source: trunk/source/event/include/G4StackManager.hh@ 1136

Last change on this file since 1136 was 964, checked in by garnier, 17 years ago

update event

File size: 6.9 KB
RevLine 
[816]1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4StackManager.hh,v 1.12 2006/06/29 18:09:07 gunter Exp $
[964]28// GEANT4 tag $Name: geant4-09-02-ref-02 $
[816]29//
30//
31
32
33#ifndef G4StackManager_h
34#define G4StackManager_h 1
35
36#include "G4UserStackingAction.hh"
37#include "G4StackedTrack.hh"
38#include "G4TrackStack.hh"
39#include "G4ClassificationOfNewTrack.hh"
40#include "G4Track.hh"
41#include "G4TrackStatus.hh"
42#include "globals.hh"
43class G4StackingMessenger;
44class G4VTrajectory;
45
46// class description:
47//
48// This is the manager class of handling stacks of G4Track objects.
49// This class must be a singleton and be constructed by G4EventManager.
50// Almost all methods must be invoked exclusively by G4EventManager.
51// Especially, some Clear() methods MUST NOT be invoked by the user.
52// Event abortion is handled by G4EventManager.
53//
54// This G4StackingManager has three stacks, the urgent stack, the
55// waiting stack, and the postpone to next event stack. The meanings
56// of each stack is descrived in the Geant4 user's manual.
57//
58
59
60class G4StackManager
61{
62 public:
63 G4StackManager();
64 ~G4StackManager();
65
66 private:
67 const G4StackManager & operator=
68 (const G4StackManager &right);
69 G4int operator==(const G4StackManager &right) const;
70 G4int operator!=(const G4StackManager &right) const;
71
72 public:
73 G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory = 0);
74 G4Track * PopNextTrack(G4VTrajectory**newTrajectory);
75 G4int PrepareNewEvent();
76
77 public: // with description
78 void ReClassify();
79 // Send all tracks stored in the Urgent stack one by one to
80 // the user's concrete ClassifyNewTrack() method. This method
81 // can be invoked from the user's G4UserStackingAction concrete
82 // class, especially fron its NewStage() method. Be aware that
83 // when the urgent stack becomes empty, all tracks in the waiting
84 // stack are send to the urgent stack and then the user's NewStage()
85 // method is invoked.
86
87 void SetNumberOfAdditionalWaitingStacks(G4int iAdd);
88 // Set the number of additional (optional) waiting stacks.
89 // This method must be invoked at PreInit, Init or Idle states.
90 // Once the user set the number of additional waiting stacks,
91 // he/she can use the corresponding ENUM in G4ClassificationOfNewTrack.
92 // The user should invoke G4RunManager::SetNumberOfAdditionalWaitingStacks
93 // method, which invokes this method.
94
95 void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination);
96 // Transfter all stacked tracks from the origin stack to the destination stack.
97 // The destination stack needs not be empty.
98 // If the destination is fKill, tracks are deleted.
99 // If the origin is fKill, nothing happen.
100
101 void TransferOneStackedTrack(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination);
102 // Transfter one stacked track from the origin stack to the destination stack.
103 // The transfered track is the one which came last to the origin stack.
104 // The destination stack needs not be empty.
105 // If the destination is fKill, the track is deleted.
106 // If the origin is fKill, nothing happen.
107
108 private:
109 G4UserStackingAction * userStackingAction;
110 G4int verboseLevel;
111 G4TrackStack * urgentStack;
112 G4TrackStack * waitingStack;
113 G4TrackStack * postponeStack;
114 G4StackingMessenger* theMessenger;
115 std::vector<G4TrackStack*> additionalWaitingStacks;
116 G4int numberOfAdditionalWaitingStacks;
117
118 public:
119 inline void clear()
120 {
121 ClearUrgentStack();
122 ClearWaitingStack();
123 for(int i=1;i<=numberOfAdditionalWaitingStacks;i++) {ClearWaitingStack(i);}
124 }
125 inline void ClearUrgentStack()
126 { urgentStack->clear(); }
127 inline void ClearWaitingStack(int i=0)
128 {
129 if(i==0) {
130 waitingStack->clear();
131 } else {
132 if(i<=numberOfAdditionalWaitingStacks) additionalWaitingStacks[i-1]->clear();
133 }
134 }
135 inline void ClearPostponeStack()
136 { postponeStack->clear(); }
137 inline G4int GetNTotalTrack() const
138 { int n = urgentStack->GetNTrack() + waitingStack->GetNTrack() + postponeStack->GetNTrack();
139 for(int i=1;i<=numberOfAdditionalWaitingStacks;i++) {n += additionalWaitingStacks[i-1]->GetNTrack();}
140 return n;
141 }
142 inline G4int GetNUrgentTrack() const
143 { return urgentStack->GetNTrack(); }
144 inline G4int GetNWaitingTrack(int i=0) const
145 { if(i==0) { return waitingStack->GetNTrack(); }
146 else {
147 if(i<=numberOfAdditionalWaitingStacks) { return additionalWaitingStacks[i-1]->GetNTrack();}
148 }
149 return 0;
150 }
151 inline G4int GetNPostponedTrack() const
152 { return postponeStack->GetNTrack(); }
153 inline void SetVerboseLevel( G4int const value )
154 { verboseLevel = value; }
155 inline void SetUserStackingAction(G4UserStackingAction* value)
156 {
157 userStackingAction = value;
158 if(userStackingAction) userStackingAction->SetStackManager(this);
159 }
160
161 private:
162 inline G4ClassificationOfNewTrack
163 DefaultClassification(G4Track *aTrack)
164 {
165 G4ClassificationOfNewTrack classification = fUrgent;
166 if( aTrack->GetTrackStatus() == fPostponeToNextEvent )
167 { classification = fPostpone; }
168 return classification;
169 }
170};
171
172#endif
173
Note: See TracBrowser for help on using the repository browser.