ATLAS Offline Software
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
36 class G4Run;
37 class G4Event;
38 class G4Step;
39 class G4Timer;
40 class ITHistSvc;
41 
42 namespace G4UA
43 {
44 
51 
53  public G4UserEventAction, public G4UserRunAction, public G4UserSteppingAction
54  {
55 
56  public:
59 
60  TestActionTimer(const TestActionTimer&) = delete;
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
G4UA::TestActionTimer::Report::time
std::vector< double > time
Vector of timers for each of the enum.
Definition: TestActionTimer.h:67
G4UA::TestActionTimer::TimerSum
double TimerSum(G4Timer *timer) const
Gets the appropriate time from the timer for adding to the sum.
Definition: TestActionTimer.cxx:224
G4UA::TestActionTimer::PPanic
void PPanic()
Method to shut down all particle timers.
Definition: TestActionTimer.cxx:231
G4UA::TestActionTimer
User action to measure time spent in subdetectors.
Definition: TestActionTimer.h:54
G4UA::TestActionTimer::eITkStrip
@ eITkStrip
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::eEMEC
@ eEMEC
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::m_report
Report m_report
Definition: TestActionTimer.h:103
G4UA::TestActionTimer::Report::nev
int nev
Definition: TestActionTimer.h:66
G4UA::TestActionTimer::eMax
@ eMax
Definition: TestActionTimer.h:99
G4UA::TestActionTimer::m_runTimer
G4Timer * m_runTimer
Timer for the entire run.
Definition: TestActionTimer.h:105
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
G4UA::TestActionTimer::Report::merge
void merge(const Report &rep)
Definition: TestActionTimer.h:70
G4UA::TestActionTimer::operator=
TestActionTimer & operator=(const TestActionTimer &)=delete
G4UA::TestActionTimer::m_timer
std::vector< G4Timer * > m_timer
Vector of timers for each of the enum.
Definition: TestActionTimer.h:109
G4UA::TestActionTimer::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition: TestActionTimer.cxx:159
G4UA::TestActionTimer::eOther
@ eOther
Definition: TestActionTimer.h:98
make_hlt_rep.rep
rep
Definition: make_hlt_rep.py:32
G4UA::TestActionTimer::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition: TestActionTimer.cxx:136
G4UA::TestActionTimer::ePx
@ ePx
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::eTrt
@ eTrt
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::eSct
@ eSct
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::TestActionTimer
TestActionTimer(const TestActionTimer &)=delete
G4UA::TestActionTimer::ePre
@ ePre
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::ePos
@ ePos
Definition: TestActionTimer.h:99
G4UA::TestActionTimer::EndOfRunAction
virtual void EndOfRunAction(const G4Run *) override
Definition: TestActionTimer.cxx:151
G4UA::TestActionTimer::eSev
@ eSev
Definition: TestActionTimer.h:98
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
G4UA::TestActionTimer::m_eventTimer
G4Timer * m_eventTimer
Timer for this event.
Definition: TestActionTimer.h:106
G4UA::TestActionTimer::eMu
@ eMu
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::eFC1
@ eFC1
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::eElec
@ eElec
Definition: TestActionTimer.h:99
G4UA::TestActionTimer::eGam
@ eGam
Definition: TestActionTimer.h:99
G4UA::TestActionTimer::eCry
@ eCry
Definition: TestActionTimer.h:97
lumiFormat.i
int i
Definition: lumiFormat.py:85
G4UA::TestActionTimer::eHEC
@ eHEC
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::eFCO
@ eFCO
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::getReport
const Report & getReport() const
Definition: TestActionTimer.h:85
G4UA::TestActionTimer::eNeut
@ eNeut
Definition: TestActionTimer.h:99
G4UA::TestActionTimer::TestActionTimer
TestActionTimer()
constructor
Definition: TestActionTimer.cxx:61
G4UA::TestActionTimer::Report
this holds all the data from individual threads that needs to be merged at EoR
Definition: TestActionTimer.h:65
G4UA::TestActionTimer::eEMB
@ eEMB
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::eLAr
@ eLAr
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::eHCB
@ eHCB
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition: TestActionTimer.cxx:121
G4UA::TestActionTimer::VPanic
void VPanic()
Method to shut down all volume timers.
Definition: TestActionTimer.cxx:253
G4UA::TestActionTimer::m_eventTime
double m_eventTime
Double for storing this event.
Definition: TestActionTimer.h:107
G4UA::TestActionTimer::ClassifyVolume
int ClassifyVolume(G4String &) const
Method to sort out which volume we are in.
Definition: TestActionTimer.cxx:275
G4UA::TestActionTimer::eITkPix
@ eITkPix
Definition: TestActionTimer.h:98
G4UA::TestActionTimer::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override
Definition: TestActionTimer.cxx:145
G4UA::TestActionTimer::eFC23
@ eFC23
Definition: TestActionTimer.h:97
G4UA::TestActionTimer::Report::runTime
double runTime
Definition: TestActionTimer.h:69
G4UA::TestActionTimer::Report::timeName
std::vector< std::string > timeName
Vector of names for each of the timers.
Definition: TestActionTimer.h:68