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