ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
TestActionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Main header include
6
#include "
TestActionTool.h
"
7
8
// Geant4 includes
9
#include "G4ios.hh"
10
11
namespace
G4UA
12
{
13
14
//---------------------------------------------------------------------------
15
// TestAction constructor
16
//---------------------------------------------------------------------------
17
TestAction::TestAction
()
18
{}
19
20
//---------------------------------------------------------------------------
21
// Begin of G4 run method
22
//---------------------------------------------------------------------------
23
void
TestAction::BeginOfRunAction
(
const
G4Run*)
24
{
25
G4cout <<
"TestAction::BeginOfRunAction"
<< G4endl;
26
}
27
28
//---------------------------------------------------------------------------
29
// End of G4 run method
30
//---------------------------------------------------------------------------
31
void
TestAction::EndOfRunAction
(
const
G4Run*)
32
{
33
G4cout <<
"TestAction::EndOfRunAction - "
34
<<
m_report
.numEvent <<
" events processed, "
35
<<
m_report
.numStep <<
" steps processed"
36
<< G4endl;
37
}
38
39
//---------------------------------------------------------------------------
40
// Begin of G4 event method
41
//---------------------------------------------------------------------------
42
void
TestAction::BeginOfEventAction
(
const
G4Event*)
43
{
44
G4cout <<
"TestAction::BeginOfEventAction"
<< G4endl;
45
m_report
.numEvent++;
46
}
47
48
//---------------------------------------------------------------------------
49
// End of G4 event method
50
//---------------------------------------------------------------------------
51
void
TestAction::EndOfEventAction
(
const
G4Event*)
52
{
53
G4cout <<
"TestAction::EndOfEventAction"
<< G4endl;
54
}
55
56
//---------------------------------------------------------------------------
57
// G4 stepping method
58
//---------------------------------------------------------------------------
59
void
TestAction::UserSteppingAction
(
const
G4Step*)
60
{
61
m_report
.numStep++;
62
}
63
64
//---------------------------------------------------------------------------
65
// Constructor
66
//---------------------------------------------------------------------------
67
TestActionTool::TestActionTool
(
const
std::string&
type
,
68
const
std::string& name,
69
const
IInterface* parent)
70
:
UserActionToolBase
<
TestAction
>(
type
, name, parent)
71
{
72
}
73
74
//---------------------------------------------------------------------------
75
// Initialize the tool
76
//---------------------------------------------------------------------------
77
StatusCode
TestActionTool::initialize
()
78
{
79
ATH_MSG_INFO
(
"Initializing "
<< name() );
80
return
StatusCode::SUCCESS;
81
}
82
83
//---------------------------------------------------------------------------
84
// Finalize the tool
85
//---------------------------------------------------------------------------
86
StatusCode
TestActionTool::finalize
()
87
{
88
ATH_MSG_INFO
(
"Finalizing "
<< name() );
89
90
// Accumulate results across threads
91
TestAction::Report
results;
92
m_actions
.accumulate(results, &
TestAction::getReport
,
93
&
TestAction::Report::merge
);
94
ATH_MSG_INFO
(
"Final accumulated results: "
<<
95
results.numEvent <<
" events processed, "
<<
96
results.numStep <<
" steps processed"
);
97
98
return
StatusCode::SUCCESS;
99
}
100
101
//---------------------------------------------------------------------------
102
// Construct and fill the user action
103
//---------------------------------------------------------------------------
104
std::unique_ptr<TestAction>
105
TestActionTool::makeAndFillAction
(
G4AtlasUserActions
& actions)
106
{
107
ATH_MSG_INFO
(
"Constructing and filling a TestAction"
);
108
109
auto
action = std::make_unique<TestAction>();
110
actions.
runActions
.push_back( action.get() );
111
actions.
eventActions
.push_back( action.get() );
112
actions.
steppingActions
.push_back( action.get() );
113
return
action;
114
}
115
116
}
// namespace G4UA
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
TestActionTool.h
G4UA::TestActionTool::initialize
virtual StatusCode initialize() override final
Initialize the tool.
Definition
TestActionTool.cxx:77
G4UA::TestActionTool::TestActionTool
TestActionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
TestActionTool.cxx:67
G4UA::TestActionTool::finalize
virtual StatusCode finalize() override final
Finalize the tool.
Definition
TestActionTool.cxx:86
G4UA::TestActionTool::makeAndFillAction
virtual std::unique_ptr< TestAction > makeAndFillAction(G4AtlasUserActions &actions) override final
Fill user action.
Definition
TestActionTool.cxx:105
G4UA::TestAction
Definition
TestActionTool.h:30
G4UA::TestAction::getReport
const Report & getReport() const
Get the results report.
Definition
TestActionTool.h:64
G4UA::TestAction::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override final
Executes before the run.
Definition
TestActionTool.cxx:23
G4UA::TestAction::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override final
Executes at end of G4 event.
Definition
TestActionTool.cxx:51
G4UA::TestAction::TestAction
TestAction()
Constructor.
Definition
TestActionTool.cxx:17
G4UA::TestAction::UserSteppingAction
virtual void UserSteppingAction(const G4Step *step) override final
Stepping action method.
Definition
TestActionTool.cxx:59
G4UA::TestAction::EndOfRunAction
virtual void EndOfRunAction(const G4Run *) override final
Exeuctes after the run.
Definition
TestActionTool.cxx:31
G4UA::TestAction::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override final
Executes at beginning of G4 event.
Definition
TestActionTool.cxx:42
G4UA::TestAction::m_report
Report m_report
Results report.
Definition
TestActionTool.h:70
G4UA::UserActionToolBase< TestAction >::m_actions
ThreadSpecificUserAction< TestAction > m_actions
Definition
UserActionToolBase.h:70
G4UA::UserActionToolBase< TestAction >::UserActionToolBase
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
UserActionToolBase.h:40
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
G4UA::G4AtlasUserActions
Struct for passing around user actions.
Definition
IUserActionTool.h:35
G4UA::G4AtlasUserActions::steppingActions
std::vector< G4UserSteppingAction * > steppingActions
Definition
IUserActionTool.h:41
G4UA::G4AtlasUserActions::eventActions
std::vector< G4UserEventAction * > eventActions
Definition
IUserActionTool.h:39
G4UA::G4AtlasUserActions::runActions
std::vector< G4UserRunAction * > runActions
Definition
IUserActionTool.h:36
G4UA::TestAction::Report
Results to be accumulated across threads at end of job.
Definition
TestActionTool.h:36
G4UA::TestAction::Report::merge
void merge(const Report &other)
Definition
TestActionTool.h:39
type
Generated on
for ATLAS Offline Software by
1.17.0