Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 7 // 26 // G4StackManager << 8 // $Id: G4StackManager.hh,v 1.5 2000/01/26 06:42:14 asaim Exp $ >> 9 // GEANT4 tag $Name: geant4-01-01 $ 27 // 10 // 28 // Class description: << 29 // 11 // 30 // This is the manager class of handling stack << 31 // This class must be a singleton and be const << 32 // Almost all methods must be invoked exclusiv << 33 // Especially, some Clear() methods MUST NOT b << 34 // Event abortion is handled by G4EventManager << 35 // << 36 // G4StackManager has three stacks, the urgent << 37 // waiting stack, and the postpone to next eve << 38 // of each stack is descrived in the Geant4 Us << 39 12 40 // Author: Makoto Asai, 1996 << 41 // << 42 // History: << 43 // - 01/Feb/1996, Makoto Asai - Created << 44 // - 04/Oct/2011, Pere Mato - Use of G4TrackSt << 45 // - 28/Aug/2023, Makoto Asai - Adding sub-eve << 46 // ------------------------------------------- << 47 #ifndef G4StackManager_hh << 48 #define G4StackManager_hh 1 << 49 13 50 #include <map> << 14 #ifndef G4StackManager_h 51 #include <vector> << 15 #define G4StackManager_h 1 52 16 53 #include "G4UserStackingAction.hh" 17 #include "G4UserStackingAction.hh" 54 #include "G4StackedTrack.hh" 18 #include "G4StackedTrack.hh" 55 #include "G4TrackStack.hh" 19 #include "G4TrackStack.hh" 56 #include "G4SmartTrackStack.hh" << 57 #include "G4SubEventTrackStack.hh" << 58 #include "G4ClassificationOfNewTrack.hh" 20 #include "G4ClassificationOfNewTrack.hh" 59 #include "G4Track.hh" 21 #include "G4Track.hh" 60 #include "G4TrackStatus.hh" 22 #include "G4TrackStatus.hh" 61 #include "G4ExceptionSeverity.hh" << 62 #include "globals.hh" 23 #include "globals.hh" 63 << 64 class G4StackingMessenger; 24 class G4StackingMessenger; 65 class G4VTrajectory; 25 class G4VTrajectory; 66 class G4Event; << 26 67 class G4ParticleDefinition; << 27 // class description: >> 28 // >> 29 // This is the manager class of handling stacks of G4Track objects. >> 30 // This class must be a singleton and be constructed by G4EventManager. >> 31 // Almost all methods must be invoked exclusively by G4EventManager. >> 32 // Especially, some Clear() methods MUST NOT be invoked by the user. >> 33 // Event abortion is handled by G4EventManager. >> 34 // >> 35 // This G4StackingManager has three stacks, the urgent stack, the >> 36 // waiting stack, and the postpone to next event stack. The meanings >> 37 // of each stack is descrived in the Geant4 user's manual. >> 38 // >> 39 // The only method the user can invoke is ReClassify(), which can >> 40 // be used from the user's concrete class of G4UserStackingAction. >> 41 // >> 42 68 43 69 class G4StackManager 44 class G4StackManager 70 { 45 { 71 public: 46 public: >> 47 G4StackManager(); >> 48 ~G4StackManager(); 72 49 73 G4StackManager(); << 50 private: 74 ~G4StackManager(); << 51 const G4StackManager & operator= 75 << 52 (const G4StackManager &right); 76 const G4StackManager& operator=(const G4St << 53 int operator==(const G4StackManager &right) const; 77 G4bool operator==(const G4StackManager&) c << 54 int operator!=(const G4StackManager &right) const; 78 G4bool operator!=(const G4StackManager&) c << 79 << 80 G4int PushOneTrack(G4Track* newTrack, << 81 G4VTrajectory* newTraje << 82 G4Track* PopNextTrack(G4VTrajectory** newT << 83 G4int PrepareNewEvent(G4Event* currentEven << 84 55 85 void ReClassify(); << 56 public: 86 // Send all tracks stored in the Urgent << 57 G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory = NULL); >> 58 G4Track * PopNextTrack(G4VTrajectory**newTrajectory); >> 59 G4int PrepareNewEvent(); >> 60 >> 61 public: // with description >> 62 void ReClassify(); >> 63 // Send all tracks stored in the Urgent stack one by one to 87 // the user's concrete ClassifyNewTrack( 64 // the user's concrete ClassifyNewTrack() method. This method 88 // can be invoked from the user's G4User 65 // can be invoked from the user's G4UserStackingAction concrete 89 // class, especially fron its NewStage() 66 // class, especially fron its NewStage() method. Be aware that 90 // when the urgent stack becomes empty, 67 // when the urgent stack becomes empty, all tracks in the waiting 91 // stack are send to the urgent stack an 68 // stack are send to the urgent stack and then the user's NewStage() 92 // method is invoked. 69 // method is invoked. 93 70 94 void SetNumberOfAdditionalWaitingStacks(G4 << 71 private: 95 // Set the number of additional (optiona << 72 G4UserStackingAction * userStackingAction; 96 // This method must be invoked at PreIni << 73 int verboseLevel; 97 // Once the user set the number of addit << 74 G4TrackStack * urgentStack; 98 // he/she can use the corresponding ENUM << 75 G4TrackStack * waitingStack; 99 // The user should invoke G4RunManager:: << 76 G4TrackStack * postponeStack; 100 // method, which invokes this method. << 77 G4StackingMessenger* theMessenger; 101 << 102 void TransferStackedTracks(G4Classificatio << 103 G4Classificatio << 104 // Transfer all stacked tracks from the << 105 // destination stack. The destination st << 106 // If the destination is fKill, tracks a << 107 // If the origin is fKill, nothing happe << 108 << 109 void TransferOneStackedTrack(G4Classificat << 110 G4Classificat << 111 // Transfter one stacked track from the << 112 // stack. << 113 // The transfered track is the one which << 114 // The destination stack needs not be em << 115 // If the destination is fKill, the trac << 116 // If the origin is fKill, nothing happe << 117 << 118 void RegisterSubEventType(G4int ty, G4int << 119 // Registering a sub-event type and the << 120 // stored in a G4SubEvent object of the << 121 << 122 void SetDefaultClassification( << 123 G4TrackStatus, G4ClassificationOf << 124 G4ExceptionSeverity es = G4Except << 125 void SetDefaultClassification( << 126 const G4ParticleDefinition*, G4Cl << 127 G4ExceptionSeverity es = G4Except << 128 // Define the default classification for << 129 // Default can be alternated by the User << 130 // G4ExceptionSeverity can be set to war << 131 // is inproperly changed. << 132 << 133 inline G4ClassificationOfNewTrack GetDefau << 134 { return fDefaultClassification; } << 135 78 136 public: 79 public: 137 void ReleaseSubEvent(G4int ty); << 80 inline void clear() 138 inline std::size_t GetNSubEventTypes() << 81 { 139 { return subEvtTypes.size(); } << 82 ClearUrgentStack(); 140 inline G4int GetSubEventType(std::size_t i << 83 ClearWaitingStack(); 141 { return subEvtTypes[i]; } << 84 } 142 << 85 inline void ClearUrgentStack() 143 void clear(); << 86 { urgentStack->clear(); } 144 void ClearUrgentStack(); << 87 inline void ClearWaitingStack() 145 void ClearWaitingStack(G4int i=0); << 88 { waitingStack->clear(); } 146 void ClearPostponeStack(); << 89 inline void ClearPostponeStack() 147 G4int GetNTotalTrack() const; << 90 { postponeStack->clear(); } 148 G4int GetNUrgentTrack() const; << 91 inline G4int GetNTotalTrack() const 149 G4int GetNWaitingTrack(G4int i=0) const; << 92 { return urgentStack->GetNTrack() 150 G4int GetNPostponedTrack() const; << 93 + waitingStack->GetNTrack() 151 void SetVerboseLevel( G4int const value ); << 94 + postponeStack->GetNTrack(); } 152 void SetUserStackingAction(G4UserStackingA << 95 inline G4int GetNUrgentTrack() const 153 << 96 { return urgentStack->GetNTrack(); } 154 private: << 97 inline G4int GetNWaitingTrack() const 155 void DefineDefaultClassification(const G4T << 98 { return waitingStack->GetNTrack(); } 156 void SortOut(G4StackedTrack&,G4Classificat << 99 inline G4int GetNPostponedTrack() const >> 100 { return postponeStack->GetNTrack(); } >> 101 inline void SetVerboseLevel( int const value ) >> 102 { verboseLevel = value; } >> 103 inline void SetUserStackingAction(G4UserStackingAction* value) >> 104 { >> 105 userStackingAction = value; >> 106 if(userStackingAction) userStackingAction->SetStackManager(this); >> 107 } 157 108 158 private: 109 private: 159 << 110 inline G4ClassificationOfNewTrack 160 G4UserStackingAction* userStackingAction = << 111 DefaultClassification(G4Track *aTrack) 161 G4int verboseLevel = 0; << 112 { 162 #ifdef G4_USESMARTSTACK << 113 G4ClassificationOfNewTrack classification = fUrgent; 163 G4SmartTrackStack* urgentStack = nullptr; << 114 if( aTrack->GetTrackStatus() == fPostponeToNextEvent ) 164 #else << 115 { classification = fPostpone; } 165 G4TrackStack* urgentStack = nullptr; << 116 return classification; 166 #endif << 117 } 167 G4TrackStack* waitingStack = nullptr; << 168 G4TrackStack* postponeStack = nullptr; << 169 G4StackingMessenger* theMessenger = nullpt << 170 std::vector<G4TrackStack*> additionalWaiti << 171 G4int numberOfAdditionalWaitingStacks = 0; << 172 << 173 std::map<G4TrackStatus, << 174 std::pair<G4ClassificationOfNewTr << 175 defClassTrackStatus; << 176 std::map<const G4ParticleDefinition*, << 177 std::pair<G4ClassificationOfNewTr << 178 defClassPartDef; << 179 G4ClassificationOfNewTrack fDefaultClassif << 180 G4ExceptionSeverity fExceptionSeverity = G << 181 << 182 std::map<G4int,G4SubEventTrackStack*> subE << 183 std::vector<G4int> subEvtTypes; << 184 }; 118 }; 185 119 186 #endif 120 #endif >> 121 187 122