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

#include <G4WorkerSubEvtRunManager.hh>

Inheritance diagram for G4WorkerSubEvtRunManager:

Public Member Functions

 G4WorkerSubEvtRunManager (G4int subEventType=0)
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
void DoCleanup () override
void ProcessUI () override
void SetUserInitialization (G4VUserPhysicsList *userPL) override
void SetUserInitialization (G4VUserDetectorConstruction *userDC) override
void SetUserInitialization (G4UserWorkerInitialization *userInit) override
void SetUserInitialization (G4UserWorkerThreadInitialization *userInit) override
void SetUserInitialization (G4VUserActionInitialization *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
G4int GetSubEventType () const override
void SetSubEventType (G4int) override
Public Member Functions inherited from G4WorkerTaskRunManager
 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
G4WorkerThreadGetWorkerThread () const
G4StrVector GetCommandStack () const
Public Member Functions inherited from G4WorkerRunManager
 G4WorkerRunManager ()
 ~G4WorkerRunManager () override
void InitializeGeometry () override
void SetWorkerThread (G4WorkerThread *wc)
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 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)
void SetDefaultClassification (G4TrackStatus ts, G4ClassificationOfNewTrack val, G4ExceptionSeverity es=G4ExceptionSeverity::IgnoreTheIssue)
void SetDefaultClassification (const G4ParticleDefinition *pd, G4ClassificationOfNewTrack val, G4ExceptionSeverity es=G4ExceptionSeverity::IgnoreTheIssue)
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
virtual void RegisterSubEventType (G4int, G4int)
virtual void MergeTrajectories (const G4SubEvent *, const G4Event *)
virtual void UpdateScoringForSubEvent (const G4SubEvent *, const G4Event *)
virtual const G4SubEventGetSubEvent (G4int, G4bool &, G4long &, G4long &, G4long &, G4bool)
virtual void SubEventFinished (const G4SubEvent *, const G4Event *)
virtual std::size_t GetMaxNTrack () const
virtual void TrajectoriesToBeMerged (G4bool)
virtual void ReportEventDeletion (const G4Event *evt)
void ResetNavigatorAtInitialization (G4bool val=true)

Static Public Member Functions

static G4WorkerSubEvtRunManagerGetWorkerRunManager ()
static G4WorkerSubEvtRunManagerKernelGetWorkerRunManagerKernel ()
Static Public Member Functions inherited from G4WorkerTaskRunManager
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
void SetupDefaultRNGEngine () override
Protected Member Functions inherited from G4WorkerTaskRunManager
void StoreRNGStatus (const G4String &filenamePrefix) override
void SetupDefaultRNGEngine () override
Protected Member Functions inherited from G4WorkerRunManager
void ConstructScoringWorlds () override
void rndmSaveThisRun () override
void rndmSaveThisEvent () override
virtual void MergePartialResults (G4bool mergeEvents=true)
Protected Member Functions inherited from G4RunManager
 G4RunManager (RMType rmType)
virtual void StackPreviousEvent (G4Event *anEvent)
virtual void CleanUpPreviousEvents ()
virtual void CleanUpUnnecessaryEvents (G4int keepNEvents)
void UpdateScoring (const G4Event *evt=nullptr)
virtual void DeleteUserInitializations ()

Additional Inherited Members

Public Types inherited from G4WorkerTaskRunManager
using G4StrVector = std::vector<G4String>
Public Types inherited from G4RunManager
enum  RMType {
  sequentialRM , masterRM , workerRM , subEventMasterRM ,
  subEventWorkerRM
}
Protected Attributes inherited from G4WorkerTaskRunManager
G4StrVector processedCommandStack
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 51 of file G4WorkerSubEvtRunManager.hh.

Constructor & Destructor Documentation

◆ G4WorkerSubEvtRunManager()

G4WorkerSubEvtRunManager::G4WorkerSubEvtRunManager ( G4int subEventType = 0)

Definition at line 74 of file G4WorkerSubEvtRunManager.cc.

Referenced by GetWorkerRunManager().

Member Function Documentation

◆ DoCleanup()

void G4WorkerSubEvtRunManager::DoCleanup ( )
overridevirtual

Reimplemented from G4WorkerTaskRunManager.

Definition at line 290 of file G4WorkerSubEvtRunManager.cc.

291{
292 // Nothing to do for a run
293
294 //CleanUpPreviousEvents();
295 //
296 //delete currentRun;
297 //currentRun = nullptr;
298}

◆ DoEventLoop()

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

Reimplemented from G4WorkerRunManager.

Definition at line 170 of file G4WorkerSubEvtRunManager.cc.

172{
173 // This method is not used in worker sub-event mode
174 G4Exception("G4WorkerSubEvtRunManager::DoEventLoop()","SubEvtXXX001",FatalException,
175 "This method is not used in the worker thread of sub-event parallel mode");
176}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

◆ DoWork()

void G4WorkerSubEvtRunManager::DoWork ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 302 of file G4WorkerSubEvtRunManager.cc.

303{
304 if(verboseLevel>1) {
305 G4cout << "G4WorkerSubEvtRunManager::DoWork() starts.........." << G4endl;
306 }
307
308 G4SubEvtRunManager* mrm = G4SubEvtRunManager::GetMasterRunManager();
309 G4bool newRun = false;
310 const G4Run* run = mrm->GetCurrentRun();
311 G4ThreadLocalStatic G4int runId = -1;
312 if ((run != nullptr) && run->GetRunID() != runId) {
313 runId = run->GetRunID();
314 newRun = true;
315 if (runId > 0) { ProcessUI(); }
316 }
317
318 G4bool reseedRequired = false;
319 if (newRun) {
321 if (cond) {
324 }
325 reseedRequired = true;
326 }
327
328 assert(workerContext != nullptr);
329 workerContext->UpdateGeometryAndPhysicsVectorFromMaster();
330
331 eventManager->UseSubEventParallelism(true);
332
333 G4bool needMoreWork = true;
334 while(needMoreWork)
335 {
336 G4bool notReady = false;
337 G4long s1, s2, s3;
338 auto subEv = mrm->GetSubEvent(fSubEventType, notReady, s1, s2, s3, reseedRequired);
339 if(subEv==nullptr && notReady)
340 {
341 // Master is not yet ready for tasking a sub-event.
342 // Wait 1 second and retry.
343 G4THREADSLEEP(1);
344 }
345 else if(subEv==nullptr)
346 {
347 // No more sub-event to process
348 // Report the results of previous sub-events if any
349 G4Event* remainingE = nullptr;
350 do
351 {
352 remainingE = eventManager->RetrieveCompletedSubEvent();
353 if(remainingE)
354 {
355 mrm->SubEventFinished(remainingE->GetSubEvent(),remainingE);
356 delete remainingE;
357 }
358 }
359 while(remainingE);
360
361 // Check if no more sub-event in event manager
362 if(eventManager->GetNumberOfRemainingSubEvents()==0)
363 { needMoreWork = false; }
364 else
365 { // Wait 1 second and revisit.
366 G4THREADSLEEP(1);
367 if(verboseLevel>1) {
368 G4cout << "G4WorkerSubEvtRunManager::DoWork() - "
369 << eventManager->GetNumberOfRemainingSubEvents()
370 << " sub-events are still incomplete in the event manager."<< G4endl;
371 }
372 }
373 }
374 else
375 {
376 // Let's work for this sub-event.
377 if(reseedRequired)
378 {
379 G4long seeds[3] = {s1, s2, s3};
380 G4Random::setTheSeeds(seeds, -1);
381 reseedRequired = false;
382 }
383
384 // create a G4Event object for this sub-event. This G4Event object will contain output
385 // to be merged into the master event.
386 auto masterEvent = subEv->GetEvent();
387 G4Event* ev = new G4Event(masterEvent->GetEventID());
388 ev->FlagAsSubEvent(masterEvent,fSubEventType,subEv);
390
391 // Create a G4TrackVector as the input
392 G4TrackVector* tv = new G4TrackVector();
393 for(auto& stackedTrack : *subEv)
394 {
395 // tracks (and trajectories) stored in G4SubEvent object belong to the master thread
396 // and thus they must not be deleted by the worker thread. They must be cloned.
397 G4Track* tr = new G4Track();
398 tr->CopyTrackInfo(*(stackedTrack.GetTrack()),false);
399 tv->push_back(tr);
400 }
401
402 // Process this sub-event
403 currentEvent = ev;
404 eventManager->ProcessOneEvent(tv,ev);
405
406 // We don't need following two lines, as they are taken care by the master
407 //////AnalyzeEvent(ev);
408 //////UpdateScoring();
409
410 // Report the results to the master if sub-event is completed
411 if(subEv->IsCompleted())
412 {
413 mrm->SubEventFinished(subEv,ev);
414 delete ev;
415 }
416
417 // Report the results of previous sub-events if any
418 G4Event* remainingE = nullptr;
419 do
420 {
421 remainingE = eventManager->RetrieveCompletedSubEvent();
422 if(remainingE)
423 {
424 mrm->SubEventFinished(remainingE->GetSubEvent(),remainingE);
425 delete remainingE;
426 }
427 }
428 while(remainingE);
429
430 if(verboseLevel>2)
431 {
432 G4cout << "G4WorkerSubEvtRunManager::DoWork() - "
433 << eventManager->GetNumberOfRemainingSubEvents()
434 << " sub-events are still incomplete in the event manager."<< G4endl;
435 }
436
437 // clean up
438 delete tv;
439 }
440 }
441
442 if(verboseLevel>1) {
443 G4cout << "G4WorkerSubEvtRunManager::DoWork() completed.........." << G4endl;
444 }
445
446}
#define G4THREADSLEEP(tick)
std::vector< G4Track * > G4TrackVector
long G4long
Definition G4Types.hh:87
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4SubEvent * GetSubEvent() const
Definition G4Event.hh:298
void FlagAsSubEvent(G4Event *me, G4int ty, const G4SubEvent *se)
Definition G4Event.hh:288
G4int numberOfEventProcessed
virtual G4bool ConfirmBeamOnCondition()
const G4Run * GetCurrentRun() const
G4EventManager * eventManager
G4Event * currentEvent
G4int GetRunID() const
Definition G4Run.hh:82
void SubEventFinished(const G4SubEvent *se, const G4Event *evt) override
static G4SubEvtRunManager * GetMasterRunManager()
const G4SubEvent * GetSubEvent(G4int ty, G4bool &notReady, G4long &s1, G4long &s2, G4long &s3, G4bool reseedRequired=true) override
void CopyTrackInfo(const G4Track &, G4bool copyTouchables=true)
Definition G4Track.cc:158
G4WorkerThread * workerContext
void ConstructScoringWorlds() override
#define G4ThreadLocalStatic
Definition tls.hh:76

◆ GenerateEvent()

G4Event * G4WorkerSubEvtRunManager::GenerateEvent ( G4int i_event)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 189 of file G4WorkerSubEvtRunManager.cc.

190{
191 // This method is not used in worker sub-event mode
192 G4Exception("G4WorkerSubEvtRunManager::GenerateEvent()","SubEvtXXX003",FatalException,
193 "This method is not used in the worker thread of sub-event parallel mode");
194 return nullptr;
195}

◆ GetSubEventType()

G4int G4WorkerSubEvtRunManager::GetSubEventType ( ) const
inlineoverridevirtual

Reimplemented from G4RunManager.

Definition at line 92 of file G4WorkerSubEvtRunManager.hh.

93 { return fSubEventType; }

◆ GetWorkerRunManager()

G4WorkerSubEvtRunManager * G4WorkerSubEvtRunManager::GetWorkerRunManager ( )
static

Definition at line 60 of file G4WorkerSubEvtRunManager.cc.

61{
63}
static G4RunManager * GetRunManager()
G4WorkerSubEvtRunManager(G4int subEventType=0)

Referenced by GetWorkerRunManagerKernel().

◆ GetWorkerRunManagerKernel()

G4WorkerSubEvtRunManagerKernel * G4WorkerSubEvtRunManager::GetWorkerRunManagerKernel ( )
static

Definition at line 67 of file G4WorkerSubEvtRunManager.cc.

68{
70}
G4WorkerTaskRunManagerKernel G4WorkerSubEvtRunManagerKernel
G4RunManagerKernel * kernel
static G4WorkerSubEvtRunManager * GetWorkerRunManager()

◆ ProcessOneEvent()

void G4WorkerSubEvtRunManager::ProcessOneEvent ( G4int i_event)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 180 of file G4WorkerSubEvtRunManager.cc.

181{
182 // This method is not used in worker sub-event mode
183 G4Exception("G4WorkerSubEvtRunManager::ProcessOneEvent()","SubEvtXXX002",FatalException,
184 "This method is not used in the worker thread of sub-event parallel mode");
185}

◆ ProcessUI()

void G4WorkerSubEvtRunManager::ProcessUI ( )
overridevirtual

Reimplemented from G4WorkerTaskRunManager.

Definition at line 262 of file G4WorkerSubEvtRunManager.cc.

263{
264 G4TaskRunManager* mrm = G4TaskRunManager::GetMasterRunManager();
265 if (mrm == nullptr) return;
266
267 //------------------------------------------------------------------------//
268 // Check UI commands not already processed
269 auto command_stack = mrm->GetCommandStack();
270 bool matching = (command_stack.size() == processedCommandStack.size());
271 if (matching) {
272 for (uintmax_t i = 0; i < command_stack.size(); ++i)
273 if (processedCommandStack.at(i) != command_stack.at(i)) {
274 matching = false;
275 break;
276 }
277 }
278
279 //------------------------------------------------------------------------//
280 // Execute UI commands stored in the master UI manager
281 if (!matching) {
282 for (const auto& itr : command_stack)
284 processedCommandStack = std::move(command_stack);
285 }
286}
std::vector< G4String > GetCommandStack()
static G4TaskRunManager * GetMasterRunManager()
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()

Referenced by DoWork().

◆ RestoreRndmEachEvent()

void G4WorkerSubEvtRunManager::RestoreRndmEachEvent ( G4bool flag)
inlineoverridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 67 of file G4WorkerSubEvtRunManager.hh.

◆ RunInitialization()

void G4WorkerSubEvtRunManager::RunInitialization ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 80 of file G4WorkerSubEvtRunManager.cc.

81{
82#ifdef G4MULTITHREADED
83 if (!visIsSetUp) {
84 G4VVisManager* pVVis = G4VVisManager::GetConcreteInstance();
85 if (pVVis != nullptr) {
86 pVVis->SetUpForAThread();
87 visIsSetUp = true;
88 }
89 }
90#endif
91 runIsSeeded = false;
92
93 if (!(kernel->RunInitialization(fakeRun))) return;
94
95 // Signal this thread can start event loop.
96 // Note this will return only when all threads reach this point
98 if (fakeRun) return;
99
100 const G4UserWorkerInitialization* uwi =
102
104
105 delete currentRun;
106
107 currentRun = nullptr;
108
110
111 // Call a user hook: this is guaranteed all threads are "synchronized"
112 if (uwi != nullptr) uwi->WorkerRunStart();
113
114 if (userRunAction != nullptr) currentRun = userRunAction->GenerateRun();
115 if (currentRun == nullptr) currentRun = new G4Run();
116
117 currentRun->SetRunID(runIDCounter);
118 G4TaskRunManager* mrm = G4TaskRunManager::GetMasterRunManager();
120 currentRun->SetNumberOfEventToBeProcessed(numberOfEventToBeProcessed);
121
122 currentRun->SetDCtable(DCtable);
123 G4SDManager* fSDM = G4SDManager::GetSDMpointerIfExist();
124 if (fSDM != nullptr) {
125 currentRun->SetHCtable(fSDM->GetHCtable());
126 }
127
128 if (G4VScoreNtupleWriter::Instance() != nullptr) {
129 auto hce = (fSDM != nullptr) ? fSDM->PrepareNewEvent() : nullptr;
131 delete hce;
132 }
133
134 std::ostringstream oss;
135 G4Random::saveFullState(oss);
137 currentRun->SetRandomNumberStatus(randomNumberStatusForThisRun);
138
139 for (G4int i_prev = 0; i_prev < n_perviousEventsToBeStored; ++i_prev)
140 previousEvents->push_back(nullptr);
141
142 if (printModulo > 0 || verboseLevel > 0) {
143 G4cout << "### Run " << currentRun->GetRunID() << " starts on worker thread "
144 << G4Threading::G4GetThreadId() << "." << G4endl;
145 }
146
147 if (userRunAction != nullptr) userRunAction->BeginOfRunAction(currentRun);
148
151 }
152
154 G4String fileN = "currentRun";
156 std::ostringstream os;
157 os << "run" << currentRun->GetRunID();
158 fileN = os.str();
159 }
160 StoreRNGStatus(fileN);
161 }
162
163 runAborted = false;
165 if(verboseLevel > 0) timer->Start();
166}
virtual void ThisWorkerReady()
static G4MTRunManager * GetMasterRunManager()
static G4ParallelWorldProcessStore * GetInstance()
G4bool isScoreNtupleWriter
virtual void CleanUpPreviousEvents()
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
std::list< G4Event * > * previousEvents
G4Timer * timer
G4int GetNumberOfEventsToBeProcessed() const
G4Run * currentRun
G4DCtable * DCtable
G4String randomNumberStatusForThisRun
static G4bool IfGeometryHasBeenDestroyed()
G4UserRunAction * userRunAction
G4bool rngStatusEventsFlag
G4int numberOfEventToBeProcessed
G4int n_perviousEventsToBeStored
G4bool storeRandomNumberStatus
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4HCtable * GetHCtable() const
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0
static G4VVisManager * GetConcreteInstance()
virtual void SetUpForAThread()
void StoreRNGStatus(const G4String &filenamePrefix) override
G4int G4GetThreadId()

Referenced by DoWork().

◆ RunTermination()

void G4WorkerSubEvtRunManager::RunTermination ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 199 of file G4WorkerSubEvtRunManager.cc.

200{
201 if (!fakeRun && (currentRun != nullptr)) {
203
204 // Call a user hook: note this is before the next barrier
205 // so threads execute this method asyncrhonouzly
206 //(TerminateRun allows for synch via G4RunAction::EndOfRun)
207 const G4UserWorkerInitialization* uwi =
209 if (uwi != nullptr) uwi->WorkerRunEnd();
210 }
211
212 if (currentRun != nullptr) {
214 }
215 // Signal this thread has finished envent-loop.
216 // Note this will return only whan all threads reach this point
218}
virtual void ThisWorkerEndEventLoop()
virtual void RunTermination()
virtual void MergePartialResults(G4bool mergeEvents=true)

◆ SetSubEventType()

void G4WorkerSubEvtRunManager::SetSubEventType ( G4int ty)
overridevirtual

Reimplemented from G4RunManager.

Definition at line 448 of file G4WorkerSubEvtRunManager.cc.

449{
451 mrm->RegisterSubEvtWorker(this,ty);
452 fSubEventType = ty;
453}

Referenced by G4WorkerSubEvtRunManager().

◆ SetupDefaultRNGEngine()

void G4WorkerSubEvtRunManager::SetupDefaultRNGEngine ( )
overrideprotectedvirtual

Reimplemented from G4WorkerRunManager.

Definition at line 241 of file G4WorkerSubEvtRunManager.cc.

242{
243 const CLHEP::HepRandomEngine* mrnge =
245 assert(mrnge); // Master has created RNG
246 const G4UserWorkerThreadInitialization* uwti =
248 uwti->SetupRNGEngine(mrnge);
249}
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const

◆ SetUserAction() [1/6]

void G4WorkerSubEvtRunManager::SetUserAction ( G4UserEventAction * userAction)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 501 of file G4WorkerSubEvtRunManager.cc.

502{
504}
virtual void SetUserAction(G4UserRunAction *userAction)

◆ SetUserAction() [2/6]

void G4WorkerSubEvtRunManager::SetUserAction ( G4UserRunAction * userAction)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 492 of file G4WorkerSubEvtRunManager.cc.

493{
494 G4Exception("G4WorkerSubEvtRunManager::SetUserAction(G4UserRunAction*)", "RunSE0221",
495 FatalException, "This method should be used only with an instance of the master thread");
496}

◆ SetUserAction() [3/6]

void G4WorkerSubEvtRunManager::SetUserAction ( G4UserStackingAction * userAction)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 514 of file G4WorkerSubEvtRunManager.cc.

515{
517}

◆ SetUserAction() [4/6]

void G4WorkerSubEvtRunManager::SetUserAction ( G4UserSteppingAction * userAction)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 526 of file G4WorkerSubEvtRunManager.cc.

527{
529}

◆ SetUserAction() [5/6]

void G4WorkerSubEvtRunManager::SetUserAction ( G4UserTrackingAction * userAction)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 520 of file G4WorkerSubEvtRunManager.cc.

521{
523}

◆ SetUserAction() [6/6]

void G4WorkerSubEvtRunManager::SetUserAction ( G4VUserPrimaryGeneratorAction * userAction)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 507 of file G4WorkerSubEvtRunManager.cc.

508{
509 G4Exception("G4WorkerSubEvtRunManager::SetUserAction(G4VUserPrimaryGeneratorAction*)", "RunSE0223",
510 FatalException, "This method should be used only with an instance of the master thread");
511}

◆ SetUserInitialization() [1/5]

void G4WorkerSubEvtRunManager::SetUserInitialization ( G4UserWorkerInitialization * userInit)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 457 of file G4WorkerSubEvtRunManager.cc.

458{
459 G4Exception("G4WorkerSubEvtRunManager::SetUserInitialization(G4UserWorkerInitialization*)", "RunSE0118",
460 FatalException, "This method should be used only with an instance of the master thread");
461}

◆ SetUserInitialization() [2/5]

void G4WorkerSubEvtRunManager::SetUserInitialization ( G4UserWorkerThreadInitialization * userInit)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 464 of file G4WorkerSubEvtRunManager.cc.

465{
466 G4Exception("G4WorkerSubEvtRunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)", "RunSE0119",
467 FatalException, "This method should be used only with an instance of the master thread");
468}

◆ SetUserInitialization() [3/5]

void G4WorkerSubEvtRunManager::SetUserInitialization ( G4VUserActionInitialization * userInit)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 471 of file G4WorkerSubEvtRunManager.cc.

472{
473 G4Exception("G4WorkerSubEvtRunManager::SetUserInitialization(G4VUserActionInitialization*)", "RunSE0120",
474 FatalException, "This method should be used only with an instance of the master thread");
475}

◆ SetUserInitialization() [4/5]

void G4WorkerSubEvtRunManager::SetUserInitialization ( G4VUserDetectorConstruction * userDC)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 478 of file G4WorkerSubEvtRunManager.cc.

479{
480 G4Exception("G4WorkerSubEvtRunManager::SetUserInitialization(G4VUserDetectorConstruction*)", "RunSE0121",
481 FatalException, "This method should be used only with an instance of the master thread");
482}

◆ SetUserInitialization() [5/5]

void G4WorkerSubEvtRunManager::SetUserInitialization ( G4VUserPhysicsList * userPL)
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 485 of file G4WorkerSubEvtRunManager.cc.

486{
487 pl->InitializeWorker();
489}
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)

◆ StoreRNGStatus()

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

Reimplemented from G4WorkerRunManager.

Definition at line 253 of file G4WorkerSubEvtRunManager.cc.

254{
255 std::ostringstream os;
256 os << randomNumberStatusDir << "G4Worker" << workerContext->GetThreadId() << "_" << fn << ".rndm";
257 G4Random::saveEngineStatus(os.str().c_str());
258}
G4String randomNumberStatusDir

Referenced by RunInitialization().

◆ TerminateEventLoop()

void G4WorkerSubEvtRunManager::TerminateEventLoop ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 222 of file G4WorkerSubEvtRunManager.cc.

223{
224 if (verboseLevel > 0 && !fakeRun) {
225 timer->Stop();
226 // prefix with thread # info due to how TBB calls this function
227 G4String prefix = "[thread " + std::to_string(workerContext->GetThreadId()) + "] ";
228 G4cout << prefix << "Thread-local run terminated." << G4endl;
229 G4cout << prefix << "Run Summary" << G4endl;
230 if (runAborted)
231 G4cout << prefix << " Run Aborted after " << numberOfEventProcessed << " sub-events processed."
232 << G4endl;
233 else
234 G4cout << prefix << " Number of sub-events processed : " << numberOfEventProcessed << G4endl;
235 G4cout << prefix << " " << *timer << G4endl;
236 }
237}
std::string to_string(G4FermiAtomicMass mass)

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