ATLAS Offline Software
Loading...
Searching...
No Matches
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
7namespace G4UA
8{
9
10 //---------------------------------------------------------------------------
11 // Constructor
12 //---------------------------------------------------------------------------
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 //---------------------------------------------------------------------------
24 {
25 ATH_MSG_DEBUG( "Initializing " << name() );
26 return StatusCode::SUCCESS;
27 }
28
29 //---------------------------------------------------------------------------
30 // Merge results from all threads
31 //---------------------------------------------------------------------------
33 {
34 ATH_MSG_DEBUG( "Finalizing " << name() );
35
36 // Accumulate results across threads
37 G4SimTimer::Report report;
38 m_actions.accumulate(report, &G4SimTimer::getReport,
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>
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}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
G4SimTimerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode initialize() override
Initialize the tool.
virtual StatusCode finalize() override
Finalize and merge results from all worker threads.
virtual std::unique_ptr< G4SimTimer > makeAndFillAction(G4AtlasUserActions &) override final
Create aciton for this thread.
A user action for monitoring G4 runtime at event and run level.
Definition G4SimTimer.h:43
const Report & getReport() const
Retrieve my timing results.
Definition G4SimTimer.h:93
ThreadSpecificUserAction< G4SimTimer > m_actions
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Struct for passing around user actions.
std::vector< G4UserRunAction * > runActionsMaster
std::vector< G4UserEventAction * > eventActions
std::vector< G4UserRunAction * > runActions
Simple struct which holds timing results for an action instance.
Definition G4SimTimer.h:49
void merge(const Report &rep)
Definition G4SimTimer.h:65