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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 ]

  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 // G4EventManager
 27 //
 28 // Class description:
 29 //
 30 // G4EventManager controls an event. This class must be a singleton
 31 // and should be constructed by G4RunManager.
 32 
 33 // Author: M.Asai, SLAC
 34 // --------------------------------------------------------------------
 35 #ifndef G4EventManager_hh
 36 #define G4EventManager_hh 1
 37 
 38 #include "G4StackManager.hh"
 39 #include "G4TrajectoryContainer.hh"
 40 #include "G4PrimaryTransformer.hh"
 41 #include "G4Event.hh"
 42 class G4UserEventAction;
 43 class G4UserStackingAction;
 44 class G4UserTrackingAction;
 45 class G4UserSteppingAction;
 46 class G4EvManMessenger;
 47 #include "G4TrackingManager.hh"
 48 #include "G4Track.hh"
 49 #include "G4VTrajectory.hh"
 50 #include "G4TrackStatus.hh"
 51 class G4SDManager;
 52 class G4StateManager;
 53 #include "globals.hh"
 54 class G4VUserEventInformation;
 55 
 56 class G4EventManager 
 57 {
 58  public:
 59     static G4EventManager* GetEventManager();
 60       // This method returns the singleton pointer of G4EventManager.
 61 
 62     G4EventManager();
 63    ~G4EventManager();
 64 
 65     G4EventManager(const G4EventManager &right) = delete;
 66     G4EventManager& operator=(const G4EventManager& right) = delete;
 67 
 68     void ProcessOneEvent(G4Event* anEvent);
 69       // This method is the main entry to this class for simulating an event.
 70 
 71     void ProcessOneEvent(G4TrackVector* trackVector, G4Event* anEvent= nullptr);
 72       // This is an alternative entry for HEP experiments which create G4Track
 73       // objects by themselves directly without using G4VPrimaryGenerator or a
 74       // user-primary-generator action. Dummy G4Event object will be created if
 75       // "anEvent" is null for internal use, but this dummy object will be
 76       // deleted at the end of this method and will never be available for use
 77       // after the processing.
 78       // Note that in this case of null G4Event pointer, no output of the
 79       // simulated event is returned by this method; the user must implement
 80       // some mechanism of storing the output, e.g. in the UserEventAction
 81       // and/or in sensitive detectors.
 82       // If a valid G4Event object is given, this object will not be deleted
 83       // by this method, and output objects such as hits collections and
 84       // trajectories will be associated to the event object. If the event
 85       // object has valid primary vertices/particles, they will be added to
 86       // the given "trackvector" input.
 87 
 88     void StackTracks(G4TrackVector* trackVector, G4bool IDhasAlreadySet= false);
 89       // Helper function to stack a vector of tracks for processing in the
 90       // current event.
 91 
 92     inline const G4Event* GetConstCurrentEvent()
 93       { return currentEvent; }
 94     inline G4Event* GetNonconstCurrentEvent()
 95       { return currentEvent; }
 96       // These methods returns the pointers of const G4Event*
 97       // and G4Event*, respectively. Null will be returned when
 98       // an event is not processing.
 99 
100     void AbortCurrentEvent();
101       // This method aborts the processing of the current event. All stacked
102       // tracks are deleted. The contents of G4Event object is not completed,
103       // but trajectories, hits, and/or digits which are created before the
104       // moment of abortion can be used.
105 
106     void SetUserAction(G4UserEventAction* userAction);
107     void SetUserAction(G4UserStackingAction* userAction);
108     void SetUserAction(G4UserTrackingAction* userAction);
109     void SetUserAction(G4UserSteppingAction* userAction);
110     inline G4UserEventAction* GetUserEventAction()
111       { return userEventAction; }
112     inline G4UserStackingAction* GetUserStackingAction()
113       { return userStackingAction; }
114     inline G4UserTrackingAction* GetUserTrackingAction()
115       { return userTrackingAction; }
116     inline G4UserSteppingAction* GetUserSteppingAction()
117       { return userSteppingAction; }
118       // Set and get methods for user action classes. User action classes
119       // which should belong to the other managers will be sent to the 
120       // corresponding managers.
121 
122     void KeepTheCurrentEvent();
123       // If the current event exists, it is kept undeleted until
124       // the end of the current run
125 
126     inline G4StackManager* GetStackManager() const
127       { return trackContainer; }
128     inline G4TrackingManager* GetTrackingManager() const
129       { return trackManager; }
130 
131     inline G4int GetVerboseLevel()
132       { return verboseLevel; }
133     inline void SetVerboseLevel( G4int value )
134       {
135         verboseLevel = value;
136         trackContainer->SetVerboseLevel( value );
137         transformer->SetVerboseLevel( value );
138       }
139       // Set and get method of the verbose level
140 
141     void SetUserInformation(G4VUserEventInformation* anInfo);
142     G4VUserEventInformation* GetUserInformation();
143       // Set and get method of G4VUserEventInformation object associating with
144       // the current event. Both methods are valid only for G4State_EventProc
145       // application state.
146 
147     inline G4PrimaryTransformer* GetPrimaryTransformer() const
148       { return transformer; }
149     inline void SetPrimaryTransformer(G4PrimaryTransformer* tf)
150       { transformer = tf; }
151     inline void StoreRandomNumberStatusToG4Event(G4int vl)
152       { storetRandomNumberStatusToG4Event = vl; }
153 
154     inline void UseSubEventParallelism(G4bool worker = false)
155       {
156         subEventPara = true; 
157         subEventParaWorker = worker;
158       }
159 
160     G4SubEvent* PopSubEvent(G4int ty);
161       // If this method is invoked by the G4RunManager while an event is still 
162       // in process. Null is returned if the sub-event does not have enough tracks.
163       // This method is Mutex-protected.
164 
165     void TerminateSubEvent(const G4SubEvent* se,const G4Event* evt);
166       // G4Event "evt" contains the results made by the worker thread.
167       // The ownership of "evt" remains to the worker thread and it will be
168       // deleted after this method. All necessary information in "evt" must
169       // be copied into the corresponding master G4Event object.
170 
171     G4int StoreSubEvent(G4Event*, G4int&, G4SubEvent*);
172       // This method is exclusively used by G4SubEventTrackStack class to 
173       // store a new G4SubEevnt into the current G4Event, with Mutex lock
174       // shared with above two methods.
175 
176   private:
177 
178     void DoProcessing(G4Event* anEvent,
179            G4TrackVector* trackVector = nullptr, G4bool IDhasAlreadySet= false);
180   
181   private:
182 
183     static G4ThreadLocal G4EventManager* fpEventManager;
184 
185     G4Event* currentEvent = nullptr;
186 
187     G4StackManager* trackContainer = nullptr;
188     G4TrackingManager* trackManager = nullptr;
189     G4TrajectoryContainer* trajectoryContainer = nullptr;
190     G4int trackIDCounter = 0;
191     G4int verboseLevel = 0;
192     G4SDManager* sdManager = nullptr;
193     G4PrimaryTransformer* transformer = nullptr;
194     G4bool tracking = false;
195     G4bool abortRequested = false;
196     G4bool subEventPara = false;
197     G4bool subEventParaWorker = false;
198     G4int evID_inSubEv = -1;
199 
200     G4EvManMessenger* theMessenger = nullptr;
201 
202     G4UserEventAction*    userEventAction = nullptr;
203     G4UserStackingAction* userStackingAction = nullptr;
204     G4UserTrackingAction* userTrackingAction = nullptr;
205     G4UserSteppingAction* userSteppingAction = nullptr;
206 
207     G4int storetRandomNumberStatusToG4Event = 0;
208     G4String randomNumberStatusToG4Event;
209 
210     G4StateManager* stateManager = nullptr;
211 };
212 
213 #endif
214