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#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
17class TProfile;
18
19namespace Belle2 {
34 class FullSimTimingModule : public Module {
35
36 public:
37
43
46
49
51 virtual void initialize() override;
52
54 virtual void event() override;
55
57 virtual void terminate() override;
58
59 private:
61 void processStep(G4Track* track, G4LogicalVolume* volume, double time);
62
64 std::string m_rootFileName;
68 std::map<const G4Region*, double> m_regionCache;
70 std::map<const G4Region*, double>::iterator m_lastRegion {m_regionCache.end()};
72 std::map<const G4Region*, int> m_regionIndices;
74 TProfile* m_timingProfile {nullptr};
76 double m_totalTime {0};
78 double m_eventTime {0};
80 unsigned int m_eventCount {0};
82 bool m_isInitialized {false};
83 };
85}
86
87#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
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
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.