ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
G4SimTimerTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
G4SimTimerTool.h
"
6
7
namespace
G4UA
8
{
9
10
//---------------------------------------------------------------------------
11
// Constructor
12
//---------------------------------------------------------------------------
13
G4SimTimerTool::G4SimTimerTool
(
const
std::string&
type
,
14
const
std::string& name,
15
const
IInterface* parent)
16
:
UserActionToolBase
<
G4SimTimer
>(
type
, name, parent)
17
{
18
}
19
20
//---------------------------------------------------------------------------
21
// Initialize - temporarily here for debugging
22
//---------------------------------------------------------------------------
23
StatusCode
G4SimTimerTool::initialize
()
24
{
25
ATH_MSG_DEBUG
(
"Initializing "
<< name() );
26
return
StatusCode::SUCCESS;
27
}
28
29
//---------------------------------------------------------------------------
30
// Merge results from all threads
31
//---------------------------------------------------------------------------
32
StatusCode
G4SimTimerTool::finalize
()
33
{
34
ATH_MSG_DEBUG
(
"Finalizing "
<< name() );
35
36
// Accumulate results across threads
37
G4SimTimer::Report
report;
38
m_actions
.accumulate(report, &
G4SimTimer::getReport
,
39
&
G4SimTimer::Report::merge
);
40
41
// Report the results
42
auto
meanSigma = report.meanAndSigma();
43
ATH_MSG_INFO
(
"======================================================================================="
);
44
ATH_MSG_INFO
(
" G4SimTimer"
);
45
ATH_MSG_INFO
(
"======================================================================================="
);
46
ATH_MSG_INFO
(
"Finalized timing results for "
<< report.nEvent <<
" events (not all events used)"
);
47
ATH_MSG_INFO
(
"Average time per event was "
<<
48
std::setprecision(4) << meanSigma.first <<
" +- "
<<
49
std::setprecision(4) << meanSigma.second);
50
ATH_MSG_INFO
(
"G4Run timer: "
<< std::setprecision(4) << report.runtime);
51
ATH_MSG_INFO
(
"======================================================================================="
);
52
return
StatusCode::SUCCESS;
53
}
54
55
//---------------------------------------------------------------------------
56
// Create the action on request
57
//---------------------------------------------------------------------------
58
std::unique_ptr<G4SimTimer>
59
G4SimTimerTool::makeAndFillAction
(
G4AtlasUserActions
& actionList)
60
{
61
ATH_MSG_DEBUG
(
"Making a G4SimTimer action"
);
62
auto
action = std::make_unique<G4SimTimer>();
63
actionList.
eventActions
.push_back( action.get() );
64
actionList.
runActionsMaster
.push_back(action.get());
65
// added to runActions for single-thread runs
66
actionList.
runActions
.push_back(action.get());
67
return
action;
68
}
69
70
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
G4SimTimerTool.h
G4UA::G4SimTimerTool::G4SimTimerTool
G4SimTimerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
G4SimTimerTool.cxx:13
G4UA::G4SimTimerTool::initialize
virtual StatusCode initialize() override
Initialize the tool.
Definition
G4SimTimerTool.cxx:23
G4UA::G4SimTimerTool::finalize
virtual StatusCode finalize() override
Finalize and merge results from all worker threads.
Definition
G4SimTimerTool.cxx:32
G4UA::G4SimTimerTool::makeAndFillAction
virtual std::unique_ptr< G4SimTimer > makeAndFillAction(G4AtlasUserActions &) override final
Create aciton for this thread.
Definition
G4SimTimerTool.cxx:59
G4UA::G4SimTimer
A user action for monitoring G4 runtime at event and run level.
Definition
G4SimTimer.h:43
G4UA::G4SimTimer::getReport
const Report & getReport() const
Retrieve my timing results.
Definition
G4SimTimer.h:93
G4UA::UserActionToolBase< G4SimTimer >::m_actions
ThreadSpecificUserAction< G4SimTimer > m_actions
Definition
UserActionToolBase.h:70
G4UA::UserActionToolBase< G4SimTimer >::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::runActionsMaster
std::vector< G4UserRunAction * > runActionsMaster
Definition
IUserActionTool.h:37
G4UA::G4AtlasUserActions::eventActions
std::vector< G4UserEventAction * > eventActions
Definition
IUserActionTool.h:39
G4UA::G4AtlasUserActions::runActions
std::vector< G4UserRunAction * > runActions
Definition
IUserActionTool.h:36
G4UA::G4SimTimer::Report
Simple struct which holds timing results for an action instance.
Definition
G4SimTimer.h:49
G4UA::G4SimTimer::Report::merge
void merge(const Report &rep)
Definition
G4SimTimer.h:65
type
Generated on
for ATLAS Offline Software by
1.17.0