Geant4 10.7.0
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 >
 
typedef std::vector< G4StringG4StrVector
 
- 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 ()
 
virtual void RunInitialization () override
 
virtual void DoEventLoop (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1) override
 
virtual void ProcessOneEvent (G4int i_event) override
 
virtual G4EventGenerateEvent (G4int i_event) override
 
virtual void RunTermination () override
 
virtual void TerminateEventLoop () override
 
virtual void DoWork () override
 
virtual void RestoreRndmEachEvent (G4bool flag) override
 
virtual void DoCleanup ()
 
virtual void ProcessUI ()
 
G4WorkerThreadGetWorkerThread () const
 
G4StrVector GetCommandStack () const
 
- Public Member Functions inherited from G4WorkerRunManager
 G4WorkerRunManager ()
 
 ~G4WorkerRunManager ()
 
virtual void InitializeGeometry ()
 
virtual void RunInitialization ()
 
virtual void DoEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void ProcessOneEvent (G4int i_event)
 
virtual G4EventGenerateEvent (G4int i_event)
 
virtual void RunTermination ()
 
virtual void TerminateEventLoop ()
 
virtual void DoWork ()
 
void SetWorkerThread (G4WorkerThread *wc)
 Sets the worker context.
 
virtual void SetUserInitialization (G4VUserPhysicsList *userInit)
 
virtual void SetUserInitialization (G4VUserDetectorConstruction *userInit)
 
virtual void SetUserInitialization (G4VUserActionInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerThreadInitialization *userInit)
 
virtual void SetUserAction (G4UserRunAction *userAction)
 
virtual void SetUserAction (G4VUserPrimaryGeneratorAction *userAction)
 
virtual void SetUserAction (G4UserEventAction *userAction)
 
virtual void SetUserAction (G4UserStackingAction *userAction)
 
virtual void SetUserAction (G4UserTrackingAction *userAction)
 
virtual void SetUserAction (G4UserSteppingAction *userAction)
 
virtual void RestoreRndmEachEvent (G4bool flag)
 
- Public Member Functions inherited from G4RunManager
 G4RunManager ()
 
virtual ~G4RunManager ()
 
virtual void BeamOn (G4int n_event, const char *macroFile=0, 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 InitializeGeometry ()
 
virtual void InitializePhysics ()
 
virtual G4bool ConfirmBeamOnCondition ()
 
virtual void RunInitialization ()
 
virtual void DoEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void RunTermination ()
 
virtual void InitializeEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void ProcessOneEvent (G4int i_event)
 
virtual void TerminateOneEvent ()
 
virtual void TerminateEventLoop ()
 
virtual G4EventGenerateEvent (G4int i_event)
 
virtual void AnalyzeEvent (G4Event *anEvent)
 
virtual void ConfigureProfilers (const std::vector< std::string > &args={})
 
void ConfigureProfilers (int argc, char **argv)
 
virtual void SetNumberOfThreads (G4int)
 
virtual G4int GetNumberOfThreads () const
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=0) const
 
virtual void rndmSaveThisRun ()
 
virtual void rndmSaveThisEvent ()
 
virtual void RestoreRandomNumberStatus (const G4String &fileN)
 
virtual void SetUserInitialization (G4VUserDetectorConstruction *userInit)
 
virtual void SetUserInitialization (G4VUserPhysicsList *userInit)
 
virtual void SetUserInitialization (G4VUserActionInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerThreadInitialization *userInit)
 
virtual void SetUserAction (G4UserRunAction *userAction)
 
virtual void SetUserAction (G4VUserPrimaryGeneratorAction *userAction)
 
virtual void SetUserAction (G4UserEventAction *userAction)
 
virtual void SetUserAction (G4UserStackingAction *userAction)
 
virtual void SetUserAction (G4UserTrackingAction *userAction)
 
virtual void SetUserAction (G4UserSteppingAction *userAction)
 
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 GeometryHasBeenModified (G4bool prop=true)
 
void ReinitializeGeometry (G4bool destroyFirst=false, G4bool prop=true)
 
void PhysicsHasBeenModified ()
 
void CutOffHasBeenModified ()
 
void ReOptimizeMotherOf (G4VPhysicalVolume *)
 
void ReOptimize (G4LogicalVolume *)
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
G4int GetPrintProgress ()
 
void SetPrintProgress (G4int i)
 
void SetGeometryToBeOptimized (G4bool vl)
 
G4bool GetGeometryToBeOptimized ()
 
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
 
G4String GetSelectMacro () const
 
void SetDCtable (G4DCtable *DCtbl)
 
RMType GetRunManagerType () const
 
virtual void ConstructScoringWorlds ()
 
virtual void RestoreRndmEachEvent (G4bool)
 
void GeometryDirectlyUpdated (G4bool val=true)
 

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

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

Additional Inherited Members

- Protected Attributes inherited from G4WorkerRunManager
G4WorkerThreadworkerContext
 
G4bool eventLoopOnGoing
 
G4bool runIsSeeded
 
G4int nevModulo
 
G4int currEvID
 
G4int luxury
 
G4SeedsQueue seedsQueue
 
G4bool readStatusFromFile
 
- Protected Attributes inherited from G4RunManager
G4RunManagerKernelkernel
 
G4EventManagereventManager
 
G4VUserDetectorConstructionuserDetector
 
G4VUserPhysicsListphysicsList
 
G4VUserActionInitializationuserActionInitialization
 
G4UserWorkerInitializationuserWorkerInitialization
 
G4UserWorkerThreadInitializationuserWorkerThreadInitialization
 
G4UserRunActionuserRunAction
 
G4VUserPrimaryGeneratorActionuserPrimaryGeneratorAction
 
G4UserEventActionuserEventAction
 
G4UserStackingActionuserStackingAction
 
G4UserTrackingActionuserTrackingAction
 
G4UserSteppingActionuserSteppingAction
 
G4bool geometryInitialized
 
G4bool physicsInitialized
 
G4bool runAborted
 
G4bool initializedAtLeastOnce
 
G4bool geometryToBeOptimized
 
G4int runIDCounter
 
G4int verboseLevel
 
G4int printModulo
 
G4Timertimer
 
G4DCtableDCtable
 
G4RuncurrentRun
 
G4EventcurrentEvent
 
std::list< G4Event * > * previousEvents
 
G4int n_perviousEventsToBeStored
 
G4int numberOfEventToBeProcessed
 
G4bool storeRandomNumberStatus
 
G4int storeRandomNumberStatusToG4Event
 
G4String randomNumberStatusDir
 
G4String randomNumberStatusForThisRun
 
G4String randomNumberStatusForThisEvent
 
G4bool rngStatusEventsFlag
 
G4VPhysicalVolumecurrentWorld
 
G4int nParallelWorlds
 
G4String msgText
 
G4int n_select_msg
 
G4int numberOfEventProcessed
 
G4String selectMacro
 
G4bool fakeRun
 
G4bool isScoreNtupleWriter
 
RMType runManagerType
 
G4bool geometryDirectlyUpdated
 
- 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 54 of file G4WorkerTaskRunManager.hh.

◆ ProfilerConfig

Constructor & Destructor Documentation

◆ G4WorkerTaskRunManager()

G4WorkerTaskRunManager::G4WorkerTaskRunManager ( )

Definition at line 81 of file G4WorkerTaskRunManager.cc.

Member Function Documentation

◆ DoCleanup()

void G4WorkerTaskRunManager::DoCleanup ( )
virtual

Definition at line 497 of file G4WorkerTaskRunManager.cc.

498{
500 if(currentRun)
501 delete currentRun;
502 currentRun = nullptr;
503}
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 194 of file G4WorkerTaskRunManager.cc.

196{
198 {
199 G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
200 "G4VUserPrimaryGeneratorAction is not defined!");
201 }
202
203 // This is the same as in the sequential case, just the for-loop indexes are
204 // different
205 InitializeEventLoop(n_event, macroFile, n_select);
206
207 // Reset random number seeds queue
208 while(seedsQueue.size() > 0)
209 seedsQueue.pop();
210 // for each run, worker should receive at least one set of random number
211 // seeds.
212 // runIsSeeded = false;
213
214 // Event loop
215 eventLoopOnGoing = true;
216 G4int i_event = -1;
217 nevModulo = -1;
218 currEvID = -1;
219
220 for(G4int evt = 0; evt < n_event; ++evt)
221 {
222 ProcessOneEvent(i_event);
224 {
226 if(runAborted)
227 eventLoopOnGoing = false;
228 }
229 else
230 {
232 }
233 }
234
235 // TerminateEventLoop();
236}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
int G4int
Definition: G4Types.hh:85
G4int numberOfEventProcessed
G4bool runAborted
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
virtual void TerminateOneEvent()
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual void ProcessOneEvent(G4int i_event) override

Referenced by DoWork().

◆ DoWork()

void G4WorkerTaskRunManager::DoWork ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 507 of file G4WorkerTaskRunManager.cc.

508{
510 G4bool newRun = false;
511 const G4Run* run = mrm->GetCurrentRun();
512 G4ThreadLocalStatic G4int runId = -1;
513 if(run && run->GetRunID() != runId)
514 {
515 runId = run->GetRunID();
516 newRun = true;
517 if(runId > 0)
518 {
519 ProcessUI();
520 assert(workerContext != nullptr);
521 }
523 }
524
525 // Start this run
527 G4int numSelect = mrm->GetNumberOfSelectEvents();
528 G4String macroFile = mrm->GetSelectMacro();
529 bool empty_macro = (macroFile == "" || macroFile == " ");
530
531 const char* macro = (empty_macro) ? nullptr : macroFile.c_str();
532 numSelect = (empty_macro) ? -1 : numSelect;
533
534 if(newRun)
535 {
537 if(cond)
538 {
541 }
542 }
543 DoEventLoop(nevts, macro, numSelect);
544}
bool G4bool
Definition: G4Types.hh:86
G4int GetNumberOfEventsToBeProcessed() const
virtual G4bool ConfirmBeamOnCondition()
const G4Run * GetCurrentRun() const
G4String GetSelectMacro() const
G4int GetNumberOfSelectEvents() const
Definition: G4Run.hh:49
G4int GetRunID() const
Definition: G4Run.hh:82
static G4TaskRunManager * GetMasterRunManager()
virtual void ConstructScoringWorlds()
G4WorkerThread * workerContext
virtual void DoEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1) override
virtual void RunInitialization() override
static void UpdateGeometryAndPhysicsVectorFromMaster()
#define G4ThreadLocalStatic
Definition: tls.hh:76

Referenced by G4TaskRunManager::CreateAndStartWorkers().

◆ GenerateEvent()

G4Event * G4WorkerTaskRunManager::GenerateEvent ( G4int  i_event)
overridevirtual

virtual void BuildPhysicsTables();

G4cout<<"Event "<<currEvID<<" is seeded with { "<<s1<<", "<<s2<<" }"<<G4endl;

G4cout<<"Event "<<currEvID<<" is seeded with { "<<s1<<", "<<s2<<" }"<<G4endl;

Reimplemented from G4WorkerRunManager.

Definition at line 259 of file G4WorkerTaskRunManager.cc.

260{
261 G4Event* anEvent = new G4Event(i_event);
262 long s1 = 0;
263 long s2 = 0;
264 long s3 = 0;
265 G4bool eventHasToBeSeeded = true;
267 eventHasToBeSeeded = false;
268
269 if(i_event < 0)
270 {
272 if(nevM == 1)
273 {
275 anEvent, s1, s2, s3, eventHasToBeSeeded);
276 runIsSeeded = true;
277 }
278 else
279 {
280 if(nevModulo <= 0)
281 {
283 anEvent, &seedsQueue, eventHasToBeSeeded);
284 if(nevToDo == 0)
285 eventLoopOnGoing = false;
286 else
287 {
288 currEvID = anEvent->GetEventID();
289 nevModulo = nevToDo - 1;
290 }
291 }
292 else
293 {
295 eventHasToBeSeeded = false;
296 anEvent->SetEventID(++currEvID);
297 nevModulo--;
298 }
299 if(eventLoopOnGoing && eventHasToBeSeeded)
300 {
301 s1 = seedsQueue.front();
302 seedsQueue.pop();
303 s2 = seedsQueue.front();
304 seedsQueue.pop();
305 }
306 }
307
309 {
310 delete anEvent;
311 return nullptr;
312 }
313 }
314 else if(eventHasToBeSeeded)
315 {
316 // Need to reseed random number generator
318 s1 = helper->GetSeed(i_event * 2);
319 s2 = helper->GetSeed(i_event * 2 + 1);
320 }
321
322 if(eventHasToBeSeeded)
323 {
324 long seeds[3] = { s1, s2, 0 };
325 G4Random::setTheSeeds(seeds, -1);
326 runIsSeeded = true;
327 ////G4cout<<"Event "<<currEvID<<" is seeded with { "<<s1<<", "<<s2<<"
328 ///}"<<G4endl;
329 }
330
331 // Read from file seed.
332 // Andrea Dotti 4 November 2015
333 // This is required for strong-reproducibility, in MT mode we have that each
334 // thread produces, for each event a status file, we want to do that.
335 // Search a random file with the format run{%d}evt{%d}.rndm
336
337 // This is the filename base constructed from run and event
338 const auto filename = [&] {
339 std::ostringstream os;
340 os << "run" << currentRun->GetRunID() << "evt" << anEvent->GetEventID();
341 return os.str();
342 };
343
344 G4bool RNGstatusReadFromFile = false;
346 {
347 // Build full path of RNG status file for this event
348 std::ostringstream os;
349 os << filename() << ".rndm";
350 const G4String& randomStatusFile = os.str();
351 std::ifstream ifile(randomStatusFile.c_str());
352 if(ifile)
353 {
354 // File valid and readable
355 RNGstatusReadFromFile = true;
356 G4Random::restoreEngineStatus(randomStatusFile.c_str());
357 }
358 }
359
362 {
363 std::ostringstream oss;
364 G4Random::saveFullState(oss);
367 }
368
369 if(storeRandomNumberStatus && !RNGstatusReadFromFile)
370 {
371 // If reading from file, avoid to rewrite the same
372 G4String fileN = "currentEvent";
374 fileN = filename();
375 StoreRNGStatus(fileN);
376 }
377
378 if(printModulo > 0 && anEvent->GetEventID() % printModulo == 0)
379 {
380 G4cout << "--> Event " << anEvent->GetEventID() << " starts";
381 if(eventHasToBeSeeded)
382 G4cout << " with initial seeds (" << s1 << "," << s2 << ")";
383 G4cout << "." << G4endl;
384 }
386 return anEvent;
387}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetRandomNumberStatus(G4String &st)
Definition: G4Event.hh:90
G4int GetEventID() const
Definition: G4Event.hh:118
void SetEventID(G4int i)
Definition: G4Event.hh:80
static G4int SeedOncePerCommunication()
virtual G4int SetUpNEvents(G4Event *, G4SeedsQueue *seedsQueue, G4bool reseedRequired=true)
virtual G4bool SetUpAnEvent(G4Event *, long &s1, long &s2, long &s3, G4bool reseedRequired=true)
G4int GetEventModulo() const
static G4MTRunManager * GetMasterRunManager()
G4int storeRandomNumberStatusToG4Event
G4bool rngStatusEventsFlag
G4String randomNumberStatusForThisEvent
G4bool storeRandomNumberStatus
static G4TemplateRNGHelper< T > * GetInstance()
Definition: G4RNGHelper.cc:37
virtual const T GetSeed(const G4int &sdId)
Definition: G4RNGHelper.hh:58
virtual void GeneratePrimaries(G4Event *anEvent)=0
virtual void StoreRNGStatus(const G4String &filenamePrefix) override

Referenced by ProcessOneEvent().

◆ GetCommandStack()

G4StrVector G4WorkerTaskRunManager::GetCommandStack ( ) const
inline

Definition at line 78 of file G4WorkerTaskRunManager.hh.

78{ return processedCommandStack; }

◆ GetWorkerRunManager()

G4WorkerTaskRunManager * G4WorkerTaskRunManager::GetWorkerRunManager ( )
static

◆ GetWorkerRunManagerKernel()

G4WorkerTaskRunManagerKernel * G4WorkerTaskRunManager::GetWorkerRunManagerKernel ( )
static

Definition at line 73 of file G4WorkerTaskRunManager.cc.

74{
75 return static_cast<G4WorkerTaskRunManagerKernel*>(
77}
G4RunManagerKernel * kernel
static G4WorkerTaskRunManager * GetWorkerRunManager()

◆ GetWorkerThread()

G4WorkerThread * G4WorkerTaskRunManager::GetWorkerThread ( ) const
inline

Definition at line 77 of file G4WorkerTaskRunManager.hh.

77{ return workerContext; }

Referenced by G4TaskRunManagerKernel::TerminateWorker().

◆ ProcessOneEvent()

void G4WorkerTaskRunManager::ProcessOneEvent ( G4int  i_event)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 240 of file G4WorkerTaskRunManager.cc.

241{
242 currentEvent = GenerateEvent(i_event);
244 {
249 {
250 G4cout << "Applying command \"" << msgText << "\" @ " << __FUNCTION__
251 << ":" << __LINE__ << G4endl;
253 }
254 }
255}
void ProcessOneEvent(G4Event *anEvent)
G4int n_select_msg
G4String msgText
G4EventManager * eventManager
virtual void AnalyzeEvent(G4Event *anEvent)
void UpdateScoring()
G4Event * currentEvent
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
virtual G4Event * GenerateEvent(G4int i_event) override

Referenced by DoEventLoop().

◆ ProcessUI()

void G4WorkerTaskRunManager::ProcessUI ( )
virtual

Definition at line 465 of file G4WorkerTaskRunManager.cc.

466{
468 if(!mrm)
469 return;
470
471 //------------------------------------------------------------------------//
472 // Check UI commands not already processed
473 auto command_stack = mrm->GetCommandStack();
474 bool matching = (command_stack.size() == processedCommandStack.size());
475 if(matching)
476 {
477 for(uintmax_t i = 0; i < command_stack.size(); ++i)
478 if(processedCommandStack.at(i) != command_stack.at(i))
479 {
480 matching = false;
481 break;
482 }
483 }
484
485 //------------------------------------------------------------------------//
486 // Execute UI commands stored in the master UI manager
487 if(!matching)
488 {
489 for(const auto& itr : command_stack)
491 processedCommandStack = command_stack;
492 }
493}
std::vector< G4String > GetCommandStack()

Referenced by DoWork().

◆ RestoreRndmEachEvent()

virtual void G4WorkerTaskRunManager::RestoreRndmEachEvent ( G4bool  flag)
inlineoverridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 70 of file G4WorkerTaskRunManager.hh.

71 {
72 readStatusFromFile = flag;
73 }

◆ RunInitialization()

void G4WorkerTaskRunManager::RunInitialization ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 87 of file G4WorkerTaskRunManager.cc.

88{
89#ifdef G4MULTITHREADED
90 if(!visIsSetUp)
91 {
93 if(pVVis)
94 {
95 pVVis->SetUpForAThread();
96 visIsSetUp = true;
97 }
98 }
99#endif
100 runIsSeeded = false;
101
103 return;
104
105 // Signal this thread can start event loop.
106 // Note this will return only when all threads reach this point
108 if(fakeRun)
109 return;
110
111 const G4UserWorkerInitialization* uwi =
113
115 if(currentRun)
116 delete currentRun;
117
118 currentRun = nullptr;
119
122
123 // Call a user hook: this is guaranteed all threads are "synchronized"
124 if(uwi)
125 uwi->WorkerRunStart();
126
127 if(userRunAction)
129 if(!currentRun)
130 currentRun = new G4Run();
131
136
139 if(fSDM)
141
143 {
144 auto hce = fSDM->PrepareNewEvent();
146 delete hce;
147 }
148
149 std::ostringstream oss;
150 G4Random::saveFullState(oss);
153
154 for(G4int i_prev = 0; i_prev < n_perviousEventsToBeStored; ++i_prev)
155 previousEvents->push_back(nullptr);
156
157 if(printModulo > 0 || verboseLevel > 0)
158 {
159 G4cout << "### Run " << currentRun->GetRunID()
160 << " starts on worker thread " << G4Threading::G4GetThreadId() << "."
161 << G4endl;
162 }
163
164 if(userRunAction)
166
167#if defined(GEANT4_USE_TIMEMORY)
168 workerRunProfiler.reset(new ProfilerConfig(currentRun));
169#endif
170
172 {
174 }
175
177 {
178 G4String fileN = "currentRun";
180 {
181 std::ostringstream os;
182 os << "run" << currentRun->GetRunID();
183 fileN = os.str();
184 }
185 StoreRNGStatus(fileN);
186 }
187
188 runAborted = false;
190}
virtual void ThisWorkerReady()
static G4ParallelWorldProcessStore * GetInstance()
G4bool RunInitialization(G4bool fakeRun=false)
G4bool isScoreNtupleWriter
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
std::list< G4Event * > * previousEvents
G4int runIDCounter
G4int verboseLevel
G4DCtable * DCtable
G4String randomNumberStatusForThisRun
static G4bool IfGeometryHasBeenDestroyed()
Definition: G4RunManager.cc:73
G4UserRunAction * userRunAction
G4int numberOfEventToBeProcessed
G4int n_perviousEventsToBeStored
void SetHCtable(G4HCtable *HCtbl)
Definition: G4Run.hh:106
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition: G4Run.hh:102
void SetRunID(G4int id)
Definition: G4Run.hh:101
void SetDCtable(G4DCtable *DCtbl)
Definition: G4Run.hh:107
void SetRandomNumberStatus(G4String &st)
Definition: G4Run.hh:108
G4HCofThisEvent * PrepareNewEvent()
Definition: G4SDManager.cc:109
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:48
G4HCtable * GetHCtable() const
Definition: G4SDManager.hh:103
virtual void BeginOfRunAction(const G4Run *aRun)
virtual G4Run * GenerateRun()
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0
static G4VVisManager * GetConcreteInstance()
G4ProfilerConfig< G4ProfileType::Run > ProfilerConfig
G4int G4GetThreadId()
Definition: G4Threading.cc:122

Referenced by DoWork().

◆ RunTermination()

void G4WorkerTaskRunManager::RunTermination ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 391 of file G4WorkerTaskRunManager.cc.

392{
393 if(!fakeRun && currentRun)
394 {
395#if defined(GEANT4_USE_TIMEMORY)
396 workerRunProfiler.reset();
397#endif
399
400 // Call a user hook: note this is before the next barrier
401 // so threads execute this method asyncrhonouzly
402 //(TerminateRun allows for synch via G4RunAction::EndOfRun)
403 const G4UserWorkerInitialization* uwi =
405 if(uwi)
406 uwi->WorkerRunEnd();
407 }
408
409 if(currentRun)
410 {
412 }
413 // Signal this thread has finished envent-loop.
414 // Note this will return only whan all threads reach this point
416}
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 455 of file G4WorkerTaskRunManager.cc.

456{
457 std::ostringstream os;
458 os << randomNumberStatusDir << "G4Worker" << workerContext->GetThreadId()
459 << "_" << fn << ".rndm";
460 G4Random::saveEngineStatus(os.str().c_str());
461}
G4String randomNumberStatusDir
G4int GetThreadId() const

Referenced by GenerateEvent(), and RunInitialization().

◆ TerminateEventLoop()

void G4WorkerTaskRunManager::TerminateEventLoop ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 420 of file G4WorkerTaskRunManager.cc.

421{
422 if(verboseLevel > 0 && !fakeRun)
423 {
424 timer->Stop();
425 // prefix with thread # info due to how TBB calls this function
427 "[thread " + std::to_string(workerContext->GetThreadId()) + "] ";
428 G4cout << prefix << "Thread-local run terminated." << G4endl;
429 G4cout << prefix << "Run Summary" << G4endl;
430 if(runAborted)
431 G4cout << prefix << " Run Aborted after " << numberOfEventProcessed
432 << " events processed." << G4endl;
433 else
434 G4cout << prefix
435 << " Number of events processed : " << numberOfEventProcessed
436 << G4endl;
437 G4cout << prefix << " " << *timer << G4endl;
438 }
439}
G4Timer * timer
void Stop()

Referenced by G4TaskRunManagerKernel::TerminateWorkerRunEventLoop().


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