Back to home page

EIC code displayed by LXR

 
 

    


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 // G4RunManager
0027 //
0028 // Class description:
0029 //
0030 // This is a class for run control in Geant4
0031 //
0032 // For the sequential mode of Geant4 application, user must provide his
0033 // own classes derived from the following three abstract classes and register
0034 // them to the RunManager:
0035 //   G4VUserDetectorConstruction       - Detector Geometry, Materials
0036 //   G4VUserPhysicsList                - Particle types and Processes
0037 //   G4VUserPrimaryGeneratorAction     - Event Generator selection
0038 //
0039 // In addition to the above mandatory classes, user can easily customise
0040 // the default functionality of a Geant4 simulation by deriving his own
0041 // classes from the following 5 user-action classes:
0042 //   G4UserRunAction                   - Actions for each Run
0043 //   G4UserEventAction                 - Actions for each Event
0044 //   G4UserStackingAction              - Tracks Stacking selection
0045 //   G4UserTrackingAction              - Actions for each Track
0046 //   G4UserSteppingAction              - Actions for each Step
0047 //
0048 // User may use G4VUserActionInitialization class to instantiate any of
0049 // the six user action-classes (1 mandatory + 6 optional).
0050 // In this case, user's concrete G4VUserActionInitialization should be
0051 // defined to the RunManager.
0052 //
0053 // If in multi-threaed mode, a user must provide his own classes derived
0054 // from the following two abstract classes and register them to the
0055 // G4MTRunManager or G4TaskingRunManager:
0056 //   G4VUserDetectorConstruction       - Detector Geometry, Materials
0057 //   G4VUserPhysicsList                - Particle types and Processes
0058 // In addition, user may optionally specify the following:
0059 //   G4UserWorkerInitialization        - Defining thread-local actions
0060 //   G4UserRunAction                   - Actions for entire Run
0061 //
0062 // In multi-threaded mode, the use of G4VUserActionInitialization
0063 // is mandatory.
0064 // In G4VUserActionInitialization, the user has to specify
0065 // G4VUserPrimaryGeneratorAction class. In addition, the default
0066 // functionality of a Geant4 simulation can be customised by making
0067 // user's classes derived from the following 5 user-action classes:
0068 //   G4VUserPrimaryGeneratorAction     - Event Generator selection
0069 //   G4UserRunAction                   - Actions for each tread-local Run
0070 //   G4UserEventAction                 - Actions for each Event
0071 //   G4UserStackingAction              - Tracks Stacking selection
0072 //   G4UserTrackingAction              - Actions for each Track
0073 //   G4UserSteppingAction              - Actions for each Step
0074 //
0075 // G4RunManager MUST be constructed (either explicitly or through
0076 // G4RunManagerFactory) by the user in the main() for enabling sequential
0077 // mode operation of a Geant4 application.
0078 //
0079 // In multi-threaded mode, G4MTRunManager is the dedicated run manager
0080 // which the user MUST construct (either explicitly or through
0081 // G4RunManagerFactory) in the main().
0082 //
0083 // Note: G4WorkerRunManager is the run manager for an individual thread,
0084 // and is instantiated automatically; the user does not need to take care
0085 // of instantiating/deleting it.
0086 // Also, the behavior of the run control can be customised by deriving
0087 // a user class from G4RunManager. In this case, the user should directly
0088 // use the provided protected methods in this class for procedures he/she
0089 // does not want to change.
0090 //
0091 // G4RunManager (or a derived class of it) MUST act as a singleton.
0092 // The user MUST NOT construct more than one such object even if there
0093 // are two different concrete implementations, nor its state can be reset
0094 // to zero, once the object has been created.
0095 //
0096 // G4RunManager controls all of state changes. See G4ApplicationState.hh
0097 // in intercoms category for the meaning of each application state.
0098 
0099 // Original author: M.Asai, 1996
0100 // --------------------------------------------------------------------
0101 #ifndef G4RunManager_hh
0102 #define G4RunManager_hh 1
0103 
0104 #include "G4Event.hh"
0105 #include "G4EventManager.hh"
0106 #include "G4Profiler.hh"
0107 #include "G4RunManagerKernel.hh"
0108 #include "globals.hh"
0109 
0110 #include "rundefs.hh"
0111 
0112 #include <algorithm>
0113 #include <list>
0114 
0115 // userAction classes
0116 class G4VUserDetectorConstruction;
0117 class G4VUserPhysicsList;
0118 class G4UserWorkerInitialization;
0119 class G4UserWorkerThreadInitialization;
0120 class G4VUserActionInitialization;
0121 class G4UserRunAction;
0122 class G4VUserPrimaryGeneratorAction;
0123 class G4UserEventAction;
0124 class G4UserStackingAction;
0125 class G4UserTrackingAction;
0126 class G4UserSteppingAction;
0127 
0128 class G4VPhysicalVolume;
0129 class G4LogicalVolume;
0130 class G4Region;
0131 class G4Timer;
0132 class G4RunMessenger;
0133 class G4DCtable;
0134 class G4Run;
0135 class G4PrimaryTransformer;
0136 class G4RunManagerFactory;
0137 
0138 class G4RunManager
0139 {
0140     friend class G4RunManagerFactory;
0141 
0142   public:
0143     // the profiler aliases are only used when compiled with the
0144     // GEANT4_USE_TIMEMORY flag enabled.
0145     using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
0146 
0147   public:
0148     // Static method which returns the singleton pointer of G4RunManager
0149     // or its derived class.
0150     // Note this returns the per-thread singleton in case of a
0151     // multi-threaded build.
0152     static G4RunManager* GetRunManager();
0153 
0154     // The constructor and the destructor. The user must construct
0155     // this class object at the beginning of his/her main() and must
0156     // delete it at the bottom of the main().
0157     G4RunManager();
0158     virtual ~G4RunManager();
0159 
0160     // Forbidden copy constructor and assignment operator.
0161     G4RunManager(const G4RunManager&) = delete;
0162     G4RunManager& operator=(const G4RunManager&) = delete;
0163 
0164     // This method starts an event loop of "n_event" events. The condition of
0165     // Geant4 is examined before starting the event loop. This method must be
0166     // invoked at 'Idle' state. The state will be changed to 'GeomClosed'
0167     // during the event loop and will go back to 'Idle' when the loop is over
0168     // or aborted.
0169     // In case a string "macroFile" which represents the name of a macro file
0170     // is provided, the macro file will be executed AT THE END of each event
0171     // processing. In case "n_select" is greater than zero, at the end of the
0172     // first "n_select" events, the macro file is executed.
0173     virtual void BeamOn(G4int n_event, const char* macroFile = nullptr, G4int n_select = -1);
0174 
0175     // This method invokes all the necessary initialisation procedures for an
0176     // event loop. This method must be invoked at the Geant4 'PreInit' state
0177     // or 'Idle'. The state will be changed to 'Init' during initialization
0178     // procedures and then changed to 'Idle'.
0179     // This method invokes two protected methods, InitializeGeometry() and
0180     // InitializePhysics().
0181     // After some event loops, the user can invoke this method once again.
0182     // It is required if the user changes geometry, physics process, and/or
0183     // cut-off value. If the user forget the second invocation, the BeamOn()
0184     // method will invoke this method (Note that this feature is not valid
0185     // for the first initialization).
0186     virtual void Initialize();
0187 
0188     // This method must be invoked if the geometry setup has been changed
0189     // between runs. The flag "topologyIsChanged" will specify if the geometry
0190     // topology is different from the original one used in the previous run;
0191     // if not, it must be set to false, so that the original optimisation and
0192     // navigation history are preserved. This method is invoked also at
0193     // initialisation.
0194     virtual void DefineWorldVolume(G4VPhysicalVolume* worldVol, G4bool topologyIsChanged = true);
0195 
0196     // This method safely aborts the current event loop even if an event is
0197     // in progress. This method is available for 'GeomClosed' and 'EventProc'
0198     // Geant4 states. The application state will be changed to 'Idle', so that
0199     // another event loop can be processed.
0200     // If the "softAbort" flag is true, the event loop is aborted after
0201     // processing the current event, while the current event is aborted if the
0202     // flag is set to false.
0203     virtual void AbortRun(G4bool softAbort = false);
0204 
0205     // This method aborts the currently processing event, remaining events
0206     // in the current event loop will be processed. This method is available
0207     // only for 'EventProc' application state.
0208     virtual void AbortEvent();
0209 
0210     // These methods are invoked from the Initialize() method for the
0211     // initializations of geometry and physics processes. The user's concrete
0212     // G4VUserDetectorConstruction class will be accessed from the method
0213     // InitializeGeometry() and the G4VUserPhysicsList class will be accessed
0214     // from the method InitializePhysics().
0215     virtual void InitializeGeometry();
0216     virtual void InitializePhysics();
0217 
0218     // These four methods are invoked from the BeamOn() method and they're
0219     // invoked in this order.
0220     // ConfirmBeamOnCondition() method checks if all the necessary
0221     // initialisations have been done already. If the condition is not
0222     // satisfied, false is returned and the following three methods will be
0223     // skipped.
0224     // The RunInitialization() method initialises a run. e.g., a G4Run class
0225     // object is constructed in this method.
0226     // The DoEventLoop() method controls an event loop. Arguments are the same
0227     // as for the BeamOn() method.
0228     // Inside the event loop, the two following methods are invoked at the
0229     // beginning and at the end of each event.
0230     // The RunTermination() method terminates a run processing. e.g., a G4Run
0231     // class object is deleted in this method. If the user adopts ODBMS and
0232     // wants to store the G4Run object, he/she must override this method.
0233     virtual G4bool ConfirmBeamOnCondition();
0234     virtual void RunInitialization();
0235     virtual void DoEventLoop(G4int n_event, const char* macroFile = nullptr, G4int n_select = -1);
0236     virtual void RunTermination();
0237 
0238     // Granular virtual methods invoked from DoEventLoop().
0239     virtual void InitializeEventLoop(G4int n_event, const char* macroFile = nullptr,
0240                                      G4int n_select = -1);
0241     virtual void ProcessOneEvent(G4int i_event);
0242     virtual void TerminateOneEvent();
0243     virtual void TerminateEventLoop();
0244 
0245     // These two methods are invoked from DoEventLoop() at the beginning and
0246     // at the end of each event processing.
0247     // GenerateEvent() constructs a G4Event class object and invoke the user's
0248     // G4VUserPrimaryGeneratorAction concrete class. If the user is adopting
0249     // an ODBMS system and event objects have been created and stored in the
0250     // data-base, he/she must override this method.
0251     // AnalyzeEvent() stores an event to a data-base if a concrete
0252     // G4VPersistentManager class is defined.
0253     virtual G4Event* GenerateEvent(G4int i_event);
0254     virtual void AnalyzeEvent(G4Event* anEvent);
0255 
0256     // This method configures the global fallback query and label generators.
0257     virtual void ConfigureProfilers(const std::vector<std::string>& args = {});
0258 
0259     // Calls the above virtual method.
0260     void ConfigureProfilers(G4int argc, char** argv);
0261 
0262     // Dummy methods to dispatch generic inheritance calls from G4RunManager
0263     // base class.
0264     virtual void SetNumberOfThreads(G4int) {}
0265     virtual G4int GetNumberOfThreads() const { return 1; }
0266 
0267     // Dump information of a region.
0268     void DumpRegion(const G4String& rname) const;
0269 
0270     // Dump information of a region.
0271     // If the pointer is NULL, all regions are shown.
0272     void DumpRegion(G4Region* region = nullptr) const;
0273 
0274     // This method must be invoked (or equivalent UI command can be used)
0275     // in case the user changes his/her detector geometry after Initialize()
0276     // method has been invoked. Then, at the beginning of the next BeamOn(),
0277     // all necessary geometry optimisations will be made.
0278     // The parameter "prop" has to be true if this C++ method is directly
0279     // invoked.
0280     void GeometryHasBeenModified(G4bool prop = true);
0281 
0282     // This method must be invoked (or equivalent UI command can be used)
0283     // in case the user needs his/her detector construction has to be
0284     // re-invoked. Geometry optimisations will be also done.
0285     // If the first parameter "destroyFirst" is true, G4SolidStore,
0286     // G4LogicalVolumeStore and G4PhysicalVolumeStore are cleaned up, and
0287     // thus all solids, logical volumes and physical volumes previously
0288     // defined are deleted.
0289     // The second parameter "prop" has to be true if this C++ method is
0290     // directly invoked.
0291     void ReinitializeGeometry(G4bool destroyFirst = false, G4bool prop = true);
0292 
0293     // This method must be invoked (or equivalent UI command can be used)
0294     // in case the user changes his/her physics process(es), e.g. (in)activate
0295     // some processes. Once this method is invoked, regardless of cuts are
0296     // changed or not, BuildPhysicsTable() of a PhysicsList is invoked for
0297     // refreshing all physics tables.
0298     inline void PhysicsHasBeenModified() { kernel->PhysicsHasBeenModified(); }
0299 
0300     inline void CutOffHasBeenModified()
0301     {
0302       G4cerr << "CutOffHasBeenModified becomes obsolete." << G4endl;
0303       G4cerr << "It is safe to remove invoking this method." << G4endl;
0304     }
0305 
0306     // This method may be used if the orientation and/or size of a
0307     // particular physical volume has been modified while the rest of the
0308     // geometries in the world has not been changed. This avoids the
0309     // full re-optimisation of the entire geometry tree which is forced
0310     // if GeometryHasBeenModified() method is invoked.
0311     void ReOptimizeMotherOf(G4VPhysicalVolume*);
0312 
0313     // Same as above, but the mother logical volume is specified instead.
0314     void ReOptimize(G4LogicalVolume*);
0315 
0316     inline void SetGeometryToBeOptimized(G4bool vl)
0317     {
0318       if (geometryToBeOptimized != vl) {
0319         geometryToBeOptimized = vl;
0320         kernel->GeometryHasBeenModified();
0321         kernel->SetGeometryToBeOptimized(vl);
0322       }
0323     }
0324     inline G4bool GetGeometryToBeOptimized() { return geometryToBeOptimized; }
0325 
0326     void GeometryDirectlyUpdated(G4bool val = true) { geometryDirectlyUpdated = val; }
0327 
0328     // This is used only by workers thread to reset RNG engines from files
0329     // that are event specific. Not implemented for sequential since run seed
0330     // defines event seeds.
0331     static G4bool IfGeometryHasBeenDestroyed();
0332 
0333     virtual void ConstructScoringWorlds();
0334 
0335     virtual void rndmSaveThisRun();
0336     virtual void rndmSaveThisEvent();
0337     virtual void RestoreRandomNumberStatus(const G4String& fileN);
0338     virtual void RestoreRndmEachEvent(G4bool)
0339     { /* No effect in SEQ */
0340     }
0341 
0342     // Set user-actions and user-initialization to the kernel.
0343     // Store respective user initialization and action classes.
0344     // In MT mode, actions are shared among all threads, and should be set
0345     // in the master thread, while user-actions are thread-private and each      `
0346     // thread has private instances. Master thread does not have user-actions
0347     // except for the (optional) run-action.
0348     // User should instantiate the user-actions in the action-initialization
0349     // and use that class' setters to set user-actions and *not* directly
0350     // the methods provided here.
0351     // Multiple Run, Event, Tracking and Stepping actions are allowed, the
0352     // multiple instances will be appended to the current configuration.
0353     // Multiple Stacking and PrimaryGeneration are not allowed.
0354     virtual void SetUserInitialization(G4VUserDetectorConstruction* userInit);
0355     virtual void SetUserInitialization(G4VUserPhysicsList* userInit);
0356     virtual void SetUserInitialization(G4VUserActionInitialization* userInit);
0357     virtual void SetUserInitialization(G4UserWorkerInitialization* userInit);
0358     virtual void SetUserInitialization(G4UserWorkerThreadInitialization* userInit);
0359     virtual void SetUserAction(G4UserRunAction* userAction);
0360     virtual void SetUserAction(G4VUserPrimaryGeneratorAction* userAction);
0361     virtual void SetUserAction(G4UserEventAction* userAction);
0362     virtual void SetUserAction(G4UserStackingAction* userAction);
0363     virtual void SetUserAction(G4UserTrackingAction* userAction);
0364     virtual void SetUserAction(G4UserSteppingAction* userAction);
0365 
0366     // Methods returning respective user initialization and action classes.
0367     inline const G4VUserDetectorConstruction* GetUserDetectorConstruction() const
0368     {
0369       return userDetector;
0370     }
0371     inline const G4VUserPhysicsList* GetUserPhysicsList() const { return physicsList; }
0372     inline const G4VUserActionInitialization* GetUserActionInitialization() const
0373     {
0374       return userActionInitialization;
0375     }
0376     inline G4VUserActionInitialization* GetNonConstUserActionInitialization() const
0377     {
0378       return userActionInitialization;
0379     }
0380     inline const G4UserWorkerInitialization* GetUserWorkerInitialization() const
0381     {
0382       return userWorkerInitialization;
0383     }
0384     inline const G4UserWorkerThreadInitialization* GetUserWorkerThreadInitialization() const
0385     {
0386       return userWorkerThreadInitialization;
0387     }
0388     inline const G4UserRunAction* GetUserRunAction() const { return userRunAction; }
0389     inline const G4VUserPrimaryGeneratorAction* GetUserPrimaryGeneratorAction() const
0390     {
0391       return userPrimaryGeneratorAction;
0392     }
0393     inline const G4UserEventAction* GetUserEventAction() const { return userEventAction; }
0394     inline const G4UserStackingAction* GetUserStackingAction() const { return userStackingAction; }
0395     inline const G4UserTrackingAction* GetUserTrackingAction() const { return userTrackingAction; }
0396     inline const G4UserSteppingAction* GetUserSteppingAction() const { return userSteppingAction; }
0397 
0398     // Set the number of additional (optional) waiting stacks.
0399     // This method must be invoked at 'PreInit', 'Init' or 'Idle' states.
0400     // Once the user sets the number of additional waiting stacks,
0401     // he/she can use the corresponding ENUM in G4ClassificationOfNewTrack.
0402     inline void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
0403     {
0404       eventManager->GetStackManager()->SetNumberOfAdditionalWaitingStacks(iAdd);
0405     }
0406 
0407     inline const G4String& GetVersionString() const { return kernel->GetVersionString(); }
0408 
0409     inline void SetPrimaryTransformer(G4PrimaryTransformer* pt)
0410     {
0411       kernel->SetPrimaryTransformer(pt);
0412     }
0413 
0414     // if vl = 1 : status before primary particle generation is stored
0415     // if vl = 2 : status before event processing (after primary particle
0416     // generation) is stored if vl = 3 : both are stored if vl = 0 : none is
0417     // stored (default).
0418     inline void StoreRandomNumberStatusToG4Event(G4int vl)
0419     {
0420       storeRandomNumberStatusToG4Event = vl;
0421       eventManager->StoreRandomNumberStatusToG4Event(vl);
0422     }
0423 
0424     inline G4int GetFlagRandomNumberStatusToG4Event() const
0425     {
0426       return storeRandomNumberStatusToG4Event;
0427     }
0428 
0429     inline void SetRandomNumberStore(G4bool flag) { storeRandomNumberStatus = flag; }
0430     inline G4bool GetRandomNumberStore() const { return storeRandomNumberStatus; }
0431     inline void SetRandomNumberStoreDir(const G4String& dir)
0432     {
0433       G4String dirStr = dir;
0434       if (dirStr.back() != '/') dirStr += "/";
0435 #ifndef WIN32
0436       G4String shellCmd = "mkdir -p ";
0437 #else
0438       std::replace(dirStr.begin(), dirStr.end(), '/', '\\');
0439       G4String shellCmd = "if not exist " + dirStr + " mkdir ";
0440 #endif
0441       shellCmd += dirStr;
0442       randomNumberStatusDir = dirStr;
0443       G4int sysret = system(shellCmd);
0444       if (sysret != 0) {
0445         G4String errmsg = "\"" + shellCmd + "\" returns non-zero value. Directory creation failed.";
0446         G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0071", JustWarning, errmsg);
0447         G4cerr << " return value = " << sysret << G4endl;
0448       }
0449     }
0450     inline const G4String& GetRandomNumberStoreDir() const { return randomNumberStatusDir; }
0451     inline const G4String& GetRandomNumberStatusForThisRun() const
0452     {
0453       return randomNumberStatusForThisRun;
0454     }
0455     inline const G4String& GetRandomNumberStatusForThisEvent() const
0456     {
0457       if (storeRandomNumberStatusToG4Event == 0 || storeRandomNumberStatusToG4Event == 2) {
0458         G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0072", JustWarning,
0459                     "Random number status is not available for this event.");
0460       }
0461       return randomNumberStatusForThisEvent;
0462     }
0463     inline void SetRandomNumberStorePerEvent(G4bool flag) { rngStatusEventsFlag = flag; }
0464     inline G4bool GetRandomNumberStorePerEvent() const { return rngStatusEventsFlag; }
0465 
0466     inline void SetVerboseLevel(G4int vl)
0467     {
0468       verboseLevel = vl;
0469       kernel->SetVerboseLevel(vl);
0470     }
0471     inline G4int GetVerboseLevel() const { return verboseLevel; }
0472     inline G4int GetPrintProgress() { return printModulo; }
0473     inline void SetPrintProgress(G4int i) { printModulo = i; }
0474 
0475     // Sets the number of events to be kept after processing. That is,
0476     // "val" previous events can be used with the most recent event for
0477     // digitizing pileup. "val"+1 previous event is deleted.
0478     // This method must be invoked before starting the event loop.
0479     inline void SetNumberOfEventsToBeStored(G4int val) { n_perviousEventsToBeStored = val; }
0480 
0481     // Returns the pointer to the current run. This method is available for
0482     // 'GeomClosed' and 'EventProc' application states.
0483     inline const G4Run* GetCurrentRun() const { return currentRun; }
0484     inline G4Run* GetNonConstCurrentRun() const { return currentRun; }
0485 
0486     // Returns the pointer to the current event. This method is available for
0487     // 'EventProc' application state.
0488     inline const G4Event* GetCurrentEvent() const { return currentEvent; }
0489 
0490     // Returns the pointer to the "i" previous event. This method is available
0491     // for 'EventProc' application state. In case the event loop has not yet
0492     // reached the requested event, null will be returned. To use this method,
0493     // SetNumberOfEventsToBeStored() method mentioned above must be invoked
0494     // previously to the event loop.
0495     inline const G4Event* GetPreviousEvent(G4int i) const
0496     {
0497       if (i >= 1 && i <= n_perviousEventsToBeStored) {
0498         auto itr = previousEvents->cbegin();
0499         for (G4int j = 1; j < i; ++j) {
0500           ++itr;
0501         }
0502         return *itr;
0503       }
0504       return nullptr;
0505     }
0506 
0507     // Set the run number counter. Initially, the counter is initialized
0508     // to zero and incremented by one for every BeamOn().
0509     inline void SetRunIDCounter(G4int i) { runIDCounter = i; }
0510 
0511     inline G4int GetNumberOfParallelWorld() const { return nParallelWorlds; }
0512     inline void SetNumberOfEventsToBeProcessed(G4int val) { numberOfEventToBeProcessed = val; }
0513     inline G4int GetNumberOfEventsToBeProcessed() const { return numberOfEventToBeProcessed; }
0514     inline G4int GetNumberOfSelectEvents() const { return n_select_msg; }
0515     inline const G4String& GetSelectMacro() const { return selectMacro; }
0516     inline void SetDCtable(G4DCtable* DCtbl) { DCtable = DCtbl; }
0517 
0518     enum RMType
0519     {
0520       sequentialRM,
0521       masterRM,
0522       workerRM
0523     };
0524 
0525     inline RMType GetRunManagerType() const { return runManagerType; }
0526 
0527   protected:
0528     // This constructor is called in case of multi-threaded build.
0529     G4RunManager(RMType rmType);
0530 
0531     void CleanUpPreviousEvents();
0532     void CleanUpUnnecessaryEvents(G4int keepNEvents);
0533     void StackPreviousEvent(G4Event* anEvent);
0534 
0535     virtual void StoreRNGStatus(const G4String& filenamePrefix);
0536 
0537     void UpdateScoring();
0538 
0539     // Called by destructor to delete user detector. Note: the user detector
0540     // is shared among threads, thus this should be re-implemented in derived
0541     // classes that implement the worker model.
0542     virtual void DeleteUserInitializations();
0543 
0544   protected:
0545     G4RunManagerKernel* kernel = nullptr;
0546     G4EventManager* eventManager = nullptr;
0547 
0548     G4VUserDetectorConstruction* userDetector = nullptr;
0549     G4VUserPhysicsList* physicsList = nullptr;
0550     G4VUserActionInitialization* userActionInitialization = nullptr;
0551     G4UserWorkerInitialization* userWorkerInitialization = nullptr;
0552     G4UserWorkerThreadInitialization* userWorkerThreadInitialization = nullptr;
0553     G4UserRunAction* userRunAction = nullptr;
0554     G4VUserPrimaryGeneratorAction* userPrimaryGeneratorAction = nullptr;
0555     G4UserEventAction* userEventAction = nullptr;
0556     G4UserStackingAction* userStackingAction = nullptr;
0557     G4UserTrackingAction* userTrackingAction = nullptr;
0558     G4UserSteppingAction* userSteppingAction = nullptr;
0559 
0560     G4bool geometryInitialized = false;
0561     G4bool physicsInitialized = false;
0562     G4bool runAborted = false;
0563     G4bool initializedAtLeastOnce = false;
0564     G4bool geometryToBeOptimized = true;
0565 
0566     G4int runIDCounter = 0;
0567     G4int verboseLevel = 0;
0568     G4int printModulo = -1;
0569     G4Timer* timer = nullptr;
0570     G4DCtable* DCtable = nullptr;
0571 
0572     G4Run* currentRun = nullptr;
0573     G4Event* currentEvent = nullptr;
0574     std::list<G4Event*>* previousEvents = nullptr;
0575     G4int n_perviousEventsToBeStored = 0;
0576     G4int numberOfEventToBeProcessed = 0;
0577 
0578     G4bool storeRandomNumberStatus = false;
0579     G4int storeRandomNumberStatusToG4Event = 0;
0580     G4String randomNumberStatusDir = "./";
0581     G4String randomNumberStatusForThisRun = "";
0582     G4String randomNumberStatusForThisEvent = "";
0583     G4bool rngStatusEventsFlag = false;
0584 
0585     G4VPhysicalVolume* currentWorld = nullptr;
0586 
0587     G4int nParallelWorlds = 0;
0588 
0589     G4String msgText = " ";
0590     G4int n_select_msg = -1;
0591     G4int numberOfEventProcessed = 0;
0592     G4String selectMacro = "";
0593     G4bool fakeRun = false;
0594     G4bool isScoreNtupleWriter = false;
0595 
0596     G4bool geometryDirectlyUpdated = false;
0597 
0598     RMType runManagerType;
0599 
0600     // This Boolean flag has to be shared by all derived objects.
0601     G4RUN_DLL static G4bool fGeometryHasBeenDestroyed;
0602 
0603   private:
0604     // Per-thread static instance of the run manager singleton.
0605     static G4ThreadLocal G4RunManager* fRunManager;
0606 
0607     G4RunMessenger* runMessenger = nullptr;
0608 
0609     std::unique_ptr<ProfilerConfig> masterRunProfiler;
0610 };
0611 
0612 #endif