58 static const size_t SizeOfSelectedDoItVector=100;
68 fpTrackingManager = 0;
77 G4ITStepProcessor::G4ITStepProcessorState::G4ITStepProcessorState() :
79 fSelectedAtRestDoItVector (gMaxNProcesses,0),
80 fSelectedPostStepDoItVector (gMaxNProcesses,0)
83 fPreviousStepSize = -1.;
95 G4ITStepProcessor::G4ITStepProcessorState::G4ITStepProcessorState(
const G4ITStepProcessorState& ) :
97 fSelectedAtRestDoItVector (gMaxNProcesses,0),
98 fSelectedPostStepDoItVector (gMaxNProcesses,0)
101 fPreviousStepSize = -1.;
104 proposedSafety = -1.;
109 fTouchableHandle = 0;
113 G4ITStepProcessor::G4ITStepProcessorState& G4ITStepProcessor::G4ITStepProcessorState::operator=(
const G4ITStepProcessorState& rhs)
115 if(
this == &rhs)
return *
this;
117 fSelectedAtRestDoItVector.clear();
118 fSelectedAtRestDoItVector.resize(gMaxNProcesses,0);
119 fSelectedPostStepDoItVector.clear();
120 fSelectedPostStepDoItVector.resize(gMaxNProcesses,0);
123 fPreviousStepSize = -1.;
126 proposedSafety = -1.;
131 fTouchableHandle = 0;
136 G4ITStepProcessor::G4ITStepProcessorState::~G4ITStepProcessorState()
142 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*> ::iterator it;
144 for(it = fProcessGeneralInfoMap.begin();it != fProcessGeneralInfoMap.end();it++)
153 fProcessGeneralInfoMap.clear();
160 fInitialized =
false;
170 if(fInitialized)
return;
174 ->GetNavigatorForTracking());
191 if(fpSecondary)
delete fpSecondary;
201 verboseLevel = rhs.verboseLevel ;
202 fStoreTrajectory = rhs.fStoreTrajectory ;
205 fpTrackingManager = 0;
207 fInitialized =
false;
209 kCarTolerance = rhs.kCarTolerance;
210 fInitialized =
false;
220 if (
this == &rhs)
return *
this;
230 G4cout<<
"G4ITStepProcessor::CloneProcesses: is called"<<
G4endl;
236 theParticleIterator->
reset();
238 while( (*theParticleIterator)() )
245 G4cerr <<
"ERROR - G4ITStepProcessor::GetProcessNumber()" << G4endl
246 <<
" ProcessManager is NULL for particle = "
249 G4Exception(
"G4ITStepProcessor::GetProcessNumber()",
"ITStepProcessor0001",
265 for(
int i = 0 ; i < processVector->
size() ; i++)
267 G4VProcess* base_process = (*processVector)[i];
282 G4cout<<
"G4ITStepProcessor::GetProcessNumber: is called track"<<
G4endl;
286 G4cerr <<
"ERROR - G4SteppingManager::GetProcessNumber()" << G4endl
287 <<
" ProcessManager is NULL for particle = "
290 G4Exception(
"G4SteppingManager::GetProcessNumber()",
"ITStepProcessor0002",
295 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it = fProcessGeneralInfoMap.find(particle);
296 if(it != fProcessGeneralInfoMap.end())
298 G4Exception(
"G4SteppingManager::SetupGeneralProcessInfo()",
"ITStepProcessor0003",
304 fpProcessInfo =
new ProcessGeneralInfo();
311 G4cout <<
"G4ITStepProcessor::GetProcessNumber: #ofAtRest="
312 << fpProcessInfo->MAXofAtRestLoops <<
G4endl;
320 G4cout <<
"G4ITStepProcessor::GetProcessNumber:#ofAlongStp="
321 << fpProcessInfo->MAXofAlongStepLoops <<
G4endl;
329 G4cout <<
"G4ITStepProcessor::GetProcessNumber: #ofPostStep="
330 << fpProcessInfo->MAXofPostStepLoops <<
G4endl;
333 if (SizeOfSelectedDoItVector<fpProcessInfo->MAXofAtRestLoops ||
334 SizeOfSelectedDoItVector<fpProcessInfo->MAXofAlongStepLoops ||
335 SizeOfSelectedDoItVector<fpProcessInfo->MAXofPostStepLoops )
337 G4cerr <<
"ERROR - G4ITStepProcessor::GetProcessNumber()" << G4endl
338 <<
" SizeOfSelectedDoItVector= " << SizeOfSelectedDoItVector
339 <<
" ; is smaller then one of MAXofAtRestLoops= "
340 << fpProcessInfo->MAXofAtRestLoops << G4endl
341 <<
" or MAXofAlongStepLoops= " << fpProcessInfo->MAXofAlongStepLoops
342 <<
" or MAXofPostStepLoops= " << fpProcessInfo->MAXofPostStepLoops <<
G4endl;
343 G4Exception(
"G4ITStepProcessor::GetProcessNumber()",
345 "The array size is smaller than the actual No of processes.");
348 if(!fpProcessInfo->fpAtRestDoItVector &&
349 !fpProcessInfo->fpAlongStepDoItVector &&
350 !fpProcessInfo->fpPostStepDoItVector)
353 exceptionDescription <<
"No DoIt process found " ;
354 G4Exception(
"G4ITStepProcessor::DoStepping",
"ITStepProcessor0005",
359 if(fpProcessInfo->fpAlongStepGetPhysIntVector && fpProcessInfo->MAXofAlongStepLoops>0)
362 ((*fpProcessInfo->fpAlongStepGetPhysIntVector)[fpProcessInfo->MAXofAlongStepLoops-1]);
364 if(fpProcessInfo->fpTransportation == 0)
367 exceptionDescription <<
"No transportation process found " ;
368 G4Exception(
"G4ITStepProcessor::SetupGeneralProcessInfo",
"ITStepProcessor0006",
372 fProcessGeneralInfoMap[particle] = fpProcessInfo;
383 fpITrack =
GetIT(fpTrack) ;
395 G4ExceptionDescription exceptionDescription (
"No IT pointer was attached to the track you try to process.");
396 G4Exception(
"G4ITStepProcessor::SetTrack",
"ITStepProcessor0007",
411 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it = fProcessGeneralInfoMap.find(particle);
413 if(it == fProcessGeneralInfoMap.end())
416 if(fpProcessInfo == 0)
419 G4Exception(
"G4ITStepProcessor::GetProcessNumber",
"ITStepProcessor0008",
426 fpProcessInfo = it->second;
447 fN2ndariesAtRestDoIt = 0;
448 fN2ndariesAlongStepDoIt = 0;
449 fN2ndariesPostStepDoIt = 0;
460 fAtRestDoItProcTriggered = 0;
463 unsigned int NofInactiveProc=0;
465 for(
size_t ri=0 ; ri < fpProcessInfo->MAXofAtRestLoops ; ri++ )
467 fpCurrentProcess = (
G4VITProcess*) (*fpProcessInfo->fpAtRestGetPhysIntVector)[ri];
468 if (fpCurrentProcess== 0)
470 (fpState->fSelectedAtRestDoItVector)[ri] =
InActivated;
477 lifeTime = fpCurrentProcess->
AtRestGPIL( *fpTrack, &fCondition );
482 (fpState->fSelectedAtRestDoItVector)[ri] =
Forced;
486 (fpState->fSelectedAtRestDoItVector)[ri] =
InActivated;
487 if(lifeTime < shortestLifeTime )
489 shortestLifeTime = lifeTime;
490 fAtRestDoItProcTriggered =
G4int(ri);
491 (fpState->fSelectedAtRestDoItVector)[fAtRestDoItProcTriggered] =
NotForced;
496 fTimeStep = shortestLifeTime ;
500 if(NofInactiveProc==fpProcessInfo->MAXofAtRestLoops)
502 G4cerr <<
"ERROR - G4ITStepProcessor::InvokeAtRestDoItProcs()" <<
G4endl
503 <<
" No AtRestDoIt process is active!" <<
G4endl;
528 &direction,
false, false );
551 fpCurrentVolume = fpState->fTouchableHandle->GetVolume();
579 if( fpCurrentVolume==0 )
584 G4cerr <<
"ERROR - G4ITStepProcessor::SetInitialStep()" <<
G4endl
585 <<
" Primary particle starting at - "
587 <<
" - is outside of the world volume." <<
G4endl;
588 G4Exception(
"G4ITStepProcessor::SetInitialStep()",
"ITStepProcessor0011",
593 G4cout <<
"WARNING - G4ITStepProcessor::SetInitialStep()" <<
G4endl
594 <<
" Initial track position is outside world! - "
623 fpState =
new G4ITStepProcessorState();
722 fpState->fPhysicalStep =
DBL_MAX;
725 double proposedTimeStep =
DBL_MAX;
726 G4VProcess* processWithPostStepGivenByTimeStep(0);
729 fPostStepDoItProcTriggered = fpProcessInfo->MAXofPostStepLoops;
730 fPostStepAtTimeDoItProcTriggered = fpProcessInfo->MAXofPostStepLoops;
736 for(
size_t np=0; np < fpProcessInfo->MAXofPostStepLoops; np++)
738 fpCurrentProcess = (
G4VITProcess*) (*fpProcessInfo->fpPostStepGetPhysIntVector)[np];
739 if (fpCurrentProcess== 0)
741 (fpState->fSelectedPostStepDoItVector)[np] =
InActivated;
749 fPhysIntLength = fpCurrentProcess->
750 PostStepGPIL( *fpTrack,
751 fpState->fPreviousStepSize,
766 G4Exception(
"G4ITStepProcessor::DefinePhysicalStepLength()",
"ITStepProcessor0008",
771 (fpState->fSelectedPostStepDoItVector)[np] =
Forced;
779 (fpState->fSelectedPostStepDoItVector)[np] =
InActivated;
785 for(
size_t nrest=np+1; nrest < fpProcessInfo->MAXofPostStepLoops; nrest++)
787 (fpState->fSelectedPostStepDoItVector)[nrest] =
InActivated;
793 if(fPhysIntLength < fpState->fPhysicalStep )
800 fPhysIntLength *= -1;
801 if(fPhysIntLength < proposedTimeStep)
803 proposedTimeStep = fPhysIntLength;
804 fPostStepAtTimeDoItProcTriggered = np;
805 processWithPostStepGivenByTimeStep = fpCurrentProcess;
810 fpState->fPhysicalStep = fPhysIntLength;
812 fPostStepDoItProcTriggered =
G4int(np);
821 fpState->proposedSafety =
DBL_MAX;
822 G4double safetyProposedToAndByProcess = fpState->proposedSafety;
824 for(
size_t kp=0; kp < fpProcessInfo->MAXofAlongStepLoops; kp++)
826 fpCurrentProcess = (
G4VITProcess*) (*fpProcessInfo->fpAlongStepGetPhysIntVector)[kp];
827 if (fpCurrentProcess== 0)
continue;
831 fPhysIntLength = fpCurrentProcess-> AlongStepGPIL( *fpTrack,
832 fpState->fPreviousStepSize,
833 fpState->fPhysicalStep,
834 safetyProposedToAndByProcess,
837 if(fPhysIntLength < fpState->fPhysicalStep)
839 fpState->fPhysicalStep = fPhysIntLength;
852 if(kp == fpProcessInfo->MAXofAlongStepLoops-1)
856 if(! fpTransportation)
859 exceptionDescription <<
"No transportation process found " ;
860 G4Exception(
"G4ITStepProcessor::DoDefinePhysicalStepLength",
"ITStepProcessor0009",
875 if(kp == fpProcessInfo->MAXofAlongStepLoops-1)
879 if(! fpTransportation)
882 exceptionDescription <<
"No transportation process found " ;
883 G4Exception(
"G4ITStepProcessor::DoDefinePhysicalStepLength",
"ITStepProcessor0010",
891 if(proposedTimeStep < fTimeStep)
893 if(fPostStepAtTimeDoItProcTriggered<fpProcessInfo->MAXofPostStepLoops)
895 if ((fpState->fSelectedPostStepDoItVector)[fPostStepAtTimeDoItProcTriggered] ==
898 (fpState->fSelectedPostStepDoItVector)[fPostStepAtTimeDoItProcTriggered] =
NotForced;
904 fTimeStep = proposedTimeStep;
906 fpTransportation->
ComputeStep(*fpTrack,*fpStep,fTimeStep,fpState->fPhysicalStep);
912 if (fPostStepDoItProcTriggered<fpProcessInfo->MAXofPostStepLoops)
914 if ((fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] ==
917 (fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] =
928 if (safetyProposedToAndByProcess < fpState->proposedSafety)
930 fpState->proposedSafety = safetyProposedToAndByProcess;
933 safetyProposedToAndByProcess = fpState->proposedSafety;