Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
G4UserWorkerThreadInitialization
GetUserWorkerThreadInitialization () const
 
const G4UserRunActionGetUserRunAction () const
 
const
G4VUserPrimaryGeneratorAction
GetUserPrimaryGeneratorAction () 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
 

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 ( )

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()","Run0103",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
static G4VVisManager * GetConcreteInstance()
void SetIgnoreCmdNotFound(G4bool val)
Definition: G4UImanager.hh:269
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
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 ( )

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

void G4WorkerRunManager::ConstructScoringWorlds ( )
protectedvirtual

Reimplemented from G4RunManager.

Definition at line 443 of file G4WorkerRunManager.cc.

444 {
445  // Return if unnecessary
447  if(!ScM) return;
448  G4int nPar = ScM->GetNumberOfMesh();
449  if(nPar<1) return;
450 
451  // Update thread-local G4TransportationManager of all the world volumes
453 
455  assert( masterScM != NULL );
456 
459 
460  for(G4int iw=0;iw<nPar;iw++)
461  {
462  G4VScoringMesh* mesh = ScM->GetMesh(iw);
464  G4VPhysicalVolume* pWorld
466  ->IsWorldExisting(ScM->GetWorldName(iw));
467  if(!pWorld)
468  {
470  ed<<"Mesh name <"<<ScM->GetWorldName(iw)<<"> is not found in the master thread.";
471  G4Exception("G4WorkerRunManager::ConstructScoringWorlds()","RUN79001",
472  FatalException,ed);
473  }
474  if(!(mesh->GetMeshElementLogical()))
475  {
476  G4AutoLock l(&ConstructScoringWorldsMutex);
477  G4VScoringMesh* masterMesh = masterScM->GetMesh(iw);
478  mesh->SetMeshElementLogical(masterMesh->GetMeshElementLogical());
479  l.unlock();
480 
481  G4ParallelWorldProcess* theParallelWorldProcess = mesh->GetParallelWorldProcess();
482  if(theParallelWorldProcess)
483  { theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw)); }
484  else
485  {
486  theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
487  mesh->SetParallelWorldProcess(theParallelWorldProcess);
488  theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
489 
490  particleIterator->reset();
491  while( (*particleIterator)() ){
492  G4ParticleDefinition* particle = particleIterator->value();
493  G4ProcessManager* pmanager = particle->GetProcessManager();
494  if(pmanager)
495  {
496  pmanager->AddProcess(theParallelWorldProcess);
497  if(theParallelWorldProcess->IsAtRestRequired(particle))
498  { pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900); }
499  pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
500  pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
501  } //if(pmanager)
502  }//while
503  }
504  }
505  mesh->WorkerConstruct(pWorld);
506  }
507 }
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
G4String GetWorldName(G4int i) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static G4bool fGeometryHasBeenDestroyed
void GeometryHasBeenDestroyed()
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void SetMeshElementLogical(G4LogicalVolume *val)
G4bool IsAtRestRequired(G4ParticleDefinition *)
void WorkerConstruct(G4VPhysicalVolume *fWorldPhys)
int G4int
Definition: G4Types.hh:78
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)
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()
G4ProcessManager * GetProcessManager() const
G4ParallelWorldProcess * GetParallelWorldProcess() const
G4LogicalVolume * GetMeshElementLogical() const
std::vector< G4InuclElementaryParticle >::iterator particleIterator
Definition: G4BigBanger.cc:65
G4RunManagerKernel * kernel
size_t GetNumberOfMesh() const
G4VScoringMesh * GetMesh(G4int i) const
G4PTblDicIterator * GetIterator() const

Here is the call graph for this function:

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:

void G4WorkerRunManager::DoWork ( )
virtual

Definition at line 588 of file G4WorkerRunManager.cc.

589 {
593  {
594  if( nextAction == G4MTRunManager::WorkerActionRequest::NEXTITERATION ) // start the next run
595  {
596  //The following code deals with changing materials between runs
597  static G4ThreadLocal G4bool skipInitialization = true;
598  if(skipInitialization)
599  {
600  // re-initialization is not necessary for the first run
601  skipInitialization = false;
602  }
603  else
604  {
605 // ReinitializeGeometry();
607  }
608 
609  // Execute UI commands stored in the master UI manager
610  std::vector<G4String> cmds = mrm->GetCommandStack();
611  G4UImanager* uimgr = G4UImanager::GetUIpointer(); //TLS instance
612  std::vector<G4String>::const_iterator it = cmds.begin();
613  for(;it!=cmds.end();it++)
614  { uimgr->ApplyCommand(*it); }
615  //Start this run
616  G4int numevents = mrm->GetNumberOfEventsToBeProcessed();
617  G4String macroFile = mrm->GetSelectMacro();
618  G4int numSelect = mrm->GetNumberOfSelectEvents();
619  if ( macroFile == "" || macroFile == " " )
620  {
621  this->BeamOn(numevents);
622  }
623  else
624  {
625  this->BeamOn(numevents,macroFile,numSelect);
626  }
627  }
628  else if (nextAction == G4MTRunManager::WorkerActionRequest::PROCESSUI ) {
629  std::vector<G4String> cmds = mrm->GetCommandStack();
630  G4UImanager* uimgr = G4UImanager::GetUIpointer(); //TLS instance
631  std::vector<G4String>::const_iterator it = cmds.begin();
632  for(;it!=cmds.end();it++)
633  { uimgr->ApplyCommand(*it); }
635  }
636  else
637  {
639  d<<"Cannot continue, this worker has been requested an unknwon action: "
640  <<static_cast<std::underlying_type<G4MTRunManager::WorkerActionRequest>::type>(nextAction);
641  G4Exception("G4WorkerRunManager::DoWork","Run0104",FatalException,d);
642  }
643 
644  //Now wait for master thread to signal new action to be performed
645  nextAction = mrm->ThisWorkerWaitForNextAction();
646  } //No more actions to perform
647 
648  return;
649 }
std::vector< G4String > GetCommandStack()
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static void UpdateGeometryAndPhysicsVectorFromMaster()
G4String GetSelectMacro() const
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:59
bool G4bool
Definition: G4Types.hh:79
static G4MTRunManager * GetMasterRunManager()
virtual WorkerActionRequest ThisWorkerWaitForNextAction()
virtual void ThisWorkerProcessCommandsStackDone()
G4int GetNumberOfEventsToBeProcessed() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int GetNumberOfSelectEvents() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function:

Here is the caller graph for this function:

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";
374  if(eventHasToBeSeeded)
375  { G4cout << " with initial seeds (" << s1 << "," << s2 << ")"; }
376  G4cout << "." << G4endl;
377  }
379  return anEvent;
380 }
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
G4int GetEventID() const
Definition: G4Event.hh:151
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 GetEventModulo() const
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:

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:

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:

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 }
G4int GetNumberOfParallelWorld() const
static G4bool fGeometryHasBeenDestroyed
void SetNumberOfParallelWorld(G4int i)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4bool geometryInitialized
static G4RunManagerKernel * GetMasterRunManagerKernel()
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:

void G4WorkerRunManager::MergePartialResults ( )
protectedvirtual

Definition at line 382 of file G4WorkerRunManager.cc.

383 {
384  //Merge partial results into global run
387  if(ScM) mtRM->MergeScores(ScM);
388  mtRM->MergeRun(currentRun);
389 }
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:

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:59
G4int GetEventID() const
Definition: G4Event.hh:151
virtual void AnalyzeEvent(G4Event *anEvent)
virtual G4Event * GenerateEvent(G4int i_event)
void ProcessOneEvent(G4Event *anEvent)
G4EventManager * eventManager
void UpdateScoring()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void G4WorkerRunManager::RestoreRndmEachEvent ( G4bool  flag)
inlinevirtual

Reimplemented from G4RunManager.

Definition at line 106 of file G4WorkerRunManager.hh.

106 { readStatusFromFile = flag; }
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
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
int G4int
Definition: G4Types.hh:78
G4bool runAborted
G4bool RunInitialization(G4bool fakeRun=false)
static G4ParallelWorldProcessStore * GetInstance()
G4HCtable * GetHCtable() const
Definition: G4SDManager.hh:101
G4GLOB_DLL std::ostream G4cout
G4bool rngStatusEventsFlag
static G4MTRunManager * GetMasterRunManager()
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
std::list< G4Event * > * previousEvents
G4UserRunAction * userRunAction
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
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:144
G4int verboseLevel
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:49
virtual void StoreRNGStatus(const G4String &filenamePrefix)

Here is the call graph for this function:

void G4WorkerRunManager::RunTermination ( )
virtual

Reimplemented from G4RunManager.

Definition at line 391 of file G4WorkerRunManager.cc.

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

Here is the call graph for this function:

void G4WorkerRunManager::SetUserAction ( G4UserRunAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 539 of file G4WorkerRunManager.cc.

540 {
541  G4RunManager::SetUserAction(userAction);
542  userAction->SetMaster(false);
543 }
virtual 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:

void G4WorkerRunManager::SetUserAction ( G4VUserPrimaryGeneratorAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 561 of file G4WorkerRunManager.cc.

562 {
564 }
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

void G4WorkerRunManager::SetUserAction ( G4UserEventAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 556 of file G4WorkerRunManager.cc.

557 {
559 }
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

void G4WorkerRunManager::SetUserAction ( G4UserStackingAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 566 of file G4WorkerRunManager.cc.

567 {
569 }
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

void G4WorkerRunManager::SetUserAction ( G4UserTrackingAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 571 of file G4WorkerRunManager.cc.

572 {
574 }
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

void G4WorkerRunManager::SetUserAction ( G4UserSteppingAction userAction)
virtual

Reimplemented from G4RunManager.

Definition at line 576 of file G4WorkerRunManager.cc.

577 {
579 }
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

void G4WorkerRunManager::SetUserInitialization ( G4VUserPhysicsList userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 533 of file G4WorkerRunManager.cc.

534 {
535  pl->InitializeWorker();
537 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4WorkerRunManager::SetUserInitialization ( G4VUserDetectorConstruction userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 527 of file G4WorkerRunManager.cc.

528 {
529  G4Exception("G4RunManager::SetUserInitialization(G4VUserDetectorConstruction*)", "Run0121",
530  FatalException, "This method should be used only with an instance of G4MTRunManager");
531 }
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:

void G4WorkerRunManager::SetUserInitialization ( G4VUserActionInitialization userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 521 of file G4WorkerRunManager.cc.

522 {
523  G4Exception("G4RunManager::SetUserInitialization(G4VUserActionInitialization*)", "Run0120",
524  FatalException, "This method should be used only with an instance of G4MTRunManager");
525 }
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:

void G4WorkerRunManager::SetUserInitialization ( G4UserWorkerInitialization userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 509 of file G4WorkerRunManager.cc.

510 {
511  G4Exception("G4RunManager::SetUserInitialization(G4UserWorkerInitialization*)", "Run0118",
512  FatalException, "This method should be used only with an instance of G4MTRunManager");
513 }
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:

void G4WorkerRunManager::SetUserInitialization ( G4UserWorkerThreadInitialization userInit)
virtual

Reimplemented from G4RunManager.

Definition at line 515 of file G4WorkerRunManager.cc.

516 {
517  G4Exception("G4RunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)", "Run0119",
518  FatalException, "This method should be used only with an instance of G4MTRunManager");
519 }
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:

void G4WorkerRunManager::SetWorkerThread ( G4WorkerThread wc)
inline

Sets the worker context.

Definition at line 79 of file G4WorkerRunManager.hh.

79 { workerContext = wc; }

Here is the caller graph for this function:

void G4WorkerRunManager::StoreRNGStatus ( const G4String filenamePrefix)
protectedvirtual

Reimplemented from G4RunManager.

Definition at line 581 of file G4WorkerRunManager.cc.

582 {
583  std::ostringstream os;
584  os << randomNumberStatusDir << "G4Worker"<<workerContext->GetThreadId()<<"_"<<fn <<".rndm";
585  G4Random::saveEngineStatus(os.str().c_str());
586 }
G4String randomNumberStatusDir
G4int GetThreadId() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4WorkerRunManager::TerminateEventLoop ( )
virtual

Reimplemented from G4RunManager.

Definition at line 412 of file G4WorkerRunManager.cc.

413 {
414  if(verboseLevel>0 && !fakeRun)
415  {
416  timer->Stop();
417  G4cout << "Thread-local run terminated." << G4endl;
418  G4cout << "Run Summary" << G4endl;
419  if(runAborted)
420  { G4cout << " Run Aborted after " << numberOfEventProcessed << " events processed." << G4endl; }
421  else
422  { G4cout << " Number of events processed : " << numberOfEventProcessed << G4endl; }
423  G4cout << " " << *timer << G4endl;
424  }
425 }
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

G4int G4WorkerRunManager::currEvID
protected

Definition at line 101 of file G4WorkerRunManager.hh.

G4bool G4WorkerRunManager::eventLoopOnGoing
protected

Definition at line 98 of file G4WorkerRunManager.hh.

G4int G4WorkerRunManager::nevModulo
protected

Definition at line 100 of file G4WorkerRunManager.hh.

G4bool G4WorkerRunManager::readStatusFromFile
protected

Definition at line 103 of file G4WorkerRunManager.hh.

G4bool G4WorkerRunManager::runIsSeeded
protected

Definition at line 99 of file G4WorkerRunManager.hh.

G4SeedsQueue G4WorkerRunManager::seedsQueue
protected

Definition at line 102 of file G4WorkerRunManager.hh.


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