Geant4 10.7.0
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 WorkerUpdateWorldVolume ()
 
void UpdateRegion ()
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=0) const
 
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
 
G4RegiondefaultRegionForParallelWorld
 
G4bool geometryNeedsToBeClosed
 

Detailed Description

Definition at line 67 of file G4RunManagerKernel.hh.

Member Enumeration Documentation

◆ RMKType

Enumerator
sequentialRMK 
masterRMK 
workerRMK 

Definition at line 84 of file G4RunManagerKernel.hh.

Constructor & Destructor Documentation

◆ G4RunManagerKernel() [1/2]

G4RunManagerKernel::G4RunManagerKernel ( )

Definition at line 88 of file G4RunManagerKernel.cc.

89 : physicsList(0)
90 , currentWorld(0)
91 , geometryInitialized(false)
92 , physicsInitialized(false)
93 , geometryToBeOptimized(true)
94 , physicsNeedsToBeReBuilt(true)
95 , verboseLevel(0)
96 , numberOfParallelWorld(0)
98 , numberOfStaticAllocators(0)
99{
100#ifdef G4FPE_DEBUG
101 InvalidOperationDetection();
102#endif
103
104#ifdef G4BT_DEBUG
105 auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
106 if(_signals.empty())
107 {
109 }
110 else
111 {
112 G4Backtrace::Enable(_signals);
113 }
114#endif
115
117 if(allocList)
118 numberOfStaticAllocators = allocList->Size();
119 defaultExceptionHandler = new G4ExceptionHandler();
120 if(fRunManagerKernel)
121 {
122 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0001",
124 "More than one G4RunManagerKernel is constructed.");
125 }
126 fRunManagerKernel = this;
127
129 if(particleTable->entries() > 0)
130 {
131 // No particle should be registered beforehand
133 ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
134 ED << " G4RunManagerKernel fatal exception" << G4endl;
135 ED << " -- Following particles have already been registered" << G4endl;
136 ED << " before G4RunManagerKernel is instantiated." << G4endl;
137 for(int i = 0; i < particleTable->entries(); i++)
138 {
139 ED << " " << particleTable->GetParticle(i)->GetParticleName()
140 << G4endl;
141 }
142 ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
143 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0002",
144 FatalException, ED);
145 }
146
147 // construction of Geant4 kernel classes
148 eventManager = new G4EventManager();
149
150 defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
152 new G4Region("DefaultRegionForParallelWorld"); // deleted by store
155 ->GetDefaultProductionCuts());
158 ->GetDefaultProductionCuts());
159
161 // set the initial application state
163
164 // version banner
165 G4String vs = G4Version;
166 vs = vs.substr(1, vs.size() - 2);
167 versionString = " Geant4 version ";
168 versionString += vs;
169 versionString += " ";
170 versionString += G4Date;
171 G4cout << G4endl
172 << "**************************************************************"
173 << G4endl << versionString << G4endl
174 << " Copyright : Geant4 Collaboration" << G4endl
175 << " References : NIM A 506 (2003), 250-303"
176 << G4endl
177 << " : IEEE-TNS 53 (2006), 270-278"
178 << G4endl
179 << " : NIM A 835 (2016), 186-225"
180 << G4endl << " WWW : http://geant4.org/"
181 << G4endl
182 << "**************************************************************"
183 << G4endl << G4endl;
184}
@ G4State_PreInit
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4AllocatorList * GetAllocatorListIfExist()
G4int Size() const
static int Enable(const std::string &)
Definition: G4Backtrace.hh:757
const G4String & GetParticleName() const
G4ParticleDefinition * GetParticle(G4int index) const
G4int entries() const
static G4ParticleTable * GetParticleTable()
static G4ProductionCutsTable * GetProductionCutsTable()
void SetProductionCuts(G4ProductionCuts *cut)
G4Region * defaultRegionForParallelWorld
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)

◆ ~G4RunManagerKernel()

G4RunManagerKernel::~G4RunManagerKernel ( )
virtual

Definition at line 348 of file G4RunManagerKernel.cc.

349{
351 // set the application state to the quite state
352 if(pStateManager->GetCurrentState() != G4State_Quit)
353 {
354 if(verboseLevel > 0)
355 G4cout << "G4 kernel has come to Quit state." << G4endl;
356 pStateManager->SetNewState(G4State_Quit);
357 }
358
359 // open geometry for deletion
361
362 // deletion of Geant4 kernel classes
365 if(pwps)
366 delete pwps;
368 if(fSDM)
369 {
370 delete fSDM;
371 if(verboseLevel > 1)
372 G4cout << "G4SDManager deleted." << G4endl;
373 }
374 delete eventManager;
375 if(verboseLevel > 1)
376 G4cout << "EventManager deleted." << G4endl;
377
379 if(verboseLevel > 1)
380 G4cout << "Units table cleared." << G4endl;
381
382 // deletion of path-finder field-manager store, geometry and transportation
383 // manager
385 if(pFinder)
386 delete pFinder;
388 if(fmStore)
389 delete fmStore;
391 if(gManager)
392 delete gManager;
393 G4TransportationManager* tManager =
395 if(tManager)
396 {
397 delete tManager;
398 if(verboseLevel > 1)
399 G4cout << "TransportationManager deleted." << G4endl;
400 }
401
402 // deletion of navigation levels
403 if(verboseLevel > 1)
406
407 // deletion of G4RNGHelper singleton
409 {
411 if(rngHelper)
412 {
413 delete rngHelper;
414 if(verboseLevel > 1)
415 G4cout << "G4RNGHelper object is deleted." << G4endl;
416 }
417 }
418
419 // deletion of allocators
421 if(allocList)
422 {
423 allocList->Destroy(numberOfStaticAllocators, verboseLevel);
424 delete allocList;
425 if(verboseLevel > 1)
426 G4cout << "G4Allocator objects are deleted." << G4endl;
427 }
428
430 if((runManagerKernelType == workerRMK) && (verboseLevel > 0))
431 {
432 G4cout << "Thread-local UImanager is to be deleted." << G4endl
433 << "There should not be any thread-local G4cout/G4cerr hereafter."
434 << G4endl;
435 verboseLevel = 0;
436 }
437 if(pUImanager)
438 delete pUImanager;
439 if(verboseLevel > 1)
440 G4cout << "UImanager deleted." << G4endl;
441
442 delete pStateManager;
443 if(verboseLevel > 1)
444 G4cout << "StateManager deleted." << G4endl;
445 delete defaultExceptionHandler;
446 if(verboseLevel > 0)
447 G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
448 fRunManagerKernel = 0;
449}
@ 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:48
const G4ApplicationState & GetCurrentState() const
static G4TemplateRNGHelper< T > * GetInstanceIfExist()
Definition: G4RNGHelper.cc:46
static G4TransportationManager * GetInstanceIfExist()
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
static void ClearUnitsTable()

◆ G4RunManagerKernel() [2/2]

G4RunManagerKernel::G4RunManagerKernel ( RMKType  rmkType)
protected

Definition at line 186 of file G4RunManagerKernel.cc.

187 : physicsList(0)
188 , currentWorld(0)
189 , geometryInitialized(false)
190 , physicsInitialized(false)
191 , geometryToBeOptimized(true)
192 , physicsNeedsToBeReBuilt(true)
193 , verboseLevel(0)
194 , numberOfParallelWorld(0)
196 , numberOfStaticAllocators(0)
197{
198// This version of the constructor should never be called in sequential mode!
199#ifndef G4MULTITHREADED
201 msg << "Geant4 code is compiled without multi-threading support "
202 "(-DG4MULTITHREADED "
203 "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 defaultExceptionHandler = new G4ExceptionHandler();
230 if(fRunManagerKernel)
231 {
232 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0001",
234 "More than one G4RunManagerKernel is constructed.");
235 }
236 fRunManagerKernel = this;
237 // construction of Geant4 kernel classes
238 eventManager = new G4EventManager();
239
240 switch(rmkType)
241 {
242 case masterRMK:
243 // Master thread behvior
245 new G4Region("DefaultRegionForTheWorld"); // deleted by store
247 new G4Region("DefaultRegionForParallelWorld"); // deleted by store
250 ->GetDefaultProductionCuts());
253 ->GetDefaultProductionCuts());
254 break;
255 case workerRMK:
256 // Worker thread behavior
258 "DefaultRegionForTheWorld", true);
260 "DefaultRegionForParallelWorld", true);
261 break;
262 default:
263 defaultRegion = 0;
266 msgx
267 << " This type of RunManagerKernel can only be used in mult-threaded "
268 "applications.";
269 G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)", "Run0106",
270 FatalException, msgx);
271 }
272 runManagerKernelType = rmkType;
273
274 // set the initial application state
276
277 // version banner
278 G4String vs = G4Version;
279 vs = vs.substr(1, vs.size() - 2);
280 switch(rmkType)
281 {
282 case masterRMK:
283 versionString = " Geant4 version ";
284 versionString += vs;
285 versionString += " ";
286 versionString += G4Date;
287 G4cout << G4endl
288 << "**************************************************************"
289 << G4endl << versionString << G4endl
290 << " << in Multi-threaded mode >> " << G4endl
291 << " Copyright : Geant4 Collaboration"
292 << G4endl
293 << " References : NIM A 506 (2003), 250-303"
294 << G4endl
295 << " : IEEE-TNS 53 (2006), 270-278"
296 << G4endl
297 << " : NIM A 835 (2016), 186-225"
298 << G4endl
299 << " WWW : http://geant4.org/"
300 << G4endl
301 << "**************************************************************"
302 << G4endl << G4endl;
303 break;
304 default:
305 if(verboseLevel)
306 {
307 versionString = " Local thread RunManagerKernel version ";
308 versionString += vs;
309 G4cout
310 << G4endl
311 << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
312 "^^^^^^^^^"
313 << G4endl << versionString << G4endl
314 << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
315 "^^^^^^^^^"
316 << G4endl << G4endl;
317 }
318 }
319
320#ifdef G4MULTITHREADED
321 G4UnitDefinition::GetUnitsTable().Synchronize();
322#endif
323}
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 920 of file G4RunManagerKernel.cc.

921{
923 physicsNeedsToBeReBuilt)
924 {
925#ifdef G4MULTITHREADED
927 {
928 // make sure workers also rebuild physics tables
930 pUImanager->ApplyCommand("/run/physicsModified");
931 }
932#endif
933 physicsList->BuildPhysicsTable();
934 ////G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();
935 physicsNeedsToBeReBuilt = false;
936 }
937
938 if(!fakeRun && verboseLevel > 1)
939 DumpRegion();
940 if(!fakeRun && verboseLevel > 0)
941 physicsList->DumpCutValuesTable();
942 if(!fakeRun)
943 physicsList->DumpCutValuesTableIfRequested();
944}
void DumpRegion(const G4String &rname) const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void DumpCutValuesTable(G4int flag=1)

Referenced by RunInitialization().

◆ CheckRegions()

void G4RunManagerKernel::CheckRegions ( )
protected

Definition at line 946 of file G4RunManagerKernel.cc.

947{
950 size_t nWorlds = transM->GetNoWorlds();
951 std::vector<G4VPhysicalVolume*>::iterator wItr;
952 for(size_t i = 0; i < G4RegionStore::GetInstance()->size(); i++)
953 {
954 G4Region* region = (*(G4RegionStore::GetInstance()))[i];
955
956 // Let each region have a pointer to the world volume where it belongs to.
957 // G4Region::SetWorld() checks if the region belongs to the given world and
958 // set it only if it does. Thus, here we go through all the registered world
959 // volumes.
960 region->SetWorld(0); // reset
961 region->UsedInMassGeometry(false);
962 region->UsedInParallelGeometry(false);
963 wItr = transM->GetWorldsIterator();
964 for(size_t iw = 0; iw < nWorlds; iw++)
965 {
966 if(region->BelongsTo(*wItr))
967 {
968 if(*wItr == currentWorld)
969 {
970 region->UsedInMassGeometry(true);
971 }
972 else
973 {
974 region->UsedInParallelGeometry(true);
975 }
976 }
977 region->SetWorld(*wItr);
978 wItr++;
979 }
980
981 G4ProductionCuts* cuts = region->GetProductionCuts();
982 if(!cuts)
983 {
984 if(region->IsInMassGeometry())
985 {
986 G4cout << "Warning : Region <" << region->GetName()
987 << "> does not have specific production cuts," << G4endl
988 << "even though it appears in the current tracking world."
989 << G4endl;
990 G4cout << "Default cuts are used for this region." << G4endl;
991 }
992
993 if(region->IsInMassGeometry() || region->IsInParallelGeometry())
994 {
995 region->SetProductionCuts(
998 }
999 }
1000 }
1001
1002 //
1003 // If a parallel world has no region, set default region for parallel world
1004 //
1005
1006 wItr = transM->GetWorldsIterator();
1007 for(size_t iw = 0; iw < nWorlds; iw++)
1008 {
1009 // G4cout << "+++ " << (*wItr)->GetName() << G4endl;
1010 if(*wItr != currentWorld)
1011 {
1012 G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
1013 if(!(pwLogical->GetRegion()))
1014 {
1017 // G4cout << "+++++ defaultRegionForParallelWorld is set to "
1018 // << (*wItr)->GetName() << " +++++" << G4endl;
1019 }
1020 }
1021 wItr++;
1022 }
1023}
void SetRegion(G4Region *reg)
G4Region * GetRegion() const
G4ProductionCuts * GetDefaultProductionCuts() const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:404
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:388
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:283
void UsedInMassGeometry(G4bool val=true)
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const

Referenced by InitializePhysics(), and UpdateRegion().

◆ DefineWorldVolume()

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

Definition at line 542 of file G4RunManagerKernel.cc.

544{
546 G4ApplicationState currentState = stateManager->GetCurrentState();
547
548 if(currentState != G4State_Init)
549 {
550 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
551 {
552 G4cout << "Current application state is "
553 << stateManager->GetStateString(currentState) << G4endl;
554 G4Exception("G4RunManagerKernel::DefineWorldVolume",
555 "DefineWorldVolumeAtIncorrectState", FatalException,
556 "Geant4 kernel is not Init state : Method ignored.");
557 return;
558 }
559 else
560 {
561 // G4Exception("G4RunManagerKernel::DefineWorldVolume",
562 // "DefineWorldVolumeAtIncorrectState",
563 // JustWarning,
564 // "Geant4 kernel is not Init state : Assuming Init state.");
565 // G4cout<<"Warning : Geant4 kernel is not Init state : Assuming Init
566 // state."
567 // <<G4endl;
568 stateManager->SetNewState(G4State_Init);
569 }
570 }
571
572 // The world volume MUST NOT have a region defined by the user
573 if(worldVol->GetLogicalVolume()->GetRegion())
574 {
575 if(worldVol->GetLogicalVolume()->GetRegion() != defaultRegion)
576 {
578 ED << "The world volume has a user-defined region <"
579 << worldVol->GetLogicalVolume()->GetRegion()->GetName() << ">."
580 << G4endl;
581 ED << "World would have a default region assigned by RunManagerKernel."
582 << G4endl;
583 G4Exception("G4RunManager::DefineWorldVolume", "Run0004", FatalException,
584 ED);
585 }
586 }
587
589
590 // Accept the world volume
591 currentWorld = worldVol;
592
593 // Set the default region to the world
594
595 G4LogicalVolume* worldLog = currentWorld->GetLogicalVolume();
596 worldLog->SetRegion(defaultRegion);
598 if(verboseLevel > 1)
599 G4cout << worldLog->GetName() << " is registered to the default region."
600 << G4endl;
601
602 // Set the world volume, notify the Navigator and reset its state
604 currentWorld);
605 if(topologyIsChanged)
607
608 // Notify the VisManager as well
610 {
612 if(pVVisManager)
613 pVVisManager->GeometryHasChanged();
614 }
615
616 geometryInitialized = true;
617 stateManager->SetNewState(currentState);
618 if(physicsInitialized && currentState != G4State_Idle)
619 {
620 stateManager->SetNewState(G4State_Idle);
621 }
622}
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 1025 of file G4RunManagerKernel.cc.

1026{
1027 G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
1028 if(region)
1029 DumpRegion(region);
1030}

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

◆ DumpRegion() [2/2]

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

Definition at line 1032 of file G4RunManagerKernel.cc.

1033{
1034 if(!region)
1035 {
1036 for(size_t i = 0; i < G4RegionStore::GetInstance()->size(); i++)
1037 {
1039 }
1040 }
1041 else
1042 {
1044 return;
1045 G4cout << G4endl;
1046 G4cout << "Region <" << region->GetName() << "> -- ";
1047 if(region->GetWorldPhysical())
1048 {
1049 G4cout << " -- appears in <" << region->GetWorldPhysical()->GetName()
1050 << "> world volume";
1051 }
1052 else
1053 {
1054 G4cout << " -- is not associated to any world.";
1055 }
1056 G4cout << G4endl;
1057 if(region->IsInMassGeometry())
1058 {
1059 G4cout << " This region is in the mass world." << G4endl;
1060 }
1061 if(region->IsInParallelGeometry())
1062 {
1063 G4cout << " This region is in the parallel world." << G4endl;
1064 }
1065
1066 G4cout << " Root logical volume(s) : ";
1067 size_t nRootLV = region->GetNumberOfRootVolumes();
1068 std::vector<G4LogicalVolume*>::iterator lvItr =
1070 for(size_t j = 0; j < nRootLV; j++)
1071 {
1072 G4cout << (*lvItr)->GetName() << " ";
1073 lvItr++;
1074 }
1075 G4cout << G4endl;
1076
1077 G4cout << " Pointers : G4VUserRegionInformation["
1078 << region->GetUserInformation() << "], G4UserLimits["
1079 << region->GetUserLimits() << "], G4FastSimulationManager["
1080 << region->GetFastSimulationManager() << "], G4UserSteppingAction["
1081 << region->GetRegionalSteppingAction() << "]" << G4endl;
1082
1083 G4cout << " Materials : ";
1084 std::vector<G4Material*>::const_iterator mItr =
1085 region->GetMaterialIterator();
1086 size_t nMaterial = region->GetNumberOfMaterials();
1087 for(size_t iMate = 0; iMate < nMaterial; iMate++)
1088 {
1089 G4cout << (*mItr)->GetName() << " ";
1090 mItr++;
1091 }
1092 G4cout << G4endl;
1093 G4ProductionCuts* cuts = region->GetProductionCuts();
1094 if(!cuts && region->IsInMassGeometry())
1095 {
1096 G4cerr << "Warning : Region <" << region->GetName()
1097 << "> does not have specific production cuts." << G4endl;
1098 G4cerr << "Default cuts are used for this region." << G4endl;
1100 ->GetDefaultProductionCuts());
1101 }
1102 else if(cuts)
1103 {
1104 G4cout << " Production cuts : "
1105 << " gamma "
1106 << G4BestUnit(cuts->GetProductionCut("gamma"), "Length")
1107 << " e- " << G4BestUnit(cuts->GetProductionCut("e-"), "Length")
1108 << " e+ " << G4BestUnit(cuts->GetProductionCut("e+"), "Length")
1109 << " proton "
1110 << G4BestUnit(cuts->GetProductionCut("proton"), "Length")
1111 << G4endl;
1112 }
1113 }
1114}
#define G4BestUnit(a, b)
G4GLOB_DLL std::ostream G4cerr
G4double GetProductionCut(G4int index) const
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:130
G4VUserRegionInformation * GetUserInformation() const
G4VPhysicalVolume * GetWorldPhysical() const
G4UserLimits * GetUserLimits() const
size_t GetNumberOfRootVolumes() const
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition: G4Region.cc:148
size_t GetNumberOfMaterials() const
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 221 of file G4RunManagerKernel.hh.

221{ return currentWorld; }

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ GetEventManager()

G4EventManager * G4RunManagerKernel::GetEventManager ( ) const
inline

Definition at line 182 of file G4RunManagerKernel.hh.

182{ return eventManager; }

Referenced by G4RunManager::G4RunManager().

◆ GetNumberOfParallelWorld()

G4int G4RunManagerKernel::GetNumberOfParallelWorld ( ) const
inline

Definition at line 213 of file G4RunManagerKernel.hh.

214 {
215 return numberOfParallelWorld;
216 }

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

◆ GetNumberOfStaticAllocators()

G4int G4RunManagerKernel::GetNumberOfStaticAllocators ( ) const
inline

Definition at line 231 of file G4RunManagerKernel.hh.

232 {
233 return numberOfStaticAllocators;
234 }

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

◆ GetPhysicsList()

G4VUserPhysicsList * G4RunManagerKernel::GetPhysicsList ( ) const
inline

Definition at line 219 of file G4RunManagerKernel.hh.

219{ return physicsList; }

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4RunManagerKernel::GetPrimaryTransformer ( ) const
inline

Definition at line 195 of file G4RunManagerKernel.hh.

196 {
197 return eventManager->GetPrimaryTransformer();
198 }
G4PrimaryTransformer * GetPrimaryTransformer() const

Referenced by RunInitialization().

◆ GetRunManagerKernel()

G4RunManagerKernel * G4RunManagerKernel::GetRunManagerKernel ( )
static

Definition at line 83 of file G4RunManagerKernel.cc.

84{
85 return fRunManagerKernel;
86}

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

◆ GetStackManager()

G4StackManager * G4RunManagerKernel::GetStackManager ( ) const
inline

Definition at line 183 of file G4RunManagerKernel.hh.

184 {
185 return eventManager->GetStackManager();
186 }
G4StackManager * GetStackManager() const

◆ GetTrackingManager()

G4TrackingManager * G4RunManagerKernel::GetTrackingManager ( ) const
inline

Definition at line 187 of file G4RunManagerKernel.hh.

188 {
189 return eventManager->GetTrackingManager();
190 }
G4TrackingManager * GetTrackingManager() const

Referenced by G4VisManager::Disable().

◆ GetVersionString()

const G4String & G4RunManagerKernel::GetVersionString ( ) const
inline

Definition at line 200 of file G4RunManagerKernel.hh.

200{ return versionString; }

Referenced by G4RunManager::GetVersionString().

◆ InitializePhysics()

void G4RunManagerKernel::InitializePhysics ( )

Definition at line 704 of file G4RunManagerKernel.cc.

705{
707 G4ApplicationState currentState = stateManager->GetCurrentState();
708 if(currentState != G4State_Init)
709 {
710 G4cout << "Current application state is "
711 << stateManager->GetStateString(currentState) << G4endl;
712 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
713 {
714 G4Exception("G4RunManagerKernel::InitializePhysics",
715 "InitializePhysicsIncorrectState", FatalException,
716 "Geant4 kernel is not Init state : Method ignored.");
717 return;
718 }
719 else
720 {
721 // G4Exception("G4RunManagerKernel::DefineWorldVolume",
722 //"DefineWorldVolumeAtIncorrectState",
723 // JustWarning,
724 //"Geant4 kernel is not Init state : Assuming Init state.");
725 G4cout
726 << "Warning : Geant4 kernel is not Init state : Assuming Init state."
727 << G4endl;
728 stateManager->SetNewState(G4State_Init);
729 }
730 }
731
732 if(!physicsList)
733 {
734 G4Exception("G4RunManagerKernel::InitializePhysics", "Run0012",
735 FatalException, "G4VUserPhysicsList is not defined");
736 return;
737 }
738
739 if(verboseLevel > 1)
740 G4cout << "physicsList->Construct() start." << G4endl;
741 if(numberOfParallelWorld > 0)
742 physicsList->UseCoupledTransportation();
743 physicsList->Construct();
744
745 if(verboseLevel > 1)
746 G4cout << "physicsList->CheckParticleList() start." << G4endl;
747 physicsList->CheckParticleList();
748 // Cannot assume that SetCuts and CheckRegions are thread safe. We need to
749 // mutex Report from valgrind --tool=drd
750 G4AutoLock l(&initphysicsmutex);
752 {
753 if(verboseLevel > 1)
754 G4cout << "physicsList->setCut() start." << G4endl;
755 physicsList->SetCuts();
756 }
757 CheckRegions();
758 l.unlock();
759
760 /*******************
761 // static G4bool createIsomerOnlyOnce = false;
762 // if(G4Threading::IsMultithreadedApplication() &&
763 G4Threading::IsMasterThread())
764 // {
765 // if(!createIsomerOnlyOnce)
766 // {
767 // createIsomerOnlyOnce = true;
768 // G4ParticleDefinition* gion =
769 G4ParticleTable::GetParticleTable()->GetGenericIon();
770 // if(gion)
771 // {
772 // G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
773 // PropagateGenericIonID();
774 // }
775 // }
776 // }
777 *********************/
778
779 physicsInitialized = true;
780#ifdef G4MULTITHREADED
781 G4UnitDefinition::GetUnitsTable().Synchronize();
782#endif
783 stateManager->SetNewState(currentState);
784 if(geometryInitialized && currentState != G4State_Idle)
785 {
786 stateManager->SetNewState(G4State_Idle);
787 }
788}
void UseCoupledTransportation(G4bool vl=true)

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

◆ PhysicsHasBeenModified()

void G4RunManagerKernel::PhysicsHasBeenModified ( )
inline

Definition at line 175 of file G4RunManagerKernel.hh.

175{ physicsNeedsToBeReBuilt = true; }

Referenced by G4RunManager::PhysicsHasBeenModified().

◆ PropagateGenericIonID()

void G4RunManagerKernel::PropagateGenericIonID ( )
protected

Definition at line 848 of file G4RunManagerKernel.cc.

849{
852 if(gion)
853 {
854 // G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
855 G4int gionId = gion->GetParticleDefinitionID();
858 pItr->reset(false);
859 while((*pItr)())
860 {
861 G4ParticleDefinition* particle = pItr->value();
862 if(particle->IsGeneralIon())
863 particle->SetParticleDefinitionID(gionId);
864 }
865 }
866}
int G4int
Definition: G4Types.hh:85
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 875 of file G4RunManagerKernel.cc.

876{
878 {
880 return;
881 }
882
883 // We have to tweak the navigator's state in case a geometry has been
884 // modified between runs. By the following calls we ensure that navigator's
885 // state is reset properly. It is required the geometry to be closed
886 // and previous optimisations to be cleared.
887
889 if(verboseLevel > 1)
890 G4cout << "Start closing geometry." << G4endl;
891
892 geomManager->OpenGeometry();
893 geomManager->CloseGeometry(geometryToBeOptimized, verboseLevel > 1);
894
896}
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)

Referenced by RunInitialization().

◆ RunInitialization()

G4bool G4RunManagerKernel::RunInitialization ( G4bool  fakeRun = false)

Definition at line 790 of file G4RunManagerKernel.cc.

791{
793 G4ApplicationState currentState = stateManager->GetCurrentState();
794
795 if(!geometryInitialized)
796 {
797 G4Exception("G4RunManagerKernel::RunInitialization", "Run0021", JustWarning,
798 "Geometry has not yet initialized : method ignored.");
799 return false;
800 }
801
802 if(!physicsInitialized)
803 {
804 G4Exception("G4RunManagerKernel::RunInitialization", "Run0022", JustWarning,
805 "Physics has not yet initialized : method ignored.");
806 return false;
807 }
808
809 if(currentState != G4State_Idle)
810 {
811 G4Exception("G4RunManagerKernel::RunInitialization", "Run0023", JustWarning,
812 "Geant4 kernel not in Idle state : method ignored.");
813 return false;
814 }
815
817 CheckRegularGeometry();
818
819 stateManager->SetNewState(G4State_Init);
822 UpdateRegion();
823 BuildPhysicsTables(fakeRun);
824
826 {
828 // CheckRegularGeometry();
829 // Notify the VisManager as well
831 {
833 if(pVVisManager)
834 pVVisManager->GeometryHasChanged();
835 }
836 }
837
839
840#ifdef G4MULTITHREADED
841 G4UnitDefinition::GetUnitsTable().Synchronize();
842#endif
843 stateManager->SetNewState(G4State_Idle);
844 stateManager->SetNewState(G4State_GeomClosed);
845 return true;
846}
@ 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 204 of file G4RunManagerKernel.hh.

205 {
206 if(geometryToBeOptimized != vl)
207 {
208 geometryToBeOptimized = vl;
210 }
211 }

Referenced by G4RunManager::SetGeometryToBeOptimized().

◆ SetNumberOfParallelWorld()

void G4RunManagerKernel::SetNumberOfParallelWorld ( G4int  i)
inline

Definition at line 217 of file G4RunManagerKernel.hh.

217{ numberOfParallelWorld = i; }

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

◆ SetPhysics()

void G4RunManagerKernel::SetPhysics ( G4VUserPhysicsList uPhys)

Definition at line 624 of file G4RunManagerKernel.cc.

625{
626 physicsList = uPhys;
627
629 return;
630
631 SetupPhysics();
632 if(verboseLevel > 2)
634 if(verboseLevel > 1)
635 {
636 G4cout << "List of instantiated particles "
637 "============================================"
638 << G4endl;
640 for(G4int i = 0; i < nPtcl; i++)
641 {
644 G4cout << pd->GetParticleName() << " ";
645 if(i % 10 == 9)
646 G4cout << G4endl;
647 }
648 G4cout << G4endl;
649 }
650}
void DumpTable(const G4String &particle_name="ALL")

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

◆ SetPrimaryTransformer()

void G4RunManagerKernel::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inline

Definition at line 191 of file G4RunManagerKernel.hh.

192 {
193 eventManager->SetPrimaryTransformer(pt);
194 }
void SetPrimaryTransformer(G4PrimaryTransformer *tf)

Referenced by G4RunManager::SetPrimaryTransformer().

◆ SetupDefaultRegion()

void G4RunManagerKernel::SetupDefaultRegion ( )
protected

Definition at line 325 of file G4RunManagerKernel.cc.

326{
328 return;
329
330 // Remove old world logical volume from the default region, if exist
332 {
333 if(defaultRegion->GetNumberOfRootVolumes() > size_t(1))
334 {
335 G4Exception("G4RunManager::SetupDefaultRegion", "Run0005", FatalException,
336 "Default world region should have a unique logical volume.");
337 }
338 std::vector<G4LogicalVolume*>::iterator lvItr =
341 if(verboseLevel > 1)
342 G4cout
343 << "Obsolete world logical volume is removed from the default region."
344 << G4endl;
345 }
346}
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition: G4Region.cc:318

Referenced by DefineWorldVolume().

◆ SetupPhysics()

void G4RunManagerKernel::SetupPhysics ( )
protected

Definition at line 657 of file G4RunManagerKernel.cc.

658{
660
661 physicsList->ConstructParticle();
662
663 // For sanity reason
667 if(gion)
668 {
670 }
672
675 pItr->reset();
676 while((*pItr)())
677 {
678 G4ParticleDefinition* particle = pItr->value();
679 if(!(particle->IsGeneralIon()))
680 particle->SetParticleDefinitionID();
681 }
682
683 if(gion)
684 {
685 G4int gionId = gion->GetParticleDefinitionID();
686 pItr->reset(false);
687 while((*pItr)())
688 {
689 G4ParticleDefinition* particle = pItr->value();
690 if(particle->IsGeneralIon())
691 particle->SetParticleDefinitionID(gionId);
692 }
693 }
694#ifdef G4MULTITHREADED
695 G4UnitDefinition::GetUnitsTable().Synchronize();
696#endif
697}
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, G4WorkerRunManagerKernel, G4TaskRunManagerKernel, and G4WorkerTaskRunManagerKernel.

Definition at line 1194 of file G4RunManagerKernel.cc.

1195{
1198 theParticleTable->GetIterator();
1199 theParticleIterator->reset();
1200 // loop on particles and get process manager from there list of processes
1201 while((*theParticleIterator)())
1202 {
1205 if(pm)
1206 {
1207 G4ProcessVector& procs = *(pm->GetProcessList());
1208 for(std::size_t idx = 0; idx < procs.size(); ++idx)
1209 {
1210 const G4VProcess* masterP = procs[idx]->GetMasterProcess();
1211 if(!masterP)
1212 {
1213 // Process does not have an associated shadow master process
1214 // We are in master mode or sequential
1215 procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
1216 }
1217 }
1218 }
1219 }
1220}
#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 202 of file G4RunManagerKernel.hh.

202{ verboseLevel = vl; }

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

◆ UpdateRegion()

void G4RunManagerKernel::UpdateRegion ( )

Definition at line 898 of file G4RunManagerKernel.cc.

899{
901 G4ApplicationState currentState = stateManager->GetCurrentState();
902 if(currentState != G4State_Init)
903 {
904 G4Exception("G4RunManagerKernel::UpdateRegion", "Run0024", JustWarning,
905 "Geant4 kernel not in Init state : method ignored.");
906 return;
907 }
908
910 return;
911
912 CheckRegions();
913
915
917 currentWorld);
918}
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=0)

Referenced by RunInitialization().

◆ WorkerDefineWorldVolume()

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

Definition at line 471 of file G4RunManagerKernel.cc.

473{
475 G4ApplicationState currentState = stateManager->GetCurrentState();
476 if(currentState != G4State_Init)
477 {
478 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
479 {
480 G4cout << "Current application state is "
481 << stateManager->GetStateString(currentState) << G4endl;
482 G4Exception("G4RunManagerKernel::DefineWorldVolume",
483 "DefineWorldVolumeAtIncorrectState", FatalException,
484 "Geant4 kernel is not Init state : Method ignored.");
485 return;
486 }
487 else
488 {
489 // G4Exception("G4RunManagerKernel::DefineWorldVolume",
490 // "DefineWorldVolumeAtIncorrectState",
491 // JustWarning,
492 // "Geant4 kernel is not Init state : Assuming Init state.");
493 // G4cout<<"Warning : Geant4 kernel is not Init state : Assuming Init
494 // state."
495 // <<G4endl;
496 stateManager->SetNewState(G4State_Init);
497 }
498 }
499
500 currentWorld = worldVol;
504 G4MTRunManager::masterWorlds_t masterWorlds = masterRM->GetMasterWorlds();
505 G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
506 for(; itrMW != masterWorlds.end(); itrMW++)
507 {
508 if((*itrMW).first == 0)
509 {
510 if((*itrMW).second != currentWorld)
511 {
512 G4Exception("G4RunManagerKernel::WorkerDefineWorldVolume", "RUN3091",
513 FatalException, "Mass world is inconsistent");
514 }
515 transM->SetWorldForTracking((*itrMW).second);
516 }
517 else
518 {
519 transM->RegisterWorld((*itrMW).second);
520 }
521 }
522
523 if(topologyIsChanged)
525
526 // Notify the VisManager as well
528 {
530 if(pVVisManager)
531 pVVisManager->GeometryHasChanged();
532 }
533
534 geometryInitialized = true;
535 stateManager->SetNewState(currentState);
536 if(physicsInitialized && currentState != G4State_Idle)
537 {
538 stateManager->SetNewState(G4State_Idle);
539 }
540}
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
static G4MTRunManager * GetMasterRunManager()
static masterWorlds_t & GetMasterWorlds()
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ WorkerUpdateWorldVolume()

void G4RunManagerKernel::WorkerUpdateWorldVolume ( )

Definition at line 451 of file G4RunManagerKernel.cc.

452{
456 G4MTRunManager::masterWorlds_t masterWorlds = masterRM->GetMasterWorlds();
457 G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
458 for(; itrMW != masterWorlds.end(); itrMW++)
459 {
460 G4VPhysicalVolume* wv = (*itrMW).second;
461 G4VPhysicalVolume* pWorld =
463 wv->GetName());
464 if(!pWorld)
465 {
466 transM->RegisterWorld(wv);
467 }
468 }
469}
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)

Referenced by G4WorkerRunManager::ConstructScoringWorlds().

Member Data Documentation

◆ defaultRegion

G4Region* G4RunManagerKernel::defaultRegion
protected

◆ defaultRegionForParallelWorld

G4Region* G4RunManagerKernel::defaultRegionForParallelWorld
protected

Definition at line 166 of file G4RunManagerKernel.hh.

Referenced by CheckRegions(), and G4RunManagerKernel().

◆ geometryNeedsToBeClosed

G4bool G4RunManagerKernel::geometryNeedsToBeClosed
protected

◆ runManagerKernelType

RMKType G4RunManagerKernel::runManagerKernelType
protected

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