Belle II Software  release-05-02-19
FullSimTimingModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 #ifndef SIMULATION_MODULES_FULLSIM_FULLSIMTIMINGMODULE_H
13 #define SIMULATION_MODULES_FULLSIM_FULLSIMTIMINGMODULE_H
14 
15 #include <framework/core/Module.h>
16 #include <simulation/kernel/StepTiming.h>
17 #include <map>
18 
19 class TProfile;
20 
21 namespace Belle2 {
39  class FullSimTimingModule : public Module {
40 
41  public:
42 
48 
51 
54 
56  virtual void initialize() override;
57 
59  virtual void event() override;
60 
62  virtual void terminate() override;
63 
64  private:
66  void processStep(G4Track* track, G4LogicalVolume* volume, double time);
67 
69  std::string m_rootFileName;
73  std::map<const G4Region*, double> m_regionCache;
75  std::map<const G4Region*, double>::iterator m_lastRegion {m_regionCache.end()};
77  std::map<const G4Region*, int> m_regionIndices;
79  TProfile* m_timingProfile {nullptr};
81  double m_totalTime {0};
83  double m_eventTime {0};
85  unsigned int m_eventCount {0};
87  bool m_isInitialized {false};
88  };
90 }
91 
92 #endif // SIMULATION_MODULES_FULLSIM_FULLSIMTIMINGMODULE_H
Belle2::FullSimTimingModule::m_eventCount
unsigned int m_eventCount
number of events with m_eventTime>0
Definition: FullSimTimingModule.h:85
Belle2::FullSimTimingModule::FullSimTimingModule
FullSimTimingModule()
Constructor: Sets the description, the properties and the parameters of the module.
Definition: FullSimTimingModule.cc:33
Belle2::FullSimTimingModule::operator=
FullSimTimingModule & operator=(const FullSimTimingModule &)=delete
No assignment.
Belle2::FullSimTimingModule::m_timing
Simulation::StepTiming * m_timing
instance of the StepTiming class which records the step times in geant4
Definition: FullSimTimingModule.h:71
Belle2::FullSimTimingModule::initialize
virtual void initialize() override
Setup the timing structure.
Definition: FullSimTimingModule.cc:57
Belle2::FullSimTimingModule
Provide more detailled timing info for FullSim module.
Definition: FullSimTimingModule.h:39
Belle2::FullSimTimingModule::m_rootFileName
std::string m_rootFileName
filename of the root file to store the timing profile
Definition: FullSimTimingModule.h:69
Belle2::FullSimTimingModule::m_lastRegion
std::map< const G4Region *, double >::iterator m_lastRegion
iterator pointing to the region of the last step to speed up lookup
Definition: FullSimTimingModule.h:75
Belle2::FullSimTimingModule::processStep
void processStep(G4Track *track, G4LogicalVolume *volume, double time)
store the time it took a Geant4 track for one step inside a volume
Definition: FullSimTimingModule.cc:128
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::FullSimTimingModule::m_regionCache
std::map< const G4Region *, double > m_regionCache
map containing the amount of time spent in each region
Definition: FullSimTimingModule.h:73
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Simulation::StepTiming
Class to perform more detailed timing studies of the Geant4 simulation.
Definition: StepTiming.h:36
Belle2::FullSimTimingModule::terminate
virtual void terminate() override
Save the output.
Definition: FullSimTimingModule.cc:142
Belle2::FullSimTimingModule::m_eventTime
double m_eventTime
stepping time of the current event
Definition: FullSimTimingModule.h:83
Belle2::FullSimTimingModule::m_totalTime
double m_totalTime
total time spent stepping through the simulation geometry
Definition: FullSimTimingModule.h:81
Belle2::FullSimTimingModule::m_regionIndices
std::map< const G4Region *, int > m_regionIndices
map between region and and bin indices in the TProfile
Definition: FullSimTimingModule.h:77
Belle2::FullSimTimingModule::event
virtual void event() override
Save the simulation time for each region in a profile.
Definition: FullSimTimingModule.cc:79
Belle2::FullSimTimingModule::m_timingProfile
TProfile * m_timingProfile
profile of the time spent per event in each region
Definition: FullSimTimingModule.h:79
Belle2::FullSimTimingModule::m_isInitialized
bool m_isInitialized
remember whether we aleady initialized everything
Definition: FullSimTimingModule.h:87