ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
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
#include <cassert>
9
10
// Infrastructure includes
11
#include "
AthenaBaseComps/AthMessaging.h
"
12
13
// Geant4 includes
14
#include "G4Timer.hh"
15
#include "G4UserEventAction.hh"
16
#include <G4UserRunAction.hh>
17
18
// Forward declarations
19
class
G4Event;
20
class
G4Run;
21
22
namespace
G4UA
23
{
24
42
class
G4SimTimer
:
public
G4UserEventAction,
public
G4UserRunAction,
public
AthMessaging
43
{
44
45
public
:
46
48
struct
Report
49
{
51
Report
();
52
53
// Total runtime
54
G4Timer
runtime
;
57
unsigned
int
nEvent
;
59
double
eventTime
;
61
double
eventTimeSquared
;
63
std::pair<double, double>
meanAndSigma
();
64
65
void
merge
(
const
Report
& rep){
66
// only one of the report instance (the master run action) will have a valid runtime
67
if
(rep.runtime.IsValid()){
68
assert(!
runtime
.IsValid());
69
runtime
= rep.runtime;
70
}
71
nEvent
+= rep.nEvent;
72
eventTime
+= rep.eventTime;
73
eventTimeSquared
+= rep.eventTimeSquared;
74
}
75
};
76
78
G4SimTimer
();
79
81
virtual
void
BeginOfRunAction
(
const
G4Run*
run
)
override
final
;
82
84
virtual
void
EndOfRunAction
(
const
G4Run*
run
)
override
final
;
85
87
virtual
void
BeginOfEventAction
(
const
G4Event* event)
override
final
;
88
90
virtual
void
EndOfEventAction
(
const
G4Event* event)
override
final
;
91
93
const
Report
&
getReport
()
const
94
{
return
m_results
; }
95
96
private
:
97
99
G4Timer
m_eventTimer
;
100
102
Report
m_results
;
103
105
bool
m_firstEvent
;
106
107
};
// class G4SimTimer
108
109
}
// namespace G4UA
110
111
#endif
// G4USERACTIONS_G4UA_G4SIMTIMER_H
AthMessaging.h
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
G4UA::G4SimTimer::EndOfRunAction
virtual void EndOfRunAction(const G4Run *run) override final
End timing this Geant4 run.
Definition
G4SimTimer.cxx:54
G4UA::G4SimTimer::m_eventTimer
G4Timer m_eventTimer
My private instance of an event timer.
Definition
G4SimTimer.h:99
G4UA::G4SimTimer::getReport
const Report & getReport() const
Retrieve my timing results.
Definition
G4SimTimer.h:93
G4UA::G4SimTimer::EndOfEventAction
virtual void EndOfEventAction(const G4Event *event) override final
Finish timing this Geant4 event.
Definition
G4SimTimer.cxx:73
G4UA::G4SimTimer::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *run) override final
Start timing this Geant4 run.
Definition
G4SimTimer.cxx:44
G4UA::G4SimTimer::m_results
Report m_results
My timing results.
Definition
G4SimTimer.h:102
G4UA::G4SimTimer::G4SimTimer
G4SimTimer()
Constructor.
Definition
G4SimTimer.cxx:36
G4UA::G4SimTimer::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *event) override final
Start timing this Geant4 event.
Definition
G4SimTimer.cxx:64
G4UA::G4SimTimer::m_firstEvent
bool m_firstEvent
Used to skip the first event.
Definition
G4SimTimer.h:105
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
G4UA::G4SimTimer::Report
Simple struct which holds timing results for an action instance.
Definition
G4SimTimer.h:49
G4UA::G4SimTimer::Report::meanAndSigma
std::pair< double, double > meanAndSigma()
Calculate the mean and sample std dev.
Definition
G4SimTimer.cxx:24
G4UA::G4SimTimer::Report::eventTime
double eventTime
Accumulated event time.
Definition
G4SimTimer.h:59
G4UA::G4SimTimer::Report::runtime
G4Timer runtime
Definition
G4SimTimer.h:54
G4UA::G4SimTimer::Report::Report
Report()
Initializes the variables.
Definition
G4SimTimer.cxx:17
G4UA::G4SimTimer::Report::nEvent
unsigned int nEvent
Number of timed G4 events (we skip the first).
Definition
G4SimTimer.h:57
G4UA::G4SimTimer::Report::eventTimeSquared
double eventTimeSquared
Accumulated squared event time.
Definition
G4SimTimer.h:61
G4UA::G4SimTimer::Report::merge
void merge(const Report &rep)
Definition
G4SimTimer.h:65
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0