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 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...
 
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 22 of file G4AtlasRunManager.cxx.

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

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 65 of file G4AtlasRunManager.cxx.

66 {
67  ATH_MSG_DEBUG( "G4AtlasRunManager::EndEvent" );
68 }

◆ Initialize()

void G4AtlasRunManager::Initialize ( )
finaloverrideprotected

Definition at line 39 of file G4AtlasRunManager.cxx.

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

◆ InitializeGeometry()

void G4AtlasRunManager::InitializeGeometry ( )
finaloverrideprotected

Definition at line 48 of file G4AtlasRunManager.cxx.

49 {
50  ATH_MSG_DEBUG( "InitializeGeometry()" );
51 
52  // Create/assign detector construction
53  G4RunManager::SetUserInitialization(
55  if (userDetector) {
56  G4RunManager::InitializeGeometry();
57  }
58  else {
59  ATH_MSG_WARNING( " User Detector not set!!! Geometry NOT initialized!!!" );
60  }
61  return;
62 }

◆ InitializePhysics()

void G4AtlasRunManager::InitializePhysics ( )
finaloverrideprotected

Definition at line 71 of file G4AtlasRunManager.cxx.

72 {
73  ATH_MSG_INFO( "InitializePhysics()" );
74  kernel->InitializePhysics();
75  physicsInitialized = true;
76 
77  // Grab the physics list tool and set the extra options
78  if (m_physListSvc.retrieve().isFailure()) {
79  ATH_MSG_ERROR ( "Could not retrieve the physics list tool" );
80  G4ExceptionDescription description;
81  description << "InitializePhysics: Failed to retrieve IPhysicsListSvc.";
82  G4Exception("G4AtlasRunManager", "CouldNotRetrievePLTool", FatalException, description);
83  abort(); // to keep Coverity happy
84  }
85  m_physListSvc->SetPhysicsOptions();
86 
87  if (m_recordFlux) {
88  m_fluxRecorder->InitializeFluxRecording();
89  }
90 
91  return;
92 }

◆ 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 94 of file G4AtlasRunManager.cxx.

95 {
96 
97  G4StateManager* stateManager = G4StateManager::GetStateManager();
98  stateManager->SetNewState(G4State_GeomClosed);
99 
100  currentEvent = event;
101 
102  eventManager->ProcessOneEvent(currentEvent);
103  if (currentEvent->IsAborted()) {
104  ATH_MSG_WARNING( "G4AtlasRunManager::ProcessEvent: Event Aborted at Detector Simulation level" );
105  currentEvent = nullptr;
106  return true;
107  }
108 
109  if (m_recordFlux) { m_fluxRecorder->RecordFlux(currentEvent); }
110 
111  this->StackPreviousEvent(currentEvent);
112  bool abort = currentEvent->IsAborted();
113  currentEvent = nullptr;
114 
115  return abort;
116 }

◆ RunTermination()

void G4AtlasRunManager::RunTermination ( )
finaloverride

G4 function called at end of run.

Definition at line 118 of file G4AtlasRunManager.cxx.

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

◆ SetDetConstructionTool()

void G4AtlasRunManager::SetDetConstructionTool ( IDetectorConstructionTool detConstruction)
inline

Configure the detector construction tool.

Definition at line 44 of file G4AtlasRunManager.h.

44  {
45  m_detConstruction = detConstruction;
46  }

◆ 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 54 of file G4AtlasRunManager.h.

54 { /* Not implemented */ }

◆ SetPhysListSvc()

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

Configure the Physics List Tool handle.

Definition at line 49 of file G4AtlasRunManager.h.

49  {
50  m_physListSvc.setTypeAndName(typeAndName);
51  }

◆ SetQuietMode()

void G4AtlasRunManager::SetQuietMode ( bool  quietMode)
inline

Configure the QuietMode option.

Definition at line 61 of file G4AtlasRunManager.h.

61  {
62  m_quietMode = quietMode;
63  }

◆ SetRecordFlux()

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

Definition at line 53 of file G4AtlasRunManager.h.

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

◆ SetVolumeSmartlessLevel()

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

Definition at line 56 of file G4AtlasRunManager.h.

56  {
57  m_volumeSmartlessLevel = nameAndValue;
58  }

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 85 of file G4AtlasRunManager.h.

◆ m_fluxRecorder

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

Interface to flux recording.

Definition at line 89 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 83 of file G4AtlasRunManager.h.

◆ m_quietMode

bool G4AtlasRunManager::m_quietMode {true}
private

Quiet Mode for production.

Definition at line 96 of file G4AtlasRunManager.h.

◆ m_recordFlux

bool G4AtlasRunManager::m_recordFlux
private

Definition at line 81 of file G4AtlasRunManager.h.

◆ m_volumeSmartlessLevel

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

Definition at line 93 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:96
IDetectorConstructionTool::GetDetectorConstruction
virtual UPDetectorConstruction GetDetectorConstruction()=0
G4AtlasRunManager::m_physListSvc
ServiceHandle< IPhysicsListSvc > m_physListSvc
Definition: G4AtlasRunManager.h:83
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:85
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:89
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:93
G4AtlasRunManager::m_recordFlux
bool m_recordFlux
Definition: G4AtlasRunManager.h:81
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