67 using namespace CLHEP;
76 #ifdef theParticleIterator
77 #undef theParticleIterator
81 {
return fRunManager; }
84 :userDetector(0),physicsList(0),
85 userActionInitialization(0),userWorkerInitialization(0),
86 userWorkerThreadInitialization(0),
87 userRunAction(0),userPrimaryGeneratorAction(0),userEventAction(0),
88 userStackingAction(0),userTrackingAction(0),userSteppingAction(0),
89 geometryInitialized(false),physicsInitialized(false),
90 runAborted(false),initializedAtLeastOnce(false),
91 geometryToBeOptimized(true),runIDCounter(0),
92 verboseLevel(0),printModulo(-1),DCtable(0),
93 currentRun(0),currentEvent(0),n_perviousEventsToBeStored(0),
94 numberOfEventToBeProcessed(0),storeRandomNumberStatus(false),
95 storeRandomNumberStatusToG4Event(0),rngStatusEventsFlag(false),
96 currentWorld(0),nParallelWorlds(0),msgText(
" "),n_select_msg(-1),
97 numberOfEventProcessed(0),selectMacro(
""),fakeRun(false)
101 G4Exception(
"G4RunManager::G4RunManager()",
"Run0031",
115 std::ostringstream oss;
116 G4Random::saveFullState(oss);
124 :userDetector(0),physicsList(0),
125 userActionInitialization(0),userWorkerInitialization(0),
126 userWorkerThreadInitialization(0),
127 userRunAction(0),userPrimaryGeneratorAction(0),userEventAction(0),
128 userStackingAction(0),userTrackingAction(0),userSteppingAction(0),
129 geometryInitialized(false),physicsInitialized(false),
130 runAborted(false),initializedAtLeastOnce(false),
131 geometryToBeOptimized(true),runIDCounter(0),
132 verboseLevel(0),printModulo(-1),DCtable(0),
133 currentRun(0),currentEvent(0),n_perviousEventsToBeStored(0),
134 numberOfEventToBeProcessed(0),storeRandomNumberStatus(false),
135 storeRandomNumberStatusToG4Event(0),rngStatusEventsFlag(false),
136 currentWorld(0),nParallelWorlds(0),msgText(
" "),n_select_msg(-1),
137 numberOfEventProcessed(0),selectMacro(
""),fakeRun(false)
140 #ifndef G4MULTITHREADED
142 msg<<
"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
143 msg<<
" This type of RunManager can only be used in mult-threaded applications.";
149 G4Exception(
"G4RunManager::G4RunManager()",
"Run0031",
165 msgx<<
" This type of RunManager can only be used in mult-threaded applications.";
179 std::ostringstream oss;
180 G4Random::saveFullState(oss);
268 if(n_event<=0) {
fakeRun =
true; }
290 G4cerr <<
"Illegal application state - BeamOn() ignored." <<
G4endl;
296 G4cerr <<
" Geant4 kernel should be initialized" <<
G4endl;
297 G4cerr <<
"before the first BeamOn(). - BeamOn ignored." <<
G4endl;
308 G4cout <<
"has been modified since last Run." <<
G4endl;
342 std::ostringstream oss;
343 G4Random::saveFullState(oss);
357 std::ostringstream os;
371 for(
G4int i_event=0; i_event<n_event; i_event++ )
443 "G4VUserPrimaryGeneratorAction is not defined!");
451 std::ostringstream oss;
452 G4Random::saveFullState(oss);
460 std::ostringstream os;
477 G4Random::saveEngineStatus(fileN);
483 if(fPersM) fPersM->
Store(anEvent);
515 if(evt && !(evt->
ToBeKept()))
delete evt;
556 {
if(!(anEvent->
ToBeKept()))
delete anEvent; }
570 G4cerr <<
"Illegal application state - "
571 <<
"G4RunManager::Initialize() ignored." <<
G4endl;
587 G4Exception(
"G4RunManager::InitializeGeometry",
"Run0033",
619 G4Exception(
"G4RunManager::InitializePhysics()",
"Run0034",
643 G4cerr <<
"Run is not in progress. AbortRun() ignored." <<
G4endl;
659 G4cerr <<
"Event is not in progress. AbortEevnt() ignored." <<
G4endl;
674 G4cerr <<
"Warning from G4RunManager::rndmSaveThisRun():"
675 <<
" Random number status was not stored prior to this run."
682 std::ostringstream os;
683 os <<
"run" << runNumber <<
".rndm" <<
'\0';
686 G4String copCmd =
"/control/shell cp "+fileIn+
" "+fileOut;
694 G4cerr <<
"Warning from G4RunManager::rndmSaveThisEvent():"
695 <<
" there is no currentEvent or its RandomEngineStatus is not available."
702 std::ostringstream os;
707 G4String copCmd =
"/control/shell cp "+fileIn+
" "+fileOut;
715 if(fileN.
index(
"/")==std::string::npos)
718 { fileNameWithDirectory = fileN; }
720 G4Random::restoreEngineStatus(fileNameWithDirectory);
722 << fileNameWithDirectory <<
G4endl;
723 G4Random::showEngineStatus();
743 #include "G4HCofThisEvent.hh"
744 #include "G4VHitsCollection.hh"
760 for(
G4int iw=0;iw<nPar;iw++)
776 if(theParallelWorldProcess)
784 theParticleIterator->
reset();
785 while( (*theParticleIterator)() ){
790 pmanager->
AddProcess(theParallelWorldProcess);
817 for(
G4int i=0;i<nColl;i++)
839 { localtimer.
Start(); }
851 G4cout <<
" heads : " << stat.GetNumberHeads() <<
" - nodes : "
852 << stat.GetNumberNodes() <<
" - pointers : "
853 << stat.GetNumberPointers() <<
G4endl;
854 G4cout <<
" Memory used : " << (stat.GetMemoryUse()+512)/1024
855 <<
"k - total time : " << stat.GetTotalTime()
856 <<
" - system time : " << stat.GetSysTime() <<
G4endl;
872 "Base-class G4RunManager cannot take G4UserWorkerInitialization. Use G4MTRunManager.");
878 "Base-class G4RunManager cannot take G4UserWorkerThreadInitialization. Use G4MTRunManager.");
941 G4cout<<
"#### G4PhysicalVolumeStore, G4LogicalVolumeStore and G4SolidStore\n"
942 <<
"#### are wiped out."<<
G4endl;
952 std::vector<G4Region*>::iterator rItr;
953 for(rItr = regionStore->begin();rItr != regionStore->end(); rItr++)
955 if((*rItr)->GetName()==
"DefaultRegionForTheWorld")
continue;
957 std::vector<G4LogicalVolume*>::iterator lvItr
958 = (*rItr)->GetRootLogicalVolumeIterator();
959 for(
size_t iRLV = 0;iRLV < (*rItr)->GetNumberOfRootVolumes(); iRLV++)
961 (*rItr)->RemoveRootLogicalVolume(*lvItr,
false);
965 {
G4cout<<
"#### Region <"<<(*rItr)->GetName()<<
"> is cleared."<<
G4endl; }
G4bool RunInitialization(G4bool fakeRun=false)
virtual void AbortRun(G4bool softAbort=false)
G4VUserDetectorConstruction * userDetector
static G4RunManager * GetRunManager()
void InitializeTiMemory()
virtual void Build() const =0
void Construct(G4VPhysicalVolume *fWorldPhys)
G4bool SetNewState(G4ApplicationState requestedState)
std::ostringstream G4ExceptionDescription
void ReOptimize(G4LogicalVolume *)
G4bool rngStatusEventsFlag
virtual void GeometryHasChanged()=0
G4VUserActionInitialization * userActionInitialization
void SetHCtable(G4HCtable *HCtbl)
static G4ParticleTable * GetParticleTable()
size_t GetNumberOfMesh() const
void StackPreviousEvent(G4Event *anEvent)
#define theParticleIterator
virtual void BeginOfRunAction(const G4Run *aRun)
void SetDCtable(G4DCtable *DCtbl)
G4bool initializedAtLeastOnce
G4int ApplyCommand(const char *aCommand)
void SetParallelWorld(G4String parallelWorldName)
void CleanUpUnnecessaryEvents(G4int keepNEvents)
static G4ParallelWorldProcessStore * GetInstance()
void ProcessOneEvent(G4Event *anEvent)
G4SmartVoxelHeader * GetVoxelHeader() const
virtual void SetUserAction(G4UserRunAction *userAction)
G4bool IsAtRestRequired(G4ParticleDefinition *)
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4UImessenger * CreateMessenger()
G4bool storeRandomNumberStatus
virtual void RunInitialization()
G4UserEventAction * userEventAction
G4bool geometryInitialized
virtual void TerminateOneEvent()
G4int GetNumberOfGrips() const
G4int ConstructParallelGeometries()
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
static G4VPersistencyManager * GetPersistencyManager()
G4VUserPhysicsList * physicsList
static G4ProcessTable * GetProcessTable()
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
void SetNumberOfParallelWorld(G4int i)
str_size index(const char *, G4int pos=0) const
G4UserRunAction * userRunAction
virtual void RunTermination()
G4PTblDicIterator * GetIterator() const
G4ParallelWorldProcess * GetParallelWorldProcess() const
virtual void EndOfRunAction(const G4Run *aRun)
void reset(G4bool ifSkipIon=true)
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
void SetUserAction(G4UserEventAction *userAction)
static G4UImanager * GetUIpointer()
G4HCofThisEvent * GetHCofThisEvent() const
static G4VVisManager * GetConcreteInstance()
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void StoreEvent(G4Event *evt)
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
void ConstructParallelSD()
virtual void TerminateEventLoop()
void SetRandomNumberStatus(G4String &st)
void ClearParallelWorlds()
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
G4int numberOfEventProcessed
virtual void rndmSaveThisRun()
void SetPhysics(G4VUserPhysicsList *uPhys)
G4LogicalVolume * GetMotherLogical() const
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void SetRandomNumberStatus(G4String &st)
void CleanUpPreviousEvents()
G4double GetSystemElapsed() const
G4bool physicsInitialized
virtual void ConstructScoringWorlds()
static G4ScoringManager * GetScoringManagerIfExist()
static G4SDManager * GetSDMpointerIfExist()
G4int storeRandomNumberStatusToG4Event
virtual G4Event * GenerateEvent(G4int i_event)
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
virtual void AnalyzeEvent(G4Event *anEvent)
static G4GeometryManager * GetInstance()
void GeometryHasBeenModified()
G4int numberOfEventToBeProcessed
virtual void ProcessOneEvent(G4int i_event)
G4double GetUserElapsed() const
G4UserWorkerInitialization * userWorkerInitialization
static G4bool fGeometryHasBeenDestroyed
virtual void DoEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
G4UserStackingAction * userStackingAction
void OpenGeometry(G4VPhysicalVolume *vol=0)
void GeometryHasBeenModified(G4bool prop=true)
G4GLOB_DLL std::ostream G4cerr
void GeometryHasBeenDestroyed()
G4VHitsCollection * GetHC(G4int i)
G4String randomNumberStatusForThisRun
static G4TransportationManager * GetTransportationManager()
virtual void DeleteUserInitializations()
G4UserSteppingAction * userSteppingAction
static G4SolidStore * GetInstance()
virtual void RecordEvent(const G4Event *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void SetNumberOfEventToBeProcessed(G4int n_ev)
static G4PhysicalVolumeStore * GetInstance()
static G4RegionStore * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
virtual G4VPhysicalVolume * Construct()=0
G4HCtable * GetHCtable() const
G4ApplicationState GetCurrentState() const
void ReOptimizeMotherOf(G4VPhysicalVolume *)
G4ProcessManager * GetProcessManager() const
void SetName(const G4String &pName)
G4EventManager * GetEventManager() const
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
virtual G4bool ConfirmBeamOnCondition()
virtual G4Run * GenerateRun()
void DumpRegion(const G4String &rname) const
virtual void RestoreRandomNumberStatus(const G4String &fileN)
void DumpRegion(const G4String &rname) const
virtual void ConstructSDandField()
G4GLOB_DLL std::ostream G4cout
std::list< G4Event * > * previousEvents
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
virtual void rndmSaveThisEvent()
G4VScoringMesh * GetMesh(G4int i) const
virtual G4bool Store(const G4Event *anEvent)=0
virtual void AbortEvent()
void Accumulate(G4VHitsCollection *map)
static G4ThreadLocal G4RunManager * fRunManager
virtual void GeneratePrimaries(G4Event *anEvent)=0
virtual void StoreRNGStatus(const G4String &filenamePrefix)
#define TIMEMORY_AUTO_TIMER(str)
G4String randomNumberStatusForThisEvent
G4RunMessenger * runMessenger
G4UserTrackingAction * userTrackingAction
G4String randomNumberStatusDir
G4UImessenger * CreateMessenger()
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
virtual void Initialize()
static G4bool IfGeometryHasBeenDestroyed()
static G4LogicalVolumeStore * GetInstance()
virtual void InitializeGeometry()
virtual void InitializePhysics()
G4int n_perviousEventsToBeStored
const G4String & GetName() const
G4RunManagerKernel * kernel
static G4StateManager * GetStateManager()
G4String GetWorldName(G4int i) const
G4EventManager * eventManager