00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "G4ErrorTrackLengthTarget.hh"
00034
00035 #include "G4ParticleTable.hh"
00036 #include "G4ParticleDefinition.hh"
00037 #include "G4VProcess.hh"
00038 #include "G4ProcessVector.hh"
00039 #include "G4ProcessManager.hh"
00040
00041 #ifdef G4VERBOSE
00042 #include "G4ErrorPropagatorData.hh"
00043 #endif
00044
00045
00046 G4ErrorTrackLengthTarget::
00047 G4ErrorTrackLengthTarget(const G4double maxTrkLength )
00048 : G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
00049 theMaximumTrackLength( maxTrkLength )
00050 {
00051 theType = G4ErrorTarget_TrkL;
00052
00053 G4ParticleTable::G4PTblDicIterator* theParticleIterator
00054 = G4ParticleTable::GetParticleTable()->GetIterator();
00055
00056
00057
00058 theParticleIterator->reset();
00059 while( (*theParticleIterator)() )
00060 {
00061 G4ParticleDefinition* particle = theParticleIterator->value();
00062 G4ProcessManager* pmanager = particle->GetProcessManager();
00063 if (!particle->IsShortLived())
00064 {
00065
00066 if ( pmanager == 0)
00067 {
00068
00069 G4String particleName = particle->GetParticleName();
00070 G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
00071 "No process manager", RunMustBeAborted, particleName );
00072 }
00073 else
00074 {
00075 G4ProcessVector* procvec = pmanager->GetProcessList();
00076 size_t isiz = procvec->size();
00077
00078 for( size_t ii=0; ii < isiz; ii++ )
00079 {
00080 if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
00081 {
00082 pmanager->RemoveProcess( (*procvec)[ii] );
00083 }
00084 }
00085 pmanager ->AddDiscreteProcess(this,4);
00086 isiz = procvec->size();
00087 }
00088 }
00089 else
00090 {
00091
00092 }
00093 }
00094 }
00095
00096
00097
00098 G4double G4ErrorTrackLengthTarget::
00099 PostStepGetPhysicalInteractionLength(const G4Track& track, G4double,
00100 G4ForceCondition* condition )
00101 {
00102 *condition = NotForced;
00103 return GetMeanFreePath( track, 0., condition );
00104 }
00105
00106
00107
00108 G4double G4ErrorTrackLengthTarget::
00109 GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
00110 {
00111 #ifdef G4VERBOSE
00112 if(G4ErrorPropagatorData::verbose() >= 3 )
00113 {
00114 G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
00115 << theMaximumTrackLength - track.GetTrackLength() << G4endl;
00116 }
00117 #endif
00118
00119 return theMaximumTrackLength - track.GetTrackLength();
00120 }
00121
00122
00123 G4VParticleChange* G4ErrorTrackLengthTarget::
00124 PostStepDoIt(const G4Track& aTrack, const G4Step& )
00125 {
00126 theParticleChange.Initialize(aTrack);
00127 return &theParticleChange;
00128 }
00129
00130
00131
00132 void G4ErrorTrackLengthTarget::Dump( const G4String& msg ) const
00133 {
00134 G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
00135 << theMaximumTrackLength << G4endl;
00136 }