Geant4-11
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
G4WorkerTaskRunManager Class Reference

#include <G4WorkerTaskRunManager.hh>

Inheritance diagram for G4WorkerTaskRunManager:
G4WorkerRunManager G4RunManager

Public Types

typedef std::vector< G4StringG4StrVector
 
using ProfilerConfig = G4ProfilerConfig< G4ProfileType::Run >
 
enum  RMType { sequentialRM , masterRM , workerRM }
 

Public Member Functions

virtual void AbortEvent ()
 
virtual void AbortRun (G4bool softAbort=false)
 
virtual void AnalyzeEvent (G4Event *anEvent)
 
virtual void BeamOn (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
 
virtual void ConfigureProfilers (const std::vector< std::string > &args={})
 
void ConfigureProfilers (G4int argc, char **argv)
 
virtual G4bool ConfirmBeamOnCondition ()
 
void CutOffHasBeenModified ()
 
virtual void DefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
virtual void DoCleanup ()
 
virtual void DoEventLoop (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1) override
 
virtual void DoWork () override
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=nullptr) const
 
 G4WorkerTaskRunManager ()
 
virtual G4EventGenerateEvent (G4int i_event) override
 
void GeometryDirectlyUpdated (G4bool val=true)
 
void GeometryHasBeenModified (G4bool prop=true)
 
G4StrVector GetCommandStack () const
 
const G4EventGetCurrentEvent () const
 
const G4RunGetCurrentRun () const
 
G4int GetFlagRandomNumberStatusToG4Event () const
 
G4bool GetGeometryToBeOptimized ()
 
G4RunGetNonConstCurrentRun () const
 
G4VUserActionInitializationGetNonConstUserActionInitialization () const
 
G4int GetNumberOfEventsToBeProcessed () const
 
G4int GetNumberOfParallelWorld () const
 
G4int GetNumberOfSelectEvents () const
 
virtual G4int GetNumberOfThreads () const
 
const G4EventGetPreviousEvent (G4int i) const
 
G4int GetPrintProgress ()
 
const G4StringGetRandomNumberStatusForThisEvent () const
 
const G4StringGetRandomNumberStatusForThisRun () const
 
G4bool GetRandomNumberStore () const
 
const G4StringGetRandomNumberStoreDir () const
 
G4bool GetRandomNumberStorePerEvent () const
 
RMType GetRunManagerType () const
 
const G4StringGetSelectMacro () const
 
const G4VUserActionInitializationGetUserActionInitialization () const
 
const G4VUserDetectorConstructionGetUserDetectorConstruction () const
 
const G4UserEventActionGetUserEventAction () const
 
const G4VUserPhysicsListGetUserPhysicsList () const
 
const G4VUserPrimaryGeneratorActionGetUserPrimaryGeneratorAction () const
 
const G4UserRunActionGetUserRunAction () const
 
const G4UserStackingActionGetUserStackingAction () const
 
const G4UserSteppingActionGetUserSteppingAction () const
 
const G4UserTrackingActionGetUserTrackingAction () const
 
const G4UserWorkerInitializationGetUserWorkerInitialization () const
 
const G4UserWorkerThreadInitializationGetUserWorkerThreadInitialization () const
 
G4int GetVerboseLevel () const
 
const G4StringGetVersionString () const
 
G4WorkerThreadGetWorkerThread () const
 
virtual void Initialize ()
 
virtual void InitializeEventLoop (G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
 
virtual void InitializeGeometry ()
 
virtual void InitializePhysics ()
 
void PhysicsHasBeenModified ()
 
virtual void ProcessOneEvent (G4int i_event) override
 
virtual void ProcessUI ()
 
void ReinitializeGeometry (G4bool destroyFirst=false, G4bool prop=true)
 
void ReOptimize (G4LogicalVolume *)
 
void ReOptimizeMotherOf (G4VPhysicalVolume *)
 
virtual void RestoreRandomNumberStatus (const G4String &fileN)
 
virtual void RestoreRndmEachEvent (G4bool flag) override
 
virtual void RunInitialization () override
 
virtual void RunTermination () override
 
void SetDCtable (G4DCtable *DCtbl)
 
void SetGeometryToBeOptimized (G4bool vl)
 
void SetNumberOfAdditionalWaitingStacks (G4int iAdd)
 
void SetNumberOfEventsToBeProcessed (G4int val)
 
void SetNumberOfEventsToBeStored (G4int val)
 
virtual void SetNumberOfThreads (G4int)
 
void SetPrimaryTransformer (G4PrimaryTransformer *pt)
 
void SetPrintProgress (G4int i)
 
void SetRandomNumberStore (G4bool flag)
 
void SetRandomNumberStoreDir (const G4String &dir)
 
void SetRandomNumberStorePerEvent (G4bool flag)
 
void SetRunIDCounter (G4int i)
 
virtual void SetUserAction (G4UserEventAction *userAction)
 
virtual void SetUserAction (G4UserRunAction *userAction)
 
virtual void SetUserAction (G4UserStackingAction *userAction)
 
virtual void SetUserAction (G4UserSteppingAction *userAction)
 
virtual void SetUserAction (G4UserTrackingAction *userAction)
 
virtual void SetUserAction (G4VUserPrimaryGeneratorAction *userAction)
 
virtual void SetUserInitialization (G4UserWorkerInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerThreadInitialization *userInit)
 
virtual void SetUserInitialization (G4VUserActionInitialization *userInit)
 
virtual void SetUserInitialization (G4VUserDetectorConstruction *userInit)
 
virtual void SetUserInitialization (G4VUserPhysicsList *userInit)
 
void SetVerboseLevel (G4int vl)
 
void SetWorkerThread (G4WorkerThread *wc)
 
void StoreRandomNumberStatusToG4Event (G4int vl)
 
virtual void TerminateEventLoop () override
 
virtual void TerminateOneEvent ()
 

Static Public Member Functions

static G4RunManagerGetRunManager ()
 
static G4WorkerTaskRunManagerGetWorkerRunManager ()
 
static G4WorkerTaskRunManagerKernelGetWorkerRunManagerKernel ()
 
static G4bool IfGeometryHasBeenDestroyed ()
 

Protected Member Functions

void CleanUpPreviousEvents ()
 
void CleanUpUnnecessaryEvents (G4int keepNEvents)
 
virtual void ConstructScoringWorlds ()
 
virtual void DeleteUserInitializations ()
 
virtual void MergePartialResults ()
 
virtual void rndmSaveThisEvent ()
 
virtual void rndmSaveThisRun ()
 
void StackPreviousEvent (G4Event *anEvent)
 
virtual void StoreRNGStatus (const G4String &filenamePrefix) override
 
void UpdateScoring ()
 

Protected Attributes

G4EventcurrentEvent = nullptr
 
G4RuncurrentRun = nullptr
 
G4VPhysicalVolumecurrentWorld = nullptr
 
G4int currEvID = -1
 
G4DCtableDCtable = nullptr
 
G4bool eventLoopOnGoing = false
 
G4EventManagereventManager = nullptr
 
G4bool fakeRun = false
 
G4bool geometryDirectlyUpdated = false
 
G4bool geometryInitialized = false
 
G4bool geometryToBeOptimized = true
 
G4bool initializedAtLeastOnce = false
 
G4bool isScoreNtupleWriter = false
 
G4RunManagerKernelkernel = nullptr
 
G4int luxury = -1
 
G4String msgText = " "
 
G4int n_perviousEventsToBeStored = 0
 
G4int n_select_msg = -1
 
G4int nevModulo = -1
 
G4int nParallelWorlds = 0
 
G4int numberOfEventProcessed = 0
 
G4int numberOfEventToBeProcessed = 0
 
G4bool physicsInitialized = false
 
G4VUserPhysicsListphysicsList = nullptr
 
std::list< G4Event * > * previousEvents = nullptr
 
G4int printModulo = -1
 
G4String randomNumberStatusDir = "./"
 
G4String randomNumberStatusForThisEvent = ""
 
G4String randomNumberStatusForThisRun = ""
 
G4bool readStatusFromFile = false
 
G4bool rngStatusEventsFlag = false
 
G4bool runAborted = false
 
G4int runIDCounter = 0
 
G4bool runIsSeeded = false
 
RMType runManagerType
 
G4SeedsQueue seedsQueue
 
G4String selectMacro = ""
 
G4bool storeRandomNumberStatus = false
 
G4int storeRandomNumberStatusToG4Event = 0
 
G4Timertimer = nullptr
 
G4VUserActionInitializationuserActionInitialization = nullptr
 
G4VUserDetectorConstructionuserDetector = nullptr
 
G4UserEventActionuserEventAction = nullptr
 
G4VUserPrimaryGeneratorActionuserPrimaryGeneratorAction = nullptr
 
G4UserRunActionuserRunAction = nullptr
 
G4UserStackingActionuserStackingAction = nullptr
 
G4UserSteppingActionuserSteppingAction = nullptr
 
G4UserTrackingActionuserTrackingAction = nullptr
 
G4UserWorkerInitializationuserWorkerInitialization = nullptr
 
G4UserWorkerThreadInitializationuserWorkerThreadInitialization = nullptr
 
G4int verboseLevel = 0
 
G4WorkerThreadworkerContext = nullptr
 

Static Protected Attributes

static G4RUN_DLL G4bool fGeometryHasBeenDestroyed = false
 

Private Member Functions

void SetupDefaultRNGEngine ()
 

Private Attributes

std::unique_ptr< ProfilerConfigmasterRunProfiler
 
G4StrVector processedCommandStack
 
G4RunMessengerrunMessenger = nullptr
 
std::unique_ptr< ProfilerConfigworkerRunProfiler
 

Static Private Attributes

static G4ThreadLocal G4RunManagerfRunManager = nullptr
 

Detailed Description

Definition at line 48 of file G4WorkerTaskRunManager.hh.

Member Typedef Documentation

◆ G4StrVector

Definition at line 54 of file G4WorkerTaskRunManager.hh.

◆ ProfilerConfig

Definition at line 51 of file G4WorkerTaskRunManager.hh.

Member Enumeration Documentation

◆ RMType

enum G4RunManager::RMType
inherited
Enumerator
sequentialRM 
masterRM 
workerRM 

Definition at line 575 of file G4RunManager.hh.

576 {
578 masterRM,
580 };

Constructor & Destructor Documentation

◆ G4WorkerTaskRunManager()

G4WorkerTaskRunManager::G4WorkerTaskRunManager ( )

Definition at line 81 of file G4WorkerTaskRunManager.cc.

Member Function Documentation

◆ AbortEvent()

void G4RunManager::AbortEvent ( )
virtualinherited

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 774 of file G4RunManager.cc.

775{
776 // This method is valid only for EventProc state
777 G4ApplicationState currentState =
779 if(currentState == G4State_EventProc)
780 {
783 }
784 else
785 {
786 G4cerr << "Event is not in progress. AbortEevnt() ignored." << G4endl;
787 }
788}
G4ApplicationState
@ G4State_EventProc
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
void AbortCurrentEvent()
void SetEventAborted()
Definition: G4Event.hh:88
G4EventManager * eventManager
G4Event * currentEvent
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()

References G4EventManager::AbortCurrentEvent(), G4RunManager::currentEvent, G4RunManager::eventManager, G4cerr, G4endl, G4State_EventProc, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), and G4Event::SetEventAborted().

Referenced by export_G4RunManager(), G4ExceptionHandler::Notify(), and G4RunMessenger::SetNewValue().

◆ AbortRun()

void G4RunManager::AbortRun ( G4bool  softAbort = false)
virtualinherited

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 753 of file G4RunManager.cc.

754{
755 // This method is valid only for GeomClosed or EventProc state
756 G4ApplicationState currentState =
758 if(currentState == G4State_GeomClosed || currentState == G4State_EventProc)
759 {
760 runAborted = true;
761 if(currentState == G4State_EventProc && !softAbort)
762 {
765 }
766 }
767 else
768 {
769 G4cerr << "Run is not in progress. AbortRun() ignored." << G4endl;
770 }
771}
@ G4State_GeomClosed
G4bool runAborted

References G4EventManager::AbortCurrentEvent(), G4RunManager::currentEvent, G4RunManager::eventManager, G4cerr, G4endl, G4State_EventProc, G4State_GeomClosed, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4RunManager::runAborted, and G4Event::SetEventAborted().

Referenced by export_G4RunManager(), G4ExceptionHandler::Notify(), and G4RunMessenger::SetNewValue().

◆ AnalyzeEvent()

void G4RunManager::AnalyzeEvent ( G4Event anEvent)
virtualinherited

Definition at line 548 of file G4RunManager.cc.

549{
550 G4VPersistencyManager* fPersM =
552 if(fPersM != nullptr)
553 fPersM->Store(anEvent);
554 currentRun->RecordEvent(anEvent);
555}
G4Run * currentRun
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:61
static G4VPersistencyManager * GetPersistencyManager()
virtual G4bool Store(const G4Event *anEvent)=0

References G4RunManager::currentRun, G4VPersistencyManager::GetPersistencyManager(), G4Run::RecordEvent(), and G4VPersistencyManager::Store().

Referenced by G4RunManager::ProcessOneEvent(), G4WorkerRunManager::ProcessOneEvent(), and ProcessOneEvent().

◆ BeamOn()

void G4RunManager::BeamOn ( G4int  n_event,
const char *  macroFile = nullptr,
G4int  n_select = -1 
)
virtualinherited

Definition at line 273 of file G4RunManager.cc.

274{
275 if(n_event <= 0)
276 {
277 fakeRun = true;
278 }
279 else
280 {
281 fakeRun = false;
282 }
284 if(cond)
285 {
290 DoEventLoop(n_event, macroFile, n_select);
292 }
293 fakeRun = false;
294}
bool G4bool
Definition: G4Types.hh:86
G4int numberOfEventProcessed
virtual G4bool ConfirmBeamOnCondition()
virtual void RunTermination()
G4int numberOfEventToBeProcessed
virtual void DoEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
virtual void RunInitialization()
virtual void ConstructScoringWorlds()

References G4RunManager::ConfirmBeamOnCondition(), G4RunManager::ConstructScoringWorlds(), G4RunManager::DoEventLoop(), G4RunManager::fakeRun, G4RunManager::numberOfEventProcessed, G4RunManager::numberOfEventToBeProcessed, G4RunManager::RunInitialization(), and G4RunManager::RunTermination().

Referenced by G4WorkerRunManager::DoWork(), export_G4RunManager(), G4MTRunManager::Initialize(), G4TaskRunManager::Initialize(), G4AdjointSimManager::RunAdjointSimulation(), and G4RunMessenger::SetNewValue().

◆ CleanUpPreviousEvents()

void G4RunManager::CleanUpPreviousEvents ( )
protectedinherited

Definition at line 589 of file G4RunManager.cc.

590{
591 // Delete all events carried over from previous run.
592 // This method is invoked at the beginning of the next run
593 // or from the destructor of G4RunManager at the very end of
594 // the program.
595 // N.B. If ToBeKept() is true, the pointer of this event is
596 // kept in G4Run of the previous run, and deleted along with
597 // the deletion of G4Run.
598
599 auto evItr = previousEvents->cbegin();
600 while(evItr != previousEvents->cend())
601 {
602 G4Event* evt = *evItr;
603 if(evt != nullptr && !(evt->ToBeKept()))
604 delete evt;
605 evItr = previousEvents->erase(evItr);
606 }
607}
G4bool ToBeKept() const
Definition: G4Event.hh:102
std::list< G4Event * > * previousEvents

References G4RunManager::previousEvents, and G4Event::ToBeKept().

Referenced by DoCleanup(), G4RunManager::RunInitialization(), G4WorkerRunManager::RunInitialization(), RunInitialization(), and G4RunManager::~G4RunManager().

◆ CleanUpUnnecessaryEvents()

void G4RunManager::CleanUpUnnecessaryEvents ( G4int  keepNEvents)
protectedinherited

Definition at line 610 of file G4RunManager.cc.

611{
612 // Delete events that are no longer necessary for post
613 // processing such as visualization.
614 // N.B. If ToBeKept() is true, the pointer of this event is
615 // kept in G4Run of the previous run, and deleted along with
616 // the deletion of G4Run.
617
618 auto evItr = previousEvents->cbegin();
619 while(evItr != previousEvents->cend())
620 {
621 if(G4int(previousEvents->size()) <= keepNEvents)
622 return;
623
624 G4Event* evt = *evItr;
625 if(evt != nullptr)
626 {
627 if(evt->GetNumberOfGrips() == 0)
628 {
629 if(!(evt->ToBeKept()))
630 delete evt;
631 evItr = previousEvents->erase(evItr);
632 }
633 else
634 {
635 ++evItr;
636 }
637 }
638 else
639 {
640 evItr = previousEvents->erase(evItr);
641 }
642 }
643}
int G4int
Definition: G4Types.hh:85
G4int GetNumberOfGrips() const
Definition: G4Event.hh:115

References G4Event::GetNumberOfGrips(), G4RunManager::previousEvents, and G4Event::ToBeKept().

Referenced by G4RunManager::RunTermination(), and G4RunManager::StackPreviousEvent().

◆ ConfigureProfilers() [1/2]

void G4RunManager::ConfigureProfilers ( const std::vector< std::string > &  args = {})
virtualinherited

Definition at line 1198 of file G4RunManager.cc.

1199{
1200#ifdef GEANT4_USE_TIMEMORY
1201 // parse command line if arguments were passed
1203#else
1205#endif
1206}
static char ** args
Definition: G4Xt.cc:51
static void Configure(const std::vector< std::string > &args)
Definition: G4Profiler.cc:91
void G4ConsumeParameters(_Args &&...)
Definition: templates.hh:187

References args, G4Profiler::Configure(), and G4ConsumeParameters().

Referenced by G4RunManager::ConfigureProfilers(), and G4RunManager::G4RunManager().

◆ ConfigureProfilers() [2/2]

void G4RunManager::ConfigureProfilers ( G4int  argc,
char **  argv 
)
inherited

Definition at line 1189 of file G4RunManager.cc.

1190{
1191 std::vector<std::string> _args;
1192 for(G4int i = 0; i < argc; ++i)
1193 _args.push_back(argv[i]);
1194 ConfigureProfilers(_args);
1195}
virtual void ConfigureProfilers(const std::vector< std::string > &args={})

References G4RunManager::ConfigureProfilers().

◆ ConfirmBeamOnCondition()

G4bool G4RunManager::ConfirmBeamOnCondition ( )
virtualinherited

Definition at line 297 of file G4RunManager.cc.

298{
300
301 G4ApplicationState currentState = stateManager->GetCurrentState();
302 if(currentState != G4State_PreInit && currentState != G4State_Idle)
303 {
304 G4cerr << "Illegal application state - BeamOn() ignored." << G4endl;
305 return false;
306 }
307
309 {
310 G4cerr << " Geant4 kernel should be initialized" << G4endl;
311 G4cerr << "before the first BeamOn(). - BeamOn ignored." << G4endl;
312 return false;
313 }
314
316 {
317 if(verboseLevel > 0)
318 {
319 G4cout << "Start re-initialization because " << G4endl;
321 G4cout << " Geometry" << G4endl;
323 G4cout << " Physics processes" << G4endl;
324 G4cout << "has been modified since last Run." << G4endl;
325 }
326 Initialize();
327 }
328 return true;
329}
@ G4State_Idle
@ G4State_PreInit
G4GLOB_DLL std::ostream G4cout
G4bool geometryInitialized
virtual void Initialize()
G4int verboseLevel
G4bool physicsInitialized
G4bool initializedAtLeastOnce

References G4cerr, G4cout, G4endl, G4State_Idle, G4State_PreInit, G4RunManager::geometryInitialized, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4RunManager::Initialize(), G4RunManager::initializedAtLeastOnce, G4RunManager::physicsInitialized, and G4RunManager::verboseLevel.

Referenced by G4RunManager::BeamOn(), and DoWork().

◆ ConstructScoringWorlds()

void G4WorkerRunManager::ConstructScoringWorlds ( )
protectedvirtualinherited

Reimplemented from G4RunManager.

Definition at line 539 of file G4WorkerRunManager.cc.

540{
541 using MeshShape = G4VScoringMesh::MeshShape;
542
543 // Return if unnecessary
545 if(ScM == nullptr)
546 return;
547 G4int nPar = ScM->GetNumberOfMesh();
548 if(nPar < 1)
549 return;
550
551 // Update thread-local G4TransportationManager of all the world volumes
553
555
557
558 for(G4int iw = 0; iw < nPar; ++iw)
559 {
560 G4VScoringMesh* mesh = ScM->GetMesh(iw);
563 G4VPhysicalVolume* pWorld = nullptr;
564 if(mesh->GetShape() != MeshShape::realWorldLogVol)
565 {
567 ->IsWorldExisting(ScM->GetWorldName(iw));
568 if(pWorld == nullptr)
569 {
571 ed << "Mesh name <" << ScM->GetWorldName(iw)
572 << "> is not found in the master thread.";
573 G4Exception("G4WorkerRunManager::ConstructScoringWorlds()", "RUN79001",
574 FatalException, ed);
575 }
576 }
577 if(!(mesh->GetMeshElementLogical()))
578 {
580 G4VScoringMesh* masterMesh = masterScM->GetMesh(iw);
581 mesh->SetMeshElementLogical(masterMesh->GetMeshElementLogical());
582 l.unlock();
583
584 if(mesh->GetShape() != MeshShape::realWorldLogVol)
585 {
586 G4ParallelWorldProcess* theParallelWorldProcess =
588 if(theParallelWorldProcess != nullptr)
589 {
590 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
591 }
592 else
593 {
594 theParallelWorldProcess =
596 mesh->SetParallelWorldProcess(theParallelWorldProcess);
597 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
598
599 particleIterator->reset();
600 while((*particleIterator)())
601 {
602 G4ParticleDefinition* particle = particleIterator->value();
603 G4ProcessManager* pmanager = particle->GetProcessManager();
604 if(pmanager != nullptr)
605 {
606 pmanager->AddProcess(theParallelWorldProcess);
607 if(theParallelWorldProcess->IsAtRestRequired(particle))
608 {
609 pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest,
610 9900);
611 }
612 pmanager->SetProcessOrderingToSecond(theParallelWorldProcess,
614 pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep,
615 9900);
616 } // if(pmanager)
617 } // while
618 }
619 theParallelWorldProcess->SetLayeredMaterialFlag(mesh->LayeredMassFlg());
620 }
621 }
622 mesh->WorkerConstruct(pWorld);
623 }
624}
std::vector< G4InuclElementaryParticle >::iterator particleIterator
Definition: G4BigBanger.cc:64
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
@ idxPostStep
@ idxAtRest
@ idxAlongStep
static G4ScoringManager * GetMasterScoringManager()
void SetLayeredMaterialFlag(G4bool flg=true)
void SetParallelWorld(G4String parallelWorldName)
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4ProcessManager * GetProcessManager() const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4RunManagerKernel * kernel
static G4RUN_DLL G4bool fGeometryHasBeenDestroyed
G4VScoringMesh * GetMesh(G4int i) const
size_t GetNumberOfMesh() const
G4String GetWorldName(G4int i) const
static G4ScoringManager * GetScoringManagerIfExist()
static G4TransportationManager * GetTransportationManager()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
MeshShape GetShape() const
G4LogicalVolume * GetMeshElementLogical() const
virtual void WorkerConstruct(G4VPhysicalVolume *fWorldPhys)
void GeometryHasBeenDestroyed()
G4ParallelWorldProcess * GetParallelWorldProcess() const
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
void SetMeshElementLogical(G4LogicalVolume *val)
G4bool LayeredMassFlg()

References G4ProcessManager::AddProcess(), anonymous_namespace{G4WorkerRunManager.cc}::ConstructScoringWorldsMutex, FatalException, G4RunManager::fGeometryHasBeenDestroyed, G4Exception(), G4VScoringMesh::GeometryHasBeenDestroyed(), G4ParticleTable::GetIterator(), G4MTRunManager::GetMasterScoringManager(), G4ScoringManager::GetMesh(), G4VScoringMesh::GetMeshElementLogical(), G4ScoringManager::GetNumberOfMesh(), G4VScoringMesh::GetParallelWorldProcess(), G4ParticleTable::GetParticleTable(), G4ParticleDefinition::GetProcessManager(), G4ScoringManager::GetScoringManagerIfExist(), G4VScoringMesh::GetShape(), G4TransportationManager::GetTransportationManager(), G4ScoringManager::GetWorldName(), idxAlongStep, idxAtRest, idxPostStep, G4ParallelWorldProcess::IsAtRestRequired(), G4TransportationManager::IsWorldExisting(), G4RunManager::kernel, G4VScoringMesh::LayeredMassFlg(), G4ParallelWorldProcess::SetLayeredMaterialFlag(), G4VScoringMesh::SetMeshElementLogical(), G4ParallelWorldProcess::SetParallelWorld(), G4VScoringMesh::SetParallelWorldProcess(), G4ProcessManager::SetProcessOrdering(), G4ProcessManager::SetProcessOrderingToSecond(), G4TemplateAutoLock< _Mutex_t >::unlock(), G4VScoringMesh::WorkerConstruct(), and G4RunManagerKernel::WorkerUpdateWorldVolume().

Referenced by DoWork().

◆ CutOffHasBeenModified()

void G4RunManager::CutOffHasBeenModified ( )
inlineinherited

Definition at line 301 of file G4RunManager.hh.

302 {
303 G4cerr << "CutOffHasBeenModified becomes obsolete." << G4endl;
304 G4cerr << "It is safe to remove invoking this method." << G4endl;
305 }

References G4cerr, and G4endl.

◆ DefineWorldVolume()

void G4RunManager::DefineWorldVolume ( G4VPhysicalVolume worldVol,
G4bool  topologyIsChanged = true 
)
virtualinherited

Definition at line 791 of file G4RunManager.cc.

793{
794 kernel->DefineWorldVolume(worldVol, topologyIsChanged);
795}
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)

References G4RunManagerKernel::DefineWorldVolume(), and G4RunManager::kernel.

Referenced by export_G4RunManager(), DetectorConstruction::SetMaterial(), G4GDMLMessenger::SetNewValue(), and ExN03DetectorConstruction::UpdateGeometry().

◆ DeleteUserInitializations()

void G4RunManager::DeleteUserInitializations ( )
protectedvirtualinherited

Definition at line 244 of file G4RunManager.cc.

245{
246 delete userDetector;
247 userDetector = nullptr;
248 if(verboseLevel > 1)
249 G4cout << "UserDetectorConstruction deleted." << G4endl;
250
251 delete physicsList;
252 physicsList = nullptr;
253 if(verboseLevel > 1)
254 G4cout << "UserPhysicsList deleted." << G4endl;
255
257 userActionInitialization = nullptr;
258 if(verboseLevel > 1)
259 G4cout << "UserActionInitialization deleted." << G4endl;
260
262 userWorkerInitialization = nullptr;
263 if(verboseLevel > 1)
264 G4cout << "UserWorkerInitialization deleted." << G4endl;
265
268 if(verboseLevel > 1)
269 G4cout << "UserWorkerThreadInitialization deleted." << G4endl;
270}
G4UserWorkerInitialization * userWorkerInitialization
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
G4VUserActionInitialization * userActionInitialization
G4VUserDetectorConstruction * userDetector
G4VUserPhysicsList * physicsList

References G4cout, G4endl, G4RunManager::physicsList, G4RunManager::userActionInitialization, G4RunManager::userDetector, G4RunManager::userWorkerInitialization, G4RunManager::userWorkerThreadInitialization, and G4RunManager::verboseLevel.

Referenced by G4RunManager::~G4RunManager().

◆ DoCleanup()

void G4WorkerTaskRunManager::DoCleanup ( )
virtual

Definition at line 495 of file G4WorkerTaskRunManager.cc.

496{
498 if(currentRun)
499 delete currentRun;
500 currentRun = nullptr;
501}
void CleanUpPreviousEvents()

References G4RunManager::CleanUpPreviousEvents(), and G4RunManager::currentRun.

◆ DoEventLoop()

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

Reimplemented from G4WorkerRunManager.

Definition at line 194 of file G4WorkerTaskRunManager.cc.

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

References G4WorkerRunManager::currEvID, G4WorkerRunManager::eventLoopOnGoing, FatalException, G4Exception(), G4RunManager::InitializeEventLoop(), G4WorkerRunManager::nevModulo, ProcessOneEvent(), G4RunManager::runAborted, G4WorkerRunManager::seedsQueue, G4RunManager::TerminateOneEvent(), and G4RunManager::userPrimaryGeneratorAction.

Referenced by DoWork().

◆ DoWork()

void G4WorkerTaskRunManager::DoWork ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 505 of file G4WorkerTaskRunManager.cc.

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

References G4RunManager::ConfirmBeamOnCondition(), G4WorkerRunManager::ConstructScoringWorlds(), DoEventLoop(), G4ThreadLocalStatic, G4RunManager::GetCurrentRun(), G4TaskRunManager::GetMasterRunManager(), G4RunManager::GetNumberOfEventsToBeProcessed(), G4RunManager::GetNumberOfSelectEvents(), G4RunManager::GetSelectMacro(), ProcessUI(), RunInitialization(), G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster(), and G4WorkerRunManager::workerContext.

Referenced by G4TaskRunManager::CreateAndStartWorkers().

◆ DumpRegion() [1/2]

void G4RunManager::DumpRegion ( const G4String rname) const
inherited

Definition at line 890 of file G4RunManager.cc.

891{
892 kernel->DumpRegion(rname);
893}
void DumpRegion(const G4String &rname) const

References G4RunManagerKernel::DumpRegion(), and G4RunManager::kernel.

Referenced by G4RunMessenger::SetNewValue().

◆ DumpRegion() [2/2]

void G4RunManager::DumpRegion ( G4Region region = nullptr) const
inherited

Definition at line 896 of file G4RunManager.cc.

897{
898 kernel->DumpRegion(region);
899}

References G4RunManagerKernel::DumpRegion(), and G4RunManager::kernel.

◆ GenerateEvent()

G4Event * G4WorkerTaskRunManager::GenerateEvent ( G4int  i_event)
overridevirtual

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

Reimplemented from G4WorkerRunManager.

Definition at line 257 of file G4WorkerTaskRunManager.cc.

258{
259 G4Event* anEvent = new G4Event(i_event);
260 long s1 = 0;
261 long s2 = 0;
262 long s3 = 0;
263 G4bool eventHasToBeSeeded = true;
265 eventHasToBeSeeded = false;
266
267 if(i_event < 0)
268 {
270 if(nevM == 1)
271 {
273 anEvent, s1, s2, s3, eventHasToBeSeeded);
274 runIsSeeded = true;
275 }
276 else
277 {
278 if(nevModulo <= 0)
279 {
281 anEvent, &seedsQueue, eventHasToBeSeeded);
282 if(nevToDo == 0)
283 eventLoopOnGoing = false;
284 else
285 {
286 currEvID = anEvent->GetEventID();
287 nevModulo = nevToDo - 1;
288 }
289 }
290 else
291 {
293 eventHasToBeSeeded = false;
294 anEvent->SetEventID(++currEvID);
295 nevModulo--;
296 }
297 if(eventLoopOnGoing && eventHasToBeSeeded)
298 {
299 s1 = seedsQueue.front();
300 seedsQueue.pop();
301 s2 = seedsQueue.front();
302 seedsQueue.pop();
303 }
304 }
305
307 {
308 delete anEvent;
309 return nullptr;
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;
327 }
328
329 // Read from file seed.
330 // Andrea Dotti 4 November 2015
331 // This is required for strong-reproducibility, in MT mode we have that each
332 // thread produces, for each event a status file, we want to do that.
333 // Search a random file with the format run{%d}evt{%d}.rndm
334
335 // This is the filename base constructed from run and event
336 const auto filename = [&] {
337 std::ostringstream os;
338 os << "run" << currentRun->GetRunID() << "evt" << anEvent->GetEventID();
339 return os.str();
340 };
341
342 G4bool RNGstatusReadFromFile = false;
344 {
345 // Build full path of RNG status file for this event
346 std::ostringstream os;
347 os << filename() << ".rndm";
348 const G4String& randomStatusFile = os.str();
349 std::ifstream ifile(randomStatusFile.c_str());
350 if(ifile)
351 {
352 // File valid and readable
353 RNGstatusReadFromFile = true;
354 G4Random::restoreEngineStatus(randomStatusFile.c_str());
355 }
356 }
357
360 {
361 std::ostringstream oss;
362 G4Random::saveFullState(oss);
365 }
366
367 if(storeRandomNumberStatus && !RNGstatusReadFromFile)
368 {
369 // If reading from file, avoid to rewrite the same
370 G4String fileN = "currentEvent";
372 fileN = filename();
373 StoreRNGStatus(fileN);
374 }
375
376 if(printModulo > 0 && anEvent->GetEventID() % printModulo == 0)
377 {
378 G4cout << "--> Event " << anEvent->GetEventID() << " starts";
379 if(eventHasToBeSeeded)
380 G4cout << " with initial seeds (" << s1 << "," << s2 << ")";
381 G4cout << "." << G4endl;
382 }
384 return anEvent;
385}
void SetRandomNumberStatus(G4String &st)
Definition: G4Event.hh:90
G4int GetEventID() const
Definition: G4Event.hh:118
void SetEventID(G4int i)
Definition: G4Event.hh:80
static G4int SeedOncePerCommunication()
virtual G4int SetUpNEvents(G4Event *, G4SeedsQueue *seedsQueue, G4bool reseedRequired=true)
virtual G4bool SetUpAnEvent(G4Event *, long &s1, long &s2, long &s3, G4bool reseedRequired=true)
G4int GetEventModulo() const
static G4MTRunManager * GetMasterRunManager()
G4int storeRandomNumberStatusToG4Event
G4bool rngStatusEventsFlag
G4String randomNumberStatusForThisEvent
G4bool storeRandomNumberStatus
G4int GetRunID() const
Definition: G4Run.hh:78
static G4TemplateRNGHelper< T > * GetInstance()
Definition: G4RNGHelper.cc:42
virtual const T GetSeed(const G4int &sdId)
Definition: G4RNGHelper.hh:64
virtual void GeneratePrimaries(G4Event *anEvent)=0
virtual void StoreRNGStatus(const G4String &filenamePrefix) override

References G4RunManager::currentRun, G4WorkerRunManager::currEvID, G4WorkerRunManager::eventLoopOnGoing, G4cout, G4endl, G4VUserPrimaryGeneratorAction::GeneratePrimaries(), G4Event::GetEventID(), G4MTRunManager::GetEventModulo(), G4TemplateRNGHelper< T >::GetInstance(), G4MTRunManager::GetMasterRunManager(), G4Run::GetRunID(), G4TemplateRNGHelper< T >::GetSeed(), G4WorkerRunManager::nevModulo, G4RunManager::printModulo, G4RunManager::randomNumberStatusForThisEvent, G4WorkerRunManager::readStatusFromFile, G4RunManager::rngStatusEventsFlag, G4WorkerRunManager::runIsSeeded, G4MTRunManager::SeedOncePerCommunication(), G4WorkerRunManager::seedsQueue, G4Event::SetEventID(), G4Event::SetRandomNumberStatus(), G4MTRunManager::SetUpAnEvent(), G4MTRunManager::SetUpNEvents(), G4RunManager::storeRandomNumberStatus, G4RunManager::storeRandomNumberStatusToG4Event, StoreRNGStatus(), and G4RunManager::userPrimaryGeneratorAction.

Referenced by ProcessOneEvent().

◆ GeometryDirectlyUpdated()

void G4RunManager::GeometryDirectlyUpdated ( G4bool  val = true)
inlineinherited

Definition at line 331 of file G4RunManager.hh.

332 {
334 }
G4bool geometryDirectlyUpdated

References G4RunManager::geometryDirectlyUpdated.

Referenced by G4GDMLMessenger::SetNewValue().

◆ GeometryHasBeenModified()

void G4RunManager::GeometryHasBeenModified ( G4bool  prop = true)
inherited

Definition at line 1117 of file G4RunManager.cc.

1118{
1119 if(prop)
1120 {
1121 G4UImanager::GetUIpointer()->ApplyCommand("/run/geometryModified");
1122 }
1123 else
1124 {
1126 }
1127}
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77

References G4UImanager::ApplyCommand(), G4RunManagerKernel::GeometryHasBeenModified(), G4UImanager::GetUIpointer(), and G4RunManager::kernel.

Referenced by G4RunManager::ConstructScoringWorlds(), export_G4RunManager(), and G4RunMessenger::SetNewValue().

◆ GetCommandStack()

G4StrVector G4WorkerTaskRunManager::GetCommandStack ( ) const
inline

Definition at line 78 of file G4WorkerTaskRunManager.hh.

References processedCommandStack.

◆ GetCurrentEvent()

const G4Event * G4RunManager::GetCurrentEvent ( ) const
inlineinherited

◆ GetCurrentRun()

const G4Run * G4RunManager::GetCurrentRun ( ) const
inlineinherited

◆ GetFlagRandomNumberStatusToG4Event()

G4int G4RunManager::GetFlagRandomNumberStatusToG4Event ( ) const
inlineinherited

◆ GetGeometryToBeOptimized()

G4bool G4RunManager::GetGeometryToBeOptimized ( )
inlineinherited

Definition at line 326 of file G4RunManager.hh.

327 {
329 }
G4bool geometryToBeOptimized

References G4RunManager::geometryToBeOptimized.

Referenced by export_G4RunManager().

◆ GetNonConstCurrentRun()

G4Run * G4RunManager::GetNonConstCurrentRun ( ) const
inlineinherited

Definition at line 534 of file G4RunManager.hh.

534{ return currentRun; }

References G4RunManager::currentRun.

◆ GetNonConstUserActionInitialization()

G4VUserActionInitialization * G4RunManager::GetNonConstUserActionInitialization ( ) const
inlineinherited

◆ GetNumberOfEventsToBeProcessed()

G4int G4RunManager::GetNumberOfEventsToBeProcessed ( ) const
inlineinherited

◆ GetNumberOfParallelWorld()

G4int G4RunManager::GetNumberOfParallelWorld ( ) const
inlineinherited

Definition at line 562 of file G4RunManager.hh.

562{ return nParallelWorlds; }
G4int nParallelWorlds

References G4RunManager::nParallelWorlds.

◆ GetNumberOfSelectEvents()

G4int G4RunManager::GetNumberOfSelectEvents ( ) const
inlineinherited

Definition at line 571 of file G4RunManager.hh.

571{ return n_select_msg; }
G4int n_select_msg

References G4RunManager::n_select_msg.

Referenced by G4WorkerRunManager::DoWork(), and DoWork().

◆ GetNumberOfThreads()

virtual G4int G4RunManager::GetNumberOfThreads ( ) const
inlinevirtualinherited

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 265 of file G4RunManager.hh.

265{ return 1; }

◆ GetPreviousEvent()

const G4Event * G4RunManager::GetPreviousEvent ( G4int  i) const
inlineinherited

Definition at line 540 of file G4RunManager.hh.

546 {
547 if(i >= 1 && i <= n_perviousEventsToBeStored)
548 {
549 auto itr = previousEvents->cbegin();
550 for(G4int j = 1; j < i; ++j)
551 {
552 ++itr;
553 }
554 return *itr;
555 }
556 return nullptr;
557 }
G4int n_perviousEventsToBeStored

References G4RunManager::n_perviousEventsToBeStored, and G4RunManager::previousEvents.

Referenced by G4DigiManager::GetDigiCollection(), and G4DigiManager::GetHitsCollection().

◆ GetPrintProgress()

G4int G4RunManager::GetPrintProgress ( )
inlineinherited

Definition at line 521 of file G4RunManager.hh.

521{ return printModulo; }

References G4RunManager::printModulo.

Referenced by G4TheMTRayTracer::CreateBitMap(), and G4RunMessenger::GetCurrentValue().

◆ GetRandomNumberStatusForThisEvent()

const G4String & G4RunManager::GetRandomNumberStatusForThisEvent ( ) const
inlineinherited

Definition at line 495 of file G4RunManager.hh.

496 {
499 {
500 G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0072",
502 "Random number status is not available for this event.");
503 }
505 }
@ JustWarning

References G4Exception(), JustWarning, G4RunManager::randomNumberStatusForThisEvent, and G4RunManager::storeRandomNumberStatusToG4Event.

◆ GetRandomNumberStatusForThisRun()

const G4String & G4RunManager::GetRandomNumberStatusForThisRun ( ) const
inlineinherited

Definition at line 491 of file G4RunManager.hh.

492 {
494 }
G4String randomNumberStatusForThisRun

References G4RunManager::randomNumberStatusForThisRun.

◆ GetRandomNumberStore()

G4bool G4RunManager::GetRandomNumberStore ( ) const
inlineinherited

Definition at line 460 of file G4RunManager.hh.

461 {
463 }

References G4RunManager::storeRandomNumberStatus.

Referenced by export_G4RunManager().

◆ GetRandomNumberStoreDir()

const G4String & G4RunManager::GetRandomNumberStoreDir ( ) const
inlineinherited

Definition at line 487 of file G4RunManager.hh.

488 {
490 }
G4String randomNumberStatusDir

References G4RunManager::randomNumberStatusDir.

Referenced by export_G4RunManager(), and G4RunMessenger::GetCurrentValue().

◆ GetRandomNumberStorePerEvent()

G4bool G4RunManager::GetRandomNumberStorePerEvent ( ) const
inlineinherited

Definition at line 510 of file G4RunManager.hh.

511 {
512 return rngStatusEventsFlag;
513 }

References G4RunManager::rngStatusEventsFlag.

◆ GetRunManager()

G4RunManager * G4RunManager::GetRunManager ( )
staticinherited

◆ GetRunManagerType()

RMType G4RunManager::GetRunManagerType ( ) const
inlineinherited

◆ GetSelectMacro()

const G4String & G4RunManager::GetSelectMacro ( ) const
inlineinherited

Definition at line 572 of file G4RunManager.hh.

572{ return selectMacro; }
G4String selectMacro

References G4RunManager::selectMacro.

Referenced by G4WorkerRunManager::DoWork(), and DoWork().

◆ GetUserActionInitialization()

const G4VUserActionInitialization * G4RunManager::GetUserActionInitialization ( ) const
inlineinherited

◆ GetUserDetectorConstruction()

const G4VUserDetectorConstruction * G4RunManager::GetUserDetectorConstruction ( ) const
inlineinherited

◆ GetUserEventAction()

const G4UserEventAction * G4RunManager::GetUserEventAction ( ) const
inlineinherited

◆ GetUserPhysicsList()

const G4VUserPhysicsList * G4RunManager::GetUserPhysicsList ( ) const
inlineinherited

◆ GetUserPrimaryGeneratorAction()

const G4VUserPrimaryGeneratorAction * G4RunManager::GetUserPrimaryGeneratorAction ( ) const
inlineinherited

◆ GetUserRunAction()

const G4UserRunAction * G4RunManager::GetUserRunAction ( ) const
inlineinherited

◆ GetUserStackingAction()

const G4UserStackingAction * G4RunManager::GetUserStackingAction ( ) const
inlineinherited

◆ GetUserSteppingAction()

const G4UserSteppingAction * G4RunManager::GetUserSteppingAction ( ) const
inlineinherited

◆ GetUserTrackingAction()

const G4UserTrackingAction * G4RunManager::GetUserTrackingAction ( ) const
inlineinherited

◆ GetUserWorkerInitialization()

const G4UserWorkerInitialization * G4RunManager::GetUserWorkerInitialization ( ) const
inlineinherited

◆ GetUserWorkerThreadInitialization()

const G4UserWorkerThreadInitialization * G4RunManager::GetUserWorkerThreadInitialization ( ) const
inlineinherited

◆ GetVerboseLevel()

G4int G4RunManager::GetVerboseLevel ( ) const
inlineinherited

◆ GetVersionString()

const G4String & G4RunManager::GetVersionString ( ) const
inlineinherited

Definition at line 431 of file G4RunManager.hh.

432 {
433 return kernel->GetVersionString();
434 }
const G4String & GetVersionString() const

References G4RunManagerKernel::GetVersionString(), and G4RunManager::kernel.

Referenced by export_G4RunManager().

◆ GetWorkerRunManager()

G4WorkerTaskRunManager * G4WorkerTaskRunManager::GetWorkerRunManager ( )
static

◆ GetWorkerRunManagerKernel()

G4WorkerTaskRunManagerKernel * G4WorkerTaskRunManager::GetWorkerRunManagerKernel ( )
static

Definition at line 73 of file G4WorkerTaskRunManager.cc.

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

References GetWorkerRunManager(), and G4RunManager::kernel.

◆ GetWorkerThread()

G4WorkerThread * G4WorkerTaskRunManager::GetWorkerThread ( ) const
inline

◆ IfGeometryHasBeenDestroyed()

G4bool G4RunManager::IfGeometryHasBeenDestroyed ( )
staticinherited

Definition at line 105 of file G4RunManager.cc.

106{
108}

References G4RunManager::fGeometryHasBeenDestroyed.

Referenced by RunInitialization().

◆ Initialize()

void G4RunManager::Initialize ( void  )
virtualinherited

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 667 of file G4RunManager.cc.

668{
670 G4ApplicationState currentState = stateManager->GetCurrentState();
671 if(currentState != G4State_PreInit && currentState != G4State_Idle)
672 {
673 G4cerr << "Illegal application state - "
674 << "G4RunManager::Initialize() ignored." << G4endl;
675 return;
676 }
677
678 stateManager->SetNewState(G4State_Init);
684 if(stateManager->GetCurrentState() != G4State_Idle)
685 {
686 stateManager->SetNewState(G4State_Idle);
687 }
688}
@ G4State_Init
virtual void InitializePhysics()
virtual void InitializeGeometry()
G4bool SetNewState(const G4ApplicationState &requestedState)

References G4cerr, G4endl, G4State_Idle, G4State_Init, G4State_PreInit, G4RunManager::geometryInitialized, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4RunManager::initializedAtLeastOnce, G4RunManager::InitializeGeometry(), G4RunManager::InitializePhysics(), G4RunManager::physicsInitialized, and G4StateManager::SetNewState().

Referenced by G4RunManager::ConfirmBeamOnCondition(), export_G4RunManager(), G4MTRunManager::Initialize(), G4TaskRunManager::Initialize(), G4RunMessenger::SetNewValue(), and G4MTRunManagerKernel::StartThread().

◆ InitializeEventLoop()

void G4RunManager::InitializeEventLoop ( G4int  n_event,
const char *  macroFile = nullptr,
G4int  n_select = -1 
)
virtualinherited

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 433 of file G4RunManager.cc.

435{
436 if(verboseLevel > 0)
437 {
438 timer->Start();
439 }
440
441 n_select_msg = n_select;
442 if(macroFile != 0)
443 {
444 if(n_select_msg < 0)
445 n_select_msg = n_event;
446 msgText = "/control/execute ";
447 msgText += macroFile;
448 selectMacro = macroFile;
449 }
450 else
451 {
452 n_select_msg = -1;
453 selectMacro = "";
454 }
455}
G4Timer * timer
G4String msgText
void Start()

References G4RunManager::msgText, G4RunManager::n_select_msg, G4RunManager::selectMacro, G4Timer::Start(), G4RunManager::timer, and G4RunManager::verboseLevel.

Referenced by G4WorkerRunManager::DoEventLoop(), G4RunManager::DoEventLoop(), and DoEventLoop().

◆ InitializeGeometry()

void G4WorkerRunManager::InitializeGeometry ( )
virtualinherited

Reimplemented from G4RunManager.

Definition at line 144 of file G4WorkerRunManager.cc.

145{
146 if(userDetector == nullptr)
147 {
148 G4Exception("G4RunManager::InitializeGeometry", "Run0033", FatalException,
149 "G4VUserDetectorConstruction is not defined!");
150 return;
151 }
153 {
155 }
156
157 // Step1: Get pointer to the physiWorld (note: needs to get the "super
158 // pointer, i.e. the one shared by all threads"
159 G4RunManagerKernel* masterKernel =
161 G4VPhysicalVolume* worldVol = masterKernel->GetCurrentWorld();
162 // Step2:, Call a new "WorkerDefineWorldVolume( pointer from 2-, false);
163 kernel->WorkerDefineWorldVolume(worldVol, false);
165 // Step3: Call user's ConstructSDandField()
168 geometryInitialized = true;
169}
static G4RunManagerKernel * GetMasterRunManagerKernel()
G4VPhysicalVolume * GetCurrentWorld() const
void SetNumberOfParallelWorld(G4int i)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4int GetNumberOfParallelWorld() const

References G4TransportationManager::ClearParallelWorlds(), G4VUserDetectorConstruction::ConstructParallelSD(), G4VUserDetectorConstruction::ConstructSDandField(), FatalException, G4RunManager::fGeometryHasBeenDestroyed, G4Exception(), G4RunManager::geometryInitialized, G4RunManagerKernel::GetCurrentWorld(), G4MTRunManager::GetMasterRunManagerKernel(), G4RunManagerKernel::GetNumberOfParallelWorld(), G4TransportationManager::GetTransportationManager(), G4RunManager::kernel, G4RunManagerKernel::SetNumberOfParallelWorld(), G4RunManager::userDetector, and G4RunManagerKernel::WorkerDefineWorldVolume().

◆ InitializePhysics()

void G4RunManager::InitializePhysics ( )
virtualinherited

Definition at line 731 of file G4RunManager.cc.

732{
734 G4ApplicationState currentState = stateManager->GetCurrentState();
735 if(currentState == G4State_PreInit || currentState == G4State_Idle)
736 {
737 stateManager->SetNewState(G4State_Init);
738 }
739 if(physicsList != nullptr)
740 {
742 }
743 else
744 {
745 G4Exception("G4RunManager::InitializePhysics()", "Run0034", FatalException,
746 "G4VUserPhysicsList is not defined!");
747 }
748 physicsInitialized = true;
749 stateManager->SetNewState(currentState);
750}

References FatalException, G4Exception(), G4State_Idle, G4State_Init, G4State_PreInit, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4RunManagerKernel::InitializePhysics(), G4RunManager::kernel, G4RunManager::physicsInitialized, G4RunManager::physicsList, and G4StateManager::SetNewState().

Referenced by G4RunManager::Initialize().

◆ MergePartialResults()

void G4WorkerRunManager::MergePartialResults ( )
protectedvirtualinherited

Definition at line 475 of file G4WorkerRunManager.cc.

476{
477 // Merge partial results into global run
480 if(ScM != nullptr)
481 mtRM->MergeScores(ScM);
482 mtRM->MergeRun(currentRun);
483}
void MergeRun(const G4Run *localRun)
void MergeScores(const G4ScoringManager *localScoringManager)

References G4RunManager::currentRun, G4MTRunManager::GetMasterRunManager(), G4ScoringManager::GetScoringManagerIfExist(), G4MTRunManager::MergeRun(), and G4MTRunManager::MergeScores().

Referenced by G4WorkerRunManager::RunTermination(), and RunTermination().

◆ PhysicsHasBeenModified()

void G4RunManager::PhysicsHasBeenModified ( )
inlineinherited

◆ ProcessOneEvent()

void G4WorkerTaskRunManager::ProcessOneEvent ( G4int  i_event)
overridevirtual

◆ ProcessUI()

void G4WorkerTaskRunManager::ProcessUI ( )
virtual

Definition at line 463 of file G4WorkerTaskRunManager.cc.

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

References G4UImanager::ApplyCommand(), G4MTRunManager::GetCommandStack(), G4TaskRunManager::GetMasterRunManager(), G4UImanager::GetUIpointer(), and processedCommandStack.

Referenced by DoWork().

◆ ReinitializeGeometry()

void G4RunManager::ReinitializeGeometry ( G4bool  destroyFirst = false,
G4bool  prop = true 
)
inherited

Definition at line 1130 of file G4RunManager.cc.

1131{
1132 if(destroyFirst && G4Threading::IsMasterThread())
1133 {
1134 if(verboseLevel > 0)
1135 {
1136 G4cout << "#### Assemblies, Volumes and Solids Stores are wiped out."
1137 << G4endl;
1138 }
1144
1145 // remove all logical volume pointers from regions
1146 // exception: world logical volume pointer must be kept
1148 for(auto rItr = regionStore->cbegin(); rItr != regionStore->cend(); ++rItr)
1149 {
1150 if((*rItr)->GetName() == "DefaultRegionForTheWorld")
1151 continue;
1152 // if((*rItr)->GetName()=="DefaultRegionForParallelWorld") continue;
1153 auto lvItr = (*rItr)->GetRootLogicalVolumeIterator();
1154 for(std::size_t iRLV=0; iRLV<(*rItr)->GetNumberOfRootVolumes(); ++iRLV)
1155 {
1156 (*rItr)->RemoveRootLogicalVolume(*lvItr, false);
1157 ++lvItr;
1158 }
1159 if(verboseLevel > 0)
1160 {
1161 G4cout << "#### Region <" << (*rItr)->GetName() << "> is cleared."
1162 << G4endl;
1163 }
1164 }
1165
1166 // clear transportation manager
1169 }
1170 if(prop)
1171 {
1172 G4UImanager::GetUIpointer()->ApplyCommand("/run/reinitializeGeometry");
1173 }
1174 else
1175 {
1177 geometryInitialized = false;
1178 // Notify the VisManager as well
1180 {
1182 if(pVVisManager != nullptr)
1183 pVVisManager->GeometryHasChanged();
1184 }
1185 }
1186}
static G4AssemblyStore * GetInstance()
static void Clean()
static G4GeometryManager * GetInstance()
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
static G4LogicalVolumeStore * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
static G4RegionStore * GetInstance()
static void Clean()
Definition: G4SolidStore.cc:74
static G4SolidStore * GetInstance()
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0
G4bool IsMasterThread()
Definition: G4Threading.cc:124

References G4UImanager::ApplyCommand(), G4LogicalVolumeStore::Clean(), G4PhysicalVolumeStore::Clean(), G4SolidStore::Clean(), G4AssemblyStore::Clean(), G4TransportationManager::ClearParallelWorlds(), G4RunManager::fGeometryHasBeenDestroyed, G4cout, G4endl, G4RunManagerKernel::GeometryHasBeenModified(), G4VVisManager::GeometryHasChanged(), G4RunManager::geometryInitialized, G4VVisManager::GetConcreteInstance(), G4GeometryManager::GetInstance(), G4LogicalVolumeStore::GetInstance(), G4PhysicalVolumeStore::GetInstance(), G4RegionStore::GetInstance(), G4SolidStore::GetInstance(), G4AssemblyStore::GetInstance(), G4TransportationManager::GetTransportationManager(), G4UImanager::GetUIpointer(), G4Threading::IsMasterThread(), G4RunManager::kernel, G4GeometryManager::OpenGeometry(), and G4RunManager::verboseLevel.

Referenced by G4GDMLMessenger::SetNewValue(), and G4RunMessenger::SetNewValue().

◆ ReOptimize()

void G4RunManager::ReOptimize ( G4LogicalVolume pLog)
inherited

Definition at line 1009 of file G4RunManager.cc.

1010{
1011 G4Timer localtimer;
1012 if(verboseLevel > 1)
1013 {
1014 localtimer.Start();
1015 }
1016 G4SmartVoxelHeader* header = pLog->GetVoxelHeader();
1017 delete header;
1018 header = new G4SmartVoxelHeader(pLog);
1019 pLog->SetVoxelHeader(header);
1020 if(verboseLevel > 1)
1021 {
1022 localtimer.Stop();
1023 G4SmartVoxelStat stat(pLog, header, localtimer.GetSystemElapsed(),
1024 localtimer.GetUserElapsed());
1025 G4cout << G4endl << "Voxelisation of logical volume <" << pLog->GetName()
1026 << ">" << G4endl;
1027 G4cout << " heads : " << stat.GetNumberHeads()
1028 << " - nodes : " << stat.GetNumberNodes()
1029 << " - pointers : " << stat.GetNumberPointers() << G4endl;
1030 G4cout << " Memory used : " << (stat.GetMemoryUse() + 512) / 1024
1031 << "k - total time : " << stat.GetTotalTime()
1032 << " - system time : " << stat.GetSysTime() << G4endl;
1033 }
1034}
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
const G4String & GetName() const
G4SmartVoxelHeader * GetVoxelHeader() const
void Stop()
G4double GetSystemElapsed() const
Definition: G4Timer.cc:132
G4double GetUserElapsed() const
Definition: G4Timer.cc:143

References G4cout, G4endl, G4SmartVoxelStat::GetMemoryUse(), G4LogicalVolume::GetName(), G4SmartVoxelStat::GetNumberHeads(), G4SmartVoxelStat::GetNumberNodes(), G4SmartVoxelStat::GetNumberPointers(), G4Timer::GetSystemElapsed(), G4SmartVoxelStat::GetSysTime(), G4SmartVoxelStat::GetTotalTime(), G4Timer::GetUserElapsed(), G4LogicalVolume::GetVoxelHeader(), G4LogicalVolume::SetVoxelHeader(), G4Timer::Start(), G4Timer::Stop(), and G4RunManager::verboseLevel.

Referenced by G4RunManager::ReOptimizeMotherOf().

◆ ReOptimizeMotherOf()

void G4RunManager::ReOptimizeMotherOf ( G4VPhysicalVolume pPhys)
inherited

Definition at line 1001 of file G4RunManager.cc.

1002{
1003 G4LogicalVolume* pMotherL = pPhys->GetMotherLogical();
1004 if(pMotherL != nullptr)
1005 ReOptimize(pMotherL);
1006}
void ReOptimize(G4LogicalVolume *)
G4LogicalVolume * GetMotherLogical() const

References G4VPhysicalVolume::GetMotherLogical(), and G4RunManager::ReOptimize().

◆ RestoreRandomNumberStatus()

void G4RunManager::RestoreRandomNumberStatus ( const G4String fileN)
virtualinherited

Definition at line 870 of file G4RunManager.cc.

871{
872 G4String fileNameWithDirectory;
873 if(fileN.find("/") == std::string::npos)
874 {
875 fileNameWithDirectory = randomNumberStatusDir + fileN;
876 }
877 else
878 {
879 fileNameWithDirectory = fileN;
880 }
881
882 G4Random::restoreEngineStatus(fileNameWithDirectory);
883 if(verboseLevel > 0)
884 G4cout << "RandomNumberEngineStatus restored from file: "
885 << fileNameWithDirectory << G4endl;
886 G4Random::showEngineStatus();
887}

References G4cout, G4endl, G4RunManager::randomNumberStatusDir, and G4RunManager::verboseLevel.

Referenced by export_G4RunManager(), and G4RunMessenger::SetNewValue().

◆ RestoreRndmEachEvent()

virtual void G4WorkerTaskRunManager::RestoreRndmEachEvent ( G4bool  flag)
inlineoverridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 70 of file G4WorkerTaskRunManager.hh.

71 {
72 readStatusFromFile = flag;
73 }

References G4WorkerRunManager::readStatusFromFile.

◆ rndmSaveThisEvent()

void G4WorkerRunManager::rndmSaveThisEvent ( )
protectedvirtualinherited

Reimplemented from G4RunManager.

Definition at line 767 of file G4WorkerRunManager.cc.

768{
769 if(currentEvent == nullptr)
770 {
771 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
772 << " there is no currentEvent available." << G4endl
773 << "Command ignored." << G4endl;
774 return;
775 }
776
778 {
779 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
780 << " Random number engine status is not available." << G4endl
781 << "/random/setSavingFlag command must be issued "
782 << "prior to the start of the run. Command ignored." << G4endl;
783 return;
784 }
785
786 std::ostringstream oos;
787 oos << "G4Worker" << workerContext->GetThreadId() << "_"
788 << "currentEvent.rndm"
789 << "\0";
790 G4String fileIn = randomNumberStatusDir + oos.str();
791
792 std::ostringstream os;
793 os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID()
794 << ".rndm" << '\0';
795 G4String fileOut = randomNumberStatusDir + os.str();
796
797#ifdef WIN32
798 G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
799#else
800 G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
801#endif
803 if(verboseLevel > 0)
804 {
805 G4cout << fileIn << " is copied to " << fileOut << G4endl;
806 }
807}
G4int GetThreadId() const

References G4UImanager::ApplyCommand(), G4RunManager::currentEvent, G4RunManager::currentRun, G4cerr, G4cout, G4endl, G4Event::GetEventID(), G4Run::GetRunID(), G4WorkerThread::GetThreadId(), G4UImanager::GetUIpointer(), G4RunManager::randomNumberStatusDir, G4RunManager::storeRandomNumberStatus, G4RunManager::verboseLevel, and G4WorkerRunManager::workerContext.

◆ rndmSaveThisRun()

void G4WorkerRunManager::rndmSaveThisRun ( )
protectedvirtualinherited

Reimplemented from G4RunManager.

Definition at line 730 of file G4WorkerRunManager.cc.

731{
732 G4int runNumber = 0;
733 if(currentRun != nullptr)
734 runNumber = currentRun->GetRunID();
736 {
737 G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
738 << " Random number status was not stored prior to this run."
739 << G4endl << "/random/setSavingFlag command must be issued. "
740 << "Command ignored." << G4endl;
741 return;
742 }
743
744 std::ostringstream oos;
745 oos << "G4Worker" << workerContext->GetThreadId() << "_"
746 << "currentRun.rndm"
747 << "\0";
748 G4String fileIn = randomNumberStatusDir + oos.str();
749
750 std::ostringstream os;
751 os << "run" << runNumber << ".rndm" << '\0';
752 G4String fileOut = randomNumberStatusDir + os.str();
753
754#ifdef WIN32
755 G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
756#else
757 G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
758#endif
760 if(verboseLevel > 0)
761 {
762 G4cout << fileIn << " is copied to " << fileOut << G4endl;
763 }
764}

References G4UImanager::ApplyCommand(), G4RunManager::currentRun, G4cerr, G4cout, G4endl, G4Run::GetRunID(), G4WorkerThread::GetThreadId(), G4UImanager::GetUIpointer(), G4RunManager::randomNumberStatusDir, G4RunManager::storeRandomNumberStatus, G4RunManager::verboseLevel, and G4WorkerRunManager::workerContext.

◆ RunInitialization()

void G4WorkerTaskRunManager::RunInitialization ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 87 of file G4WorkerTaskRunManager.cc.

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

References G4UserRunAction::BeginOfRunAction(), G4VScoreNtupleWriter::Book(), G4RunManager::CleanUpPreviousEvents(), G4RunManager::currentRun, G4RunManager::DCtable, G4RunManager::fakeRun, G4cout, G4endl, G4Threading::G4GetThreadId(), G4UserRunAction::GenerateRun(), G4VVisManager::GetConcreteInstance(), G4SDManager::GetHCtable(), G4ParallelWorldProcessStore::GetInstance(), G4MTRunManager::GetMasterRunManager(), G4TaskRunManager::GetMasterRunManager(), G4RunManager::GetNumberOfEventsToBeProcessed(), G4Run::GetRunID(), G4SDManager::GetSDMpointerIfExist(), G4RunManager::GetUserWorkerInitialization(), G4RunManager::IfGeometryHasBeenDestroyed(), G4VScoreNtupleWriter::Instance(), G4RunManager::isScoreNtupleWriter, G4RunManager::kernel, G4RunManager::n_perviousEventsToBeStored, G4RunManager::numberOfEventProcessed, G4RunManager::numberOfEventToBeProcessed, G4VScoreNtupleWriter::OpenFile(), G4SDManager::PrepareNewEvent(), G4RunManager::previousEvents, G4RunManager::printModulo, G4RunManager::randomNumberStatusForThisRun, G4RunManager::rngStatusEventsFlag, G4RunManager::runAborted, G4RunManager::runIDCounter, G4RunManagerKernel::RunInitialization(), G4WorkerRunManager::runIsSeeded, G4Run::SetDCtable(), G4Run::SetHCtable(), G4Run::SetNumberOfEventToBeProcessed(), G4Run::SetRandomNumberStatus(), G4Run::SetRunID(), G4RunManager::storeRandomNumberStatus, StoreRNGStatus(), G4MTRunManager::ThisWorkerReady(), G4ParallelWorldProcessStore::UpdateWorlds(), G4RunManager::userRunAction, G4RunManager::verboseLevel, workerRunProfiler, and G4UserWorkerInitialization::WorkerRunStart().

Referenced by DoWork().

◆ RunTermination()

void G4WorkerTaskRunManager::RunTermination ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 389 of file G4WorkerTaskRunManager.cc.

390{
391 if(!fakeRun && currentRun)
392 {
393#if defined(GEANT4_USE_TIMEMORY)
394 workerRunProfiler.reset();
395#endif
397
398 // Call a user hook: note this is before the next barrier
399 // so threads execute this method asyncrhonouzly
400 //(TerminateRun allows for synch via G4RunAction::EndOfRun)
401 const G4UserWorkerInitialization* uwi =
403 if(uwi)
404 uwi->WorkerRunEnd();
405 }
406
407 if(currentRun)
408 {
410 }
411 // Signal this thread has finished envent-loop.
412 // Note this will return only whan all threads reach this point
414}
virtual void ThisWorkerEndEventLoop()
virtual void MergePartialResults()

References G4RunManager::currentRun, G4RunManager::fakeRun, G4MTRunManager::GetMasterRunManager(), G4RunManager::GetUserWorkerInitialization(), G4WorkerRunManager::MergePartialResults(), G4RunManager::RunTermination(), G4MTRunManager::ThisWorkerEndEventLoop(), G4UserWorkerInitialization::WorkerRunEnd(), and workerRunProfiler.

Referenced by G4TaskRunManagerKernel::TerminateWorkerRunEventLoop().

◆ SetDCtable()

void G4RunManager::SetDCtable ( G4DCtable DCtbl)
inlineinherited

Definition at line 573 of file G4RunManager.hh.

573{ DCtable = DCtbl; }

References G4RunManager::DCtable.

Referenced by G4DigiManager::AddNewModule().

◆ SetGeometryToBeOptimized()

void G4RunManager::SetGeometryToBeOptimized ( G4bool  vl)
inlineinherited

◆ SetNumberOfAdditionalWaitingStacks()

void G4RunManager::SetNumberOfAdditionalWaitingStacks ( G4int  iAdd)
inlineinherited

◆ SetNumberOfEventsToBeProcessed()

void G4RunManager::SetNumberOfEventsToBeProcessed ( G4int  val)
inlineinherited

Definition at line 563 of file G4RunManager.hh.

564 {
566 }

References G4RunManager::numberOfEventToBeProcessed.

◆ SetNumberOfEventsToBeStored()

void G4RunManager::SetNumberOfEventsToBeStored ( G4int  val)
inlineinherited

Definition at line 524 of file G4RunManager.hh.

529 {
531 }

References G4RunManager::n_perviousEventsToBeStored.

◆ SetNumberOfThreads()

virtual void G4RunManager::SetNumberOfThreads ( G4int  )
inlinevirtualinherited

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 264 of file G4RunManager.hh.

264{}

◆ SetPrimaryTransformer()

void G4RunManager::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inlineinherited

Definition at line 436 of file G4RunManager.hh.

437 {
439 }
void SetPrimaryTransformer(G4PrimaryTransformer *pt)

References G4RunManager::kernel, and G4RunManagerKernel::SetPrimaryTransformer().

◆ SetPrintProgress()

void G4RunManager::SetPrintProgress ( G4int  i)
inlineinherited

Definition at line 522 of file G4RunManager.hh.

522{ printModulo = i; }

References G4RunManager::printModulo.

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStore()

void G4RunManager::SetRandomNumberStore ( G4bool  flag)
inlineinherited

Definition at line 456 of file G4RunManager.hh.

457 {
459 }

References G4RunManager::storeRandomNumberStatus.

Referenced by export_G4RunManager(), and G4RunMessenger::SetNewValue().

◆ SetRandomNumberStoreDir()

void G4RunManager::SetRandomNumberStoreDir ( const G4String dir)
inlineinherited

Definition at line 464 of file G4RunManager.hh.

465 {
466 G4String dirStr = dir;
467 if(dirStr.back() != '/')
468 dirStr += "/";
469 #ifndef WIN32
470 G4String shellCmd = "mkdir -p ";
471 #else
472 std::replace(dirStr.begin(), dirStr.end(), '/', '\\');
473 G4String shellCmd = "if not exist " + dirStr + " mkdir ";
474 #endif
475 shellCmd += dirStr;
476 randomNumberStatusDir = dirStr;
477 G4int sysret = system(shellCmd);
478 if(sysret != 0)
479 {
480 G4String errmsg = "\"" + shellCmd
481 + "\" returns non-zero value. Directory creation failed.";
482 G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0071",
483 JustWarning, errmsg);
484 G4cerr << " return value = " << sysret << G4endl;
485 }
486 }

References G4cerr, G4endl, G4Exception(), JustWarning, and G4RunManager::randomNumberStatusDir.

Referenced by export_G4RunManager(), and G4RunMessenger::SetNewValue().

◆ SetRandomNumberStorePerEvent()

void G4RunManager::SetRandomNumberStorePerEvent ( G4bool  flag)
inlineinherited

Definition at line 506 of file G4RunManager.hh.

507 {
508 rngStatusEventsFlag = flag;
509 }

References G4RunManager::rngStatusEventsFlag.

Referenced by G4RunMessenger::SetNewValue().

◆ SetRunIDCounter()

void G4RunManager::SetRunIDCounter ( G4int  i)
inlineinherited

◆ SetupDefaultRNGEngine()

void G4WorkerTaskRunManager::SetupDefaultRNGEngine ( )
private

◆ SetUserAction() [1/6]

void G4WorkerRunManager::SetUserAction ( G4UserEventAction userAction)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 691 of file G4WorkerRunManager.cc.

692{
694}
virtual void SetUserAction(G4UserRunAction *userAction)

References G4RunManager::SetUserAction().

◆ SetUserAction() [2/6]

void G4WorkerRunManager::SetUserAction ( G4UserRunAction userAction)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 671 of file G4WorkerRunManager.cc.

672{
673 G4RunManager::SetUserAction(userAction);
674 if(userAction != nullptr)
675 userAction->SetMaster(false);
676}
virtual void SetMaster(G4bool val=true)

References G4UserRunAction::SetMaster(), and G4RunManager::SetUserAction().

Referenced by G4RTWorkerInitialization::WorkerRunEnd(), and G4RTWorkerInitialization::WorkerRunStart().

◆ SetUserAction() [3/6]

void G4WorkerRunManager::SetUserAction ( G4UserStackingAction userAction)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 703 of file G4WorkerRunManager.cc.

704{
706}

References G4RunManager::SetUserAction().

◆ SetUserAction() [4/6]

void G4WorkerRunManager::SetUserAction ( G4UserSteppingAction userAction)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 715 of file G4WorkerRunManager.cc.

716{
718}

References G4RunManager::SetUserAction().

◆ SetUserAction() [5/6]

void G4WorkerRunManager::SetUserAction ( G4UserTrackingAction userAction)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 709 of file G4WorkerRunManager.cc.

710{
712}

References G4RunManager::SetUserAction().

◆ SetUserAction() [6/6]

void G4WorkerRunManager::SetUserAction ( G4VUserPrimaryGeneratorAction userAction)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 697 of file G4WorkerRunManager.cc.

698{
700}

References G4RunManager::SetUserAction().

◆ SetUserInitialization() [1/5]

void G4WorkerRunManager::SetUserInitialization ( G4UserWorkerInitialization userInit)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 627 of file G4WorkerRunManager.cc.

628{
630 "G4RunManager::SetUserInitialization(G4UserWorkerInitialization*)",
631 "Run0118", FatalException,
632 "This method should be used only with an instance of G4MTRunManager");
633}

References FatalException, and G4Exception().

◆ SetUserInitialization() [2/5]

void G4WorkerRunManager::SetUserInitialization ( G4UserWorkerThreadInitialization userInit)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 636 of file G4WorkerRunManager.cc.

638{
640 "G4RunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)",
641 "Run0119", FatalException,
642 "This method should be used only with an instance of G4MTRunManager");
643}

References FatalException, and G4Exception().

◆ SetUserInitialization() [3/5]

void G4WorkerRunManager::SetUserInitialization ( G4VUserActionInitialization userInit)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 646 of file G4WorkerRunManager.cc.

647{
649 "G4RunManager::SetUserInitialization(G4VUserActionInitialization*)",
650 "Run0120", FatalException,
651 "This method should be used only with an instance of G4MTRunManager");
652}

References FatalException, and G4Exception().

◆ SetUserInitialization() [4/5]

void G4WorkerRunManager::SetUserInitialization ( G4VUserDetectorConstruction userInit)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 655 of file G4WorkerRunManager.cc.

656{
658 "G4RunManager::SetUserInitialization(G4VUserDetectorConstruction*)",
659 "Run0121", FatalException,
660 "This method should be used only with an instance of G4MTRunManager");
661}

References FatalException, and G4Exception().

◆ SetUserInitialization() [5/5]

void G4WorkerRunManager::SetUserInitialization ( G4VUserPhysicsList userInit)
virtualinherited

Reimplemented from G4RunManager.

Definition at line 664 of file G4WorkerRunManager.cc.

665{
666 pl->InitializeWorker();
668}
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)

References G4VUserPhysicsList::InitializeWorker(), and G4RunManager::SetUserInitialization().

Referenced by G4MTRunManagerKernel::StartThread().

◆ SetVerboseLevel()

void G4RunManager::SetVerboseLevel ( G4int  vl)
inlineinherited

◆ SetWorkerThread()

void G4WorkerRunManager::SetWorkerThread ( G4WorkerThread wc)
inlineinherited

Definition at line 74 of file G4WorkerRunManager.hh.

74{ workerContext = wc; }

References G4WorkerRunManager::workerContext.

Referenced by G4MTRunManagerKernel::StartThread().

◆ StackPreviousEvent()

void G4RunManager::StackPreviousEvent ( G4Event anEvent)
protectedinherited

Definition at line 646 of file G4RunManager.cc.

647{
648 if(anEvent->ToBeKept())
649 currentRun->StoreEvent(anEvent);
650
652 {
653 if(anEvent->GetNumberOfGrips() == 0)
654 {
655 if(!(anEvent->ToBeKept()))
656 delete anEvent;
657 }
658 else
659 {
660 previousEvents->push_back(anEvent);
661 }
662 }
664}
void CleanUpUnnecessaryEvents(G4int keepNEvents)
void StoreEvent(G4Event *evt)
Definition: G4Run.cc:78

References G4RunManager::CleanUpUnnecessaryEvents(), G4RunManager::currentRun, G4Event::GetNumberOfGrips(), G4RunManager::n_perviousEventsToBeStored, G4RunManager::previousEvents, G4Run::StoreEvent(), and G4Event::ToBeKept().

Referenced by G4RunManager::TerminateOneEvent().

◆ StoreRandomNumberStatusToG4Event()

void G4RunManager::StoreRandomNumberStatusToG4Event ( G4int  vl)
inlineinherited

◆ StoreRNGStatus()

void G4WorkerTaskRunManager::StoreRNGStatus ( const G4String filenamePrefix)
overrideprotectedvirtual

Reimplemented from G4WorkerRunManager.

Definition at line 453 of file G4WorkerTaskRunManager.cc.

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

References G4WorkerThread::GetThreadId(), G4RunManager::randomNumberStatusDir, and G4WorkerRunManager::workerContext.

Referenced by GenerateEvent(), and RunInitialization().

◆ TerminateEventLoop()

void G4WorkerTaskRunManager::TerminateEventLoop ( )
overridevirtual

Reimplemented from G4WorkerRunManager.

Definition at line 418 of file G4WorkerTaskRunManager.cc.

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

References G4RunManager::fakeRun, G4cout, G4endl, G4WorkerThread::GetThreadId(), G4RunManager::numberOfEventProcessed, G4RunManager::runAborted, G4Timer::Stop(), G4RunManager::timer, G4RunManager::verboseLevel, and G4WorkerRunManager::workerContext.

Referenced by G4TaskRunManagerKernel::TerminateWorkerRunEventLoop().

◆ TerminateOneEvent()

void G4RunManager::TerminateOneEvent ( )
virtualinherited

◆ UpdateScoring()

void G4RunManager::UpdateScoring ( )
protectedinherited

Definition at line 973 of file G4RunManager.cc.

974{
976 {
979 }
980
982 if(ScM == nullptr)
983 return;
984 G4int nPar = ScM->GetNumberOfMesh();
985 if(nPar < 1)
986 return;
987
989 if(HCE == nullptr)
990 return;
991 G4int nColl = HCE->GetCapacity();
992 for(G4int i = 0; i < nColl; ++i)
993 {
994 G4VHitsCollection* HC = HCE->GetHC(i);
995 if(HC != nullptr)
996 ScM->Accumulate(HC);
997 }
998}
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:156
G4VHitsCollection * GetHC(G4int i)
void Accumulate(G4VHitsCollection *map)
virtual void Fill(G4HCofThisEvent *hce, G4int eventNumber)=0

References G4ScoringManager::Accumulate(), G4RunManager::currentEvent, G4VScoreNtupleWriter::Fill(), G4HCofThisEvent::GetCapacity(), G4Event::GetEventID(), G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), G4ScoringManager::GetNumberOfMesh(), G4ScoringManager::GetScoringManagerIfExist(), G4VScoreNtupleWriter::Instance(), and G4RunManager::isScoreNtupleWriter.

Referenced by G4RunManager::ProcessOneEvent(), G4WorkerRunManager::ProcessOneEvent(), and ProcessOneEvent().

Field Documentation

◆ currentEvent

G4Event* G4RunManager::currentEvent = nullptr
protectedinherited

◆ currentRun

G4Run* G4RunManager::currentRun = nullptr
protectedinherited

◆ currentWorld

G4VPhysicalVolume* G4RunManager::currentWorld = nullptr
protectedinherited

Definition at line 643 of file G4RunManager.hh.

◆ currEvID

G4int G4WorkerRunManager::currEvID = -1
protectedinherited

◆ DCtable

G4DCtable* G4RunManager::DCtable = nullptr
protectedinherited

◆ eventLoopOnGoing

G4bool G4WorkerRunManager::eventLoopOnGoing = false
protectedinherited

◆ eventManager

G4EventManager* G4RunManager::eventManager = nullptr
protectedinherited

◆ fakeRun

G4bool G4RunManager::fakeRun = false
protectedinherited

◆ fGeometryHasBeenDestroyed

G4bool G4RunManager::fGeometryHasBeenDestroyed = false
staticprotectedinherited

◆ fRunManager

G4ThreadLocal G4RunManager * G4RunManager::fRunManager = nullptr
staticprivateinherited

◆ geometryDirectlyUpdated

G4bool G4RunManager::geometryDirectlyUpdated = false
protectedinherited

◆ geometryInitialized

G4bool G4RunManager::geometryInitialized = false
protectedinherited

◆ geometryToBeOptimized

G4bool G4RunManager::geometryToBeOptimized = true
protectedinherited

◆ initializedAtLeastOnce

G4bool G4RunManager::initializedAtLeastOnce = false
protectedinherited

◆ isScoreNtupleWriter

G4bool G4RunManager::isScoreNtupleWriter = false
protectedinherited

◆ kernel

G4RunManagerKernel* G4RunManager::kernel = nullptr
protectedinherited

◆ luxury

G4int G4WorkerRunManager::luxury = -1
protectedinherited

◆ masterRunProfiler

std::unique_ptr<ProfilerConfig> G4RunManager::masterRunProfiler
privateinherited

◆ msgText

G4String G4RunManager::msgText = " "
protectedinherited

◆ n_perviousEventsToBeStored

G4int G4RunManager::n_perviousEventsToBeStored = 0
protectedinherited

◆ n_select_msg

G4int G4RunManager::n_select_msg = -1
protectedinherited

◆ nevModulo

G4int G4WorkerRunManager::nevModulo = -1
protectedinherited

◆ nParallelWorlds

G4int G4RunManager::nParallelWorlds = 0
protectedinherited

◆ numberOfEventProcessed

G4int G4RunManager::numberOfEventProcessed = 0
protectedinherited

◆ numberOfEventToBeProcessed

G4int G4RunManager::numberOfEventToBeProcessed = 0
protectedinherited

◆ physicsInitialized

G4bool G4RunManager::physicsInitialized = false
protectedinherited

◆ physicsList

G4VUserPhysicsList* G4RunManager::physicsList = nullptr
protectedinherited

◆ previousEvents

std::list<G4Event*>* G4RunManager::previousEvents = nullptr
protectedinherited

◆ printModulo

G4int G4RunManager::printModulo = -1
protectedinherited

◆ processedCommandStack

G4StrVector G4WorkerTaskRunManager::processedCommandStack
private

Definition at line 87 of file G4WorkerTaskRunManager.hh.

Referenced by GetCommandStack(), and ProcessUI().

◆ randomNumberStatusDir

G4String G4RunManager::randomNumberStatusDir = "./"
protectedinherited

◆ randomNumberStatusForThisEvent

G4String G4RunManager::randomNumberStatusForThisEvent = ""
protectedinherited

◆ randomNumberStatusForThisRun

G4String G4RunManager::randomNumberStatusForThisRun = ""
protectedinherited

◆ readStatusFromFile

G4bool G4WorkerRunManager::readStatusFromFile = false
protectedinherited

◆ rngStatusEventsFlag

G4bool G4RunManager::rngStatusEventsFlag = false
protectedinherited

◆ runAborted

G4bool G4RunManager::runAborted = false
protectedinherited

◆ runIDCounter

G4int G4RunManager::runIDCounter = 0
protectedinherited

◆ runIsSeeded

G4bool G4WorkerRunManager::runIsSeeded = false
protectedinherited

◆ runManagerType

RMType G4RunManager::runManagerType
protectedinherited

◆ runMessenger

G4RunMessenger* G4RunManager::runMessenger = nullptr
privateinherited

Definition at line 666 of file G4RunManager.hh.

Referenced by G4RunManager::G4RunManager(), and G4RunManager::~G4RunManager().

◆ seedsQueue

G4SeedsQueue G4WorkerRunManager::seedsQueue
protectedinherited

◆ selectMacro

G4String G4RunManager::selectMacro = ""
protectedinherited

◆ storeRandomNumberStatus

G4bool G4RunManager::storeRandomNumberStatus = false
protectedinherited

◆ storeRandomNumberStatusToG4Event

G4int G4RunManager::storeRandomNumberStatusToG4Event = 0
protectedinherited

◆ timer

G4Timer* G4RunManager::timer = nullptr
protectedinherited

◆ userActionInitialization

G4VUserActionInitialization* G4RunManager::userActionInitialization = nullptr
protectedinherited

◆ userDetector

G4VUserDetectorConstruction* G4RunManager::userDetector = nullptr
protectedinherited

◆ userEventAction

G4UserEventAction* G4RunManager::userEventAction = nullptr
protectedinherited

◆ userPrimaryGeneratorAction

G4VUserPrimaryGeneratorAction* G4RunManager::userPrimaryGeneratorAction = nullptr
protectedinherited

◆ userRunAction

G4UserRunAction* G4RunManager::userRunAction = nullptr
protectedinherited

◆ userStackingAction

G4UserStackingAction* G4RunManager::userStackingAction = nullptr
protectedinherited

◆ userSteppingAction

G4UserSteppingAction* G4RunManager::userSteppingAction = nullptr
protectedinherited

◆ userTrackingAction

G4UserTrackingAction* G4RunManager::userTrackingAction = nullptr
protectedinherited

◆ userWorkerInitialization

G4UserWorkerInitialization* G4RunManager::userWorkerInitialization = nullptr
protectedinherited

◆ userWorkerThreadInitialization

G4UserWorkerThreadInitialization* G4RunManager::userWorkerThreadInitialization = nullptr
protectedinherited

◆ verboseLevel

G4int G4RunManager::verboseLevel = 0
protectedinherited

◆ workerContext

G4WorkerThread* G4WorkerRunManager::workerContext = nullptr
protectedinherited

◆ workerRunProfiler

std::unique_ptr<ProfilerConfig> G4WorkerTaskRunManager::workerRunProfiler
private

Definition at line 90 of file G4WorkerTaskRunManager.hh.

Referenced by RunInitialization(), and RunTermination().


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