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

#include <G4MTRunManagerKernel.hh>

Inheritance diagram for G4MTRunManagerKernel:
G4RunManagerKernel

Public Types

enum  RMKType { sequentialRMK , masterRMK , workerRMK }
 

Public Member Functions

void BroadcastAbortRun (G4bool softAbort)
 
void DefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=nullptr) const
 
 G4MTRunManagerKernel ()
 
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 SetUpDecayChannels ()
 
void SetVerboseLevel (G4int vl)
 
void UpdateRegion ()
 
void WorkerDefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
void WorkerUpdateWorldVolume ()
 
virtual ~G4MTRunManagerKernel ()
 

Static Public Member Functions

static G4RunManagerKernelGetRunManagerKernel ()
 
static G4WorkerThreadGetWorkerThread ()
 
static void StartThread (G4WorkerThread *context)
 

Protected Member Functions

void BuildPhysicsTables (G4bool fakeRun)
 
void CheckRegions ()
 
void PropagateGenericIonID ()
 
void ResetNavigator ()
 
void SetupDefaultRegion ()
 
void SetupPhysics ()
 
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
 
static std::vector< G4WorkerRunManager * > * workerRMvector = nullptr
 
static G4ThreadLocal G4WorkerThreadwThreadContext = nullptr
 

Detailed Description

Definition at line 66 of file G4MTRunManagerKernel.hh.

Member Enumeration Documentation

◆ RMKType

Enumerator
sequentialRMK 
masterRMK 
workerRMK 

Definition at line 176 of file G4RunManagerKernel.hh.

Constructor & Destructor Documentation

◆ G4MTRunManagerKernel()

G4MTRunManagerKernel::G4MTRunManagerKernel ( )

Definition at line 74 of file G4MTRunManagerKernel.cc.

76{
77 // This version of the constructor should never be called in sequential mode!
78#ifndef G4MULTITHREADED
80 msg << "Geant4 code is compiled without multi-threading support "
81 "(-DG4MULTITHREADED "
82 "is set to off).";
83 msg << " This type of RunManager can only be used in mult-threaded "
84 "applications.";
85 G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0109",
86 FatalException, msg);
87#endif
89 if(workerRMvector == nullptr)
90 workerRMvector = new std::vector<G4WorkerRunManager*>;
91 l.unlock();
92 // Set flag that a MT-type kernel has been instantiated
94}
@ 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 std::vector< G4WorkerRunManager * > * workerRMvector
void SetMultithreadedApplication(G4bool value)
Definition: G4Threading.cc:129

References FatalException, G4Exception(), G4Threading::SetMultithreadedApplication(), G4TemplateAutoLock< _Mutex_t >::unlock(), anonymous_namespace{G4MTRunManagerKernel.cc}::workerRMMutex, and workerRMvector.

◆ ~G4MTRunManagerKernel()

G4MTRunManagerKernel::~G4MTRunManagerKernel ( )
virtual

Definition at line 97 of file G4MTRunManagerKernel.cc.

98{
100 if(workerRMvector != nullptr)
101 {
102 if(workerRMvector->size() > 0)
103 {
105 msg << "G4MTRunManagerKernel is to be deleted while "
106 << workerRMvector->size() << " G4WorkerRunManager are still alive.";
107 G4Exception("G4RunManagerKernel::~G4RunManagerKernel()", "Run10035",
108 FatalException, msg);
109 }
110 delete workerRMvector;
111 workerRMvector = nullptr;
112 }
113}

References FatalException, G4Exception(), anonymous_namespace{G4MTRunManagerKernel.cc}::workerRMMutex, and workerRMvector.

Member Function Documentation

◆ BroadcastAbortRun()

void G4MTRunManagerKernel::BroadcastAbortRun ( G4bool  softAbort)

Definition at line 280 of file G4MTRunManagerKernel.cc.

281{
283
284 for(auto itr = workerRMvector->cbegin(); itr != workerRMvector->cend(); ++itr)
285 {
286 (*itr)->AbortRun(softAbort);
287 }
288}

References anonymous_namespace{G4MTRunManagerKernel.cc}::workerRMMutex, and workerRMvector.

Referenced by G4MTRunManager::AbortRun().

◆ BuildPhysicsTables()

void G4RunManagerKernel::BuildPhysicsTables ( G4bool  fakeRun)
protectedinherited

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}
static G4ProductionCutsTable * GetProductionCutsTable()
G4VUserPhysicsList * physicsList
void DumpRegion(const G4String &rname) const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void DumpCutValuesTable(G4int flag=1)

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

Referenced by G4RunManagerKernel::RunInitialization().

◆ CheckRegions()

void G4RunManagerKernel::CheckRegions ( )
protectedinherited

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}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetRegion(G4Region *reg)
G4Region * GetRegion() const
G4ProductionCuts * GetDefaultProductionCuts() const
static G4RegionStore * GetInstance()
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:414
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:398
G4bool IsInParallelGeometry() const
G4ProductionCuts * GetProductionCuts() const
void SetProductionCuts(G4ProductionCuts *cut)
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)
G4Region * defaultRegionForParallelWorld
G4VPhysicalVolume * currentWorld
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const

References G4Region::AddRootLogicalVolume(), G4Region::BelongsTo(), G4RunManagerKernel::currentWorld, G4RunManagerKernel::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 G4RunManagerKernel::verboseLevel.

Referenced by G4RunManagerKernel::InitializePhysics(), and G4RunManagerKernel::UpdateRegion().

◆ CheckRegularGeometry()

void G4RunManagerKernel::CheckRegularGeometry ( )
privateinherited

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 G4RunManagerKernel::SetScoreSplitter().

Referenced by G4RunManagerKernel::RunInitialization().

◆ ConfirmCoupledTransportation()

G4bool G4RunManagerKernel::ConfirmCoupledTransportation ( )
privateinherited

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
static G4ParticleTable * GetParticleTable()
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 
)
inherited

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
@ G4State_PreInit
const G4String & GetName() const
const G4ApplicationState & GetCurrentState() const
G4String GetStateString(const G4ApplicationState &aState) const
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)
void SetWorldForTracking(G4VPhysicalVolume *theWorld)
G4LogicalVolume * GetLogicalVolume() const
static G4VVisManager * GetConcreteInstance()
virtual void GeometryHasChanged()=0
G4bool IsMasterThread()
Definition: G4Threading.cc:124

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

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

◆ DumpRegion() [1/2]

void G4RunManagerKernel::DumpRegion ( const G4String rname) const
inherited

Definition at line 999 of file G4RunManagerKernel.cc.

1000{
1001 G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
1002 if(region != nullptr)
1003 DumpRegion(region);
1004}
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const

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

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

◆ DumpRegion() [2/2]

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

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 G4RunManagerKernel::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 ( )
inlineinherited

◆ GetCurrentWorld()

G4VPhysicalVolume * G4RunManagerKernel::GetCurrentWorld ( ) const
inlineinherited

Definition at line 169 of file G4RunManagerKernel.hh.

169{ return currentWorld; }

References G4RunManagerKernel::currentWorld.

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ GetEventManager()

G4EventManager * G4RunManagerKernel::GetEventManager ( ) const
inlineinherited

Definition at line 130 of file G4RunManagerKernel.hh.

130{ return eventManager; }
G4EventManager * eventManager

References G4RunManagerKernel::eventManager.

Referenced by G4RunManager::G4RunManager().

◆ GetNumberOfParallelWorld()

G4int G4RunManagerKernel::GetNumberOfParallelWorld ( ) const
inlineinherited

◆ GetNumberOfStaticAllocators()

G4int G4RunManagerKernel::GetNumberOfStaticAllocators ( ) const
inlineinherited

◆ GetPhysicsList()

G4VUserPhysicsList * G4RunManagerKernel::GetPhysicsList ( ) const
inlineinherited

Definition at line 167 of file G4RunManagerKernel.hh.

167{ return physicsList; }

References G4RunManagerKernel::physicsList.

◆ GetPrimaryTransformer()

G4PrimaryTransformer * G4RunManagerKernel::GetPrimaryTransformer ( ) const
inlineinherited

Definition at line 143 of file G4RunManagerKernel.hh.

144 {
146 }
G4PrimaryTransformer * GetPrimaryTransformer() const

References G4RunManagerKernel::eventManager, and G4EventManager::GetPrimaryTransformer().

Referenced by G4RunManagerKernel::RunInitialization().

◆ GetRunManagerKernel()

G4RunManagerKernel * G4RunManagerKernel::GetRunManagerKernel ( )
staticinherited

◆ GetStackManager()

G4StackManager * G4RunManagerKernel::GetStackManager ( ) const
inlineinherited

Definition at line 131 of file G4RunManagerKernel.hh.

132 {
134 }
G4StackManager * GetStackManager() const

References G4RunManagerKernel::eventManager, and G4EventManager::GetStackManager().

◆ GetTrackingManager()

G4TrackingManager * G4RunManagerKernel::GetTrackingManager ( ) const
inlineinherited

Definition at line 135 of file G4RunManagerKernel.hh.

136 {
138 }
G4TrackingManager * GetTrackingManager() const

References G4RunManagerKernel::eventManager, and G4EventManager::GetTrackingManager().

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

◆ GetVersionString()

const G4String & G4RunManagerKernel::GetVersionString ( ) const
inlineinherited

Definition at line 148 of file G4RunManagerKernel.hh.

148{ return versionString; }

References G4RunManagerKernel::versionString.

Referenced by G4RunManager::GetVersionString().

◆ GetWorkerThread()

G4WorkerThread * G4MTRunManagerKernel::GetWorkerThread ( )
static

Definition at line 124 of file G4MTRunManagerKernel.cc.

125{
126 return wThreadContext;
127}
static G4ThreadLocal G4WorkerThread * wThreadContext

References wThreadContext.

◆ InitializePhysics()

void G4RunManagerKernel::InitializePhysics ( )
inherited

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}
static G4UnitsTable & GetUnitsTable()
void UseCoupledTransportation(G4bool vl=true)

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

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

◆ PhysicsHasBeenModified()

void G4RunManagerKernel::PhysicsHasBeenModified ( )
inlineinherited

◆ PropagateGenericIonID()

void G4RunManagerKernel::PropagateGenericIonID ( )
protectedinherited

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}
int G4int
Definition: G4Types.hh:85
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 G4RunManagerKernel::RunInitialization().

◆ ResetNavigator()

void G4RunManagerKernel::ResetNavigator ( )
protectedinherited

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}
static G4GeometryManager * GetInstance()
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)

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

Referenced by G4RunManagerKernel::RunInitialization().

◆ RunInitialization()

G4bool G4RunManagerKernel::RunInitialization ( G4bool  fakeRun = false)
inherited

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 G4RunManagerKernel::BuildPhysicsTables(), G4RunManagerKernel::CheckRegularGeometry(), G4PrimaryTransformer::CheckUnknown(), G4Exception(), G4State_GeomClosed, G4State_Idle, G4State_Init, G4VVisManager::GeometryHasChanged(), G4RunManagerKernel::geometryInitialized, G4RunManagerKernel::geometryNeedsToBeClosed, G4VVisManager::GetConcreteInstance(), G4StateManager::GetCurrentState(), G4RunManagerKernel::GetPrimaryTransformer(), G4StateManager::GetStateManager(), G4UnitDefinition::GetUnitsTable(), G4Threading::IsMasterThread(), JustWarning, G4RunManagerKernel::physicsInitialized, G4RunManagerKernel::PropagateGenericIonID(), G4RunManagerKernel::ResetNavigator(), G4StateManager::SetNewState(), G4RunManagerKernel::SetupShadowProcess(), and G4RunManagerKernel::UpdateRegion().

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

◆ RunTermination()

void G4RunManagerKernel::RunTermination ( )
inherited

◆ SetGeometryToBeOptimized()

void G4RunManagerKernel::SetGeometryToBeOptimized ( G4bool  vl)
inlineinherited

◆ SetNumberOfParallelWorld()

void G4RunManagerKernel::SetNumberOfParallelWorld ( G4int  i)
inlineinherited

◆ SetPhysics()

void G4RunManagerKernel::SetPhysics ( G4VUserPhysicsList uPhys)
inherited

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}
const G4String & GetParticleName() const
G4ParticleDefinition * GetParticle(G4int index) const
G4int entries() const
void DumpTable(const G4String &particle_name="ALL")

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

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

◆ SetPrimaryTransformer()

void G4RunManagerKernel::SetPrimaryTransformer ( G4PrimaryTransformer pt)
inlineinherited

Definition at line 139 of file G4RunManagerKernel.hh.

140 {
142 }
void SetPrimaryTransformer(G4PrimaryTransformer *tf)

References G4RunManagerKernel::eventManager, and G4EventManager::SetPrimaryTransformer().

Referenced by G4RunManager::SetPrimaryTransformer().

◆ SetScoreSplitter()

void G4RunManagerKernel::SetScoreSplitter ( )
privateinherited

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 G4RunManagerKernel::verboseLevel.

Referenced by G4RunManagerKernel::CheckRegularGeometry().

◆ SetUpDecayChannels()

void G4MTRunManagerKernel::SetUpDecayChannels ( )

Definition at line 261 of file G4MTRunManagerKernel.cc.

262{
264 pItr->reset();
265 while((*pItr)())
266 {
267 G4DecayTable* dt = pItr->value()->GetDecayTable();
268 if(dt != nullptr)
269 {
270 G4int nCh = dt->entries();
271 for(G4int i = 0; i < nCh; ++i)
272 {
273 dt->GetDecayChannel(i)->GetDaughter(0);
274 }
275 }
276 }
277}
G4VDecayChannel * GetDecayChannel(G4int index) const
G4int entries() const
G4ParticleDefinition * GetDaughter(G4int anIndex)

References G4DecayTable::entries(), G4VDecayChannel::GetDaughter(), G4DecayTable::GetDecayChannel(), G4ParticleTable::GetIterator(), G4ParticleTable::GetParticleTable(), and G4ParticleTableIterator< K, V >::reset().

Referenced by G4MTRunManager::InitializeEventLoop().

◆ SetupDefaultRegion()

void G4RunManagerKernel::SetupDefaultRegion ( )
protectedinherited

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 G4RunManagerKernel::defaultRegion, FatalException, G4cout, G4endl, G4Exception(), G4Region::GetNumberOfRootVolumes(), G4Region::GetRootLogicalVolumeIterator(), G4Region::RemoveRootLogicalVolume(), G4RunManagerKernel::runManagerKernelType, G4RunManagerKernel::verboseLevel, and G4RunManagerKernel::workerRMK.

Referenced by G4RunManagerKernel::DefineWorldVolume().

◆ SetupPhysics()

void G4RunManagerKernel::SetupPhysics ( )
protectedinherited

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(), G4RunManagerKernel::physicsList, G4ParticleTableIterator< K, V >::reset(), G4ParticleDefinition::SetParticleDefinitionID(), and G4ParticleTable::SetReadiness().

Referenced by G4RunManagerKernel::SetPhysics().

◆ SetupShadowProcess()

void G4MTRunManagerKernel::SetupShadowProcess ( ) const
protectedvirtual

Reimplemented from G4RunManagerKernel.

Definition at line 116 of file G4MTRunManagerKernel.cc.

117{
118 // Behavior is the same as base class (sequential mode)
119 // ShadowProcess pointer == process poitner
121}

References G4RunManagerKernel::SetupShadowProcess().

◆ SetVerboseLevel()

void G4RunManagerKernel::SetVerboseLevel ( G4int  vl)
inlineinherited

◆ StartThread()

void G4MTRunManagerKernel::StartThread ( G4WorkerThread context)
static

!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! IMPORTANT !!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 130 of file G4MTRunManagerKernel.cc.

131{
135 // Here is not sequential anymore and G4UserWorkerThreadInitialization is
136 // a shared user initialization class.
137 // This means this method cannot use data members of G4RunManagerKernel
138 // unless they are invariant ("read-only") and can be safely shared.
139 // All the rest that is not invariant should be incapsulated into
140 // the context (or, as for wThreadContext be G4ThreadLocal)
142 //#ifdef G4MULTITHREADED
143 // turnontpmalloc();
144 //#endif
148
149 //============================
150 // Step-0: Thread ID
151 //============================
152 // Initialise per-thread stream-output
153 // The following line is needed before we actually do IO initialisation
154 // because the constructor of UI manager resets the IO destination.
155 G4int thisID = wThreadContext->GetThreadId();
158
159 //============================
160 // Optimization: optional
161 //============================
162 // Enforce thread affinity if requested
164
165 //============================
166 // Step-1: Random number engine
167 //============================
168 // RNG Engine needs to be initialised by "cloning" the master one.
169 const CLHEP::HepRandomEngine* masterEngine =
170 masterRM->getMasterRandomEngine();
171 masterRM->GetUserWorkerThreadInitialization()->SetupRNGEngine(masterEngine);
172
173 //============================
174 // Step-2: Initialise worker thread
175 //============================
176 if(masterRM->GetUserWorkerInitialization())
177 {
179 }
180 if(masterRM->GetUserActionInitialization())
181 {
184 if(sv != nullptr)
185 {
187 }
188 }
189 // Now initialise worker part of shared objects (geometry/physics)
191 G4WorkerRunManager* wrm =
195 workerRMvector->push_back(wrm);
196 wrmm.unlock();
197
198 //================================
199 // Step-3: Setup worker run manager
200 //================================
201 // Set the detector and physics list to the worker thread. Share with master
202 const G4VUserDetectorConstruction* detector =
203 masterRM->GetUserDetectorConstruction();
204 wrm->G4RunManager::SetUserInitialization(
205 const_cast<G4VUserDetectorConstruction*>(detector));
206 const G4VUserPhysicsList* physicslist = masterRM->GetUserPhysicsList();
207 wrm->SetUserInitialization(const_cast<G4VUserPhysicsList*>(physicslist));
208
209 //================================
210 // Step-4: Initialise worker run manager
211 //================================
212 if(masterRM->GetUserActionInitialization())
213 {
215 }
216 if(masterRM->GetUserWorkerInitialization())
217 {
219 }
220 wrm->Initialize();
221
222 //================================
223 // Step5: Loop over requests from the master thread
224 //================================
225 // This function should enter a loop processing new runs and actions
226 // requests from master. It should block until thread is ready
227 // to terminate
228 wrm->DoWork();
229
230 //===============================
231 // Step-6: Terminate worker thread
232 //===============================
233 if(masterRM->GetUserWorkerInitialization())
234 {
236 }
237
238 wrmm.lock();
239 for(auto itrWrm = workerRMvector->cbegin();
240 itrWrm != workerRMvector->cend(); ++itrWrm)
241 {
242 if((*itrWrm) == wrm)
243 {
244 workerRMvector->erase(itrWrm);
245 break;
246 }
247 }
248 wrmm.unlock();
249 delete wrm;
250
251 //===============================
252 // Step-7: Cleanup split classes
253 //===============================
255 wThreadContext = nullptr;
256
258}
G4int GetPinAffinity() const
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
static G4MTRunManager * GetMasterRunManager()
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
virtual void Initialize()
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
const G4VUserActionInitialization * GetUserActionInitialization() const
G4VUserActionInitialization * GetNonConstUserActionInitialization() const
const G4VUserPhysicsList * GetUserPhysicsList() const
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
void SetUpForAThread(G4int tId)
Definition: G4UImanager.cc:860
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const
virtual G4WorkerRunManager * CreateWorkerRunManager() const
static void SetInstance(G4VSteppingVerbose *Instance)
virtual void Build() const =0
virtual G4VSteppingVerbose * InitializeSteppingVerbose() const
void SetWorkerThread(G4WorkerThread *wc)
virtual void SetUserInitialization(G4VUserPhysicsList *userInit)
G4int GetThreadId() const
static void BuildGeometryAndPhysicsVector()
static void DestroyGeometryAndPhysicsVector()
void SetPinAffinity(G4int aff) const
G4int WorkerThreadJoinsPool()
Definition: G4Threading.cc:132
G4int WorkerThreadLeavesPool()
Definition: G4Threading.cc:131
void G4SetThreadId(G4int aNewValue)
Definition: G4Threading.cc:125
context
Definition: g4zmq.py:11

References G4VUserActionInitialization::Build(), G4WorkerThread::BuildGeometryAndPhysicsVector(), g4zmq::context, G4UserWorkerThreadInitialization::CreateWorkerRunManager(), G4WorkerThread::DestroyGeometryAndPhysicsVector(), G4WorkerRunManager::DoWork(), G4Threading::G4SetThreadId(), G4MTRunManager::getMasterRandomEngine(), G4MTRunManager::GetMasterRunManager(), G4RunManager::GetNonConstUserActionInitialization(), G4MTRunManager::GetPinAffinity(), G4WorkerThread::GetThreadId(), G4UImanager::GetUIpointer(), G4RunManager::GetUserActionInitialization(), G4RunManager::GetUserDetectorConstruction(), G4RunManager::GetUserPhysicsList(), G4RunManager::GetUserWorkerInitialization(), G4RunManager::GetUserWorkerThreadInitialization(), G4RunManager::Initialize(), G4VUserActionInitialization::InitializeSteppingVerbose(), G4TemplateAutoLock< _Mutex_t >::lock(), G4VSteppingVerbose::SetInstance(), G4WorkerThread::SetPinAffinity(), G4UImanager::SetUpForAThread(), G4UserWorkerThreadInitialization::SetupRNGEngine(), G4WorkerRunManager::SetUserInitialization(), G4WorkerRunManager::SetWorkerThread(), G4TemplateAutoLock< _Mutex_t >::unlock(), G4UserWorkerInitialization::WorkerInitialize(), anonymous_namespace{G4MTRunManagerKernel.cc}::workerRMMutex, workerRMvector, G4UserWorkerInitialization::WorkerStart(), G4UserWorkerInitialization::WorkerStop(), G4Threading::WorkerThreadJoinsPool(), G4Threading::WorkerThreadLeavesPool(), and wThreadContext.

◆ UpdateRegion()

void G4RunManagerKernel::UpdateRegion ( )
inherited

◆ WorkerDefineWorldVolume()

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

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}
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
static masterWorlds_t & GetMasterWorlds()
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)

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

Referenced by G4WorkerRunManager::InitializeGeometry().

◆ WorkerUpdateWorldVolume()

void G4RunManagerKernel::WorkerUpdateWorldVolume ( )
inherited

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
privateinherited

◆ defaultExceptionHandler

G4ExceptionHandler* G4RunManagerKernel::defaultExceptionHandler = nullptr
privateinherited

◆ defaultRegion

G4Region* G4RunManagerKernel::defaultRegion = nullptr
protectedinherited

◆ defaultRegionForParallelWorld

G4Region* G4RunManagerKernel::defaultRegionForParallelWorld = nullptr
protectedinherited

◆ eventManager

G4EventManager* G4RunManagerKernel::eventManager = nullptr
privateinherited

◆ fRunManagerKernel

G4ThreadLocal G4RunManagerKernel * G4RunManagerKernel::fRunManagerKernel = nullptr
staticprivateinherited

◆ geometryInitialized

G4bool G4RunManagerKernel::geometryInitialized = false
privateinherited

◆ geometryNeedsToBeClosed

G4bool G4RunManagerKernel::geometryNeedsToBeClosed = true
protectedinherited

◆ geometryToBeOptimized

G4bool G4RunManagerKernel::geometryToBeOptimized = true
privateinherited

◆ numberOfParallelWorld

G4int G4RunManagerKernel::numberOfParallelWorld = 0
privateinherited

◆ numberOfStaticAllocators

G4int G4RunManagerKernel::numberOfStaticAllocators = 0
privateinherited

◆ physicsInitialized

G4bool G4RunManagerKernel::physicsInitialized = false
privateinherited

◆ physicsList

G4VUserPhysicsList* G4RunManagerKernel::physicsList = nullptr
privateinherited

◆ physicsNeedsToBeReBuilt

G4bool G4RunManagerKernel::physicsNeedsToBeReBuilt = true
privateinherited

◆ runManagerKernelType

RMKType G4RunManagerKernel::runManagerKernelType
protectedinherited

◆ verboseLevel

G4int G4RunManagerKernel::verboseLevel = 0
privateinherited

◆ versionString

G4String G4RunManagerKernel::versionString = ""
privateinherited

◆ workerRMvector

std::vector< G4WorkerRunManager * > * G4MTRunManagerKernel::workerRMvector = nullptr
staticprivate

◆ wThreadContext

G4ThreadLocal G4WorkerThread * G4MTRunManagerKernel::wThreadContext = nullptr
staticprivate

Definition at line 93 of file G4MTRunManagerKernel.hh.

Referenced by GetWorkerThread(), and StartThread().


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