92#ifdef theParticleIterator
93# undef theParticleIterator
115 if (fRunManager !=
nullptr) {
117 "G4RunManager constructed twice.");
129 std::ostringstream oss;
130 G4Random::saveFullState(oss);
141#ifndef G4MULTITHREADED
143 msg <<
"Geant4 code is compiled without multi-threading support "
144 "(-DG4MULTITHREADED is set to off).";
145 msg <<
" This type of RunManager can only be used in mult-threaded "
150 if (fRunManager !=
nullptr) {
152 "G4RunManager constructed twice.");
166 msgx <<
"This type of RunManager can only be used in multi-threaded "
181 std::ostringstream oss;
182 G4Random::saveFullState(oss);
202 <<
" events kept in eventVector";
229 fRunManager =
nullptr;
281 G4cerr <<
"Illegal application state - BeamOn() ignored." <<
G4endl;
286 G4cerr <<
" Geant4 kernel should be initialized" <<
G4endl;
287 G4cerr <<
"before the first BeamOn(). - BeamOn ignored." <<
G4endl;
296 G4cout <<
"has been modified since last Run." <<
G4endl;
316 <<
" events kept in eventVector";
335 if (fSDM !=
nullptr) {
345 std::ostringstream oss;
346 G4Random::saveFullState(oss);
366 std::ostringstream os;
380 for (
G4int i_event = 0; i_event < n_event; ++i_event) {
399 if (macroFile !=
nullptr) {
452 "G4VUserPrimaryGeneratorAction is not defined!");
456 auto anEvent =
new G4Event(i_event);
459 std::ostringstream oss;
460 G4Random::saveFullState(oss);
468 std::ostringstream os;
469 os <<
"run" <<
currentRun->GetRunID() <<
"evt" << anEvent->GetEventID();
476 G4cout <<
"--> Event " << anEvent->GetEventID() <<
" starts." <<
G4endl;
486 G4Random::saveEngineStatus(fileN);
493 if (fPersM !=
nullptr) fPersM->
Store(anEvent);
538 if (evt !=
nullptr && !(evt->
ToBeKept())) {
561 if (evt !=
nullptr) {
622 G4cerr <<
"Illegal application state - "
623 <<
"G4RunManager::Initialize() ignored." <<
G4endl;
641 "G4VUserDetectorConstruction is not defined!");
679 kernel->InitializePhysics();
683 "G4VUserPhysicsList is not defined!");
702 G4cerr <<
"Run is not in progress. AbortRun() ignored." <<
G4endl;
716 G4cerr <<
"Event is not in progress. AbortEevnt() ignored." <<
G4endl;
723 kernel->DefineWorldVolume(worldVol, topologyIsChanged);
732 G4cerr <<
"Warning from G4RunManager::rndmSaveThisRun():"
733 <<
" Random number status was not stored prior to this run." <<
G4endl
734 <<
"/random/setSavingFlag command must be issued. "
735 <<
"Command ignored." <<
G4endl;
741 std::ostringstream os;
742 os <<
"run" << runNumber <<
".rndm" <<
'\0';
747 G4cout << fileIn <<
" is copied to " << fileOut <<
G4endl;
755 G4cerr <<
"Warning from G4RunManager::rndmSaveThisEvent():"
756 <<
" there is no currentEvent available." <<
G4endl <<
"Command ignored." <<
G4endl;
761 G4cerr <<
"Warning from G4RunManager::rndmSaveThisEvent():"
762 <<
" Random number engine status is not available." <<
G4endl
763 <<
"/random/setSavingFlag command must be issued "
764 <<
"prior to the start of the run. Command ignored." <<
G4endl;
770 std::ostringstream os;
776 G4cout << fileIn <<
" is copied to " << fileOut <<
G4endl;
784 if (fileN.find(
'/') == std::string::npos) {
788 fileNameWithDirectory = fileN;
791 G4Random::restoreEngineStatus(fileNameWithDirectory);
793 G4cout <<
"RandomNumberEngineStatus restored from file: " << fileNameWithDirectory <<
G4endl;
794 G4Random::showEngineStatus();
800 kernel->DumpRegion(rname);
806 kernel->DumpRegion(region);
815 if (ScM ==
nullptr)
return;
818 if (nPar < 1)
return;
821 for (
G4int iw = 0; iw < nPar; ++iw) {
825 if (mesh->
GetShape() != MeshShape::realWorldLogVol) {
828 if (pWorld ==
nullptr) {
834 if (theParallelWorldProcess !=
nullptr) {
846 if (pmanager !=
nullptr) {
847 pmanager->
AddProcess(theParallelWorldProcess);
879 "Double-counting!!!");
885 if (ScM ==
nullptr)
return;
887 if (nPar < 1)
return;
890 if (HCE ==
nullptr)
return;
892 for (
G4int i = 0; i < nColl; ++i) {
902 if (pMotherL !=
nullptr)
ReOptimize(pMotherL);
938 kernel->SetPhysics(userInit);
945 "Base-class G4RunManager cannot take G4UserWorkerInitialization. Use "
953 "Base-class G4RunManager cannot take G4UserWorkerThreadInitialization. "
954 "Use G4MTRunManager.");
1011 kernel->GeometryHasBeenModified();
1020 G4cout <<
"#### Assembly, Volume, Solid, and Surface Stores are being cleaned." <<
G4endl;
1033 for (
const auto& rItr : *regionStore) {
1034 if (rItr->GetName() ==
"DefaultRegionForTheWorld")
continue;
1035 auto lvItr = rItr->GetRootLogicalVolumeIterator();
1036 for (std::size_t iRLV = 0; iRLV < rItr->GetNumberOfRootVolumes(); ++iRLV) {
1037 rItr->RemoveRootLogicalVolume(*lvItr,
false);
1041 G4cout <<
"#### Region <" << rItr->GetName() <<
"> is cleared." <<
G4endl;
1053 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()
static G4FieldBuilder * Instance()
static G4GeometryManager * GetInstance()
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
std::size_t GetCapacity()
G4VHitsCollection * GetHC(G4int i)
static void CleanSurfaceTable()
static void CleanSurfaceTable()
static G4LogicalVolumeStore * GetInstance()
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
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()
G4RegionStore is a singleton class, acting as container for all geometrical regions,...
static G4RegionStore * GetInstance()
G4Region defines a region or a group of regions in the detector geometry setup, sharing properties as...
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()
G4SmartVoxelStat stores the information on the performance of the smart voxel optimisation algorithm ...
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
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
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