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

#include <G4RunManager.hh>

+ Inheritance diagram for G4RunManager:

Public Types

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

Public Member Functions

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

Static Public Member Functions

static G4RunManagerGetRunManager ()
 
static G4bool IfGeometryHasBeenDestroyed ()
 

Protected Member Functions

 G4RunManager (RMType rmType)
 
void CleanUpPreviousEvents ()
 
void CleanUpUnnecessaryEvents (G4int keepNEvents)
 
void StackPreviousEvent (G4Event *anEvent)
 
virtual void StoreRNGStatus (const G4String &filenamePrefix)
 
void UpdateScoring ()
 
virtual void DeleteUserInitializations ()
 

Protected Attributes

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

Static Protected Attributes

static G4RUN_DLL G4bool fGeometryHasBeenDestroyed = false
 

Friends

class G4RunManagerFactory
 

Detailed Description

Definition at line 138 of file G4RunManager.hh.

Member Typedef Documentation

◆ ProfilerConfig

Member Enumeration Documentation

◆ RMType

Enumerator
sequentialRM 
masterRM 
workerRM 

Definition at line 518 of file G4RunManager.hh.

Constructor & Destructor Documentation

◆ G4RunManager() [1/3]

G4RunManager::G4RunManager ( )

Definition at line 112 of file G4RunManager.cc.

113{
114 if (fRunManager != nullptr) {
115 G4Exception("G4RunManager::G4RunManager()", "Run0031", FatalException,
116 "G4RunManager constructed twice.");
117 }
118 fRunManager = this;
119
122
123 timer = new G4Timer();
124 runMessenger = new G4RunMessenger(this);
125 previousEvents = new std::list<G4Event*>;
128 std::ostringstream oss;
129 G4Random::saveFullState(oss);
133}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static G4ParticleTable * GetParticleTable()
G4UImessenger * CreateMessenger()
static G4ProcessTable * GetProcessTable()
G4EventManager * GetEventManager() const
std::list< G4Event * > * previousEvents
G4Timer * timer
G4RunManagerKernel * kernel
G4String randomNumberStatusForThisRun
G4String randomNumberStatusForThisEvent
RMType runManagerType
G4EventManager * eventManager

◆ ~G4RunManager()

G4RunManager::~G4RunManager ( )
virtual

Definition at line 187 of file G4RunManager.cc.

188{
189 // finalise profiler before shutting down the threads
192 // set the application state to the quite state
193 if (pStateManager->GetCurrentState() != G4State_Quit) {
194 if (verboseLevel > 1) G4cout << "G4 kernel has come to Quit state." << G4endl;
195 pStateManager->SetNewState(G4State_Quit);
196 }
197
199 delete currentRun;
200 delete timer;
201 delete runMessenger;
202 delete previousEvents;
203
204 // The following will work for all RunManager types
205 // if derived class does the correct thing in the derived
206 // destructor that is: set to zero pointers of
207 // user initialization objects for which have no
208 // ownership
210 delete userRunAction;
211 userRunAction = nullptr;
212 if (verboseLevel > 1) G4cout << "UserRunAction deleted." << G4endl;
213
216 if (verboseLevel > 1) G4cout << "UserPrimaryGenerator deleted." << G4endl;
217
218 if (verboseLevel > 1) G4cout << "RunManager is deleting RunManagerKernel." << G4endl;
219
220 delete kernel;
221
222 fRunManager = nullptr;
223
224 if (verboseLevel > 1) G4cout << "RunManager is deleted." << G4endl;
225}
@ G4State_Quit
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static void Finalize()
void CleanUpPreviousEvents()
virtual void DeleteUserInitializations()
G4Run * currentRun
G4UserRunAction * userRunAction
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)

◆ G4RunManager() [2/3]

G4RunManager::G4RunManager ( const G4RunManager & )
delete

◆ G4RunManager() [3/3]

G4RunManager::G4RunManager ( RMType rmType)
protected

Definition at line 136 of file G4RunManager.cc.

137{
138 // This version of the constructor should never be called in sequential mode!
139#ifndef G4MULTITHREADED
141 msg << "Geant4 code is compiled without multi-threading support "
142 "(-DG4MULTITHREADED is set to off).";
143 msg << " This type of RunManager can only be used in mult-threaded "
144 "applications.";
145 G4Exception("G4RunManager::G4RunManager(G4bool)", "Run0107", FatalException, msg);
146#endif
147
148 if (fRunManager != nullptr) {
149 G4Exception("G4RunManager::G4RunManager()", "Run0031", FatalException,
150 "G4RunManager constructed twice.");
151 return;
152 }
153 fRunManager = this;
154
155 switch (rmType) {
156 case masterRM:
158 break;
159 case workerRM:
161 break;
162 default:
164 msgx << "This type of RunManager can only be used in multi-threaded "
165 "applications.";
166 G4Exception("G4RunManager::G4RunManager(G4bool)", "Run0108", FatalException, msgx);
167 return;
168 }
169 runManagerType = rmType;
170
172
173 timer = new G4Timer();
174 runMessenger = new G4RunMessenger(this);
175 previousEvents = new std::list<G4Event*>;
179 std::ostringstream oss;
180 G4Random::saveFullState(oss);
184}
std::ostringstream G4ExceptionDescription
G4String randomNumberStatusDir
virtual void ConfigureProfilers(const std::vector< std::string > &args={})

Member Function Documentation

◆ AbortEvent()

void G4RunManager::AbortEvent ( )
virtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 666 of file G4RunManager.cc.

667{
668 // This method is valid only for EventProc state
670 if (currentState == G4State_EventProc) {
673 }
674 else {
675 G4cerr << "Event is not in progress. AbortEevnt() ignored." << G4endl;
676 }
677}
G4ApplicationState
@ G4State_EventProc
G4GLOB_DLL std::ostream G4cerr
void SetEventAborted()
Definition G4Event.hh:93
G4Event * currentEvent

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

◆ AbortRun()

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

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 649 of file G4RunManager.cc.

650{
651 // This method is valid only for GeomClosed or EventProc state
653 if (currentState == G4State_GeomClosed || currentState == G4State_EventProc) {
654 runAborted = true;
655 if (currentState == G4State_EventProc && !softAbort) {
658 }
659 }
660 else {
661 G4cerr << "Run is not in progress. AbortRun() ignored." << G4endl;
662 }
663}
@ G4State_GeomClosed

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

◆ AnalyzeEvent()

void G4RunManager::AnalyzeEvent ( G4Event * anEvent)
virtual

Definition at line 479 of file G4RunManager.cc.

480{
482 if (fPersM != nullptr) fPersM->Store(anEvent);
483 currentRun->RecordEvent(anEvent);
484}
virtual void RecordEvent(const G4Event *)
Definition G4Run.cc:59
static G4VPersistencyManager * GetPersistencyManager()
virtual G4bool Store(const G4Event *anEvent)=0

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

◆ BeamOn()

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

Definition at line 252 of file G4RunManager.cc.

253{
254 fakeRun = n_event <= 0;
256 if (cond) {
261 DoEventLoop(n_event, macroFile, n_select);
263 }
264 fakeRun = false;
265}
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()

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

◆ CleanUpPreviousEvents()

void G4RunManager::CleanUpPreviousEvents ( )
protected

Definition at line 512 of file G4RunManager.cc.

513{
514 // Delete all events carried over from previous run.
515 // This method is invoked at the beginning of the next run
516 // or from the destructor of G4RunManager at the very end of
517 // the program.
518 // N.B. If ToBeKept() is true, the pointer of this event is
519 // kept in G4Run of the previous run, and deleted along with
520 // the deletion of G4Run.
521
522 auto evItr = previousEvents->cbegin();
523 while (evItr != previousEvents->cend()) {
524 G4Event* evt = *evItr;
525 if (evt != nullptr && !(evt->ToBeKept())) delete evt;
526 evItr = previousEvents->erase(evItr);
527 }
528}
G4bool ToBeKept() const
Definition G4Event.hh:107

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

◆ CleanUpUnnecessaryEvents()

void G4RunManager::CleanUpUnnecessaryEvents ( G4int keepNEvents)
protected

Definition at line 531 of file G4RunManager.cc.

532{
533 // Delete events that are no longer necessary for post
534 // processing such as visualization.
535 // N.B. If ToBeKept() is true, the pointer of this event is
536 // kept in G4Run of the previous run, and deleted along with
537 // the deletion of G4Run.
538
539 auto evItr = previousEvents->cbegin();
540 while (evItr != previousEvents->cend()) {
541 if (G4int(previousEvents->size()) <= keepNEvents) return;
542
543 G4Event* evt = *evItr;
544 if (evt != nullptr) {
545 if (evt->GetNumberOfGrips() == 0) {
546 if (!(evt->ToBeKept())) delete evt;
547 evItr = previousEvents->erase(evItr);
548 }
549 else {
550 ++evItr;
551 }
552 }
553 else {
554 evItr = previousEvents->erase(evItr);
555 }
556 }
557}
int G4int
Definition G4Types.hh:85
G4int GetNumberOfGrips() const
Definition G4Event.hh:120

Referenced by RunTermination(), and StackPreviousEvent().

◆ ConfigureProfilers() [1/2]

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

Definition at line 1018 of file G4RunManager.cc.

1019{
1020#ifdef GEANT4_USE_TIMEMORY
1021 // parse command line if arguments were passed
1023#else
1024 G4ConsumeParameters(args);
1025#endif
1026}
static void Configure(const std::vector< std::string > &args)
Definition G4Profiler.cc:91
void G4ConsumeParameters(_Args &&...)
Definition templates.hh:177

Referenced by ConfigureProfilers(), and G4RunManager().

◆ ConfigureProfilers() [2/2]

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

Definition at line 1009 of file G4RunManager.cc.

1010{
1011 std::vector<std::string> _args;
1012 for (G4int i = 0; i < argc; ++i)
1013 _args.emplace_back(argv[i]);
1014 ConfigureProfilers(_args);
1015}

◆ ConfirmBeamOnCondition()

G4bool G4RunManager::ConfirmBeamOnCondition ( )
virtual

Definition at line 268 of file G4RunManager.cc.

269{
271
272 G4ApplicationState currentState = stateManager->GetCurrentState();
273 if (currentState != G4State_PreInit && currentState != G4State_Idle) {
274 G4cerr << "Illegal application state - BeamOn() ignored." << G4endl;
275 return false;
276 }
277
279 G4cerr << " Geant4 kernel should be initialized" << G4endl;
280 G4cerr << "before the first BeamOn(). - BeamOn ignored." << G4endl;
281 return false;
282 }
283
285 if (verboseLevel > 0) {
286 G4cout << "Start re-initialization because " << G4endl;
287 if (!geometryInitialized) G4cout << " Geometry" << G4endl;
288 if (!physicsInitialized) G4cout << " Physics processes" << G4endl;
289 G4cout << "has been modified since last Run." << G4endl;
290 }
291 Initialize();
292 }
293 return true;
294}
@ G4State_Idle
@ G4State_PreInit
G4bool geometryInitialized
virtual void Initialize()
G4bool physicsInitialized
G4bool initializedAtLeastOnce

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

◆ ConstructScoringWorlds()

void G4RunManager::ConstructScoringWorlds ( )
virtual

Reimplemented in G4MTRunManager, G4TaskRunManager, and G4WorkerRunManager.

Definition at line 769 of file G4RunManager.cc.

770{
771 using MeshShape = G4VScoringMesh::MeshShape;
772
774 if (ScM == nullptr) return;
775
776 auto nPar = (G4int)ScM->GetNumberOfMesh();
777 if (nPar < 1) return;
778
780 for (G4int iw = 0; iw < nPar; ++iw) {
781 G4VScoringMesh* mesh = ScM->GetMesh(iw);
783 G4VPhysicalVolume* pWorld = nullptr;
784 if (mesh->GetShape() != MeshShape::realWorldLogVol) {
785 pWorld =
787 if (pWorld == nullptr) {
789 ScM->GetWorldName(iw));
790 pWorld->SetName(ScM->GetWorldName(iw));
791
792 G4ParallelWorldProcess* theParallelWorldProcess = mesh->GetParallelWorldProcess();
793 if (theParallelWorldProcess != nullptr) {
794 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
795 }
796 else {
797 theParallelWorldProcess = new G4ParallelWorldProcess(ScM->GetWorldName(iw));
798 mesh->SetParallelWorldProcess(theParallelWorldProcess);
799 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
800
801 theParticleIterator->reset();
802 while ((*theParticleIterator)()) {
803 G4ParticleDefinition* particle = theParticleIterator->value();
804 G4ProcessManager* pmanager = particle->GetProcessManager();
805 if (pmanager != nullptr) {
806 pmanager->AddProcess(theParallelWorldProcess);
807 if (theParallelWorldProcess->IsAtRestRequired(particle)) {
808 pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest, 9900);
809 }
810 pmanager->SetProcessOrderingToSecond(theParallelWorldProcess, idxAlongStep);
811 pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep, 9900);
812 }
813 }
814 }
815 theParallelWorldProcess->SetLayeredMaterialFlag(mesh->LayeredMassFlg());
816 }
817 }
818 mesh->Construct(pWorld);
819 }
821}
@ idxPostStep
@ idxAtRest
@ idxAlongStep
#define theParticleIterator
void SetLayeredMaterialFlag(G4bool flg=true)
void SetParallelWorld(G4String parallelWorldName)
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4ProcessManager * GetProcessManager() const
G4PTblDicIterator * GetIterator() const
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)
static G4RUN_DLL G4bool fGeometryHasBeenDestroyed
void GeometryHasBeenModified(G4bool prop=true)
G4VScoringMesh * GetMesh(G4int i) const
size_t GetNumberOfMesh() const
G4String GetWorldName(G4int i) const
static G4ScoringManager * GetScoringManagerIfExist()
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
static G4TransportationManager * GetTransportationManager()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetName(const G4String &pName)
MeshShape GetShape() const
void GeometryHasBeenDestroyed()
G4ParallelWorldProcess * GetParallelWorldProcess() const
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
virtual void Construct(G4VPhysicalVolume *fWorldPhys)
G4bool LayeredMassFlg()

Referenced by BeamOn(), G4MTRunManager::ConstructScoringWorlds(), G4TaskRunManager::ConstructScoringWorlds(), and G4RunMessenger::SetNewValue().

◆ CutOffHasBeenModified()

void G4RunManager::CutOffHasBeenModified ( )
inline

Definition at line 300 of file G4RunManager.hh.

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

◆ DefineWorldVolume()

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

Definition at line 680 of file G4RunManager.cc.

681{
682 kernel->DefineWorldVolume(worldVol, topologyIsChanged);
683}
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)

Referenced by G4GDMLMessenger::SetNewValue().

◆ DeleteUserInitializations()

void G4RunManager::DeleteUserInitializations ( )
protectedvirtual

Definition at line 228 of file G4RunManager.cc.

229{
230 delete userDetector;
231 userDetector = nullptr;
232 if (verboseLevel > 1) G4cout << "UserDetectorConstruction deleted." << G4endl;
233
234 delete physicsList;
235 physicsList = nullptr;
236 if (verboseLevel > 1) G4cout << "UserPhysicsList deleted." << G4endl;
237
239 userActionInitialization = nullptr;
240 if (verboseLevel > 1) G4cout << "UserActionInitialization deleted." << G4endl;
241
243 userWorkerInitialization = nullptr;
244 if (verboseLevel > 1) G4cout << "UserWorkerInitialization deleted." << G4endl;
245
248 if (verboseLevel > 1) G4cout << "UserWorkerThreadInitialization deleted." << G4endl;
249}
G4UserWorkerInitialization * userWorkerInitialization
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
G4VUserActionInitialization * userActionInitialization
G4VUserDetectorConstruction * userDetector
G4VUserPhysicsList * physicsList

Referenced by ~G4RunManager().

◆ DoEventLoop()

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

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 364 of file G4RunManager.cc.

365{
366 InitializeEventLoop(n_event, macroFile, n_select);
367
368 // Event loop
369 for (G4int i_event = 0; i_event < n_event; ++i_event) {
370 ProcessOneEvent(i_event);
372 if (runAborted) break;
373 }
374
375 // For G4MTRunManager, TerminateEventLoop() is invoked after all threads are
376 // finished.
378}
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
virtual void TerminateEventLoop()
virtual void ProcessOneEvent(G4int i_event)
virtual void TerminateOneEvent()

Referenced by BeamOn().

◆ DumpRegion() [1/2]

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

Definition at line 757 of file G4RunManager.cc.

758{
759 kernel->DumpRegion(rname);
760}
void DumpRegion(const G4String &rname) const

Referenced by G4RunMessenger::SetNewValue().

◆ DumpRegion() [2/2]

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

Definition at line 763 of file G4RunManager.cc.

764{
765 kernel->DumpRegion(region);
766}

◆ GenerateEvent()

G4Event * G4RunManager::GenerateEvent ( G4int i_event)
virtual

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 437 of file G4RunManager.cc.

438{
439 if (userPrimaryGeneratorAction == nullptr) {
440 G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
441 "G4VUserPrimaryGeneratorAction is not defined!");
442 return nullptr;
443 }
444
445 auto anEvent = new G4Event(i_event);
446
448 std::ostringstream oss;
449 G4Random::saveFullState(oss);
451 anEvent->SetRandomNumberStatus(randomNumberStatusForThisEvent);
452 }
453
455 G4String fileN = "currentEvent";
457 std::ostringstream os;
458 os << "run" << currentRun->GetRunID() << "evt" << anEvent->GetEventID();
459 fileN = os.str();
460 }
461 StoreRNGStatus(fileN);
462 }
463
464 if (printModulo > 0 && anEvent->GetEventID() % printModulo == 0) {
465 G4cout << "--> Event " << anEvent->GetEventID() << " starts." << G4endl;
466 }
468 return anEvent;
469}
G4int storeRandomNumberStatusToG4Event
G4bool rngStatusEventsFlag
G4bool storeRandomNumberStatus
virtual void StoreRNGStatus(const G4String &filenamePrefix)
G4int GetRunID() const
Definition G4Run.hh:86
virtual void GeneratePrimaries(G4Event *anEvent)=0

Referenced by ProcessOneEvent().

◆ GeometryDirectlyUpdated()

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

Definition at line 326 of file G4RunManager.hh.

G4bool geometryDirectlyUpdated

Referenced by G4GDMLMessenger::SetNewValue().

◆ GeometryHasBeenModified()

void G4RunManager::GeometryHasBeenModified ( G4bool prop = true)

Definition at line 952 of file G4RunManager.cc.

953{
954 if (prop) {
955 G4UImanager::GetUIpointer()->ApplyCommand("/run/geometryModified");
956 }
957 else {
959 }
960}
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()

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

◆ GetCurrentEvent()

const G4Event * G4RunManager::GetCurrentEvent ( ) const
inline

◆ GetCurrentRun()

◆ GetFlagRandomNumberStatusToG4Event()

G4int G4RunManager::GetFlagRandomNumberStatusToG4Event ( ) const
inline

Definition at line 424 of file G4RunManager.hh.

425 {
427 }

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetGeometryToBeOptimized()

G4bool G4RunManager::GetGeometryToBeOptimized ( )
inline

Definition at line 324 of file G4RunManager.hh.

324{ return geometryToBeOptimized; }
G4bool geometryToBeOptimized

◆ GetNonConstCurrentRun()

G4Run * G4RunManager::GetNonConstCurrentRun ( ) const
inline

Definition at line 484 of file G4RunManager.hh.

484{ return currentRun; }

◆ GetNonConstUserActionInitialization()

G4VUserActionInitialization * G4RunManager::GetNonConstUserActionInitialization ( ) const
inline

◆ GetNumberOfEventsToBeProcessed()

G4int G4RunManager::GetNumberOfEventsToBeProcessed ( ) const
inline

◆ GetNumberOfParallelWorld()

G4int G4RunManager::GetNumberOfParallelWorld ( ) const
inline

Definition at line 511 of file G4RunManager.hh.

511{ return nParallelWorlds; }
G4int nParallelWorlds

◆ GetNumberOfSelectEvents()

G4int G4RunManager::GetNumberOfSelectEvents ( ) const
inline

Definition at line 514 of file G4RunManager.hh.

514{ return n_select_msg; }

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

◆ GetNumberOfThreads()

virtual G4int G4RunManager::GetNumberOfThreads ( ) const
inlinevirtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 265 of file G4RunManager.hh.

265{ return 1; }

◆ GetPreviousEvent()

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

Definition at line 495 of file G4RunManager.hh.

496 {
497 if (i >= 1 && i <= n_perviousEventsToBeStored) {
498 auto itr = previousEvents->cbegin();
499 for (G4int j = 1; j < i; ++j) {
500 ++itr;
501 }
502 return *itr;
503 }
504 return nullptr;
505 }
G4int n_perviousEventsToBeStored

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

◆ GetPrintProgress()

G4int G4RunManager::GetPrintProgress ( )
inline

Definition at line 472 of file G4RunManager.hh.

472{ return printModulo; }

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

◆ GetRandomNumberStatusForThisEvent()

const G4String & G4RunManager::GetRandomNumberStatusForThisEvent ( ) const
inline

Definition at line 455 of file G4RunManager.hh.

456 {
458 G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0072", JustWarning,
459 "Random number status is not available for this event.");
460 }
462 }
@ JustWarning

◆ GetRandomNumberStatusForThisRun()

const G4String & G4RunManager::GetRandomNumberStatusForThisRun ( ) const
inline

Definition at line 451 of file G4RunManager.hh.

452 {
454 }

◆ GetRandomNumberStore()

G4bool G4RunManager::GetRandomNumberStore ( ) const
inline

Definition at line 430 of file G4RunManager.hh.

430{ return storeRandomNumberStatus; }

◆ GetRandomNumberStoreDir()

const G4String & G4RunManager::GetRandomNumberStoreDir ( ) const
inline

Definition at line 450 of file G4RunManager.hh.

450{ return randomNumberStatusDir; }

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetRandomNumberStorePerEvent()

G4bool G4RunManager::GetRandomNumberStorePerEvent ( ) const
inline

Definition at line 464 of file G4RunManager.hh.

464{ return rngStatusEventsFlag; }

◆ GetRunManager()

◆ GetRunManagerType()

RMType G4RunManager::GetRunManagerType ( ) const
inline

◆ GetSelectMacro()

const G4String & G4RunManager::GetSelectMacro ( ) const
inline

Definition at line 515 of file G4RunManager.hh.

515{ return selectMacro; }
G4String selectMacro

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

◆ GetUserActionInitialization()

const G4VUserActionInitialization * G4RunManager::GetUserActionInitialization ( ) const
inline

◆ GetUserDetectorConstruction()

const G4VUserDetectorConstruction * G4RunManager::GetUserDetectorConstruction ( ) const
inline

Definition at line 367 of file G4RunManager.hh.

368 {
369 return userDetector;
370 }

Referenced by G4TaskRunManagerKernel::InitializeWorker(), and G4MTRunManagerKernel::StartThread().

◆ GetUserEventAction()

const G4UserEventAction * G4RunManager::GetUserEventAction ( ) const
inline

Definition at line 393 of file G4RunManager.hh.

393{ return userEventAction; }
G4UserEventAction * userEventAction

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserPhysicsList()

const G4VUserPhysicsList * G4RunManager::GetUserPhysicsList ( ) const
inline

◆ GetUserPrimaryGeneratorAction()

const G4VUserPrimaryGeneratorAction * G4RunManager::GetUserPrimaryGeneratorAction ( ) const
inline

Definition at line 389 of file G4RunManager.hh.

390 {
392 }

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserRunAction()

const G4UserRunAction * G4RunManager::GetUserRunAction ( ) const
inline

◆ GetUserStackingAction()

const G4UserStackingAction * G4RunManager::GetUserStackingAction ( ) const
inline

Definition at line 394 of file G4RunManager.hh.

394{ return userStackingAction; }
G4UserStackingAction * userStackingAction

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserSteppingAction()

const G4UserSteppingAction * G4RunManager::GetUserSteppingAction ( ) const
inline

Definition at line 396 of file G4RunManager.hh.

396{ return userSteppingAction; }
G4UserSteppingAction * userSteppingAction

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserTrackingAction()

const G4UserTrackingAction * G4RunManager::GetUserTrackingAction ( ) const
inline

Definition at line 395 of file G4RunManager.hh.

395{ return userTrackingAction; }
G4UserTrackingAction * userTrackingAction

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserWorkerInitialization()

◆ GetUserWorkerThreadInitialization()

const G4UserWorkerThreadInitialization * G4RunManager::GetUserWorkerThreadInitialization ( ) const
inline

◆ GetVerboseLevel()

G4int G4RunManager::GetVerboseLevel ( ) const
inline

Definition at line 471 of file G4RunManager.hh.

471{ return verboseLevel; }

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

◆ GetVersionString()

const G4String & G4RunManager::GetVersionString ( ) const
inline

Definition at line 407 of file G4RunManager.hh.

407{ return kernel->GetVersionString(); }
const G4String & GetVersionString() const

◆ IfGeometryHasBeenDestroyed()

G4bool G4RunManager::IfGeometryHasBeenDestroyed ( )
static

Definition at line 100 of file G4RunManager.cc.

101{
103}

Referenced by G4WorkerTaskRunManager::RunInitialization().

◆ Initialize()

void G4RunManager::Initialize ( )
virtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 576 of file G4RunManager.cc.

577{
579 G4ApplicationState currentState = stateManager->GetCurrentState();
580 if (currentState != G4State_PreInit && currentState != G4State_Idle) {
581 G4cerr << "Illegal application state - "
582 << "G4RunManager::Initialize() ignored." << G4endl;
583 return;
584 }
585
586 stateManager->SetNewState(G4State_Init);
590 if (stateManager->GetCurrentState() != G4State_Idle) {
591 stateManager->SetNewState(G4State_Idle);
592 }
593}
@ G4State_Init
virtual void InitializePhysics()
virtual void InitializeGeometry()

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

◆ InitializeEventLoop()

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

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 381 of file G4RunManager.cc.

382{
383 if (verboseLevel > 0) {
384 timer->Start();
385 }
386
387 n_select_msg = n_select;
388 if (macroFile != nullptr) {
389 if (n_select_msg < 0) n_select_msg = n_event;
390 msgText = "/control/execute ";
391 msgText += macroFile;
392 selectMacro = macroFile;
393 }
394 else {
395 n_select_msg = -1;
396 selectMacro = "";
397 }
398}
G4String msgText
void Start()

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

◆ InitializeGeometry()

void G4RunManager::InitializeGeometry ( )
virtual

Reimplemented in G4WorkerRunManager.

Definition at line 596 of file G4RunManager.cc.

597{
598 if (userDetector == nullptr) {
599 G4Exception("G4RunManager::InitializeGeometry", "Run0033", FatalException,
600 "G4VUserDetectorConstruction is not defined!");
601 return;
602 }
603
604 if (verboseLevel > 1) G4cout << "userDetector->Construct() start." << G4endl;
605
607 G4ApplicationState currentState = stateManager->GetCurrentState();
608 if (currentState == G4State_PreInit || currentState == G4State_Idle) {
609 stateManager->SetNewState(G4State_Init);
610 }
617 }
618 // Notify the VisManager as well
621 if (pVVisManager != nullptr) pVVisManager->GeometryHasChanged();
622 }
623
625 geometryInitialized = true;
626 stateManager->SetNewState(currentState);
627}
void SetNumberOfParallelWorld(G4int i)
virtual G4VPhysicalVolume * Construct()=0
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0
G4bool IsMasterThread()

Referenced by Initialize().

◆ InitializePhysics()

void G4RunManager::InitializePhysics ( )
virtual

Definition at line 630 of file G4RunManager.cc.

631{
633 G4ApplicationState currentState = stateManager->GetCurrentState();
634 if (currentState == G4State_PreInit || currentState == G4State_Idle) {
635 stateManager->SetNewState(G4State_Init);
636 }
637 if (physicsList != nullptr) {
639 }
640 else {
641 G4Exception("G4RunManager::InitializePhysics()", "Run0034", FatalException,
642 "G4VUserPhysicsList is not defined!");
643 }
644 physicsInitialized = true;
645 stateManager->SetNewState(currentState);
646}

Referenced by Initialize().

◆ operator=()

G4RunManager & G4RunManager::operator= ( const G4RunManager & )
delete

◆ PhysicsHasBeenModified()

void G4RunManager::PhysicsHasBeenModified ( )
inline

Definition at line 298 of file G4RunManager.hh.

Referenced by G4RunMessenger::SetNewValue().

◆ ProcessOneEvent()

void G4RunManager::ProcessOneEvent ( G4int i_event)
virtual

Reimplemented in G4MTRunManager, G4TaskRunManager, G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 401 of file G4RunManager.cc.

402{
403 currentEvent = GenerateEvent(i_event);
408}
void ProcessOneEvent(G4Event *anEvent)
virtual G4Event * GenerateEvent(G4int i_event)
virtual void AnalyzeEvent(G4Event *anEvent)
void UpdateScoring()

Referenced by DoEventLoop().

◆ ReinitializeGeometry()

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

Definition at line 963 of file G4RunManager.cc.

964{
965 if (destroyFirst && G4Threading::IsMasterThread()) {
966 if (verboseLevel > 0) {
967 G4cout << "#### Assemblies, Volumes and Solids Stores are wiped out." << G4endl;
968 }
974
975 // remove all logical volume pointers from regions
976 // exception: world logical volume pointer must be kept
978 for (const auto& rItr : *regionStore) {
979 if (rItr->GetName() == "DefaultRegionForTheWorld") continue;
980 auto lvItr = rItr->GetRootLogicalVolumeIterator();
981 for (std::size_t iRLV = 0; iRLV < rItr->GetNumberOfRootVolumes(); ++iRLV) {
982 rItr->RemoveRootLogicalVolume(*lvItr, false);
983 ++lvItr;
984 }
985 if (verboseLevel > 0) {
986 G4cout << "#### Region <" << rItr->GetName() << "> is cleared." << G4endl;
987 }
988 }
989
990 // clear transportation manager
993 }
994 if (prop) {
995 G4UImanager::GetUIpointer()->ApplyCommand("/run/reinitializeGeometry");
996 }
997 else {
999 geometryInitialized = false;
1000 // Notify the VisManager as well
1003 if (pVVisManager != nullptr) pVVisManager->GeometryHasChanged();
1004 }
1005 }
1006}
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()
static G4SolidStore * GetInstance()

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

◆ ReOptimize()

void G4RunManager::ReOptimize ( G4LogicalVolume * pLog)

Definition at line 853 of file G4RunManager.cc.

854{
855 G4Timer localtimer;
856 if (verboseLevel > 1) {
857 localtimer.Start();
858 }
859 G4SmartVoxelHeader* header = pLog->GetVoxelHeader();
860 delete header;
861 header = new G4SmartVoxelHeader(pLog);
862 pLog->SetVoxelHeader(header);
863 if (verboseLevel > 1) {
864 localtimer.Stop();
865 G4SmartVoxelStat stat(pLog, header, localtimer.GetSystemElapsed(), localtimer.GetUserElapsed());
866 G4cout << G4endl << "Voxelisation of logical volume <" << pLog->GetName() << ">" << G4endl;
867 G4cout << " heads : " << stat.GetNumberHeads() << " - nodes : " << stat.GetNumberNodes()
868 << " - pointers : " << stat.GetNumberPointers() << G4endl;
869 G4cout << " Memory used : " << (stat.GetMemoryUse() + 512) / 1024
870 << "k - total time : " << stat.GetTotalTime() << " - system time : " << stat.GetSysTime()
871 << G4endl;
872 }
873}
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
const G4String & GetName() const
G4SmartVoxelHeader * GetVoxelHeader() const
void Stop()
G4double GetSystemElapsed() const
Definition G4Timer.cc:124
G4double GetUserElapsed() const
Definition G4Timer.cc:135

Referenced by ReOptimizeMotherOf().

◆ ReOptimizeMotherOf()

void G4RunManager::ReOptimizeMotherOf ( G4VPhysicalVolume * pPhys)

Definition at line 846 of file G4RunManager.cc.

847{
848 G4LogicalVolume* pMotherL = pPhys->GetMotherLogical();
849 if (pMotherL != nullptr) ReOptimize(pMotherL);
850}
void ReOptimize(G4LogicalVolume *)
G4LogicalVolume * GetMotherLogical() const

◆ RestoreRandomNumberStatus()

void G4RunManager::RestoreRandomNumberStatus ( const G4String & fileN)
virtual

Definition at line 740 of file G4RunManager.cc.

741{
742 G4String fileNameWithDirectory;
743 if (fileN.find('/') == std::string::npos) {
744 fileNameWithDirectory = randomNumberStatusDir + fileN;
745 }
746 else {
747 fileNameWithDirectory = fileN;
748 }
749
750 G4Random::restoreEngineStatus(fileNameWithDirectory);
751 if (verboseLevel > 0)
752 G4cout << "RandomNumberEngineStatus restored from file: " << fileNameWithDirectory << G4endl;
753 G4Random::showEngineStatus();
754}

Referenced by G4RunMessenger::SetNewValue().

◆ RestoreRndmEachEvent()

virtual void G4RunManager::RestoreRndmEachEvent ( G4bool )
inlinevirtual

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 338 of file G4RunManager.hh.

339 { /* No effect in SEQ */
340 }

Referenced by G4RunMessenger::SetNewValue().

◆ rndmSaveThisEvent()

void G4RunManager::rndmSaveThisEvent ( )
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 711 of file G4RunManager.cc.

712{
713 if (currentEvent == nullptr) {
714 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
715 << " there is no currentEvent available." << G4endl << "Command ignored." << G4endl;
716 return;
717 }
718
720 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
721 << " Random number engine status is not available." << G4endl
722 << "/random/setSavingFlag command must be issued "
723 << "prior to the start of the run. Command ignored." << G4endl;
724 return;
725 }
726
727 G4fs::path fileIn = randomNumberStatusDir + "currentEvent.rndm";
728
729 std::ostringstream os;
730 os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID() << ".rndm" << '\0';
731 G4fs::path fileOut = randomNumberStatusDir + os.str();
732
733 if (G4CopyRandomState(fileIn, fileOut, "G4RunManager::rndmSaveThisEvent()") && verboseLevel > 0)
734 {
735 G4cout << fileIn << " is copied to " << fileOut << G4endl;
736 }
737}
G4bool G4CopyRandomState(const G4fs::path &source, const G4fs::path &dest, const G4String &callsite)
G4int GetEventID() const
Definition G4Event.hh:123

Referenced by G4RunMessenger::SetNewValue().

◆ rndmSaveThisRun()

void G4RunManager::rndmSaveThisRun ( )
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 686 of file G4RunManager.cc.

687{
688 G4int runNumber = 0;
689 if (currentRun != nullptr) runNumber = currentRun->GetRunID();
691 G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
692 << " Random number status was not stored prior to this run." << G4endl
693 << "/random/setSavingFlag command must be issued. "
694 << "Command ignored." << G4endl;
695 return;
696 }
697
698 G4fs::path fileIn = randomNumberStatusDir + "currentRun.rndm";
699
700 std::ostringstream os;
701 os << "run" << runNumber << ".rndm" << '\0';
702 G4fs::path fileOut = randomNumberStatusDir + os.str();
703
704 if (G4CopyRandomState(fileIn, fileOut, "G4RunManager::rndmSaveThisRun()") && verboseLevel > 0)
705 {
706 G4cout << fileIn << " is copied to " << fileOut << G4endl;
707 }
708}

Referenced by G4RunMessenger::SetNewValue().

◆ RunInitialization()

void G4RunManager::RunInitialization ( )
virtual

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 297 of file G4RunManager.cc.

298{
299 if (!(kernel->RunInitialization(fakeRun))) return;
300
301 runAborted = false;
303
305 delete currentRun;
306 currentRun = nullptr;
307
308 if (fakeRun) return;
309
311
313 if (currentRun == nullptr) currentRun = new G4Run();
314
317
320 if (fSDM != nullptr) {
322 }
323
324 if (G4VScoreNtupleWriter::Instance() != nullptr) {
325 auto hce = (fSDM != nullptr) ? fSDM->PrepareNewEvent() : nullptr;
327 delete hce;
328 }
329
330 std::ostringstream oss;
331 G4Random::saveFullState(oss);
334
335 for (G4int i_prev = 0; i_prev < n_perviousEventsToBeStored; ++i_prev) {
336 previousEvents->push_back(nullptr);
337 }
338
339 if (printModulo >= 0 || verboseLevel > 0) {
340 G4cout << "### Run " << currentRun->GetRunID() << " starts." << G4endl;
341 }
343
344#if defined(GEANT4_USE_TIMEMORY)
345 masterRunProfiler.reset(new ProfilerConfig(currentRun));
346#endif
347
350 }
351
353 G4String fileN = "currentRun";
355 std::ostringstream os;
356 os << "run" << currentRun->GetRunID();
357 fileN = os.str();
358 }
359 StoreRNGStatus(fileN);
360 }
361}
static G4ParallelWorldProcessStore * GetInstance()
G4bool RunInitialization(G4bool fakeRun=false)
G4bool isScoreNtupleWriter
G4DCtable * DCtable
G4ProfilerConfig< G4ProfileType::Run > ProfilerConfig
Definition G4Run.hh:49
void SetHCtable(G4HCtable *HCtbl)
Definition G4Run.hh:108
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition G4Run.hh:107
void SetRunID(G4int id)
Definition G4Run.hh:106
void SetDCtable(G4DCtable *DCtbl)
Definition G4Run.hh:109
void SetRandomNumberStatus(G4String &st)
Definition G4Run.hh:110
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4HCtable * GetHCtable() const
virtual G4Run * GenerateRun()
virtual void BeginOfRunAction(const G4Run *)
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0

Referenced by BeamOn().

◆ RunTermination()

void G4RunManager::RunTermination ( )
virtual

Reimplemented in G4MTRunManager, G4TaskRunManager, G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 487 of file G4RunManager.cc.

488{
489 if (!fakeRun) {
490#if defined(GEANT4_USE_TIMEMORY)
491 masterRunProfiler.reset();
492#endif
494 // tasking occasionally will call this function even
495 // if there was not a current run
496 if (currentRun != nullptr) {
499 if (fPersM != nullptr) fPersM->Store(currentRun);
500 // write & close analysis output
503 }
504 }
505 ++runIDCounter;
506 }
507
509}
void CleanUpUnnecessaryEvents(G4int keepNEvents)
virtual void EndOfRunAction(const G4Run *)
virtual void Write()=0

Referenced by BeamOn(), G4MTRunManager::RunTermination(), G4TaskRunManager::RunTermination(), G4WorkerRunManager::RunTermination(), and G4WorkerTaskRunManager::RunTermination().

◆ SetDCtable()

void G4RunManager::SetDCtable ( G4DCtable * DCtbl)
inline

Definition at line 516 of file G4RunManager.hh.

516{ DCtable = DCtbl; }

Referenced by G4DigiManager::AddNewModule().

◆ SetGeometryToBeOptimized()

void G4RunManager::SetGeometryToBeOptimized ( G4bool vl)
inline

Definition at line 316 of file G4RunManager.hh.

317 {
318 if (geometryToBeOptimized != vl) {
322 }
323 }
void SetGeometryToBeOptimized(G4bool vl)

Referenced by G4RunMessenger::SetNewValue().

◆ SetNumberOfAdditionalWaitingStacks()

void G4RunManager::SetNumberOfAdditionalWaitingStacks ( G4int iAdd)
inline

Definition at line 402 of file G4RunManager.hh.

403 {
405 }
G4StackManager * GetStackManager() const
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)

◆ SetNumberOfEventsToBeProcessed()

void G4RunManager::SetNumberOfEventsToBeProcessed ( G4int val)
inline

Definition at line 512 of file G4RunManager.hh.

◆ SetNumberOfEventsToBeStored()

void G4RunManager::SetNumberOfEventsToBeStored ( G4int val)
inline

Definition at line 479 of file G4RunManager.hh.

◆ SetNumberOfThreads()

virtual void G4RunManager::SetNumberOfThreads ( G4int )
inlinevirtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 264 of file G4RunManager.hh.

264{}

◆ SetPrimaryTransformer()

void G4RunManager::SetPrimaryTransformer ( G4PrimaryTransformer * pt)
inline

Definition at line 409 of file G4RunManager.hh.

410 {
412 }
void SetPrimaryTransformer(G4PrimaryTransformer *pt)

◆ SetPrintProgress()

void G4RunManager::SetPrintProgress ( G4int i)
inline

Definition at line 473 of file G4RunManager.hh.

473{ printModulo = i; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStore()

void G4RunManager::SetRandomNumberStore ( G4bool flag)
inline

Definition at line 429 of file G4RunManager.hh.

429{ storeRandomNumberStatus = flag; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStoreDir()

void G4RunManager::SetRandomNumberStoreDir ( const G4String & dir)
inline

Definition at line 431 of file G4RunManager.hh.

432 {
433 G4String dirStr = dir;
434 if (dirStr.back() != '/') dirStr += "/";
435#ifndef WIN32
436 G4String shellCmd = "mkdir -p ";
437#else
438 std::replace(dirStr.begin(), dirStr.end(), '/', '\\');
439 G4String shellCmd = "if not exist " + dirStr + " mkdir ";
440#endif
441 shellCmd += dirStr;
442 randomNumberStatusDir = dirStr;
443 G4int sysret = system(shellCmd);
444 if (sysret != 0) {
445 G4String errmsg = "\"" + shellCmd + "\" returns non-zero value. Directory creation failed.";
446 G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0071", JustWarning, errmsg);
447 G4cerr << " return value = " << sysret << G4endl;
448 }
449 }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStorePerEvent()

void G4RunManager::SetRandomNumberStorePerEvent ( G4bool flag)
inline

Definition at line 463 of file G4RunManager.hh.

463{ rngStatusEventsFlag = flag; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRunIDCounter()

void G4RunManager::SetRunIDCounter ( G4int i)
inline

Definition at line 509 of file G4RunManager.hh.

509{ runIDCounter = i; }

Referenced by G4MTRunManager::Initialize(), and G4TaskRunManager::Initialize().

◆ SetUserAction() [1/6]

void G4RunManager::SetUserAction ( G4UserEventAction * userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 924 of file G4RunManager.cc.

925{
926 eventManager->SetUserAction(userAction);
927 userEventAction = userAction;
928}
void SetUserAction(G4UserEventAction *userAction)

◆ SetUserAction() [2/6]

◆ SetUserAction() [3/6]

void G4RunManager::SetUserAction ( G4UserStackingAction * userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 931 of file G4RunManager.cc.

932{
933 eventManager->SetUserAction(userAction);
934 userStackingAction = userAction;
935}

◆ SetUserAction() [4/6]

void G4RunManager::SetUserAction ( G4UserSteppingAction * userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 945 of file G4RunManager.cc.

946{
947 eventManager->SetUserAction(userAction);
948 userSteppingAction = userAction;
949}

◆ SetUserAction() [5/6]

void G4RunManager::SetUserAction ( G4UserTrackingAction * userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 938 of file G4RunManager.cc.

939{
940 eventManager->SetUserAction(userAction);
941 userTrackingAction = userAction;
942}

◆ SetUserAction() [6/6]

void G4RunManager::SetUserAction ( G4VUserPrimaryGeneratorAction * userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 918 of file G4RunManager.cc.

919{
920 userPrimaryGeneratorAction = userAction;
921}

◆ SetUserInitialization() [1/5]

void G4RunManager::SetUserInitialization ( G4UserWorkerInitialization * userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 889 of file G4RunManager.cc.

890{
891 G4Exception("G4RunManager::SetUserInitialization()", "Run3001", FatalException,
892 "Base-class G4RunManager cannot take G4UserWorkerInitialization. Use "
893 "G4MTRunManager.");
894}

◆ SetUserInitialization() [2/5]

void G4RunManager::SetUserInitialization ( G4UserWorkerThreadInitialization * userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 897 of file G4RunManager.cc.

898{
899 G4Exception("G4RunManager::SetUserThreadInitialization()", "Run3001", FatalException,
900 "Base-class G4RunManager cannot take G4UserWorkerThreadInitialization. "
901 "Use G4MTRunManager.");
902}

◆ SetUserInitialization() [3/5]

void G4RunManager::SetUserInitialization ( G4VUserActionInitialization * userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 905 of file G4RunManager.cc.

906{
907 userActionInitialization = userInit;
909}
virtual void Build() const =0

◆ SetUserInitialization() [4/5]

void G4RunManager::SetUserInitialization ( G4VUserDetectorConstruction * userInit)
virtual

◆ SetUserInitialization() [5/5]

void G4RunManager::SetUserInitialization ( G4VUserPhysicsList * userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 882 of file G4RunManager.cc.

883{
884 physicsList = userInit;
885 kernel->SetPhysics(userInit);
886}
void SetPhysics(G4VUserPhysicsList *uPhys)

◆ SetVerboseLevel()

void G4RunManager::SetVerboseLevel ( G4int vl)
inline

Definition at line 466 of file G4RunManager.hh.

467 {
468 verboseLevel = vl;
470 }
void SetVerboseLevel(G4int vl)

Referenced by G4RunMessenger::SetNewValue().

◆ StackPreviousEvent()

void G4RunManager::StackPreviousEvent ( G4Event * anEvent)
protected

Definition at line 560 of file G4RunManager.cc.

561{
562 if (anEvent->ToBeKept()) currentRun->StoreEvent(anEvent);
563
565 if (anEvent->GetNumberOfGrips() == 0) {
566 if (!(anEvent->ToBeKept())) delete anEvent;
567 }
568 else {
569 previousEvents->push_back(anEvent);
570 }
571 }
573}
void StoreEvent(G4Event *evt)
Definition G4Run.cc:73

Referenced by TerminateOneEvent().

◆ StoreRandomNumberStatusToG4Event()

void G4RunManager::StoreRandomNumberStatusToG4Event ( G4int vl)
inline

Definition at line 418 of file G4RunManager.hh.

Referenced by G4RunMessenger::SetNewValue().

◆ StoreRNGStatus()

void G4RunManager::StoreRNGStatus ( const G4String & filenamePrefix)
protectedvirtual

Reimplemented in G4MTRunManager, G4TaskRunManager, G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 472 of file G4RunManager.cc.

473{
474 G4String fileN = randomNumberStatusDir + fnpref + ".rndm";
475 G4Random::saveEngineStatus(fileN);
476}

Referenced by GenerateEvent(), and RunInitialization().

◆ TerminateEventLoop()

void G4RunManager::TerminateEventLoop ( )
virtual

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 419 of file G4RunManager.cc.

420{
421 if (verboseLevel > 0 && !fakeRun) {
422 timer->Stop();
423 G4cout << " Run terminated." << G4endl;
424 G4cout << "Run Summary" << G4endl;
425 if (runAborted) {
426 G4cout << " Run Aborted after " << numberOfEventProcessed << " events processed." << G4endl;
427 }
428 else {
429 G4cout << " Number of events processed : " << numberOfEventProcessed << G4endl;
430 }
431 G4cout << " " << *timer << G4endl;
432 }
434}

Referenced by DoEventLoop(), G4MTRunManager::RunTermination(), and G4TaskRunManager::RunTermination().

◆ TerminateOneEvent()

void G4RunManager::TerminateOneEvent ( )
virtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 411 of file G4RunManager.cc.

412{
414 currentEvent = nullptr;
416}
void StackPreviousEvent(G4Event *anEvent)

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

◆ UpdateScoring()

void G4RunManager::UpdateScoring ( )
protected

Definition at line 824 of file G4RunManager.cc.

825{
829 }
830
832 if (ScM == nullptr) return;
833 auto nPar = (G4int)ScM->GetNumberOfMesh();
834 if (nPar < 1) return;
835
837 if (HCE == nullptr) return;
838 auto nColl = (G4int)HCE->GetCapacity();
839 for (G4int i = 0; i < nColl; ++i) {
840 G4VHitsCollection* HC = HCE->GetHC(i);
841 if (HC != nullptr) ScM->Accumulate(HC);
842 }
843}
G4HCofThisEvent * GetHCofThisEvent() const
Definition G4Event.hh:161
G4VHitsCollection * GetHC(G4int i)
void Accumulate(G4VHitsCollection *map)
virtual void Fill(G4HCofThisEvent *hce, G4int eventNumber)=0

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

Friends And Related Symbol Documentation

◆ G4RunManagerFactory

friend class G4RunManagerFactory
friend

Definition at line 140 of file G4RunManager.hh.

Member Data Documentation

◆ currentEvent

◆ currentRun

◆ currentWorld

G4VPhysicalVolume* G4RunManager::currentWorld = nullptr
protected

Definition at line 585 of file G4RunManager.hh.

◆ DCtable

G4DCtable* G4RunManager::DCtable = nullptr
protected

◆ eventManager

◆ fakeRun

◆ fGeometryHasBeenDestroyed

◆ geometryDirectlyUpdated

G4bool G4RunManager::geometryDirectlyUpdated = false
protected

Definition at line 596 of file G4RunManager.hh.

Referenced by GeometryDirectlyUpdated(), and InitializeGeometry().

◆ geometryInitialized

G4bool G4RunManager::geometryInitialized = false
protected

◆ geometryToBeOptimized

G4bool G4RunManager::geometryToBeOptimized = true
protected

Definition at line 564 of file G4RunManager.hh.

Referenced by GetGeometryToBeOptimized(), and SetGeometryToBeOptimized().

◆ initializedAtLeastOnce

G4bool G4RunManager::initializedAtLeastOnce = false
protected

Definition at line 563 of file G4RunManager.hh.

Referenced by ConfirmBeamOnCondition(), and Initialize().

◆ isScoreNtupleWriter

G4bool G4RunManager::isScoreNtupleWriter = false
protected

◆ kernel

◆ msgText

◆ n_perviousEventsToBeStored

◆ n_select_msg

◆ nParallelWorlds

G4int G4RunManager::nParallelWorlds = 0
protected

Definition at line 587 of file G4RunManager.hh.

Referenced by GetNumberOfParallelWorld(), and InitializeGeometry().

◆ numberOfEventProcessed

◆ numberOfEventToBeProcessed

◆ physicsInitialized

G4bool G4RunManager::physicsInitialized = false
protected

Definition at line 561 of file G4RunManager.hh.

Referenced by ConfirmBeamOnCondition(), Initialize(), and InitializePhysics().

◆ physicsList

◆ previousEvents

◆ printModulo

◆ randomNumberStatusDir

◆ randomNumberStatusForThisEvent

G4String G4RunManager::randomNumberStatusForThisEvent = ""
protected

◆ randomNumberStatusForThisRun

◆ rngStatusEventsFlag

◆ runAborted

◆ runIDCounter

◆ runManagerType

RMType G4RunManager::runManagerType
protected

Definition at line 598 of file G4RunManager.hh.

Referenced by DoEventLoop(), G4RunManager(), G4RunManager(), and GetRunManagerType().

◆ selectMacro

G4String G4RunManager::selectMacro = ""
protected

◆ storeRandomNumberStatus

◆ storeRandomNumberStatusToG4Event

◆ timer

◆ userActionInitialization

◆ userDetector

◆ userEventAction

G4UserEventAction* G4RunManager::userEventAction = nullptr
protected

Definition at line 555 of file G4RunManager.hh.

Referenced by GetUserEventAction(), and SetUserAction().

◆ userPrimaryGeneratorAction

◆ userRunAction

◆ userStackingAction

G4UserStackingAction* G4RunManager::userStackingAction = nullptr
protected

Definition at line 556 of file G4RunManager.hh.

Referenced by GetUserStackingAction(), and SetUserAction().

◆ userSteppingAction

G4UserSteppingAction* G4RunManager::userSteppingAction = nullptr
protected

Definition at line 558 of file G4RunManager.hh.

Referenced by GetUserSteppingAction(), and SetUserAction().

◆ userTrackingAction

G4UserTrackingAction* G4RunManager::userTrackingAction = nullptr
protected

Definition at line 557 of file G4RunManager.hh.

Referenced by GetUserTrackingAction(), and SetUserAction().

◆ userWorkerInitialization

◆ userWorkerThreadInitialization

◆ verboseLevel


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