40:userStackingAction(0),verboseLevel(0),numberOfAdditionalWaitingStacks(0)
43#ifdef G4_USESMARTSTACK
56 if(userStackingAction)
delete userStackingAction;
60 G4cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<
G4endl;
62 G4cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<
G4endl;
68 if(numberOfAdditionalWaitingStacks>0) {
69 for(
int i=0;i<numberOfAdditionalWaitingStacks;i++) {
70 delete additionalWaitingStacks[i];
85 if(userStackingAction)
88 { classification = DefaultClassification( newTrack ); }
90 if(classification==
fKill)
93 if( verboseLevel > 1 )
95 G4cout <<
" ---> G4Track " << newTrack <<
" (trackID "
101 delete newTrajectory;
106 switch (classification)
118 G4int i = classification - 10;
119 if(i<1||i>numberOfAdditionalWaitingStacks) {
121 ED <<
"invalid classification " << classification <<
G4endl;
122 G4Exception(
"G4StackManager::PushOneTrack",
"Event0051",
125 additionalWaitingStacks[i-1]->PushToStack( newStackedTrack );
138 if( verboseLevel > 1 )
140 G4cout <<
"### pop requested out of "
149 <<
" waiting tracks are re-classified to" <<
G4endl;
152 if(numberOfAdditionalWaitingStacks>0) {
153 for(
int i=0;i<numberOfAdditionalWaitingStacks;i++) {
155 additionalWaitingStacks[0]->TransferTo(waitingStack);
157 additionalWaitingStacks[i]->TransferTo(additionalWaitingStacks[i-1]);
161 if(userStackingAction) userStackingAction->
NewStage();
165 <<
" waiting tracks." <<
G4endl;
175 if( verboseLevel > 2 )
177 G4cout <<
"Selected G4StackedTrack : " << &selectedStackedTrack
178 <<
" with G4Track " << selectedStackedTrack.
GetTrack()
185 return selectedTrack;
193 if( !userStackingAction )
return;
202 switch (classification)
218 G4int i = classification - 10;
219 if(i<1||i>numberOfAdditionalWaitingStacks) {
221 ED <<
"invalid classification " << classification <<
G4endl;
222 G4Exception(
"G4StackManager::ReClassify",
"Event0052",
225 additionalWaitingStacks[i-1]->PushToStack( aStackedTrack );
238 G4int n_passedFromPrevious = 0;
243 if( verboseLevel > 1 )
246 <<
" postponed tracked are now shifted to the stack." <<
G4endl;
261 if(userStackingAction)
264 { classification = DefaultClassification( aTrack ); }
266 if(classification==
fKill)
273 aTrack->
SetTrackID(-(++n_passedFromPrevious));
274 switch (classification)
286 G4int i = classification - 10;
287 if(i<1||i>numberOfAdditionalWaitingStacks) {
289 ED <<
"invalid classification " << classification <<
G4endl;
290 G4Exception(
"G4StackManager::PrepareNewEvent",
"Event0053",
293 additionalWaitingStacks[i-1]->PushToStack( aStackedTrack );
301 return n_passedFromPrevious;
306 if(iAdd > numberOfAdditionalWaitingStacks)
308 for(
int i=numberOfAdditionalWaitingStacks;i<iAdd;i++)
311 additionalWaitingStacks.push_back(newStack);
313 numberOfAdditionalWaitingStacks = iAdd;
315 else if (iAdd < numberOfAdditionalWaitingStacks)
317 for(
int i=numberOfAdditionalWaitingStacks;i>iAdd;i--)
319 delete additionalWaitingStacks[i];
326 if(origin==destination)
return;
327 if(origin==
fKill)
return;
335 originStack = waitingStack;
338 originStack = postponeStack;
342 if(i<=numberOfAdditionalWaitingStacks) originStack = additionalWaitingStacks[i-1];
346 if(destination==
fKill)
362 targetStack = waitingStack;
365 targetStack = postponeStack;
368 int i = destination - 10;
369 if(i<=numberOfAdditionalWaitingStacks) targetStack = additionalWaitingStacks[i-1];
387 if(origin==destination)
return;
388 if(origin==
fKill)
return;
396 originStack = waitingStack;
399 originStack = postponeStack;
403 if(i<=numberOfAdditionalWaitingStacks) originStack = additionalWaitingStacks[i-1];
408 if(destination==
fKill)
410 if( originStack && originStack->
GetNTrack() ) {
430 targetStack = waitingStack;
433 targetStack = postponeStack;
436 int i = destination - 10;
437 if(i<=numberOfAdditionalWaitingStacks) targetStack = additionalWaitingStacks[i-1];
440 if(originStack && originStack->
GetNTrack()) {
442 if(targetStack) { targetStack->
PushToStack(aStackedTrack); }
447 if(targetStack) { targetStack->
PushToStack(aStackedTrack); }
471 if(i<=numberOfAdditionalWaitingStacks) additionalWaitingStacks[i-1]->clearAndDestroy();
483 for(
int i=1;i<=numberOfAdditionalWaitingStacks;i++) {n += additionalWaitingStacks[i-1]->GetNTrack();}
494 if(i==0) {
return waitingStack->
GetNTrack(); }
496 if(i<=numberOfAdditionalWaitingStacks) {
return additionalWaitingStacks[i-1]->GetNTrack();}
508 verboseLevel = value;
513 userStackingAction = value;
522 return classification;
G4ClassificationOfNewTrack
G4DLLIMPORT std::ostream G4cout
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=0)
void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
void SetUserStackingAction(G4UserStackingAction *value)
void ClearPostponeStack()
G4int GetNWaitingTrack(int i=0) const
void ClearWaitingStack(int i=0)
G4Track * GetTrack() const
G4VTrajectory * GetTrajectory() const
G4int GetMaxNTrack() const
void PushToStack(const G4StackedTrack &aStackedTrack)
void TransferTo(G4TrackStack *aStack)
G4StackedTrack PopFromStack()
G4TrackStatus GetTrackStatus() 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)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription