Belle II Software  release-08-01-10
FullSimTimingModule.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 #ifndef SIMULATION_MODULES_FULLSIM_FULLSIMTIMINGMODULE_H
11 #define SIMULATION_MODULES_FULLSIM_FULLSIMTIMINGMODULE_H
12 
13 #include <framework/core/Module.h>
14 #include <simulation/kernel/StepTiming.h>
15 #include <map>
16 
17 class TProfile;
18 
19 namespace Belle2 {
37  class FullSimTimingModule : public Module {
38 
39  public:
40 
46 
49 
52 
54  virtual void initialize() override;
55 
57  virtual void event() override;
58 
60  virtual void terminate() override;
61 
62  private:
64  void processStep(G4Track* track, G4LogicalVolume* volume, double time);
65 
67  std::string m_rootFileName;
71  std::map<const G4Region*, double> m_regionCache;
73  std::map<const G4Region*, double>::iterator m_lastRegion {m_regionCache.end()};
75  std::map<const G4Region*, int> m_regionIndices;
77  TProfile* m_timingProfile {nullptr};
79  double m_totalTime {0};
81  double m_eventTime {0};
83  unsigned int m_eventCount {0};
85  bool m_isInitialized {false};
86  };
88 }
89 
90 #endif // SIMULATION_MODULES_FULLSIM_FULLSIMTIMINGMODULE_H
Provide more detailled timing info for FullSim module.
std::string m_rootFileName
filename of the root file to store the timing profile
double m_totalTime
total time spent stepping through the simulation geometry
bool m_isInitialized
remember whether we aleady initialized everything
Simulation::StepTiming * m_timing
instance of the StepTiming class which records the step times in geant4
virtual void initialize() override
Setup the timing structure.
virtual void event() override
Save the simulation time for each region in a profile.
FullSimTimingModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::map< const G4Region *, double >::iterator m_lastRegion
iterator pointing to the region of the last step to speed up lookup
virtual void terminate() override
Save the output.
FullSimTimingModule(const FullSimTimingModule &)=delete
No copying.
double m_eventTime
stepping time of the current event
void processStep(G4Track *track, G4LogicalVolume *volume, double time)
store the time it took a Geant4 track for one step inside a volume
unsigned int m_eventCount
number of events with m_eventTime>0
FullSimTimingModule & operator=(const FullSimTimingModule &)=delete
No assignment.
std::map< const G4Region *, int > m_regionIndices
map between region and and bin indices in the TProfile
std::map< const G4Region *, double > m_regionCache
map containing the amount of time spent in each region
TProfile * m_timingProfile
profile of the time spent per event in each region
Base class for Modules.
Definition: Module.h:72
Class to perform more detailed timing studies of the Geant4 simulation.
Definition: StepTiming.h:34
Abstract base class for different kinds of events.