ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4ProfilingTools
src
TestActionVPTimer.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// //
7
// TestActionVPTimer //
8
// Code for text output (into the athena.out files) //
9
// of information about the time spent simulating //
10
// various pieces of the detector and particles. //
11
// //
12
// Written by Kevin Sapp //
13
// University of Pittsburgh //
14
// kcs34@pitt.edu //
15
// Last update 10.13.09 //
16
// //
18
19
20
#include "
TestActionVPTimer.h
"
21
22
#include <G4Track.hh>
23
#include <G4Electron.hh>
24
#include <G4Gamma.hh>
25
#include <G4Positron.hh>
26
#include <G4TouchableHistory.hh>
27
#include <G4ParticleDefinition.hh>
28
29
#include <algorithm>
30
#include <iomanip>
31
#include <ios>
32
33
using
std::map;
34
using
std::max;
35
using
std::string;
36
using
std::setw;
37
using
std::ios;
38
using
std::make_pair;
39
using
std::pair;
40
using
std::find;
41
using
std::vector;
42
43
// #define _myDebug
44
45
namespace
G4UA
46
{
47
48
TestActionVPTimer::TestActionVPTimer
(
const
Config
& config)
49
:
m_config
(config),
m_runTimer
(0),
m_eventTimer
(0),
m_eventTime
(0.)
50
{
51
// create event & run timers
52
m_runTimer
=
new
G4Timer();
53
m_runTimer
->Start();
54
m_runTimer
->Stop();
55
m_eventTimer
=
new
G4Timer();
56
m_eventTimer
->Start();
57
m_eventTimer
->Stop();
58
59
// create step timer
60
v_timer
=
new
G4Timer();
61
v_timer
->Start();
62
v_timer
->Stop();
63
}
64
65
void
TestActionVPTimer::BeginOfEventAction
(
const
G4Event*)
66
{
67
m_report
.nev++;
68
m_eventTimer
->Start();
69
}
70
71
void
TestActionVPTimer::EndOfEventAction
(
const
G4Event*)
72
{
73
// this function also stops the timer. it will be restarted at BoE
74
m_eventTime
+=
TimerSum
(
m_eventTimer
);
75
}
76
77
void
TestActionVPTimer::BeginOfRunAction
(
const
G4Run*)
78
{
79
m_runTimer
->Start();
80
}
81
82
void
TestActionVPTimer::EndOfRunAction
(
const
G4Run*)
83
{
84
// this also stops the timer
85
m_report
.runTime +=
TimerSum
(
m_runTimer
);
86
}
87
88
void
TestActionVPTimer::UserSteppingAction
(
const
G4Step* aStep)
89
{
90
// HERE IS WHERE WE BEGIN OUR CLOCKING -- ONLY IF
91
// TIMERS ARE NOT VALID
92
93
if
(!
v_timer
->IsValid()) {
94
95
// Collect the total time before processing anything else
96
// this stops the timer
97
double
vtime =
TimerSum
(
v_timer
);
98
99
// CHECKIN' OUT THA NAVIGATA
100
VolumeTreeNavigator
currentTree( aStep );
101
102
// Set depth cuts here
103
currentTree.
SetDepthCutSimple
(
m_config
.dCALO,
m_config
.dBeam,
m_config
.dIDET,
m_config
.dMUON);
104
if
( !
m_config
.dDetail.empty() ) {
105
currentTree.
SetDepthCutDetail
(
m_config
.dDetail.c_str() );
106
}
107
108
// Store time generated in current volume, remove deepest entry in v_history, then
109
// repeat for the resulting VolTree (one level higher)
110
G4ParticleDefinition* PDef = currentTree.
GetTrack
()->GetDefinition();
111
while
(
true
) {
112
VolTree
VHistory = currentTree.
Extract
();
113
m_report
.time_index[VHistory].tTotal += vtime;
114
//std::cout<<"filling "<<m_report.time_index[VHistory].tTotal<<std::endl;
115
if
(PDef->GetParticleName() ==
"neutron"
) {
m_report
.time_index[VHistory].tNeutron += vtime; }
116
else
if
(PDef->GetParticleSubType() ==
"e"
) {
m_report
.time_index[VHistory].tElectron += vtime; }
117
else
if
(PDef->GetParticleSubType() ==
"pi"
) {
m_report
.time_index[VHistory].tPion += vtime; }
118
else
if
(PDef->GetParticleType() ==
"gamma"
) {
m_report
.time_index[VHistory].tPhoton += vtime; }
119
else
if
(PDef->GetParticleType() ==
"baryon"
) {
m_report
.time_index[VHistory].tBaryon += vtime; }
120
else
if
(PDef->GetParticleType() ==
"lepton"
) {
m_report
.time_index[VHistory].tLepton += vtime; }
121
else
if
(PDef->GetParticleType() ==
"meson"
) {
m_report
.time_index[VHistory].tMeson += vtime; }
122
else
{
m_report
.time_index[VHistory].tOther += vtime; }
123
//ATH_MSG_DEBUG("Time stored in "<<VHistory.back().first->GetName());
124
if
( !currentTree.
Ascend
() )
break
;
125
}
126
}
127
128
// Restart timer
129
v_timer
->Start();
130
}
131
132
}
// namespace G4UA
TestActionVPTimer.h
VolTree
std::vector< VolID > VolTree
Definition
VolumeTreeNavigator.h:36
G4UA::TestActionVPTimer::m_config
Config m_config
Definition
TestActionVPTimer.h:151
G4UA::TestActionVPTimer::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override
Definition
TestActionVPTimer.cxx:77
G4UA::TestActionVPTimer::m_eventTime
double m_eventTime
Double for storing this event time.
Definition
TestActionVPTimer.h:157
G4UA::TestActionVPTimer::TimerSum
double TimerSum(G4Timer *timer) const
Gets the time from the timer for summation.
Definition
TestActionVPTimer.h:166
G4UA::TestActionVPTimer::TestActionVPTimer
TestActionVPTimer(const Config &config)
Definition
TestActionVPTimer.cxx:48
G4UA::TestActionVPTimer::m_eventTimer
G4Timer * m_eventTimer
Timer for this event.
Definition
TestActionVPTimer.h:155
G4UA::TestActionVPTimer::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition
TestActionVPTimer.cxx:71
G4UA::TestActionVPTimer::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition
TestActionVPTimer.cxx:65
G4UA::TestActionVPTimer::m_report
Report m_report
Definition
TestActionVPTimer.h:152
G4UA::TestActionVPTimer::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition
TestActionVPTimer.cxx:88
G4UA::TestActionVPTimer::v_timer
G4Timer * v_timer
Timer activated for each volume.
Definition
TestActionVPTimer.h:156
G4UA::TestActionVPTimer::EndOfRunAction
virtual void EndOfRunAction(const G4Run *) override
Definition
TestActionVPTimer.cxx:82
G4UA::TestActionVPTimer::m_runTimer
G4Timer * m_runTimer
Timer for the entire run.
Definition
TestActionVPTimer.h:154
VolumeTreeNavigator
Definition
VolumeTreeNavigator.h:39
VolumeTreeNavigator::Ascend
bool Ascend(int levels=1)
Definition
VolumeTreeNavigator.cxx:137
VolumeTreeNavigator::GetTrack
const G4Track * GetTrack() const
VolumeTreeNavigator::SetDepthCutDetail
void SetDepthCutDetail(const char *)
Definition
VolumeTreeNavigator.cxx:92
VolumeTreeNavigator::Extract
VolTree Extract()
Definition
VolumeTreeNavigator.cxx:126
VolumeTreeNavigator::SetDepthCutSimple
void SetDepthCutSimple(const int, const int, const int, const int)
Definition
VolumeTreeNavigator.cxx:69
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
G4UA::TestActionVPTimer::Config
Definition
TestActionVPTimer.h:58
Generated on
for ATLAS Offline Software by
1.17.0