11 #include "G4StateManager.hh"
12 #include "G4GeometryManager.hh"
13 #include "G4UserRunAction.hh"
15 #include "G4LogicalVolumeStore.hh"
16 #include "G4MTRunManagerKernel.hh"
18 #include "G4IonTable.hh"
19 #include "G4ParticleTable.hh"
20 #include "G4CascadeInterface.hh"
22 #include "GaudiKernel/ISvcLocator.h"
23 #include "GaudiKernel/Bootstrap.h"
25 G4AtlasMTRunManager::G4AtlasMTRunManager()
28 , m_detGeoSvc(
"DetectorGeometrySvc",
"G4AtlasMTRunManager")
29 , m_physListSvc(
"PhysicsListSvc",
"G4AtlasMTRunManager")
30 , m_fastSimTool(
"FastSimulationMasterTool")
36 static G4AtlasMTRunManager* thisManager =
nullptr;
37 if (!thisManager) { thisManager =
new G4AtlasMTRunManager; }
48 ConstructScoringWorlds();
51 if (m_quietMode) { SetVerboseLevel(0); }
55 GetMTMasterRunManagerKernel()->SetUpDecayChannels();
57 PrepareCommandsStack();
61 void G4AtlasMTRunManager::InitializeGeometry()
66 if (m_detGeoSvc.retrieve().isFailure()) {
69 description <<
"InitializeGeometry: Failed to retrieve IDetectorGeometrySvc.";
70 G4Exception(
"G4AtlasMTRunManager",
"CouldNotRetrieveDetGeoSvc",
76 SetUserInitialization( m_detGeoSvc->GetDetectorConstruction() );
78 G4RunManager::InitializeGeometry();
82 ATH_MSG_WARNING(
"User Detector not set!!! Geometry NOT initialized!!!");
86 void G4AtlasMTRunManager::InitializePhysics()
89 kernel->InitializePhysics();
93 physicsInitialized =
true;
96 if (m_physListSvc.retrieve().isFailure()) {
99 description <<
"InitializePhysics: Failed to retrieve IPhysicsListSvc.";
100 G4Exception(
"G4AtlasMTRunManager",
"CouldNotRetrievePLTool",
104 m_physListSvc->SetPhysicsOptions();
107 const std::string methodName =
"G4AtlasMTRunManager::InitializePhysics";
108 if(m_fastSimTool.retrieve().isFailure()) {
109 throw GaudiException(
"Could not retrieve FastSims master tool",
110 methodName, StatusCode::FAILURE);
112 if(m_fastSimTool->initializeFastSims().isFailure()) {
113 throw GaudiException(
"Failed to initialize FastSims for master thread",
114 methodName, StatusCode::FAILURE);
123 void G4AtlasMTRunManager::RunTermination()
126 CleanUpPreviousEvents();
127 previousEvents->clear();
129 if(userRunAction) { userRunAction->EndOfRunAction(currentRun); }
132 currentRun =
nullptr;
136 G4StateManager* stateManager = G4StateManager::GetStateManager();
137 stateManager->SetNewState(G4State_Idle);
140 G4GeometryManager::GetInstance()->OpenGeometry();
143 stateManager->GetStateString( stateManager->GetCurrentState() ) );
144 kernel->RunTermination();
147 userRunAction =
nullptr;
148 userEventAction =
nullptr;
149 userSteppingAction =
nullptr;
150 userStackingAction =
nullptr;
151 userTrackingAction =
nullptr;
153 userDetector =
nullptr;
154 userPrimaryGeneratorAction =
nullptr;
157 #endif // G4MULTITHREADED