Geant4 10.7.0
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"
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
92 { return currentEvent; }
94 { return currentEvent; }
95 // These methods returns the pointers of const G4Event*
96 // and G4Event*, respectively. Null will be returned when
97 // an event is not processing.
98
99 void AbortCurrentEvent();
100 // This method aborts the processing of the current event. All stacked
101 // tracks are deleted. The contents of G4Event object is not completed,
102 // but trajectories, hits, and/or digits which are created before the
103 // moment of abortion can be used.
104
105 void SetUserAction(G4UserEventAction* userAction);
106 void SetUserAction(G4UserStackingAction* userAction);
107 void SetUserAction(G4UserTrackingAction* userAction);
108 void SetUserAction(G4UserSteppingAction* userAction);
110 { return userEventAction; }
112 { return userStackingAction; }
114 { return userTrackingAction; }
116 { return userSteppingAction; }
117 // Set and get methods for user action classes. User action classes
118 // which should belong to the other managers will be sent to the
119 // corresponding managers.
120
122 { trackContainer->SetNumberOfAdditionalWaitingStacks(iAdd); }
123
124 void KeepTheCurrentEvent();
125 // If the current event exists, it is kept undeleted until
126 // the end of the current run
127
129 { return trackContainer; }
131 { return trackManager; }
132
134 { return verboseLevel; }
135 inline void SetVerboseLevel( G4int value )
136 {
137 verboseLevel = value;
138 trackContainer->SetVerboseLevel( value );
139 transformer->SetVerboseLevel( value );
140 }
141 // Set and get method of the verbose level
142
145 // Set and get method of G4VUserEventInformation object associating with
146 // the current event. Both methods are valid only for G4State_EventProc
147 // application state.
148
150 { return transformer; }
152 { transformer = tf; }
154 { storetRandomNumberStatusToG4Event = vl; }
155
156 private:
157
158 void DoProcessing(G4Event* anEvent);
159 void StackTracks(G4TrackVector* trackVector, G4bool IDhasAlreadySet= false);
160
161 private:
162
163 static G4ThreadLocal G4EventManager* fpEventManager;
164
165 G4Event* currentEvent = nullptr;
166
167 G4StackManager* trackContainer = nullptr;
168 G4TrackingManager* trackManager = nullptr;
169 G4TrajectoryContainer* trajectoryContainer = nullptr;
170 G4int trackIDCounter = 0;
171 G4int verboseLevel = 0;
172 G4SDManager* sdManager = nullptr;
173 G4PrimaryTransformer* transformer = nullptr;
174 G4bool tracking = false;
175 G4bool abortRequested = false;
176
177 G4EvManMessenger* theMessenger = nullptr;
178
179 G4UserEventAction* userEventAction = nullptr;
180 G4UserStackingAction* userStackingAction = nullptr;
181 G4UserTrackingAction* userTrackingAction = nullptr;
182 G4UserSteppingAction* userSteppingAction = nullptr;
183
184 G4int storetRandomNumberStatusToG4Event = 0;
185 G4String randomNumberStatusToG4Event;
186
187 G4StateManager* stateManager = nullptr;
188
189 private:
190 std::unique_ptr<ProfilerConfig> eventProfiler;
191};
192
193#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 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