69 #ifdef theParticleIterator
70 #undef theParticleIterator
76 {
return fRunManagerKernel; }
79 : physicsList(0),currentWorld(0),
80 geometryInitialized(false),physicsInitialized(false),
81 geometryToBeOptimized(true),
82 physicsNeedsToBeReBuilt(true),verboseLevel(0),
83 numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
84 numberOfStaticAllocators(0)
90 if(allocList) numberOfStaticAllocators = allocList->
Size();
94 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel()",
"Run0001",
95 FatalException,
"More than one G4RunManagerKernel is constructed.");
97 fRunManagerKernel =
this;
104 ED<<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<
G4endl;
105 ED<<
" G4RunManagerKernel fatal exception"<<
G4endl;
106 ED<<
" -- Following particles have already been registered"<<
G4endl;
107 ED<<
" before G4RunManagerKernel is instantiated."<<
G4endl;
108 for(
int i=0;i<particleTable->
entries();i++)
110 ED<<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<
G4endl;
111 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel()",
"Run0002",
131 vs = vs.substr(1,vs.size()-2);
132 versionString =
" Geant4 version ";
134 versionString +=
" ";
137 <<
"*************************************************************" <<
G4endl
138 << versionString <<
G4endl
139 <<
" Copyright : Geant4 Collaboration" <<
G4endl
140 <<
" Reference : NIM A 506 (2003), 250-303" <<
G4endl
141 <<
" WWW : http://cern.ch/geant4" <<
G4endl
142 <<
"*************************************************************" <<
G4endl
147 : physicsList(0),currentWorld(0),
148 geometryInitialized(false),physicsInitialized(false),
149 geometryToBeOptimized(true),
150 physicsNeedsToBeReBuilt(true),verboseLevel(0),
151 numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
152 numberOfStaticAllocators(0)
155 #ifndef G4MULTITHREADED
157 msg<<
"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
158 msg<<
" This type of RunManagerKernel can only be used in mult-threaded applications.";
169 if(fRunManagerKernel)
171 G4Exception(
"G4RunManagerKernel::G4RunManagerKernel()",
"Run0001",
172 FatalException,
"More than one G4RunManagerKernel is constructed.");
174 fRunManagerKernel =
this;
199 msgx<<
" This type of RunManagerKernel can only be used in mult-threaded applications.";
209 vs = vs.substr(1,vs.size()-2);
213 versionString =
" Geant4 version ";
215 versionString +=
" ";
218 <<
"*************************************************************" <<
G4endl
219 << versionString <<
G4endl
220 <<
" << in Multi-threaded mode >> " <<
G4endl
221 <<
" Copyright : Geant4 Collaboration" <<
G4endl
222 <<
" Reference : NIM A 506 (2003), 250-303" <<
G4endl
223 <<
" WWW : http://cern.ch/geant4" <<
G4endl
224 <<
"*************************************************************" <<
G4endl
229 versionString =
" Local thread RunManagerKernel version ";
232 <<
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
233 << versionString << G4endl
234 <<
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
239 #ifdef G4MULTITHREADED
256 "Default world region should have a unique logical volume.");
258 std::vector<G4LogicalVolume*>::iterator lvItr
262 <<
"Obsolete world logical volume is removed from the default region." <<
G4endl;
273 if(verboseLevel>0)
G4cout <<
"G4 kernel has come to Quit state." <<
G4endl;
282 if(pwps)
delete pwps;
287 if(verboseLevel>1)
G4cout <<
"G4SDManager deleted." <<
G4endl;
290 if(verboseLevel>1)
G4cout <<
"EventManager deleted." <<
G4endl;
293 if(verboseLevel>1)
G4cout <<
"Units table cleared." <<
G4endl;
303 allocList->
Destroy(numberOfStaticAllocators,verboseLevel);
305 if(verboseLevel>1)
G4cout <<
"G4Allocator objects are deleted." <<
G4endl;
311 G4cout <<
"Thread-local UImanager is to be deleted." << G4endl
312 <<
"There should not be any thread-local G4cout/G4cerr hereafter."
316 if(pUImanager)
delete pUImanager;
317 if(verboseLevel>1)
G4cout <<
"UImanager deleted." <<
G4endl;
319 delete pStateManager;
320 if(verboseLevel>1)
G4cout <<
"StateManager deleted." <<
G4endl;
321 delete defaultExceptionHandler;
322 if(verboseLevel>0)
G4cout <<
"RunManagerKernel is deleted. Good bye :)" <<
G4endl;
323 fRunManagerKernel = 0;
331 G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
332 for(;itrMW!=masterWorlds.end();itrMW++)
350 G4cout <<
"Current application state is "
354 G4Exception(
"G4RunManagerKernel::DefineWorldVolume",
355 "DefineWorldVolumeAtIncorrectState",
357 "Geant4 kernel is not Init state : Method ignored.");
364 G4cout<<
"Warning : Geant4 kernel is not Init state : Assuming Init state."
370 currentWorld = worldVol;
374 G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
375 for(;itrMW!=masterWorlds.end();itrMW++)
377 if((*itrMW).first == 0)
379 if((*itrMW).second != currentWorld)
381 G4Exception(
"G4RunManagerKernel::WorkerDefineWorldVolume",
"RUN3091",
401 geometryInitialized =
true;
414 G4cout <<
"Current application state is "
418 G4Exception(
"G4RunManagerKernel::DefineWorldVolume",
419 "DefineWorldVolumeAtIncorrectState",
421 "Geant4 kernel is not Init state : Method ignored.");
428 G4cout<<
"Warning : Geant4 kernel is not Init state : Assuming Init state."
440 ED <<
"The world volume has a user-defined region <"
443 ED <<
"World would have a default region assigned by RunManagerKernel."
453 currentWorld = worldVol;
461 <<
" is registered to the default region." <<
G4endl;
475 geometryInitialized =
true;
491 G4cout <<
"List of instantiated particles ============================================" <<
G4endl;
493 for(
G4int i=0;i<nPtcl;i++)
539 #ifdef G4MULTITHREADED
554 G4cout <<
"Current application state is "
558 G4Exception(
"G4RunManagerKernel::InitializePhysics",
559 "InitializePhysicsIncorrectState",
561 "Geant4 kernel is not Init state : Method ignored.");
568 G4cout<<
"Warning : Geant4 kernel is not Init state : Assuming Init state."
576 G4Exception(
"G4RunManagerKernel::InitializePhysics",
578 "G4VUserPhysicsList is not defined");
582 if(verboseLevel>1)
G4cout <<
"physicsList->Construct() start." <<
G4endl;
586 if(verboseLevel>1)
G4cout <<
"physicsList->CheckParticleList() start." <<
G4endl;
592 if(verboseLevel>1)
G4cout <<
"physicsList->setCut() start." <<
G4endl;
616 physicsInitialized =
true;
617 #ifdef G4MULTITHREADED
630 if(!geometryInitialized)
632 G4Exception(
"G4RunManagerKernel::RunInitialization",
635 "Geometry has not yet initialized : method ignored.");
639 if(!physicsInitialized)
641 G4Exception(
"G4RunManagerKernel::RunInitialization",
644 "Physics has not yet initialized : method ignored.");
650 G4Exception(
"G4RunManagerKernel::RunInitialization",
653 "Geant4 kernel not in Idle state : method ignored.");
678 #ifdef G4MULTITHREADED
720 if(verboseLevel>1)
G4cout <<
"Start closing geometry." <<
G4endl;
723 geomManager->
CloseGeometry(geometryToBeOptimized, verboseLevel>1);
737 "Geant4 kernel not in Idle state : method ignored.");
753 || physicsNeedsToBeReBuilt)
755 #ifdef G4MULTITHREADED
765 physicsNeedsToBeReBuilt =
false;
777 std::vector<G4VPhysicalVolume*>::iterator wItr;
789 for(
size_t iw=0;iw<nWorlds;iw++)
793 if(*wItr==currentWorld)
808 <<
"> does not have specific production cuts," <<
G4endl
809 <<
"even though it appears in the current tracking world." <<
G4endl;
810 G4cout <<
"Default cuts are used for this region." <<
G4endl;
817 ->GetDefaultProductionCuts());
827 for(
size_t iw=0;iw<nWorlds;iw++)
830 if(*wItr!=currentWorld)
866 G4cout <<
" -- appears in <"
870 {
G4cout <<
" -- is not associated to any world."; }
873 {
G4cout <<
" This region is in the mass world." <<
G4endl; }
875 {
G4cout <<
" This region is in the parallel world." <<
G4endl; }
877 G4cout <<
" Root logical volume(s) : ";
880 for(
size_t j=0;j<nRootLV;j++)
881 {
G4cout << (*lvItr)->GetName() <<
" "; lvItr++; }
889 G4cout <<
" Materials : ";
892 for(
size_t iMate=0;iMate<nMaterial;iMate++)
894 G4cout << (*mItr)->GetName() <<
" ";
902 <<
"> does not have specific production cuts." <<
G4endl;
903 G4cerr <<
"Default cuts are used for this region." <<
G4endl;
909 G4cout <<
" Production cuts : "
924 void G4RunManagerKernel::CheckRegularGeometry()
927 for(G4LogicalVolumeStore::iterator
pos=store->begin();
pos!=store->end();
pos++)
929 if((*
pos)&&((*pos)->GetNoDaughters()==1))
931 if((*pos)->GetDaughter(0)->IsRegularStructure())
945 G4bool G4RunManagerKernel::ConfirmCoupledTransportation()
949 theParticleIterator->
reset();
950 while((*theParticleIterator)())
965 void G4RunManagerKernel::SetScoreSplitter()
973 if( ! InitSplitter ) {
976 theParticleIterator->
reset();
977 while( (*theParticleIterator)() )
987 G4cout <<
"G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all particles." <<
G4endl;
996 theParticleIterator->
reset();
998 while((*theParticleIterator)())
1005 for (
G4int idx = 0 ; idx<procs.
size() ; ++idx)
1007 const G4VProcess* masterP = procs[idx]->GetMasterProcess();
1012 procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
virtual void GeometryHasChanged()=0
static G4Geantino * GeantinoDefinition()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
G4int GetParticleDefinitionID() const
G4Region * defaultRegionForParallelWorld
void InitializeLightIons()
G4ProductionCuts * GetProductionCuts() const
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
virtual void SetupShadowProcess() const
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
void DumpCutValuesTableIfRequested()
const G4String & GetName() const
void SetPhysics(G4VUserPhysicsList *uPhys)
void SetParticleDefinitionID(G4int id=-1)
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=0)
void DumpTable(const G4String &particle_name="ALL")
std::ostringstream G4ExceptionDescription
G4UserSteppingAction * GetRegionalSteppingAction() const
void AddRootLogicalVolume(G4LogicalVolume *lv)
void UsedInParallelGeometry(G4bool val=true)
static G4VVisManager * GetConcreteInstance()
static G4AllocatorList * GetAllocatorListIfExist()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
G4double GetProductionCut(G4int index) const
G4VUserRegionInformation * GetUserInformation() const
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
static masterWorlds_t & GetMasterWorlds()
void SetReadiness(G4bool val=true)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4Region * GetRegion() const
G4ParticleDefinition * GetGenericIon() const
static G4RunManagerKernel * GetRunManagerKernel()
#define G4MUTEX_INITIALIZER
G4bool RunInitialization(G4bool fakeRun=false)
const G4String & GetParticleName() const
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4bool IsGeneralIon() const
static void ConstructParticle()
static G4UImanager * GetUIpointer()
static G4ParallelWorldProcessStore * GetInstanceIfExist()
static G4RegionStore * GetInstance()
static G4StateManager * GetStateManager()
void SetRegion(G4Region *reg)
G4VPhysicalVolume * GetWorldPhysical() const
G4ParticleDefinition * GetParticle(G4int index) const
G4IonTable * GetIonTable() const
void DumpCutValuesTable(G4int flag=1)
G4GLOB_DLL std::ostream G4cout
G4bool SetNewState(G4ApplicationState requestedState)
void PhysicsTableUpdated()
void reset(G4bool ifSkipIon=true)
const G4String & GetName() const
static void InvalidOperationDetection()
void DumpRegion(const G4String &rname) const
static G4MTRunManager * GetMasterRunManager()
void UsedInMassGeometry(G4bool val=true)
static const G4String G4Version
#define theParticleIterator
static G4LogicalVolumeStore * GetInstance()
static const G4String G4Date
G4ApplicationState GetCurrentState() const
RMKType runManagerKernelType
static G4GeometryManager * GetInstance()
const G4String & GetProcessName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetupDefaultRegion()
static G4TransportationManager * GetTransportationManager()
static void ClearUnitsTable()
static G4UnitsTable & GetUnitsTable()
static G4ProductionCutsTable * GetProductionCutsTable()
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
void UseCoupledTransportation(G4bool vl=true)
G4LogicalVolume * GetLogicalVolume() const
void SetWorld(G4VPhysicalVolume *wp)
static G4ParticleTable * GetParticleTable()
G4ProcessManager * GetProcessManager() const
G4PrimaryTransformer * GetPrimaryTransformer() const
G4bool IsInMassGeometry() const
size_t GetNoWorlds() const
void Destroy(G4int nStat=0, G4int verboseLevel=0)
void SetProductionCuts(G4ProductionCuts *cut)
void OpenGeometry(G4VPhysicalVolume *vol=0)
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
virtual void ConstructParticle()=0
const G4String & GetName() const
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)
size_t GetNumberOfMaterials() const
void SetWorldForTracking(G4VPhysicalVolume *theWorld)
void BuildPhysicsTables(G4bool fakeRun)
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
static G4NavigationHistoryPool * GetInstance()
size_t GetNumberOfRootVolumes() const
virtual ~G4RunManagerKernel()
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
void WorkerUpdateWorldVolume()
G4bool IsInParallelGeometry() const
G4PTblDicIterator * GetIterator() const
G4FastSimulationManager * GetFastSimulationManager() const
G4UserLimits * GetUserLimits() const
static const G4double pos
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=0)
void PropagateGenericIonID()
G4int ApplyCommand(const char *aCommand)
G4ProcessVector * GetProcessList() const
G4GLOB_DLL std::ostream G4cerr
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4String GetStateString(G4ApplicationState aState) const
static G4SDManager * GetSDMpointerIfExist()
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()
G4bool geometryNeedsToBeClosed