Geant4 11.2.2
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// G4RunManagerKernel
27//
28// Class description:
29//
30// This is a class for mandatory control of the Geant4 kernel.
31//
32// This class is constructed by G4RunManager. If a user adopts his/her own
33// class instead of G4RunManager, this class must be instantiated by at the
34// very beginning of the application and must be deleted at the very end.
35// In addition, the following methods must be invoked in the proper order:
36// DefineWorldVolume()
37// InitializePhysics()
38// RunInitialization()
39// RunTermination()
40//
41// User must provide his/her own classes derived from the following abstract
42// class and register it to G4RunManagerKernel:
43// G4VUserPhysicsList - Particle types, Processes and Cuts
44//
45// G4RunManagerKernel does not have any event loop. Handling of events
46// is managed by G4RunManager.
47
48// Author: M.Asai, 1 August 2003
49// --------------------------------------------------------------------
50#ifndef G4RunManagerKernel_hh
51#define G4RunManagerKernel_hh 1
52
53#include "G4EventManager.hh"
54#include "globals.hh"
55
58class G4Region;
60class G4StackManager;
63
65{
66 public:
67 // Static method returning the singleton pointer of
68 // G4RunManagerKernel or its derived class.
70
71 // The constructor and the destructor. The user must construct this class
72 // object at the beginning of his/her main() and must delete it at the
73 // bottom of the main(), unless he/she used G4RunManager.
75 virtual ~G4RunManagerKernel();
76
77 void DefineWorldVolume(G4VPhysicalVolume* worldVol, G4bool topologyIsChanged = true);
78
79 // This method must be invoked if the geometry setup has been changed
80 // between runs. The flag "topologyIsChanged" will specify if the
81 // geometry topology is different from the original one used in the
82 // previous run; if not, it must be set to false, so that the original
83 // optimisation and navigation history is preserved. This method is
84 // invoked also at initialisation.
85 void WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol, G4bool topologyIsChanged = true);
86
87 // This method must be invoked at least once with a valid concrete
88 // implementation of user physics list.
89 void SetPhysics(G4VUserPhysicsList* uPhys);
90
91 // This method must be invoked at least once to build physics processes.
92 void InitializePhysics();
93
94 // Trigger geometry closing and physics table constructions.
95 // It returns TRUE if all procedures went well.
96 G4bool RunInitialization(G4bool fakeRun = false);
97
98 // Set the application state to 'Idle' so that the user can modify
99 // physics/geometry.
100 void RunTermination();
101
102 // Update region list. This method is mandatory before invoking the
103 // following two dump methods.
104 // At RunInitialization(), this method is automatically invoked.
105 void UpdateRegion();
106
107 // Dump information of a region.
108 void DumpRegion(const G4String& rname) const;
109
110 // Dump information of a region.
111 // If the pointer is NULL, all regions are shown.
112 void DumpRegion(G4Region* region = nullptr) const;
113
115
116 // This method must be invoked (or equivalent UI commands can be used)
117 // in case the user changes his/her detector geometry.
118 // This method is automatically invoked from DefineWorldVolume().
120
121 // This method must be invoked in case the user changes his/her physics
122 // process(es), e.g. (in)activate some processes. Once this method is
123 // invoked, regardless of cuts changed or not, BuildPhysicsTable() of
124 // a PhysicsList is invoked for refreshing all physics tables.
125 inline void PhysicsHasBeenModified() { physicsNeedsToBeReBuilt = true; }
126
127 inline G4EventManager* GetEventManager() const { return eventManager; }
128 inline G4StackManager* GetStackManager() const { return eventManager->GetStackManager(); }
130 {
131 return eventManager->GetTrackingManager();
132 }
134 {
135 eventManager->SetPrimaryTransformer(pt);
136 }
138 {
139 return eventManager->GetPrimaryTransformer();
140 }
141
142 inline const G4String& GetVersionString() const { return versionString; }
143
144 inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
145
147 {
148 if (geometryToBeOptimized != vl) {
149 geometryToBeOptimized = vl;
151 }
152 }
153
154 inline G4int GetNumberOfParallelWorld() const { return numberOfParallelWorld; }
155 inline void SetNumberOfParallelWorld(G4int i) { numberOfParallelWorld = i; }
156
157 inline G4VUserPhysicsList* GetPhysicsList() const { return physicsList; }
158
159 inline G4VPhysicalVolume* GetCurrentWorld() const { return currentWorld; }
160
161 inline G4int GetNumberOfStaticAllocators() const { return numberOfStaticAllocators; }
162
169
170 protected:
171 // Constructor to be used by derived classes.
173
174 // Called by DefineWorldVolume().
175 void SetupDefaultRegion();
176 void SetupPhysics();
177 void ResetNavigator();
178 void BuildPhysicsTables(G4bool fakeRun);
179 void CheckRegions();
180
181 // This method will setup the G4VProcesses instances to have a reference
182 // to the process instance created by the master thread.
183 // See G4VProcess::GetMasterProcess().
184 virtual void SetupShadowProcess() const;
185
187
188 private:
189 void CheckRegularGeometry();
190 G4bool ConfirmCoupledTransportation();
191 void SetScoreSplitter();
192
193 protected:
198
199 private:
200 G4VUserPhysicsList* physicsList = nullptr;
201 G4VPhysicalVolume* currentWorld = nullptr;
202 G4bool geometryInitialized = false;
203 G4bool physicsInitialized = false;
204 G4bool geometryToBeOptimized = true;
205 G4bool physicsNeedsToBeReBuilt = true;
206 G4int verboseLevel = 0;
207 G4int numberOfParallelWorld = 0;
208
209 G4EventManager* eventManager = nullptr;
210 G4ExceptionHandler* defaultExceptionHandler = nullptr;
211 G4String versionString = "";
212
213 static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel;
214
215 G4int numberOfStaticAllocators = 0;
216};
217
218#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