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