File indexing completed on 2025-01-18 09:59:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #ifndef G4WorkerRunManager_hh
0040 #define G4WorkerRunManager_hh 1
0041
0042 #include "G4RNGHelper.hh"
0043 #include "G4RunManager.hh"
0044
0045 class G4WorkerThread;
0046 class G4WorkerRunManagerKernel;
0047
0048 class G4WorkerRunManager : public G4RunManager
0049 {
0050 public:
0051 using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
0052
0053 public:
0054 static G4WorkerRunManager* GetWorkerRunManager();
0055 static G4WorkerRunManagerKernel* GetWorkerRunManagerKernel();
0056
0057 G4WorkerRunManager();
0058 ~G4WorkerRunManager() override;
0059
0060 void InitializeGeometry() override;
0061 void RunInitialization() override;
0062 void DoEventLoop(G4int n_event, const char* macroFile = nullptr, G4int n_select = -1) override;
0063 void ProcessOneEvent(G4int i_event) override;
0064 G4Event* GenerateEvent(G4int i_event) override;
0065
0066 void RunTermination() override;
0067 void TerminateEventLoop() override;
0068
0069
0070
0071 virtual void DoWork();
0072
0073
0074 inline void SetWorkerThread(G4WorkerThread* wc) { workerContext = wc; }
0075
0076 void SetUserInitialization(G4VUserPhysicsList* userInit) override;
0077 void SetUserInitialization(G4VUserDetectorConstruction* userInit) override;
0078 void SetUserInitialization(G4VUserActionInitialization* userInit) override;
0079 void SetUserInitialization(G4UserWorkerInitialization* userInit) override;
0080 void SetUserInitialization(G4UserWorkerThreadInitialization* userInit) override;
0081 void SetUserAction(G4UserRunAction* userAction) override;
0082 void SetUserAction(G4VUserPrimaryGeneratorAction* userAction) override;
0083 void SetUserAction(G4UserEventAction* userAction) override;
0084 void SetUserAction(G4UserStackingAction* userAction) override;
0085 void SetUserAction(G4UserTrackingAction* userAction) override;
0086 void SetUserAction(G4UserSteppingAction* userAction) override;
0087
0088 void RestoreRndmEachEvent(G4bool flag) override { readStatusFromFile = flag; }
0089
0090 protected:
0091 void ConstructScoringWorlds() override;
0092 void StoreRNGStatus(const G4String& filenamePrefix) override;
0093 void rndmSaveThisRun() override;
0094 void rndmSaveThisEvent() override;
0095
0096
0097
0098 virtual void MergePartialResults();
0099
0100 protected:
0101 G4WorkerThread* workerContext = nullptr;
0102 #ifdef G4MULTITHREADED
0103 G4bool visIsSetUp = false;
0104 #endif
0105
0106 G4bool eventLoopOnGoing = false;
0107 G4bool runIsSeeded = false;
0108 G4int nevModulo = -1;
0109 G4int currEvID = -1;
0110 G4int luxury = -1;
0111 G4SeedsQueue seedsQueue;
0112 G4bool readStatusFromFile = false;
0113
0114 private:
0115 void SetupDefaultRNGEngine();
0116
0117 private:
0118 std::unique_ptr<ProfilerConfig> workerRunProfiler;
0119 };
0120
0121 #endif