source: trunk/source/error_propagation/src/G4ErrorTrackLengthTarget.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 5.1 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// $Id: G4ErrorTrackLengthTarget.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
27// GEANT4 tag $Name: geant4-09-04-beta-01 $
28//
29// ------------------------------------------------------------
30//      GEANT 4 class implementation file
31// ------------------------------------------------------------
32//
33
34#include "G4ErrorTrackLengthTarget.hh"
35
36#include "G4ParticleTable.hh"
37#include "G4ParticleDefinition.hh"
38#include "G4VProcess.hh"
39#include "G4ProcessVector.hh"
40#include "G4ProcessManager.hh"
41
42#ifdef G4VERBOSE
43#include "G4ErrorPropagatorData.hh" //for verbosity checking
44#endif
45
46//----------------------------------------------------------------------------
47G4ErrorTrackLengthTarget::
48G4ErrorTrackLengthTarget(const G4double maxTrkLength )
49  : G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
50    theMaximumTrackLength( maxTrkLength )
51{
52  theType = G4ErrorTarget_TrkL;
53
54   G4ParticleTable::G4PTblDicIterator* theParticleIterator
55     = G4ParticleTable::GetParticleTable()->GetIterator();
56
57  // loop over all particles in G4ParticleTable
58
59  theParticleIterator->reset();
60  while( (*theParticleIterator)() )
61  {
62    G4ParticleDefinition* particle = theParticleIterator->value();
63    G4ProcessManager* pmanager = particle->GetProcessManager();
64    if (!particle->IsShortLived())
65    {
66      // Add transportation process for all particles other than  "shortlived"
67      if ( pmanager == 0)
68      {
69        // Error !! no process manager
70        G4String particleName = particle->GetParticleName();
71        G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
72                    "No process manager", RunMustBeAborted, particleName );
73      }
74      else
75      {
76        G4ProcessVector* procvec = pmanager->GetProcessList();
77        size_t isiz = procvec->size();
78        G4bool processAlreadyDefined = false;
79
80        for( size_t ii=0; ii < isiz; ii++ )
81        {
82          if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
83          {
84            pmanager->RemoveProcess( (*procvec)[ii] );
85            processAlreadyDefined = true;
86          }
87        }
88        pmanager ->AddDiscreteProcess(this,4);
89        isiz = procvec->size();
90      }
91    }
92    else
93    {
94      // shortlived particle case
95    }
96  }
97}
98
99
100//-----------------------------------------------------------------------
101G4double G4ErrorTrackLengthTarget::
102PostStepGetPhysicalInteractionLength(const G4Track& track, G4double,
103                                     G4ForceCondition* condition )
104{
105  *condition = NotForced;
106  return GetMeanFreePath( track, 0., condition );
107}
108
109
110//-----------------------------------------------------------------------
111G4double G4ErrorTrackLengthTarget::
112GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
113{
114#ifdef G4VERBOSE
115  if(G4ErrorPropagatorData::verbose() >= 3 )
116  { 
117    G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
118           << theMaximumTrackLength - track.GetTrackLength() << G4endl;
119  }
120#endif
121
122  return theMaximumTrackLength - track.GetTrackLength();
123}
124
125
126G4VParticleChange* G4ErrorTrackLengthTarget::
127PostStepDoIt(const G4Track& aTrack, const G4Step& )
128{
129  G4ParticleChange* aParticleChange = new G4ParticleChange;
130  aParticleChange->Initialize(aTrack);
131  return aParticleChange;
132}
133
134
135//-----------------------------------------------------------------------
136void G4ErrorTrackLengthTarget::Dump( const G4String& msg ) const
137{
138  G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
139         << theMaximumTrackLength << G4endl;
140}
Note: See TracBrowser for help on using the repository browser.