48#ifdef G4_USESMARTSTACK
61 delete userStackingAction;
66 G4cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<
G4endl;
68 G4cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<
G4endl;
75 if(numberOfAdditionalWaitingStacks>0)
77 for(
G4int i=0; i<numberOfAdditionalWaitingStacks; ++i)
79 delete additionalWaitingStacks[i];
91 ED <<
"A track without proper process manager is pushed \
92 into the track stack.\n"
96 ED <<
"created by a primary particle generator.";
107 ED <<
"creaded by unknown process.";
110 G4Exception(
"G4StackManager::PushOneTrack",
"Event10051",
117 if(userStackingAction !=
nullptr)
122 if(classification==
fKill)
125 if( verboseLevel > 1 )
127 G4cout <<
" ---> G4Track " << newTrack <<
" (trackID "
133 delete newTrajectory;
138 switch (classification)
150 G4int i = classification - 10;
151 if(i<1 || i>numberOfAdditionalWaitingStacks)
154 ED <<
"invalid classification " << classification <<
G4endl;
155 G4Exception(
"G4StackManager::PushOneTrack",
"Event0051",
160 additionalWaitingStacks[i-1]->PushToStack( newStackedTrack );
172 if( verboseLevel > 1 )
174 G4cout <<
"### pop requested out of "
182 if( verboseLevel > 1 )
185 <<
" waiting tracks are re-classified to" <<
G4endl;
189 if(numberOfAdditionalWaitingStacks>0)
191 for(
G4int i=0; i<numberOfAdditionalWaitingStacks; ++i)
195 additionalWaitingStacks[0]->TransferTo(waitingStack);
199 additionalWaitingStacks[i]->TransferTo(additionalWaitingStacks[i-1]);
203 if(userStackingAction !=
nullptr)
209 if( verboseLevel > 1 )
212 <<
" waiting tracks." <<
G4endl;
223 if( verboseLevel > 2 )
225 G4cout <<
"Selected G4StackedTrack : " << &selectedStackedTrack
226 <<
" with G4Track " << selectedStackedTrack.
GetTrack()
233 return selectedTrack;
241 if( userStackingAction ==
nullptr )
return;
250 switch (classification)
266 G4int i = classification - 10;
267 if(i<1||i>numberOfAdditionalWaitingStacks)
270 ED <<
"invalid classification " << classification <<
G4endl;
271 G4Exception(
"G4StackManager::ReClassify",
"Event0052",
276 additionalWaitingStacks[i-1]->PushToStack( aStackedTrack );
285 if(userStackingAction !=
nullptr)
295 G4int n_passedFromPrevious = 0;
300 if( verboseLevel > 1 )
303 <<
" postponed tracked are now shifted to the stack." <<
G4endl;
318 if(userStackingAction !=
nullptr)
324 classification = DefaultClassification( aTrack );
327 if(classification==
fKill)
334 aTrack->
SetTrackID(-(++n_passedFromPrevious));
335 switch (classification)
347 G4int i = classification - 10;
348 if(i<1||i>numberOfAdditionalWaitingStacks)
351 ED <<
"invalid classification " << classification <<
G4endl;
352 G4Exception(
"G4StackManager::PrepareNewEvent",
"Event0053",
357 additionalWaitingStacks[i-1]->PushToStack( aStackedTrack );
364 return n_passedFromPrevious;
369 if(iAdd > numberOfAdditionalWaitingStacks)
371 for(
G4int i=numberOfAdditionalWaitingStacks; i<iAdd; ++i)
374 additionalWaitingStacks.push_back(newStack);
376 numberOfAdditionalWaitingStacks = iAdd;
378 else if (iAdd < numberOfAdditionalWaitingStacks)
380 for(
G4int i=numberOfAdditionalWaitingStacks; i>iAdd; --i)
382 delete additionalWaitingStacks[i];
391 if(origin==destination)
return;
392 if(origin==
fKill)
return;
397 originStack =
nullptr;
400 originStack = waitingStack;
403 originStack = postponeStack;
406 G4int i = origin - 10;
407 if(i<=numberOfAdditionalWaitingStacks)
409 originStack = additionalWaitingStacks[i-1];
414 if(destination==
fKill)
416 if(originStack !=
nullptr)
431 targetStack =
nullptr;
434 targetStack = waitingStack;
437 targetStack = postponeStack;
440 G4int i = destination - 10;
441 if(i<=numberOfAdditionalWaitingStacks)
443 targetStack = additionalWaitingStacks[i-1];
447 if(originStack !=
nullptr)
449 if(targetStack !=
nullptr)
470 if(origin==destination)
return;
471 if(origin==
fKill)
return;
476 originStack =
nullptr;
479 originStack = waitingStack;
482 originStack = postponeStack;
485 G4int i = origin - 10;
486 if(i<=numberOfAdditionalWaitingStacks)
488 originStack = additionalWaitingStacks[i-1];
494 if(destination==
fKill)
496 if( originStack !=
nullptr && (originStack->
GetNTrack() != 0u) )
502 else if (urgentStack->
GetNTrack() != 0u )
515 targetStack =
nullptr;
518 targetStack = waitingStack;
521 targetStack = postponeStack;
524 G4int i = destination - 10;
525 if(i<=numberOfAdditionalWaitingStacks)
527 targetStack = additionalWaitingStacks[i-1];
531 if((originStack !=
nullptr) && (originStack->
GetNTrack() != 0u))
534 if(targetStack !=
nullptr) { targetStack->
PushToStack(aStackedTrack); }
540 if(targetStack !=
nullptr) { targetStack->
PushToStack(aStackedTrack); }
551 for(
G4int i=1; i<=numberOfAdditionalWaitingStacks; ++i)
570 if(i<=numberOfAdditionalWaitingStacks)
572 additionalWaitingStacks[i-1]->clearAndDestroy();
587 for(
G4int i=1; i<=numberOfAdditionalWaitingStacks; ++i)
589 n += additionalWaitingStacks[i-1]->GetNTrack();
606 if(i<=numberOfAdditionalWaitingStacks)
608 return (
G4int)additionalWaitingStacks[i-1]->GetNTrack();
621 verboseLevel = value;
626 userStackingAction = value;
627 if(userStackingAction !=
nullptr)
634DefaultClassification(
G4Track* aTrack)
641 return classification;
G4ClassificationOfNewTrack
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
G4int GetParticleDefinitionID() const
const G4String & GetParticleName() const
G4int GetNTotalTrack() const
void TransferOneStackedTrack(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
G4int GetNUrgentTrack() const
G4int GetNPostponedTrack() const
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
void SetVerboseLevel(G4int const value)
G4Track * PopNextTrack(G4VTrajectory **newTrajectory)
G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory=nullptr)
void ClearWaitingStack(G4int i=0)
void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
void SetUserStackingAction(G4UserStackingAction *value)
void ClearPostponeStack()
G4int GetNWaitingTrack(G4int i=0) const
G4Track * GetTrack() const
G4VTrajectory * GetTrajectory() const
void PushToStack(const G4StackedTrack &aStackedTrack)
void TransferTo(G4TrackStack *aStack)
std::size_t GetNTrack() const
G4StackedTrack PopFromStack()
std::size_t GetMaxNTrack() const
G4TrackStatus GetTrackStatus() const
const G4ParticleDefinition * GetParticleDefinition() const
const G4VProcess * GetCreatorProcess() const
void SetTrackID(const G4int aValue)
G4int GetParentID() const
void SetParentID(const G4int aValue)
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
virtual void PrepareNewEvent()
void SetStackManager(G4StackManager *value)
const G4String & GetProcessName() const