40 :userStackingAction(0),verboseLevel(0),numberOfAdditionalWaitingStacks(0)
43 #ifdef G4_USESMARTSTACK
56 if(userStackingAction)
delete userStackingAction;
61 G4cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<
G4endl;
63 G4cout <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" <<
G4endl;
70 if(numberOfAdditionalWaitingStacks>0) {
71 for(
int i=0;i<numberOfAdditionalWaitingStacks;i++) {
72 delete additionalWaitingStacks[i];
80 const{
return false; }
100 ED <<
"A track without proper process manager is pushed into the track stack.\n"
103 { ED <<
"created by a primary particle generator."; }
110 { ED <<
"creaded by unknown process."; }
118 if( verboseLevel > 0 ) {
119 ED <<
"\n Process manager is temporally set, but this operation is thread-unsafe\n"
120 <<
"and will be replaced with other methods at version 10.0.";
127 if ((genericIon ==0) || (pman==0)){
129 "Can not define process manager. GenericIon is not available.");
134 if( verboseLevel > 1 )
138 <<
" that is equivalent to " << pman <<
G4endl;
140 for(
G4int ip1=0;ip1<ionPvec->
size();ip1++)
142 G4cout <<
" " << ip1 <<
" - " << (*ionPvec)[ip1]->GetProcessName()
155 if( verboseLevel > 0 ) {
156 ED <<
"\nThis track is deleted.";
157 G4Exception(
"G4StackManager::PushOneTrack",
"Event10051",
167 if(userStackingAction)
170 if(classification==
fKill)
173 if( verboseLevel > 1 )
175 G4cout <<
" ---> G4Track " << newTrack <<
" (trackID "
181 delete newTrajectory;
186 switch (classification)
198 G4int i = classification - 10;
199 if(i<1||i>numberOfAdditionalWaitingStacks) {
201 ED <<
"invalid classification " << classification <<
G4endl;
202 G4Exception(
"G4StackManager::PushOneTrack",
"Event0051",
205 additionalWaitingStacks[i-1]->PushToStack( newStackedTrack );
218 if( verboseLevel > 1 )
220 G4cout <<
"### pop requested out of "
229 <<
" waiting tracks are re-classified to" <<
G4endl;
232 if(numberOfAdditionalWaitingStacks>0) {
233 for(
int i=0;i<numberOfAdditionalWaitingStacks;i++) {
235 additionalWaitingStacks[0]->TransferTo(waitingStack);
237 additionalWaitingStacks[i]->TransferTo(additionalWaitingStacks[i-1]);
241 if(userStackingAction) userStackingAction->
NewStage();
245 <<
" waiting tracks." <<
G4endl;
255 if( verboseLevel > 2 )
257 G4cout <<
"Selected G4StackedTrack : " << &selectedStackedTrack
258 <<
" with G4Track " << selectedStackedTrack.
GetTrack()
265 return selectedTrack;
273 if( !userStackingAction )
return;
282 switch (classification)
298 G4int i = classification - 10;
299 if(i<1||i>numberOfAdditionalWaitingStacks) {
301 ED <<
"invalid classification " << classification <<
G4endl;
302 G4Exception(
"G4StackManager::ReClassify",
"Event0052",
305 additionalWaitingStacks[i-1]->PushToStack( aStackedTrack );
318 G4int n_passedFromPrevious = 0;
323 if( verboseLevel > 1 )
326 <<
" postponed tracked are now shifted to the stack." <<
G4endl;
341 if(userStackingAction)
344 { classification = DefaultClassification( aTrack ); }
346 if(classification==
fKill)
353 aTrack->
SetTrackID(-(++n_passedFromPrevious));
354 switch (classification)
366 G4int i = classification - 10;
367 if(i<1||i>numberOfAdditionalWaitingStacks) {
369 ED <<
"invalid classification " << classification <<
G4endl;
370 G4Exception(
"G4StackManager::PrepareNewEvent",
"Event0053",
373 additionalWaitingStacks[i-1]->PushToStack( aStackedTrack );
381 return n_passedFromPrevious;
386 if(iAdd > numberOfAdditionalWaitingStacks)
388 for(
int i=numberOfAdditionalWaitingStacks;i<iAdd;i++)
391 additionalWaitingStacks.push_back(newStack);
393 numberOfAdditionalWaitingStacks = iAdd;
395 else if (iAdd < numberOfAdditionalWaitingStacks)
397 for(
int i=numberOfAdditionalWaitingStacks;i>iAdd;i--)
399 delete additionalWaitingStacks[i];
406 if(origin==destination)
return;
407 if(origin==
fKill)
return;
415 originStack = waitingStack;
418 originStack = postponeStack;
422 if(i<=numberOfAdditionalWaitingStacks) originStack = additionalWaitingStacks[i-1];
426 if(destination==
fKill)
442 targetStack = waitingStack;
445 targetStack = postponeStack;
448 int i = destination - 10;
449 if(i<=numberOfAdditionalWaitingStacks) targetStack = additionalWaitingStacks[i-1];
467 if(origin==destination)
return;
468 if(origin==
fKill)
return;
476 originStack = waitingStack;
479 originStack = postponeStack;
483 if(i<=numberOfAdditionalWaitingStacks) originStack = additionalWaitingStacks[i-1];
488 if(destination==
fKill)
490 if( originStack && originStack->
GetNTrack() ) {
510 targetStack = waitingStack;
513 targetStack = postponeStack;
516 int i = destination - 10;
517 if(i<=numberOfAdditionalWaitingStacks) targetStack = additionalWaitingStacks[i-1];
520 if(originStack && originStack->
GetNTrack()) {
522 if(targetStack) { targetStack->
PushToStack(aStackedTrack); }
527 if(targetStack) { targetStack->
PushToStack(aStackedTrack); }
551 if(i<=numberOfAdditionalWaitingStacks) additionalWaitingStacks[i-1]->clearAndDestroy();
563 for(
int i=1;i<=numberOfAdditionalWaitingStacks;i++) {n += additionalWaitingStacks[i-1]->GetNTrack();}
574 if(i==0) {
return waitingStack->
GetNTrack(); }
576 if(i<=numberOfAdditionalWaitingStacks) {
return additionalWaitingStacks[i-1]->GetNTrack();}
588 verboseLevel =
value;
593 userStackingAction =
value;
602 return classification;
G4Track * GetTrack() const
G4int GetParticleDefinitionID() const
G4int GetParentID() const
void SetParticleDefinitionID(G4int id=-1)
G4int GetAlongStepIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
std::ostringstream G4ExceptionDescription
void SetStackManager(G4StackManager *value)
void PushToStack(const G4StackedTrack &aStackedTrack)
G4int GetNTotalTrack() const
G4TrackStatus GetTrackStatus() const
G4Track * PopNextTrack(G4VTrajectory **newTrajectory)
G4ParticleDefinition * GetGenericIon() const
const G4String & GetParticleName() const
G4int GetAtRestIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4int GetNUrgentTrack() const
G4bool IsGeneralIon() const
void TransferTo(G4TrackStack *aStack)
const G4VProcess * GetCreatorProcess() const
void SetUserStackingAction(G4UserStackingAction *value)
G4GLOB_DLL std::ostream G4cout
G4VTrajectory * GetTrajectory() const
const XML_Char int const XML_Char * value
G4StackedTrack PopFromStack()
G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory=0)
const G4ParticleDefinition * GetParticleDefinition() const
virtual void PrepareNewEvent()
void SetVerboseLevel(G4int const value)
const G4String & GetProcessName() const
void TransferOneStackedTrack(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination)
G4int GetNWaitingTrack(int i=0) const
void ClearPostponeStack()
G4ClassificationOfNewTrack
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
static G4ParticleTable * GetParticleTable()
G4ProcessManager * GetProcessManager() const
void SetParentID(const G4int aValue)
G4int GetPostStepIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
G4int GetNPostponedTrack() const
G4int GetMaxNTrack() const
void SetTrackID(const G4int aValue)
G4ProcessVector * GetProcessList() const
void ClearWaitingStack(int i=0)