Geant4 10.7.0
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 ()
 
virtual void BeamOn (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void Initialize ()
 
virtual void DefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
virtual void AbortRun (G4bool softAbort=false)
 
virtual void AbortEvent ()
 
virtual void InitializeGeometry ()
 
virtual void InitializePhysics ()
 
virtual G4bool ConfirmBeamOnCondition ()
 
virtual void RunInitialization ()
 
virtual void DoEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void RunTermination ()
 
virtual void InitializeEventLoop (G4int n_event, const char *macroFile=0, 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 (int argc, char **argv)
 
virtual void SetNumberOfThreads (G4int)
 
virtual G4int GetNumberOfThreads () const
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=0) const
 
virtual void rndmSaveThisRun ()
 
virtual void rndmSaveThisEvent ()
 
virtual void RestoreRandomNumberStatus (const G4String &fileN)
 
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 GeometryHasBeenModified (G4bool prop=true)
 
void ReinitializeGeometry (G4bool destroyFirst=false, G4bool prop=true)
 
void PhysicsHasBeenModified ()
 
void CutOffHasBeenModified ()
 
void ReOptimizeMotherOf (G4VPhysicalVolume *)
 
void ReOptimize (G4LogicalVolume *)
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
G4int GetPrintProgress ()
 
void SetPrintProgress (G4int i)
 
void SetGeometryToBeOptimized (G4bool vl)
 
G4bool GetGeometryToBeOptimized ()
 
void SetNumberOfEventsToBeStored (G4int val)
 
const G4RunGetCurrentRun () const
 
G4RunGetNonConstCurrentRun () const
 
const G4EventGetCurrentEvent () const
 
const G4EventGetPreviousEvent (G4int i) const
 
void SetRunIDCounter (G4int i)
 
G4int GetNumberOfParallelWorld () const
 
void SetNumberOfEventsToBeProcessed (G4int val)
 
G4int GetNumberOfEventsToBeProcessed () const
 
G4int GetNumberOfSelectEvents () const
 
G4String GetSelectMacro () const
 
void SetDCtable (G4DCtable *DCtbl)
 
RMType GetRunManagerType () const
 
virtual void ConstructScoringWorlds ()
 
virtual void RestoreRndmEachEvent (G4bool)
 
void GeometryDirectlyUpdated (G4bool val=true)
 

Static Public Member Functions

static G4RunManagerGetRunManager ()
 
static G4bool IfGeometryHasBeenDestroyed ()
 

Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

static G4RUN_DLL G4bool fGeometryHasBeenDestroyed = false
 

Friends

class G4RunManagerFactory
 

Detailed Description

Definition at line 141 of file G4RunManager.hh.

Member Typedef Documentation

◆ ProfilerConfig

Member Enumeration Documentation

◆ RMType

Enumerator
sequentialRM 
masterRM 
workerRM 

Definition at line 307 of file G4RunManager.hh.

308 {
310 masterRM,
312 };

Constructor & Destructor Documentation

◆ G4RunManager() [1/2]

G4RunManager::G4RunManager ( )

Definition at line 86 of file G4RunManager.cc.

87 : userDetector(0)
88 , physicsList(0)
92 , userRunAction(0)
98 , geometryInitialized(false)
99 , physicsInitialized(false)
100 , runAborted(false)
103 , runIDCounter(0)
104 , verboseLevel(0)
105 , printModulo(-1)
106 , DCtable(0)
107 , currentRun(0)
108 , currentEvent(0)
113 , rngStatusEventsFlag(false)
114 , currentWorld(0)
115 , nParallelWorlds(0)
116 , msgText(" ")
117 , n_select_msg(-1)
119 , selectMacro("")
120 , fakeRun(false)
121 , isScoreNtupleWriter(false)
123{
124 if(fRunManager)
125 {
126 G4Exception("G4RunManager::G4RunManager()", "Run0031", FatalException,
127 "G4RunManager constructed twice.");
128 }
129 fRunManager = this;
130
133
134 timer = new G4Timer();
135 runMessenger = new G4RunMessenger(this);
136 previousEvents = new std::list<G4Event*>;
140 std::ostringstream oss;
141 G4Random::saveFullState(oss);
145}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static G4ParticleTable * GetParticleTable()
G4UImessenger * CreateMessenger()
static G4ProcessTable * GetProcessTable()
G4EventManager * GetEventManager() const
G4bool isScoreNtupleWriter
G4bool geometryInitialized
G4int storeRandomNumberStatusToG4Event
G4UserWorkerInitialization * userWorkerInitialization
G4int nParallelWorlds
std::list< G4Event * > * previousEvents
G4Timer * timer
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
G4bool geometryDirectlyUpdated
G4int n_select_msg
G4int numberOfEventProcessed
G4UserEventAction * userEventAction
G4int runIDCounter
G4RunManagerKernel * kernel
G4int verboseLevel
G4Run * currentRun
G4bool geometryToBeOptimized
G4DCtable * DCtable
G4String randomNumberStatusForThisRun
G4bool runAborted
G4String msgText
G4UserRunAction * userRunAction
G4bool rngStatusEventsFlag
G4String selectMacro
G4bool physicsInitialized
G4VUserActionInitialization * userActionInitialization
G4VPhysicalVolume * currentWorld
G4VUserDetectorConstruction * userDetector
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
G4int numberOfEventToBeProcessed
G4String randomNumberStatusDir
G4String randomNumberStatusForThisEvent
G4UserTrackingAction * userTrackingAction
RMType runManagerType
G4int n_perviousEventsToBeStored
G4bool storeRandomNumberStatus
G4bool initializedAtLeastOnce
G4EventManager * eventManager
G4VUserPhysicsList * physicsList
G4UserStackingAction * userStackingAction
G4Event * currentEvent
G4UserSteppingAction * userSteppingAction

◆ ~G4RunManager()

G4RunManager::~G4RunManager ( )
virtual

Definition at line 238 of file G4RunManager.cc.

239{
240 // finalize profiler before shutting down the threads
243 // set the application state to the quite state
244 if(pStateManager->GetCurrentState() != G4State_Quit)
245 {
246 if(verboseLevel > 0)
247 G4cout << "G4 kernel has come to Quit state." << G4endl;
248 pStateManager->SetNewState(G4State_Quit);
249 }
250
252 if(currentRun)
253 delete currentRun;
254 delete timer;
255 delete runMessenger;
256 delete previousEvents;
257
258 // The following will work for all RunManager types
259 // if derived class does the correct thing in derived
260 // destructor that is set to zero pointers of
261 // user initialization objects for which does not have
262 // ownership
264 if(userRunAction)
265 {
266 delete userRunAction;
267 userRunAction = 0;
268 if(verboseLevel > 1)
269 G4cout << "UserRunAction deleted." << G4endl;
270 }
272 {
275 if(verboseLevel > 1)
276 G4cout << "UserPrimaryGenerator deleted." << G4endl;
277 }
278
279 if(verboseLevel > 1)
280 G4cout << "RunManager is deleting RunManagerKernel." << G4endl;
281
282 delete kernel;
283
284 fRunManager = 0;
285}
@ G4State_Quit
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static void Finalize()
Definition: G4Profiler.cc:331
void CleanUpPreviousEvents()
virtual void DeleteUserInitializations()
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)

◆ G4RunManager() [2/2]

G4RunManager::G4RunManager ( RMType  rmType)
protected

Definition at line 147 of file G4RunManager.cc.

148 : userDetector(0)
149 , physicsList(0)
153 , userRunAction(0)
155 , userEventAction(0)
159 , geometryInitialized(false)
160 , physicsInitialized(false)
161 , runAborted(false)
164 , runIDCounter(0)
165 , verboseLevel(0)
166 , printModulo(-1)
167 , DCtable(0)
168 , currentRun(0)
169 , currentEvent(0)
174 , rngStatusEventsFlag(false)
175 , currentWorld(0)
176 , nParallelWorlds(0)
177 , msgText(" ")
178 , n_select_msg(-1)
180 , selectMacro("")
181 , fakeRun(false)
182 , isScoreNtupleWriter(false)
184{
185 // This version of the constructor should never be called in sequential mode!
186#ifndef G4MULTITHREADED
188 msg << "Geant4 code is compiled without multi-threading support "
189 "(-DG4MULTITHREADED "
190 "is set to off).";
191 msg << " This type of RunManager can only be used in mult-threaded "
192 "applications.";
193 G4Exception("G4RunManager::G4RunManager(G4bool)", "Run0107", FatalException,
194 msg);
195#endif
196
197 if(fRunManager)
198 {
199 G4Exception("G4RunManager::G4RunManager()", "Run0031", FatalException,
200 "G4RunManager constructed twice.");
201 return;
202 }
203 fRunManager = this;
204
205 switch(rmType)
206 {
207 case masterRM:
209 break;
210 case workerRM:
212 break;
213 default:
215 msgx << " This type of RunManager can only be used in mult-threaded "
216 "applications.";
217 G4Exception("G4RunManager::G4RunManager(G4bool)", "Run0108",
218 FatalException, msgx);
219 return;
220 }
221 runManagerType = rmType;
222
224
225 timer = new G4Timer();
226 runMessenger = new G4RunMessenger(this);
227 previousEvents = new std::list<G4Event*>;
231 std::ostringstream oss;
232 G4Random::saveFullState(oss);
236}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
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 812 of file G4RunManager.cc.

813{
814 // This method is valid only for EventProc state
815 G4ApplicationState currentState =
817 if(currentState == G4State_EventProc)
818 {
821 }
822 else
823 {
824 G4cerr << "Event is not in progress. AbortEevnt() ignored." << G4endl;
825 }
826}
G4ApplicationState
@ G4State_EventProc
G4GLOB_DLL std::ostream G4cerr
void AbortCurrentEvent()
void SetEventAborted()
Definition: G4Event.hh:88

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

◆ AbortRun()

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

virtual void ResetNavigator() const;

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 792 of file G4RunManager.cc.

793{
794 // This method is valid only for GeomClosed or EventProc state
795 G4ApplicationState currentState =
797 if(currentState == G4State_GeomClosed || currentState == G4State_EventProc)
798 {
799 runAborted = true;
800 if(currentState == G4State_EventProc && !softAbort)
801 {
804 }
805 }
806 else
807 {
808 G4cerr << "Run is not in progress. AbortRun() ignored." << G4endl;
809 }
810}
@ G4State_GeomClosed

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

◆ AnalyzeEvent()

void G4RunManager::AnalyzeEvent ( G4Event anEvent)
virtual

Definition at line 594 of file G4RunManager.cc.

595{
596 G4VPersistencyManager* fPersM =
598 if(fPersM)
599 fPersM->Store(anEvent);
600 currentRun->RecordEvent(anEvent);
601}
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:62
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 = 0,
G4int  n_select = -1 
)
virtual

Definition at line 326 of file G4RunManager.cc.

327{
328 if(n_event <= 0)
329 {
330 fakeRun = true;
331 }
332 else
333 {
334 fakeRun = false;
335 }
337 if(cond)
338 {
343 DoEventLoop(n_event, macroFile, n_select);
345 }
346 fakeRun = false;
347}
bool G4bool
Definition: G4Types.hh:86
virtual void DoEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual G4bool ConfirmBeamOnCondition()
virtual void RunTermination()
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 633 of file G4RunManager.cc.

634{
635 // Delete all events carried over from previous run.
636 // This method is invoked at the beginning of the next run
637 // or from the destructor of G4RunManager at the very end of
638 // the program.
639 // N.B. If ToBeKept() is true, the pointer of this event is
640 // kept in G4Run of the previous run, and deleted along with
641 // the deletion of G4Run.
642
643 std::list<G4Event*>::iterator evItr = previousEvents->begin();
644 while(evItr != previousEvents->end())
645 {
646 G4Event* evt = *evItr;
647 if(evt && !(evt->ToBeKept()))
648 delete evt;
649 evItr = previousEvents->erase(evItr);
650 }
651}
G4bool ToBeKept() const
Definition: G4Event.hh:102

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

◆ CleanUpUnnecessaryEvents()

void G4RunManager::CleanUpUnnecessaryEvents ( G4int  keepNEvents)
protected

Definition at line 653 of file G4RunManager.cc.

654{
655 // Delete events that are no longer necessary for post
656 // processing such as visualization.
657 // N.B. If ToBeKept() is true, the pointer of this event is
658 // kept in G4Run of the previous run, and deleted along with
659 // the deletion of G4Run.
660
661 std::list<G4Event*>::iterator evItr = previousEvents->begin();
662 while(evItr != previousEvents->end())
663 {
664 if(G4int(previousEvents->size()) <= keepNEvents)
665 return;
666
667 G4Event* evt = *evItr;
668 if(evt)
669 {
670 if(evt->GetNumberOfGrips() == 0)
671 {
672 if(!(evt->ToBeKept()))
673 delete evt;
674 evItr = previousEvents->erase(evItr);
675 }
676 else
677 {
678 evItr++;
679 }
680 }
681 else
682 {
683 evItr = previousEvents->erase(evItr);
684 }
685 }
686}
int G4int
Definition: G4Types.hh:85
G4int GetNumberOfGrips() const
Definition: G4Event.hh:115

Referenced by RunTermination(), and StackPreviousEvent().

◆ ConfigureProfilers() [1/2]

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

Definition at line 1243 of file G4RunManager.cc.

1244{
1245#ifdef GEANT4_USE_TIMEMORY
1246 // parse command line if arguments were passed
1248#else
1249 G4ConsumeParameters(args);
1250#endif
1251}
static void Configure(const std::vector< std::string > &args)
Definition: G4Profiler.cc:91
void G4ConsumeParameters(_Args &&...)
Definition: templates.hh:187

Referenced by ConfigureProfilers(), and G4RunManager().

◆ ConfigureProfilers() [2/2]

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

Definition at line 1233 of file G4RunManager.cc.

1234{
1235 std::vector<std::string> _args;
1236 for(int i = 0; i < argc; ++i)
1237 _args.push_back(argv[i]);
1238 ConfigureProfilers(_args);
1239}

◆ ConfirmBeamOnCondition()

G4bool G4RunManager::ConfirmBeamOnCondition ( )
virtual

Definition at line 349 of file G4RunManager.cc.

350{
352
353 G4ApplicationState currentState = stateManager->GetCurrentState();
354 if(currentState != G4State_PreInit && currentState != G4State_Idle)
355 {
356 G4cerr << "Illegal application state - BeamOn() ignored." << G4endl;
357 return false;
358 }
359
361 {
362 G4cerr << " Geant4 kernel should be initialized" << G4endl;
363 G4cerr << "before the first BeamOn(). - BeamOn ignored." << G4endl;
364 return false;
365 }
366
368 {
369 if(verboseLevel > 0)
370 {
371 G4cout << "Start re-initialization because " << G4endl;
373 G4cout << " Geometry" << G4endl;
375 G4cout << " Physics processes" << G4endl;
376 G4cout << "has been modified since last Run." << G4endl;
377 }
378 Initialize();
379 }
380 return true;
381}
@ G4State_Idle
@ G4State_PreInit
virtual void Initialize()

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

◆ ConstructScoringWorlds()

void G4RunManager::ConstructScoringWorlds ( )
virtual

Reimplemented in G4MTRunManager, G4WorkerRunManager, and G4TaskRunManager.

Definition at line 943 of file G4RunManager.cc.

944{
945 using MeshShape = G4VScoringMesh::MeshShape;
946
948 if(!ScM)
949 return;
950
951 G4int nPar = ScM->GetNumberOfMesh();
952 if(nPar < 1)
953 return;
954
957 for(G4int iw = 0; iw < nPar; iw++)
958 {
959 G4VScoringMesh* mesh = ScM->GetMesh(iw);
962 G4VPhysicalVolume* pWorld = nullptr;
963 if(mesh->GetShape() != MeshShape::realWorldLogVol)
964 {
965 pWorld =
967 ScM->GetWorldName(iw));
968 if(!pWorld)
969 {
970 pWorld =
972 ScM->GetWorldName(iw));
973 pWorld->SetName(ScM->GetWorldName(iw));
974
975 G4ParallelWorldProcess* theParallelWorldProcess =
977 if(theParallelWorldProcess)
978 {
979 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
980 }
981 else
982 {
983 theParallelWorldProcess =
985 mesh->SetParallelWorldProcess(theParallelWorldProcess);
986 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
987
988 theParticleIterator->reset();
989 while((*theParticleIterator)())
990 {
991 G4ParticleDefinition* particle = theParticleIterator->value();
992 G4ProcessManager* pmanager = particle->GetProcessManager();
993 if(pmanager)
994 {
995 pmanager->AddProcess(theParallelWorldProcess);
996 if(theParallelWorldProcess->IsAtRestRequired(particle))
997 {
998 pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest,
999 9900);
1000 }
1001 pmanager->SetProcessOrderingToSecond(theParallelWorldProcess,
1002 idxAlongStep);
1003 pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep,
1004 9900);
1005 }
1006 }
1007 }
1008 theParallelWorldProcess->SetLayeredMaterialFlag(mesh->LayeredMassFlg());
1009 }
1010 }
1011 mesh->Construct(pWorld);
1012 }
1013
1015}
@ 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)
void Construct(G4VPhysicalVolume *fWorldPhys)
G4bool LayeredMassFlg()

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

◆ CutOffHasBeenModified()

void G4RunManager::CutOffHasBeenModified ( )
inline

Definition at line 576 of file G4RunManager.hh.

577 {
578 G4cerr << "CutOffHasBeenModified becomes obsolete." << G4endl;
579 G4cerr << "It is safe to remove invoking this method." << G4endl;
580 }

◆ DefineWorldVolume()

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

Definition at line 828 of file G4RunManager.cc.

830{
831 kernel->DefineWorldVolume(worldVol, topologyIsChanged);
832}
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)

Referenced by G4GDMLMessenger::SetNewValue().

◆ DeleteUserInitializations()

void G4RunManager::DeleteUserInitializations ( )
protectedvirtual

Definition at line 287 of file G4RunManager.cc.

288{
289 if(userDetector)
290 {
291 delete userDetector;
292 userDetector = 0;
293 if(verboseLevel > 1)
294 G4cout << "UserDetectorConstruction deleted." << G4endl;
295 }
296 if(physicsList)
297 {
298 delete physicsList;
299 physicsList = 0;
300 if(verboseLevel > 1)
301 G4cout << "UserPhysicsList deleted." << G4endl;
302 }
304 {
307 if(verboseLevel > 1)
308 G4cout << "UserActionInitialization deleted." << G4endl;
309 }
311 {
314 if(verboseLevel > 1)
315 G4cout << "UserWorkerInitialization deleted." << G4endl;
316 }
318 {
321 if(verboseLevel > 1)
322 G4cout << "UserWorkerThreadInitialization deleted." << G4endl;
323 }
324}

Referenced by ~G4RunManager().

◆ DoEventLoop()

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

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 463 of file G4RunManager.cc.

465{
466 InitializeEventLoop(n_event, macroFile, n_select);
467
468 // Event loop
469 for(G4int i_event = 0; i_event < n_event; i_event++)
470 {
471 ProcessOneEvent(i_event);
473 if(runAborted)
474 break;
475 }
476
477 // For G4MTRunManager, TerminateEventLoop() is invoked after all threads are
478 // finished.
481}
virtual void TerminateEventLoop()
virtual void ProcessOneEvent(G4int i_event)
virtual void TerminateOneEvent()
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)

Referenced by BeamOn().

◆ DumpRegion() [1/2]

void G4RunManager::DumpRegion ( const G4String rname) const

Definition at line 920 of file G4RunManager.cc.

921{
922 kernel->DumpRegion(rname);
923}
void DumpRegion(const G4String &rname) const

Referenced by G4RunMessenger::SetNewValue().

◆ DumpRegion() [2/2]

void G4RunManager::DumpRegion ( G4Region region = 0) const

Definition at line 925 of file G4RunManager.cc.

926{
927 kernel->DumpRegion(region);
928}

◆ GenerateEvent()

G4Event * G4RunManager::GenerateEvent ( G4int  i_event)
virtual

virtual void BuildPhysicsTables();

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 548 of file G4RunManager.cc.

549{
551 {
552 G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
553 "G4VUserPrimaryGeneratorAction is not defined!");
554 return 0;
555 }
556
557 G4Event* anEvent = new G4Event(i_event);
558
561 {
562 std::ostringstream oss;
563 G4Random::saveFullState(oss);
566 }
567
569 {
570 G4String fileN = "currentEvent";
572 {
573 std::ostringstream os;
574 os << "run" << currentRun->GetRunID() << "evt" << anEvent->GetEventID();
575 fileN = os.str();
576 }
577 StoreRNGStatus(fileN);
578 }
579
580 if(printModulo > 0 && anEvent->GetEventID() % printModulo == 0)
581 {
582 G4cout << "--> Event " << anEvent->GetEventID() << " starts." << G4endl;
583 }
585 return anEvent;
586}
void SetRandomNumberStatus(G4String &st)
Definition: G4Event.hh:90
G4int GetEventID() const
Definition: G4Event.hh:118
virtual void StoreRNGStatus(const G4String &filenamePrefix)
G4int GetRunID() const
Definition: G4Run.hh:82
virtual void GeneratePrimaries(G4Event *anEvent)=0

Referenced by ProcessOneEvent().

◆ GeometryDirectlyUpdated()

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

Definition at line 708 of file G4RunManager.hh.

709 {
711 }

Referenced by G4GDMLMessenger::SetNewValue().

◆ GeometryHasBeenModified()

void G4RunManager::GeometryHasBeenModified ( G4bool  prop = true)

Definition at line 1152 of file G4RunManager.cc.

1153{
1154 if(prop)
1155 {
1156 G4UImanager::GetUIpointer()->ApplyCommand("/run/geometryModified");
1157 }
1158 else
1159 {
1161 }
1162}
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77

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

◆ GetCurrentEvent()

const G4Event * G4RunManager::GetCurrentEvent ( ) const
inline

◆ GetCurrentRun()

◆ GetFlagRandomNumberStatusToG4Event()

G4int G4RunManager::GetFlagRandomNumberStatusToG4Event ( ) const
inline

Definition at line 487 of file G4RunManager.hh.

488 {
490 }

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetGeometryToBeOptimized()

G4bool G4RunManager::GetGeometryToBeOptimized ( )
inline

Definition at line 612 of file G4RunManager.hh.

612{ return geometryToBeOptimized; }

◆ GetNonConstCurrentRun()

G4Run * G4RunManager::GetNonConstCurrentRun ( ) const
inline

Definition at line 625 of file G4RunManager.hh.

625{ return currentRun; }

◆ GetNonConstUserActionInitialization()

G4VUserActionInitialization * G4RunManager::GetNonConstUserActionInitialization ( ) const
inline

◆ GetNumberOfEventsToBeProcessed()

G4int G4RunManager::GetNumberOfEventsToBeProcessed ( ) const
inline

◆ GetNumberOfParallelWorld()

G4int G4RunManager::GetNumberOfParallelWorld ( ) const
inline

Definition at line 658 of file G4RunManager.hh.

658{ return nParallelWorlds; }

◆ GetNumberOfSelectEvents()

G4int G4RunManager::GetNumberOfSelectEvents ( ) const
inline

Definition at line 667 of file G4RunManager.hh.

667{ 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 283 of file G4RunManager.hh.

283{ return 1; }

◆ GetPreviousEvent()

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

Definition at line 633 of file G4RunManager.hh.

634 {
635 if(i >= 1 && i <= n_perviousEventsToBeStored)
636 {
637 std::list<G4Event*>::iterator itr = previousEvents->begin();
638 for(G4int j = 1; j < i; j++)
639 {
640 itr++;
641 }
642 return *itr;
643 }
644 return 0;
645 }

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

◆ GetPrintProgress()

G4int G4RunManager::GetPrintProgress ( )
inline

Definition at line 600 of file G4RunManager.hh.

600{ return printModulo; }

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

◆ GetRandomNumberStatusForThisEvent()

const G4String & G4RunManager::GetRandomNumberStatusForThisEvent ( ) const
inline

Definition at line 529 of file G4RunManager.hh.

530 {
533 {
534 G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0072",
536 "Random number status is not available for this event.");
537 }
539 }
@ JustWarning

◆ GetRandomNumberStatusForThisRun()

const G4String & G4RunManager::GetRandomNumberStatusForThisRun ( ) const
inline

Definition at line 525 of file G4RunManager.hh.

526 {
528 }

◆ GetRandomNumberStore()

G4bool G4RunManager::GetRandomNumberStore ( ) const
inline

Definition at line 497 of file G4RunManager.hh.

497{ return storeRandomNumberStatus; }

◆ GetRandomNumberStoreDir()

const G4String & G4RunManager::GetRandomNumberStoreDir ( ) const
inline

Definition at line 521 of file G4RunManager.hh.

522 {
524 }

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetRandomNumberStorePerEvent()

G4bool G4RunManager::GetRandomNumberStorePerEvent ( ) const
inline

Definition at line 544 of file G4RunManager.hh.

545 {
546 return rngStatusEventsFlag;
547 }

◆ GetRunManager()

◆ GetRunManagerType()

RMType G4RunManager::GetRunManagerType ( ) const
inline

◆ GetSelectMacro()

G4String G4RunManager::GetSelectMacro ( ) const
inline

Definition at line 668 of file G4RunManager.hh.

668{ return 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 406 of file G4RunManager.hh.

407 {
408 return userDetector;
409 }

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

◆ GetUserEventAction()

const G4UserEventAction * G4RunManager::GetUserEventAction ( ) const
inline

Definition at line 441 of file G4RunManager.hh.

442 {
443 return userEventAction;
444 }

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserPhysicsList()

const G4VUserPhysicsList * G4RunManager::GetUserPhysicsList ( ) const
inline

Definition at line 410 of file G4RunManager.hh.

411 {
412 return physicsList;
413 }

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

◆ GetUserPrimaryGeneratorAction()

const G4VUserPrimaryGeneratorAction * G4RunManager::GetUserPrimaryGeneratorAction ( ) const
inline

Definition at line 436 of file G4RunManager.hh.

438 {
440 }

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserRunAction()

const G4UserRunAction * G4RunManager::GetUserRunAction ( ) const
inline

Definition at line 432 of file G4RunManager.hh.

433 {
434 return userRunAction;
435 }

Referenced by G4TheMTRayTracer::StoreUserActions(), and G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserStackingAction()

const G4UserStackingAction * G4RunManager::GetUserStackingAction ( ) const
inline

Definition at line 445 of file G4RunManager.hh.

446 {
447 return userStackingAction;
448 }

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserSteppingAction()

const G4UserSteppingAction * G4RunManager::GetUserSteppingAction ( ) const
inline

Definition at line 453 of file G4RunManager.hh.

454 {
455 return userSteppingAction;
456 }

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserTrackingAction()

const G4UserTrackingAction * G4RunManager::GetUserTrackingAction ( ) const
inline

Definition at line 449 of file G4RunManager.hh.

450 {
451 return userTrackingAction;
452 }

Referenced by G4RTWorkerInitialization::WorkerRunStart().

◆ GetUserWorkerInitialization()

◆ GetUserWorkerThreadInitialization()

const G4UserWorkerThreadInitialization * G4RunManager::GetUserWorkerThreadInitialization ( ) const
inline

◆ GetVerboseLevel()

G4int G4RunManager::GetVerboseLevel ( ) const
inline

Definition at line 599 of file G4RunManager.hh.

599{ return verboseLevel; }

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

◆ GetVersionString()

const G4String & G4RunManager::GetVersionString ( ) const
inline

Definition at line 468 of file G4RunManager.hh.

469 {
470 return kernel->GetVersionString();
471 }
const G4String & GetVersionString() const

◆ IfGeometryHasBeenDestroyed()

G4bool G4RunManager::IfGeometryHasBeenDestroyed ( )
static

Definition at line 73 of file G4RunManager.cc.

74{
76}

Referenced by G4WorkerTaskRunManager::RunInitialization().

◆ Initialize()

void G4RunManager::Initialize ( )
virtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 709 of file G4RunManager.cc.

710{
712 G4ApplicationState currentState = stateManager->GetCurrentState();
713 if(currentState != G4State_PreInit && currentState != G4State_Idle)
714 {
715 G4cerr << "Illegal application state - "
716 << "G4RunManager::Initialize() ignored." << G4endl;
717 return;
718 }
719
720 stateManager->SetNewState(G4State_Init);
726 if(stateManager->GetCurrentState() != G4State_Idle)
727 {
728 stateManager->SetNewState(G4State_Idle);
729 }
730}
@ 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 = 0,
G4int  n_select = -1 
)
virtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 483 of file G4RunManager.cc.

485{
486 if(verboseLevel > 0)
487 {
488 timer->Start();
489 }
490
491 n_select_msg = n_select;
492 if(macroFile != 0)
493 {
494 if(n_select_msg < 0)
495 n_select_msg = n_event;
496 msgText = "/control/execute ";
497 msgText += macroFile;
498 selectMacro = macroFile;
499 }
500 else
501 {
502 n_select_msg = -1;
503 selectMacro = "";
504 }
505}
void Start()

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

◆ InitializeGeometry()

void G4RunManager::InitializeGeometry ( )
virtual

Reimplemented in G4WorkerRunManager.

Definition at line 732 of file G4RunManager.cc.

733{
734 if(!userDetector)
735 {
736 G4Exception("G4RunManager::InitializeGeometry", "Run0033", FatalException,
737 "G4VUserDetectorConstruction is not defined!");
738 return;
739 }
740
741 if(verboseLevel > 1)
742 G4cout << "userDetector->Construct() start." << G4endl;
743
745 G4ApplicationState currentState = stateManager->GetCurrentState();
746 if(currentState == G4State_PreInit || currentState == G4State_Idle)
747 {
748 stateManager->SetNewState(G4State_Init);
749 }
751 {
757 }
758 // Notify the VisManager as well
760 {
762 if(pVVisManager)
763 pVVisManager->GeometryHasChanged();
764 }
765
767 geometryInitialized = true;
768 stateManager->SetNewState(currentState);
769}
void SetNumberOfParallelWorld(G4int i)
virtual G4VPhysicalVolume * Construct()=0
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0
G4bool IsMasterThread()
Definition: G4Threading.cc:124

Referenced by Initialize().

◆ InitializePhysics()

void G4RunManager::InitializePhysics ( )
virtual

Definition at line 771 of file G4RunManager.cc.

772{
774 G4ApplicationState currentState = stateManager->GetCurrentState();
775 if(currentState == G4State_PreInit || currentState == G4State_Idle)
776 {
777 stateManager->SetNewState(G4State_Init);
778 }
779 if(physicsList)
780 {
782 }
783 else
784 {
785 G4Exception("G4RunManager::InitializePhysics()", "Run0034", FatalException,
786 "G4VUserPhysicsList is not defined!");
787 }
788 physicsInitialized = true;
789 stateManager->SetNewState(currentState);
790}

Referenced by Initialize().

◆ PhysicsHasBeenModified()

void G4RunManager::PhysicsHasBeenModified ( )
inline

Definition at line 569 of file G4RunManager.hh.

Referenced by G4RunMessenger::SetNewValue().

◆ ProcessOneEvent()

void G4RunManager::ProcessOneEvent ( G4int  i_event)
virtual

Reimplemented in G4MTRunManager, G4WorkerRunManager, G4TaskRunManager, and G4WorkerTaskRunManager.

Definition at line 507 of file G4RunManager.cc.

508{
509 currentEvent = GenerateEvent(i_event);
513 if(i_event < n_select_msg)
515}
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 1171 of file G4RunManager.cc.

1172{
1173 if(destroyFirst && G4Threading::IsMasterThread())
1174 {
1175 if(verboseLevel > 0)
1176 {
1177 G4cout << "#### Assemblies, Volumes and Solids Stores are wiped out."
1178 << G4endl;
1179 }
1185
1186 // remove all logical volume pointers from regions
1187 // exception: world logical volume pointer must be kept
1189 std::vector<G4Region*>::iterator rItr;
1190 for(rItr = regionStore->begin(); rItr != regionStore->end(); rItr++)
1191 {
1192 if((*rItr)->GetName() == "DefaultRegionForTheWorld")
1193 continue;
1194 // if((*rItr)->GetName()=="DefaultRegionForParallelWorld") continue;
1195 std::vector<G4LogicalVolume*>::iterator lvItr =
1196 (*rItr)->GetRootLogicalVolumeIterator();
1197 for(size_t iRLV = 0; iRLV < (*rItr)->GetNumberOfRootVolumes(); iRLV++)
1198 {
1199 (*rItr)->RemoveRootLogicalVolume(*lvItr, false);
1200 lvItr++;
1201 }
1202 if(verboseLevel > 0)
1203 {
1204 G4cout << "#### Region <" << (*rItr)->GetName() << "> is cleared."
1205 << G4endl;
1206 }
1207 }
1208
1209 // clear transportation manager
1212 }
1213 if(prop)
1214 {
1215 G4UImanager::GetUIpointer()->ApplyCommand("/run/reinitializeGeometry");
1216 }
1217 else
1218 {
1220 geometryInitialized = false;
1221 // Notify the VisManager as well
1223 {
1225 if(pVVisManager)
1226 pVVisManager->GeometryHasChanged();
1227 }
1228 }
1229}
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:68
static G4SolidStore * GetInstance()

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

◆ ReOptimize()

void G4RunManager::ReOptimize ( G4LogicalVolume pLog)

Definition at line 1056 of file G4RunManager.cc.

1057{
1058 G4Timer localtimer;
1059 if(verboseLevel > 1)
1060 {
1061 localtimer.Start();
1062 }
1063 G4SmartVoxelHeader* header = pLog->GetVoxelHeader();
1064 delete header;
1065 header = new G4SmartVoxelHeader(pLog);
1066 pLog->SetVoxelHeader(header);
1067 if(verboseLevel > 1)
1068 {
1069 localtimer.Stop();
1070 G4SmartVoxelStat stat(pLog, header, localtimer.GetSystemElapsed(),
1071 localtimer.GetUserElapsed());
1072 G4cout << G4endl << "Voxelisation of logical volume <" << pLog->GetName()
1073 << ">" << G4endl;
1074 G4cout << " heads : " << stat.GetNumberHeads()
1075 << " - nodes : " << stat.GetNumberNodes()
1076 << " - pointers : " << stat.GetNumberPointers() << G4endl;
1077 G4cout << " Memory used : " << (stat.GetMemoryUse() + 512) / 1024
1078 << "k - total time : " << stat.GetTotalTime()
1079 << " - system time : " << stat.GetSysTime() << G4endl;
1080 }
1081}
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

Referenced by ReOptimizeMotherOf().

◆ ReOptimizeMotherOf()

void G4RunManager::ReOptimizeMotherOf ( G4VPhysicalVolume pPhys)

Definition at line 1049 of file G4RunManager.cc.

1050{
1051 G4LogicalVolume* pMotherL = pPhys->GetMotherLogical();
1052 if(pMotherL)
1053 ReOptimize(pMotherL);
1054}
void ReOptimize(G4LogicalVolume *)
G4LogicalVolume * GetMotherLogical() const

◆ RestoreRandomNumberStatus()

void G4RunManager::RestoreRandomNumberStatus ( const G4String fileN)
virtual

Definition at line 901 of file G4RunManager.cc.

902{
903 G4String fileNameWithDirectory;
904 if(fileN.index("/") == std::string::npos)
905 {
906 fileNameWithDirectory = randomNumberStatusDir + fileN;
907 }
908 else
909 {
910 fileNameWithDirectory = fileN;
911 }
912
913 G4Random::restoreEngineStatus(fileNameWithDirectory);
914 if(verboseLevel > 0)
915 G4cout << "RandomNumberEngineStatus restored from file: "
916 << fileNameWithDirectory << G4endl;
917 G4Random::showEngineStatus();
918}
str_size index(const char *, G4int pos=0) const

Referenced by G4RunMessenger::SetNewValue().

◆ RestoreRndmEachEvent()

virtual void G4RunManager::RestoreRndmEachEvent ( G4bool  )
inlinevirtual

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 700 of file G4RunManager.hh.

701 { /*No effect in SEQ */
702 }

Referenced by G4RunMessenger::SetNewValue().

◆ rndmSaveThisEvent()

void G4RunManager::rndmSaveThisEvent ( )
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 863 of file G4RunManager.cc.

864{
865 if(currentEvent == 0)
866 {
867 G4cerr
868 << "Warning from G4RunManager::rndmSaveThisEvent():"
869 << " there is no currentEvent available."
870 << G4endl << "Command ignored." << G4endl;
871 return;
872 }
873
875 {
876 G4cerr
877 << "Warning from G4RunManager::rndmSaveThisEvent():"
878 << " Random number engine status is not available."
879 << G4endl << "/random/setSavingFlag command must be issued "
880 << "prior to the start of the run. Command ignored." << G4endl;
881 return;
882 }
883
884 G4String fileIn = randomNumberStatusDir + "currentEvent.rndm";
885
886 std::ostringstream os;
887 os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID()
888 << ".rndm" << '\0';
889 G4String fileOut = randomNumberStatusDir + os.str();
890
891#ifdef WIN32
892 G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
893#else
894 G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
895#endif
897 if(verboseLevel > 0)
898 { G4cout << fileIn << " is copied to " << fileOut << G4endl; }
899}

Referenced by G4RunMessenger::SetNewValue().

◆ rndmSaveThisRun()

void G4RunManager::rndmSaveThisRun ( )
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 834 of file G4RunManager.cc.

835{
836 G4int runNumber = 0;
837 if(currentRun) runNumber = currentRun->GetRunID();
839 {
840 G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
841 << " Random number status was not stored prior to this run."
842 << G4endl << "/random/setSavingFlag command must be issued. "
843 << "Command ignored." << G4endl;
844 return;
845 }
846
847 G4String fileIn = randomNumberStatusDir + "currentRun.rndm";
848
849 std::ostringstream os;
850 os << "run" << runNumber << ".rndm" << '\0';
851 G4String fileOut = randomNumberStatusDir + os.str();
852
853#ifdef WIN32
854 G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
855#else
856 G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
857#endif
859 if(verboseLevel > 0)
860 { G4cout << fileIn << " is copied to " << fileOut << G4endl; }
861}

Referenced by G4RunMessenger::SetNewValue().

◆ RunInitialization()

void G4RunManager::RunInitialization ( )
virtual

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 383 of file G4RunManager.cc.

384{
386 return;
387
388 runAborted = false;
390
392 if(currentRun)
393 delete currentRun;
394 currentRun = 0;
395
396 if(fakeRun)
397 return;
398
401
402 if(userRunAction)
404 if(!currentRun)
405 currentRun = new G4Run();
406
409
412 if(fSDM)
413 {
415 }
416
418 {
419 auto hce = fSDM->PrepareNewEvent();
421 delete hce;
422 }
423
424 std::ostringstream oss;
425 G4Random::saveFullState(oss);
428
429 for(G4int i_prev = 0; i_prev < n_perviousEventsToBeStored; i_prev++)
430 {
431 previousEvents->push_back((G4Event*) 0);
432 }
433
434 if(printModulo >= 0 || verboseLevel > 0)
435 {
436 G4cout << "### Run " << currentRun->GetRunID() << " starts." << G4endl;
437 }
438 if(userRunAction)
440
441#if defined(GEANT4_USE_TIMEMORY)
442 masterRunProfiler.reset(new ProfilerConfig(currentRun));
443#endif
444
446 {
448 }
449
451 {
452 G4String fileN = "currentRun";
454 {
455 std::ostringstream os;
456 os << "run" << currentRun->GetRunID();
457 fileN = os.str();
458 }
459 StoreRNGStatus(fileN);
460 }
461}
static G4ParallelWorldProcessStore * GetInstance()
G4bool RunInitialization(G4bool fakeRun=false)
G4ProfilerConfig< G4ProfileType::Run > ProfilerConfig
Definition: G4Run.hh:49
void SetHCtable(G4HCtable *HCtbl)
Definition: G4Run.hh:106
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition: G4Run.hh:102
void SetRunID(G4int id)
Definition: G4Run.hh:101
void SetDCtable(G4DCtable *DCtbl)
Definition: G4Run.hh:107
void SetRandomNumberStatus(G4String &st)
Definition: G4Run.hh:108
G4HCofThisEvent * PrepareNewEvent()
Definition: G4SDManager.cc:109
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:48
G4HCtable * GetHCtable() const
Definition: G4SDManager.hh:103
virtual void BeginOfRunAction(const G4Run *aRun)
virtual G4Run * GenerateRun()
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0

Referenced by BeamOn().

◆ RunTermination()

void G4RunManager::RunTermination ( )
virtual

Reimplemented in G4MTRunManager, G4WorkerRunManager, G4TaskRunManager, and G4WorkerTaskRunManager.

Definition at line 603 of file G4RunManager.cc.

604{
605 if(!fakeRun)
606 {
607#if defined(GEANT4_USE_TIMEMORY)
608 masterRunProfiler.reset();
609#endif
611 // tasking occasionally will call this function even
612 // if there was not a current run
613 if(currentRun)
614 {
615 if(userRunAction)
617 G4VPersistencyManager* fPersM =
619 if(fPersM)
620 fPersM->Store(currentRun);
621 // write & close analysis output
623 {
625 }
626 }
627 runIDCounter++;
628 }
629
631}
void CleanUpUnnecessaryEvents(G4int keepNEvents)
virtual void EndOfRunAction(const G4Run *aRun)
virtual void Write()=0

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

◆ SetDCtable()

void G4RunManager::SetDCtable ( G4DCtable DCtbl)
inline

Definition at line 669 of file G4RunManager.hh.

669{ DCtable = DCtbl; }

Referenced by G4DigiManager::AddNewModule().

◆ SetGeometryToBeOptimized()

void G4RunManager::SetGeometryToBeOptimized ( G4bool  vl)
inline

Definition at line 603 of file G4RunManager.hh.

604 {
605 if(geometryToBeOptimized != vl)
606 {
610 }
611 }
void SetGeometryToBeOptimized(G4bool vl)

Referenced by G4RunMessenger::SetNewValue().

◆ SetNumberOfAdditionalWaitingStacks()

void G4RunManager::SetNumberOfAdditionalWaitingStacks ( G4int  iAdd)
inline

Definition at line 459 of file G4RunManager.hh.

460 {
462 }
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)

◆ SetNumberOfEventsToBeProcessed()

void G4RunManager::SetNumberOfEventsToBeProcessed ( G4int  val)
inline

Definition at line 659 of file G4RunManager.hh.

660 {
662 }

◆ SetNumberOfEventsToBeStored()

void G4RunManager::SetNumberOfEventsToBeStored ( G4int  val)
inline

Definition at line 615 of file G4RunManager.hh.

616 {
618 }

◆ SetNumberOfThreads()

virtual void G4RunManager::SetNumberOfThreads ( G4int  )
inlinevirtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 282 of file G4RunManager.hh.

282{}

◆ SetPrimaryTransformer()

void G4RunManager::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inline

Definition at line 473 of file G4RunManager.hh.

474 {
476 }
void SetPrimaryTransformer(G4PrimaryTransformer *pt)

◆ SetPrintProgress()

void G4RunManager::SetPrintProgress ( G4int  i)
inline

Definition at line 601 of file G4RunManager.hh.

601{ printModulo = i; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStore()

void G4RunManager::SetRandomNumberStore ( G4bool  flag)
inline

Definition at line 493 of file G4RunManager.hh.

494 {
496 }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStoreDir()

void G4RunManager::SetRandomNumberStoreDir ( const G4String dir)
inline

Definition at line 498 of file G4RunManager.hh.

499 {
500 G4String dirStr = dir;
501 if(dirStr(dirStr.length() - 1) != '/')
502 dirStr += "/";
503#ifndef WIN32
504 G4String shellCmd = "mkdir -p ";
505#else
506 std::replace(dirStr.begin(), dirStr.end(), '/', '\\');
507 G4String shellCmd = "if not exist " + dirStr + " mkdir ";
508#endif
509 shellCmd += dirStr;
510 randomNumberStatusDir = dirStr;
511 G4int sysret = system(shellCmd);
512 if(sysret != 0)
513 {
514 G4String errmsg = "\"" + shellCmd +
515 "\" returns non-zero value. Directory creation failed.";
516 G4Exception("GrRunManager::SetRandomNumberStoreDir", "Run0071",
517 JustWarning, errmsg);
518 G4cerr << " return value = " << sysret << G4endl;
519 }
520 }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStorePerEvent()

void G4RunManager::SetRandomNumberStorePerEvent ( G4bool  flag)
inline

Definition at line 540 of file G4RunManager.hh.

541 {
542 rngStatusEventsFlag = flag;
543 }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRunIDCounter()

void G4RunManager::SetRunIDCounter ( G4int  i)
inline

Definition at line 652 of file G4RunManager.hh.

652{ 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 1128 of file G4RunManager.cc.

1129{
1130 eventManager->SetUserAction(userAction);
1131 userEventAction = userAction;
1132}
void SetUserAction(G4UserEventAction *userAction)

◆ SetUserAction() [2/6]

void G4RunManager::SetUserAction ( G4UserRunAction userAction)
virtual

◆ SetUserAction() [3/6]

void G4RunManager::SetUserAction ( G4UserStackingAction userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1134 of file G4RunManager.cc.

1135{
1136 eventManager->SetUserAction(userAction);
1137 userStackingAction = userAction;
1138}

◆ SetUserAction() [4/6]

void G4RunManager::SetUserAction ( G4UserSteppingAction userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1146 of file G4RunManager.cc.

1147{
1148 eventManager->SetUserAction(userAction);
1149 userSteppingAction = userAction;
1150}

◆ SetUserAction() [5/6]

void G4RunManager::SetUserAction ( G4UserTrackingAction userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1140 of file G4RunManager.cc.

1141{
1142 eventManager->SetUserAction(userAction);
1143 userTrackingAction = userAction;
1144}

◆ SetUserAction() [6/6]

void G4RunManager::SetUserAction ( G4VUserPrimaryGeneratorAction userAction)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1123 of file G4RunManager.cc.

1124{
1125 userPrimaryGeneratorAction = userAction;
1126}

◆ SetUserInitialization() [1/5]

void G4RunManager::SetUserInitialization ( G4UserWorkerInitialization userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1094 of file G4RunManager.cc.

1096{
1098 "G4RunManager::SetUserInitialization()", "Run3001", FatalException,
1099 "Base-class G4RunManager cannot take G4UserWorkerInitialization. Use "
1100 "G4MTRunManager.");
1101}

◆ SetUserInitialization() [2/5]

void G4RunManager::SetUserInitialization ( G4UserWorkerThreadInitialization userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1103 of file G4RunManager.cc.

1105{
1107 "G4RunManager::SetUserThreadInitialization()", "Run3001", FatalException,
1108 "Base-class G4RunManager cannot take G4UserWorkerThreadInitialization. "
1109 "Use G4MTRunManager.");
1110}

◆ SetUserInitialization() [3/5]

void G4RunManager::SetUserInitialization ( G4VUserActionInitialization userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1112 of file G4RunManager.cc.

1113{
1114 userActionInitialization = userInit;
1116}
virtual void Build() const =0

◆ SetUserInitialization() [4/5]

void G4RunManager::SetUserInitialization ( G4VUserDetectorConstruction userInit)
virtual

Reimplemented in G4MTRunManager, and G4WorkerRunManager.

Definition at line 1083 of file G4RunManager.cc.

1084{
1085 userDetector = userInit;
1086}

Referenced by G4WorkerRunManager::SetUserInitialization(), and G4MTRunManager::SetUserInitialization().

◆ SetUserInitialization() [5/5]

void G4RunManager::SetUserInitialization ( G4VUserPhysicsList userInit)
virtual

Reimplemented in G4WorkerRunManager, and G4MTRunManager.

Definition at line 1088 of file G4RunManager.cc.

1089{
1090 physicsList = userInit;
1091 kernel->SetPhysics(userInit);
1092}
void SetPhysics(G4VUserPhysicsList *uPhys)

◆ SetVerboseLevel()

void G4RunManager::SetVerboseLevel ( G4int  vl)
inline

Definition at line 594 of file G4RunManager.hh.

595 {
596 verboseLevel = vl;
598 }
void SetVerboseLevel(G4int vl)

Referenced by G4RunMessenger::SetNewValue().

◆ StackPreviousEvent()

void G4RunManager::StackPreviousEvent ( G4Event anEvent)
protected

Definition at line 688 of file G4RunManager.cc.

689{
690 if(anEvent->ToBeKept())
691 currentRun->StoreEvent(anEvent);
692
694 {
695 if(anEvent->GetNumberOfGrips() == 0)
696 {
697 if(!(anEvent->ToBeKept()))
698 delete anEvent;
699 }
700 else
701 {
702 previousEvents->push_back(anEvent);
703 }
704 }
705
707}
void StoreEvent(G4Event *evt)
Definition: G4Run.cc:74

Referenced by TerminateOneEvent().

◆ StoreRandomNumberStatusToG4Event()

void G4RunManager::StoreRandomNumberStatusToG4Event ( G4int  vl)
inline

Definition at line 478 of file G4RunManager.hh.

Referenced by G4RunMessenger::SetNewValue().

◆ StoreRNGStatus()

void G4RunManager::StoreRNGStatus ( const G4String filenamePrefix)
protectedvirtual

Reimplemented in G4MTRunManager, G4WorkerRunManager, G4TaskRunManager, and G4WorkerTaskRunManager.

Definition at line 588 of file G4RunManager.cc.

589{
590 G4String fileN = randomNumberStatusDir + fnpref + ".rndm";
591 G4Random::saveEngineStatus(fileN);
592}

Referenced by GenerateEvent(), and RunInitialization().

◆ TerminateEventLoop()

void G4RunManager::TerminateEventLoop ( )
virtual

G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();

Reimplemented in G4WorkerRunManager, and G4WorkerTaskRunManager.

Definition at line 524 of file G4RunManager.cc.

525{
526 if(verboseLevel > 0 && !fakeRun)
527 {
528 timer->Stop();
529 G4cout << " Run terminated." << G4endl;
530 G4cout << "Run Summary" << G4endl;
531 if(runAborted)
532 {
533 G4cout << " Run Aborted after " << numberOfEventProcessed
534 << " events processed." << G4endl;
535 }
536 else
537 {
538 G4cout << " Number of events processed : " << numberOfEventProcessed
539 << G4endl;
540 }
541 G4cout << " " << *timer << G4endl;
542 }
543 ////////////////
544 /// G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();
546}

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

◆ TerminateOneEvent()

void G4RunManager::TerminateOneEvent ( )
virtual

Reimplemented in G4MTRunManager, and G4TaskRunManager.

Definition at line 517 of file G4RunManager.cc.

518{
520 currentEvent = 0;
522}
void StackPreviousEvent(G4Event *anEvent)

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

◆ UpdateScoring()

void G4RunManager::UpdateScoring ( )
protected

Definition at line 1017 of file G4RunManager.cc.

1018{
1020 {
1023 }
1024
1026 if(!ScM)
1027 return;
1028 G4int nPar = ScM->GetNumberOfMesh();
1029 if(nPar < 1)
1030 return;
1031
1033 if(!HCE)
1034 return;
1035 G4int nColl = HCE->GetCapacity();
1036 for(G4int i = 0; i < nColl; i++)
1037 {
1038 G4VHitsCollection* HC = HCE->GetHC(i);
1039 if(HC)
1040 ScM->Accumulate(HC);
1041 }
1042}
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:156
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 Function Documentation

◆ G4RunManagerFactory

friend class G4RunManagerFactory
friend

Definition at line 143 of file G4RunManager.hh.

Member Data Documentation

◆ currentEvent

◆ currentRun

◆ currentWorld

G4VPhysicalVolume* G4RunManager::currentWorld
protected

Definition at line 364 of file G4RunManager.hh.

◆ DCtable

◆ eventManager

◆ fakeRun

◆ fGeometryHasBeenDestroyed

◆ geometryDirectlyUpdated

G4bool G4RunManager::geometryDirectlyUpdated
protected

Definition at line 705 of file G4RunManager.hh.

Referenced by GeometryDirectlyUpdated(), and InitializeGeometry().

◆ geometryInitialized

G4bool G4RunManager::geometryInitialized
protected

◆ geometryToBeOptimized

G4bool G4RunManager::geometryToBeOptimized
protected

Definition at line 342 of file G4RunManager.hh.

Referenced by GetGeometryToBeOptimized(), and SetGeometryToBeOptimized().

◆ initializedAtLeastOnce

G4bool G4RunManager::initializedAtLeastOnce
protected

Definition at line 341 of file G4RunManager.hh.

Referenced by ConfirmBeamOnCondition(), and Initialize().

◆ isScoreNtupleWriter

G4bool G4RunManager::isScoreNtupleWriter
protected

◆ kernel

◆ msgText

◆ n_perviousEventsToBeStored

◆ n_select_msg

◆ nParallelWorlds

G4int G4RunManager::nParallelWorlds
protected

Definition at line 366 of file G4RunManager.hh.

Referenced by GetNumberOfParallelWorld(), and InitializeGeometry().

◆ numberOfEventProcessed

◆ numberOfEventToBeProcessed

◆ physicsInitialized

G4bool G4RunManager::physicsInitialized
protected

Definition at line 339 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 675 of file G4RunManager.hh.

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

◆ selectMacro

G4String G4RunManager::selectMacro
protected

◆ storeRandomNumberStatus

◆ storeRandomNumberStatusToG4Event

◆ timer

◆ userActionInitialization

◆ userDetector

◆ userEventAction

G4UserEventAction* G4RunManager::userEventAction
protected

Definition at line 329 of file G4RunManager.hh.

Referenced by GetUserEventAction(), and SetUserAction().

◆ userPrimaryGeneratorAction

◆ userRunAction

◆ userStackingAction

G4UserStackingAction* G4RunManager::userStackingAction
protected

Definition at line 330 of file G4RunManager.hh.

Referenced by GetUserStackingAction(), and SetUserAction().

◆ userSteppingAction

G4UserSteppingAction* G4RunManager::userSteppingAction
protected

Definition at line 332 of file G4RunManager.hh.

Referenced by GetUserSteppingAction(), and SetUserAction().

◆ userTrackingAction

G4UserTrackingAction* G4RunManager::userTrackingAction
protected

Definition at line 331 of file G4RunManager.hh.

Referenced by GetUserTrackingAction(), and SetUserAction().

◆ userWorkerInitialization

◆ userWorkerThreadInitialization

◆ verboseLevel


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