ATLAS Offline Software
G4SimTimer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef G4USERACTIONS_G4UA_G4SIMTIMER_H
6 #define G4USERACTIONS_G4UA_G4SIMTIMER_H
7 
8 // Infrastructure includes
10 
11 // Geant4 includes
12 #include "G4Timer.hh"
13 #include "G4UserEventAction.hh"
14 
15 // Forward declarations
16 class G4Event;
17 class G4Run;
18 
19 namespace G4UA
20 {
21 
40  class G4SimTimer : public G4UserEventAction, public AthMessaging
41  {
42 
43  public:
44 
46  struct Report
47  {
49  Report();
52  unsigned int nEvent;
54  double eventTime;
58  std::pair<double, double> meanAndSigma();
59 
60  void merge(const Report& rep){
61  nEvent += rep.nEvent;
62  eventTime += rep.eventTime;
63  eventTimeSquared += rep.eventTimeSquared;
64  }
65  };
66 
68  G4SimTimer();
69 
71  virtual void BeginOfEventAction(const G4Event* event) override final;
72 
74  virtual void EndOfEventAction(const G4Event* event) override final;
75 
77  const Report& getReport() const
78  { return m_results; }
79 
80  private:
81 
83  G4Timer m_eventTimer;
84 
87 
90 
91  }; // class G4SimTimer
92 
93 } // namespace G4UA
94 
95 #endif // G4USERACTIONS_G4UA_G4SIMTIMER_H
G4UA::G4SimTimer::Report::eventTime
double eventTime
Accumulated event time.
Definition: G4SimTimer.h:54
G4UA::G4SimTimer::Report::eventTimeSquared
double eventTimeSquared
Accumulated squared event time.
Definition: G4SimTimer.h:56
G4UA::G4SimTimer::G4SimTimer
G4SimTimer()
Constructor.
Definition: G4SimTimer.cxx:35
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
make_hlt_rep.rep
rep
Definition: make_hlt_rep.py:32
G4UA::G4SimTimer::Report
Simple struct which holds timing results for an action instance.
Definition: G4SimTimer.h:47
G4UA::G4SimTimer::getReport
const Report & getReport() const
Retrieve my timing results.
Definition: G4SimTimer.h:77
G4UA::G4SimTimer::Report::nEvent
unsigned int nEvent
Number of timed G4 events (we skip the first).
Definition: G4SimTimer.h:52
G4UA::G4SimTimer::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *event) override final
Start timing this Geant4 event.
Definition: G4SimTimer.cxx:43
G4UA::G4SimTimer::Report::merge
void merge(const Report &rep)
Definition: G4SimTimer.h:60
G4UA::G4SimTimer::Report::meanAndSigma
std::pair< double, double > meanAndSigma()
Calculate the mean and sample std dev.
Definition: G4SimTimer.cxx:23
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
G4UA::G4SimTimer::m_eventTimer
G4Timer m_eventTimer
My private instance of an event timer.
Definition: G4SimTimer.h:83
G4UA::G4SimTimer
A user action for monitoring G4 runtime at event and run level.
Definition: G4SimTimer.h:41
G4UA::G4SimTimer::EndOfEventAction
virtual void EndOfEventAction(const G4Event *event) override final
Finish timing this Geant4 event.
Definition: G4SimTimer.cxx:52
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
G4UA::G4SimTimer::m_results
Report m_results
My timing results.
Definition: G4SimTimer.h:86
G4UA::G4SimTimer::m_firstEvent
bool m_firstEvent
Used to skip the first event.
Definition: G4SimTimer.h:89
AthMessaging.h
G4UA::G4SimTimer::Report::Report
Report()
Initializes the variables.
Definition: G4SimTimer.cxx:16