76#define State(theXInfo) (fTransportationState->theXInfo)
84 fThreshold_Warning_Energy( 100 * MeV ),
85 fThreshold_Important_Energy( 250 * MeV ),
86 fThresholdTrials( 10 ),
87 fUnimportant_Energy( 1 * MeV ),
88 fSumEnergyKilled( 0.0 ), fMaxEnergyKilled( 0.0 ),
89 fShortStepOptimisation(false),
90 fVerboseLevel( verbose )
112 fInstantiateProcessState =
true;
151 fInstantiateProcessState = right.fInstantiateProcessState;
156 if(
this == &right)
return *
this;
164 fCurrentTouchableHandle(0)
194 G4cout <<
" G4ITTransportation: Statistics for looping particles " <<
G4endl;
225 G4double geometryStepLength(-1.0), newSafety(-1.0) ;
227 State(fParticleIsLooping) = false ;
228 State(fEndGlobalTimeComputed) = false ;
229 State(fGeometryLimitedStep) = false ;
257 if( MagSqShift >=
sqr(
State(fPreviousSafety)) )
259 currentSafety = 0.0 ;
263 currentSafety =
State(fPreviousSafety) - std::sqrt(MagSqShift) ;
278 G4bool fieldExertsForce = false ;
279 if( (particleCharge != 0.0) )
300 if( !fieldExertsForce )
307 geometryStepLength = currentMinimumStep ;
308 State(fGeometryLimitedStep) = false ;
320 State(fPreviousSftOrigin) = startPosition ;
321 State(fPreviousSafety) = newSafety ;
326 currentSafety = newSafety ;
328 State(fGeometryLimitedStep)= (linearStepLength <= currentMinimumStep);
329 if(
State(fGeometryLimitedStep) )
332 geometryStepLength = linearStepLength ;
337 geometryStepLength = currentMinimumStep ;
340 State(endpointDistance) = geometryStepLength ;
344 State(fTransportEndPosition) = startPosition+geometryStepLength*startMomentumDir ;
348 State(fTransportEndMomentumDir) = startMomentumDir ;
351 State(fParticleIsLooping) = false ;
352 State(fMomentumChanged) = false ;
353 State(fEndGlobalTimeComputed) = true ;
367 exceptionDescription <<
"ITTransportation does not support external fields.";
368 exceptionDescription <<
" If you are dealing with a tradiational MC simulation, ";
369 exceptionDescription <<
"please use G4Transportation.";
371 G4Exception(
"G4ITTransportation::AlongStepGetPhysicalInteractionLength",
"NoExternalFieldSupport",
520 if( currentMinimumStep == 0.0 )
522 if( currentSafety == 0.0 )
524 State(fGeometryLimitedStep) = true ;
533 if( currentSafety <
State(endpointDistance) )
538 if( particleCharge != 0.0 )
543 currentSafety = endSafety ;
544 State(fPreviousSftOrigin) =
State(fTransportEndPosition) ;
545 State(fPreviousSafety) = currentSafety ;
551 currentSafety +=
State(endpointDistance) ;
553#ifdef G4DEBUG_TRANSPORT
555 G4cout <<
"***G4Transportation::AlongStepGPIL ** " <<
G4endl ;
556 G4cout <<
" Called Navigator->ComputeSafety at " <<
State(fTransportEndPosition)
557 <<
" and it returned safety= " << endSafety <<
G4endl ;
558 G4cout <<
" Adding endpoint distance " <<
State(endpointDistance)
559 <<
" to obtain pseudo-safety= " << currentSafety <<
G4endl ;
566 return geometryStepLength ;
572 const double timeStep,
573 double& oPhysicalStep)
582 State(fGeometryLimitedStep) =
false;
588 State(fEndGlobalTimeComputed) = true ;
592 if( !
State(fMomentumChanged) )
596 oPhysicalStep = initialVelocity*timeStep ;
600 State(fTransportEndPosition) = startPosition + oPhysicalStep*startMomentumDir ;
619 static G4int noCalls=0;
643 if (
State(fEndGlobalTimeComputed) ==
false)
656 deltaTime = stepLength/finalVelocity ;
658 else if( initialVelocity > 0.0 )
660 deltaTime = stepLength/initialVelocity ;
663 State(fCandidateEndGlobalTime) = startTime + deltaTime ;
667 deltaTime =
State(fCandidateEndGlobalTime) - startTime ;
690 if (
State(fParticleIsLooping) )
713 G4cout <<
" G4ITTransportation is killing track that is looping or stuck "
716 <<
" MeV energy." <<
G4endl;
717 G4cout <<
" Number of trials = " <<
State(fNoLooperTrials)
718 <<
" No of calls to AlongStepDoIt = " << noCalls
722 State(fNoLooperTrials)=0;
726 State(fNoLooperTrials) ++;
730 G4cout <<
" G4ITTransportation::AlongStepDoIt(): Particle looping - "
731 <<
" Number of trials = " <<
State(fNoLooperTrials)
732 <<
" No of calls to = " << noCalls
740 State(fNoLooperTrials)=0;
790 if(
State(fGeometryLimitedStep))
799 if(
State(fCurrentTouchableHandle)->GetVolume() == 0 )
802 exceptionDescription <<
"No current touchable found " ;
803 G4Exception(
" G4ITTransportation::PostStepDoIt",
"G4ITTransportation001",
809 LocateGlobalPointAndUpdateTouchableHandle( track.
GetPosition(),
811 State(fCurrentTouchableHandle),
816 if(
State(fCurrentTouchableHandle)->GetVolume() == 0 )
823 G4cout <<
"G4ITTransportation will killed the track because State(fCurrentTouchableHandle)->GetVolume() == 0"<<
G4endl;
829 retCurrentTouchable =
State(fCurrentTouchableHandle) ;
844#ifdef G4DEBUG_TRANSPORT
849 if( ! (exiting || entering) )
851 G4cout <<
" Transport> : Proposed isLastStep= " << isLastStep
854 <<
" Track position : " << track.
GetPosition() /nanometer <<
" [nm]"
875#ifdef G4DEBUG_TRANSPORT
877 G4cout <<
" Transport> Proposed isLastStep= " << isLastStep
878 <<
" Geometry did not limit step. Position : "
907 if( pNewVol!=0 && pNewMaterialCutsCouple!=0 && pNewMaterialCutsCouple->
GetMaterial()!=pNewMaterial )
911 pNewMaterialCutsCouple =
936 if(fInstantiateProcessState)
CLHEP::Hep3Vector G4ThreeVector
#define InitProcessState(destination, source)
G4DLLIMPORT std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
G4double GetCharge() const
static G4FieldManagerStore * GetInstance()
void ClearAllChordFindersState()
virtual void ConfigureForTrack(const G4Track *)
const G4Field * GetDetectorField() const
G4bool DoesFieldExist() const
G4bool ExitedMotherVolume() const
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
G4bool EnteredDaughterVolume() const
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
void SetGeometricallyLimitedStep()
G4ITNavigator * GetNavigatorForTracking()
static G4ITTransportationManager * GetTransportationManager()
G4double fMaxEnergyKilled
G4ParticleChangeForTransport fParticleChange
G4double fUnimportant_Energy
G4double fThreshold_Important_Energy
G4SafetyHelper * fpSafetyHelper
G4double fSumEnergyKilled
virtual void ComputeStep(const G4Track &, const G4Step &, const double timeStep, double &spaceStep)
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double, G4ForceCondition *pForceCond)
void SetInstantiateProcessState(G4bool flag)
G4PropagatorInField * fFieldPropagator
G4bool DoesGlobalFieldExist()
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)
virtual ~G4ITTransportation()
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double, G4double currentMinimumStep, G4double ¤tSafety, G4GPILSelection *selection)
G4bool fShortStepOptimisation
G4double fThreshold_Warning_Energy
G4ITNavigator * fLinearNavigator
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &)
G4ITTransportation(const G4String &aName="ITTransportation", G4int verbosityLevel=1)
virtual void StartTracking(G4Track *aTrack)
G4VSensitiveDetector * GetSensitiveDetector() const
G4Material * GetMaterial() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
void SetMaterialInTouchable(G4Material *fMaterial)
void SetTouchableHandle(const G4TouchableHandle &fTouchable)
void SetMaterialCutsCoupleInTouchable(const G4MaterialCutsCouple *fMaterialCutsCouple)
void SetPointerToVectorOfAuxiliaryPoints(std::vector< G4ThreeVector > *theNewVectorPointer)
virtual void Initialize(const G4Track &)
void SetSensitiveDetectorInTouchable(G4VSensitiveDetector *fSensitiveDetector)
void SetMomentumChanged(G4bool b)
void ProposePolarization(G4double Px, G4double Py, G4double Pz)
void ProposePosition(G4double x, G4double y, G4double z)
void ProposeLocalTime(G4double t)
void ProposeVelocity(G4double finalVelocity)
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
void ProposeGlobalTime(G4double t)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static G4ProductionCutsTable * GetProductionCutsTable()
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
void ClearPropagatorState()
std::vector< G4ThreeVector > * GimmeTrajectoryVectorAndForgetIt() const
void SetCurrentSafety(G4double val, const G4ThreeVector &pos)
G4double GetVelocity() const
G4StepPoint * GetPreStepPoint() const
G4TrackStatus GetTrackStatus() const
G4double GetVelocity() const
G4double CalculateVelocityForOpticalPhoton() const
const G4ParticleDefinition * GetParticleDefinition() const
G4VPhysicalVolume * GetVolume() const
const G4ThreeVector & GetPosition() const
G4double GetGlobalTime() const
G4double GetLocalTime() const
const G4DynamicParticle * GetDynamicParticle() const
const G4TouchableHandle & GetTouchableHandle() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
G4double CalculateVelocity() const
const G4ThreeVector & GetPolarization() const
G4double GetStepLength() const
static G4TransportationManager * GetTransportationManager()
G4PropagatorInField * GetPropagatorInField() const
G4FieldManager * GetFieldManager() const
virtual void StartTracking(G4Track *)
void SetInstantiateProcessState(G4bool flag)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLastStepInVolume(G4bool flag)
G4LogicalVolume * GetLogicalVolume() const
G4bool enableAlongStepDoIt
void SetProcessSubType(G4int)
virtual void StartTracking(G4Track *)
G4bool enablePostStepDoIt
G4VParticleChange * pParticleChange
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription
G4TouchableHandle fCurrentTouchableHandle
G4bool fParticleIsLooping
G4double endpointDistance
virtual ~G4ITTransportationState()
G4ThreeVector fPreviousSftOrigin
G4ThreeVector fTransportEndMomentumDir
G4ITTransportationState()
Process State.
G4double fCandidateEndGlobalTime
G4ThreeVector fTransportEndPosition
G4double fTransportEndKineticEnergy
G4bool fEndGlobalTimeComputed
G4bool fGeometryLimitedStep
G4ThreeVector fTransportEndSpin