Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ErrorTrackLengthTarget.cc
Go to the documentation of this file.
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 91809 2015-08-06 13:00:09Z gcosmo $
27 //
28 // ------------------------------------------------------------
29 // GEANT 4 class implementation file
30 // ------------------------------------------------------------
31 //
32 
34 
35 #include "G4ParticleTable.hh"
36 #include "G4ParticleDefinition.hh"
37 #include "G4VProcess.hh"
38 #include "G4ProcessVector.hh"
39 #include "G4ProcessManager.hh"
40 
41 #ifdef G4VERBOSE
42 #include "G4ErrorPropagatorData.hh" //for verbosity checking
43 #endif
44 
45 //----------------------------------------------------------------------------
47 G4ErrorTrackLengthTarget(const G4double maxTrkLength )
48  : G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
49  theMaximumTrackLength( maxTrkLength )
50 {
52 
55 
56  // loop over all particles in G4ParticleTable
57 
58  theParticleIterator->reset();
59  while( (*theParticleIterator)() ) // Loop checking, 06.08.2015, G.Cosmo
60  {
61  G4ParticleDefinition* particle = theParticleIterator->value();
62  G4ProcessManager* pmanager = particle->GetProcessManager();
63  if (!particle->IsShortLived())
64  {
65  // Add transportation process for all particles other than "shortlived"
66  if ( pmanager == 0)
67  {
68  // Error !! no process manager
69  G4String particleName = particle->GetParticleName();
70  G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
71  "No process manager", RunMustBeAborted, particleName );
72  }
73  else
74  {
75  G4ProcessVector* procvec = pmanager->GetProcessList();
76  size_t isiz = procvec->size();
77 
78  for( size_t ii=0; ii < isiz; ii++ )
79  {
80  if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
81  {
82  pmanager->RemoveProcess( (*procvec)[ii] );
83  }
84  }
85  pmanager ->AddDiscreteProcess(this,4);
86  isiz = procvec->size();
87  }
88  }
89  else
90  {
91  // shortlived particle case
92  }
93  }
94 }
95 
96 
97 //-----------------------------------------------------------------------
101 {
102  *condition = NotForced;
103  return GetMeanFreePath( track, 0., condition );
104 }
105 
106 
107 //-----------------------------------------------------------------------
109 GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
110 {
111 #ifdef G4VERBOSE
113  {
114  G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
115  << theMaximumTrackLength - track.GetTrackLength() << G4endl;
116  }
117 #endif
118 
119  return theMaximumTrackLength - track.GetTrackLength();
120 }
121 
122 
124 PostStepDoIt(const G4Track& aTrack, const G4Step& )
125 {
126  theParticleChange.Initialize(aTrack);
127  return &theParticleChange;
128 }
129 
130 
131 //-----------------------------------------------------------------------
132 void G4ErrorTrackLengthTarget::Dump( const G4String& msg ) const
133 {
134  G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
135  << theMaximumTrackLength << G4endl;
136 }
G4double condition(const G4ErrorSymMatrix &m)
virtual void Initialize(const G4Track &)
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
virtual void Dump(const G4String &msg) const
const G4String & GetParticleName() const
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
virtual G4double GetMeanFreePath(const class G4Track &track, G4double, G4ForceCondition *)
G4GLOB_DLL std::ostream G4cout
void reset(G4bool ifSkipIon=true)
#define theParticleIterator
Definition: G4Step.hh:76
G4ErrorTrackLengthTarget(const G4double maxTrkLength)
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4double GetTrackLength() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int size() const
G4ErrorTargetType theType
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
static G4ParticleTable * GetParticleTable()
G4ProcessManager * GetProcessManager() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4ForceCondition
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4PTblDicIterator * GetIterator() const
G4ProcessVector * GetProcessList() const