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

#include <G4RunManagerKernel.hh>

+ Inheritance diagram for G4RunManagerKernel:

Public Types

enum  RMKType { sequentialRMK , masterRMK , workerRMK }
 

Public Member Functions

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

Static Public Member Functions

static G4RunManagerKernelGetRunManagerKernel ()
 

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Definition at line 64 of file G4RunManagerKernel.hh.

Member Enumeration Documentation

◆ RMKType

Enumerator
sequentialRMK 
masterRMK 
workerRMK 

Definition at line 163 of file G4RunManagerKernel.hh.

Constructor & Destructor Documentation

◆ G4RunManagerKernel() [1/2]

G4RunManagerKernel::G4RunManagerKernel ( )

Definition at line 98 of file G4RunManagerKernel.cc.

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()) {
108 }
109 else {
110 G4Backtrace::Enable(_signals);
111 }
112#endif
113
115 if (allocList != nullptr) numberOfStaticAllocators = (G4int)allocList->Size();
116
117 if (G4StateManager::GetStateManager()->GetExceptionHandler() == nullptr) {
118 defaultExceptionHandler = new G4ExceptionHandler();
119 }
120 if (fRunManagerKernel != nullptr) {
121 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0001", FatalException,
122 "More than one G4RunManagerKernel is constructed.");
123 }
124 fRunManagerKernel = this;
125
127 if (particleTable->entries() > 0) {
128 // No particle should be registered beforehand
130 ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
131 ED << " G4RunManagerKernel fatal exception" << G4endl;
132 ED << " -- Following particles have already been registered" << G4endl;
133 ED << " before G4RunManagerKernel is instantiated." << G4endl;
134 for (G4int i = 0; i < particleTable->entries(); ++i) {
135 ED << " " << particleTable->GetParticle(i)->GetParticleName() << G4endl;
136 }
137 ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
138 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0002", FatalException, ED);
139 }
140
141 // construction of Geant4 kernel classes
142 eventManager = new G4EventManager();
143
144 defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
146 new G4Region("DefaultRegionForParallelWorld"); // deleted by store
148 G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
150 G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
151
153 // set the initial application state
155
156 // version banner
157 G4String vs = G4Version;
158 vs = vs.substr(1, vs.size() - 2);
159 versionString = " Geant4 version ";
160 versionString += vs;
161 versionString += " ";
162 versionString += G4Date;
163 G4cout << G4endl << "**************************************************************" << G4endl
164 << versionString << G4endl << " Copyright : Geant4 Collaboration"
165 << G4endl << " References : NIM A 506 (2003), 250-303" << G4endl
166 << " : IEEE-TNS 53 (2006), 270-278" << G4endl
167 << " : NIM A 835 (2016), 186-225" << G4endl
168 << " WWW : http://geant4.org/" << G4endl
169 << "**************************************************************" << G4endl << G4endl;
170}
@ G4State_PreInit
_Tp G4GetEnv(const std::string &env_id, _Tp _default=_Tp())
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4AllocatorList * GetAllocatorListIfExist()
std::size_t Size() const
static G4int Enable(const std::string &)
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 301 of file G4RunManagerKernel.cc.

302{
304 // set the application state to the quite state
305 if (pStateManager->GetCurrentState() != G4State_Quit) {
306 if (verboseLevel > 1) G4cout << "G4 kernel has come to Quit state." << G4endl;
307 pStateManager->SetNewState(G4State_Quit);
308 }
309
310 // open geometry for deletion
312
313 // deletion of Geant4 kernel classes
316 if (verboseLevel > 1) G4cout << "G4SDManager deleted." << G4endl;
317 delete eventManager;
318 if (verboseLevel > 1) G4cout << "EventManager deleted." << G4endl;
319
321 if (verboseLevel > 1) G4cout << "Units table cleared." << G4endl;
322
323 // deletion of path-finder field-manager store, geometry and transportation
324 // manager
329 if (verboseLevel > 1) G4cout << "TransportationManager deleted." << G4endl;
330
331 // deletion of navigation levels
332 if (verboseLevel > 1) G4NavigationHistoryPool::GetInstance()->Print();
334
335 // deletion of G4RNGHelper singleton
338 if (verboseLevel > 1) G4cout << "G4RNGHelper object is deleted." << G4endl;
339 }
340
341 // deletion of allocators
343 if (allocList != nullptr) {
344 allocList->Destroy(numberOfStaticAllocators, verboseLevel);
345 delete allocList;
346 if (verboseLevel > 1) G4cout << "G4Allocator objects are deleted." << G4endl;
347 }
348
350 if ((runManagerKernelType == workerRMK) && (verboseLevel > 1)) {
351 G4cout << "Thread-local UImanager is to be deleted." << G4endl
352 << "There should not be any thread-local G4cout/G4cerr hereafter." << G4endl;
353 }
354 delete pUImanager;
355 if (verboseLevel > 1) G4cout << "UImanager deleted." << G4endl;
356
357 delete pStateManager;
358 if (verboseLevel > 1) G4cout << "StateManager deleted." << G4endl;
359 delete defaultExceptionHandler;
360 if (verboseLevel > 1) G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
361 fRunManagerKernel = nullptr;
362}
@ 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()
static G4SDManager * GetSDMpointerIfExist()
const G4ApplicationState & GetCurrentState() const
static G4TemplateRNGHelper< T > * GetInstanceIfExist()
static G4TransportationManager * GetInstanceIfExist()
static G4UImanager * GetUIpointer()
static void ClearUnitsTable()

◆ G4RunManagerKernel() [2/2]

G4RunManagerKernel::G4RunManagerKernel ( RMKType rmkType)
protected

Definition at line 173 of file G4RunManagerKernel.cc.

174{
175// This version of the constructor should never be called in sequential mode!
176#ifndef G4MULTITHREADED
178 msg << "Geant4 code is compiled without multi-threading support "
179 "(-DG4MULTITHREADED is set to off).";
180 msg << " This type of RunManagerKernel can only be used in mult-threaded "
181 "applications.";
182 G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)", "Run0105", FatalException, msg);
183#endif
184
185#ifdef G4FPE_DEBUG
187 InvalidOperationDetection();
188 }
189#endif
190
191#ifdef G4BT_DEBUG
192 auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
193 if (_signals.empty()) {
195 }
196 else {
197 G4Backtrace::Enable(_signals);
198 }
199#endif
200
201 if (G4StateManager::GetStateManager()->GetExceptionHandler() == nullptr) {
202 defaultExceptionHandler = new G4ExceptionHandler();
203 }
204
205 if (fRunManagerKernel != nullptr) {
206 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0001", FatalException,
207 "More than one G4RunManagerKernel is constructed.");
208 }
209 fRunManagerKernel = this;
210 // construction of Geant4 kernel classes
211 eventManager = new G4EventManager();
212
213 switch (rmkType) {
214 case masterRMK:
215 // Master thread behvior
216 defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
218 new G4Region("DefaultRegionForParallelWorld"); // deleted by store
220 G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
222 G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
223 break;
224 case workerRMK:
225 // Worker thread behavior
226 defaultRegion = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", true);
228 G4RegionStore::GetInstance()->GetRegion("DefaultRegionForParallelWorld", true);
229 break;
230 default:
231 defaultRegion = nullptr;
234 msgx << " This type of RunManagerKernel can only be used in mult-threaded "
235 "applications.";
236 G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)", "Run0106", FatalException,
237 msgx);
238 }
239 runManagerKernelType = rmkType;
240
241 // set the initial application state
243
244 // version banner
245 G4String vs = G4Version;
246 vs = vs.substr(1, vs.size() - 2);
247 switch (rmkType) {
248 case masterRMK:
249 versionString = " Geant4 version ";
250 versionString += vs;
251 versionString += " ";
252 versionString += G4Date;
253 G4cout << G4endl << "**************************************************************" << G4endl
254 << versionString << G4endl << " << in Multi-threaded mode >> " << G4endl
255 << " Copyright : Geant4 Collaboration" << G4endl
256 << " References : NIM A 506 (2003), 250-303" << G4endl
257 << " : IEEE-TNS 53 (2006), 270-278" << G4endl
258 << " : NIM A 835 (2016), 186-225" << G4endl
259 << " WWW : http://geant4.org/" << G4endl
260 << "**************************************************************" << G4endl
261 << G4endl;
262 break;
263 default:
264 if (verboseLevel != 0) {
265 versionString = " Local thread RunManagerKernel version ";
266 versionString += vs;
267 G4cout << G4endl
268 << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
269 "^^^^^^^^^"
270 << G4endl << versionString << G4endl
271 << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
272 "^^^^^^^^^"
273 << G4endl << G4endl;
274 }
275 }
276
277#ifdef G4MULTITHREADED
278 G4UnitDefinition::GetUnitsTable().Synchronize();
279#endif
280}
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
static G4UnitsTable & GetUnitsTable()
G4bool IsMasterThread()

Member Function Documentation

◆ BuildPhysicsTables()

void G4RunManagerKernel::BuildPhysicsTables ( G4bool fakeRun)
protected

Definition at line 725 of file G4RunManagerKernel.cc.

726{
727 if (G4ProductionCutsTable::GetProductionCutsTable()->IsModified() || physicsNeedsToBeReBuilt) {
728#ifdef G4MULTITHREADED
730 // make sure workers also rebuild physics tables
732 pUImanager->ApplyCommand("/run/physicsModified");
733 }
734#endif
735 physicsList->BuildPhysicsTable();
736 physicsNeedsToBeReBuilt = false;
737 }
738
739 if (!fakeRun && verboseLevel > 1) DumpRegion();
740 if (!fakeRun && verboseLevel > 0) physicsList->DumpCutValuesTable();
741 if (!fakeRun) physicsList->DumpCutValuesTableIfRequested();
742}
void DumpRegion(const G4String &rname) const
G4int ApplyCommand(const char *aCommand)
void DumpCutValuesTable(G4int flag=1)

Referenced by RunInitialization().

◆ CheckRegions()

void G4RunManagerKernel::CheckRegions ( )
protected

Definition at line 745 of file G4RunManagerKernel.cc.

746{
748 std::size_t nWorlds = transM->GetNoWorlds();
749 std::vector<G4VPhysicalVolume*>::iterator wItr;
750 for (auto region : *G4RegionStore::GetInstance()) {
751 // Let each region have a pointer to the world volume where it belongs to.
752 // G4Region::SetWorld() checks if the region belongs to the given world and
753 // set it only if it does. Thus, here we go through all the registered world
754 // volumes.
755 region->SetWorld(nullptr); // reset
756 region->UsedInMassGeometry(false);
757 region->UsedInParallelGeometry(false);
758 wItr = transM->GetWorldsIterator();
759 for (std::size_t iw = 0; iw < nWorlds; ++iw) {
760 if (region->BelongsTo(*wItr)) {
761 if (*wItr == currentWorld) {
762 region->UsedInMassGeometry(true);
763 }
764 else {
765 region->UsedInParallelGeometry(true);
766 }
767 }
768 region->SetWorld(*wItr);
769 ++wItr;
770 }
771
772 G4ProductionCuts* cuts = region->GetProductionCuts();
773 if (cuts == nullptr) {
774 if (region->IsInMassGeometry() && verboseLevel > 0) {
775 G4cout << "Warning : Region <" << region->GetName()
776 << "> does not have specific production cuts," << G4endl
777 << "even though it appears in the current tracking world." << G4endl;
778 G4cout << "Default cuts are used for this region." << G4endl;
779 }
780
781 if (region->IsInMassGeometry() || region->IsInParallelGeometry()) {
782 region->SetProductionCuts(
783 G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
784 }
785 }
786 }
787
788 //
789 // If a parallel world has no region, set default region for parallel world
790 //
791
792 wItr = transM->GetWorldsIterator();
793 for (std::size_t iw = 0; iw < nWorlds; ++iw) {
794 if (*wItr != currentWorld) {
795 G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
796 if (pwLogical->GetRegion() == nullptr) {
799 }
800 }
801 ++wItr;
802 }
803}
void SetRegion(G4Region *reg)
G4Region * GetRegion() const
const std::vector< G4double > & GetProductionCuts() const
void AddRootLogicalVolume(G4LogicalVolume *lv, G4bool search=true)
Definition G4Region.cc:293
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const

Referenced by InitializePhysics(), and UpdateRegion().

◆ DefineWorldVolume()

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

Definition at line 431 of file G4RunManagerKernel.cc.

432{
434 G4ApplicationState currentState = stateManager->GetCurrentState();
435
436 if (currentState != G4State_Init) {
437 if (currentState != G4State_Idle && currentState != G4State_PreInit) {
438 G4cout << "Current application state is " << stateManager->GetStateString(currentState)
439 << G4endl;
440 G4Exception("G4RunManagerKernel::DefineWorldVolume", "DefineWorldVolumeAtIncorrectState",
441 FatalException, "Geant4 kernel is not Init state : Method ignored.");
442 return;
443 }
444
445 stateManager->SetNewState(G4State_Init);
446 }
447
448 // The world volume MUST NOT have a region defined by the user
449 if (worldVol->GetLogicalVolume()->GetRegion() != nullptr) {
450 if (worldVol->GetLogicalVolume()->GetRegion() != defaultRegion) {
452 ED << "The world volume has a user-defined region <"
453 << worldVol->GetLogicalVolume()->GetRegion()->GetName() << ">." << G4endl;
454 ED << "World would have a default region assigned by RunManagerKernel." << G4endl;
455 G4Exception("G4RunManager::DefineWorldVolume", "Run0004", FatalException, ED);
456 }
457 }
458
460
461 // Accept the world volume
462 currentWorld = worldVol;
463
464 // Set the default region to the world
465
466 G4LogicalVolume* worldLog = currentWorld->GetLogicalVolume();
467 worldLog->SetRegion(defaultRegion);
469 if (verboseLevel > 1)
470 G4cout << worldLog->GetName() << " is registered to the default region." << G4endl;
471
472 // Set the world volume, notify the Navigator and reset its state
474 if (topologyIsChanged) geometryNeedsToBeClosed = true;
475
476 // Notify the VisManager as well
479 if (pVVisManager != nullptr) pVVisManager->GeometryHasChanged();
480 }
481
482 geometryInitialized = true;
483 stateManager->SetNewState(currentState);
484 if (physicsInitialized && currentState != G4State_Idle) {
485 stateManager->SetNewState(G4State_Idle);
486 }
487}
G4ApplicationState
@ G4State_Init
@ G4State_Idle
const G4String & GetName() const
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 806 of file G4RunManagerKernel.cc.

807{
809 if (region != nullptr) DumpRegion(region);
810}

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

◆ DumpRegion() [2/2]

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

Definition at line 813 of file G4RunManagerKernel.cc.

814{
815 if (region == nullptr) {
816 for (const auto& i : *G4RegionStore::GetInstance()) {
817 DumpRegion(i);
818 }
819 }
820 else {
821 if (G4Threading::IsWorkerThread()) return;
822 G4cout << G4endl;
823 G4cout << "Region <" << region->GetName() << "> -- ";
824 if (region->GetWorldPhysical() != nullptr) {
825 G4cout << " -- appears in <" << region->GetWorldPhysical()->GetName() << "> world volume";
826 }
827 else {
828 G4cout << " -- is not associated to any world.";
829 }
830 G4cout << G4endl;
831 if (region->IsInMassGeometry()) {
832 G4cout << " This region is in the mass world." << G4endl;
833 }
834 if (region->IsInParallelGeometry()) {
835 G4cout << " This region is in the parallel world." << G4endl;
836 }
837
838 G4cout << " Root logical volume(s) : ";
839 std::size_t nRootLV = region->GetNumberOfRootVolumes();
840 auto lvItr = region->GetRootLogicalVolumeIterator();
841 for (std::size_t j = 0; j < nRootLV; ++j) {
842 G4cout << (*lvItr)->GetName() << " ";
843 ++lvItr;
844 }
845 G4cout << G4endl;
846
847 G4cout << " Pointers : G4VUserRegionInformation[" << region->GetUserInformation()
848 << "], G4UserLimits[" << region->GetUserLimits() << "], G4FastSimulationManager["
849 << region->GetFastSimulationManager() << "], G4UserSteppingAction["
850 << region->GetRegionalSteppingAction() << "]" << G4endl;
851
852 G4cout << " Materials : ";
853 auto mItr = region->GetMaterialIterator();
854 std::size_t nMaterial = region->GetNumberOfMaterials();
855 for (std::size_t iMate = 0; iMate < nMaterial; ++iMate) {
856 G4cout << (*mItr)->GetName() << " ";
857 ++mItr;
858 }
859 G4cout << G4endl;
860 G4ProductionCuts* cuts = region->GetProductionCuts();
861 if ((cuts == nullptr) && region->IsInMassGeometry()) {
862 G4cerr << "Warning : Region <" << region->GetName()
863 << "> does not have specific production cuts." << G4endl;
864 G4cerr << "Default cuts are used for this region." << G4endl;
865 region->SetProductionCuts(
866 G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
867 }
868 else if (cuts != nullptr) {
869 G4cout << " Production cuts : "
870 << " gamma " << G4BestUnit(cuts->GetProductionCut("gamma"), "Length") << " e- "
871 << G4BestUnit(cuts->GetProductionCut("e-"), "Length") << " e+ "
872 << G4BestUnit(cuts->GetProductionCut("e+"), "Length") << " proton "
873 << G4BestUnit(cuts->GetProductionCut("proton"), "Length") << G4endl;
874 }
875 }
876}
#define G4BestUnit(a, b)
G4GLOB_DLL std::ostream G4cerr
G4double GetProductionCut(G4int index) const
std::size_t GetNumberOfRootVolumes() const
std::size_t GetNumberOfMaterials() const
G4FastSimulationManager * GetFastSimulationManager() const
Definition G4Region.cc:140
G4VUserRegionInformation * GetUserInformation() const
G4bool IsInParallelGeometry() const
G4ProductionCuts * GetProductionCuts() const
G4VPhysicalVolume * GetWorldPhysical() const
G4UserLimits * GetUserLimits() const
G4bool IsInMassGeometry() const
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition G4Region.cc:158
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()
const G4String & GetName() const
G4bool IsWorkerThread()

◆ GeometryHasBeenModified()

void G4RunManagerKernel::GeometryHasBeenModified ( )
inline

◆ GetCurrentWorld()

G4VPhysicalVolume * G4RunManagerKernel::GetCurrentWorld ( ) const
inline

Definition at line 159 of file G4RunManagerKernel.hh.

159{ return currentWorld; }

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ GetEventManager()

G4EventManager * G4RunManagerKernel::GetEventManager ( ) const
inline

Definition at line 127 of file G4RunManagerKernel.hh.

127{ return eventManager; }

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

◆ GetNumberOfParallelWorld()

G4int G4RunManagerKernel::GetNumberOfParallelWorld ( ) const
inline

Definition at line 154 of file G4RunManagerKernel.hh.

154{ return numberOfParallelWorld; }

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

◆ GetNumberOfStaticAllocators()

G4int G4RunManagerKernel::GetNumberOfStaticAllocators ( ) const
inline

Definition at line 161 of file G4RunManagerKernel.hh.

161{ return numberOfStaticAllocators; }

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

◆ GetPhysicsList()

G4VUserPhysicsList * G4RunManagerKernel::GetPhysicsList ( ) const
inline

Definition at line 157 of file G4RunManagerKernel.hh.

157{ return physicsList; }

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4RunManagerKernel::GetPrimaryTransformer ( ) const
inline

Definition at line 137 of file G4RunManagerKernel.hh.

138 {
139 return eventManager->GetPrimaryTransformer();
140 }
G4PrimaryTransformer * GetPrimaryTransformer() const

Referenced by RunInitialization().

◆ GetRunManagerKernel()

G4RunManagerKernel * G4RunManagerKernel::GetRunManagerKernel ( )
static

Definition at line 92 of file G4RunManagerKernel.cc.

93{
94 return fRunManagerKernel;
95}

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

◆ GetStackManager()

G4StackManager * G4RunManagerKernel::GetStackManager ( ) const
inline

Definition at line 128 of file G4RunManagerKernel.hh.

128{ return eventManager->GetStackManager(); }
G4StackManager * GetStackManager() const

◆ GetTrackingManager()

G4TrackingManager * G4RunManagerKernel::GetTrackingManager ( ) const
inline

Definition at line 129 of file G4RunManagerKernel.hh.

130 {
131 return eventManager->GetTrackingManager();
132 }
G4TrackingManager * GetTrackingManager() const

Referenced by G4VisManager::Disable().

◆ GetVersionString()

const G4String & G4RunManagerKernel::GetVersionString ( ) const
inline

Definition at line 142 of file G4RunManagerKernel.hh.

142{ return versionString; }

Referenced by G4RunManager::GetVersionString().

◆ InitializePhysics()

void G4RunManagerKernel::InitializePhysics ( )

Definition at line 554 of file G4RunManagerKernel.cc.

555{
557 G4ApplicationState currentState = stateManager->GetCurrentState();
558 if (currentState != G4State_Init) {
559 G4cout << "Current application state is " << stateManager->GetStateString(currentState)
560 << G4endl;
561 if (currentState != G4State_Idle && currentState != G4State_PreInit) {
562 G4Exception("G4RunManagerKernel::InitializePhysics", "InitializePhysicsIncorrectState",
563 FatalException, "Geant4 kernel is not Init state : Method ignored.");
564 return;
565 }
566
567 G4cout << "Warning : Geant4 kernel is not Init state : Assuming Init state." << G4endl;
568 stateManager->SetNewState(G4State_Init);
569 }
570
571 if (physicsList == nullptr) {
572 G4Exception("G4RunManagerKernel::InitializePhysics", "Run0012", FatalException,
573 "G4VUserPhysicsList is not defined");
574 return;
575 }
576
577 if (verboseLevel > 1) G4cout << "physicsList->Construct() start." << G4endl;
578 if (numberOfParallelWorld > 0) physicsList->UseCoupledTransportation();
579 physicsList->Construct();
580
581 if (verboseLevel > 1) G4cout << "physicsList->CheckParticleList() start." << G4endl;
582 physicsList->CheckParticleList();
583
584 // Cannot assume that SetCuts() and CheckRegions() are thread safe.
585 // We need to mutex (report from valgrind --tool=drd)
586 G4AutoLock l(&initphysicsmutex);
588 if (verboseLevel > 1) G4cout << "physicsList->setCut() start." << G4endl;
589 physicsList->SetCuts();
590 }
591 CheckRegions();
592 l.unlock();
593
594 physicsInitialized = true;
595
596#ifdef G4MULTITHREADED
597 G4UnitDefinition::GetUnitsTable().Synchronize();
598#endif
599
600 stateManager->SetNewState(currentState);
601 if (geometryInitialized && currentState != G4State_Idle) {
602 stateManager->SetNewState(G4State_Idle);
603 }
604}
void UseCoupledTransportation(G4bool vl=true)

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

◆ PhysicsHasBeenModified()

void G4RunManagerKernel::PhysicsHasBeenModified ( )
inline

Definition at line 125 of file G4RunManagerKernel.hh.

125{ physicsNeedsToBeReBuilt = true; }

Referenced by G4RunManager::PhysicsHasBeenModified().

◆ PropagateGenericIonID()

void G4RunManagerKernel::PropagateGenericIonID ( )
protected

Definition at line 660 of file G4RunManagerKernel.cc.

661{
663 if (gion != nullptr) {
664 G4int gionId = gion->GetParticleDefinitionID();
666 pItr->reset(false);
667 while ((*pItr)()) {
668 G4ParticleDefinition* particle = pItr->value();
669 if (particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
670 }
671 }
672}
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 683 of file G4RunManagerKernel.cc.

684{
687 return;
688 }
689
690 // We have to tweak the navigator's state in case a geometry has been
691 // modified between runs. By the following calls we ensure that navigator's
692 // state is reset properly. It is required the geometry to be closed
693 // and previous optimisations to be cleared.
694
696 if (verboseLevel > 1) G4cout << "Start closing geometry." << G4endl;
697
698 geomManager->OpenGeometry();
699 geomManager->CloseGeometry(geometryToBeOptimized, verboseLevel > 1);
700
702}
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)

Referenced by RunInitialization().

◆ RunInitialization()

G4bool G4RunManagerKernel::RunInitialization ( G4bool fakeRun = false)

Definition at line 607 of file G4RunManagerKernel.cc.

608{
610 G4ApplicationState currentState = stateManager->GetCurrentState();
611
612 if (!geometryInitialized) {
613 G4Exception("G4RunManagerKernel::RunInitialization", "Run0021", JustWarning,
614 "Geometry has not yet initialized : method ignored.");
615 return false;
616 }
617
618 if (!physicsInitialized) {
619 G4Exception("G4RunManagerKernel::RunInitialization", "Run0022", JustWarning,
620 "Physics has not yet initialized : method ignored.");
621 return false;
622 }
623
624 if (currentState != G4State_Idle) {
625 G4Exception("G4RunManagerKernel::RunInitialization", "Run0023", JustWarning,
626 "Geant4 kernel not in Idle state : method ignored.");
627 return false;
628 }
629
630 if (geometryNeedsToBeClosed) CheckRegularGeometry();
631
632 stateManager->SetNewState(G4State_Init);
635 UpdateRegion();
636 BuildPhysicsTables(fakeRun);
637
640 // CheckRegularGeometry();
641 // Notify the VisManager as well
644 if (pVVisManager != nullptr) pVVisManager->GeometryHasChanged();
645 }
646 }
647
649
650#ifdef G4MULTITHREADED
651 G4UnitDefinition::GetUnitsTable().Synchronize();
652#endif
653
654 stateManager->SetNewState(G4State_Idle);
655 stateManager->SetNewState(G4State_GeomClosed);
656 return true;
657}
@ 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 146 of file G4RunManagerKernel.hh.

147 {
148 if (geometryToBeOptimized != vl) {
149 geometryToBeOptimized = vl;
151 }
152 }

Referenced by G4RunManager::SetGeometryToBeOptimized().

◆ SetNumberOfParallelWorld()

void G4RunManagerKernel::SetNumberOfParallelWorld ( G4int i)
inline

Definition at line 155 of file G4RunManagerKernel.hh.

155{ numberOfParallelWorld = i; }

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

◆ SetPhysics()

void G4RunManagerKernel::SetPhysics ( G4VUserPhysicsList * uPhys)

Definition at line 490 of file G4RunManagerKernel.cc.

491{
492 physicsList = uPhys;
493
494 if (runManagerKernelType == workerRMK) return;
495
496 SetupPhysics();
497 if (verboseLevel > 2) G4ParticleTable::GetParticleTable()->DumpTable();
498 if (verboseLevel > 1) {
499 G4cout << "List of instantiated particles "
500 "============================================"
501 << G4endl;
503 for (G4int i = 0; i < nPtcl; ++i) {
505 G4cout << pd->GetParticleName() << " ";
506 if (i % 10 == 9) G4cout << G4endl;
507 }
508 G4cout << G4endl;
509 }
510}
void DumpTable(const G4String &particle_name="ALL")

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

◆ SetPrimaryTransformer()

void G4RunManagerKernel::SetPrimaryTransformer ( G4PrimaryTransformer * pt)
inline

Definition at line 133 of file G4RunManagerKernel.hh.

134 {
135 eventManager->SetPrimaryTransformer(pt);
136 }
void SetPrimaryTransformer(G4PrimaryTransformer *tf)

Referenced by G4RunManager::SetPrimaryTransformer().

◆ SetupDefaultRegion()

void G4RunManagerKernel::SetupDefaultRegion ( )
protected

Definition at line 283 of file G4RunManagerKernel.cc.

284{
285 if (runManagerKernelType == workerRMK) return;
286
287 // Remove old world logical volume from the default region, if exist
289 if (defaultRegion->GetNumberOfRootVolumes() > size_t(1)) {
290 G4Exception("G4RunManager::SetupDefaultRegion", "Run0005", FatalException,
291 "Default world region should have a unique logical volume.");
292 }
295 if (verboseLevel > 1)
296 G4cout << "Obsolete world logical volume is removed from the default region." << G4endl;
297 }
298}
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition G4Region.cc:342

Referenced by DefineWorldVolume().

◆ SetupPhysics()

void G4RunManagerKernel::SetupPhysics ( )
protected

Definition at line 513 of file G4RunManagerKernel.cc.

514{
516
517 physicsList->ConstructParticle();
518
519 // For sanity reason
522 if (gion != nullptr) {
524 }
526
528 pItr->reset();
529 while ((*pItr)()) {
530 G4ParticleDefinition* particle = pItr->value();
531 if (!(particle->IsGeneralIon())) particle->SetParticleDefinitionID();
532 }
533
534 if (gion != nullptr) {
535 G4int gionId = gion->GetParticleDefinitionID();
536 pItr->reset(false);
537 while ((*pItr)()) {
538 G4ParticleDefinition* particle = pItr->value();
539 if (particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
540 }
541 }
542#ifdef G4MULTITHREADED
543 G4UnitDefinition::GetUnitsTable().Synchronize();
544#endif
545}
static G4Geantino * GeantinoDefinition()
Definition G4Geantino.cc:76
static void ConstructParticle()
void InitializeLightIons()
G4IonTable * GetIonTable() const
void SetReadiness(G4bool val=true)
virtual void ConstructParticle()=0

Referenced by SetPhysics().

◆ SetupShadowProcess()

void G4RunManagerKernel::SetupShadowProcess ( ) const
protectedvirtual

Reimplemented in G4MTRunManagerKernel, G4TaskRunManagerKernel, G4WorkerRunManagerKernel, and G4WorkerTaskRunManagerKernel.

Definition at line 940 of file G4RunManagerKernel.cc.

941{
943 auto theParticleIterator = theParticleTable->GetIterator();
945 // loop on particles and get process manager from there list of processes
946 while ((*theParticleIterator)()) {
949 if (pm != nullptr) {
950 G4ProcessVector& procs = *(pm->GetProcessList());
951 for (G4int idx = 0; idx < (G4int)procs.size(); ++idx) {
952 const G4VProcess* masterP = procs[idx]->GetMasterProcess();
953 if (masterP == nullptr) {
954 // Process does not have an associated shadow master process
955 // We are in master mode or sequential
956 procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
957 }
958 }
959 }
960 }
961}
#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 144 of file G4RunManagerKernel.hh.

144{ verboseLevel = vl; }

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

◆ UpdateRegion()

void G4RunManagerKernel::UpdateRegion ( )

Definition at line 705 of file G4RunManagerKernel.cc.

706{
708 G4ApplicationState currentState = stateManager->GetCurrentState();
709 if (currentState != G4State_Init) {
710 G4Exception("G4RunManagerKernel::UpdateRegion", "Run0024", JustWarning,
711 "Geant4 kernel not in Init state : method ignored.");
712 return;
713 }
714
715 if (runManagerKernelType == workerRMK) return;
716
717 CheckRegions();
718
720
722}
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=nullptr)

Referenced by RunInitialization().

◆ WorkerDefineWorldVolume()

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

Definition at line 381 of file G4RunManagerKernel.cc.

383{
385 G4ApplicationState currentState = stateManager->GetCurrentState();
386 if (currentState != G4State_Init) {
387 if (currentState != G4State_Idle && currentState != G4State_PreInit) {
388 G4cout << "Current application state is " << stateManager->GetStateString(currentState)
389 << G4endl;
390 G4Exception("G4RunManagerKernel::DefineWorldVolume", "DefineWorldVolumeAtIncorrectState",
391 FatalException, "Geant4 kernel is not Init state : Method ignored.");
392 return;
393 }
394
395 stateManager->SetNewState(G4State_Init);
396 }
397
398 currentWorld = worldVol;
401 G4MTRunManager::masterWorlds_t masterWorlds = masterRM->GetMasterWorlds();
402 for (const auto& masterWorld : masterWorlds) {
403 if (masterWorld.first == 0) {
404 if (masterWorld.second != currentWorld) {
405 G4Exception("G4RunManagerKernel::WorkerDefineWorldVolume", "RUN3091", FatalException,
406 "Mass world is inconsistent");
407 }
408 transM->SetWorldForTracking(masterWorld.second);
409 }
410 else {
411 transM->RegisterWorld(masterWorld.second);
412 }
413 }
414
415 if (topologyIsChanged) geometryNeedsToBeClosed = true;
416
417 // Notify the VisManager as well
420 if (pVVisManager != nullptr) pVVisManager->GeometryHasChanged();
421 }
422
423 geometryInitialized = true;
424 stateManager->SetNewState(currentState);
425 if (physicsInitialized && currentState != G4State_Idle) {
426 stateManager->SetNewState(G4State_Idle);
427 }
428}
static G4MTRunManager * GetMasterRunManager()
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
static masterWorlds_t & GetMasterWorlds()
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ WorkerUpdateWorldVolume()

void G4RunManagerKernel::WorkerUpdateWorldVolume ( )

Definition at line 365 of file G4RunManagerKernel.cc.

366{
369 G4MTRunManager::masterWorlds_t masterWorlds = masterRM->GetMasterWorlds();
370 for (const auto& masterWorld : masterWorlds) {
371 G4VPhysicalVolume* wv = masterWorld.second;
372 G4VPhysicalVolume* pWorld =
374 if (pWorld == nullptr) {
375 transM->RegisterWorld(wv);
376 }
377 }
378}
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)

Referenced by G4WorkerRunManager::ConstructScoringWorlds().

Member Data Documentation

◆ defaultRegion

G4Region* G4RunManagerKernel::defaultRegion = nullptr
protected

◆ defaultRegionForParallelWorld

G4Region* G4RunManagerKernel::defaultRegionForParallelWorld = nullptr
protected

Definition at line 196 of file G4RunManagerKernel.hh.

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

◆ geometryNeedsToBeClosed

G4bool G4RunManagerKernel::geometryNeedsToBeClosed = true
protected

◆ runManagerKernelType


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