ATLAS Offline Software
Loading...
Searching...
No Matches
G4UA::TestActionVPTimer Class Reference

#include <TestActionVPTimer.h>

Inheritance diagram for G4UA::TestActionVPTimer:
Collaboration diagram for G4UA::TestActionVPTimer:

Classes

struct  Config
struct  Report
struct  volumeData

Public Types

typedef std::map< VolTree, TestActionVPTimer::volumeDataVolMap
typedef VolMap::const_iterator VolIt

Public Member Functions

 TestActionVPTimer (const Config &config)
 TestActionVPTimer (const TestActionVPTimer &)=delete
TestActionVPTimeroperator= (const TestActionVPTimer &)=delete
const ReportgetReport () const
virtual void BeginOfEventAction (const G4Event *) override
virtual void EndOfEventAction (const G4Event *) override
virtual void BeginOfRunAction (const G4Run *) override
virtual void EndOfRunAction (const G4Run *) override
virtual void UserSteppingAction (const G4Step *) override

Private Member Functions

double TimerSum (G4Timer *timer) const
 Gets the time from the timer for summation.

Private Attributes

Config m_config
Report m_report
G4Timer * m_runTimer
 Timer for the entire run.
G4Timer * m_eventTimer
 Timer for this event.
G4Timer * v_timer
 Timer activated for each volume.
double m_eventTime
 Double for storing this event time.
VolTree v_history
 Vector of the current volume history, used to assign times to each element.

Detailed Description

Definition at line 51 of file TestActionVPTimer.h.

Member Typedef Documentation

◆ VolIt

typedef VolMap::const_iterator G4UA::TestActionVPTimer::VolIt

Definition at line 100 of file TestActionVPTimer.h.

◆ VolMap

Constructor & Destructor Documentation

◆ TestActionVPTimer() [1/2]

G4UA::TestActionVPTimer::TestActionVPTimer ( const Config & config)

Definition at line 48 of file TestActionVPTimer.cxx.

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 }
double m_eventTime
Double for storing this event time.
G4Timer * m_eventTimer
Timer for this event.
G4Timer * v_timer
Timer activated for each volume.
G4Timer * m_runTimer
Timer for the entire run.

◆ TestActionVPTimer() [2/2]

G4UA::TestActionVPTimer::TestActionVPTimer ( const TestActionVPTimer & )
delete

Member Function Documentation

◆ BeginOfEventAction()

void G4UA::TestActionVPTimer::BeginOfEventAction ( const G4Event * )
overridevirtual

Definition at line 65 of file TestActionVPTimer.cxx.

66 {
67 m_report.nev++;
68 m_eventTimer->Start();
69 }

◆ BeginOfRunAction()

void G4UA::TestActionVPTimer::BeginOfRunAction ( const G4Run * )
overridevirtual

Definition at line 77 of file TestActionVPTimer.cxx.

78 {
79 m_runTimer->Start();
80 }

◆ EndOfEventAction()

void G4UA::TestActionVPTimer::EndOfEventAction ( const G4Event * )
overridevirtual

Definition at line 71 of file TestActionVPTimer.cxx.

72 {
73 // this function also stops the timer. it will be restarted at BoE
75 }
double TimerSum(G4Timer *timer) const
Gets the time from the timer for summation.

◆ EndOfRunAction()

void G4UA::TestActionVPTimer::EndOfRunAction ( const G4Run * )
overridevirtual

Definition at line 82 of file TestActionVPTimer.cxx.

83 {
84 // this also stops the timer
85 m_report.runTime += TimerSum(m_runTimer);
86 }

◆ getReport()

const Report & G4UA::TestActionVPTimer::getReport ( ) const
inline

Definition at line 141 of file TestActionVPTimer.h.

142 { return m_report; }

◆ operator=()

TestActionVPTimer & G4UA::TestActionVPTimer::operator= ( const TestActionVPTimer & )
delete

◆ TimerSum()

double G4UA::TestActionVPTimer::TimerSum ( G4Timer * timer) const
inlineprivate

Gets the time from the timer for summation.

Stops a timer and return the elapsed time.

Definition at line 166 of file TestActionVPTimer.h.

167 {
168 if (timer == 0) return -999.;
169 timer->Stop();
170 return (timer->GetUserElapsed() + timer->GetSystemElapsed());
171 }
timer(name, disabled=False)

◆ UserSteppingAction()

void G4UA::TestActionVPTimer::UserSteppingAction ( const G4Step * aStep)
overridevirtual

Definition at line 88 of file TestActionVPTimer.cxx.

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 }
std::vector< VolID > VolTree

Member Data Documentation

◆ m_config

Config G4UA::TestActionVPTimer::m_config
private

Definition at line 151 of file TestActionVPTimer.h.

◆ m_eventTime

double G4UA::TestActionVPTimer::m_eventTime
private

Double for storing this event time.

Definition at line 157 of file TestActionVPTimer.h.

◆ m_eventTimer

G4Timer* G4UA::TestActionVPTimer::m_eventTimer
private

Timer for this event.

Definition at line 155 of file TestActionVPTimer.h.

◆ m_report

Report G4UA::TestActionVPTimer::m_report
private

Definition at line 152 of file TestActionVPTimer.h.

◆ m_runTimer

G4Timer* G4UA::TestActionVPTimer::m_runTimer
private

Timer for the entire run.

Definition at line 154 of file TestActionVPTimer.h.

◆ v_history

VolTree G4UA::TestActionVPTimer::v_history
private

Vector of the current volume history, used to assign times to each element.

Definition at line 159 of file TestActionVPTimer.h.

◆ v_timer

G4Timer* G4UA::TestActionVPTimer::v_timer
private

Timer activated for each volume.

Definition at line 156 of file TestActionVPTimer.h.


The documentation for this class was generated from the following files: