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

Tool which manages the TestActionTimer action. More...

#include <TestActionTimerTool.h>

Inheritance diagram for G4UA::TestActionTimerTool:
Collaboration diagram for G4UA::TestActionTimerTool:

Public Member Functions

 TestActionTimerTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor.
virtual StatusCode initialize () override
 Initialize the tool.
virtual StatusCode finalize () override
 Finalize the tool.
virtual StatusCode fillUserAction (G4AtlasUserActions &actionLists) override final
 Fill the user action lists.
StatusCode BeginOfAthenaEvent (HitCollectionMap &) override
 Calls BeginOfAthenaEvent.
StatusCode EndOfAthenaEvent (HitCollectionMap &) override
 Calls EndOfAthenaEvent.

Protected Member Functions

virtual std::unique_ptr< TestActionTimermakeAndFillAction (G4AtlasUserActions &) override final
 Create action for this thread.

Protected Attributes

ThreadSpecificUserAction< TestActionTimerm_actions
 Thread-specific storage of the user action.

Private Attributes

ServiceHandle< ITHistSvc > m_histSvc
 HistSvc to record timing histograms.

Detailed Description

Tool which manages the TestActionTimer action.

Create the TestActionTimer for each worker thread

Author
Andrea Di Simone

Definition at line 23 of file TestActionTimerTool.h.

Constructor & Destructor Documentation

◆ TestActionTimerTool()

G4UA::TestActionTimerTool::TestActionTimerTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard constructor.

Definition at line 12 of file TestActionTimerTool.cxx.

15 : UserActionToolBase<TestActionTimer>(type, name, parent),
16 m_histSvc("THistSvc", name)
17 {
18 }
ServiceHandle< ITHistSvc > m_histSvc
HistSvc to record timing histograms.
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ BeginOfAthenaEvent()

StatusCode G4UA::UserActionToolBase< TestActionTimer >::BeginOfAthenaEvent ( HitCollectionMap & )
inlineoverrideinherited

Calls BeginOfAthenaEvent.

Definition at line 59 of file UserActionToolBase.h.

59{return StatusCode::SUCCESS;};
abstract template utility base-class for G4 user-action tools.

◆ EndOfAthenaEvent()

StatusCode G4UA::UserActionToolBase< TestActionTimer >::EndOfAthenaEvent ( HitCollectionMap & )
inlineoverrideinherited

Calls EndOfAthenaEvent.

Definition at line 61 of file UserActionToolBase.h.

61{return StatusCode::SUCCESS;};

◆ fillUserAction()

virtual StatusCode G4UA::UserActionToolBase< TestActionTimer >::fillUserAction ( G4AtlasUserActions & actionLists)
inlinefinaloverridevirtualinherited

Fill the user action lists.

Definition at line 47 of file UserActionToolBase.h.

48 {
50 if(myAction == nullptr) {
51 ATH_MSG_ERROR( "Failed to construct user action in " << name() );
53 }
56 }
#define ATH_MSG_ERROR(x)
virtual std::unique_ptr< TestActionTimer > makeAndFillAction(G4AtlasUserActions &actionLists)=0

◆ finalize()

StatusCode G4UA::TestActionTimerTool::finalize ( )
overridevirtual

Finalize the tool.

Definition at line 37 of file TestActionTimerTool.cxx.

38 {
39 // Accumulate results across threads
40 TestActionTimer::Report report;
41 m_actions.accumulate(report, &TestActionTimer::getReport,
43
44 if(!report.time.empty()){
45 G4double sumVTime = 0.;
46 G4double sumPTime = 0.;
47 for (int i(0); i <= TestActionTimer::eOther; ++i) sumVTime += report.time[i];
48 for (int i(TestActionTimer::eElec); i < TestActionTimer::eMax; ++i) sumPTime += report.time[i];
49
50 if (report.nev>0){
51 ATH_MSG_INFO("****** TestActionTimer: Beginning timer dump ******");
52
53 G4double DeadTime = report.runTime - sumVTime;
54 G4double OtherPart = report.runTime - DeadTime - sumPTime;
55
56 ATH_MSG_INFO("Timer\tEvent\tFraction");
57 ATH_MSG_INFO("EvtAve\t"<<report.runTime/report.nev<<"\t100");
58
59 for (int i(0);i <= TestActionTimer::eOther; i++) {
60 ATH_MSG_INFO(report.timeName[i] << "\t" << report.time[i]/report.nev << "\t" << report.time[i]/report.runTime);
61 }
62 ATH_MSG_INFO("Dead\t" << DeadTime/report.nev << "\t" << DeadTime/report.runTime);
64 ATH_MSG_INFO(report.timeName[i] << "\t" << report.time[i]/report.nev << "\t" << report.time[i]/report.runTime);
65 }
66 ATH_MSG_INFO("OtherPart\t" << OtherPart/report.nev << "\t" << OtherPart/report.runTime);
67
68 ATH_MSG_INFO("****** TestActionTimer: Major Subdet Times per Event *********");
69 ATH_MSG_INFO("EMB\t" << (report.time[TestActionTimer::eEMB])/report.nev);
70 ATH_MSG_INFO("EMEC\t" << (report.time[TestActionTimer::eEMEC])/report.nev);
72 ATH_MSG_INFO("HEC\t" << (report.time[TestActionTimer::eHEC])/report.nev);
73 ATH_MSG_INFO("Tile\t" << (report.time[TestActionTimer::eHCB])/report.nev);
75 ATH_MSG_INFO("Muons\t" << (report.time[TestActionTimer::eMu])/report.nev);
76 ATH_MSG_INFO("Oth.LAr\t" << (report.time[TestActionTimer::ePre]+report.time[TestActionTimer::TestActionTimer::eCry]+report.time[TestActionTimer::eLAr])/report.nev);
77 ATH_MSG_INFO("Other\t" << (report.time[TestActionTimer::eOther])/report.nev);
78 ATH_MSG_INFO("EvtAve\t" << (report.runTime)/report.nev);
79 ATH_MSG_INFO("******* TestActionTimer: Major Subdet Frac per Event *********");
80 ATH_MSG_INFO("EMB\t" << (report.time[TestActionTimer::eEMB])/report.runTime*100.);
81 ATH_MSG_INFO("EMEC\t" << (report.time[TestActionTimer::eEMEC])/report.runTime*100.);
83 ATH_MSG_INFO("HEC\t" << (report.time[TestActionTimer::eHEC])/report.runTime*100.);
84 ATH_MSG_INFO("Tile\t" << (report.time[TestActionTimer::eHCB])/report.runTime*100.);
86 ATH_MSG_INFO("Muons\t" << (report.time[TestActionTimer::eMu])/report.runTime*100.);
88 ATH_MSG_INFO("Other\t" << (report.time[TestActionTimer::eOther])/report.runTime*100.);
89 ATH_MSG_INFO("EvtAve\t" << (report.runTime)/report.nev);
90 ATH_MSG_INFO("******* TestActionTimer: Timer Information *********");
91 ATH_MSG_INFO("NOTE: in case of MT runs, the timings for the individual threads are added, i.e. it is");
92 ATH_MSG_INFO(" equivalent to running the N threads sequentially instead of in parallel.");
93 ATH_MSG_INFO("Timers were run over " << report.nev << " events, and the averages were taken by");
94 ATH_MSG_INFO("detector portion. Detectors are determined by volume name. Pieces include:");
95 ATH_MSG_INFO("EMB, EMEC, FCAL, HEC, Tile - the sampling portions of the calorimeters.");
96 ATH_MSG_INFO("Pixel, SCT, TRT - the sensitive portions of the tracker only");
97 ATH_MSG_INFO("InDetSvc - all remaining portions of the inner detector");
98 ATH_MSG_INFO("Oth.LAr - all remaining portions of the LAr, including preshower, solenoid,");
99 ATH_MSG_INFO("\tcryostats, and services.");
100 ATH_MSG_INFO("Other - volumes not listed, including ATLAS::ATLAS and CALO::CALO");
101 ATH_MSG_INFO("");
102 ATH_MSG_INFO("Dead time includes overhead per event (file i/o, event loading, timing overhead)");
103 ATH_MSG_INFO("");
104 ATH_MSG_INFO("All times are user+system time on your processor");
105 ATH_MSG_INFO("******* TestActionTimer: End of timer dump *********");
106
107 TH1D * r_geo = new TH1D("GeoResults","GeoResults",TestActionTimer::eOther-TestActionTimer::eEMB+1,-0.5,float(TestActionTimer::eOther-TestActionTimer::eEMB+1)-0.5);
108 TH1D * r_part = new TH1D("ParticleResults","ParticleResults",TestActionTimer::eMax-TestActionTimer::eElec+1,-0.5,float(TestActionTimer::eMax-TestActionTimer::eElec+1)-0.5);
109
110 report.runTime -= DeadTime;
111 for (int i(0); i <= TestActionTimer::eOther; ++i){
112 r_geo->Fill( i , report.time[i] / report.runTime*100. );
113 r_geo->GetXaxis()->SetBinLabel( i+1 , report.timeName[i].c_str() );
114 }
116 r_part->Fill( i-TestActionTimer::eElec , report.time[i] / report.runTime*100. );
117 r_part->GetXaxis()->SetBinLabel( i-TestActionTimer::eElec+1 , report.timeName[i].c_str() );
118 }
119 r_part->Fill( TestActionTimer::eMax-TestActionTimer::eElec , OtherPart / report.runTime*100. ); // Other particles don't get their own timer
120 r_part->GetXaxis()->SetBinLabel( TestActionTimer::eMax-TestActionTimer::eElec+1 , "Others" );
121 r_geo->SetXTitle("Detector Region");
122 r_part->SetXTitle("Particle Type");
123 r_geo->SetYTitle("Percent of Event Time");
124 r_part->SetYTitle("Percent of Event Time");
125
126 if (m_histSvc){
127 if ( m_histSvc->regHist("/simTime/GeoResults",r_geo).isFailure() ||
128 m_histSvc->regHist("/simTime/ParticleResults",r_part).isFailure() ){
129 ATH_MSG_ERROR("Could not register histograms!");
130 }
131 }
132
133 } else {
134
135 ATH_MSG_INFO("******* TestActionTimer: Nothing to report, no events timed! *********");
136 }
137 } else {ATH_MSG_INFO("******* TestActionTimer: No timing information recoreded! *********");}
138 return StatusCode::SUCCESS;
139 }
#define ATH_MSG_INFO(x)
const Report & getReport() const
ThreadSpecificUserAction< TestActionTimer > m_actions
list report
Definition checkTP.py:125
void merge(const Report &rep)

◆ initialize()

StatusCode G4UA::TestActionTimerTool::initialize ( )
overridevirtual

Initialize the tool.

Definition at line 20 of file TestActionTimerTool.cxx.

21 {
22 ATH_CHECK(m_histSvc.retrieve());
23 return StatusCode::SUCCESS;
24 }
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ makeAndFillAction()

std::unique_ptr< TestActionTimer > G4UA::TestActionTimerTool::makeAndFillAction ( G4AtlasUserActions & actionList)
finaloverrideprotectedvirtual

Create action for this thread.

Implements G4UA::UserActionToolBase< TestActionTimer >.

Definition at line 27 of file TestActionTimerTool.cxx.

28 {
29 ATH_MSG_DEBUG("Constructing a TestActionTimer");
30 auto action = std::make_unique<TestActionTimer>();
31 actionList.runActions.push_back( action.get() );
32 actionList.eventActions.push_back( action.get() );
33 actionList.steppingActions.push_back( action.get() );
34 return action;
35 }
#define ATH_MSG_DEBUG(x)

Member Data Documentation

◆ m_actions

Thread-specific storage of the user action.

Definition at line 70 of file UserActionToolBase.h.

◆ m_histSvc

ServiceHandle<ITHistSvc> G4UA::TestActionTimerTool::m_histSvc
private

HistSvc to record timing histograms.

Definition at line 42 of file TestActionTimerTool.h.


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