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.";
79 #ifdef G4MULTITHREADED
83 pVVis->SetUpForAThread();
87 { visIsSetUp =
false; }
112 G4Exception(
"G4RunManager::InitializeGeometry",
"Run0033",
135 #ifdef G4MULTITHREADED
141 pVVis->SetUpForAThread();
175 std::ostringstream oss;
176 G4Random::saveFullState(oss);
193 std::ostringstream os;
209 "G4VUserPrimaryGeneratorAction is not defined!");
266 G4bool eventHasToBeSeeded =
true;
268 { eventHasToBeSeeded =
false; }
312 else if(eventHasToBeSeeded)
316 s1 = helper->
GetSeed(i_event*2);
317 s2 = helper->
GetSeed(i_event*2+1);
320 if(eventHasToBeSeeded)
322 long seeds[3] = { s1, s2, 0 };
323 G4Random::setTheSeeds(seeds,-1);
335 const auto filename = [&] {
336 std::ostringstream os;
341 G4bool RNGstatusReadFromFile =
false;
344 std::ostringstream os;
345 os << filename() <<
".rndm";
346 const G4String& randomStatusFile = os.str();
347 std::ifstream ifile(randomStatusFile.c_str());
349 RNGstatusReadFromFile =
true;
350 G4Random::restoreEngineStatus(randomStatusFile.c_str());
357 std::ostringstream oss;
358 G4Random::saveFullState(oss);
373 G4cout <<
"--> Event " << anEvent->
GetEventID() <<
" starts with initial seeds ("
374 << s1 <<
"," << s2 <<
")." <<
G4endl;
453 assert( masterScM != NULL );
458 for(
G4int iw=0;iw<nPar;iw++)
468 ed<<
"Mesh name <"<<ScM->
GetWorldName(iw)<<
"> is not found in the masther thread.";
469 G4Exception(
"G4WorkerRunManager::ConstructScoringWorlds()",
"RUN79001",
480 if(theParallelWorldProcess)
488 particleIterator->
reset();
489 while( (*particleIterator)() ){
494 pmanager->
AddProcess(theParallelWorldProcess);
509 G4Exception(
"G4RunManager::SetUserInitialization(G4UserWorkerInitialization*)",
"Run3021",
510 FatalException,
"This method should be used only with an instance of G4MTRunManager");
515 G4Exception(
"G4RunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)",
"Run3021",
516 FatalException,
"This method should be used only with an instance of G4MTRunManager");
521 G4Exception(
"G4RunManager::SetUserInitialization(G4VUserActionInitialization*)",
"Run3021",
522 FatalException,
"This method should be used only with an instance of G4MTRunManager");
527 G4Exception(
"G4RunManager::SetUserInitialization(G4VUserDetectorConstruction*)",
"Run3021",
528 FatalException,
"This method should be used only with an instance of G4MTRunManager");
581 std::ostringstream os;
583 G4Random::saveEngineStatus(os.str().c_str());
596 if(skipInitialization)
599 skipInitialization =
false;
610 std::vector<G4String>::const_iterator it = cmds.begin();
611 for(;it!=cmds.end();it++)
617 if ( macroFile ==
"" || macroFile ==
" " )
623 this->
BeamOn(numevents,macroFile,numSelect);
629 d<<
"Cannot continue, this worker has been requested an unknwon action: "
void SetNumberOfEventToBeProcessed(G4int n_ev)
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetMaster(G4bool val=true)
void WorkerG4ParticleTable()
G4int numberOfEventToBeProcessed
static G4TemplateRNGHelper * GetInstance()
void SetDCtable(G4DCtable *DCtbl)
virtual G4int SetUpNEvents(G4Event *, G4SeedsQueue *seedsQueue, G4bool reseedRequired=true)
std::vector< G4String > GetCommandStack()
G4int GetNumberOfParallelWorld() const
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void RemoveProcessManager()
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
G4int numberOfEventProcessed
G4String GetWorldName(G4int i) const
G4String randomNumberStatusForThisRun
virtual void RunTermination()
std::ostringstream G4ExceptionDescription
virtual void ThisWorkerEndEventLoop()
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const
G4VUserPhysicsList * physicsList
virtual void InitializeGeometry()
G4String randomNumberStatusForThisEvent
static G4bool fGeometryHasBeenDestroyed
G4WorkerThread * workerContext
void GeometryHasBeenDestroyed()
static void UpdateGeometryAndPhysicsVectorFromMaster()
static G4VVisManager * GetConcreteInstance()
void SetIgnoreCmdNotFound(G4bool val)
void SetNumberOfParallelWorld(G4int i)
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4VUserActionInitialization * userActionInitialization
void SetMeshElementLogical(G4LogicalVolume *val)
virtual void ConstructScoringWorlds()
static G4WorkerRunManager * GetWorkerRunManager()
virtual void WorkerRunEnd() const
G4bool storeRandomNumberStatus
G4String GetSelectMacro() const
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
virtual void TerminateEventLoop()
void ConstructParallelSD()
virtual void DoEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual void RunInitialization()
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual const T GetSeed(const G4int &sdId)
virtual void WorkerRunStart() const
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
void WorkerConstruct(G4VPhysicalVolume *fWorldPhys)
virtual void SetUserInitialization(G4VUserPhysicsList *userInit)
G4ProcessManager * GetProcessManager() const
#define G4MUTEX_INITIALIZER
G4bool RunInitialization(G4bool fakeRun=false)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
static G4UImanager * GetUIpointer()
static G4ParallelWorldProcessStore * GetInstance()
G4bool geometryInitialized
G4HCtable * GetHCtable() const
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
void SetParallelWorld(G4String parallelWorldName)
static G4RunManagerKernel * GetMasterRunManagerKernel()
G4GLOB_DLL std::ostream G4cout
void MergeRun(const G4Run *localRun)
void reset(G4bool ifSkipIon=true)
static G4ScoringManager * GetScoringManagerIfExist()
G4UserWorkerInitialization * userWorkerInitialization
G4String randomNumberStatusDir
G4bool rngStatusEventsFlag
virtual void AnalyzeEvent(G4Event *anEvent)
static G4MTRunManager * GetMasterRunManager()
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4int storeRandomNumberStatusToG4Event
virtual WorkerActionRequest ThisWorkerWaitForNextAction()
G4int GetThreadId() const
G4int GetNumberOfEventsToBeProcessed() const
G4bool readStatusFromFile
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
std::list< G4Event * > * previousEvents
G4UserRunAction * userRunAction
virtual void RunTermination()
virtual void ProcessOneEvent(G4int i_event)
void SetHCtable(G4HCtable *HCtbl)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetRandomNumberStatus(G4String &st)
static G4TransportationManager * GetTransportationManager()
G4int GetNumberOfSelectEvents() const
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
static G4RunManager * GetRunManager()
void ClearParallelWorlds()
static G4ScoringManager * GetMasterScoringManager()
virtual void ConstructSDandField()
virtual void GeneratePrimaries(G4Event *anEvent)=0
virtual void ThisWorkerReady()
static G4ParticleTable * GetParticleTable()
void CleanUpPreviousEvents()
virtual G4Event * GenerateEvent(G4int i_event)
virtual G4bool SetUpAnEvent(G4Event *, long &s1, long &s2, long &s3, G4bool reseedRequired=true)
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
G4int GetEventModulo() const
G4ParallelWorldProcess * GetParallelWorldProcess() const
virtual void BeginOfRunAction(const G4Run *aRun)
static G4int SeedOncePerCommunication()
G4LogicalVolume * GetMeshElementLogical() const
std::vector< G4InuclElementaryParticle >::iterator particleIterator
void ProcessOneEvent(G4Event *anEvent)
G4RunManagerKernel * kernel
static G4ScoringManager * GetScoringManager()
void SetupDefaultRNGEngine()
size_t GetNumberOfMesh() const
G4EventManager * eventManager
virtual void TerminateOneEvent()
G4VUserDetectorConstruction * userDetector
G4VScoringMesh * GetMesh(G4int i) const
virtual void SetUserAction(G4UserRunAction *userAction)
void SetRandomNumberStatus(G4String &st)
void WorkerUpdateWorldVolume()
virtual G4Run * GenerateRun()
void MergeScores(const G4ScoringManager *localScoringManager)
G4PTblDicIterator * GetIterator() const
G4int n_perviousEventsToBeStored
G4VPhysicalVolume * GetCurrentWorld() const
G4int ApplyCommand(const char *aCommand)
virtual void SetUserAction(G4UserRunAction *userAction)
static G4SDManager * GetSDMpointerIfExist()
static G4WorkerRunManagerKernel * GetWorkerRunManagerKernel()
virtual void MergePartialResults()
virtual void StoreRNGStatus(const G4String &filenamePrefix)