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