10 #include "G4RunManager.hh"
24 ISvcLocator* pSvcLocator)
25 : base_class(
name, pSvcLocator)
26 , m_userActionTools(this)
44 return StatusCode::SUCCESS;
48 if (!service_tool.isPublic()){
50 return StatusCode::FAILURE;
52 if (service_tool.empty()) {
54 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
73 std::lock_guard<std::mutex> userActionLock(userActionMutex);
85 if( G4RunManager::GetRunManager()->GetUserRunAction() ||
86 G4RunManager::GetRunManager()->GetUserEventAction() ||
87 G4RunManager::GetRunManager()->GetUserStackingAction() ||
88 G4RunManager::GetRunManager()->GetUserTrackingAction() ||
89 G4RunManager::GetRunManager()->GetUserSteppingAction() )
91 ATH_MSG_FATAL(
"UserActionSvc has found that actions were already " <<
92 "registered to the G4RunManager. Check your code/configuration");
93 return StatusCode::FAILURE;
104 ATH_MSG_ERROR(
"Run action already exists for current thread!");
105 return StatusCode::FAILURE;
107 auto runAction = std::make_unique<G4AtlasRunAction>();
110 runAction->addRunAction(
action);
111 G4RunManager::GetRunManager()->SetUserAction( runAction.get() );
116 ATH_MSG_ERROR(
"Event action already exists for current thread!");
117 return StatusCode::FAILURE;
119 auto eventAction = std::make_unique<G4AtlasEventAction>();
122 eventAction->addEventAction(
action);
124 action->SetEventManager( G4EventManager::GetEventManager() );
126 G4RunManager::GetRunManager()->SetUserAction( eventAction.get() );
131 ATH_MSG_ERROR(
"Stacking action already exists for current thread!");
132 return StatusCode::FAILURE;
134 auto stackAction = std::make_unique<G4AtlasStackingAction>();
137 stackAction->addAction(
action);
139 action->SetStackManager( G4EventManager::GetEventManager()->GetStackManager() );
141 G4RunManager::GetRunManager()->SetUserAction( stackAction.get() );
146 ATH_MSG_ERROR(
"Tracking action already exists for current thread!");
147 return StatusCode::FAILURE;
149 auto trackAction = std::make_unique<G4AtlasTrackingAction>();
152 trackAction->addTrackAction(
action);
154 action->SetTrackingManagerPointer ( G4EventManager::GetEventManager()->GetTrackingManager() );
156 G4RunManager::GetRunManager()->SetUserAction( trackAction.get() );
161 ATH_MSG_ERROR(
"Stepping action already exists for current thread!");
162 return StatusCode::FAILURE;
164 auto stepAction = std::make_unique<G4AtlasSteppingAction>();
167 stepAction->addAction(
action);
169 action->SetSteppingManagerPointer( G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager() );
171 G4RunManager::GetRunManager()->SetUserAction( stepAction.get() );
174 return StatusCode::SUCCESS;
183 return StatusCode::SUCCESS;