Belle II Software development
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
11#include <framework/core/Module.h>
12#include <map>
13
14class TProfile;
15
16class G4Track;
17class G4LogicalVolume;
18class G4Region;
19
20namespace Belle2 {
25 namespace Simulation {
26 class StepTiming;
27 }
28
32
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 };
89
90}
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
std::map< constG4Region *, double >::iterator m_lastRegion
iterator pointing to the region of the last step to speed up lookup
Simulation::StepTiming * m_timing
instance of the StepTiming class which records the step times in geant4
virtual void initialize() override
Setup the timing structure.
FullSimTimingModule & operator=(const FullSimTimingModule &)=delete
No assignment.
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.
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
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
Module()
Constructor.
Definition Module.cc:30
Class to perform more detailed timing studies of the Geant4 simulation.
Definition StepTiming.h:33
Abstract base class for different kinds of events.