ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
G4AtlasRunManager Class Reference

ATLAS custom singleton run manager. More...

#include <G4AtlasRunManager.h>

Inheritance diagram for G4AtlasRunManager:
Collaboration diagram for G4AtlasRunManager:

Public Member Functions

virtual ~G4AtlasRunManager ()
 
bool ProcessEvent (G4Event *event)
 Does the work of simulating an ATLAS event. More...
 
void RunInitialization () override final
 G4 function called at start of run. More...
 
void RunTermination () override final
 G4 function called at end of run. More...
 
void SetDetConstructionTool (IDetectorConstructionTool *detConstruction)
 Configure the detector construction tool. More...
 
void SetPhysListSvc (const std::string &typeAndName)
 Configure the Physics List Tool handle. More...
 
void SetRecordFlux (bool b, std::unique_ptr< IFluxRecorder > f)
 
void SetLogLevel (int)
 
void SetVolumeSmartlessLevel (const std::map< std::string, double > &nameAndValue)
 
void SetQuietMode (bool quietMode)
 Configure the QuietMode option. More...
 
void SetUserInitialization (G4UserWorkerInitialization *userInit) override
 Allow user worker initialization for single-threaded runmanager. More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Static Public Member Functions

static G4AtlasRunManager *GetG4AtlasRunManager ATLAS_NOT_THREAD_SAFE ()
 Retrieve the singleton instance. More...
 

Protected Member Functions

Overridden G4 init methods for customization
void Initialize () override final
 
void InitializeGeometry () override final
 
void InitializePhysics () override final
 

Private Member Functions

 G4AtlasRunManager ()
 Pure singleton private constructor. More...
 
void EndEvent ()
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

bool m_recordFlux
 
ServiceHandle< IPhysicsListSvcm_physListSvc
 
IDetectorConstructionToolm_detConstruction {nullptr}
 
std::unique_ptr< IFluxRecorderm_fluxRecorder
 Interface to flux recording. More...
 
std::map< std::string, double > m_volumeSmartlessLevel
 
bool m_quietMode {true}
 Quiet Mode for production. More...
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

ATLAS custom singleton run manager.

This is the run manager used for serial (not-MT) jobs.

Todo:
sync and reduce code duplication with MT run managers.

Definition at line 28 of file G4AtlasRunManager.h.

Constructor & Destructor Documentation

◆ ~G4AtlasRunManager()

virtual G4AtlasRunManager::~G4AtlasRunManager ( )
inlinevirtual

Definition at line 32 of file G4AtlasRunManager.h.

32 {}

◆ G4AtlasRunManager()

G4AtlasRunManager::G4AtlasRunManager ( )
private

Pure singleton private constructor.

Definition at line 24 of file G4AtlasRunManager.cxx.

25  : G4RunManager()
26  , AthMessaging("G4AtlasRunManager")
27  , m_recordFlux(false)
28  , m_physListSvc("PhysicsListSvc", "G4AtlasRunManager")
30 { }

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

static G4AtlasRunManager* GetG4AtlasRunManager G4AtlasRunManager::ATLAS_NOT_THREAD_SAFE ( )
static

Retrieve the singleton instance.

◆ EndEvent()

void G4AtlasRunManager::EndEvent ( )
private

Definition at line 75 of file G4AtlasRunManager.cxx.

76 {
77  ATH_MSG_DEBUG( "G4AtlasRunManager::EndEvent" );
78 }

◆ Initialize()

void G4AtlasRunManager::Initialize ( )
finaloverrideprotected

Definition at line 41 of file G4AtlasRunManager.cxx.

42 {
43  // ADA 11/28.2018: switch initialization order to meet ISF requirements
44  // Call the base class Initialize method. This will call
45  // InitializeGeometry and InitializePhysics.
46  if (m_quietMode) { SetVerboseLevel(0); } // HACK
48 }

◆ InitializeGeometry()

void G4AtlasRunManager::InitializeGeometry ( )
finaloverrideprotected

Definition at line 58 of file G4AtlasRunManager.cxx.

59 {
60  ATH_MSG_DEBUG( "InitializeGeometry()" );
61 
62  // Create/assign detector construction
63  G4RunManager::SetUserInitialization(
65  if (userDetector) {
66  G4RunManager::InitializeGeometry();
67  }
68  else {
69  ATH_MSG_WARNING( " User Detector not set!!! Geometry NOT initialized!!!" );
70  }
71  return;
72 }

◆ InitializePhysics()

void G4AtlasRunManager::InitializePhysics ( )
finaloverrideprotected

Definition at line 81 of file G4AtlasRunManager.cxx.

82 {
83  ATH_MSG_INFO( "InitializePhysics()" );
84  kernel->InitializePhysics();
85  physicsInitialized = true;
86 
87  // Grab the physics list tool and set the extra options
88  if (m_physListSvc.retrieve().isFailure()) {
89  ATH_MSG_ERROR ( "Could not retrieve the physics list tool" );
90  G4ExceptionDescription description;
91  description << "InitializePhysics: Failed to retrieve IPhysicsListSvc.";
92  G4Exception("G4AtlasRunManager", "CouldNotRetrievePLTool", FatalException, description);
93  abort(); // to keep Coverity happy
94  }
95  m_physListSvc->SetPhysicsOptions();
96 
97  if (m_recordFlux) {
98  m_fluxRecorder->InitializeFluxRecording();
99  }
100 
101  return;
102 }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ ProcessEvent()

bool G4AtlasRunManager::ProcessEvent ( G4Event *  event)

Does the work of simulating an ATLAS event.

Definition at line 104 of file G4AtlasRunManager.cxx.

105 {
106 
107  G4StateManager* stateManager = G4StateManager::GetStateManager();
108  stateManager->SetNewState(G4State_GeomClosed);
109 
110  currentEvent = event;
111 
112  eventManager->ProcessOneEvent(currentEvent);
113  if (currentEvent->IsAborted()) {
114  ATH_MSG_WARNING( "G4AtlasRunManager::ProcessEvent: Event Aborted at Detector Simulation level" );
115  currentEvent = nullptr;
116  return true;
117  }
118 
119  if (m_recordFlux) { m_fluxRecorder->RecordFlux(currentEvent); }
120 
121  this->StackPreviousEvent(currentEvent);
122  bool abort = currentEvent->IsAborted();
123  currentEvent = nullptr;
124 
125  return abort;
126 }

◆ RunInitialization()

void G4AtlasRunManager::RunInitialization ( )
finaloverride

G4 function called at start of run.

Definition at line 50 of file G4AtlasRunManager.cxx.

51 {
52  G4RunManager::RunInitialization();
53  if(auto* uwi = GetUserWorkerInitialization()) {
54  uwi->WorkerRunStart();
55  }
56 }

◆ RunTermination()

void G4AtlasRunManager::RunTermination ( )
finaloverride

G4 function called at end of run.

Definition at line 128 of file G4AtlasRunManager.cxx.

129 {
130  ATH_MSG_DEBUG( " G4AtlasRunManager::RunTermination() " );
131  if (m_recordFlux) {
132  m_fluxRecorder->WriteFluxInformation();
133  }
134 
135  this->CleanUpPreviousEvents();
136  previousEvents->clear();
137 
138  if (userRunAction) {
139  userRunAction->EndOfRunAction(currentRun);
140  }
141 
142  delete currentRun;
143  currentRun = nullptr;
144  runIDCounter++;
145 
146  ATH_MSG_VERBOSE( "Changing the state..." );
147  G4StateManager* stateManager = G4StateManager::GetStateManager();
148  stateManager->SetNewState(G4State_Idle);
149 
150  ATH_MSG_VERBOSE( "Opening the geometry back up" );
151  G4GeometryManager::GetInstance()->OpenGeometry();
152 
153  ATH_MSG_VERBOSE( "Terminating the run... State is " << stateManager->GetStateString( stateManager->GetCurrentState() ) );
154  kernel->RunTermination();
155  ATH_MSG_VERBOSE( "All done..." );
156 
157  userRunAction = nullptr;
158  userEventAction = nullptr;
159  userSteppingAction = nullptr;
160  userStackingAction = nullptr;
161  userTrackingAction = nullptr;
162  userDetector = nullptr;
163  userPrimaryGeneratorAction = nullptr;
164 
165  return;
166 }

◆ SetDetConstructionTool()

void G4AtlasRunManager::SetDetConstructionTool ( IDetectorConstructionTool detConstruction)
inline

Configure the detector construction tool.

Definition at line 47 of file G4AtlasRunManager.h.

47  {
48  m_detConstruction = detConstruction;
49  }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ SetLogLevel()

void G4AtlasRunManager::SetLogLevel ( int  )
inline

Definition at line 57 of file G4AtlasRunManager.h.

57 { /* Not implemented */ }

◆ SetPhysListSvc()

void G4AtlasRunManager::SetPhysListSvc ( const std::string &  typeAndName)
inline

Configure the Physics List Tool handle.

Definition at line 52 of file G4AtlasRunManager.h.

52  {
53  m_physListSvc.setTypeAndName(typeAndName);
54  }

◆ SetQuietMode()

void G4AtlasRunManager::SetQuietMode ( bool  quietMode)
inline

Configure the QuietMode option.

Definition at line 64 of file G4AtlasRunManager.h.

64  {
65  m_quietMode = quietMode;
66  }

◆ SetRecordFlux()

void G4AtlasRunManager::SetRecordFlux ( bool  b,
std::unique_ptr< IFluxRecorder f 
)
inline

Definition at line 56 of file G4AtlasRunManager.h.

56 { m_recordFlux = b; m_fluxRecorder=std::move(f);}

◆ SetUserInitialization()

void G4AtlasRunManager::SetUserInitialization ( G4UserWorkerInitialization *  userInit)
inlineoverride

Allow user worker initialization for single-threaded runmanager.

Definition at line 72 of file G4AtlasRunManager.h.

72  {
73  userWorkerInitialization = userInit;
74  }

◆ SetVolumeSmartlessLevel()

void G4AtlasRunManager::SetVolumeSmartlessLevel ( const std::map< std::string, double > &  nameAndValue)
inline

Definition at line 59 of file G4AtlasRunManager.h.

59  {
60  m_volumeSmartlessLevel = nameAndValue;
61  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_detConstruction

IDetectorConstructionTool* G4AtlasRunManager::m_detConstruction {nullptr}
private

Definition at line 96 of file G4AtlasRunManager.h.

◆ m_fluxRecorder

std::unique_ptr<IFluxRecorder> G4AtlasRunManager::m_fluxRecorder
private

Interface to flux recording.

Definition at line 100 of file G4AtlasRunManager.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_physListSvc

ServiceHandle<IPhysicsListSvc> G4AtlasRunManager::m_physListSvc
private

Definition at line 94 of file G4AtlasRunManager.h.

◆ m_quietMode

bool G4AtlasRunManager::m_quietMode {true}
private

Quiet Mode for production.

Definition at line 107 of file G4AtlasRunManager.h.

◆ m_recordFlux

bool G4AtlasRunManager::m_recordFlux
private

Definition at line 92 of file G4AtlasRunManager.h.

◆ m_volumeSmartlessLevel

std::map<std::string, double> G4AtlasRunManager::m_volumeSmartlessLevel
private

Definition at line 104 of file G4AtlasRunManager.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4AtlasRunManager::m_quietMode
bool m_quietMode
Quiet Mode for production.
Definition: G4AtlasRunManager.h:107
IDetectorConstructionTool::GetDetectorConstruction
virtual UPDetectorConstruction GetDetectorConstruction()=0
G4AtlasRunManager::m_physListSvc
ServiceHandle< IPhysicsListSvc > m_physListSvc
Definition: G4AtlasRunManager.h:94
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
G4AtlasRunManager::m_detConstruction
IDetectorConstructionTool * m_detConstruction
Definition: G4AtlasRunManager.h:96
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
G4AtlasRunManager::m_fluxRecorder
std::unique_ptr< IFluxRecorder > m_fluxRecorder
Interface to flux recording.
Definition: G4AtlasRunManager.h:100
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
G4AtlasRunManager::m_volumeSmartlessLevel
std::map< std::string, double > m_volumeSmartlessLevel
Definition: G4AtlasRunManager.h:104
G4AtlasRunManager::m_recordFlux
bool m_recordFlux
Definition: G4AtlasRunManager.h:92
hist_file_dump.f
f
Definition: hist_file_dump.py:140
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
jobOptions.Initialize
Initialize
Definition: jobOptions.pA.py:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
python.SystemOfUnits.ms
float ms
Definition: SystemOfUnits.py:148