Geant4-11
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
G4RunManagerKernel Class Reference

#include <G4RunManagerKernel.hh>

Inheritance diagram for G4RunManagerKernel:
G4MTRunManagerKernel G4TaskRunManagerKernel G4WorkerRunManagerKernel G4WorkerTaskRunManagerKernel

Public Types

enum  RMKType { sequentialRMK , masterRMK , workerRMK }
 

Public Member Functions

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

Static Public Member Functions

static G4RunManagerKernelGetRunManagerKernel ()
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

void CheckRegularGeometry ()
 
G4bool ConfirmCoupledTransportation ()
 
void SetScoreSplitter ()
 

Private Attributes

G4VPhysicalVolumecurrentWorld = nullptr
 
G4ExceptionHandlerdefaultExceptionHandler = nullptr
 
G4EventManagereventManager = nullptr
 
G4bool geometryInitialized = false
 
G4bool geometryToBeOptimized = true
 
G4int numberOfParallelWorld = 0
 
G4int numberOfStaticAllocators = 0
 
G4bool physicsInitialized = false
 
G4VUserPhysicsListphysicsList = nullptr
 
G4bool physicsNeedsToBeReBuilt = true
 
G4int verboseLevel = 0
 
G4String versionString = ""
 

Static Private Attributes

static G4ThreadLocal G4RunManagerKernelfRunManagerKernel = nullptr
 

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
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 = allocList->Size();
125
126 if(G4StateManager::GetStateManager()->GetExceptionHandler() == nullptr)
127 {
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
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 += " ";
181 G4cout << G4endl
182 << "**************************************************************"
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:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
static void InvalidOperationDetection()
int G4int
Definition: G4Types.hh:85
static const G4String G4Date
Definition: G4Version.hh:60
static const G4String G4Version
Definition: G4Version.hh:58
#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: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
G4ExceptionHandler * defaultExceptionHandler
static G4ThreadLocal G4RunManagerKernel * fRunManagerKernel
G4EventManager * eventManager
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)

References defaultExceptionHandler, defaultRegion, defaultRegionForParallelWorld, G4Backtrace::Enable(), G4ParticleTable::entries(), eventManager, FatalException, fRunManagerKernel, G4cout, G4Date, G4endl, G4Exception(), G4State_PreInit, G4Version, G4AllocatorList::GetAllocatorListIfExist(), G4ParticleTable::GetParticle(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetParticleTable(), G4ProductionCutsTable::GetProductionCutsTable(), G4StateManager::GetStateManager(), InvalidOperationDetection(), numberOfStaticAllocators, runManagerKernelType, sequentialRMK, G4StateManager::SetNewState(), G4Region::SetProductionCuts(), G4AllocatorList::Size(), and versionString.

◆ ~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 > 0)
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 {
407 delete allocList;
408 if(verboseLevel > 1)
409 G4cout << "G4Allocator objects are deleted." << G4endl;
410 }
411
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 verboseLevel = 0;
419 }
420 delete pUImanager;
421 if(verboseLevel > 1)
422 G4cout << "UImanager deleted." << G4endl;
423
424 delete pStateManager;
425 if(verboseLevel > 1)
426 G4cout << "StateManager deleted." << G4endl;
428 if(verboseLevel > 0)
429 G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
430 fRunManagerKernel = nullptr;
431}
@ 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()

References G4UnitDefinition::ClearUnitsTable(), defaultExceptionHandler, G4AllocatorList::Destroy(), eventManager, fRunManagerKernel, G4cout, G4endl, G4State_Quit, G4AllocatorList::GetAllocatorListIfExist(), G4StateManager::GetCurrentState(), G4GeometryManager::GetInstance(), G4NavigationHistoryPool::GetInstance(), G4FieldManagerStore::GetInstanceIfExist(), G4GeometryManager::GetInstanceIfExist(), G4PathFinder::GetInstanceIfExist(), G4TransportationManager::GetInstanceIfExist(), G4ParallelWorldProcessStore::GetInstanceIfExist(), G4TemplateRNGHelper< T >::GetInstanceIfExist(), G4SDManager::GetSDMpointerIfExist(), G4StateManager::GetStateManager(), G4UImanager::GetUIpointer(), numberOfStaticAllocators, G4GeometryManager::OpenGeometry(), G4NavigationHistoryPool::Print(), runManagerKernelType, G4StateManager::SetNewState(), verboseLevel, and workerRMK.

◆ 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 {
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 {
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
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 += " ";
291 G4cout << G4endl
292 << "**************************************************************"
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 "^^^^^^^^^"
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

References defaultExceptionHandler, defaultRegion, defaultRegionForParallelWorld, G4Backtrace::Enable(), eventManager, FatalException, fRunManagerKernel, G4cout, G4Date, G4endl, G4Exception(), G4State_PreInit, G4Version, G4RegionStore::GetInstance(), G4ProductionCutsTable::GetProductionCutsTable(), G4RegionStore::GetRegion(), G4StateManager::GetStateManager(), G4UnitDefinition::GetUnitsTable(), InvalidOperationDetection(), G4Threading::IsMasterThread(), masterRMK, runManagerKernelType, G4StateManager::SetNewState(), G4Region::SetProductionCuts(), verboseLevel, versionString, and workerRMK.

Member Function Documentation

◆ BuildPhysicsTables()

void G4RunManagerKernel::BuildPhysicsTables ( G4bool  fakeRun)
protected

Definition at line 895 of file G4RunManagerKernel.cc.

896{
899 {
900 #ifdef G4MULTITHREADED
902 {
903 // make sure workers also rebuild physics tables
905 pUImanager->ApplyCommand("/run/physicsModified");
906 }
907 #endif
911 }
912
913 if(!fakeRun && verboseLevel > 1)
914 DumpRegion();
915 if(!fakeRun && verboseLevel > 0)
917 if(!fakeRun)
919}
G4VUserPhysicsList * physicsList
void DumpRegion(const G4String &rname) const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void DumpCutValuesTable(G4int flag=1)

References G4UImanager::ApplyCommand(), G4VUserPhysicsList::BuildPhysicsTable(), G4VUserPhysicsList::DumpCutValuesTable(), G4VUserPhysicsList::DumpCutValuesTableIfRequested(), DumpRegion(), G4ProductionCutsTable::GetProductionCutsTable(), G4UImanager::GetUIpointer(), masterRMK, physicsList, physicsNeedsToBeReBuilt, runManagerKernelType, and verboseLevel.

Referenced by RunInitialization().

◆ CheckRegions()

void G4RunManagerKernel::CheckRegions ( )
protected

Definition at line 922 of file G4RunManagerKernel.cc.

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

References G4Region::AddRootLogicalVolume(), G4Region::BelongsTo(), currentWorld, defaultRegionForParallelWorld, G4cout, G4endl, G4ProductionCutsTable::GetDefaultProductionCuts(), G4RegionStore::GetInstance(), G4Region::GetName(), G4TransportationManager::GetNoWorlds(), G4Region::GetProductionCuts(), G4ProductionCutsTable::GetProductionCutsTable(), G4LogicalVolume::GetRegion(), G4TransportationManager::GetTransportationManager(), G4TransportationManager::GetWorldsIterator(), G4Region::IsInMassGeometry(), G4Region::IsInParallelGeometry(), G4Region::SetProductionCuts(), G4LogicalVolume::SetRegion(), G4Region::SetWorld(), G4Region::UsedInMassGeometry(), G4Region::UsedInParallelGeometry(), and verboseLevel.

Referenced by InitializePhysics(), and UpdateRegion().

◆ CheckRegularGeometry()

void G4RunManagerKernel::CheckRegularGeometry ( )
private

Definition at line 1090 of file G4RunManagerKernel.cc.

1091{
1093 for(auto pos = store->cbegin(); pos != store->cend(); ++pos)
1094 {
1095 if((*pos) && ((*pos)->GetNoDaughters() == 1))
1096 {
1097 if((*pos)->GetDaughter(0)->IsRegularStructure())
1098 {
1100 return;
1101 }
1102 }
1103 }
1104}
static const G4double pos
static G4LogicalVolumeStore * GetInstance()

References G4LogicalVolumeStore::GetInstance(), pos, and SetScoreSplitter().

Referenced by RunInitialization().

◆ ConfirmCoupledTransportation()

G4bool G4RunManagerKernel::ConfirmCoupledTransportation ( )
private

Definition at line 1107 of file G4RunManagerKernel.cc.

1108{
1110 auto theParticleIterator = theParticleTable->GetIterator();
1111 theParticleIterator->reset();
1112 while((*theParticleIterator)())
1113 {
1116 if(pm)
1117 {
1119 G4VProcess* p = (*pv)[0];
1120 return ((p->GetProcessName()) == "CoupledTransportation");
1121 }
1122 }
1123 return false;
1124}
@ typeDoIt
#define theParticleIterator
G4ProcessManager * GetProcessManager() const
G4PTblDicIterator * GetIterator() const
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:382

References G4ProcessManager::GetAlongStepProcessVector(), G4ParticleTable::GetIterator(), G4ParticleTable::GetParticleTable(), G4ParticleDefinition::GetProcessManager(), G4VProcess::GetProcessName(), theParticleIterator, and typeDoIt.

◆ DefineWorldVolume()

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

Definition at line 520 of file G4RunManagerKernel.cc.

522{
524 G4ApplicationState currentState = stateManager->GetCurrentState();
525
526 if(currentState != G4State_Init)
527 {
528 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
529 {
530 G4cout << "Current application state is "
531 << stateManager->GetStateString(currentState) << G4endl;
532 G4Exception("G4RunManagerKernel::DefineWorldVolume",
533 "DefineWorldVolumeAtIncorrectState", FatalException,
534 "Geant4 kernel is not Init state : Method ignored.");
535 return;
536 }
537 else
538 {
539 stateManager->SetNewState(G4State_Init);
540 }
541 }
542
543 // The world volume MUST NOT have a region defined by the user
544 if(worldVol->GetLogicalVolume()->GetRegion() != nullptr)
545 {
546 if(worldVol->GetLogicalVolume()->GetRegion() != defaultRegion)
547 {
549 ED << "The world volume has a user-defined region <"
550 << worldVol->GetLogicalVolume()->GetRegion()->GetName() << ">."
551 << G4endl;
552 ED << "World would have a default region assigned by RunManagerKernel."
553 << G4endl;
554 G4Exception("G4RunManager::DefineWorldVolume", "Run0004", FatalException,
555 ED);
556 }
557 }
558
560
561 // Accept the world volume
562 currentWorld = worldVol;
563
564 // Set the default region to the world
565
567 worldLog->SetRegion(defaultRegion);
569 if(verboseLevel > 1)
570 G4cout << worldLog->GetName() << " is registered to the default region."
571 << G4endl;
572
573 // Set the world volume, notify the Navigator and reset its state
576 if(topologyIsChanged)
578
579 // Notify the VisManager as well
581 {
583 if(pVVisManager != nullptr)
584 pVVisManager->GeometryHasChanged();
585 }
586
587 geometryInitialized = true;
588 stateManager->SetNewState(currentState);
589 if(physicsInitialized && currentState != G4State_Idle)
590 {
591 stateManager->SetNewState(G4State_Idle);
592 }
593}
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

References G4Region::AddRootLogicalVolume(), currentWorld, defaultRegion, FatalException, G4cout, G4endl, G4Exception(), G4State_Idle, G4State_Init, G4State_PreInit, G4VVisManager::GeometryHasChanged(), geometryInitialized, geometryNeedsToBeClosed, G4VVisManager::GetConcreteInstance(), G4StateManager::GetCurrentState(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetName(), G4Region::GetName(), G4LogicalVolume::GetRegion(), G4StateManager::GetStateManager(), G4StateManager::GetStateString(), G4TransportationManager::GetTransportationManager(), G4Threading::IsMasterThread(), physicsInitialized, G4StateManager::SetNewState(), G4LogicalVolume::SetRegion(), SetupDefaultRegion(), G4TransportationManager::SetWorldForTracking(), and verboseLevel.

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

◆ DumpRegion() [1/2]

void G4RunManagerKernel::DumpRegion ( const G4String rname) const

Definition at line 999 of file G4RunManagerKernel.cc.

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

References DumpRegion(), G4RegionStore::GetInstance(), and G4RegionStore::GetRegion().

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

◆ DumpRegion() [2/2]

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

Definition at line 1007 of file G4RunManagerKernel.cc.

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

References DumpRegion(), G4BestUnit, G4cerr, G4cout, G4endl, G4Region::GetFastSimulationManager(), G4RegionStore::GetInstance(), G4Region::GetMaterialIterator(), G4Region::GetName(), G4VPhysicalVolume::GetName(), G4Region::GetNumberOfMaterials(), G4Region::GetNumberOfRootVolumes(), G4ProductionCuts::GetProductionCut(), G4Region::GetProductionCuts(), G4ProductionCutsTable::GetProductionCutsTable(), G4Region::GetRegionalSteppingAction(), G4Region::GetRootLogicalVolumeIterator(), G4Region::GetUserInformation(), G4Region::GetUserLimits(), G4Region::GetWorldPhysical(), G4Region::IsInMassGeometry(), G4Region::IsInParallelGeometry(), G4Threading::IsWorkerThread(), and G4Region::SetProductionCuts().

◆ GeometryHasBeenModified()

void G4RunManagerKernel::GeometryHasBeenModified ( )
inline

◆ GetCurrentWorld()

G4VPhysicalVolume * G4RunManagerKernel::GetCurrentWorld ( ) const
inline

Definition at line 169 of file G4RunManagerKernel.hh.

169{ return currentWorld; }

References currentWorld.

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ GetEventManager()

G4EventManager * G4RunManagerKernel::GetEventManager ( ) const
inline

Definition at line 130 of file G4RunManagerKernel.hh.

130{ return eventManager; }

References eventManager.

Referenced by G4RunManager::G4RunManager().

◆ GetNumberOfParallelWorld()

G4int G4RunManagerKernel::GetNumberOfParallelWorld ( ) const
inline

◆ GetNumberOfStaticAllocators()

G4int G4RunManagerKernel::GetNumberOfStaticAllocators ( ) const
inline

◆ GetPhysicsList()

G4VUserPhysicsList * G4RunManagerKernel::GetPhysicsList ( ) const
inline

Definition at line 167 of file G4RunManagerKernel.hh.

167{ return physicsList; }

References physicsList.

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4RunManagerKernel::GetPrimaryTransformer ( ) const
inline

Definition at line 143 of file G4RunManagerKernel.hh.

144 {
146 }
G4PrimaryTransformer * GetPrimaryTransformer() const

References eventManager, and G4EventManager::GetPrimaryTransformer().

Referenced by RunInitialization().

◆ GetRunManagerKernel()

G4RunManagerKernel * G4RunManagerKernel::GetRunManagerKernel ( )
static

◆ GetStackManager()

G4StackManager * G4RunManagerKernel::GetStackManager ( ) const
inline

Definition at line 131 of file G4RunManagerKernel.hh.

132 {
134 }
G4StackManager * GetStackManager() const

References eventManager, and G4EventManager::GetStackManager().

◆ GetTrackingManager()

G4TrackingManager * G4RunManagerKernel::GetTrackingManager ( ) const
inline

Definition at line 135 of file G4RunManagerKernel.hh.

136 {
138 }
G4TrackingManager * GetTrackingManager() const

References eventManager, and G4EventManager::GetTrackingManager().

Referenced by G4VisManager::Disable(), and G4ExceptionHandler::DumpTrackInfo().

◆ GetVersionString()

const G4String & G4RunManagerKernel::GetVersionString ( ) const
inline

Definition at line 148 of file G4RunManagerKernel.hh.

148{ return versionString; }

References versionString.

Referenced by G4RunManager::GetVersionString().

◆ InitializePhysics()

void G4RunManagerKernel::InitializePhysics ( )

Definition at line 673 of file G4RunManagerKernel.cc.

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

References G4VUserPhysicsList::CheckParticleList(), CheckRegions(), G4VUserPhysicsList::Construct(), FatalException, G4cout, G4endl, G4Exception(), G4State_Idle, G4State_Init, G4State_PreInit, geometryInitialized, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4StateManager::GetStateString(), G4UnitDefinition::GetUnitsTable(), anonymous_namespace{G4RunManagerKernel.cc}::initphysicsmutex, G4Threading::IsMasterThread(), numberOfParallelWorld, physicsInitialized, physicsList, G4VUserPhysicsList::SetCuts(), G4StateManager::SetNewState(), G4TemplateAutoLock< _Mutex_t >::unlock(), G4VUserPhysicsList::UseCoupledTransportation(), and verboseLevel.

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

◆ PhysicsHasBeenModified()

void G4RunManagerKernel::PhysicsHasBeenModified ( )
inline

Definition at line 124 of file G4RunManagerKernel.hh.

124{ physicsNeedsToBeReBuilt = true; }

References physicsNeedsToBeReBuilt.

Referenced by G4RunManager::PhysicsHasBeenModified().

◆ PropagateGenericIonID()

void G4RunManagerKernel::PropagateGenericIonID ( )
protected

Definition at line 820 of file G4RunManagerKernel.cc.

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

References G4ParticleTable::GetGenericIon(), G4ParticleTable::GetIterator(), G4ParticleDefinition::GetParticleDefinitionID(), G4ParticleTable::GetParticleTable(), G4ParticleDefinition::IsGeneralIon(), G4ParticleTableIterator< K, V >::reset(), and G4ParticleDefinition::SetParticleDefinitionID().

Referenced by RunInitialization().

◆ ResetNavigator()

void G4RunManagerKernel::ResetNavigator ( )
protected

Definition at line 848 of file G4RunManagerKernel.cc.

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

References G4GeometryManager::CloseGeometry(), G4cout, G4endl, geometryNeedsToBeClosed, geometryToBeOptimized, G4GeometryManager::GetInstance(), G4GeometryManager::OpenGeometry(), runManagerKernelType, verboseLevel, and workerRMK.

Referenced by RunInitialization().

◆ RunInitialization()

G4bool G4RunManagerKernel::RunInitialization ( G4bool  fakeRun = false)

Definition at line 761 of file G4RunManagerKernel.cc.

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

References BuildPhysicsTables(), CheckRegularGeometry(), G4PrimaryTransformer::CheckUnknown(), G4Exception(), G4State_GeomClosed, G4State_Idle, G4State_Init, G4VVisManager::GeometryHasChanged(), geometryInitialized, geometryNeedsToBeClosed, G4VVisManager::GetConcreteInstance(), G4StateManager::GetCurrentState(), GetPrimaryTransformer(), G4StateManager::GetStateManager(), G4UnitDefinition::GetUnitsTable(), G4Threading::IsMasterThread(), JustWarning, physicsInitialized, PropagateGenericIonID(), ResetNavigator(), G4StateManager::SetNewState(), SetupShadowProcess(), and UpdateRegion().

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

◆ RunTermination()

void G4RunManagerKernel::RunTermination ( )

◆ SetGeometryToBeOptimized()

void G4RunManagerKernel::SetGeometryToBeOptimized ( G4bool  vl)
inline

Definition at line 152 of file G4RunManagerKernel.hh.

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

References geometryNeedsToBeClosed, and geometryToBeOptimized.

Referenced by G4RunManager::SetGeometryToBeOptimized().

◆ SetNumberOfParallelWorld()

void G4RunManagerKernel::SetNumberOfParallelWorld ( G4int  i)
inline

◆ SetPhysics()

void G4RunManagerKernel::SetPhysics ( G4VUserPhysicsList uPhys)

Definition at line 596 of file G4RunManagerKernel.cc.

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

References G4ParticleTable::DumpTable(), G4ParticleTable::entries(), G4cout, G4endl, G4ParticleTable::GetParticle(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetParticleTable(), physicsList, runManagerKernelType, SetupPhysics(), verboseLevel, and workerRMK.

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

◆ SetPrimaryTransformer()

void G4RunManagerKernel::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inline

Definition at line 139 of file G4RunManagerKernel.hh.

140 {
142 }
void SetPrimaryTransformer(G4PrimaryTransformer *tf)

References eventManager, and G4EventManager::SetPrimaryTransformer().

Referenced by G4RunManager::SetPrimaryTransformer().

◆ SetScoreSplitter()

void G4RunManagerKernel::SetScoreSplitter ( )
private

Definition at line 1127 of file G4RunManagerKernel.cc.

1128{
1131 auto theParticleIterator = theParticleTable->GetIterator();
1132
1133 // Ensure that Process is added only once to the particles' process managers
1134 static G4ThreadLocal G4bool InitSplitter = false;
1135 if(!InitSplitter)
1136 {
1137 InitSplitter = true;
1138
1139 theParticleIterator->reset();
1140 while((*theParticleIterator)())
1141 {
1142 G4ParticleDefinition* particle = theParticleIterator->value();
1143 G4ProcessManager* pmanager = particle->GetProcessManager();
1144 if(pmanager)
1145 {
1146 pmanager->AddDiscreteProcess(pSplitter);
1147 }
1148 }
1149
1150 if(verboseLevel > 0)
1151 {
1152 G4cout
1153 << "G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all "
1154 "particles."
1155 << G4endl;
1156 }
1157 }
1158}
bool G4bool
Definition: G4Types.hh:86
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
#define G4ThreadLocal
Definition: tls.hh:77

References G4ProcessManager::AddDiscreteProcess(), G4cout, G4endl, G4ThreadLocal, G4ParticleTable::GetIterator(), G4ParticleTable::GetParticleTable(), G4ParticleDefinition::GetProcessManager(), theParticleIterator, and verboseLevel.

Referenced by CheckRegularGeometry().

◆ 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

References defaultRegion, FatalException, G4cout, G4endl, G4Exception(), G4Region::GetNumberOfRootVolumes(), G4Region::GetRootLogicalVolumeIterator(), G4Region::RemoveRootLogicalVolume(), runManagerKernelType, verboseLevel, and workerRMK.

Referenced by DefineWorldVolume().

◆ SetupPhysics()

void G4RunManagerKernel::SetupPhysics ( )
protected

Definition at line 625 of file G4RunManagerKernel.cc.

626{
628
630
631 // For sanity reason
635 if(gion != nullptr)
636 {
638 }
640
642 pItr->reset();
643 while((*pItr)())
644 {
645 G4ParticleDefinition* particle = pItr->value();
646 if(!(particle->IsGeneralIon()))
647 particle->SetParticleDefinitionID();
648 }
649
650 if(gion != nullptr)
651 {
652 G4int gionId = gion->GetParticleDefinitionID();
653 pItr->reset(false);
654 while((*pItr)())
655 {
656 G4ParticleDefinition* particle = pItr->value();
657 if(particle->IsGeneralIon())
658 particle->SetParticleDefinitionID(gionId);
659 }
660 }
661#ifdef G4MULTITHREADED
662 G4UnitDefinition::GetUnitsTable().Synchronize();
663#endif
664}
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

References G4IonConstructor::ConstructParticle(), G4VUserPhysicsList::ConstructParticle(), G4Geantino::GeantinoDefinition(), G4ParticleTable::GetGenericIon(), G4ParticleTable::GetIonTable(), G4ParticleTable::GetIterator(), G4ParticleDefinition::GetParticleDefinitionID(), G4ParticleTable::GetParticleTable(), G4UnitDefinition::GetUnitsTable(), G4IonTable::InitializeLightIons(), G4ParticleDefinition::IsGeneralIon(), physicsList, G4ParticleTableIterator< K, V >::reset(), G4ParticleDefinition::SetParticleDefinitionID(), and G4ParticleTable::SetReadiness().

Referenced by SetPhysics().

◆ SetupShadowProcess()

void G4RunManagerKernel::SetupShadowProcess ( ) const
protectedvirtual

Reimplemented in G4MTRunManagerKernel, G4WorkerRunManagerKernel, G4TaskRunManagerKernel, and G4WorkerTaskRunManagerKernel.

Definition at line 1161 of file G4RunManagerKernel.cc.

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

References G4ParticleTable::GetIterator(), G4ParticleTable::GetParticleTable(), G4ProcessManager::GetProcessList(), G4ParticleDefinition::GetProcessManager(), G4ProcessVector::size(), and theParticleIterator.

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

◆ SetVerboseLevel()

void G4RunManagerKernel::SetVerboseLevel ( G4int  vl)
inline

◆ UpdateRegion()

void G4RunManagerKernel::UpdateRegion ( )

Definition at line 872 of file G4RunManagerKernel.cc.

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

References CheckRegions(), currentWorld, G4Exception(), G4State_Init, G4StateManager::GetCurrentState(), G4RegionStore::GetInstance(), G4ProductionCutsTable::GetProductionCutsTable(), G4StateManager::GetStateManager(), JustWarning, runManagerKernelType, G4ProductionCutsTable::UpdateCoupleTable(), G4RegionStore::UpdateMaterialList(), and workerRMK.

Referenced by G4MaterialScanner::DoScan(), and RunInitialization().

◆ WorkerDefineWorldVolume()

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

Definition at line 455 of file G4RunManagerKernel.cc.

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

References currentWorld, FatalException, G4cout, G4endl, G4Exception(), G4State_Idle, G4State_Init, G4State_PreInit, G4VVisManager::GeometryHasChanged(), geometryInitialized, geometryNeedsToBeClosed, G4VVisManager::GetConcreteInstance(), G4StateManager::GetCurrentState(), G4MTRunManager::GetMasterRunManager(), G4MTRunManager::GetMasterWorlds(), G4StateManager::GetStateManager(), G4StateManager::GetStateString(), G4TransportationManager::GetTransportationManager(), G4Threading::IsMasterThread(), physicsInitialized, G4TransportationManager::RegisterWorld(), G4StateManager::SetNewState(), and G4TransportationManager::SetWorldForTracking().

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ WorkerUpdateWorldVolume()

void G4RunManagerKernel::WorkerUpdateWorldVolume ( )

Definition at line 434 of file G4RunManagerKernel.cc.

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

References G4MTRunManager::GetMasterRunManager(), G4MTRunManager::GetMasterWorlds(), G4VPhysicalVolume::GetName(), G4TransportationManager::GetTransportationManager(), G4TransportationManager::IsWorldExisting(), and G4TransportationManager::RegisterWorld().

Referenced by G4WorkerRunManager::ConstructScoringWorlds().

Field Documentation

◆ currentWorld

G4VPhysicalVolume* G4RunManagerKernel::currentWorld = nullptr
private

◆ defaultExceptionHandler

G4ExceptionHandler* G4RunManagerKernel::defaultExceptionHandler = nullptr
private

Definition at line 227 of file G4RunManagerKernel.hh.

Referenced by G4RunManagerKernel(), and ~G4RunManagerKernel().

◆ 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().

◆ eventManager

G4EventManager* G4RunManagerKernel::eventManager = nullptr
private

◆ fRunManagerKernel

G4ThreadLocal G4RunManagerKernel * G4RunManagerKernel::fRunManagerKernel = nullptr
staticprivate

◆ geometryInitialized

G4bool G4RunManagerKernel::geometryInitialized = false
private

◆ geometryNeedsToBeClosed

G4bool G4RunManagerKernel::geometryNeedsToBeClosed = true
protected

◆ geometryToBeOptimized

G4bool G4RunManagerKernel::geometryToBeOptimized = true
private

Definition at line 221 of file G4RunManagerKernel.hh.

Referenced by ResetNavigator(), and SetGeometryToBeOptimized().

◆ numberOfParallelWorld

G4int G4RunManagerKernel::numberOfParallelWorld = 0
private

◆ numberOfStaticAllocators

G4int G4RunManagerKernel::numberOfStaticAllocators = 0
private

◆ physicsInitialized

G4bool G4RunManagerKernel::physicsInitialized = false
private

◆ physicsList

G4VUserPhysicsList* G4RunManagerKernel::physicsList = nullptr
private

◆ physicsNeedsToBeReBuilt

G4bool G4RunManagerKernel::physicsNeedsToBeReBuilt = true
private

Definition at line 222 of file G4RunManagerKernel.hh.

Referenced by BuildPhysicsTables(), and PhysicsHasBeenModified().

◆ runManagerKernelType

RMKType G4RunManagerKernel::runManagerKernelType
protected

◆ verboseLevel

G4int G4RunManagerKernel::verboseLevel = 0
private

◆ versionString

G4String G4RunManagerKernel::versionString = ""
private

Definition at line 228 of file G4RunManagerKernel.hh.

Referenced by G4RunManagerKernel(), and GetVersionString().


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