90#ifdef theParticleIterator
91# undef theParticleIterator
95G4RunManagerKernel::fRunManagerKernel =
nullptr;
100 return fRunManagerKernel;
107 InvalidOperationDetection();
111 auto _signals = G4GetEnv<std::string>(
"G4BACKTRACE",
"");
123 if(allocList !=
nullptr)
124 numberOfStaticAllocators = (
G4int)allocList->
Size();
130 if(fRunManagerKernel !=
nullptr)
132 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel()",
"Run0001",
134 "More than one G4RunManagerKernel is constructed.");
136 fRunManagerKernel =
this;
139 if(particleTable->
entries() > 0)
143 ED <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" <<
G4endl;
144 ED <<
" G4RunManagerKernel fatal exception" <<
G4endl;
145 ED <<
" -- Following particles have already been registered" <<
G4endl;
146 ED <<
" before G4RunManagerKernel is instantiated." <<
G4endl;
152 ED <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" <<
G4endl;
153 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel()",
"Run0002",
162 new G4Region(
"DefaultRegionForParallelWorld");
165 ->GetDefaultProductionCuts());
168 ->GetDefaultProductionCuts());
176 vs = vs.substr(1, vs.size() - 2);
177 versionString =
" Geant4 version ";
179 versionString +=
" ";
180 versionString += G4Date;
182 <<
"**************************************************************"
184 <<
" Copyright : Geant4 Collaboration" <<
G4endl
185 <<
" References : NIM A 506 (2003), 250-303"
187 <<
" : IEEE-TNS 53 (2006), 270-278"
189 <<
" : NIM A 835 (2016), 186-225"
190 <<
G4endl <<
" WWW : http://geant4.org/"
192 <<
"**************************************************************"
200 #ifndef G4MULTITHREADED
202 msg <<
"Geant4 code is compiled without multi-threading support "
203 "(-DG4MULTITHREADED is set to off).";
204 msg <<
" This type of RunManagerKernel can only be used in mult-threaded "
206 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel(G4bool)",
"Run0105",
213 InvalidOperationDetection();
218 auto _signals = G4GetEnv<std::string>(
"G4BACKTRACE",
"");
234 if(fRunManagerKernel !=
nullptr)
236 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel()",
"Run0001",
238 "More than one G4RunManagerKernel is constructed.");
240 fRunManagerKernel =
this;
249 new G4Region(
"DefaultRegionForTheWorld");
251 new G4Region(
"DefaultRegionForParallelWorld");
254 ->GetDefaultProductionCuts());
257 ->GetDefaultProductionCuts());
262 "DefaultRegionForTheWorld",
true);
264 "DefaultRegionForParallelWorld",
true);
271 <<
" This type of RunManagerKernel can only be used in mult-threaded "
273 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel(G4bool)",
"Run0106",
283 vs = vs.substr(1, vs.size() - 2);
287 versionString =
" Geant4 version ";
289 versionString +=
" ";
290 versionString += G4Date;
292 <<
"**************************************************************"
294 <<
" << in Multi-threaded mode >> " <<
G4endl
295 <<
" Copyright : Geant4 Collaboration"
297 <<
" References : NIM A 506 (2003), 250-303"
299 <<
" : IEEE-TNS 53 (2006), 270-278"
301 <<
" : NIM A 835 (2016), 186-225"
303 <<
" WWW : http://geant4.org/"
305 <<
"**************************************************************"
311 versionString =
" Local thread RunManagerKernel version ";
315 <<
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
318 <<
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
324 #ifdef G4MULTITHREADED
341 "Default world region should have a unique logical volume.");
347 <<
"Obsolete world logical volume is removed from the default region."
360 G4cout <<
"G4 kernel has come to Quit state." <<
G4endl;
406 allocList->
Destroy(numberOfStaticAllocators, verboseLevel);
415 G4cout <<
"Thread-local UImanager is to be deleted." <<
G4endl
416 <<
"There should not be any thread-local G4cout/G4cerr hereafter."
423 delete pStateManager;
426 delete defaultExceptionHandler;
428 G4cout <<
"RunManagerKernel is deleted. Good bye :)" <<
G4endl;
429 fRunManagerKernel =
nullptr;
439 for(
auto itrMW = masterWorlds.cbegin();
440 itrMW != masterWorlds.cend(); ++itrMW)
446 if(pWorld ==
nullptr)
463 G4cout <<
"Current application state is "
465 G4Exception(
"G4RunManagerKernel::DefineWorldVolume",
467 "Geant4 kernel is not Init state : Method ignored.");
476 currentWorld = worldVol;
481 for(
auto itrMW = masterWorlds.cbegin();
482 itrMW != masterWorlds.cend(); ++itrMW)
484 if((*itrMW).first == 0)
486 if((*itrMW).second != currentWorld)
488 G4Exception(
"G4RunManagerKernel::WorkerDefineWorldVolume",
"RUN3091",
499 if(topologyIsChanged)
506 if(pVVisManager !=
nullptr)
510 geometryInitialized =
true;
529 G4cout <<
"Current application state is "
531 G4Exception(
"G4RunManagerKernel::DefineWorldVolume",
533 "Geant4 kernel is not Init state : Method ignored.");
548 ED <<
"The world volume has a user-defined region <"
551 ED <<
"World would have a default region assigned by RunManagerKernel."
561 currentWorld = worldVol;
569 G4cout << worldLog->
GetName() <<
" is registered to the default region."
575 if(topologyIsChanged)
582 if(pVVisManager !=
nullptr)
586 geometryInitialized =
true;
607 G4cout <<
"List of instantiated particles "
608 "============================================"
611 for(
G4int i = 0; i < nPtcl; ++i)
660#ifdef G4MULTITHREADED
678 G4cout <<
"Current application state is "
682 G4Exception(
"G4RunManagerKernel::InitializePhysics",
684 "Geant4 kernel is not Init state : Method ignored.");
693 <<
"Warning : Geant4 kernel is not Init state : Assuming Init state."
699 if(physicsList ==
nullptr)
701 G4Exception(
"G4RunManagerKernel::InitializePhysics",
"Run0012",
708 if(numberOfParallelWorld > 0)
713 G4cout <<
"physicsList->CheckParticleList() start." <<
G4endl;
748 physicsInitialized =
true;
749#ifdef G4MULTITHREADED
765 if(!geometryInitialized)
768 "Geometry has not yet initialized : method ignored.");
772 if(!physicsInitialized)
775 "Physics has not yet initialized : method ignored.");
782 "Geant4 kernel not in Idle state : method ignored.");
787 CheckRegularGeometry();
803 if(pVVisManager !=
nullptr)
810#ifdef G4MULTITHREADED
865 geomManager->
CloseGeometry(geometryToBeOptimized, verboseLevel > 1);
878 "Geant4 kernel not in Init state : method ignored.");
897 physicsNeedsToBeReBuilt)
899 #ifdef G4MULTITHREADED
909 physicsNeedsToBeReBuilt =
false;
912 if(!fakeRun && verboseLevel > 1)
914 if(!fakeRun && verboseLevel > 0)
926 std::vector<G4VPhysicalVolume*>::iterator wItr;
939 for(std::size_t iw = 0; iw < nWorlds; ++iw)
943 if(*wItr == currentWorld)
962 <<
"> does not have specific production cuts," <<
G4endl
963 <<
"even though it appears in the current tracking world."
965 G4cout <<
"Default cuts are used for this region." <<
G4endl;
982 for(std::size_t iw = 0; iw < nWorlds; ++iw)
984 if(*wItr != currentWorld)
1001 if(region !=
nullptr)
1008 if(region ==
nullptr)
1024 <<
"> world volume";
1028 G4cout <<
" -- is not associated to any world.";
1033 G4cout <<
" This region is in the mass world." <<
G4endl;
1037 G4cout <<
" This region is in the parallel world." <<
G4endl;
1040 G4cout <<
" Root logical volume(s) : ";
1043 for(std::size_t j = 0; j < nRootLV; ++j)
1045 G4cout << (*lvItr)->GetName() <<
" ";
1050 G4cout <<
" Pointers : G4VUserRegionInformation["
1056 G4cout <<
" Materials : ";
1059 for(std::size_t iMate = 0; iMate < nMaterial; ++iMate)
1061 G4cout << (*mItr)->GetName() <<
" ";
1069 <<
"> does not have specific production cuts." <<
G4endl;
1070 G4cerr <<
"Default cuts are used for this region." <<
G4endl;
1072 ->GetDefaultProductionCuts());
1074 else if(cuts !=
nullptr)
1076 G4cout <<
" Production cuts : "
1089void G4RunManagerKernel::CheckRegularGeometry()
1092 for(
auto pos = store->cbegin(); pos != store->cend(); ++pos)
1094 if((*pos) && ((*pos)->GetNoDaughters() == 1))
1096 if((*pos)->GetDaughter(0)->IsRegularStructure())
1106G4bool G4RunManagerKernel::ConfirmCoupledTransportation()
1126void G4RunManagerKernel::SetScoreSplitter()
1136 InitSplitter =
true;
1149 if(verboseLevel > 0)
1152 <<
"G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all "
1175 const G4VProcess* masterP = procs[idx]->GetMasterProcess();
1176 if(masterP ==
nullptr)
1180 procs[idx]->SetMasterProcess(
const_cast<G4VProcess*
>(procs[idx]));
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
#define theParticleIterator
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static G4AllocatorList * GetAllocatorListIfExist()
void Destroy(G4int nStat=0, G4int verboseLevel=0)
static G4int Enable(const std::string &)
static G4FieldManagerStore * GetInstanceIfExist()
static G4Geantino * GeantinoDefinition()
static G4GeometryManager * GetInstance()
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
static G4GeometryManager * GetInstanceIfExist()
static void ConstructParticle()
void InitializeLightIons()
static G4LogicalVolumeStore * GetInstance()
void SetRegion(G4Region *reg)
G4Region * GetRegion() const
const G4String & GetName() const
static G4MTRunManager * GetMasterRunManager()
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
static masterWorlds_t & GetMasterWorlds()
static G4NavigationHistoryPool * GetInstance()
static G4ParallelWorldProcessStore * GetInstanceIfExist()
G4ProcessManager * GetProcessManager() const
G4bool IsGeneralIon() const
void SetParticleDefinitionID(G4int id=-1)
G4int GetParticleDefinitionID() const
const G4String & GetParticleName() const
void reset(G4bool ifSkipIon=true)
G4IonTable * GetIonTable() const
G4ParticleDefinition * GetParticle(G4int index) const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
void SetReadiness(G4bool val=true)
G4ParticleDefinition * GetGenericIon() const
void DumpTable(const G4String &particle_name="ALL")
static G4PathFinder * GetInstanceIfExist()
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4ProcessVector * GetProcessList() const
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
void PhysicsTableUpdated()
static G4ProductionCutsTable * GetProductionCutsTable()
G4ProductionCuts * GetDefaultProductionCuts() const
G4double GetProductionCut(G4int index) const
static G4RegionStore * GetInstance()
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=nullptr)
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
std::size_t GetNumberOfRootVolumes() const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
std::size_t GetNumberOfMaterials() const
G4FastSimulationManager * GetFastSimulationManager() const
G4VUserRegionInformation * GetUserInformation() const
void SetWorld(G4VPhysicalVolume *wp)
G4bool IsInParallelGeometry() const
G4ProductionCuts * GetProductionCuts() const
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
G4VPhysicalVolume * GetWorldPhysical() const
void SetProductionCuts(G4ProductionCuts *cut)
G4UserLimits * GetUserLimits() const
const G4String & GetName() const
G4bool IsInMassGeometry() const
G4UserSteppingAction * GetRegionalSteppingAction() const
void UsedInParallelGeometry(G4bool val=true)
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
void AddRootLogicalVolume(G4LogicalVolume *lv, G4bool search=true)
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()
void UsedInMassGeometry(G4bool val=true)
void SetupDefaultRegion()
G4PrimaryTransformer * GetPrimaryTransformer() const
G4Region * defaultRegionForParallelWorld
static G4RunManagerKernel * GetRunManagerKernel()
void SetPhysics(G4VUserPhysicsList *uPhys)
RMKType runManagerKernelType
void WorkerUpdateWorldVolume()
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
void PropagateGenericIonID()
G4bool RunInitialization(G4bool fakeRun=false)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
virtual void SetupShadowProcess() const
virtual ~G4RunManagerKernel()
void DumpRegion(const G4String &rname) const
G4bool geometryNeedsToBeClosed
void BuildPhysicsTables(G4bool fakeRun)
static G4SDManager * GetSDMpointerIfExist()
const G4ApplicationState & GetCurrentState() const
G4VExceptionHandler * GetExceptionHandler() const
G4String GetStateString(const G4ApplicationState &aState) const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)
static G4TemplateRNGHelper< T > * GetInstanceIfExist()
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)
static G4TransportationManager * GetTransportationManager()
static G4TransportationManager * GetInstanceIfExist()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetWorldForTracking(G4VPhysicalVolume *theWorld)
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
static void ClearUnitsTable()
static G4UnitsTable & GetUnitsTable()
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
const G4String & GetProcessName() const
void UseCoupledTransportation(G4bool vl=true)
virtual void ConstructParticle()=0
void DumpCutValuesTableIfRequested()
void DumpCutValuesTable(G4int flag=1)
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0