Geant4  10.02.p03
G4WorkerRunManager Class Reference

#include <G4WorkerRunManager.hh>

Inheritance diagram for G4WorkerRunManager:
Collaboration diagram for G4WorkerRunManager:

Public Member Functions

 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. More...
 
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 InitializePhysics ()
 
virtual G4bool ConfirmBeamOnCondition ()
 
virtual void InitializeEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void TerminateOneEvent ()
 
virtual void AnalyzeEvent (G4Event *anEvent)
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=0) const
 
virtual void rndmSaveThisRun ()
 
virtual void rndmSaveThisEvent ()
 
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 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
 

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

G4bool eventLoopOnGoing
 
G4bool runIsSeeded
 
G4int nevModulo
 
G4int currEvID
 
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
 
RMType runManagerType
 

Private Member Functions

void SetupDefaultRNGEngine ()
 

Private Attributes

G4WorkerThreadworkerContext
 

Additional Inherited Members

- Public Types inherited from G4RunManager
enum  RMType { sequentialRM, masterRM, workerRM }
 
- Static Protected Attributes inherited from G4RunManager
static G4bool fGeometryHasBeenDestroyed = false
 

Detailed Description

Definition at line 47 of file G4WorkerRunManager.hh.

Constructor & Destructor Documentation

◆ G4WorkerRunManager()

G4WorkerRunManager::G4WorkerRunManager ( )

Definition at line 58 of file G4WorkerRunManager.cc.

59  //This constructor should never be called in non-multithreaded mode
60 #ifndef G4MULTITHREADED
62  msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
63  msg<<" This type of RunManager can only be used in mult-threaded applications.";
64  G4Exception("G4WorkerRunManager::G4WorkerRunManager()","Run0035",FatalException,msg);
65 #endif
68  if(masterScM) G4ScoringManager::GetScoringManager(); //TLS instance for a worker
69 
70  eventLoopOnGoing = false;
71  runIsSeeded = false;
72  nevModulo = -1;
73  currEvID = -1;
74  workerContext = 0;
75  readStatusFromFile = false;
76 
78 
79 #ifdef G4MULTITHREADED
81  if(pVVis)
82  {
83  pVVis->SetUpForAThread();
84  visIsSetUp = true;
85  }
86  else
87  { visIsSetUp = false; }
88 #endif
89 }
void WorkerG4ParticleTable()
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4WorkerThread * workerContext
static G4VVisManager * GetConcreteInstance()
void SetIgnoreCmdNotFound(G4bool val)
Definition: G4UImanager.hh:269
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4ScoringManager * GetMasterScoringManager()
static G4ParticleTable * GetParticleTable()
static G4ScoringManager * GetScoringManager()
Here is the call graph for this function:

◆ ~G4WorkerRunManager()

G4WorkerRunManager::~G4WorkerRunManager ( )

Definition at line 93 of file G4WorkerRunManager.cc.

93  {
94  // Delete thread-local process manager objects
96 
97  //Put these pointers to zero: owned by master thread
98  //If not to zero, the base class destructor will attempt to
99  //delete them
100  userDetector = 0;
104  physicsList = 0;
105  if(verboseLevel>0) G4cout<<"Destroying WorkerRunManager ("<<this<<")"<<G4endl;
106 }
G4VUserPhysicsList * physicsList
G4VUserActionInitialization * userActionInitialization
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
G4GLOB_DLL std::ostream G4cout
G4UserWorkerInitialization * userWorkerInitialization
#define G4endl
Definition: G4ios.hh:61
G4VUserDetectorConstruction * userDetector
G4int verboseLevel
Here is the call graph for this function:

Member Function Documentation

◆ ConstructScoringWorlds()

void G4WorkerRunManager::ConstructScoringWorlds ( )
protectedvirtual

Reimplemented from G4RunManager.

Reimplemented in tbbWorkerRunManager.

Definition at line 441 of file G4WorkerRunManager.cc.

442 {
443  // Return if unnecessary
445  if(!ScM) return;
446  G4int nPar = ScM->GetNumberOfMesh();
447  if(nPar<1) return;
448 
449  // Update thread-local G4TransportationManager of all the world volumes
451 
453  assert( masterScM != NULL );
454 
457 
458  for(G4int iw=0;iw<nPar;iw++)
459  {
460  G4VScoringMesh* mesh = ScM->GetMesh(iw);
462  G4VPhysicalVolume* pWorld
464  ->IsWorldExisting(ScM->GetWorldName(iw));
465  if(!pWorld)
466  {
468  ed<<"Mesh name <"<<ScM->GetWorldName(iw)<<"> is not found in the master thread.";
469  G4Exception("G4WorkerRunManager::ConstructScoringWorlds()","RUN79001",
470  FatalException,ed);
471  }
472  if(!(mesh->GetMeshElementLogical()))
473  {
474  G4AutoLock l(&ConstructScoringWorldsMutex);
475  G4VScoringMesh* masterMesh = masterScM->GetMesh(iw);
476  mesh->SetMeshElementLogical(masterMesh->GetMeshElementLogical());
477  l.unlock();
478 
479  G4ParallelWorldProcess* theParallelWorldProcess = mesh->GetParallelWorldProcess();
480  if(theParallelWorldProcess)
481  { theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw)); }
482  else
483  {
484  theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
485  mesh->SetParallelWorldProcess(theParallelWorldProcess);
486  theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
487 
488  particleIterator->reset();
489  while( (*particleIterator)() ){
490  G4ParticleDefinition* particle = particleIterator->value();
491  G4ProcessManager* pmanager = particle->GetProcessManager();
492  if(pmanager)
493  {
494  pmanager->AddProcess(theParallelWorldProcess);
495  if(theParallelWorldProcess->IsAtRestRequired(particle))
496  { pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900); }
497  pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
498  pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
499  } //if(pmanager)
500  }//while
501  }
502  }
503  mesh->WorkerConstruct(pWorld);
504  }
505 }
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static G4bool fGeometryHasBeenDestroyed
void GeometryHasBeenDestroyed()
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
size_t GetNumberOfMesh() const
void SetMeshElementLogical(G4LogicalVolume *val)
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4String GetWorldName(G4int i) const
G4ProcessManager * GetProcessManager() const
void WorkerConstruct(G4VPhysicalVolume *fWorldPhys)
G4VScoringMesh * GetMesh(G4int i) const
int G4int
Definition: G4Types.hh:78
G4LogicalVolume * GetMeshElementLogical() const
void SetParallelWorld(G4String parallelWorldName)
void reset(G4bool ifSkipIon=true)
static G4ScoringManager * GetScoringManagerIfExist()
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
G4ParallelWorldProcess * GetParallelWorldProcess() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4TransportationManager * GetTransportationManager()
static G4ScoringManager * GetMasterScoringManager()
static G4ParticleTable * GetParticleTable()
std::vector< G4InuclElementaryParticle >::iterator particleIterator
Definition: G4BigBanger.cc:65
G4RunManagerKernel * kernel
G4PTblDicIterator * GetIterator() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoEventLoop()

void G4WorkerRunManager::DoEventLoop ( G4int  n_event,
const char *  macroFile = 0,
G4int  n_select = -1 
)
virtual

Reimplemented from G4RunManager.

Definition at line 204 of file G4WorkerRunManager.cc.

205 {
207  {
208  G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
209  "G4VUserPrimaryGeneratorAction is not defined!");
210  }
211 
212  //This is the same as in the sequential case, just the for-loop indexes are
213  //different
214  InitializeEventLoop(n_event,macroFile,n_select);
215 
216  // Reset random number seeds queue
217  while(seedsQueue.size()>0)
218  { seedsQueue.pop(); }
219  // for each run, worker should receive at least one set of random number seeds.
220  runIsSeeded = false;
221 
222  // Event loop
223  eventLoopOnGoing = true;
225  G4int i_event = -1;
226  nevModulo = -1;
227  currEvID = -1;
228 
229  while(eventLoopOnGoing)
230  {
231  ProcessOneEvent(i_event);
232  if(eventLoopOnGoing)
233  {
235  if(runAborted)
236  { eventLoopOnGoing = false; }
242  }
243  }
244 
246 }
virtual void TerminateEventLoop()
int G4int
Definition: G4Types.hh:78
G4bool runAborted
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
virtual void ProcessOneEvent(G4int i_event)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual void TerminateOneEvent()
Here is the call graph for this function:

◆ DoWork()

void G4WorkerRunManager::DoWork ( )
virtual

Definition at line 586 of file G4WorkerRunManager.cc.

587 {
590  while( nextAction != G4MTRunManager::ENDWORKER )
591  {
592  if( nextAction == G4MTRunManager::NEXTITERATION ) // start the next run
593  {
594  //The following code deals with changing materials between runs
595  static G4ThreadLocal G4bool skipInitialization = true;
596  if(skipInitialization)
597  {
598  // re-initialization is not necessary for the first run
599  skipInitialization = false;
600  }
601  else
602  {
603 // ReinitializeGeometry();
605  }
606 
607  // Execute UI commands stored in the masther UI manager
608  std::vector<G4String> cmds = mrm->GetCommandStack();
609  G4UImanager* uimgr = G4UImanager::GetUIpointer(); //TLS instance
610  std::vector<G4String>::const_iterator it = cmds.begin();
611  for(;it!=cmds.end();it++)
612  { uimgr->ApplyCommand(*it); }
613  //Start this run
614  G4int numevents = mrm->GetNumberOfEventsToBeProcessed();
615  G4String macroFile = mrm->GetSelectMacro();
616  G4int numSelect = mrm->GetNumberOfSelectEvents();
617  if ( macroFile == "" || macroFile == " " )
618  {
619  this->BeamOn(numevents);
620  }
621  else
622  {
623  this->BeamOn(numevents,macroFile,numSelect);
624  }
625  }
626  else
627  {
629  d<<"Cannot continue, this worker has been requested an unknwon action: "
630  <<nextAction<<" expecting: ENDWORKER(=" <<G4MTRunManager::ENDWORKER
631  <<") or NEXTITERATION(="<<G4MTRunManager::NEXTITERATION<<")";
632  G4Exception("G4WorkerRunManager::DoWork","Run0035",FatalException,d);
633  }
634 
635  //Now wait for master thread to signal new action to be performed
636  nextAction = mrm->ThisWorkerWaitForNextAction();
637  } //No more actions to perform
638 
639  return;
640 }
std::vector< G4String > GetCommandStack()
G4int GetNumberOfEventsToBeProcessed() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
Float_t d
G4WorkerThread * workerContext
static void UpdateGeometryAndPhysicsVectorFromMaster()
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
bool G4bool
Definition: G4Types.hh:79
static G4MTRunManager * GetMasterRunManager()
virtual WorkerActionRequest ThisWorkerWaitForNextAction()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4String GetSelectMacro() const
G4int GetNumberOfSelectEvents() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateEvent()

G4Event * G4WorkerRunManager::GenerateEvent ( G4int  i_event)
virtual

Reimplemented from G4RunManager.

Definition at line 260 of file G4WorkerRunManager.cc.

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

◆ GetWorkerRunManager()

G4WorkerRunManager * G4WorkerRunManager::GetWorkerRunManager ( )
static

Definition at line 52 of file G4WorkerRunManager.cc.

53 { return static_cast<G4WorkerRunManager*>(G4RunManager::GetRunManager()); }
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWorkerRunManagerKernel()

G4WorkerRunManagerKernel * G4WorkerRunManager::GetWorkerRunManagerKernel ( )
static

Definition at line 55 of file G4WorkerRunManager.cc.

56 { return static_cast<G4WorkerRunManagerKernel*>(GetWorkerRunManager()->kernel); }
static G4WorkerRunManager * GetWorkerRunManager()
G4RunManagerKernel * kernel
Here is the call graph for this function:

◆ InitializeGeometry()

void G4WorkerRunManager::InitializeGeometry ( )
virtual

Reimplemented from G4RunManager.

Definition at line 109 of file G4WorkerRunManager.cc.

109  {
110  if(!userDetector)
111  {
112  G4Exception("G4RunManager::InitializeGeometry", "Run0033",
113  FatalException, "G4VUserDetectorConstruction is not defined!");
114  return;
115  }
118 
119  //Step1: Get pointer to the physiWorld (note: needs to get the "super pointer, i.e. the one shared by all threads"
121  G4VPhysicalVolume* worldVol = masterKernel->GetCurrentWorld();
122  //Step2:, Call a new "WorkerDefineWorldVolume( pointer from 2-, false);
123  kernel->WorkerDefineWorldVolume(worldVol,false);
125  //Step3: Call user's ConstructSDandField()
128  geometryInitialized = true;
129 }
static G4bool fGeometryHasBeenDestroyed
void SetNumberOfParallelWorld(G4int i)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4bool geometryInitialized
static G4RunManagerKernel * GetMasterRunManagerKernel()
G4int GetNumberOfParallelWorld() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4TransportationManager * GetTransportationManager()
G4RunManagerKernel * kernel
G4VUserDetectorConstruction * userDetector
G4VPhysicalVolume * GetCurrentWorld() const
Here is the call graph for this function:

◆ MergePartialResults()

void G4WorkerRunManager::MergePartialResults ( )
protectedvirtual

Reimplemented in tbbWorkerRunManager.

Definition at line 380 of file G4WorkerRunManager.cc.

381 {
382  //Merge partial results into global run
385  if(ScM) mtRM->MergeScores(ScM);
386  mtRM->MergeRun(currentRun);
387 }
void MergeRun(const G4Run *localRun)
static G4ScoringManager * GetScoringManagerIfExist()
static G4MTRunManager * GetMasterRunManager()
G4Run * currentRun
void MergeScores(const G4ScoringManager *localScoringManager)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessOneEvent()

void G4WorkerRunManager::ProcessOneEvent ( G4int  i_event)
virtual

Reimplemented from G4RunManager.

Definition at line 248 of file G4WorkerRunManager.cc.

249 {
250  currentEvent = GenerateEvent(i_event);
251  if(eventLoopOnGoing)
252  {
255  UpdateScoring();
257  }
258 }
G4int n_select_msg
G4String msgText
G4Event * currentEvent
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
virtual void AnalyzeEvent(G4Event *anEvent)
virtual G4Event * GenerateEvent(G4int i_event)
G4int GetEventID() const
Definition: G4Event.hh:151
void ProcessOneEvent(G4Event *anEvent)
G4EventManager * eventManager
void UpdateScoring()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RestoreRndmEachEvent()

virtual void G4WorkerRunManager::RestoreRndmEachEvent ( G4bool  flag)
inlinevirtual

Reimplemented from G4RunManager.

Definition at line 106 of file G4WorkerRunManager.hh.

106 { readStatusFromFile = flag; }

◆ RunInitialization()

void G4WorkerRunManager::RunInitialization ( )
virtual

Reimplemented from G4RunManager.

Definition at line 133 of file G4WorkerRunManager.cc.

134 {
135 #ifdef G4MULTITHREADED
136  if(!visIsSetUp)
137  {
139  if(pVVis)
140  {
141  pVVis->SetUpForAThread();
142  visIsSetUp = true;
143  }
144  }
145 #endif
146 
147  if(!(kernel->RunInitialization(fakeRun))) return;
148 
149  //Signal this thread can start event loop.
150  //Note this will return only when all threads reach this point
152  if(fakeRun) return;
153 
154  const G4UserWorkerInitialization* uwi
157  if(currentRun) delete currentRun;
158  currentRun = 0;
159 
161  //Call a user hook: this is guaranteed all threads are "synchronized"
162  if(uwi) uwi->WorkerRunStart();
163 
165  if(!currentRun) currentRun = new G4Run();
166 
169 
172  if(fSDM)
173  { currentRun->SetHCtable(fSDM->GetHCtable()); }
174 
175  std::ostringstream oss;
176  G4Random::saveFullState(oss);
177  randomNumberStatusForThisRun = oss.str();
179 
180  for(G4int i_prev=0;i_prev<n_perviousEventsToBeStored;i_prev++)
181  { previousEvents->push_back((G4Event*)0); }
182 
183  if(printModulo>0 || verboseLevel>0)
184  {
185  G4cout << "### Run " << currentRun->GetRunID() << " starts on worker thread "
186  << G4Threading::G4GetThreadId() << "." << G4endl;
187  }
189 
191  G4String fileN = "currentRun";
192  if ( rngStatusEventsFlag ) {
193  std::ostringstream os;
194  os << "run" << currentRun->GetRunID();
195  fileN = os.str();
196  }
197  StoreRNGStatus(fileN);
198  }
199 
200  runAborted = false;
202 }
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition: G4Run.hh:97
G4int numberOfEventToBeProcessed
void SetDCtable(G4DCtable *DCtbl)
Definition: G4Run.hh:101
G4int numberOfEventProcessed
G4String randomNumberStatusForThisRun
static G4bool fGeometryHasBeenDestroyed
static G4VVisManager * GetConcreteInstance()
G4bool storeRandomNumberStatus
int G4int
Definition: G4Types.hh:78
G4bool runAborted
G4bool RunInitialization(G4bool fakeRun=false)
static G4ParallelWorldProcessStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
G4bool rngStatusEventsFlag
static G4MTRunManager * GetMasterRunManager()
Definition: G4Run.hh:46
std::list< G4Event * > * previousEvents
G4UserRunAction * userRunAction
G4int GetRunID() const
Definition: G4Run.hh:76
void SetHCtable(G4HCtable *HCtbl)
Definition: G4Run.hh:99
G4int runIDCounter
virtual void ThisWorkerReady()
void CleanUpPreviousEvents()
virtual void BeginOfRunAction(const G4Run *aRun)
G4Run * currentRun
#define G4endl
Definition: G4ios.hh:61
G4RunManagerKernel * kernel
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
G4HCtable * GetHCtable() const
Definition: G4SDManager.hh:101
void SetRunID(G4int id)
Definition: G4Run.hh:95
void SetRandomNumberStatus(G4String &st)
Definition: G4Run.hh:103
virtual G4Run * GenerateRun()
G4DCtable * DCtable
G4int n_perviousEventsToBeStored
G4int G4GetThreadId()
Definition: G4Threading.cc:134
G4int verboseLevel
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:49
virtual void StoreRNGStatus(const G4String &filenamePrefix)
Here is the call graph for this function:

◆ RunTermination()

void G4WorkerRunManager::RunTermination ( )
virtual

Reimplemented from G4RunManager.

Definition at line 389 of file G4WorkerRunManager.cc.

390 {
391  if(!fakeRun)
392  {
394 
395  //Call a user hook: note this is before the next barrier
396  //so threads execute this method asyncrhonouzly
397  //(TerminateRun allows for synch via G4RunAction::EndOfRun)
398  const G4UserWorkerInitialization* uwi
400  if(uwi) uwi->WorkerRunEnd();
401  }
402 
404  //Signal this thread has finished envent-loop.
405  //Note this will return only whan all threads reach this point
407 
408 }
virtual void RunTermination()
virtual void ThisWorkerEndEventLoop()
static G4MTRunManager * GetMasterRunManager()
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
virtual void MergePartialResults()
Here is the call graph for this function:

◆ SetupDefaultRNGEngine()

void G4WorkerRunManager::SetupDefaultRNGEngine ( )
private

Definition at line 543 of file G4WorkerRunManager.cc.

544 {
546  assert(mrnge);//Master has created RNG
549  uwti->SetupRNGEngine(mrnge);
550 }
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
static G4MTRunManager * GetMasterRunManager()
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
Here is the call graph for this function:

◆ SetUserAction() [1/6]

void G4WorkerRunManager::SetUserAction ( G4UserRunAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 537 of file G4WorkerRunManager.cc.

538 {
539  G4RunManager::SetUserAction(userAction);
540  userAction->SetMaster(false);
541 }
void SetMaster(G4bool val=true)
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetUserAction() [2/6]

void G4WorkerRunManager::SetUserAction ( G4VUserPrimaryGeneratorAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 559 of file G4WorkerRunManager.cc.

560 {
562 }
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:

◆ SetUserAction() [3/6]

void G4WorkerRunManager::SetUserAction ( G4UserEventAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 554 of file G4WorkerRunManager.cc.

555 {
557 }
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:

◆ SetUserAction() [4/6]

void G4WorkerRunManager::SetUserAction ( G4UserStackingAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 564 of file G4WorkerRunManager.cc.

565 {
567 }
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:

◆ SetUserAction() [5/6]

void G4WorkerRunManager::SetUserAction ( G4UserTrackingAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 569 of file G4WorkerRunManager.cc.

570 {
572 }
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:

◆ SetUserAction() [6/6]

void G4WorkerRunManager::SetUserAction ( G4UserSteppingAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 574 of file G4WorkerRunManager.cc.

575 {
577 }
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:

◆ SetUserInitialization() [1/5]

void G4WorkerRunManager::SetUserInitialization ( G4VUserPhysicsList userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 531 of file G4WorkerRunManager.cc.

532 {
533  pl->InitializeWorker();
535 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
pl
Definition: readPY.py:5
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetUserInitialization() [2/5]

void G4WorkerRunManager::SetUserInitialization ( G4VUserDetectorConstruction userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 525 of file G4WorkerRunManager.cc.

526 {
527  G4Exception("G4RunManager::SetUserInitialization(G4VUserDetectorConstruction*)", "Run3021",
528  FatalException, "This method should be used only with an instance of G4MTRunManager");
529 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ SetUserInitialization() [3/5]

void G4WorkerRunManager::SetUserInitialization ( G4VUserActionInitialization userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 519 of file G4WorkerRunManager.cc.

520 {
521  G4Exception("G4RunManager::SetUserInitialization(G4VUserActionInitialization*)", "Run3021",
522  FatalException, "This method should be used only with an instance of G4MTRunManager");
523 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ SetUserInitialization() [4/5]

void G4WorkerRunManager::SetUserInitialization ( G4UserWorkerInitialization userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 507 of file G4WorkerRunManager.cc.

508 {
509  G4Exception("G4RunManager::SetUserInitialization(G4UserWorkerInitialization*)", "Run3021",
510  FatalException, "This method should be used only with an instance of G4MTRunManager");
511 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ SetUserInitialization() [5/5]

void G4WorkerRunManager::SetUserInitialization ( G4UserWorkerThreadInitialization userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 513 of file G4WorkerRunManager.cc.

514 {
515  G4Exception("G4RunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)", "Run3021",
516  FatalException, "This method should be used only with an instance of G4MTRunManager");
517 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ SetWorkerThread()

void G4WorkerRunManager::SetWorkerThread ( G4WorkerThread wc)
inline

Sets the worker context.

Definition at line 79 of file G4WorkerRunManager.hh.

79 { workerContext = wc; }
G4WorkerThread * workerContext
Here is the caller graph for this function:

◆ StoreRNGStatus()

void G4WorkerRunManager::StoreRNGStatus ( const G4String filenamePrefix)
protectedvirtual

Reimplemented from G4RunManager.

Definition at line 579 of file G4WorkerRunManager.cc.

580 {
581  std::ostringstream os;
582  os << randomNumberStatusDir << "G4Worker"<<workerContext->GetThreadId()<<"_"<<fn <<".rndm";
583  G4Random::saveEngineStatus(os.str().c_str());
584 }
G4WorkerThread * workerContext
G4String randomNumberStatusDir
G4int GetThreadId() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TerminateEventLoop()

void G4WorkerRunManager::TerminateEventLoop ( )
virtual

Reimplemented from G4RunManager.

Definition at line 410 of file G4WorkerRunManager.cc.

411 {
412  if(verboseLevel>0 && !fakeRun)
413  {
414  timer->Stop();
415  G4cout << "Thread-local run terminated." << G4endl;
416  G4cout << "Run Summary" << G4endl;
417  if(runAborted)
418  { G4cout << " Run Aborted after " << numberOfEventProcessed << " events processed." << G4endl; }
419  else
420  { G4cout << " Number of events processed : " << numberOfEventProcessed << G4endl; }
421  G4cout << " " << *timer << G4endl;
422  }
423 }
G4Timer * timer
G4int numberOfEventProcessed
G4bool runAborted
G4GLOB_DLL std::ostream G4cout
void Stop()
#define G4endl
Definition: G4ios.hh:61
G4int verboseLevel
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ currEvID

G4int G4WorkerRunManager::currEvID
protected

Definition at line 101 of file G4WorkerRunManager.hh.

◆ eventLoopOnGoing

G4bool G4WorkerRunManager::eventLoopOnGoing
protected

Definition at line 98 of file G4WorkerRunManager.hh.

◆ nevModulo

G4int G4WorkerRunManager::nevModulo
protected

Definition at line 100 of file G4WorkerRunManager.hh.

◆ readStatusFromFile

G4bool G4WorkerRunManager::readStatusFromFile
protected

Definition at line 103 of file G4WorkerRunManager.hh.

◆ runIsSeeded

G4bool G4WorkerRunManager::runIsSeeded
protected

Definition at line 99 of file G4WorkerRunManager.hh.

◆ seedsQueue

G4SeedsQueue G4WorkerRunManager::seedsQueue
protected

Definition at line 102 of file G4WorkerRunManager.hh.

◆ workerContext

G4WorkerThread* G4WorkerRunManager::workerContext
private

Definition at line 81 of file G4WorkerRunManager.hh.


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