64 using namespace CLHEP;
70 #ifdef theParticleIterator
71 #undef theParticleIterator
75 {
return fRunManager; }
78 :userDetector(0),physicsList(0),
79 userActionInitialization(0),userWorkerInitialization(0),
80 userWorkerThreadInitialization(0),
81 userRunAction(0),userPrimaryGeneratorAction(0),userEventAction(0),
82 userStackingAction(0),userTrackingAction(0),userSteppingAction(0),
83 geometryInitialized(false),physicsInitialized(false),
84 runAborted(false),initializedAtLeastOnce(false),
85 geometryToBeOptimized(true),runIDCounter(0),
86 verboseLevel(0),printModulo(-1),DCtable(0),
87 currentRun(0),currentEvent(0),n_perviousEventsToBeStored(0),
88 numberOfEventToBeProcessed(0),storeRandomNumberStatus(false),
89 storeRandomNumberStatusToG4Event(0),rngStatusEventsFlag(false),
90 currentWorld(0),nParallelWorlds(0),msgText(
" "),n_select_msg(-1),
91 numberOfEventProcessed(0),selectMacro(
""),fakeRun(false)
95 G4Exception(
"G4RunManager::G4RunManager()",
"Run0031",
109 std::ostringstream oss;
110 G4Random::saveFullState(oss);
117 :userDetector(0),physicsList(0),
118 userActionInitialization(0),userWorkerInitialization(0),
119 userWorkerThreadInitialization(0),
120 userRunAction(0),userPrimaryGeneratorAction(0),userEventAction(0),
121 userStackingAction(0),userTrackingAction(0),userSteppingAction(0),
122 geometryInitialized(false),physicsInitialized(false),
123 runAborted(false),initializedAtLeastOnce(false),
124 geometryToBeOptimized(true),runIDCounter(0),
125 verboseLevel(0),printModulo(-1),DCtable(0),
126 currentRun(0),currentEvent(0),n_perviousEventsToBeStored(0),
127 numberOfEventToBeProcessed(0),storeRandomNumberStatus(false),
128 storeRandomNumberStatusToG4Event(0),rngStatusEventsFlag(false),
129 currentWorld(0),nParallelWorlds(0),msgText(
" "),n_select_msg(-1),
130 numberOfEventProcessed(0),selectMacro(
""),fakeRun(false)
133 #ifndef G4MULTITHREADED
135 msg<<
"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
136 msg<<
" This type of RunManager can only be used in mult-threaded applications.";
142 G4Exception(
"G4RunManager::G4RunManager()",
"Run0031",
157 msgx<<
" This type of RunManager can only be used in mult-threaded applications.";
170 std::ostringstream oss;
171 G4Random::saveFullState(oss);
256 if(n_event<=0) {
fakeRun =
true; }
277 G4cerr <<
"Illegal application state - BeamOn() ignored." <<
G4endl;
283 G4cerr <<
" Geant4 kernel should be initialized" <<
G4endl;
284 G4cerr <<
"before the first BeamOn(). - BeamOn ignored." <<
G4endl;
295 G4cout <<
"has been modified since last Run." <<
G4endl;
321 std::ostringstream oss;
322 G4Random::saveFullState(oss);
337 std::ostringstream os;
353 for(
G4int i_event=0; i_event<n_event; i_event++ )
420 "G4VUserPrimaryGeneratorAction is not defined!");
428 std::ostringstream oss;
429 G4Random::saveFullState(oss);
437 std::ostringstream os;
453 G4Random::saveEngineStatus(fileN);
459 if(fPersM) fPersM->
Store(anEvent);
469 G4Event* prevEv = (*previousEvents)[itr];
470 if((prevEv) && !(prevEv->
ToBeKept()))
delete prevEv;
498 if(evt && !(evt->
ToBeKept()))
delete evt;
507 G4cerr <<
"Illegal application state - "
508 <<
"G4RunManager::Initialize() ignored." <<
G4endl;
521 G4Exception(
"G4RunManager::InitializeGeometry",
"Run0033",
544 G4Exception(
"G4RunManager::InitializePhysics()",
"Run0034",
567 G4cerr <<
"Run is not in progress. AbortRun() ignored." <<
G4endl;
583 G4cerr <<
"Event is not in progress. AbortEevnt() ignored." <<
G4endl;
598 G4cerr <<
"Warning from G4RunManager::rndmSaveThisRun():"
599 <<
" Random number status was not stored prior to this run."
606 std::ostringstream os;
607 os <<
"run" << runNumber <<
".rndm" <<
'\0';
610 G4String copCmd =
"/control/shell cp "+fileIn+
" "+fileOut;
618 G4cerr <<
"Warning from G4RunManager::rndmSaveThisEvent():"
619 <<
" there is no currentEvent or its RandomEngineStatus is not available."
626 std::ostringstream os;
631 G4String copCmd =
"/control/shell cp "+fileIn+
" "+fileOut;
639 if(fileN.
index(
"/")==std::string::npos)
642 { fileNameWithDirectory = fileN; }
644 G4Random::restoreEngineStatus(fileNameWithDirectory);
646 << fileNameWithDirectory <<
G4endl;
647 G4Random::showEngineStatus();
667 #include "G4HCofThisEvent.hh"
668 #include "G4VHitsCollection.hh"
683 for(
G4int iw=0;iw<nPar;iw++)
700 theParticleIterator->
reset();
701 while( (*theParticleIterator)() ){
706 pmanager->
AddProcess(theParallelWorldProcess);
731 for(
G4int i=0;i<nColl;i++)
753 { localtimer.
Start(); }
765 G4cout <<
" heads : " << stat.GetNumberHeads() <<
" - nodes : "
766 << stat.GetNumberNodes() <<
" - pointers : "
767 << stat.GetNumberPointers() <<
G4endl;
768 G4cout <<
" Memory used : " << (stat.GetMemoryUse()+512)/1024
769 <<
"k - total time : " << stat.GetTotalTime()
770 <<
" - system time : " << stat.GetSysTime() <<
G4endl;
786 "Base-class G4RunManager cannot take G4UserWorkerInitialization. Use G4MTRunManager.");
792 "Base-class G4RunManager cannot take G4UserWorkerThreadInitialization. Use G4MTRunManager.");
850 G4cout<<
"#### G4PhysicalVolumeStore, G4LogicalVolumeStore and G4SolidStore\n"
851 <<
"#### are wiped out. Command-based scorer, layerd mass geometry,\n"
852 <<
"#### biasing with parallel world, etc. are not functioning any longer."
virtual G4VPhysicalVolume * Construct()=0
void GeometryHasBeenModified(G4bool prop=true)
void SetNumberOfEventToBeProcessed(G4int n_ev)
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
virtual void AbortRun(G4bool softAbort=false)
G4int numberOfEventToBeProcessed
virtual void ProcessOneEvent(G4int i_event)
virtual void TerminateEventLoop()
void SetDCtable(G4DCtable *DCtbl)
G4SmartVoxelHeader * GetVoxelHeader() const
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
G4double GetSystemElapsed() const
void SetPhysics(G4VUserPhysicsList *uPhys)
G4int numberOfEventProcessed
G4UserTrackingAction * userTrackingAction
G4VHitsCollection * GetHC(G4int i)
G4String GetWorldName(G4int i) const
G4String randomNumberStatusForThisRun
virtual void RunTermination()
std::ostringstream G4ExceptionDescription
G4VUserPhysicsList * physicsList
G4String randomNumberStatusForThisEvent
G4EventManager * GetEventManager() const
void SetNumberOfParallelWorld(G4int i)
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4UImessenger * CreateMessenger()
G4VUserActionInitialization * userActionInitialization
G4bool storeRandomNumberStatus
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4UImessenger * CreateMessenger()
virtual void RunInitialization()
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
void ConstructParallelSD()
virtual void EndOfRunAction(const G4Run *aRun)
G4bool physicsInitialized
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual void Construct(G4VPhysicalVolume *fWorldPhys)=0
void SetName(const G4String &pName)
virtual void InitializePhysics()
void ReOptimize(G4LogicalVolume *)
G4ProcessManager * GetProcessManager() const
virtual G4bool Store(const G4Event *anEvent)=0
G4bool RunInitialization(G4bool fakeRun=false)
virtual void InitializeGeometry()
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
virtual G4bool ConfirmBeamOnCondition()
static G4UImanager * GetUIpointer()
virtual void RestoreRandomNumberStatus(const G4String &fileN)
static G4PhysicalVolumeStore * GetInstance()
G4bool geometryInitialized
G4HCtable * GetHCtable() const
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
G4bool initializedAtLeastOnce
static G4StateManager * GetStateManager()
virtual void rndmSaveThisRun()
void SetParallelWorld(G4String parallelWorldName)
virtual G4Event * GenerateEvent(G4int i_event)
G4GLOB_DLL std::ostream G4cout
G4bool SetNewState(G4ApplicationState requestedState)
str_size index(const char *, G4int pos=0) const
void reset(G4bool ifSkipIon=true)
static G4ScoringManager * GetScoringManagerIfExist()
G4UserWorkerInitialization * userWorkerInitialization
void DumpRegion(const G4String &rname) const
G4String randomNumberStatusDir
G4bool rngStatusEventsFlag
virtual void ConstructScoringWorlds()
virtual void AnalyzeEvent(G4Event *anEvent)
G4double GetUserElapsed() const
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4int storeRandomNumberStatusToG4Event
G4UserEventAction * userEventAction
virtual void rndmSaveThisEvent()
virtual void Build() const =0
static G4LogicalVolumeStore * GetInstance()
void Accumulate(G4VHitsCollection *map)
static G4SolidStore * GetInstance()
virtual void DeleteUserInitializations()
G4ApplicationState GetCurrentState() const
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
static G4GeometryManager * GetInstance()
G4LogicalVolume * GetMotherLogical() const
G4UserRunAction * userRunAction
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void SetHCtable(G4HCtable *HCtbl)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetRandomNumberStatus(G4String &st)
G4int ConstructParallelGeometries()
static G4TransportationManager * GetTransportationManager()
static G4RunManager * GetRunManager()
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
virtual void ConstructSDandField()
virtual void GeneratePrimaries(G4Event *anEvent)=0
static G4ParticleTable * GetParticleTable()
virtual void DoEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
void SetUserAction(G4UserEventAction *userAction)
void ReOptimizeMotherOf(G4VPhysicalVolume *)
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual void StoreRNGStatus(const G4String &filenamePrefix)
void StoreEvent(G4Event *evt)
virtual void RecordEvent(const G4Event *)
virtual void BeginOfRunAction(const G4Run *aRun)
virtual void Initialize()
void StackPreviousEvent(G4Event *anEvent)
void GeometryHasBeenModified()
void OpenGeometry(G4VPhysicalVolume *vol=0)
void ProcessOneEvent(G4Event *anEvent)
virtual void AbortEvent()
G4RunManagerKernel * kernel
G4HCofThisEvent * GetHCofThisEvent() const
size_t GetNumberOfMesh() const
G4EventManager * eventManager
virtual void TerminateOneEvent()
G4VUserDetectorConstruction * userDetector
G4UserSteppingAction * userSteppingAction
G4VScoringMesh * GetMesh(G4int i) const
void SetRandomNumberStatus(G4String &st)
G4RunMessenger * runMessenger
virtual G4Run * GenerateRun()
std::vector< G4Event * > * previousEvents
static G4ProcessTable * GetProcessTable()
G4PTblDicIterator * GetIterator() const
void DumpRegion(const G4String &rname) const
G4int n_perviousEventsToBeStored
#define theParticleIterator
G4int ApplyCommand(const char *aCommand)
static G4ThreadLocal G4RunManager * fRunManager
G4GLOB_DLL std::ostream G4cerr
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4UserStackingAction * userStackingAction
virtual void SetUserAction(G4UserRunAction *userAction)
static G4VPersistencyManager * GetPersistencyManager()
static G4SDManager * GetSDMpointerIfExist()