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

#include <G4RunManager.hh>

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)
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=0) const
 
virtual void rndmSaveThisRun ()
 
virtual void rndmSaveThisEvent ()
 
virtual void RestoreRandomNumberStatus (const G4String &fileN)
 
void SetUserInitialization (G4VUserDetectorConstruction *userInit)
 
void SetUserInitialization (G4VUserPhysicsList *userInit)
 
void SetUserAction (G4UserRunAction *userAction)
 
void SetUserAction (G4VUserPrimaryGeneratorAction *userAction)
 
void SetUserAction (G4UserEventAction *userAction)
 
void SetUserAction (G4UserStackingAction *userAction)
 
void SetUserAction (G4UserTrackingAction *userAction)
 
void SetUserAction (G4UserSteppingAction *userAction)
 
const G4VUserDetectorConstructionGetUserDetectorConstruction () const
 
const G4VUserPhysicsListGetUserPhysicsList () 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 GeometryHasBeenModified ()
 
void PhysicsHasBeenModified ()
 
void CutOffHasBeenModified ()
 
void ReOptimizeMotherOf (G4VPhysicalVolume *)
 
void ReOptimize (G4LogicalVolume *)
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
void SetGeometryToBeOptimized (G4bool vl)
 
G4bool GetGeometryToBeOptimized ()
 
void SetNumberOfEventsToBeStored (G4int val)
 
const G4RunGetCurrentRun () const
 
const G4EventGetCurrentEvent () const
 
const G4EventGetPreviousEvent (G4int i) const
 
void SetRunIDCounter (G4int i)
 
G4int GetNumberOfParallelWorld () const
 
void SetNumberOfEventsToBeProcessed (G4int val)
 
void SetDCtable (G4DCtable *DCtbl)
 
void ConstructScoringWorlds ()
 

Static Public Member Functions

static G4RunManagerGetRunManager ()
 

Protected Member Functions

void StackPreviousEvent (G4Event *anEvent)
 
void UpdateScoring ()
 

Protected Attributes

G4RunManagerKernelkernel
 
G4EventManagereventManager
 
G4VUserDetectorConstructionuserDetector
 
G4VUserPhysicsListphysicsList
 
G4UserRunActionuserRunAction
 
G4VUserPrimaryGeneratorActionuserPrimaryGeneratorAction
 
G4UserEventActionuserEventAction
 
G4UserStackingActionuserStackingAction
 
G4UserTrackingActionuserTrackingAction
 
G4UserSteppingActionuserSteppingAction
 
G4bool geometryInitialized
 
G4bool physicsInitialized
 
G4bool runAborted
 
G4bool initializedAtLeastOnce
 
G4bool geometryToBeOptimized
 
G4int runIDCounter
 
G4int verboseLevel
 
G4Timertimer
 
G4DCtableDCtable
 
G4RuncurrentRun
 
G4EventcurrentEvent
 
std::vector< G4Event * > * previousEvents
 
G4int n_perviousEventsToBeStored
 
G4int numberOfEventToBeProcessed
 
G4bool storeRandomNumberStatus
 
G4int storeRandomNumberStatusToG4Event
 
G4String randomNumberStatusDir
 
G4String randomNumberStatusForThisRun
 
G4String randomNumberStatusForThisEvent
 
G4VPhysicalVolumecurrentWorld
 
G4int nParallelWorlds
 
G4String msgText
 
G4int n_select_msg
 
G4int numberOfEventProcessed
 

Detailed Description

Definition at line 96 of file G4RunManager.hh.

Constructor & Destructor Documentation

◆ G4RunManager()

G4RunManager::G4RunManager ( )

Definition at line 65 of file G4RunManager.cc.

77{
78 if(fRunManager)
79 {
80 G4Exception("G4RunManager::G4RunManager()", "Run0031",
81 FatalException, "G4RunManager constructed twice.");
82 }
83 fRunManager = this;
84
87
88 timer = new G4Timer();
89 runMessenger = new G4RunMessenger(this);
90 previousEvents = new std::vector<G4Event*>;
94 std::ostringstream oss;
98}
@ FatalException
static std::ostream & saveFullState(std::ostream &os)
Definition: Random.cc:185
static G4ParticleTable * GetParticleTable()
G4UImessenger * CreateMessenger()
static G4ProcessTable * GetProcessTable()
G4UImessenger * CreateMessenger()
G4EventManager * GetEventManager() const
G4bool geometryInitialized
G4int storeRandomNumberStatusToG4Event
G4int nParallelWorlds
G4Timer * timer
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 physicsInitialized
G4VPhysicalVolume * currentWorld
G4VUserDetectorConstruction * userDetector
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
G4int numberOfEventToBeProcessed
G4String randomNumberStatusDir
G4String randomNumberStatusForThisEvent
G4UserTrackingAction * userTrackingAction
G4int n_perviousEventsToBeStored
G4bool storeRandomNumberStatus
G4bool initializedAtLeastOnce
G4EventManager * eventManager
G4VUserPhysicsList * physicsList
G4UserStackingAction * userStackingAction
G4Event * currentEvent
std::vector< G4Event * > * previousEvents
G4UserSteppingAction * userSteppingAction
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ ~G4RunManager()

G4RunManager::~G4RunManager ( )
virtual

Definition at line 100 of file G4RunManager.cc.

101{
103 // set the application state to the quite state
104 if(pStateManager->GetCurrentState()!=G4State_Quit)
105 {
106 if(verboseLevel>0) G4cout << "G4 kernel has come to Quit state." << G4endl;
107 pStateManager->SetNewState(G4State_Quit);
108 }
109
110 if(currentRun) delete currentRun;
111 delete timer;
112 delete runMessenger;
115 delete previousEvents;
116 if(userDetector)
117 {
118 delete userDetector;
119 userDetector = 0;
120 if(verboseLevel>1) G4cout << "UserDetectorConstruction deleted." << G4endl;
121 }
122 if(physicsList)
123 {
124 delete physicsList;
125 physicsList = 0;
126 if(verboseLevel>1) G4cout << "UserPhysicsList deleted." << G4endl;
127 }
128 if(userRunAction)
129 {
130 delete userRunAction;
131 userRunAction = 0;
132 if(verboseLevel>1) G4cout << "UserRunAction deleted." << G4endl;
133 }
135 {
138 if(verboseLevel>1) G4cout << "UserPrimaryGenerator deleted." << G4endl;
139 }
140
141 delete kernel;
142
143 if(verboseLevel>1) G4cout << "RunManager is deleted." << G4endl;
144 fRunManager = 0;
145}
@ G4State_Quit
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4ApplicationState GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool SetNewState(G4ApplicationState requestedState)

Member Function Documentation

◆ AbortEvent()

void G4RunManager::AbortEvent ( )
virtual

Definition at line 429 of file G4RunManager.cc.

430{
431 // This method is valid only for EventProc state
432 G4ApplicationState currentState =
434 if(currentState==G4State_EventProc)
435 {
438 }
439 else
440 {
441 G4cerr << "Event is not in progress. AbortEevnt() ignored." << G4endl;
442 }
443}
G4ApplicationState
@ G4State_EventProc
G4DLLIMPORT std::ostream G4cerr
void AbortCurrentEvent()
void SetEventAborted()
Definition: G4Event.hh:121

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

◆ AbortRun()

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

Definition at line 409 of file G4RunManager.cc.

410{
411 // This method is valid only for GeomClosed or EventProc state
412 G4ApplicationState currentState =
414 if(currentState==G4State_GeomClosed || currentState==G4State_EventProc)
415 {
416 runAborted = true;
417 if(currentState==G4State_EventProc && !softAbort)
418 {
421 }
422 }
423 else
424 {
425 G4cerr << "Run is not in progress. AbortRun() ignored." << G4endl;
426 }
427}
@ G4State_GeomClosed

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

◆ AnalyzeEvent()

void G4RunManager::AnalyzeEvent ( G4Event anEvent)
virtual

Definition at line 320 of file G4RunManager.cc.

321{
323 if(fPersM) fPersM->Store(anEvent);
324 currentRun->RecordEvent(anEvent);
325}
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:45
static G4VPersistencyManager * GetPersistencyManager()
virtual G4bool Store(const G4Event *anEvent)=0

Referenced by ProcessOneEvent().

◆ BeamOn()

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

Definition at line 147 of file G4RunManager.cc.

148{
150 if(cond)
151 {
155 if(n_event>0) DoEventLoop(n_event,macroFile,n_select);
157 }
158}
bool G4bool
Definition: G4Types.hh:67
virtual void DoEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual G4bool ConfirmBeamOnCondition()
virtual void RunTermination()
virtual void RunInitialization()
void ConstructScoringWorlds()

Referenced by G4AdjointSimManager::RunAdjointSimulation(), and G4RunMessenger::SetNewValue().

◆ ConfirmBeamOnCondition()

G4bool G4RunManager::ConfirmBeamOnCondition ( )
virtual

Definition at line 160 of file G4RunManager.cc.

161{
163
164 G4ApplicationState currentState = stateManager->GetCurrentState();
165 if(currentState!=G4State_PreInit && currentState!=G4State_Idle)
166 {
167 G4cerr << "Illegal application state - BeamOn() ignored." << G4endl;
168 return false;
169 }
170
172 {
173 G4cerr << " Geant4 kernel should be initialized" << G4endl;
174 G4cerr << "before the first BeamOn(). - BeamOn ignored." << G4endl;
175 return false;
176 }
177
179 {
180 if(verboseLevel>0)
181 {
182 G4cout << "Start re-initialization because " << G4endl;
183 if(!geometryInitialized) G4cout << " Geometry" << G4endl;
184 if(!physicsInitialized) G4cout << " Physics processes" << G4endl;
185 G4cout << "has been modified since last Run." << G4endl;
186 }
187 Initialize();
188 }
189 return true;
190}
@ G4State_Idle
@ G4State_PreInit
virtual void Initialize()

Referenced by BeamOn().

◆ ConstructScoringWorlds()

void G4RunManager::ConstructScoringWorlds ( )

Definition at line 530 of file G4RunManager.cc.

531{
533 if(!ScM) return;
534 G4int nPar = ScM->GetNumberOfMesh();
535 if(nPar<1) return;
536
537 G4ParticleTable::G4PTblDicIterator* theParticleIterator
539 for(G4int iw=0;iw<nPar;iw++)
540 {
541 G4VScoringMesh* mesh = ScM->GetMesh(iw);
542 G4VPhysicalVolume* pWorld
544 ->IsWorldExisting(ScM->GetWorldName(iw));
545 if(!pWorld)
546 {
548 ->GetParallelWorld(ScM->GetWorldName(iw));
549 pWorld->SetName(ScM->GetWorldName(iw));
550
551 G4ParallelWorldScoringProcess* theParallelWorldScoringProcess
553 theParallelWorldScoringProcess->SetParallelWorld(ScM->GetWorldName(iw));
554
555 theParticleIterator->reset();
556 while( (*theParticleIterator)() ){
557 G4ParticleDefinition* particle = theParticleIterator->value();
558 G4ProcessManager* pmanager = particle->GetProcessManager();
559 if(pmanager)
560 {
561 pmanager->AddProcess(theParallelWorldScoringProcess);
562 if(theParallelWorldScoringProcess->IsAtRestRequired(particle))
563 { pmanager->SetProcessOrdering(theParallelWorldScoringProcess, idxAtRest, 9999); }
564 pmanager->SetProcessOrderingToSecond(theParallelWorldScoringProcess, idxAlongStep);
565 pmanager->SetProcessOrdering(theParallelWorldScoringProcess, idxPostStep, 9999);
566 }
567 }
568 }
569 mesh->Construct(pWorld);
570 }
572}
@ idxPostStep
@ idxAtRest
@ idxAlongStep
int G4int
Definition: G4Types.hh:66
G4bool IsAtRestRequired(G4ParticleDefinition *partDef)
void SetParallelWorld(G4String parallelWorldName)
G4ProcessManager * GetProcessManager() const
G4PTblDicIterator * GetIterator()
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)
void GeometryHasBeenModified()
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)
virtual void Construct(G4VPhysicalVolume *fWorldPhys)=0

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

◆ CutOffHasBeenModified()

void G4RunManager::CutOffHasBeenModified ( )
inline

Definition at line 403 of file G4RunManager.hh.

404 {
405 G4cerr << "CutOffHasBeenModified becomes obsolete." << G4endl;
406 G4cerr << "It is safe to remove invoking this method." << G4endl;
407 }

Referenced by G4RunMessenger::SetNewValue().

◆ DefineWorldVolume()

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

Definition at line 445 of file G4RunManager.cc.

447{
448 kernel->DefineWorldVolume(worldVol,topologyIsChanged);
449}
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)

Referenced by G4GDMLMessenger::SetNewValue().

◆ DoEventLoop()

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

Definition at line 230 of file G4RunManager.cc.

231{
232 InitializeEventLoop(n_event,macroFile,n_select);
233
234// Event loop
235 for(G4int i_event=0; i_event<n_event; i_event++ )
236 {
237 ProcessOneEvent(i_event);
239 if(runAborted) break;
240 }
241
243}
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 508 of file G4RunManager.cc.

509{
510// kernel->UpdateRegion();
511 kernel->DumpRegion(rname);
512}
void DumpRegion(const G4String &rname) const

Referenced by G4RunMessenger::SetNewValue().

◆ DumpRegion() [2/2]

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

Definition at line 514 of file G4RunManager.cc.

515{
516// kernel->UpdateRegion();
517 kernel->DumpRegion(region);
518}

◆ GenerateEvent()

G4Event * G4RunManager::GenerateEvent ( G4int  i_event)
virtual

Definition at line 292 of file G4RunManager.cc.

293{
295 {
296 G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
297 "G4VUserPrimaryGeneratorAction is not defined!");
298 return 0;
299 }
300
301 G4Event* anEvent = new G4Event(i_event);
302
304 {
305 std::ostringstream oss;
309 }
310
312 G4String fileN = randomNumberStatusDir + "currentEvent.rndm";
314 }
315
317 return anEvent;
318}
static void saveEngineStatus(const char filename[]="Config.conf")
Definition: Random.cc:175
void SetRandomNumberStatus(G4String &st)
Definition: G4Event.hh:123
virtual void GeneratePrimaries(G4Event *anEvent)=0

Referenced by ProcessOneEvent().

◆ GeometryHasBeenModified()

void G4RunManager::GeometryHasBeenModified ( )
inline

◆ GetCurrentEvent()

const G4Event * G4RunManager::GetCurrentEvent ( ) const
inline

◆ GetCurrentRun()

const G4Run * G4RunManager::GetCurrentRun ( ) const
inline

◆ GetFlagRandomNumberStatusToG4Event()

G4int G4RunManager::GetFlagRandomNumberStatusToG4Event ( ) const
inline

Definition at line 346 of file G4RunManager.hh.

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetGeometryToBeOptimized()

G4bool G4RunManager::GetGeometryToBeOptimized ( )
inline

Definition at line 436 of file G4RunManager.hh.

437 { return geometryToBeOptimized; }

◆ GetNumberOfParallelWorld()

G4int G4RunManager::GetNumberOfParallelWorld ( ) const
inline

Definition at line 470 of file G4RunManager.hh.

471 { return nParallelWorlds; }

◆ GetPreviousEvent()

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

Definition at line 454 of file G4RunManager.hh.

455 {
456 if(i>=1 && i<=n_perviousEventsToBeStored)
457 { return (*previousEvents)[i-1]; }
458 return 0;
459 }

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

◆ GetRandomNumberStatusForThisEvent()

const G4String & G4RunManager::GetRandomNumberStatusForThisEvent ( ) const
inline

Definition at line 378 of file G4RunManager.hh.

379 {
381 { G4Exception("GrRunManager::SetRandomNumberStoreDir",
382 "Run0072",JustWarning,
383 "Random number status is not available for this event."); }
385 }
@ JustWarning

◆ GetRandomNumberStatusForThisRun()

const G4String & G4RunManager::GetRandomNumberStatusForThisRun ( ) const
inline

Definition at line 376 of file G4RunManager.hh.

◆ GetRandomNumberStore()

G4bool G4RunManager::GetRandomNumberStore ( ) const
inline

Definition at line 352 of file G4RunManager.hh.

353 { return storeRandomNumberStatus; }

◆ GetRandomNumberStoreDir()

const G4String & G4RunManager::GetRandomNumberStoreDir ( ) const
inline

Definition at line 374 of file G4RunManager.hh.

375 { return randomNumberStatusDir; }

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetRunManager()

◆ GetUserDetectorConstruction()

const G4VUserDetectorConstruction * G4RunManager::GetUserDetectorConstruction ( ) const
inline

Definition at line 306 of file G4RunManager.hh.

307 { return userDetector; }

◆ GetUserEventAction()

const G4UserEventAction * G4RunManager::GetUserEventAction ( ) const
inline

Definition at line 314 of file G4RunManager.hh.

315 { return userEventAction; }

◆ GetUserPhysicsList()

const G4VUserPhysicsList * G4RunManager::GetUserPhysicsList ( ) const
inline

Definition at line 308 of file G4RunManager.hh.

309 { return physicsList; }

◆ GetUserPrimaryGeneratorAction()

const G4VUserPrimaryGeneratorAction * G4RunManager::GetUserPrimaryGeneratorAction ( ) const
inline

Definition at line 312 of file G4RunManager.hh.

◆ GetUserRunAction()

const G4UserRunAction * G4RunManager::GetUserRunAction ( ) const
inline

Definition at line 310 of file G4RunManager.hh.

311 { return userRunAction; }

◆ GetUserStackingAction()

const G4UserStackingAction * G4RunManager::GetUserStackingAction ( ) const
inline

Definition at line 316 of file G4RunManager.hh.

317 { return userStackingAction; }

◆ GetUserSteppingAction()

const G4UserSteppingAction * G4RunManager::GetUserSteppingAction ( ) const
inline

Definition at line 320 of file G4RunManager.hh.

321 { return userSteppingAction; }

◆ GetUserTrackingAction()

const G4UserTrackingAction * G4RunManager::GetUserTrackingAction ( ) const
inline

Definition at line 318 of file G4RunManager.hh.

319 { return userTrackingAction; }

◆ GetVerboseLevel()

G4int G4RunManager::GetVerboseLevel ( ) const
inline

Definition at line 424 of file G4RunManager.hh.

425 { return verboseLevel; }

Referenced by G4RunMessenger::GetCurrentValue().

◆ GetVersionString()

const G4String & G4RunManager::GetVersionString ( ) const
inline

Definition at line 331 of file G4RunManager.hh.

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

◆ Initialize()

void G4RunManager::Initialize ( )
virtual

Definition at line 362 of file G4RunManager.cc.

363{
365 G4ApplicationState currentState = stateManager->GetCurrentState();
366 if(currentState!=G4State_PreInit && currentState!=G4State_Idle)
367 {
368 G4cerr << "Illegal application state - "
369 << "G4RunManager::Initialize() ignored." << G4endl;
370 return;
371 }
372
376}
virtual void InitializePhysics()
virtual void InitializeGeometry()

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

◆ InitializeEventLoop()

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

Definition at line 245 of file G4RunManager.cc.

246{
247 if(verboseLevel>0)
248 { timer->Start(); }
249
250 n_select_msg = n_select;
251 if(macroFile!=0)
252 {
253 if(n_select_msg<0) n_select_msg = n_event;
254 msgText = "/control/execute ";
255 msgText += macroFile;
256 }
257 else
258 { n_select_msg = -1; }
259}
void Start()

Referenced by DoEventLoop().

◆ InitializeGeometry()

void G4RunManager::InitializeGeometry ( )
virtual

Definition at line 378 of file G4RunManager.cc.

379{
380 if(!userDetector)
381 {
382 G4Exception("G4RunManager::InitializeGeometry", "Run0033",
383 FatalException, "G4VUserDetectorConstruction is not defined!");
384 return;
385 }
386
387 if(verboseLevel>1) G4cout << "userDetector->Construct() start." << G4endl;
391 geometryInitialized = true;
392}
void SetNumberOfParallelWorld(G4int i)
virtual G4VPhysicalVolume * Construct()=0

Referenced by Initialize().

◆ InitializePhysics()

void G4RunManager::InitializePhysics ( )
virtual

Definition at line 394 of file G4RunManager.cc.

395{
396 if(physicsList)
397 {
398 if(verboseLevel>1) G4cout << "physicsList->Construct() start." << G4endl;
400 }
401 else
402 {
403 G4Exception("G4RunManager::InitializePhysics()", "Run0034",
404 FatalException, "G4VUserPhysicsList is not defined!");
405 }
406 physicsInitialized = true;
407}

Referenced by Initialize().

◆ PhysicsHasBeenModified()

void G4RunManager::PhysicsHasBeenModified ( )
inline

Definition at line 395 of file G4RunManager.hh.

Referenced by G4RunMessenger::SetNewValue().

◆ ProcessOneEvent()

void G4RunManager::ProcessOneEvent ( G4int  i_event)
virtual

Definition at line 261 of file G4RunManager.cc.

262{
263 currentEvent = GenerateEvent(i_event);
268}
void ProcessOneEvent(G4Event *anEvent)
virtual G4Event * GenerateEvent(G4int i_event)
virtual void AnalyzeEvent(G4Event *anEvent)
void UpdateScoring()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:369
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51

Referenced by DoEventLoop().

◆ ReOptimize()

void G4RunManager::ReOptimize ( G4LogicalVolume pLog)

Definition at line 601 of file G4RunManager.cc.

602{
603 G4SmartVoxelHeader* header = pLog->GetVoxelHeader();
604 delete header;
605 header = new G4SmartVoxelHeader(pLog);
606 pLog->SetVoxelHeader(header);
607}
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
G4SmartVoxelHeader * GetVoxelHeader() const

Referenced by ReOptimizeMotherOf().

◆ ReOptimizeMotherOf()

void G4RunManager::ReOptimizeMotherOf ( G4VPhysicalVolume pPhys)

Definition at line 595 of file G4RunManager.cc.

596{
597 G4LogicalVolume* pMotherL = pPhys->GetMotherLogical();
598 if(pMotherL) ReOptimize(pMotherL);
599}
void ReOptimize(G4LogicalVolume *)
G4LogicalVolume * GetMotherLogical() const

◆ RestoreRandomNumberStatus()

void G4RunManager::RestoreRandomNumberStatus ( const G4String fileN)
virtual

Definition at line 494 of file G4RunManager.cc.

495{
496 G4String fileNameWithDirectory;
497 if(fileN.index("/")==std::string::npos)
498 { fileNameWithDirectory = randomNumberStatusDir+fileN; }
499 else
500 { fileNameWithDirectory = fileN; }
501
502 HepRandom::restoreEngineStatus(fileNameWithDirectory);
503 if(verboseLevel>0) G4cout << "RandomNumberEngineStatus restored from file: "
504 << fileNameWithDirectory << G4endl;
506}
static void restoreEngineStatus(const char filename[]="Config.conf")
Definition: Random.cc:180
static void showEngineStatus()
Definition: Random.cc:203
str_size index(const char *, G4int pos=0) const

Referenced by G4RunMessenger::SetNewValue().

◆ rndmSaveThisEvent()

void G4RunManager::rndmSaveThisEvent ( )
virtual

Definition at line 473 of file G4RunManager.cc.

474{
476 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
477 << " there is no currentEvent or its RandomEngineStatus is not available."
478 << G4endl << "Command ignored." << G4endl;
479 return;
480 }
481
482 G4String fileIn = randomNumberStatusDir + "currentEvent.rndm";
483
484 std::ostringstream os;
485 os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID()
486 << ".rndm" << '\0';
487 G4String fileOut = randomNumberStatusDir + os.str();
488
489 G4String copCmd = "/control/shell cp "+fileIn+" "+fileOut;
491 if(verboseLevel>0) G4cout << "currentEvent.rndm is copied to file: " << fileOut << G4endl;
492}
G4int GetEventID() const
Definition: G4Event.hh:139
G4int GetRunID() const
Definition: G4Run.hh:73

Referenced by G4RunMessenger::SetNewValue().

◆ rndmSaveThisRun()

void G4RunManager::rndmSaveThisRun ( )
virtual

Definition at line 451 of file G4RunManager.cc.

452{
453 G4int runNumber = 0;
454 if(currentRun) runNumber = currentRun->GetRunID();
456 G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
457 << " Random number status was not stored prior to this run."
458 << G4endl << "Command ignored." << G4endl;
459 return;
460 }
461
462 G4String fileIn = randomNumberStatusDir + "currentRun.rndm";
463
464 std::ostringstream os;
465 os << "run" << runNumber << ".rndm" << '\0';
466 G4String fileOut = randomNumberStatusDir + os.str();
467
468 G4String copCmd = "/control/shell cp "+fileIn+" "+fileOut;
470 if(verboseLevel>0) G4cout << "currentRun.rndm is copied to file: " << fileOut << G4endl;
471}

Referenced by G4RunMessenger::SetNewValue().

◆ RunInitialization()

void G4RunManager::RunInitialization ( )
virtual

Definition at line 192 of file G4RunManager.cc.

193{
194 if(!(kernel->RunInitialization())) return;
195 if(currentRun) delete currentRun;
196 currentRun = 0;
197
199 if(!currentRun) currentRun = new G4Run();
200
203
206 if(fSDM)
207 { currentRun->SetHCtable(fSDM->GetHCtable()); }
208
209 std::ostringstream oss;
213
214 previousEvents->clear();
215 for(G4int i_prev=0;i_prev<n_perviousEventsToBeStored;i_prev++)
216 { previousEvents->push_back((G4Event*)0); }
217
219
221 G4String fileN = randomNumberStatusDir + "currentRun.rndm";
223 }
224
225 runAborted = false;
227 if(verboseLevel>0) G4cout << "Start Run processing." << G4endl;
228}
Definition: G4Run.hh:47
void SetHCtable(G4HCtable *HCtbl)
Definition: G4Run.hh:96
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition: G4Run.hh:94
void SetRunID(G4int id)
Definition: G4Run.hh:92
void SetDCtable(G4DCtable *DCtbl)
Definition: G4Run.hh:98
void SetRandomNumberStatus(G4String &st)
Definition: G4Run.hh:100
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:49
G4HCtable * GetHCtable() const
Definition: G4SDManager.hh:101
virtual void BeginOfRunAction(const G4Run *aRun)
virtual G4Run * GenerateRun()

Referenced by BeamOn().

◆ RunTermination()

void G4RunManager::RunTermination ( )
virtual

Definition at line 327 of file G4RunManager.cc.

328{
329 for(size_t itr=0;itr<previousEvents->size();itr++)
330 {
331 G4Event* prevEv = (*previousEvents)[itr];
332 if((prevEv) && !(prevEv->ToBeKept())) delete prevEv;
333 }
334 previousEvents->clear();
335 for(G4int i_prev=0;i_prev<n_perviousEventsToBeStored;i_prev++)
336 { previousEvents->push_back((G4Event*)0); }
337
339
341 if(fPersM) fPersM->Store(currentRun);
342 runIDCounter++;
343
345}
G4bool ToBeKept() const
Definition: G4Event.hh:135
virtual void EndOfRunAction(const G4Run *aRun)

Referenced by BeamOn().

◆ SetDCtable()

void G4RunManager::SetDCtable ( G4DCtable DCtbl)
inline

Definition at line 474 of file G4RunManager.hh.

475 { DCtable = DCtbl; }

Referenced by G4DigiManager::AddNewModule().

◆ SetGeometryToBeOptimized()

void G4RunManager::SetGeometryToBeOptimized ( G4bool  vl)
inline

Definition at line 427 of file G4RunManager.hh.

428 {
429 if(geometryToBeOptimized != vl)
430 {
434 }
435 }
void SetGeometryToBeOptimized(G4bool vl)

Referenced by G4RunMessenger::SetNewValue().

◆ SetNumberOfAdditionalWaitingStacks()

void G4RunManager::SetNumberOfAdditionalWaitingStacks ( G4int  iAdd)
inline

Definition at line 324 of file G4RunManager.hh.

void SetNumberOfAdditionalWaitingStacks(G4int iAdd)

◆ SetNumberOfEventsToBeProcessed()

void G4RunManager::SetNumberOfEventsToBeProcessed ( G4int  val)
inline

Definition at line 472 of file G4RunManager.hh.

◆ SetNumberOfEventsToBeStored()

void G4RunManager::SetNumberOfEventsToBeStored ( G4int  val)
inline

Definition at line 440 of file G4RunManager.hh.

◆ SetPrimaryTransformer()

void G4RunManager::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inline

Definition at line 334 of file G4RunManager.hh.

void SetPrimaryTransformer(G4PrimaryTransformer *pt)

◆ SetRandomNumberStore()

void G4RunManager::SetRandomNumberStore ( G4bool  flag)
inline

Definition at line 350 of file G4RunManager.hh.

351 { storeRandomNumberStatus = flag; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRandomNumberStoreDir()

void G4RunManager::SetRandomNumberStoreDir ( const G4String dir)
inline

Definition at line 354 of file G4RunManager.hh.

355 {
356 G4String dirStr = dir;
357 if( dirStr(dirStr.length()-1) != '/' ) dirStr += "/";
358#ifndef WIN32
359 G4String shellCmd = "mkdir -p ";
360#else
361 std::replace(dirStr.begin(), dirStr.end(),'/','\\');
362 G4String shellCmd = "if not exist " + dirStr + " mkdir ";
363#endif
364 shellCmd += dirStr;
365 randomNumberStatusDir = dirStr;
366 G4int sysret = system(shellCmd);
367 if(sysret!=0)
368 {
369 G4String errmsg = "\"" + shellCmd + "\" returns non-zero value. Directory creation failed.";
370 G4Exception("GrRunManager::SetRandomNumberStoreDir","Run0071",JustWarning,errmsg);
371 G4cerr << " return value = " << sysret << G4endl;
372 }
373 }

Referenced by G4RunMessenger::SetNewValue().

◆ SetRunIDCounter()

void G4RunManager::SetRunIDCounter ( G4int  i)
inline

Definition at line 464 of file G4RunManager.hh.

465 { runIDCounter = i; }

◆ SetUserAction() [1/6]

void G4RunManager::SetUserAction ( G4UserEventAction userAction)
inline

Definition at line 285 of file G4RunManager.hh.

286 {
287 eventManager->SetUserAction(userAction);
288 userEventAction = userAction;
289 }
void SetUserAction(G4UserEventAction *userAction)

◆ SetUserAction() [2/6]

void G4RunManager::SetUserAction ( G4UserRunAction userAction)
inline

Definition at line 281 of file G4RunManager.hh.

282 { userRunAction = userAction; }

◆ SetUserAction() [3/6]

void G4RunManager::SetUserAction ( G4UserStackingAction userAction)
inline

Definition at line 290 of file G4RunManager.hh.

291 {
292 eventManager->SetUserAction(userAction);
293 userStackingAction = userAction;
294 }

◆ SetUserAction() [4/6]

void G4RunManager::SetUserAction ( G4UserSteppingAction userAction)
inline

Definition at line 300 of file G4RunManager.hh.

301 {
302 eventManager->SetUserAction(userAction);
303 userSteppingAction = userAction;
304 }

◆ SetUserAction() [5/6]

void G4RunManager::SetUserAction ( G4UserTrackingAction userAction)
inline

Definition at line 295 of file G4RunManager.hh.

296 {
297 eventManager->SetUserAction(userAction);
298 userTrackingAction = userAction;
299 }

◆ SetUserAction() [6/6]

void G4RunManager::SetUserAction ( G4VUserPrimaryGeneratorAction userAction)
inline

Definition at line 283 of file G4RunManager.hh.

284 { userPrimaryGeneratorAction = userAction; }

◆ SetUserInitialization() [1/2]

void G4RunManager::SetUserInitialization ( G4VUserDetectorConstruction userInit)
inline

Definition at line 274 of file G4RunManager.hh.

275 { userDetector = userInit; }

◆ SetUserInitialization() [2/2]

void G4RunManager::SetUserInitialization ( G4VUserPhysicsList userInit)
inline

Definition at line 276 of file G4RunManager.hh.

277 {
278 physicsList = userInit;
279 kernel->SetPhysics(userInit);
280 }
void SetPhysics(G4VUserPhysicsList *uPhys)

◆ SetVerboseLevel()

void G4RunManager::SetVerboseLevel ( G4int  vl)
inline

Definition at line 421 of file G4RunManager.hh.

422 { verboseLevel = vl;
423 kernel->SetVerboseLevel(vl); }
void SetVerboseLevel(G4int vl)

Referenced by G4RunMessenger::SetNewValue().

◆ StackPreviousEvent()

void G4RunManager::StackPreviousEvent ( G4Event anEvent)
protected

Definition at line 347 of file G4RunManager.cc.

348{
349 if(anEvent->ToBeKept()) currentRun->StoreEvent(anEvent);
350 G4Event* evt;
352 { evt = anEvent; }
353 else
354 {
355 previousEvents->insert(previousEvents->begin(),anEvent);
356 evt = previousEvents->back();
357 previousEvents->pop_back();
358 }
359 if(evt && !(evt->ToBeKept())) delete evt;
360}
void StoreEvent(G4Event *evt)
Definition: G4Run.cc:48

Referenced by TerminateOneEvent().

◆ StoreRandomNumberStatusToG4Event()

void G4RunManager::StoreRandomNumberStatusToG4Event ( G4int  vl)
inline

Definition at line 337 of file G4RunManager.hh.

Referenced by G4RunMessenger::SetNewValue().

◆ TerminateEventLoop()

void G4RunManager::TerminateEventLoop ( )
virtual

Definition at line 277 of file G4RunManager.cc.

278{
279 if(verboseLevel>0)
280 {
281 timer->Stop();
282 G4cout << "Run terminated." << G4endl;
283 G4cout << "Run Summary" << G4endl;
284 if(runAborted)
285 { G4cout << " Run Aborted after " << numberOfEventProcessed << " events processed." << G4endl; }
286 else
287 { G4cout << " Number of events processed : " << numberOfEventProcessed << G4endl; }
288 G4cout << " " << *timer << G4endl;
289 }
290}
void Stop()

Referenced by DoEventLoop().

◆ TerminateOneEvent()

void G4RunManager::TerminateOneEvent ( )
virtual

Definition at line 270 of file G4RunManager.cc.

271{
273 currentEvent = 0;
275}
void StackPreviousEvent(G4Event *anEvent)

Referenced by DoEventLoop().

◆ UpdateScoring()

void G4RunManager::UpdateScoring ( )
protected

Definition at line 574 of file G4RunManager.cc.

575{
577 if(!ScM) return;
578 G4int nPar = ScM->GetNumberOfMesh();
579 if(nPar<1) return;
580
582 if(!HCE) return;
583 G4int nColl = HCE->GetCapacity();
584 for(G4int i=0;i<nColl;i++)
585 {
586 G4VHitsCollection* HC = HCE->GetHC(i);
587 if(HC) ScM->Accumulate(HC);
588 }
589}
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:173
G4VHitsCollection * GetHC(G4int i)
void Accumulate(G4VHitsCollection *map)

Referenced by ProcessOneEvent().

Member Data Documentation

◆ currentEvent

G4Event* G4RunManager::currentEvent
protected

◆ currentRun

◆ currentWorld

G4VPhysicalVolume* G4RunManager::currentWorld
protected

Definition at line 260 of file G4RunManager.hh.

◆ DCtable

G4DCtable* G4RunManager::DCtable
protected

Definition at line 246 of file G4RunManager.hh.

Referenced by RunInitialization(), and SetDCtable().

◆ eventManager

◆ geometryInitialized

G4bool G4RunManager::geometryInitialized
protected

Definition at line 237 of file G4RunManager.hh.

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

◆ geometryToBeOptimized

G4bool G4RunManager::geometryToBeOptimized
protected

Definition at line 241 of file G4RunManager.hh.

Referenced by GetGeometryToBeOptimized(), and SetGeometryToBeOptimized().

◆ initializedAtLeastOnce

G4bool G4RunManager::initializedAtLeastOnce
protected

Definition at line 240 of file G4RunManager.hh.

Referenced by ConfirmBeamOnCondition(), and Initialize().

◆ kernel

◆ msgText

G4String G4RunManager::msgText
protected

Definition at line 264 of file G4RunManager.hh.

Referenced by InitializeEventLoop(), and ProcessOneEvent().

◆ n_perviousEventsToBeStored

G4int G4RunManager::n_perviousEventsToBeStored
protected

◆ n_select_msg

G4int G4RunManager::n_select_msg
protected

Definition at line 265 of file G4RunManager.hh.

Referenced by InitializeEventLoop(), and ProcessOneEvent().

◆ nParallelWorlds

G4int G4RunManager::nParallelWorlds
protected

Definition at line 262 of file G4RunManager.hh.

Referenced by GetNumberOfParallelWorld(), and InitializeGeometry().

◆ numberOfEventProcessed

G4int G4RunManager::numberOfEventProcessed
protected

Definition at line 266 of file G4RunManager.hh.

Referenced by RunInitialization(), TerminateEventLoop(), and TerminateOneEvent().

◆ numberOfEventToBeProcessed

G4int G4RunManager::numberOfEventToBeProcessed
protected

Definition at line 252 of file G4RunManager.hh.

Referenced by BeamOn(), RunInitialization(), and SetNumberOfEventsToBeProcessed().

◆ physicsInitialized

G4bool G4RunManager::physicsInitialized
protected

Definition at line 238 of file G4RunManager.hh.

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

◆ physicsList

G4VUserPhysicsList* G4RunManager::physicsList
protected

◆ previousEvents

std::vector<G4Event*>* G4RunManager::previousEvents
protected

◆ randomNumberStatusDir

◆ randomNumberStatusForThisEvent

G4String G4RunManager::randomNumberStatusForThisEvent
protected

Definition at line 258 of file G4RunManager.hh.

Referenced by G4RunManager(), GenerateEvent(), and GetRandomNumberStatusForThisEvent().

◆ randomNumberStatusForThisRun

G4String G4RunManager::randomNumberStatusForThisRun
protected

◆ runAborted

G4bool G4RunManager::runAborted
protected

Definition at line 239 of file G4RunManager.hh.

Referenced by AbortRun(), DoEventLoop(), RunInitialization(), and TerminateEventLoop().

◆ runIDCounter

G4int G4RunManager::runIDCounter
protected

Definition at line 243 of file G4RunManager.hh.

Referenced by RunInitialization(), RunTermination(), and SetRunIDCounter().

◆ storeRandomNumberStatus

G4bool G4RunManager::storeRandomNumberStatus
protected

◆ storeRandomNumberStatusToG4Event

G4int G4RunManager::storeRandomNumberStatusToG4Event
protected

◆ timer

G4Timer* G4RunManager::timer
protected

◆ userDetector

G4VUserDetectorConstruction* G4RunManager::userDetector
protected

◆ userEventAction

G4UserEventAction* G4RunManager::userEventAction
protected

Definition at line 228 of file G4RunManager.hh.

Referenced by GetUserEventAction(), and SetUserAction().

◆ userPrimaryGeneratorAction

G4VUserPrimaryGeneratorAction* G4RunManager::userPrimaryGeneratorAction
protected

◆ userRunAction

G4UserRunAction* G4RunManager::userRunAction
protected

◆ userStackingAction

G4UserStackingAction* G4RunManager::userStackingAction
protected

Definition at line 229 of file G4RunManager.hh.

Referenced by GetUserStackingAction(), and SetUserAction().

◆ userSteppingAction

G4UserSteppingAction* G4RunManager::userSteppingAction
protected

Definition at line 231 of file G4RunManager.hh.

Referenced by GetUserSteppingAction(), and SetUserAction().

◆ userTrackingAction

G4UserTrackingAction* G4RunManager::userTrackingAction
protected

Definition at line 230 of file G4RunManager.hh.

Referenced by GetUserTrackingAction(), and SetUserAction().

◆ verboseLevel


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