Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RunManagerKernel.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//
27//
28//
29
30// class description:
31//
32// This is a class for mandatory control of GEANT4 kernel.
33//
34// This class is constructed by G4RunManager. If a user uses his/her own
35// class instead of G4RunManager, this class must be instantiated by
36// him/herself at the very beginning of the application and must be deleted
37// at the very end of the application. Also, following methods must be
38// invoked in the proper order.
39// DefineWorldVolume
40// InitializePhysics
41// RunInitialization
42// RunTermination
43//
44// User must provide his/her own classes derived from the following
45// abstract class and register it to the RunManagerKernel.
46// G4VUserPhysicsList - Particle types, Processes and Cuts
47//
48// G4RunManagerKernel does not have any eveny loop. Handling of events
49// is managed by G4RunManager.
50//
51
52#ifndef G4RunManagerKernel_h
53#define G4RunManagerKernel_h 1
54
56
58class G4Region;
60class G4StackManager;
63
64#include "G4EventManager.hh"
65#include "globals.hh"
66
68{
69 public: // with description
71 // Static method which returns the singleton pointer of G4RunManagerKernel or
72 // its derived class.
73
74 private:
75 static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel;
76
77 public: // with description
79 virtual ~G4RunManagerKernel();
80 // The constructor and the destructor. The user must construct this class
81 // object at the beginning of his/her main() and must delete it at the
82 // bottom of the main(), unless he/she used G4RunManager.
83 public:
85 {
89 };
90
91 protected:
92 // Constructor to be used by derived classes
95
96 public: // with description
98 G4bool topologyIsChanged = true);
99
101 G4bool topologyIsChanged = true);
102
103 // This method must be invoked if the geometry setup has been changed between
104 // runs. The flag 'topologyIsChanged' will specify if the geometry topology is
105 // different from the original one used in the previous run; if not, it must
106 // be set to false, so that the original optimisation and navigation history
107 // is preserved. This method is invoked also at initialisation.
108
109 void SetPhysics(G4VUserPhysicsList* uPhys);
110 // This method must be invoked at least once by the user with a valid
111 // concrete implementation of user physics list.
112
113 void InitializePhysics();
114 // This method must be invoked at least once by the user to build physics
115 // processes.
116
117 G4bool RunInitialization(G4bool fakeRun = false);
118 // Trigger geometry closing and physics table constructions.
119 // It returns TRUE if all procedures went well.
120
121 void RunTermination();
122 // Set the application state to G4State_Idle so that the user can modify
123 // physics/geometry.
124
125 public:
127
128 protected:
129 void SetupDefaultRegion();
130 // Called by DefineWorldVolume
131 void SetupPhysics();
132 void ResetNavigator();
133 void BuildPhysicsTables(G4bool fakeRun);
134 void CheckRegions();
135
136 public: // with description
137 void UpdateRegion();
138 // Update region list.
139 // This method is mandatory before invoking following two dump methods.
140 // At RunInitialization(), this method is automatically invoked, and thus
141 // the user needs not invoke.
142
143 void DumpRegion(const G4String& rname) const;
144 // Dump information of a region.
145
146 void DumpRegion(G4Region* region = 0) const;
147 // Dump information of a region.
148 // If the pointer is NULL, all regions are shown.
149
150 private:
151 G4VUserPhysicsList* physicsList;
152 G4VPhysicalVolume* currentWorld;
153 G4bool geometryInitialized;
154 G4bool physicsInitialized;
155 G4bool geometryToBeOptimized;
156 G4bool physicsNeedsToBeReBuilt;
157 G4int verboseLevel;
158 G4int numberOfParallelWorld;
159
160 G4EventManager* eventManager;
161 G4ExceptionHandler* defaultExceptionHandler;
162 G4String versionString;
163
164 protected:
168
169 public: // with description
171 // This method must be invoked (or equivalent UI commands can be used)
172 // in case the user changes his/her detector geometry.
173 // This method is automatically invoked from DefineWorldVolume() method.
174
175 inline void PhysicsHasBeenModified() { physicsNeedsToBeReBuilt = true; }
176 // This method must be invoked in case the user changes his/her physics
177 // process(es), e.g. (in)activate some processes. Once this method is
178 // invoked, regardless of cuts are changed or not, BuildPhysicsTable()
179 // of PhysicsList is invoked for refreshing all physics tables.
180
181 public:
182 inline G4EventManager* GetEventManager() const { return eventManager; }
184 {
185 return eventManager->GetStackManager();
186 }
188 {
189 return eventManager->GetTrackingManager();
190 }
192 {
193 eventManager->SetPrimaryTransformer(pt);
194 }
196 {
197 return eventManager->GetPrimaryTransformer();
198 }
199
200 inline const G4String& GetVersionString() const { return versionString; }
201
202 inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
203
205 {
206 if(geometryToBeOptimized != vl)
207 {
208 geometryToBeOptimized = vl;
210 }
211 }
212
214 {
215 return numberOfParallelWorld;
216 }
217 inline void SetNumberOfParallelWorld(G4int i) { numberOfParallelWorld = i; }
218
219 inline G4VUserPhysicsList* GetPhysicsList() const { return physicsList; }
220
221 inline G4VPhysicalVolume* GetCurrentWorld() const { return currentWorld; }
222
223 private:
224 void CheckRegularGeometry();
225 G4bool ConfirmCoupledTransportation();
226 void SetScoreSplitter();
227
228 G4int numberOfStaticAllocators;
229
230 public:
232 {
233 return numberOfStaticAllocators;
234 }
235
236 protected:
237 virtual void SetupShadowProcess() const;
238 // This method will setup the G4VProcesses
239 // instances to have a reference to the process instance
240 // created by the master thread. See G4VProcess::GetMasterProcess
241
243};
244
245#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4PrimaryTransformer * GetPrimaryTransformer() const
void SetPrimaryTransformer(G4PrimaryTransformer *tf)
G4TrackingManager * GetTrackingManager() const
G4StackManager * GetStackManager() const
G4PrimaryTransformer * GetPrimaryTransformer() const
G4Region * defaultRegionForParallelWorld
static G4RunManagerKernel * GetRunManagerKernel()
void SetPhysics(G4VUserPhysicsList *uPhys)
G4StackManager * GetStackManager() const
G4VPhysicalVolume * GetCurrentWorld() const
G4int GetNumberOfStaticAllocators() const
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
void SetNumberOfParallelWorld(G4int i)
G4EventManager * GetEventManager() const
void SetGeometryToBeOptimized(G4bool vl)
G4bool RunInitialization(G4bool fakeRun=false)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4VUserPhysicsList * GetPhysicsList() const
virtual void SetupShadowProcess() const
G4int GetNumberOfParallelWorld() const
void SetPrimaryTransformer(G4PrimaryTransformer *pt)
void DumpRegion(const G4String &rname) const
void BuildPhysicsTables(G4bool fakeRun)
const G4String & GetVersionString() const
void SetVerboseLevel(G4int vl)
G4TrackingManager * GetTrackingManager() const
#define G4ThreadLocal
Definition: tls.hh:77