65 if (fVerbose ==
nullptr) {
104 fTouchableHandle =
nullptr;
112 delete fSelectedAtRestDoItVector;
113 delete fSelectedAlongStepDoItVector;
114 delete fSelectedPostStepDoItVector;
115 delete fUserSteppingAction;
117 if (KillVerbose)
delete fVerbose;
125#ifdef GEANT4_USE_TIMEMORY
133 if (verboseLevel > 0) {
136 else if (verboseLevel == -1) {
156 fN2ndariesAtRestDoIt = 0;
157 fN2ndariesAlongStepDoIt = 0;
158 fN2ndariesPostStepDoIt = 0;
173 if (MAXofAtRestLoops > 0) {
174 InvokeAtRestDoItProcs();
193 DefinePhysicalStepLength();
198 G4double GeomStepLength = PhysicalStep;
204 InvokeAlongStepDoItProcs();
216 endpointSafety = std::max(proposedSafety - GeomStepLength, kCarTolerance);
225 InvokePostStepDoItProcs();
243 if (verboseLevel > 0) fVerbose->
StepInfo();
252 if (fSensitive !=
nullptr) {
253 fSensitive->
Hit(fStep);
259 if (fUserSteppingAction !=
nullptr) {
279 PreStepPointIsGeom =
false;
281 fParticleChange =
nullptr;
282 fPreviousStepSize = 0.;
289 GeometricalStep = 0.;
291 PreStepPointIsGeom =
false;
294 TempInitVelocity = 0.;
296 sumEnergyChange = 0.;
350 fCurrentVolume = fTouchableHandle->
GetVolume();
354 if (fCurrentVolume ==
nullptr) {
357 G4cerr <<
"ERROR - G4SteppingManager::SetInitialStep()" <<
G4endl
358 <<
" Primary particle starting at - " << fTrack->
GetPosition()
359 <<
" - is outside of the world volume." <<
G4endl;
361 "Primary vertex outside of the world!");
365 G4cout <<
"WARNING - G4SteppingManager::SetInitialStep()" <<
G4endl
366 <<
" Initial track position is outside world! - " << fTrack->
GetPosition()
384 G4cout <<
"G4SteppingManager::GetProcessNumber: is called track=" << fTrack <<
G4endl;
389 G4cerr <<
"ERROR - G4SteppingManager::GetProcessNumber()" <<
G4endl
390 <<
" ProcessManager is NULL for particle = "
394 "Process Manager is not found.");
405 G4cout <<
"G4SteppingManager::GetProcessNumber: #ofAtRest=" << MAXofAtRestLoops <<
G4endl;
415 G4cout <<
"G4SteppingManager::GetProcessNumber:#ofAlongStp=" << MAXofAlongStepLoops <<
G4endl;
425 G4cout <<
"G4SteppingManager::GetProcessNumber: #ofPostStep=" << MAXofPostStepLoops <<
G4endl;
428 if (SizeOfSelectedDoItVector < MAXofAtRestLoops ||
429 SizeOfSelectedDoItVector < MAXofAlongStepLoops ||
430 SizeOfSelectedDoItVector < MAXofPostStepLoops)
432 G4cerr <<
"ERROR - G4SteppingManager::GetProcessNumber()" <<
G4endl
433 <<
" SizeOfSelectedDoItVector= " << SizeOfSelectedDoItVector
434 <<
" ; is smaller then one of MAXofAtRestLoops= " << MAXofAtRestLoops <<
G4endl
435 <<
" or MAXofAlongStepLoops= " << MAXofAlongStepLoops
436 <<
" or MAXofPostStepLoops= " << MAXofPostStepLoops <<
G4endl;
438 "The array size is smaller than the actual No of processes.");
449void G4SteppingManager::DefinePhysicalStepLength()
463 fPostStepDoItProcTriggered = MAXofPostStepLoops;
465 for (std::size_t np = 0; np < MAXofPostStepLoops; ++np) {
466 fCurrentProcess = (*fPostStepGetPhysIntVector)((
G4int)np);
467 if (fCurrentProcess ==
nullptr) {
472 physIntLength = fCurrentProcess->
PostStepGPIL(*fTrack, fPreviousStepSize, &fCondition);
477 switch (fCondition) {
486 "This feature no more supported");
489 (*fSelectedPostStepDoItVector)[np] =
Forced;
500 for (std::size_t nrest = np + 1; nrest < MAXofPostStepLoops; ++nrest) {
501 (*fSelectedPostStepDoItVector)[nrest] =
InActivated;
506 if (physIntLength < PhysicalStep) {
507 PhysicalStep = physIntLength;
509 fPostStepDoItProcTriggered =
G4int(np);
514 if (fPostStepDoItProcTriggered < MAXofPostStepLoops) {
515 if ((*fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] ==
InActivated) {
516 (*fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] =
NotForced;
523 G4double safetyProposedToAndByProcess = proposedSafety;
524 G4bool delegateToTransportation =
false;
526 for (std::size_t kp = 0; kp < MAXofAlongStepLoops; ++kp) {
527 fCurrentProcess = (*fAlongStepGetPhysIntVector)[(
G4int)kp];
528 if (fCurrentProcess ==
nullptr)
continue;
532 *fTrack, fPreviousStepSize, PhysicalStep, safetyProposedToAndByProcess, &fGPILSelection);
537 if (physIntLength < PhysicalStep) {
538 PhysicalStep = physIntLength;
550 delegateToTransportation =
true;
555 if (kp == MAXofAlongStepLoops - 1) {
559 delegateToTransportation =
false;
566 if (safetyProposedToAndByProcess < proposedSafety) {
569 proposedSafety = safetyProposedToAndByProcess;
574 safetyProposedToAndByProcess = proposedSafety;
577 if (delegateToTransportation) {
584G4int G4SteppingManager::ProcessSecondariesFromParticleChange()
589 G4int pushedSecondaries = 0;
592 if (num2ndaries == 0) {
600 for (
G4int DSecLoop = 0; DSecLoop < num2ndaries; ++DSecLoop) {
601 tempSecondaryTrack = fParticleChange->
GetSecondary(DSecLoop);
616 ED <<
"A track without proper process manager is pushed\n"
617 <<
"into the track stack.\n"
620 G4Exception(
"G4SteppingManager::ProcessSecondariesFromParticleChange()",
"Tracking10051",
625 fSecondary->push_back(tempSecondaryTrack);
629 delete tempSecondaryTrack;
633 fSecondary->push_back(tempSecondaryTrack);
638 return pushedSecondaries;
642void G4SteppingManager::InvokeAtRestDoItProcs()
649 G4double lifeTime, shortestLifeTime;
651 fAtRestDoItProcTriggered = 0;
654 for (std::size_t ri = 0; ri < MAXofAtRestLoops; ++ri) {
655 fCurrentProcess = (*fAtRestGetPhysIntVector)[(
G4int)ri];
656 if (fCurrentProcess ==
nullptr) {
661 lifeTime = fCurrentProcess->
AtRestGPIL(*fTrack, &fCondition);
663 if (fCondition ==
Forced) {
664 (*fSelectedAtRestDoItVector)[ri] =
Forced;
668 if (lifeTime < shortestLifeTime) {
669 shortestLifeTime = lifeTime;
670 fAtRestDoItProcTriggered =
G4int(ri);
676 (*fSelectedAtRestDoItVector)[fAtRestDoItProcTriggered] =
NotForced;
685 if (shortestLifeTime < 1.0e+100)
689 for (std::size_t np = 0; np < MAXofAtRestLoops; ++np) {
694 if ((*fSelectedAtRestDoItVector)[MAXofAtRestLoops - np - 1] !=
InActivated) {
695 fCurrentProcess = (*fAtRestDoItVector)[(
G4int)np];
696 fParticleChange = fCurrentProcess->
AtRestDoIt(*fTrack, *fStep);
703 fN2ndariesAtRestDoIt += ProcessSecondariesFromParticleChange();
706 fParticleChange->Clear();
722void G4SteppingManager::InvokeAlongStepDoItProcs()
734 for (std::size_t ci = 0; ci < MAXofAlongStepLoops; ++ci) {
735 fCurrentProcess = (*fAlongStepDoItVector)[(
G4int)ci];
736 if (fCurrentProcess ==
nullptr)
continue;
739 fParticleChange = fCurrentProcess->
AlongStepDoIt(*fTrack, *fStep);
749 fN2ndariesAlongStepDoIt += ProcessSecondariesFromParticleChange();
757 fParticleChange->Clear();
764 if (MAXofAtRestLoops > 0)
773void G4SteppingManager::InvokePostStepDoItProcs()
778 for (std::size_t np = 0; np < MAXofPostStepLoops; ++np) {
783 G4int Cond = (*fSelectedPostStepDoItVector)[MAXofPostStepLoops - np - 1];
802 for (std::size_t np1 = np + 1; np1 < MAXofPostStepLoops; ++np1) {
803 G4int Cond2 = (*fSelectedPostStepDoItVector)[MAXofPostStepLoops - np1 - 1];
814void G4SteppingManager::InvokePSDIP(
size_t np)
817 fCurrentProcess = (*fPostStepDoItVector)[(
G4int)np];
818 fParticleChange = fCurrentProcess->
PostStepDoIt(*fTrack, *fStep);
834 fN2ndariesPostStepDoIt += ProcessSecondariesFromParticleChange();
840 fParticleChange->Clear();
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::vector< G4int > G4SelectedPostStepDoItVector
std::vector< G4int > G4SelectedAtRestDoItVector
std::vector< G4int > G4SelectedAlongStepDoItVector
Definition of the G4SteppingVerboseWithUnits class.
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4Region * GetRegion() const
G4TouchableHistory * CreateTouchableHistory() const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4ProcessManager * GetProcessManager() const
G4int GetPDGEncoding() const
const G4String & GetParticleName() const
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4ProcessVector * GetAtRestProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
std::size_t entries() const
G4UserSteppingAction * GetRegionalSteppingAction() const
G4StepStatus GetStepStatus() const
void SetSafety(const G4double aValue)
void SetStepStatus(const G4StepStatus aValue)
void SetProcessDefinedStep(const G4VProcess *aValue)
const G4ThreeVector & GetPosition() const
G4VSensitiveDetector * GetSensitiveDetector() const
G4VPhysicalVolume * GetPhysicalVolume() const
void DeleteSecondaryVector()
void SetPointerToVectorOfAuxiliaryPoints(std::vector< G4ThreeVector > *vec)
void InitializeStep(G4Track *aValue)
G4SteppingControl GetControlFlag() const
void ResetTotalEnergyDeposit()
void SetStepLength(G4double value)
void CopyPostToPreStepPoint()
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4TrackVector * NewSecondaryVector()
G4StepPoint * GetPostStepPoint() const
void SetTrack(G4Track *value)
void SetNavigator(G4Navigator *value)
void SetInitialStep(G4Track *valueTrack)
static G4int BestUnitPrecision()
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
G4TrackStatus GetTrackStatus() const
void SetTrackStatus(const G4TrackStatus aTrackStatus)
void SetStepLength(G4double value)
G4VPhysicalVolume * GetVolume() const
void SetVertexPosition(const G4ThreeVector &aValue)
const G4TouchableHandle & GetNextTouchableHandle() const
void SetVertexMomentumDirection(const G4ThreeVector &aValue)
G4VPhysicalVolume * GetNextVolume() const
void SetNextTouchableHandle(const G4TouchableHandle &apValue)
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4int GetCurrentStepNumber() const
void SetOriginTouchableHandle(const G4TouchableHandle &apValue)
G4ParticleDefinition * GetDefinition() const
void AddTrackLength(const G4double aValue)
const G4DynamicParticle * GetDynamicParticle() const
const G4TouchableHandle & GetTouchableHandle() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
void SetVertexKineticEnergy(const G4double aValue)
G4int GetParentID() const
void SetLogicalVolumeAtVertex(const G4LogicalVolume *)
void SetParentID(const G4int aValue)
void SetCreatorProcess(const G4VProcess *aValue)
static G4TransportationManager * GetTransportationManager()
virtual void UserSteppingAction(const G4Step *)
virtual G4Step * UpdateStepForAlongStep(G4Step *Step)
virtual G4Step * UpdateStepForAtRest(G4Step *Step)
virtual G4Step * UpdateStepForPostStep(G4Step *Step)
G4int GetNumberOfSecondaries() const
G4Track * GetSecondary(G4int anIndex) const
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetRegularStructureId() const =0
virtual G4VParticleChange * AtRestDoIt(const G4Track &track, const G4Step &stepData)=0
G4ProcessType GetProcessType() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData)=0
G4double PostStepGPIL(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
G4double AtRestGPIL(const G4Track &track, G4ForceCondition *condition)
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)=0
G4double AlongStepGPIL(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
virtual const G4VProcess * GetCreatorProcess() const
const G4String & GetProcessName() const
G4bool Hit(G4Step *aStep)
static G4VSteppingVerbose * GetInstance()
virtual void AlongStepDoItAllDone()=0
virtual G4VSteppingVerbose * Clone()
virtual void AlongStepDoItOneByOne()=0
virtual void DPSLPostStep()=0
virtual void PostStepDoItAllDone()=0
virtual void AtRestDoItInvoked()=0
virtual void DPSLAlongStep()=0
virtual void StepInfo()=0
virtual void PostStepDoItOneByOne()=0
virtual void DPSLStarted()=0
static void SetSilent(G4int fSilent)
virtual void TrackingStarted()=0
static G4VSteppingVerbose * GetMasterInstance()
virtual void SetManager(G4SteppingManager *const)