|
||||
File indexing completed on 2025-01-18 09:59:03
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4RunManagerKernel 0027 // 0028 // Class description: 0029 // 0030 // This is a class for mandatory control of the Geant4 kernel. 0031 // 0032 // This class is constructed by G4RunManager. If a user adopts his/her own 0033 // class instead of G4RunManager, this class must be instantiated by at the 0034 // very beginning of the application and must be deleted at the very end. 0035 // In addition, the following methods must be invoked in the proper order: 0036 // DefineWorldVolume() 0037 // InitializePhysics() 0038 // RunInitialization() 0039 // RunTermination() 0040 // 0041 // User must provide his/her own classes derived from the following abstract 0042 // class and register it to G4RunManagerKernel: 0043 // G4VUserPhysicsList - Particle types, Processes and Cuts 0044 // 0045 // G4RunManagerKernel does not have any event loop. Handling of events 0046 // is managed by G4RunManager. 0047 0048 // Author: M.Asai, 1 August 2003 0049 // -------------------------------------------------------------------- 0050 #ifndef G4RunManagerKernel_hh 0051 #define G4RunManagerKernel_hh 1 0052 0053 #include "G4EventManager.hh" 0054 #include "globals.hh" 0055 0056 class G4VUserPhysicsList; 0057 class G4VPhysicalVolume; 0058 class G4Region; 0059 class G4ExceptionHandler; 0060 class G4StackManager; 0061 class G4TrackingManager; 0062 class G4PrimaryTransformer; 0063 0064 class G4RunManagerKernel 0065 { 0066 public: 0067 // Static method returning the singleton pointer of 0068 // G4RunManagerKernel or its derived class. 0069 static G4RunManagerKernel* GetRunManagerKernel(); 0070 0071 // The constructor and the destructor. The user must construct this class 0072 // object at the beginning of his/her main() and must delete it at the 0073 // bottom of the main(), unless he/she used G4RunManager. 0074 G4RunManagerKernel(); 0075 virtual ~G4RunManagerKernel(); 0076 0077 void DefineWorldVolume(G4VPhysicalVolume* worldVol, G4bool topologyIsChanged = true); 0078 0079 // This method must be invoked if the geometry setup has been changed 0080 // between runs. The flag "topologyIsChanged" will specify if the 0081 // geometry topology is different from the original one used in the 0082 // previous run; if not, it must be set to false, so that the original 0083 // optimisation and navigation history is preserved. This method is 0084 // invoked also at initialisation. 0085 void WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol, G4bool topologyIsChanged = true); 0086 0087 // This method must be invoked at least once with a valid concrete 0088 // implementation of user physics list. 0089 void SetPhysics(G4VUserPhysicsList* uPhys); 0090 0091 // This method must be invoked at least once to build physics processes. 0092 void InitializePhysics(); 0093 0094 // Trigger geometry closing and physics table constructions. 0095 // It returns TRUE if all procedures went well. 0096 G4bool RunInitialization(G4bool fakeRun = false); 0097 0098 // Set the application state to 'Idle' so that the user can modify 0099 // physics/geometry. 0100 void RunTermination(); 0101 0102 // Update region list. This method is mandatory before invoking the 0103 // following two dump methods. 0104 // At RunInitialization(), this method is automatically invoked. 0105 void UpdateRegion(); 0106 0107 // Dump information of a region. 0108 void DumpRegion(const G4String& rname) const; 0109 0110 // Dump information of a region. 0111 // If the pointer is NULL, all regions are shown. 0112 void DumpRegion(G4Region* region = nullptr) const; 0113 0114 void WorkerUpdateWorldVolume(); 0115 0116 // This method must be invoked (or equivalent UI commands can be used) 0117 // in case the user changes his/her detector geometry. 0118 // This method is automatically invoked from DefineWorldVolume(). 0119 inline void GeometryHasBeenModified() { geometryNeedsToBeClosed = true; } 0120 0121 // This method must be invoked in case the user changes his/her physics 0122 // process(es), e.g. (in)activate some processes. Once this method is 0123 // invoked, regardless of cuts changed or not, BuildPhysicsTable() of 0124 // a PhysicsList is invoked for refreshing all physics tables. 0125 inline void PhysicsHasBeenModified() { physicsNeedsToBeReBuilt = true; } 0126 0127 inline G4EventManager* GetEventManager() const { return eventManager; } 0128 inline G4StackManager* GetStackManager() const { return eventManager->GetStackManager(); } 0129 inline G4TrackingManager* GetTrackingManager() const 0130 { 0131 return eventManager->GetTrackingManager(); 0132 } 0133 inline void SetPrimaryTransformer(G4PrimaryTransformer* pt) 0134 { 0135 eventManager->SetPrimaryTransformer(pt); 0136 } 0137 inline G4PrimaryTransformer* GetPrimaryTransformer() const 0138 { 0139 return eventManager->GetPrimaryTransformer(); 0140 } 0141 0142 inline const G4String& GetVersionString() const { return versionString; } 0143 0144 inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; } 0145 0146 inline void SetGeometryToBeOptimized(G4bool vl) 0147 { 0148 if (geometryToBeOptimized != vl) { 0149 geometryToBeOptimized = vl; 0150 geometryNeedsToBeClosed = true; 0151 } 0152 } 0153 0154 inline G4int GetNumberOfParallelWorld() const { return numberOfParallelWorld; } 0155 inline void SetNumberOfParallelWorld(G4int i) { numberOfParallelWorld = i; } 0156 0157 inline G4VUserPhysicsList* GetPhysicsList() const { return physicsList; } 0158 0159 inline G4VPhysicalVolume* GetCurrentWorld() const { return currentWorld; } 0160 0161 inline G4int GetNumberOfStaticAllocators() const { return numberOfStaticAllocators; } 0162 0163 enum RMKType 0164 { 0165 sequentialRMK, 0166 masterRMK, 0167 workerRMK 0168 }; 0169 0170 protected: 0171 // Constructor to be used by derived classes. 0172 G4RunManagerKernel(RMKType rmkType); 0173 0174 // Called by DefineWorldVolume(). 0175 void SetupDefaultRegion(); 0176 void SetupPhysics(); 0177 void ResetNavigator(); 0178 void BuildPhysicsTables(G4bool fakeRun); 0179 void CheckRegions(); 0180 0181 // This method will setup the G4VProcesses instances to have a reference 0182 // to the process instance created by the master thread. 0183 // See G4VProcess::GetMasterProcess(). 0184 virtual void SetupShadowProcess() const; 0185 0186 void PropagateGenericIonID(); 0187 0188 private: 0189 void CheckRegularGeometry(); 0190 G4bool ConfirmCoupledTransportation(); 0191 void SetScoreSplitter(); 0192 0193 protected: 0194 RMKType runManagerKernelType; 0195 G4Region* defaultRegion = nullptr; 0196 G4Region* defaultRegionForParallelWorld = nullptr; 0197 G4bool geometryNeedsToBeClosed = true; 0198 0199 private: 0200 G4VUserPhysicsList* physicsList = nullptr; 0201 G4VPhysicalVolume* currentWorld = nullptr; 0202 G4bool geometryInitialized = false; 0203 G4bool physicsInitialized = false; 0204 G4bool geometryToBeOptimized = true; 0205 G4bool physicsNeedsToBeReBuilt = true; 0206 G4int verboseLevel = 0; 0207 G4int numberOfParallelWorld = 0; 0208 0209 G4EventManager* eventManager = nullptr; 0210 G4ExceptionHandler* defaultExceptionHandler = nullptr; 0211 G4String versionString = ""; 0212 0213 static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel; 0214 0215 G4int numberOfStaticAllocators = 0; 0216 }; 0217 0218 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |