MCPcopy Create free account
hub / github.com/Geant4/geant4 / RunInitialization

Method RunInitialization

source/run/src/G4WorkerTaskRunManager.cc:74–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72//============================================================================//
73
74void G4WorkerTaskRunManager::RunInitialization()
75{
76#ifdef G4MULTITHREADED
77 if (!visIsSetUp) {
78 G4VVisManager* pVVis = G4VVisManager::GetConcreteInstance();
79 if (pVVis != nullptr) {
80 pVVis->SetUpForAThread();
81 visIsSetUp = true;
82 }
83 }
84#endif
85 runIsSeeded = false;
86
87 if (!(kernel->RunInitialization(fakeRun))) return;
88
89 // Signal this thread can start event loop.
90 // Note this will return only when all threads reach this point
91 G4MTRunManager::GetMasterRunManager()->ThisWorkerReady();
92 if (fakeRun) return;
93
94 const G4UserWorkerInitialization* uwi =
95 G4MTRunManager::GetMasterRunManager()->GetUserWorkerInitialization();
96
97 CleanUpPreviousEvents();
98
99 delete currentRun;
100
101 currentRun = nullptr;
102
103 if (IfGeometryHasBeenDestroyed()) G4ParallelWorldProcessStore::GetInstance()->UpdateWorlds();
104
105 // Call a user hook: this is guaranteed all threads are "synchronized"
106 if (uwi != nullptr) uwi->WorkerRunStart();
107
108 if (userRunAction != nullptr) currentRun = userRunAction->GenerateRun();
109 if (currentRun == nullptr) currentRun = new G4Run();
110
111 currentRun->SetRunID(runIDCounter);
112 G4TaskRunManager* mrm = G4TaskRunManager::GetMasterRunManager();
113 numberOfEventToBeProcessed = mrm->GetNumberOfEventsToBeProcessed();
114 currentRun->SetNumberOfEventToBeProcessed(numberOfEventToBeProcessed);
115
116 currentRun->SetDCtable(DCtable);
117 G4SDManager* fSDM = G4SDManager::GetSDMpointerIfExist();
118 if (fSDM != nullptr) {
119 currentRun->SetHCtable(fSDM->GetHCtable());
120 }
121
122 if (G4VScoreNtupleWriter::Instance() != nullptr) {
123 auto hce = (fSDM != nullptr) ? fSDM->PrepareNewEvent() : nullptr;
124 isScoreNtupleWriter = G4VScoreNtupleWriter::Instance()->Book(hce);
125 delete hce;
126 }
127
128 std::ostringstream oss;
129 G4Random::saveFullState(oss);
130 randomNumberStatusForThisRun = oss.str();
131 currentRun->SetRandomNumberStatus(randomNumberStatusForThisRun);

Callers

nothing calls this directly

Calls 15

GetInstanceFunction · 0.85
UpdateWorldsMethod · 0.80
SetHCtableMethod · 0.80
SetUpForAThreadMethod · 0.45
ThisWorkerReadyMethod · 0.45
WorkerRunStartMethod · 0.45
GenerateRunMethod · 0.45
SetRunIDMethod · 0.45
SetDCtableMethod · 0.45

Tested by

no test coverage detected