Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
41class G4Event;
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
126 { trackContainer->SetNumberOfAdditionalWaitingStacks(iAdd); }
127
128 void KeepTheCurrentEvent();
129 // If the current event exists, it is kept undeleted until
130 // the end of the current run
131
133 { return trackContainer; }
135 { return trackManager; }
136
138 { return verboseLevel; }
139 inline void SetVerboseLevel( G4int value )
140 {
141 verboseLevel = value;
142 trackContainer->SetVerboseLevel( value );
143 transformer->SetVerboseLevel( value );
144 }
145 // Set and get method of the verbose level
146
149 // Set and get method of G4VUserEventInformation object associating with
150 // the current event. Both methods are valid only for G4State_EventProc
151 // application state.
152
154 { return transformer; }
156 { transformer = tf; }
158 { storetRandomNumberStatusToG4Event = vl; }
159
160 private:
161
162 void DoProcessing(G4Event* anEvent);
163
164 private:
165
166 static G4ThreadLocal G4EventManager* fpEventManager;
167
168 G4Event* currentEvent = nullptr;
169
170 G4StackManager* trackContainer = nullptr;
171 G4TrackingManager* trackManager = nullptr;
172 G4TrajectoryContainer* trajectoryContainer = nullptr;
173 G4int trackIDCounter = 0;
174 G4int verboseLevel = 0;
175 G4SDManager* sdManager = nullptr;
176 G4PrimaryTransformer* transformer = nullptr;
177 G4bool tracking = false;
178 G4bool abortRequested = false;
179
180 G4EvManMessenger* theMessenger = nullptr;
181
182 G4UserEventAction* userEventAction = nullptr;
183 G4UserStackingAction* userStackingAction = nullptr;
184 G4UserTrackingAction* userTrackingAction = nullptr;
185 G4UserSteppingAction* userSteppingAction = nullptr;
186
187 G4int storetRandomNumberStatusToG4Event = 0;
188 G4String randomNumberStatusToG4Event;
189
190 G4StateManager* stateManager = nullptr;
191
192 private:
193 std::unique_ptr<ProfilerConfig> eventProfiler;
194};
195
196#endif
std::vector< G4Track * > G4TrackVector
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4UserTrackingAction * GetUserTrackingAction()
void SetUserAction(G4UserEventAction *userAction)
void SetUserInformation(G4VUserEventInformation *anInfo)
G4PrimaryTransformer * GetPrimaryTransformer() const
G4UserSteppingAction * GetUserSteppingAction()
G4UserStackingAction * GetUserStackingAction()
void KeepTheCurrentEvent()
void SetVerboseLevel(G4int value)
const G4Event * GetConstCurrentEvent()
void AbortCurrentEvent()
G4EventManager & operator=(const G4EventManager &right)=delete
G4Event * GetNonconstCurrentEvent()
G4UserEventAction * GetUserEventAction()
static G4EventManager * GetEventManager()
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
void SetPrimaryTransformer(G4PrimaryTransformer *tf)
G4TrackingManager * GetTrackingManager() const
void StackTracks(G4TrackVector *trackVector, G4bool IDhasAlreadySet=false)
void StoreRandomNumberStatusToG4Event(G4int vl)
void ProcessOneEvent(G4Event *anEvent)
G4int GetVerboseLevel()
G4StackManager * GetStackManager() const
G4VUserEventInformation * GetUserInformation()
G4EventManager(const G4EventManager &right)=delete
void SetVerboseLevel(G4int vl)
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
void SetVerboseLevel(G4int const value)
#define G4ThreadLocal
Definition: tls.hh:77