ATLAS Offline Software
Loading...
Searching...
No Matches
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.
void RunTermination () override final
 G4 function called at end of run.
void SetDetConstructionTool (IDetectorConstructionTool *detConstruction)
 Configure the detector construction tool.
void SetPhysListSvc (const std::string &typeAndName)
 Configure the Physics List Tool handle.
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.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

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

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.
void EndEvent ()
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

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

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{ }
AthMessaging()
Default constructor:
ServiceHandle< IPhysicsListSvc > m_physListSvc
std::map< std::string, double > m_volumeSmartlessLevel

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

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}
#define ATH_MSG_DEBUG(x)

◆ 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
45 G4RunManager::Initialize();
46}
bool m_quietMode
Quiet Mode for production.

◆ 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(
54 m_detConstruction->GetDetectorConstruction().release());
55 if (userDetector) {
56 G4RunManager::InitializeGeometry();
57 }
58 else {
59 ATH_MSG_WARNING( " User Detector not set!!! Geometry NOT initialized!!!" );
60 }
61 return;
62}
#define ATH_MSG_WARNING(x)
IDetectorConstructionTool * m_detConstruction

◆ 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}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
std::unique_ptr< IFluxRecorder > m_fluxRecorder
Interface to flux recording.
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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}
#define ATH_MSG_VERBOSE(x)

◆ 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.

◆ 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.

85{nullptr};

◆ 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.

135{ nullptr };

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ 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.

96{true};

◆ 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: