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("Finalized timing results for " << report.nEvent <<
44 " events (not all events used)");
45 ATH_MSG_INFO("Average time per event was " <<
46 std::setprecision(4) << meanSigma.first << " +- " <<
47 std::setprecision(4) << meanSigma.second);
48 return StatusCode::SUCCESS;
49 }
50
51 //---------------------------------------------------------------------------
52 // Create the action on request
53 //---------------------------------------------------------------------------
54 std::unique_ptr<G4SimTimer>
56 {
57 ATH_MSG_DEBUG("Making a G4SimTimer action");
58 auto action = std::make_unique<G4SimTimer>();
59 actionList.eventActions.push_back( action.get() );
60 return action;
61 }
62
63}
#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:41
const Report & getReport() const
Retrieve my timing results.
Definition G4SimTimer.h:77
ThreadSpecificUserAction< G4SimTimer > m_actions
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Struct for passing around user actions.
std::vector< G4UserEventAction * > eventActions
Simple struct which holds timing results for an action instance.
Definition G4SimTimer.h:47
void merge(const Report &rep)
Definition G4SimTimer.h:60