Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RunManagerKernel Class Reference

#include <G4RunManagerKernel.hh>

+ Inheritance diagram for G4RunManagerKernel:

Public Types

enum  RMKType { sequentialRMK , masterRMK , workerRMK }
 

Public Member Functions

 G4RunManagerKernel ()
 
virtual ~G4RunManagerKernel ()
 
void DefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
void WorkerDefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
void SetPhysics (G4VUserPhysicsList *uPhys)
 
void InitializePhysics ()
 
G4bool RunInitialization (G4bool fakeRun=false)
 
void RunTermination ()
 
void UpdateRegion ()
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=nullptr) const
 
void WorkerUpdateWorldVolume ()
 
void GeometryHasBeenModified ()
 
void PhysicsHasBeenModified ()
 
G4EventManagerGetEventManager () const
 
G4StackManagerGetStackManager () const
 
G4TrackingManagerGetTrackingManager () const
 
void SetPrimaryTransformer (G4PrimaryTransformer *pt)
 
G4PrimaryTransformerGetPrimaryTransformer () const
 
const G4StringGetVersionString () const
 
void SetVerboseLevel (G4int vl)
 
void SetGeometryToBeOptimized (G4bool vl)
 
G4int GetNumberOfParallelWorld () const
 
void SetNumberOfParallelWorld (G4int i)
 
G4VUserPhysicsListGetPhysicsList () const
 
G4VPhysicalVolumeGetCurrentWorld () const
 
G4int GetNumberOfStaticAllocators () const
 

Static Public Member Functions

static G4RunManagerKernelGetRunManagerKernel ()
 

Protected Member Functions

 G4RunManagerKernel (RMKType rmkType)
 
void SetupDefaultRegion ()
 
void SetupPhysics ()
 
void ResetNavigator ()
 
void BuildPhysicsTables (G4bool fakeRun)
 
void CheckRegions ()
 
virtual void SetupShadowProcess () const
 
void PropagateGenericIonID ()
 

Protected Attributes

RMKType runManagerKernelType
 
G4RegiondefaultRegion = nullptr
 
G4RegiondefaultRegionForParallelWorld = nullptr
 
G4bool geometryNeedsToBeClosed = true
 

Detailed Description

Definition at line 64 of file G4RunManagerKernel.hh.

Member Enumeration Documentation

◆ RMKType

Enumerator
sequentialRMK 
masterRMK 
workerRMK 

Definition at line 176 of file G4RunManagerKernel.hh.

Constructor & Destructor Documentation

◆ G4RunManagerKernel() [1/2]

G4RunManagerKernel::G4RunManagerKernel ( )

Definition at line 104 of file G4RunManagerKernel.cc.

105{
106 #ifdef G4FPE_DEBUG
107 InvalidOperationDetection();
108 #endif
109
110 #ifdef G4BT_DEBUG
111 auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
112 if(_signals.empty())
113 {
115 }
116 else
117 {
118 G4Backtrace::Enable(_signals);
119 }
120 #endif
121
123 if(allocList != nullptr)
124 numberOfStaticAllocators = (G4int)allocList->Size();
125
127 {
128 defaultExceptionHandler = new G4ExceptionHandler();
129 }
130 if(fRunManagerKernel != nullptr)
131 {
132 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0001",
134 "More than one G4RunManagerKernel is constructed.");
135 }
136 fRunManagerKernel = this;
137
139 if(particleTable->entries() > 0)
140 {
141 // No particle should be registered beforehand
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;
147 for(G4int i = 0; i < particleTable->entries(); ++i)
148 {
149 ED << " " << particleTable->GetParticle(i)->GetParticleName()
150 << G4endl;
151 }
152 ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
153 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0002",
154 FatalException, ED);
155 }
156
157 // construction of Geant4 kernel classes
158 eventManager = new G4EventManager();
159
160 defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
162 new G4Region("DefaultRegionForParallelWorld"); // deleted by store
165 ->GetDefaultProductionCuts());
168 ->GetDefaultProductionCuts());
169
171 // set the initial application state
173
174 // version banner
175 G4String vs = G4Version;
176 vs = vs.substr(1, vs.size() - 2);
177 versionString = " Geant4 version ";
178 versionString += vs;
179 versionString += " ";
180 versionString += G4Date;
181 G4cout << G4endl
182 << "**************************************************************"
183 << G4endl << versionString << G4endl
184 << " Copyright : Geant4 Collaboration" << G4endl
185 << " References : NIM A 506 (2003), 250-303"
186 << G4endl
187 << " : IEEE-TNS 53 (2006), 270-278"
188 << G4endl
189 << " : NIM A 835 (2016), 186-225"
190 << G4endl << " WWW : http://geant4.org/"
191 << G4endl
192 << "**************************************************************"
193 << G4endl << G4endl;
194}
@ G4State_PreInit
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4AllocatorList * GetAllocatorListIfExist()
std::size_t Size() const
static G4int Enable(const std::string &)
Definition: G4Backtrace.hh:756
const G4String & GetParticleName() const
G4ParticleDefinition * GetParticle(G4int index) const
G4int entries() const
static G4ParticleTable * GetParticleTable()
static G4ProductionCutsTable * GetProductionCutsTable()
void SetProductionCuts(G4ProductionCuts *cut)
G4Region * defaultRegionForParallelWorld
G4VExceptionHandler * GetExceptionHandler() const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)

◆ ~G4RunManagerKernel()

G4RunManagerKernel::~G4RunManagerKernel ( )
virtual

Definition at line 353 of file G4RunManagerKernel.cc.

354{
356 // set the application state to the quite state
357 if(pStateManager->GetCurrentState() != G4State_Quit)
358 {
359 if(verboseLevel > 1)
360 G4cout << "G4 kernel has come to Quit state." << G4endl;
361 pStateManager->SetNewState(G4State_Quit);
362 }
363
364 // open geometry for deletion
366
367 // deletion of Geant4 kernel classes
370 if(verboseLevel > 1)
371 G4cout << "G4SDManager deleted." << G4endl;
372 delete eventManager;
373 if(verboseLevel > 1)
374 G4cout << "EventManager deleted." << G4endl;
375
377 if(verboseLevel > 1)
378 G4cout << "Units table cleared." << G4endl;
379
380 // deletion of path-finder field-manager store, geometry and transportation
381 // manager
386 if(verboseLevel > 1)
387 G4cout << "TransportationManager deleted." << G4endl;
388
389 // deletion of navigation levels
390 if(verboseLevel > 1)
393
394 // deletion of G4RNGHelper singleton
396 {
398 if(verboseLevel > 1)
399 G4cout << "G4RNGHelper object is deleted." << G4endl;
400 }
401
402 // deletion of allocators
404 if(allocList)
405 {
406 allocList->Destroy(numberOfStaticAllocators, verboseLevel);
407 delete allocList;
408 if(verboseLevel > 1)
409 G4cout << "G4Allocator objects are deleted." << G4endl;
410 }
411
413 if((runManagerKernelType == workerRMK) && (verboseLevel > 1))
414 {
415 G4cout << "Thread-local UImanager is to be deleted." << G4endl
416 << "There should not be any thread-local G4cout/G4cerr hereafter."
417 << G4endl;
418 }
419 delete pUImanager;
420 if(verboseLevel > 1)
421 G4cout << "UImanager deleted." << G4endl;
422
423 delete pStateManager;
424 if(verboseLevel > 1)
425 G4cout << "StateManager deleted." << G4endl;
426 delete defaultExceptionHandler;
427 if(verboseLevel > 1)
428 G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
429 fRunManagerKernel = nullptr;
430}
@ G4State_Quit
void Destroy(G4int nStat=0, G4int verboseLevel=0)
static G4FieldManagerStore * GetInstanceIfExist()
static G4GeometryManager * GetInstance()
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
static G4GeometryManager * GetInstanceIfExist()
static G4NavigationHistoryPool * GetInstance()
static G4ParallelWorldProcessStore * GetInstanceIfExist()
static G4PathFinder * GetInstanceIfExist()
Definition: G4PathFinder.cc:66
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:47
const G4ApplicationState & GetCurrentState() const
static G4TemplateRNGHelper< T > * GetInstanceIfExist()
Definition: G4RNGHelper.cc:53
static G4TransportationManager * GetInstanceIfExist()
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
static void ClearUnitsTable()

◆ G4RunManagerKernel() [2/2]

G4RunManagerKernel::G4RunManagerKernel ( RMKType  rmkType)
protected

Definition at line 197 of file G4RunManagerKernel.cc.

198{
199 // This version of the constructor should never be called in sequential mode!
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 "
205 "applications.";
206 G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)", "Run0105",
207 FatalException, msg);
208 #endif
209
210 #ifdef G4FPE_DEBUG
212 {
213 InvalidOperationDetection();
214 }
215 #endif
216
217 #ifdef G4BT_DEBUG
218 auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
219 if(_signals.empty())
220 {
222 }
223 else
224 {
225 G4Backtrace::Enable(_signals);
226 }
227 #endif
228
229 if(G4StateManager::GetStateManager()->GetExceptionHandler() == nullptr)
230 {
231 defaultExceptionHandler = new G4ExceptionHandler();
232 }
233
234 if(fRunManagerKernel != nullptr)
235 {
236 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0001",
238 "More than one G4RunManagerKernel is constructed.");
239 }
240 fRunManagerKernel = this;
241 // construction of Geant4 kernel classes
242 eventManager = new G4EventManager();
243
244 switch(rmkType)
245 {
246 case masterRMK:
247 // Master thread behvior
249 new G4Region("DefaultRegionForTheWorld"); // deleted by store
251 new G4Region("DefaultRegionForParallelWorld"); // deleted by store
254 ->GetDefaultProductionCuts());
257 ->GetDefaultProductionCuts());
258 break;
259 case workerRMK:
260 // Worker thread behavior
262 "DefaultRegionForTheWorld", true);
264 "DefaultRegionForParallelWorld", true);
265 break;
266 default:
267 defaultRegion = nullptr;
270 msgx
271 << " This type of RunManagerKernel can only be used in mult-threaded "
272 "applications.";
273 G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)", "Run0106",
274 FatalException, msgx);
275 }
276 runManagerKernelType = rmkType;
277
278 // set the initial application state
280
281 // version banner
282 G4String vs = G4Version;
283 vs = vs.substr(1, vs.size() - 2);
284 switch(rmkType)
285 {
286 case masterRMK:
287 versionString = " Geant4 version ";
288 versionString += vs;
289 versionString += " ";
290 versionString += G4Date;
291 G4cout << G4endl
292 << "**************************************************************"
293 << G4endl << versionString << G4endl
294 << " << in Multi-threaded mode >> " << G4endl
295 << " Copyright : Geant4 Collaboration"
296 << G4endl
297 << " References : NIM A 506 (2003), 250-303"
298 << G4endl
299 << " : IEEE-TNS 53 (2006), 270-278"
300 << G4endl
301 << " : NIM A 835 (2016), 186-225"
302 << G4endl
303 << " WWW : http://geant4.org/"
304 << G4endl
305 << "**************************************************************"
306 << G4endl << G4endl;
307 break;
308 default:
309 if(verboseLevel)
310 {
311 versionString = " Local thread RunManagerKernel version ";
312 versionString += vs;
313 G4cout
314 << G4endl
315 << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
316 "^^^^^^^^^"
317 << G4endl << versionString << G4endl
318 << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
319 "^^^^^^^^^"
320 << G4endl << G4endl;
321 }
322 }
323
324 #ifdef G4MULTITHREADED
325 G4UnitDefinition::GetUnitsTable().Synchronize();
326 #endif
327}
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
static G4UnitsTable & GetUnitsTable()
G4bool IsMasterThread()
Definition: G4Threading.cc:124

Member Function Documentation

◆ BuildPhysicsTables()

void G4RunManagerKernel::BuildPhysicsTables ( G4bool  fakeRun)
protected

Definition at line 894 of file G4RunManagerKernel.cc.

895{
897 physicsNeedsToBeReBuilt)
898 {
899 #ifdef G4MULTITHREADED
901 {
902 // make sure workers also rebuild physics tables
904 pUImanager->ApplyCommand("/run/physicsModified");
905 }
906 #endif
907 physicsList->BuildPhysicsTable();
908 ////G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();
909 physicsNeedsToBeReBuilt = false;
910 }
911
912 if(!fakeRun && verboseLevel > 1)
913 DumpRegion();
914 if(!fakeRun && verboseLevel > 0)
915 physicsList->DumpCutValuesTable();
916 if(!fakeRun)
917 physicsList->DumpCutValuesTableIfRequested();
918}
void DumpRegion(const G4String &rname) const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
void DumpCutValuesTable(G4int flag=1)

Referenced by RunInitialization().

◆ CheckRegions()

void G4RunManagerKernel::CheckRegions ( )
protected

Definition at line 921 of file G4RunManagerKernel.cc.

922{
925 std::size_t nWorlds = transM->GetNoWorlds();
926 std::vector<G4VPhysicalVolume*>::iterator wItr;
927 for(std::size_t i = 0; i < G4RegionStore::GetInstance()->size(); ++i)
928 {
929 G4Region* region = (*(G4RegionStore::GetInstance()))[i];
930
931 // Let each region have a pointer to the world volume where it belongs to.
932 // G4Region::SetWorld() checks if the region belongs to the given world and
933 // set it only if it does. Thus, here we go through all the registered world
934 // volumes.
935 region->SetWorld(nullptr); // reset
936 region->UsedInMassGeometry(false);
937 region->UsedInParallelGeometry(false);
938 wItr = transM->GetWorldsIterator();
939 for(std::size_t iw = 0; iw < nWorlds; ++iw)
940 {
941 if(region->BelongsTo(*wItr))
942 {
943 if(*wItr == currentWorld)
944 {
945 region->UsedInMassGeometry(true);
946 }
947 else
948 {
949 region->UsedInParallelGeometry(true);
950 }
951 }
952 region->SetWorld(*wItr);
953 ++wItr;
954 }
955
956 G4ProductionCuts* cuts = region->GetProductionCuts();
957 if(cuts == nullptr)
958 {
959 if(region->IsInMassGeometry() && verboseLevel > 0)
960 {
961 G4cout << "Warning : Region <" << region->GetName()
962 << "> does not have specific production cuts," << G4endl
963 << "even though it appears in the current tracking world."
964 << G4endl;
965 G4cout << "Default cuts are used for this region." << G4endl;
966 }
967
968 if(region->IsInMassGeometry() || region->IsInParallelGeometry())
969 {
970 region->SetProductionCuts(
973 }
974 }
975 }
976
977 //
978 // If a parallel world has no region, set default region for parallel world
979 //
980
981 wItr = transM->GetWorldsIterator();
982 for(std::size_t iw = 0; iw < nWorlds; ++iw)
983 {
984 if(*wItr != currentWorld)
985 {
986 G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
987 if(pwLogical->GetRegion() == nullptr)
988 {
991 }
992 }
993 ++wItr;
994 }
995}
void SetRegion(G4Region *reg)
G4Region * GetRegion() const
G4ProductionCuts * GetDefaultProductionCuts() const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:414
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:398
G4bool IsInParallelGeometry() const
G4ProductionCuts * GetProductionCuts() const
const G4String & GetName() const
G4bool IsInMassGeometry() const
void UsedInParallelGeometry(G4bool val=true)
void AddRootLogicalVolume(G4LogicalVolume *lv, G4bool search=true)
Definition: G4Region.cc:293
void UsedInMassGeometry(G4bool val=true)
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const

Referenced by InitializePhysics(), and UpdateRegion().

◆ DefineWorldVolume()

void G4RunManagerKernel::DefineWorldVolume ( G4VPhysicalVolume worldVol,
G4bool  topologyIsChanged = true 
)

Definition at line 519 of file G4RunManagerKernel.cc.

521{
523 G4ApplicationState currentState = stateManager->GetCurrentState();
524
525 if(currentState != G4State_Init)
526 {
527 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
528 {
529 G4cout << "Current application state is "
530 << stateManager->GetStateString(currentState) << G4endl;
531 G4Exception("G4RunManagerKernel::DefineWorldVolume",
532 "DefineWorldVolumeAtIncorrectState", FatalException,
533 "Geant4 kernel is not Init state : Method ignored.");
534 return;
535 }
536 else
537 {
538 stateManager->SetNewState(G4State_Init);
539 }
540 }
541
542 // The world volume MUST NOT have a region defined by the user
543 if(worldVol->GetLogicalVolume()->GetRegion() != nullptr)
544 {
545 if(worldVol->GetLogicalVolume()->GetRegion() != defaultRegion)
546 {
548 ED << "The world volume has a user-defined region <"
549 << worldVol->GetLogicalVolume()->GetRegion()->GetName() << ">."
550 << G4endl;
551 ED << "World would have a default region assigned by RunManagerKernel."
552 << G4endl;
553 G4Exception("G4RunManager::DefineWorldVolume", "Run0004", FatalException,
554 ED);
555 }
556 }
557
559
560 // Accept the world volume
561 currentWorld = worldVol;
562
563 // Set the default region to the world
564
565 G4LogicalVolume* worldLog = currentWorld->GetLogicalVolume();
566 worldLog->SetRegion(defaultRegion);
568 if(verboseLevel > 1)
569 G4cout << worldLog->GetName() << " is registered to the default region."
570 << G4endl;
571
572 // Set the world volume, notify the Navigator and reset its state
574 ->SetWorldForTracking(currentWorld);
575 if(topologyIsChanged)
577
578 // Notify the VisManager as well
580 {
582 if(pVVisManager != nullptr)
583 pVVisManager->GeometryHasChanged();
584 }
585
586 geometryInitialized = true;
587 stateManager->SetNewState(currentState);
588 if(physicsInitialized && currentState != G4State_Idle)
589 {
590 stateManager->SetNewState(G4State_Idle);
591 }
592}
G4ApplicationState
@ G4State_Init
@ G4State_Idle
const G4String & GetName() const
G4String GetStateString(const G4ApplicationState &aState) const
void SetWorldForTracking(G4VPhysicalVolume *theWorld)
G4LogicalVolume * GetLogicalVolume() const
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0

Referenced by G4RunManager::DefineWorldVolume(), G4ErrorRunManagerHelper::InitializeGeometry(), and G4RunManager::InitializeGeometry().

◆ DumpRegion() [1/2]

void G4RunManagerKernel::DumpRegion ( const G4String rname) const

Definition at line 998 of file G4RunManagerKernel.cc.

999{
1000 G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
1001 if(region != nullptr)
1002 DumpRegion(region);
1003}

Referenced by BuildPhysicsTables(), G4RunManager::DumpRegion(), and DumpRegion().

◆ DumpRegion() [2/2]

void G4RunManagerKernel::DumpRegion ( G4Region region = nullptr) const

Definition at line 1006 of file G4RunManagerKernel.cc.

1007{
1008 if(region == nullptr)
1009 {
1010 for(std::size_t i = 0; i < G4RegionStore::GetInstance()->size(); ++i)
1011 {
1013 }
1014 }
1015 else
1016 {
1018 return;
1019 G4cout << G4endl;
1020 G4cout << "Region <" << region->GetName() << "> -- ";
1021 if(region->GetWorldPhysical())
1022 {
1023 G4cout << " -- appears in <" << region->GetWorldPhysical()->GetName()
1024 << "> world volume";
1025 }
1026 else
1027 {
1028 G4cout << " -- is not associated to any world.";
1029 }
1030 G4cout << G4endl;
1031 if(region->IsInMassGeometry())
1032 {
1033 G4cout << " This region is in the mass world." << G4endl;
1034 }
1035 if(region->IsInParallelGeometry())
1036 {
1037 G4cout << " This region is in the parallel world." << G4endl;
1038 }
1039
1040 G4cout << " Root logical volume(s) : ";
1041 std::size_t nRootLV = region->GetNumberOfRootVolumes();
1042 auto lvItr = region->GetRootLogicalVolumeIterator();
1043 for(std::size_t j = 0; j < nRootLV; ++j)
1044 {
1045 G4cout << (*lvItr)->GetName() << " ";
1046 ++lvItr;
1047 }
1048 G4cout << G4endl;
1049
1050 G4cout << " Pointers : G4VUserRegionInformation["
1051 << region->GetUserInformation() << "], G4UserLimits["
1052 << region->GetUserLimits() << "], G4FastSimulationManager["
1053 << region->GetFastSimulationManager() << "], G4UserSteppingAction["
1054 << region->GetRegionalSteppingAction() << "]" << G4endl;
1055
1056 G4cout << " Materials : ";
1057 auto mItr = region->GetMaterialIterator();
1058 std::size_t nMaterial = region->GetNumberOfMaterials();
1059 for(std::size_t iMate = 0; iMate < nMaterial; ++iMate)
1060 {
1061 G4cout << (*mItr)->GetName() << " ";
1062 ++mItr;
1063 }
1064 G4cout << G4endl;
1065 G4ProductionCuts* cuts = region->GetProductionCuts();
1066 if(!cuts && region->IsInMassGeometry())
1067 {
1068 G4cerr << "Warning : Region <" << region->GetName()
1069 << "> does not have specific production cuts." << G4endl;
1070 G4cerr << "Default cuts are used for this region." << G4endl;
1072 ->GetDefaultProductionCuts());
1073 }
1074 else if(cuts != nullptr)
1075 {
1076 G4cout << " Production cuts : "
1077 << " gamma "
1078 << G4BestUnit(cuts->GetProductionCut("gamma"), "Length")
1079 << " e- " << G4BestUnit(cuts->GetProductionCut("e-"), "Length")
1080 << " e+ " << G4BestUnit(cuts->GetProductionCut("e+"), "Length")
1081 << " proton "
1082 << G4BestUnit(cuts->GetProductionCut("proton"), "Length")
1083 << G4endl;
1084 }
1085 }
1086}
#define G4BestUnit(a, b)
G4GLOB_DLL std::ostream G4cerr
G4double GetProductionCut(G4int index) const
std::size_t GetNumberOfRootVolumes() const
std::size_t GetNumberOfMaterials() const
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:140
G4VUserRegionInformation * GetUserInformation() const
G4VPhysicalVolume * GetWorldPhysical() const
G4UserLimits * GetUserLimits() const
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition: G4Region.cc:158
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()
const G4String & GetName() const
G4bool IsWorkerThread()
Definition: G4Threading.cc:123

◆ GeometryHasBeenModified()

void G4RunManagerKernel::GeometryHasBeenModified ( )
inline

◆ GetCurrentWorld()

G4VPhysicalVolume * G4RunManagerKernel::GetCurrentWorld ( ) const
inline

Definition at line 169 of file G4RunManagerKernel.hh.

169{ return currentWorld; }

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ GetEventManager()

G4EventManager * G4RunManagerKernel::GetEventManager ( ) const
inline

Definition at line 130 of file G4RunManagerKernel.hh.

130{ return eventManager; }

Referenced by G4RunManager::G4RunManager().

◆ GetNumberOfParallelWorld()

G4int G4RunManagerKernel::GetNumberOfParallelWorld ( ) const
inline

Definition at line 161 of file G4RunManagerKernel.hh.

162 {
163 return numberOfParallelWorld;
164 }

Referenced by G4PhysicsListHelper::AddTransportation(), and G4WorkerRunManager::InitializeGeometry().

◆ GetNumberOfStaticAllocators()

G4int G4RunManagerKernel::GetNumberOfStaticAllocators ( ) const
inline

Definition at line 171 of file G4RunManagerKernel.hh.

172 {
173 return numberOfStaticAllocators;
174 }

Referenced by G4MTRunManager::G4MTRunManager(), and G4TaskRunManager::G4TaskRunManager().

◆ GetPhysicsList()

G4VUserPhysicsList * G4RunManagerKernel::GetPhysicsList ( ) const
inline

Definition at line 167 of file G4RunManagerKernel.hh.

167{ return physicsList; }

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4RunManagerKernel::GetPrimaryTransformer ( ) const
inline

Definition at line 143 of file G4RunManagerKernel.hh.

144 {
145 return eventManager->GetPrimaryTransformer();
146 }
G4PrimaryTransformer * GetPrimaryTransformer() const

Referenced by RunInitialization().

◆ GetRunManagerKernel()

G4RunManagerKernel * G4RunManagerKernel::GetRunManagerKernel ( )
static

Definition at line 98 of file G4RunManagerKernel.cc.

99{
100 return fRunManagerKernel;
101}

Referenced by G4PhysicsListHelper::AddTransportation(), G4VisManager::Disable(), and G4ErrorRunManagerHelper::G4ErrorRunManagerHelper().

◆ GetStackManager()

G4StackManager * G4RunManagerKernel::GetStackManager ( ) const
inline

Definition at line 131 of file G4RunManagerKernel.hh.

132 {
133 return eventManager->GetStackManager();
134 }
G4StackManager * GetStackManager() const

◆ GetTrackingManager()

G4TrackingManager * G4RunManagerKernel::GetTrackingManager ( ) const
inline

Definition at line 135 of file G4RunManagerKernel.hh.

136 {
137 return eventManager->GetTrackingManager();
138 }
G4TrackingManager * GetTrackingManager() const

Referenced by G4VisManager::Disable().

◆ GetVersionString()

const G4String & G4RunManagerKernel::GetVersionString ( ) const
inline

Definition at line 148 of file G4RunManagerKernel.hh.

148{ return versionString; }

Referenced by G4RunManager::GetVersionString().

◆ InitializePhysics()

void G4RunManagerKernel::InitializePhysics ( )

Definition at line 672 of file G4RunManagerKernel.cc.

673{
675 G4ApplicationState currentState = stateManager->GetCurrentState();
676 if(currentState != G4State_Init)
677 {
678 G4cout << "Current application state is "
679 << stateManager->GetStateString(currentState) << G4endl;
680 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
681 {
682 G4Exception("G4RunManagerKernel::InitializePhysics",
683 "InitializePhysicsIncorrectState", FatalException,
684 "Geant4 kernel is not Init state : Method ignored.");
685 return;
686 }
687 else
688 {
689 // G4Exception("G4RunManagerKernel::DefineWorldVolume",
690 // "DefineWorldVolumeAtIncorrectState", JustWarning,
691 // "Geant4 kernel is not Init state : Assuming Init state.");
692 G4cout
693 << "Warning : Geant4 kernel is not Init state : Assuming Init state."
694 << G4endl;
695 stateManager->SetNewState(G4State_Init);
696 }
697 }
698
699 if(physicsList == nullptr)
700 {
701 G4Exception("G4RunManagerKernel::InitializePhysics", "Run0012",
702 FatalException, "G4VUserPhysicsList is not defined");
703 return;
704 }
705
706 if(verboseLevel > 1)
707 G4cout << "physicsList->Construct() start." << G4endl;
708 if(numberOfParallelWorld > 0)
709 physicsList->UseCoupledTransportation();
710 physicsList->Construct();
711
712 if(verboseLevel > 1)
713 G4cout << "physicsList->CheckParticleList() start." << G4endl;
714 physicsList->CheckParticleList();
715
716 // Cannot assume that SetCuts() and CheckRegions() are thread safe.
717 // We need to mutex (report from valgrind --tool=drd)
718 G4AutoLock l(&initphysicsmutex);
720 {
721 if(verboseLevel > 1)
722 G4cout << "physicsList->setCut() start." << G4endl;
723 physicsList->SetCuts();
724 }
725 CheckRegions();
726 l.unlock();
727
728 /*******************
729 // static G4bool createIsomerOnlyOnce = false;
730 // if(G4Threading::IsMultithreadedApplication() &&
731 G4Threading::IsMasterThread())
732 // {
733 // if(!createIsomerOnlyOnce)
734 // {
735 // createIsomerOnlyOnce = true;
736 // G4ParticleDefinition* gion =
737 G4ParticleTable::GetParticleTable()->GetGenericIon();
738 // if(gion != nullptr)
739 // {
740 // G4ParticleTable::GetParticleTable()
741 ->GetIonTable()->CreateAllIsomer();
742 // PropagateGenericIonID();
743 // }
744 // }
745 // }
746 *********************/
747
748 physicsInitialized = true;
749#ifdef G4MULTITHREADED
750 G4UnitDefinition::GetUnitsTable().Synchronize();
751#endif
752 stateManager->SetNewState(currentState);
753 if(geometryInitialized && currentState != G4State_Idle)
754 {
755 stateManager->SetNewState(G4State_Idle);
756 }
757}
void UseCoupledTransportation(G4bool vl=true)

Referenced by G4ErrorRunManagerHelper::InitializePhysics(), and G4RunManager::InitializePhysics().

◆ PhysicsHasBeenModified()

void G4RunManagerKernel::PhysicsHasBeenModified ( )
inline

Definition at line 124 of file G4RunManagerKernel.hh.

124{ physicsNeedsToBeReBuilt = true; }

Referenced by G4RunManager::PhysicsHasBeenModified().

◆ PropagateGenericIonID()

void G4RunManagerKernel::PropagateGenericIonID ( )
protected

Definition at line 819 of file G4RunManagerKernel.cc.

820{
823 if(gion != nullptr)
824 {
825 // G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
826 G4int gionId = gion->GetParticleDefinitionID();
828 pItr->reset(false);
829 while((*pItr)())
830 {
831 G4ParticleDefinition* particle = pItr->value();
832 if(particle->IsGeneralIon())
833 particle->SetParticleDefinitionID(gionId);
834 }
835 }
836}
G4bool IsGeneralIon() const
void SetParticleDefinitionID(G4int id=-1)
G4int GetParticleDefinitionID() const
void reset(G4bool ifSkipIon=true)
G4PTblDicIterator * GetIterator() const
G4ParticleDefinition * GetGenericIon() const

Referenced by RunInitialization().

◆ ResetNavigator()

void G4RunManagerKernel::ResetNavigator ( )
protected

Definition at line 847 of file G4RunManagerKernel.cc.

848{
850 {
852 return;
853 }
854
855 // We have to tweak the navigator's state in case a geometry has been
856 // modified between runs. By the following calls we ensure that navigator's
857 // state is reset properly. It is required the geometry to be closed
858 // and previous optimisations to be cleared.
859
861 if(verboseLevel > 1)
862 G4cout << "Start closing geometry." << G4endl;
863
864 geomManager->OpenGeometry();
865 geomManager->CloseGeometry(geometryToBeOptimized, verboseLevel > 1);
866
868}
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)

Referenced by RunInitialization().

◆ RunInitialization()

G4bool G4RunManagerKernel::RunInitialization ( G4bool  fakeRun = false)

Definition at line 760 of file G4RunManagerKernel.cc.

761{
763 G4ApplicationState currentState = stateManager->GetCurrentState();
764
765 if(!geometryInitialized)
766 {
767 G4Exception("G4RunManagerKernel::RunInitialization", "Run0021", JustWarning,
768 "Geometry has not yet initialized : method ignored.");
769 return false;
770 }
771
772 if(!physicsInitialized)
773 {
774 G4Exception("G4RunManagerKernel::RunInitialization", "Run0022", JustWarning,
775 "Physics has not yet initialized : method ignored.");
776 return false;
777 }
778
779 if(currentState != G4State_Idle)
780 {
781 G4Exception("G4RunManagerKernel::RunInitialization", "Run0023", JustWarning,
782 "Geant4 kernel not in Idle state : method ignored.");
783 return false;
784 }
785
787 CheckRegularGeometry();
788
789 stateManager->SetNewState(G4State_Init);
792 UpdateRegion();
793 BuildPhysicsTables(fakeRun);
794
796 {
798 // CheckRegularGeometry();
799 // Notify the VisManager as well
801 {
803 if(pVVisManager != nullptr)
804 pVVisManager->GeometryHasChanged();
805 }
806 }
807
809
810#ifdef G4MULTITHREADED
811 G4UnitDefinition::GetUnitsTable().Synchronize();
812#endif
813 stateManager->SetNewState(G4State_Idle);
814 stateManager->SetNewState(G4State_GeomClosed);
815 return true;
816}
@ G4State_GeomClosed
@ JustWarning
G4PrimaryTransformer * GetPrimaryTransformer() const
virtual void SetupShadowProcess() const
void BuildPhysicsTables(G4bool fakeRun)

Referenced by G4ErrorRunManagerHelper::RunInitialization(), G4RunManager::RunInitialization(), G4WorkerRunManager::RunInitialization(), and G4WorkerTaskRunManager::RunInitialization().

◆ RunTermination()

◆ SetGeometryToBeOptimized()

void G4RunManagerKernel::SetGeometryToBeOptimized ( G4bool  vl)
inline

Definition at line 152 of file G4RunManagerKernel.hh.

153 {
154 if(geometryToBeOptimized != vl)
155 {
156 geometryToBeOptimized = vl;
158 }
159 }

Referenced by G4RunManager::SetGeometryToBeOptimized().

◆ SetNumberOfParallelWorld()

void G4RunManagerKernel::SetNumberOfParallelWorld ( G4int  i)
inline

Definition at line 165 of file G4RunManagerKernel.hh.

165{ numberOfParallelWorld = i; }

Referenced by G4RunManager::InitializeGeometry(), and G4WorkerRunManager::InitializeGeometry().

◆ SetPhysics()

void G4RunManagerKernel::SetPhysics ( G4VUserPhysicsList uPhys)

Definition at line 595 of file G4RunManagerKernel.cc.

596{
597 physicsList = uPhys;
598
600 return;
601
602 SetupPhysics();
603 if(verboseLevel > 2)
605 if(verboseLevel > 1)
606 {
607 G4cout << "List of instantiated particles "
608 "============================================"
609 << G4endl;
611 for(G4int i = 0; i < nPtcl; ++i)
612 {
615 G4cout << pd->GetParticleName() << " ";
616 if(i % 10 == 9)
617 G4cout << G4endl;
618 }
619 G4cout << G4endl;
620 }
621}
void DumpTable(const G4String &particle_name="ALL")

Referenced by G4ErrorRunManagerHelper::InitializePhysics(), and G4RunManager::SetUserInitialization().

◆ SetPrimaryTransformer()

void G4RunManagerKernel::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inline

Definition at line 139 of file G4RunManagerKernel.hh.

140 {
141 eventManager->SetPrimaryTransformer(pt);
142 }
void SetPrimaryTransformer(G4PrimaryTransformer *tf)

Referenced by G4RunManager::SetPrimaryTransformer().

◆ SetupDefaultRegion()

void G4RunManagerKernel::SetupDefaultRegion ( )
protected

Definition at line 330 of file G4RunManagerKernel.cc.

331{
333 return;
334
335 // Remove old world logical volume from the default region, if exist
337 {
338 if(defaultRegion->GetNumberOfRootVolumes() > size_t(1))
339 {
340 G4Exception("G4RunManager::SetupDefaultRegion", "Run0005", FatalException,
341 "Default world region should have a unique logical volume.");
342 }
345 if(verboseLevel > 1)
346 G4cout
347 << "Obsolete world logical volume is removed from the default region."
348 << G4endl;
349 }
350}
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition: G4Region.cc:328

Referenced by DefineWorldVolume().

◆ SetupPhysics()

void G4RunManagerKernel::SetupPhysics ( )
protected

Definition at line 624 of file G4RunManagerKernel.cc.

625{
627
628 physicsList->ConstructParticle();
629
630 // For sanity reason
634 if(gion != nullptr)
635 {
637 }
639
641 pItr->reset();
642 while((*pItr)())
643 {
644 G4ParticleDefinition* particle = pItr->value();
645 if(!(particle->IsGeneralIon()))
646 particle->SetParticleDefinitionID();
647 }
648
649 if(gion != nullptr)
650 {
651 G4int gionId = gion->GetParticleDefinitionID();
652 pItr->reset(false);
653 while((*pItr)())
654 {
655 G4ParticleDefinition* particle = pItr->value();
656 if(particle->IsGeneralIon())
657 particle->SetParticleDefinitionID(gionId);
658 }
659 }
660#ifdef G4MULTITHREADED
661 G4UnitDefinition::GetUnitsTable().Synchronize();
662#endif
663}
static G4Geantino * GeantinoDefinition()
Definition: G4Geantino.cc:81
static void ConstructParticle()
void InitializeLightIons()
Definition: G4IonTable.cc:205
G4IonTable * GetIonTable() const
void SetReadiness(G4bool val=true)
virtual void ConstructParticle()=0

Referenced by SetPhysics().

◆ SetupShadowProcess()

void G4RunManagerKernel::SetupShadowProcess ( ) const
protectedvirtual

Reimplemented in G4MTRunManagerKernel, G4TaskRunManagerKernel, G4WorkerRunManagerKernel, and G4WorkerTaskRunManagerKernel.

Definition at line 1160 of file G4RunManagerKernel.cc.

1161{
1163 auto theParticleIterator = theParticleTable->GetIterator();
1164 theParticleIterator->reset();
1165 // loop on particles and get process manager from there list of processes
1166 while((*theParticleIterator)())
1167 {
1170 if(pm != nullptr)
1171 {
1172 G4ProcessVector& procs = *(pm->GetProcessList());
1173 for(G4int idx = 0; idx < (G4int)procs.size(); ++idx)
1174 {
1175 const G4VProcess* masterP = procs[idx]->GetMasterProcess();
1176 if(masterP == nullptr)
1177 {
1178 // Process does not have an associated shadow master process
1179 // We are in master mode or sequential
1180 procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
1181 }
1182 }
1183 }
1184 }
1185}
#define theParticleIterator
G4ProcessManager * GetProcessManager() const
G4ProcessVector * GetProcessList() const
std::size_t size() const

Referenced by RunInitialization(), G4MTRunManagerKernel::SetupShadowProcess(), and G4TaskRunManagerKernel::SetupShadowProcess().

◆ SetVerboseLevel()

void G4RunManagerKernel::SetVerboseLevel ( G4int  vl)
inline

Definition at line 150 of file G4RunManagerKernel.hh.

150{ verboseLevel = vl; }

Referenced by G4ErrorRunManagerHelper::G4ErrorRunManagerHelper(), and G4RunManager::SetVerboseLevel().

◆ UpdateRegion()

void G4RunManagerKernel::UpdateRegion ( )

Definition at line 871 of file G4RunManagerKernel.cc.

872{
874 G4ApplicationState currentState = stateManager->GetCurrentState();
875 if(currentState != G4State_Init)
876 {
877 G4Exception("G4RunManagerKernel::UpdateRegion", "Run0024", JustWarning,
878 "Geant4 kernel not in Init state : method ignored.");
879 return;
880 }
881
883 return;
884
885 CheckRegions();
886
888
890 currentWorld);
891}
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=nullptr)

Referenced by RunInitialization().

◆ WorkerDefineWorldVolume()

void G4RunManagerKernel::WorkerDefineWorldVolume ( G4VPhysicalVolume worldVol,
G4bool  topologyIsChanged = true 
)

Definition at line 454 of file G4RunManagerKernel.cc.

456{
458 G4ApplicationState currentState = stateManager->GetCurrentState();
459 if(currentState != G4State_Init)
460 {
461 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
462 {
463 G4cout << "Current application state is "
464 << stateManager->GetStateString(currentState) << G4endl;
465 G4Exception("G4RunManagerKernel::DefineWorldVolume",
466 "DefineWorldVolumeAtIncorrectState", FatalException,
467 "Geant4 kernel is not Init state : Method ignored.");
468 return;
469 }
470 else
471 {
472 stateManager->SetNewState(G4State_Init);
473 }
474 }
475
476 currentWorld = worldVol;
480 G4MTRunManager::masterWorlds_t masterWorlds = masterRM->GetMasterWorlds();
481 for(auto itrMW = masterWorlds.cbegin();
482 itrMW != masterWorlds.cend(); ++itrMW)
483 {
484 if((*itrMW).first == 0)
485 {
486 if((*itrMW).second != currentWorld)
487 {
488 G4Exception("G4RunManagerKernel::WorkerDefineWorldVolume", "RUN3091",
489 FatalException, "Mass world is inconsistent");
490 }
491 transM->SetWorldForTracking((*itrMW).second);
492 }
493 else
494 {
495 transM->RegisterWorld((*itrMW).second);
496 }
497 }
498
499 if(topologyIsChanged)
501
502 // Notify the VisManager as well
504 {
506 if(pVVisManager != nullptr)
507 pVVisManager->GeometryHasChanged();
508 }
509
510 geometryInitialized = true;
511 stateManager->SetNewState(currentState);
512 if(physicsInitialized && currentState != G4State_Idle)
513 {
514 stateManager->SetNewState(G4State_Idle);
515 }
516}
static G4MTRunManager * GetMasterRunManager()
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
static masterWorlds_t & GetMasterWorlds()
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ WorkerUpdateWorldVolume()

void G4RunManagerKernel::WorkerUpdateWorldVolume ( )

Definition at line 433 of file G4RunManagerKernel.cc.

434{
438 G4MTRunManager::masterWorlds_t masterWorlds = masterRM->GetMasterWorlds();
439 for(auto itrMW = masterWorlds.cbegin();
440 itrMW != masterWorlds.cend(); ++itrMW)
441 {
442 G4VPhysicalVolume* wv = (*itrMW).second;
443 G4VPhysicalVolume* pWorld =
445 ->IsWorldExisting(wv->GetName());
446 if(pWorld == nullptr)
447 {
448 transM->RegisterWorld(wv);
449 }
450 }
451}
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)

Referenced by G4WorkerRunManager::ConstructScoringWorlds().

Member Data Documentation

◆ defaultRegion

G4Region* G4RunManagerKernel::defaultRegion = nullptr
protected

◆ defaultRegionForParallelWorld

G4Region* G4RunManagerKernel::defaultRegionForParallelWorld = nullptr
protected

Definition at line 212 of file G4RunManagerKernel.hh.

Referenced by CheckRegions(), and G4RunManagerKernel().

◆ geometryNeedsToBeClosed

G4bool G4RunManagerKernel::geometryNeedsToBeClosed = true
protected

◆ runManagerKernelType

RMKType G4RunManagerKernel::runManagerKernelType
protected

The documentation for this class was generated from the following files: