90#ifdef theParticleIterator
91# undef theParticleIterator
113 if (fRunManager !=
nullptr) {
115 "G4RunManager constructed twice.");
127 std::ostringstream oss;
128 G4Random::saveFullState(oss);
139#ifndef G4MULTITHREADED
141 msg <<
"Geant4 code is compiled without multi-threading support "
142 "(-DG4MULTITHREADED is set to off).";
143 msg <<
" This type of RunManager can only be used in mult-threaded "
148 if (fRunManager !=
nullptr) {
150 "G4RunManager constructed twice.");
164 msgx <<
"This type of RunManager can only be used in multi-threaded "
179 std::ostringstream oss;
180 G4Random::saveFullState(oss);
200 <<
" events kept in eventVector";
227 fRunManager =
nullptr;
279 G4cerr <<
"Illegal application state - BeamOn() ignored." <<
G4endl;
284 G4cerr <<
" Geant4 kernel should be initialized" <<
G4endl;
285 G4cerr <<
"before the first BeamOn(). - BeamOn ignored." <<
G4endl;
294 G4cout <<
"has been modified since last Run." <<
G4endl;
314 <<
" events kept in eventVector";
333 if (fSDM !=
nullptr) {
343 std::ostringstream oss;
344 G4Random::saveFullState(oss);
364 std::ostringstream os;
378 for (
G4int i_event = 0; i_event < n_event; ++i_event) {
397 if (macroFile !=
nullptr) {
450 "G4VUserPrimaryGeneratorAction is not defined!");
454 auto anEvent =
new G4Event(i_event);
457 std::ostringstream oss;
458 G4Random::saveFullState(oss);
466 std::ostringstream os;
467 os <<
"run" <<
currentRun->GetRunID() <<
"evt" << anEvent->GetEventID();
474 G4cout <<
"--> Event " << anEvent->GetEventID() <<
" starts." <<
G4endl;
484 G4Random::saveEngineStatus(fileN);
491 if (fPersM !=
nullptr) fPersM->
Store(anEvent);
536 if (evt !=
nullptr && !(evt->
ToBeKept())) {
559 if (evt !=
nullptr) {
620 G4cerr <<
"Illegal application state - "
621 <<
"G4RunManager::Initialize() ignored." <<
G4endl;
639 "G4VUserDetectorConstruction is not defined!");
677 kernel->InitializePhysics();
681 "G4VUserPhysicsList is not defined!");
700 G4cerr <<
"Run is not in progress. AbortRun() ignored." <<
G4endl;
714 G4cerr <<
"Event is not in progress. AbortEevnt() ignored." <<
G4endl;
721 kernel->DefineWorldVolume(worldVol, topologyIsChanged);
730 G4cerr <<
"Warning from G4RunManager::rndmSaveThisRun():"
731 <<
" Random number status was not stored prior to this run." <<
G4endl
732 <<
"/random/setSavingFlag command must be issued. "
733 <<
"Command ignored." <<
G4endl;
739 std::ostringstream os;
740 os <<
"run" << runNumber <<
".rndm" <<
'\0';
745 G4cout << fileIn <<
" is copied to " << fileOut <<
G4endl;
753 G4cerr <<
"Warning from G4RunManager::rndmSaveThisEvent():"
754 <<
" there is no currentEvent available." <<
G4endl <<
"Command ignored." <<
G4endl;
759 G4cerr <<
"Warning from G4RunManager::rndmSaveThisEvent():"
760 <<
" Random number engine status is not available." <<
G4endl
761 <<
"/random/setSavingFlag command must be issued "
762 <<
"prior to the start of the run. Command ignored." <<
G4endl;
768 std::ostringstream os;
774 G4cout << fileIn <<
" is copied to " << fileOut <<
G4endl;
782 if (fileN.find(
'/') == std::string::npos) {
786 fileNameWithDirectory = fileN;
789 G4Random::restoreEngineStatus(fileNameWithDirectory);
791 G4cout <<
"RandomNumberEngineStatus restored from file: " << fileNameWithDirectory <<
G4endl;
792 G4Random::showEngineStatus();
798 kernel->DumpRegion(rname);
804 kernel->DumpRegion(region);
813 if (ScM ==
nullptr)
return;
816 if (nPar < 1)
return;
819 for (
G4int iw = 0; iw < nPar; ++iw) {
823 if (mesh->
GetShape() != MeshShape::realWorldLogVol) {
826 if (pWorld ==
nullptr) {
832 if (theParallelWorldProcess !=
nullptr) {
844 if (pmanager !=
nullptr) {
845 pmanager->
AddProcess(theParallelWorldProcess);
877 "Double-counting!!!");
883 if (ScM ==
nullptr)
return;
885 if (nPar < 1)
return;
888 if (HCE ==
nullptr)
return;
890 for (
G4int i = 0; i < nColl; ++i) {
900 if (pMotherL !=
nullptr)
ReOptimize(pMotherL);
936 kernel->SetPhysics(userInit);
943 "Base-class G4RunManager cannot take G4UserWorkerInitialization. Use "
951 "Base-class G4RunManager cannot take G4UserWorkerThreadInitialization. "
952 "Use G4MTRunManager.");
1009 kernel->GeometryHasBeenModified();
1018 G4cout <<
"#### Assemblies, Volumes and Solids Stores are wiped out." <<
G4endl;
1029 for (
const auto& rItr : *regionStore) {
1030 if (rItr->GetName() ==
"DefaultRegionForTheWorld")
continue;
1031 auto lvItr = rItr->GetRootLogicalVolumeIterator();
1032 for (std::size_t iRLV = 0; iRLV < rItr->GetNumberOfRootVolumes(); ++iRLV) {
1033 rItr->RemoveRootLogicalVolume(*lvItr,
false);
1037 G4cout <<
"#### Region <" << rItr->GetName() <<
"> is cleared." <<
G4endl;
1049 kernel->GeometryHasBeenModified();
Helper function for copying random state files in G4run.
G4bool G4CopyRandomState(const G4fs::path &source, const G4fs::path &dest, const G4String &callsite)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define theParticleIterator
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static G4AssemblyStore * GetInstance()
G4int GetNumberOfGrips() const
G4HCofThisEvent * GetHCofThisEvent() const
G4int GetNumberOfCompletedSubEvent() const
G4bool KeepTheEventFlag() const
G4bool ScoresAlreadyRecorded() const
void ScoresRecorded() const
G4int GetNumberOfRemainingSubEvents() const
static G4bool IsInstance()
Return the information if an instance exists.
static G4FieldBuilder * Instance()
static G4GeometryManager * GetInstance()
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
std::size_t GetCapacity()
G4VHitsCollection * GetHC(G4int i)
static G4LogicalVolumeStore * GetInstance()
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
const G4String & GetName() const
G4SmartVoxelHeader * GetVoxelHeader() const
static G4ParallelWorldProcessStore * GetInstance()
void SetLayeredMaterialFlag(G4bool flg=true)
void SetParallelWorld(G4String parallelWorldName)
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4ProcessManager * GetProcessManager() const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
G4UImessenger * CreateMessenger()
static G4PhysicalVolumeStore * GetInstance()
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 G4ProcessTable * GetProcessTable()
static G4RegionStore * GetInstance()
G4bool isScoreNtupleWriter
G4bool geometryInitialized
virtual void CleanUpPreviousEvents()
virtual void CleanUpUnnecessaryEvents(G4int keepNEvents)
G4int storeRandomNumberStatusToG4Event
G4UserWorkerInitialization * userWorkerInitialization
virtual void AbortRun(G4bool softAbort=false)
virtual void Initialize()
virtual void ReportEventDeletion(const G4Event *evt)
std::list< G4Event * > * previousEvents
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
G4bool geometryDirectlyUpdated
G4int numberOfEventProcessed
virtual void RestoreRandomNumberStatus(const G4String &fileN)
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
G4UserEventAction * userEventAction
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
virtual void rndmSaveThisEvent()
virtual void DeleteUserInitializations()
G4RunManagerKernel * kernel
virtual G4bool ConfirmBeamOnCondition()
static G4RunManager * GetRunManager()
virtual void AbortEvent()
virtual void rndmSaveThisRun()
virtual void InitializePhysics()
G4String randomNumberStatusForThisRun
virtual void BeamOn(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
static G4bool IfGeometryHasBeenDestroyed()
G4UserRunAction * userRunAction
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4bool rngStatusEventsFlag
virtual void InitializeGeometry()
virtual void RunTermination()
G4bool physicsInitialized
G4VUserActionInitialization * userActionInitialization
virtual void StackPreviousEvent(G4Event *anEvent)
static G4RUN_DLL G4bool fGeometryHasBeenDestroyed
void ReOptimize(G4LogicalVolume *)
G4VUserDetectorConstruction * userDetector
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
void UpdateScoring(const G4Event *evt=nullptr)
G4int numberOfEventToBeProcessed
G4String randomNumberStatusDir
virtual void TerminateEventLoop()
virtual void SetUserAction(G4UserRunAction *userAction)
G4String randomNumberStatusForThisEvent
void GeometryHasBeenModified(G4bool prop=true)
G4UserTrackingAction * userTrackingAction
G4int n_perviousEventsToBeStored
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void ReOptimizeMotherOf(G4VPhysicalVolume *)
virtual void ProcessOneEvent(G4int i_event)
G4bool storeRandomNumberStatus
virtual G4Event * GenerateEvent(G4int i_event)
G4bool initializedAtLeastOnce
G4EventManager * eventManager
virtual void StoreRNGStatus(const G4String &filenamePrefix)
virtual void DoEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
virtual void TerminateOneEvent()
virtual void RunInitialization()
void DumpRegion(const G4String &rname) const
G4VUserPhysicsList * physicsList
virtual void AnalyzeEvent(G4Event *anEvent)
G4UserStackingAction * userStackingAction
virtual void ConstructScoringWorlds()
G4UserSteppingAction * userSteppingAction
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4HCtable * GetHCtable() const
G4VScoringMesh * GetMesh(G4int i) const
void Accumulate(G4VHitsCollection *map)
const G4String & GetWorldName(G4int i) const
std::size_t GetNumberOfMesh() const
static G4ScoringManager * GetScoringManagerIfExist()
G4long GetMemoryUse() const
G4double GetTotalTime() const
G4long GetNumberPointers() const
G4long GetNumberHeads() const
G4double GetSysTime() const
G4long GetNumberNodes() const
static G4SolidStore * GetInstance()
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)
G4double GetSystemElapsed() const
G4double GetUserElapsed() const
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
static G4TransportationManager * GetTransportationManager()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void ClearParallelWorlds()
G4int ApplyCommand(const char *aCommand)
void SetAlias(const char *aliasLine)
static G4UImanager * GetUIpointer()
static G4VPersistencyManager * GetPersistencyManager()
virtual G4bool Store(const G4Event *anEvent)=0
G4LogicalVolume * GetMotherLogical() const
void SetName(const G4String &pName)
virtual void Fill(G4HCofThisEvent *hce, G4int eventNumber)=0
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0
MeshShape GetShape() const
void GeometryHasBeenDestroyed()
G4ParallelWorldProcess * GetParallelWorldProcess() const
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
virtual void Construct(G4VPhysicalVolume *fWorldPhys)
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0