ATLAS Offline Software
Loading...
Searching...
No Matches
TestActionTimer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// $Id: TestActionTimer.h 660034 2015-04-10 17:20:49Z jchapman $ //
8// //
9// TestActionTimer //
10// Code for text output (into log file) //
11// of information about the time spent simulating //
12// various pieces of the detector and particles. //
13// //
14// Written by //
15// Zachary Marshall, Caltech, USA //
16// Wolfgang Ehrenfeld, University of Hamburg, Germany //
17// //
18// @version $Revision: 660034 $ //
19// //
21
22#ifndef TestActionTimer_H
23#define TestActionTimer_H
24
25
26#include <string>
27#include <vector>
28
29#include "G4String.hh"
30
31#include "G4UserEventAction.hh"
32#include "G4UserRunAction.hh"
33#include "G4UserSteppingAction.hh"
34
35// Forward declarations
36class G4Run;
37class G4Event;
38class G4Step;
39class G4Timer;
40class ITHistSvc;
41
42namespace G4UA
43{
44
51
53 public G4UserEventAction, public G4UserRunAction, public G4UserSteppingAction
54 {
55
56 public:
59
62
64 struct Report
65 {
66 int nev=0;
67 std::vector<double> time;
68 std::vector<std::string> timeName;
69 double runTime=0;
70 void merge(const Report& rep){
71 nev+=rep.nev;
72 runTime+=rep.runTime;
73 // copy first report
74 if(time.empty()){
75 time=rep.time;
76 timeName=rep.timeName;
77 return;
78 }
79 // sum the following ones
80 for(unsigned int i=0;i<time.size();++i)
81 time[i]+=rep.time[i];
82 }
83 };
84
85 const Report& getReport() const
86 { return m_report; }
87
88 virtual void BeginOfEventAction(const G4Event*) override;
89 virtual void EndOfEventAction(const G4Event*) override;
90 virtual void BeginOfRunAction(const G4Run*) override;
91 virtual void EndOfRunAction(const G4Run*) override;
92 virtual void UserSteppingAction(const G4Step*) override;
93
94 /* Enumeration for timers to be used
95 First timers are by subdetector, second few are by particle
96 These are not straightforward for the non-expert to interpret*/
100
101 private:
102
104
105 G4Timer* m_runTimer;
106 G4Timer* m_eventTimer;
107 double m_eventTime;
108
109 std::vector<G4Timer*> m_timer;
110
111 double TimerSum(G4Timer* timer) const;
112
113 void PPanic();
114 void VPanic();
115 int ClassifyVolume( G4String& ) const;
116
117 }; // class TestActionTimer
118
119} // namespace G4UA
120
121#endif // #define TestActionTimer_H
TestActionTimer & operator=(const TestActionTimer &)=delete
G4Timer * m_runTimer
Timer for the entire run.
const Report & getReport() const
int ClassifyVolume(G4String &) const
Method to sort out which volume we are in.
double TimerSum(G4Timer *timer) const
Gets the appropriate time from the timer for adding to the sum.
G4Timer * m_eventTimer
Timer for this event.
std::vector< G4Timer * > m_timer
Vector of timers for each of the enum.
virtual void UserSteppingAction(const G4Step *) override
virtual void EndOfRunAction(const G4Run *) override
double m_eventTime
Double for storing this event.
virtual void BeginOfRunAction(const G4Run *) override
virtual void EndOfEventAction(const G4Event *) override
virtual void BeginOfEventAction(const G4Event *) override
void PPanic()
Method to shut down all particle timers.
void VPanic()
Method to shut down all volume timers.
TestActionTimer(const TestActionTimer &)=delete
this holds all the data from individual threads that needs to be merged at EoR
std::vector< double > time
Vector of timers for each of the enum.
void merge(const Report &rep)
std::vector< std::string > timeName
Vector of names for each of the timers.