Initialize the user actions for the current thread.
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;
97 G4AtlasUserActions actions;
104 ATH_MSG_ERROR(
"Run action already exists for current thread!");
105 return StatusCode::FAILURE;
107 auto runAction = std::make_unique<G4AtlasRunAction>();
109 for(
auto*
action : actions.runActions)
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>();
121 for(
auto*
action : actions.eventActions) {
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>();
136 for(
auto*
action : actions.stackingActions) {
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>();
151 for(
auto*
action : actions.trackingActions) {
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>();
166 for(
auto*
action : actions.steppingActions) {
167 stepAction->addAction(
action);
169 action->SetSteppingManagerPointer( G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager() );
171 G4RunManager::GetRunManager()->SetUserAction( stepAction.get() );
174 return StatusCode::SUCCESS;