Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4WorkerTaskRunManager Class Reference

#include <G4WorkerTaskRunManager.hh>

+ Inheritance diagram for G4WorkerTaskRunManager:

Public Types

using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>
 
using G4StrVector = std::vector<G4String>
 
- Public Types inherited from G4WorkerRunManager
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>
 
- Public Types inherited from G4RunManager
enum  RMType { sequentialRM , masterRM , workerRM }
 
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>
 

Public Member Functions

 G4WorkerTaskRunManager ()=default
 
void RunInitialization () override
 
void DoEventLoop (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1) override
 
void ProcessOneEvent (G4int i_event) override
 
G4EventGenerateEvent (G4int i_event) override
 
void RunTermination () override
 
void TerminateEventLoop () override
 
void DoWork () override
 
void RestoreRndmEachEvent (G4bool flag) override
 
virtual void DoCleanup ()
 
virtual void ProcessUI ()
 
G4WorkerThreadGetWorkerThread () const
 
G4StrVector GetCommandStack () const
 
- Public Member Functions inherited from G4WorkerRunManager
 G4WorkerRunManager ()
 
 ~G4WorkerRunManager () override
 
void InitializeGeometry () override
 
void SetWorkerThread (G4WorkerThread *wc)
 
void SetUserInitialization (G4VUserPhysicsList *userInit) override
 
void SetUserInitialization (G4VUserDetectorConstruction *userInit) override
 
void SetUserInitialization (G4VUserActionInitialization *userInit) override
 
void SetUserInitialization (G4UserWorkerInitialization *userInit) override
 
void SetUserInitialization (G4UserWorkerThreadInitialization *userInit) override
 
void SetUserAction (G4UserRunAction *userAction) override
 
void SetUserAction (G4VUserPrimaryGeneratorAction *userAction) override
 
void SetUserAction (G4UserEventAction *userAction) override
 
void SetUserAction (G4UserStackingAction *userAction) override
 
void SetUserAction (G4UserTrackingAction *userAction) override
 
void SetUserAction (G4UserSteppingAction *userAction) override
 
- Public Member Functions inherited from G4RunManager
 G4RunManager ()
 
virtual ~G4RunManager ()
 
 G4RunManager (const G4RunManager &)=delete
 
G4RunManageroperator= (const G4RunManager &)=delete
 
virtual void BeamOn (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
 
virtual void Initialize ()
 
virtual void DefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
virtual void AbortRun (G4bool softAbort=false)
 
virtual void AbortEvent ()
 
virtual void InitializePhysics ()
 
virtual G4bool ConfirmBeamOnCondition ()
 
virtual void InitializeEventLoop (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
 
virtual void TerminateOneEvent ()
 
virtual void AnalyzeEvent (G4Event *anEvent)
 
virtual void ConfigureProfilers (const std::vector< std::string > &args={})
 
void ConfigureProfilers (G4int argc, char **argv)
 
virtual void SetNumberOfThreads (G4int)
 
virtual G4int GetNumberOfThreads () const
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=nullptr) const
 
void GeometryHasBeenModified (G4bool prop=true)
 
void ReinitializeGeometry (G4bool destroyFirst=false, G4bool prop=true)
 
void PhysicsHasBeenModified ()
 
void CutOffHasBeenModified ()
 
void ReOptimizeMotherOf (G4VPhysicalVolume *)
 
void ReOptimize (G4LogicalVolume *)
 
void SetGeometryToBeOptimized (G4bool vl)
 
G4bool GetGeometryToBeOptimized ()
 
void GeometryDirectlyUpdated (G4bool val=true)
 
virtual void RestoreRandomNumberStatus (const G4String &fileN)
 
const G4VUserDetectorConstructionGetUserDetectorConstruction () const
 
const G4VUserPhysicsListGetUserPhysicsList () const
 
const G4VUserActionInitializationGetUserActionInitialization () const
 
G4VUserActionInitializationGetNonConstUserActionInitialization () const
 
const G4UserWorkerInitializationGetUserWorkerInitialization () const
 
const G4UserWorkerThreadInitializationGetUserWorkerThreadInitialization () const
 
const G4UserRunActionGetUserRunAction () const
 
const G4VUserPrimaryGeneratorActionGetUserPrimaryGeneratorAction () const
 
const G4UserEventActionGetUserEventAction () const
 
const G4UserStackingActionGetUserStackingAction () const
 
const G4UserTrackingActionGetUserTrackingAction () const
 
const G4UserSteppingActionGetUserSteppingAction () const
 
void SetNumberOfAdditionalWaitingStacks (G4int iAdd)
 
const G4StringGetVersionString () const
 
void SetPrimaryTransformer (G4PrimaryTransformer *pt)
 
void StoreRandomNumberStatusToG4Event (G4int vl)
 
G4int GetFlagRandomNumberStatusToG4Event () const
 
void SetRandomNumberStore (G4bool flag)
 
G4bool GetRandomNumberStore () const
 
void SetRandomNumberStoreDir (const G4String &dir)
 
const G4StringGetRandomNumberStoreDir () const
 
const G4StringGetRandomNumberStatusForThisRun () const
 
const G4StringGetRandomNumberStatusForThisEvent () const
 
void SetRandomNumberStorePerEvent (G4bool flag)
 
G4bool GetRandomNumberStorePerEvent () const
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
G4int GetPrintProgress ()
 
void SetPrintProgress (G4int i)
 
void SetNumberOfEventsToBeStored (G4int val)
 
const G4RunGetCurrentRun () const
 
G4RunGetNonConstCurrentRun () const
 
const G4EventGetCurrentEvent () const
 
const G4EventGetPreviousEvent (G4int i) const
 
void SetRunIDCounter (G4int i)
 
G4int GetNumberOfParallelWorld () const
 
void SetNumberOfEventsToBeProcessed (G4int val)
 
G4int GetNumberOfEventsToBeProcessed () const
 
G4int GetNumberOfSelectEvents () const
 
const G4StringGetSelectMacro () const
 
void SetDCtable (G4DCtable *DCtbl)
 
RMType GetRunManagerType () const
 

Static Public Member Functions

static G4WorkerTaskRunManagerGetWorkerRunManager ()
 
static G4WorkerTaskRunManagerKernelGetWorkerRunManagerKernel ()
 
- Static Public Member Functions inherited from G4WorkerRunManager
static G4WorkerRunManagerGetWorkerRunManager ()
 
static G4WorkerRunManagerKernelGetWorkerRunManagerKernel ()
 
- Static Public Member Functions inherited from G4RunManager
static G4RunManagerGetRunManager ()
 
static G4bool IfGeometryHasBeenDestroyed ()
 

Protected Member Functions

void StoreRNGStatus (const G4String &filenamePrefix) override
 
- Protected Member Functions inherited from G4WorkerRunManager
void ConstructScoringWorlds () override
 
void rndmSaveThisRun () override
 
void rndmSaveThisEvent () override
 
virtual void MergePartialResults ()
 
- Protected Member Functions inherited from G4RunManager
 G4RunManager (RMType rmType)
 
void CleanUpPreviousEvents ()
 
void CleanUpUnnecessaryEvents (G4int keepNEvents)
 
void StackPreviousEvent (G4Event *anEvent)
 
void UpdateScoring ()
 
virtual void DeleteUserInitializations ()
 

Additional Inherited Members

- Protected Attributes inherited from G4WorkerRunManager
G4WorkerThreadworkerContext = nullptr
 
G4bool eventLoopOnGoing = false
 
G4bool runIsSeeded = false
 
G4int nevModulo = -1
 
G4int currEvID = -1
 
G4int luxury = -1
 
G4SeedsQueue seedsQueue
 
G4bool readStatusFromFile = false
 
- Protected Attributes inherited from G4RunManager
G4RunManagerKernelkernel = nullptr
 
G4EventManagereventManager = nullptr
 
G4VUserDetectorConstructionuserDetector = nullptr
 
G4VUserPhysicsListphysicsList = nullptr
 
G4VUserActionInitializationuserActionInitialization = nullptr
 
G4UserWorkerInitializationuserWorkerInitialization = nullptr
 
G4UserWorkerThreadInitializationuserWorkerThreadInitialization = nullptr
 
G4UserRunActionuserRunAction = nullptr
 
G4VUserPrimaryGeneratorActionuserPrimaryGeneratorAction = nullptr
 
G4UserEventActionuserEventAction = nullptr
 
G4UserStackingActionuserStackingAction = nullptr
 
G4UserTrackingActionuserTrackingAction = nullptr
 
G4UserSteppingActionuserSteppingAction = nullptr
 
G4bool geometryInitialized = false
 
G4bool physicsInitialized = false
 
G4bool runAborted = false
 
G4bool initializedAtLeastOnce = false
 
G4bool geometryToBeOptimized = true
 
G4int runIDCounter = 0
 
G4int verboseLevel = 0
 
G4int printModulo = -1
 
G4Timertimer = nullptr
 
G4DCtableDCtable = nullptr
 
G4RuncurrentRun = nullptr
 
G4EventcurrentEvent = nullptr
 
std::list< G4Event * > * previousEvents = nullptr
 
G4int n_perviousEventsToBeStored = 0
 
G4int numberOfEventToBeProcessed = 0
 
G4bool storeRandomNumberStatus = false
 
G4int storeRandomNumberStatusToG4Event = 0
 
G4String randomNumberStatusDir = "./"
 
G4String randomNumberStatusForThisRun = ""
 
G4String randomNumberStatusForThisEvent = ""
 
G4bool rngStatusEventsFlag = false
 
G4VPhysicalVolumecurrentWorld = nullptr
 
G4int nParallelWorlds = 0
 
G4String msgText = " "
 
G4int n_select_msg = -1
 
G4int numberOfEventProcessed = 0
 
G4String selectMacro = ""
 
G4bool fakeRun = false
 
G4bool isScoreNtupleWriter = false
 
G4bool geometryDirectlyUpdated = false
 
RMType runManagerType
 
- Static Protected Attributes inherited from G4RunManager
static G4RUN_DLL G4bool fGeometryHasBeenDestroyed = false
 

Detailed Description

Definition at line 48 of file G4WorkerTaskRunManager.hh.

Member Typedef Documentation

◆ G4StrVector

Definition at line 52 of file G4WorkerTaskRunManager.hh.

◆ ProfilerConfig

Constructor & Destructor Documentation

◆ G4WorkerTaskRunManager()

G4WorkerTaskRunManager::G4WorkerTaskRunManager ( )
default

Member Function Documentation

◆ DoCleanup()

void G4WorkerTaskRunManager::DoCleanup ( )
virtual

Definition at line 425 of file G4WorkerTaskRunManager.cc.

426{
428
429 delete currentRun;
430 currentRun = nullptr;
431}
void CleanUpPreviousEvents()
G4Run * currentRun

◆ DoEventLoop()

void G4WorkerTaskRunManager::DoEventLoop ( G4int n_event,
const char * macroFile = nullptr,
G4int n_select = -1 )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 168 of file G4WorkerTaskRunManager.cc.

169{
170 if (userPrimaryGeneratorAction == nullptr) {
171 G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
172 "G4VUserPrimaryGeneratorAction is not defined!");
173 }
174
175 // This is the same as in the sequential case, just the for-loop indexes are
176 // different
177 InitializeEventLoop(n_event, macroFile, n_select);
178
179 // Reset random number seeds queue
180 while (!seedsQueue.empty())
181 seedsQueue.pop();
182 // for each run, worker should receive at least one set of random number
183 // seeds.
184 // runIsSeeded = false;
185
186 // Event loop
187 eventLoopOnGoing = true;
188 G4int i_event = -1;
189 nevModulo = -1;
190 currEvID = -1;
191
192 for (G4int evt = 0; evt < n_event; ++evt) {
193 ProcessOneEvent(i_event);
194 if (eventLoopOnGoing) {
196 if (runAborted) eventLoopOnGoing = false;
197 }
198 if (!eventLoopOnGoing) break;
199 }
200}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
int G4int
Definition G4Types.hh:85
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
virtual void TerminateOneEvent()
void ProcessOneEvent(G4int i_event) override

Referenced by DoWork().

◆ DoWork()

void G4WorkerTaskRunManager::DoWork ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 435 of file G4WorkerTaskRunManager.cc.

436{
438 G4bool newRun = false;
439 const G4Run* run = mrm->GetCurrentRun();
440 G4ThreadLocalStatic G4int runId = -1;
441 if ((run != nullptr) && run->GetRunID() != runId) {
442 runId = run->GetRunID();
443 newRun = true;
444 if (runId > 0) {
445 ProcessUI();
446 assert(workerContext != nullptr);
447 }
449 }
450
451 // Start this run
453 G4int numSelect = mrm->GetNumberOfSelectEvents();
454 G4String macroFile = mrm->GetSelectMacro();
455 G4bool empty_macro = (macroFile.empty() || macroFile == " ");
456
457 const char* macro = (empty_macro) ? nullptr : macroFile.c_str();
458 numSelect = (empty_macro) ? -1 : numSelect;
459
460 if (newRun) {
462 if (cond) {
465 }
466 }
467 DoEventLoop(nevts, macro, numSelect);
468}
bool G4bool
Definition G4Types.hh:86
G4int GetNumberOfEventsToBeProcessed() const
virtual G4bool ConfirmBeamOnCondition()
const G4String & GetSelectMacro() const
const G4Run * GetCurrentRun() const
G4int GetNumberOfSelectEvents() const
Definition G4Run.hh:49
G4int GetRunID() const
Definition G4Run.hh:86
static G4TaskRunManager * GetMasterRunManager()
G4WorkerThread * workerContext
void ConstructScoringWorlds() override
void DoEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1) override
static void UpdateGeometryAndPhysicsVectorFromMaster()
#define G4ThreadLocalStatic
Definition tls.hh:76

Referenced by G4TaskRunManager::CreateAndStartWorkers().

◆ GenerateEvent()

G4Event * G4WorkerTaskRunManager::GenerateEvent ( G4int i_event)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 221 of file G4WorkerTaskRunManager.cc.

222{
223 auto anEvent = new G4Event(i_event);
224 G4long s1 = 0;
225 G4long s2 = 0;
226 G4long s3 = 0;
227 G4bool eventHasToBeSeeded = true;
228 if (G4MTRunManager::SeedOncePerCommunication() == 1 && runIsSeeded) eventHasToBeSeeded = false;
229
230 if (i_event < 0) {
232 if (nevM == 1) {
234 eventHasToBeSeeded);
235 runIsSeeded = true;
236 }
237 else {
238 if (nevModulo <= 0) {
240 eventHasToBeSeeded);
241 if (nevToDo == 0)
242 eventLoopOnGoing = false;
243 else {
244 currEvID = anEvent->GetEventID();
245 nevModulo = nevToDo - 1;
246 }
247 }
248 else {
249 if (G4MTRunManager::SeedOncePerCommunication() > 0) eventHasToBeSeeded = false;
250 anEvent->SetEventID(++currEvID);
251 nevModulo--;
252 }
253 if (eventLoopOnGoing && eventHasToBeSeeded) {
254 s1 = seedsQueue.front();
255 seedsQueue.pop();
256 s2 = seedsQueue.front();
257 seedsQueue.pop();
258 }
259 }
260
261 if (!eventLoopOnGoing) {
262 delete anEvent;
263 return nullptr;
264 }
265 }
266 else if (eventHasToBeSeeded) {
267 // Need to reseed random number generator
269 s1 = helper->GetSeed(i_event * 2);
270 s2 = helper->GetSeed(i_event * 2 + 1);
271 }
272
273 if (eventHasToBeSeeded) {
274 G4long seeds[3] = {s1, s2, 0};
275 G4Random::setTheSeeds(seeds, -1);
276 runIsSeeded = true;
277 }
278
279 // Read from file seed.
280 // Andrea Dotti 4 November 2015
281 // This is required for strong-reproducibility, in MT mode we have that each
282 // thread produces, for each event a status file, we want to do that.
283 // Search a random file with the format run{%d}evt{%d}.rndm
284
285 // This is the filename base constructed from run and event
286 const auto filename = [&] {
287 std::ostringstream os;
288 os << "run" << currentRun->GetRunID() << "evt" << anEvent->GetEventID();
289 return os.str();
290 };
291
292 G4bool RNGstatusReadFromFile = false;
293 if (readStatusFromFile) {
294 // Build full path of RNG status file for this event
295 std::ostringstream os;
296 os << filename() << ".rndm";
297 const G4String& randomStatusFile = os.str();
298 std::ifstream ifile(randomStatusFile.c_str());
299 if (ifile) {
300 // File valid and readable
301 RNGstatusReadFromFile = true;
302 G4Random::restoreEngineStatus(randomStatusFile.c_str());
303 }
304 }
305
307 std::ostringstream oss;
308 G4Random::saveFullState(oss);
310 anEvent->SetRandomNumberStatus(randomNumberStatusForThisEvent);
311 }
312
313 if (storeRandomNumberStatus && !RNGstatusReadFromFile) {
314 // If reading from file, avoid to rewrite the same
315 G4String fileN = "currentEvent";
316 if (rngStatusEventsFlag) fileN = filename();
317 StoreRNGStatus(fileN);
318 }
319
320 if (printModulo > 0 && anEvent->GetEventID() % printModulo == 0) {
321 G4cout << "--> Event " << anEvent->GetEventID() << " starts";
322 if (eventHasToBeSeeded) G4cout << " with initial seeds (" << s1 << "," << s2 << ")";
323 G4cout << "." << G4endl;
324 }
326 return anEvent;
327}
long G4long
Definition G4Types.hh:87
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4int SeedOncePerCommunication()
virtual G4int SetUpNEvents(G4Event *, G4SeedsQueue *seedsQueue, G4bool reseedRequired=true)
G4int GetEventModulo() const
static G4MTRunManager * GetMasterRunManager()
virtual G4bool SetUpAnEvent(G4Event *, G4long &s1, G4long &s2, G4long &s3, G4bool reseedRequired=true)
G4int storeRandomNumberStatusToG4Event
G4bool rngStatusEventsFlag
G4String randomNumberStatusForThisEvent
G4bool storeRandomNumberStatus
static G4TemplateRNGHelper< T > * GetInstance()
virtual const T GetSeed(const G4int &sdId)
virtual void GeneratePrimaries(G4Event *anEvent)=0
void StoreRNGStatus(const G4String &filenamePrefix) override

Referenced by ProcessOneEvent().

◆ GetCommandStack()

G4StrVector G4WorkerTaskRunManager::GetCommandStack ( ) const
inline

Definition at line 72 of file G4WorkerTaskRunManager.hh.

72{ return processedCommandStack; }

◆ GetWorkerRunManager()

G4WorkerTaskRunManager * G4WorkerTaskRunManager::GetWorkerRunManager ( )
static

◆ GetWorkerRunManagerKernel()

G4WorkerTaskRunManagerKernel * G4WorkerTaskRunManager::GetWorkerRunManagerKernel ( )
static

Definition at line 68 of file G4WorkerTaskRunManager.cc.

69{
71}
G4RunManagerKernel * kernel
static G4WorkerTaskRunManager * GetWorkerRunManager()

◆ GetWorkerThread()

G4WorkerThread * G4WorkerTaskRunManager::GetWorkerThread ( ) const
inline

Definition at line 71 of file G4WorkerTaskRunManager.hh.

71{ return workerContext; }

Referenced by G4TaskRunManagerKernel::TerminateWorker().

◆ ProcessOneEvent()

void G4WorkerTaskRunManager::ProcessOneEvent ( G4int i_event)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 204 of file G4WorkerTaskRunManager.cc.

205{
206 currentEvent = GenerateEvent(i_event);
207 if (eventLoopOnGoing) {
212 G4cout << "Applying command \"" << msgText << "\" @ " << __FUNCTION__ << ":" << __LINE__
213 << G4endl;
215 }
216 }
217}
void ProcessOneEvent(G4Event *anEvent)
G4int GetEventID() const
Definition G4Event.hh:123
G4String msgText
G4EventManager * eventManager
virtual void AnalyzeEvent(G4Event *anEvent)
void UpdateScoring()
G4Event * currentEvent
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
G4Event * GenerateEvent(G4int i_event) override

Referenced by DoEventLoop().

◆ ProcessUI()

void G4WorkerTaskRunManager::ProcessUI ( )
virtual

Definition at line 397 of file G4WorkerTaskRunManager.cc.

398{
400 if (mrm == nullptr) return;
401
402 //------------------------------------------------------------------------//
403 // Check UI commands not already processed
404 auto command_stack = mrm->GetCommandStack();
405 bool matching = (command_stack.size() == processedCommandStack.size());
406 if (matching) {
407 for (uintmax_t i = 0; i < command_stack.size(); ++i)
408 if (processedCommandStack.at(i) != command_stack.at(i)) {
409 matching = false;
410 break;
411 }
412 }
413
414 //------------------------------------------------------------------------//
415 // Execute UI commands stored in the master UI manager
416 if (!matching) {
417 for (const auto& itr : command_stack)
419 processedCommandStack = command_stack;
420 }
421}
std::vector< G4String > GetCommandStack()

Referenced by DoWork().

◆ RestoreRndmEachEvent()

void G4WorkerTaskRunManager::RestoreRndmEachEvent ( G4bool flag)
inlineoverridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 67 of file G4WorkerTaskRunManager.hh.

67{ readStatusFromFile = flag; }

◆ RunInitialization()

void G4WorkerTaskRunManager::RunInitialization ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 75 of file G4WorkerTaskRunManager.cc.

76{
77#ifdef G4MULTITHREADED
78 if (!visIsSetUp) {
80 if (pVVis != nullptr) {
81 pVVis->SetUpForAThread();
82 visIsSetUp = true;
83 }
84 }
85#endif
86 runIsSeeded = false;
87
88 if (!(kernel->RunInitialization(fakeRun))) return;
89
90 // Signal this thread can start event loop.
91 // Note this will return only when all threads reach this point
93 if (fakeRun) return;
94
97
99
100 delete currentRun;
101
102 currentRun = nullptr;
103
105
106 // Call a user hook: this is guaranteed all threads are "synchronized"
107 if (uwi != nullptr) uwi->WorkerRunStart();
108
110 if (currentRun == nullptr) currentRun = new G4Run();
111
116
119 if (fSDM != nullptr) {
121 }
122
123 if (G4VScoreNtupleWriter::Instance() != nullptr) {
124 auto hce = (fSDM != nullptr) ? fSDM->PrepareNewEvent() : nullptr;
126 delete hce;
127 }
128
129 std::ostringstream oss;
130 G4Random::saveFullState(oss);
133
134 for (G4int i_prev = 0; i_prev < n_perviousEventsToBeStored; ++i_prev)
135 previousEvents->push_back(nullptr);
136
137 if (printModulo > 0 || verboseLevel > 0) {
138 G4cout << "### Run " << currentRun->GetRunID() << " starts on worker thread "
139 << G4Threading::G4GetThreadId() << "." << G4endl;
140 }
141
143
144#if defined(GEANT4_USE_TIMEMORY)
145 workerRunProfiler.reset(new ProfilerConfig(currentRun));
146#endif
147
150 }
151
153 G4String fileN = "currentRun";
155 std::ostringstream os;
156 os << "run" << currentRun->GetRunID();
157 fileN = os.str();
158 }
159 StoreRNGStatus(fileN);
160 }
161
162 runAborted = false;
164}
virtual void ThisWorkerReady()
static G4ParallelWorldProcessStore * GetInstance()
G4bool RunInitialization(G4bool fakeRun=false)
G4bool isScoreNtupleWriter
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
std::list< G4Event * > * previousEvents
G4int numberOfEventProcessed
G4DCtable * DCtable
G4String randomNumberStatusForThisRun
static G4bool IfGeometryHasBeenDestroyed()
G4UserRunAction * userRunAction
G4int numberOfEventToBeProcessed
G4int n_perviousEventsToBeStored
void SetHCtable(G4HCtable *HCtbl)
Definition G4Run.hh:108
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition G4Run.hh:107
void SetRunID(G4int id)
Definition G4Run.hh:106
void SetDCtable(G4DCtable *DCtbl)
Definition G4Run.hh:109
void SetRandomNumberStatus(G4String &st)
Definition G4Run.hh:110
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4HCtable * GetHCtable() const
virtual G4Run * GenerateRun()
virtual void BeginOfRunAction(const G4Run *)
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0
static G4VVisManager * GetConcreteInstance()
G4ProfilerConfig< G4ProfileType::Run > ProfilerConfig
G4int G4GetThreadId()

Referenced by DoWork().

◆ RunTermination()

void G4WorkerTaskRunManager::RunTermination ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 331 of file G4WorkerTaskRunManager.cc.

332{
333 if (!fakeRun && (currentRun != nullptr)) {
334#if defined(GEANT4_USE_TIMEMORY)
335 workerRunProfiler.reset();
336#endif
338
339 // Call a user hook: note this is before the next barrier
340 // so threads execute this method asyncrhonouzly
341 //(TerminateRun allows for synch via G4RunAction::EndOfRun)
342 const G4UserWorkerInitialization* uwi =
344 if (uwi != nullptr) uwi->WorkerRunEnd();
345 }
346
347 if (currentRun != nullptr) {
349 }
350 // Signal this thread has finished envent-loop.
351 // Note this will return only whan all threads reach this point
353}
virtual void ThisWorkerEndEventLoop()
virtual void RunTermination()
virtual void MergePartialResults()

Referenced by G4TaskRunManagerKernel::TerminateWorkerRunEventLoop().

◆ StoreRNGStatus()

void G4WorkerTaskRunManager::StoreRNGStatus ( const G4String & filenamePrefix)
overrideprotectedvirtual

Reimplemented from G4WorkerRunManager.

Definition at line 388 of file G4WorkerTaskRunManager.cc.

389{
390 std::ostringstream os;
391 os << randomNumberStatusDir << "G4Worker" << workerContext->GetThreadId() << "_" << fn << ".rndm";
392 G4Random::saveEngineStatus(os.str().c_str());
393}
G4String randomNumberStatusDir
G4int GetThreadId() const

Referenced by GenerateEvent(), and RunInitialization().

◆ TerminateEventLoop()

void G4WorkerTaskRunManager::TerminateEventLoop ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 357 of file G4WorkerTaskRunManager.cc.

358{
359 if (verboseLevel > 0 && !fakeRun) {
360 timer->Stop();
361 // prefix with thread # info due to how TBB calls this function
362 G4String prefix = "[thread " + std::to_string(workerContext->GetThreadId()) + "] ";
363 G4cout << prefix << "Thread-local run terminated." << G4endl;
364 G4cout << prefix << "Run Summary" << G4endl;
365 if (runAborted)
366 G4cout << prefix << " Run Aborted after " << numberOfEventProcessed << " events processed."
367 << G4endl;
368 else
369 G4cout << prefix << " Number of events processed : " << numberOfEventProcessed << G4endl;
370 G4cout << prefix << " " << *timer << G4endl;
371 }
372}
G4Timer * timer
void Stop()

Referenced by G4TaskRunManagerKernel::TerminateWorkerRunEventLoop().


The documentation for this class was generated from the following files: