ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasAlg
src
G4AtlasRunManager.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
G4AtlasAlg/G4AtlasRunManager.h
"
6
7
8
#include "G4GeometryManager.hh"
9
#include "G4LogicalVolumeStore.hh"
10
#include "G4ParallelWorldScoringProcess.hh"
11
#include "G4RegionStore.hh"
12
#include "G4Run.hh"
13
#include "G4ScoringManager.hh"
14
#include "G4StateManager.hh"
15
#include "G4TransportationManager.hh"
16
#include "G4UImanager.hh"
17
#include "G4UserRunAction.hh"
18
#include "G4Version.hh"
19
20
#include <string>
21
22
G4AtlasRunManager::G4AtlasRunManager
()
23
: G4RunManager()
24
,
AthMessaging
(
"G4AtlasRunManager"
)
25
,
m_recordFlux
(false)
26
,
m_physListSvc
(
"PhysicsListSvc"
,
"G4AtlasRunManager"
)
27
,
m_volumeSmartlessLevel
({})
28
{ }
29
30
31
G4AtlasRunManager
* G4AtlasRunManager::GetG4AtlasRunManager
ATLAS_NOT_THREAD_SAFE
()
32
{
33
static
G4AtlasRunManager
*thisManager =
nullptr
;
34
if
(!thisManager) { thisManager =
new
G4AtlasRunManager
; }
// Leaked
35
return
thisManager;
36
}
37
38
39
void
G4AtlasRunManager::Initialize
()
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
}
47
48
void
G4AtlasRunManager::InitializeGeometry
()
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
}
63
64
65
void
G4AtlasRunManager::EndEvent
()
66
{
67
ATH_MSG_DEBUG
(
"G4AtlasRunManager::EndEvent"
);
68
}
69
70
71
void
G4AtlasRunManager::InitializePhysics
()
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
}
93
94
bool
G4AtlasRunManager::ProcessEvent
(G4Event* event)
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
}
117
118
void
G4AtlasRunManager::RunTermination
()
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
}
157
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ATLAS_NOT_THREAD_SAFE
G4AtlasRunManager *G4AtlasRunManager::GetG4AtlasRunManager ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition
G4AtlasRunManager.cxx:31
G4AtlasRunManager.h
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
G4AtlasRunManager
ATLAS custom singleton run manager.
Definition
G4AtlasRunManager.h:28
G4AtlasRunManager::InitializeGeometry
void InitializeGeometry() override final
Definition
G4AtlasRunManager.cxx:48
G4AtlasRunManager::EndEvent
void EndEvent()
Definition
G4AtlasRunManager.cxx:65
G4AtlasRunManager::ProcessEvent
bool ProcessEvent(G4Event *event)
Does the work of simulating an ATLAS event.
Definition
G4AtlasRunManager.cxx:94
G4AtlasRunManager::m_physListSvc
ServiceHandle< IPhysicsListSvc > m_physListSvc
Definition
G4AtlasRunManager.h:83
G4AtlasRunManager::m_volumeSmartlessLevel
std::map< std::string, double > m_volumeSmartlessLevel
Definition
G4AtlasRunManager.h:93
G4AtlasRunManager::m_detConstruction
IDetectorConstructionTool * m_detConstruction
Definition
G4AtlasRunManager.h:85
G4AtlasRunManager::RunTermination
void RunTermination() override final
G4 function called at end of run.
Definition
G4AtlasRunManager.cxx:118
G4AtlasRunManager::m_recordFlux
bool m_recordFlux
Definition
G4AtlasRunManager.h:81
G4AtlasRunManager::G4AtlasRunManager
G4AtlasRunManager()
Pure singleton private constructor.
Definition
G4AtlasRunManager.cxx:22
G4AtlasRunManager::m_quietMode
bool m_quietMode
Quiet Mode for production.
Definition
G4AtlasRunManager.h:96
G4AtlasRunManager::m_fluxRecorder
std::unique_ptr< IFluxRecorder > m_fluxRecorder
Interface to flux recording.
Definition
G4AtlasRunManager.h:89
G4AtlasRunManager::Initialize
void Initialize() override final
Definition
G4AtlasRunManager.cxx:39
G4AtlasRunManager::InitializePhysics
void InitializePhysics() override final
Definition
G4AtlasRunManager.cxx:71
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
Generated on
for ATLAS Offline Software by
1.17.0