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p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /event/include/G4StackManager.hh (Version 11.3.0) and /event/include/G4StackManager.hh (Version 5.2.p2)


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