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

Tool which manages the TestActionVPTimer action. More...

#include <TestActionVPTimerTool.h>

Inheritance diagram for G4UA::TestActionVPTimerTool:
Collaboration diagram for G4UA::TestActionVPTimerTool:

Public Member Functions

 TestActionVPTimerTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor.
virtual StatusCode finalize () override
 Triggers report merging from threads.
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< TestActionVPTimermakeAndFillAction (G4AtlasUserActions &) override final
 Create action for this thread.

Protected Attributes

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

Private Member Functions

void TimerPrint (std::pair< VolTree, TestActionVPTimer::volumeData >, const double tTotal, const int depth=0) const
void TreeOut (const VolTree &, const double tAtlas, int depth=0)

Private Attributes

TestActionVPTimer::Config m_config
 holds the runtime configuration
TestActionVPTimer::Report m_report
 holds data to be reported at end of run

Detailed Description

Tool which manages the TestActionVPTimer action.

Create the TestActionVPTimer for each worker thread and merges timing results in finalization.

Author
Andrea Di Simone

Definition at line 23 of file TestActionVPTimerTool.h.

Constructor & Destructor Documentation

◆ TestActionVPTimerTool()

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

Standard constructor.

Definition at line 40 of file TestActionVPTimerTool.cxx.

43 : UserActionToolBase<TestActionVPTimer>(type, name, parent)
44 {
45 declareProperty("CaloDepth",m_config.dCALO);
46 declareProperty("BeamPipeDepth",m_config.dBeam);
47 declareProperty("InDetDepth",m_config.dIDET);
48 declareProperty("MuonDepth",m_config.dMUON);
49 declareProperty("DetailDepth",m_config.dDetail);
50 }
TestActionVPTimer::Config m_config
holds the runtime configuration
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ BeginOfAthenaEvent()

StatusCode G4UA::UserActionToolBase< TestActionVPTimer >::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< TestActionVPTimer >::EndOfAthenaEvent ( HitCollectionMap & )
inlineoverrideinherited

Calls EndOfAthenaEvent.

Definition at line 61 of file UserActionToolBase.h.

61{return StatusCode::SUCCESS;};

◆ fillUserAction()

virtual StatusCode G4UA::UserActionToolBase< TestActionVPTimer >::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< TestActionVPTimer > makeAndFillAction(G4AtlasUserActions &actionLists)=0

◆ finalize()

StatusCode G4UA::TestActionVPTimerTool::finalize ( )
overridevirtual

Triggers report merging from threads.

Definition at line 65 of file TestActionVPTimerTool.cxx.

66 {
67 // We shouldn't need this. End-run actions should be called by Geant4.
68 // I'll leave this here, commented out for now, for reference.
69 //for(auto& tidAction : m_actions) {
70 // ((G4UserRunAction*)tidAction.second)->EndOfRunAction(0);
71 //}
72
73 // Accumulate results across threads
76
77 if(m_report.time_index.size()){
78
79 VolTree topPV; // vector< pair<physvol*,int> >
80 // time_index is map<VolTree, TestActionVPTimer::volumeData>
81
82 topPV.push_back(m_report.time_index.begin()->first.front());
83 auto it = m_report.time_index.find(topPV);
84 if (it == m_report.time_index.end()){
85 ATH_MSG_WARNING("topPV not found.");
86 return StatusCode::FAILURE;
87 }
88 TestActionVPTimer::volumeData atlasData =it->second;
89 G4double DeadTime = m_report.runTime - atlasData.tTotal;
90
91 ATH_MSG_INFO("Runtime " << m_report.runTime
92 << " Dead Time " << DeadTime );
93
94 if (m_report.nev != 0){
95 ATH_MSG_INFO("******* Beginning timer dump *******" );
96
97 ATH_MSG_INFO(setw(12) << "Time" << setw(12) << "per Event" << setw(12)
98 << "per Run" << setw(6) << "Depth" << " Location/Particle" );
99 ATH_MSG_INFO(vPrFmt(m_report.runTime, m_report.nev, atlasData.tTotal, -999, " Event Average") );
100 ATH_MSG_INFO(vPrFmt(DeadTime, m_report.nev, atlasData.tTotal, -999, " Dead/Initialization") );
101
102 ATH_MSG_INFO("\n******* Data by volume/select particles *******");
103 ATH_MSG_INFO("Data printed in reverse tree order (mother following daughter)");
104
105 TreeOut(topPV, atlasData.tTotal);
106 // for (VolIt c = v_time_index.begin(); c != v_time_index.end(); c++) {
107 // TimerPrint(*c, atlasData.tTotal, c->first.size());
108 // }
109
110 ATH_MSG_INFO( "\n******* Data by particle/category *******");
111
112 ATH_MSG_INFO(vPrFmt(atlasData.tElectron, m_report.nev, atlasData.tTotal, -999, "e+/-" ) );
113 ATH_MSG_INFO(vPrFmt(atlasData.tPhoton, m_report.nev, atlasData.tTotal, -999, "gamma" ) );
114 ATH_MSG_INFO(vPrFmt(atlasData.tNeutron, m_report.nev, atlasData.tTotal, -999, "neutron") );
115 ATH_MSG_INFO(vPrFmt(atlasData.tPion, m_report.nev, atlasData.tTotal, -999, "pi+/-/0") );
116 ATH_MSG_INFO(vPrFmt(atlasData.tBaryon, m_report.nev, atlasData.tTotal, -999, "baryon" ) );
117 ATH_MSG_INFO(vPrFmt(atlasData.tLepton, m_report.nev, atlasData.tTotal, -999, "lepton" ) );
118 ATH_MSG_INFO(vPrFmt(atlasData.tMeson, m_report.nev, atlasData.tTotal, -999, "meson" ) );
119 ATH_MSG_INFO(vPrFmt(atlasData.tOther, m_report.nev, atlasData.tTotal, -999, "other" ) );
120
121 } else { ATH_MSG_WARNING("******* No events timed! *******"); }
122 } else { ATH_MSG_WARNING("******* No Timing information recorded! *******"); }
123
124 return StatusCode::SUCCESS;
125 }
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
std::vector< VolID > VolTree
TestActionVPTimer::Report m_report
holds data to be reported at end of run
void TreeOut(const VolTree &, const double tAtlas, int depth=0)
const Report & getReport() const
ThreadSpecificUserAction< TestActionVPTimer > m_actions
std::string vPrFmt(double time, double nEv, double tRun, int depth, const std::string &id)

◆ makeAndFillAction()

std::unique_ptr< TestActionVPTimer > G4UA::TestActionVPTimerTool::makeAndFillAction ( G4AtlasUserActions & actionList)
finaloverrideprotectedvirtual

Create action for this thread.

Implements G4UA::UserActionToolBase< TestActionVPTimer >.

Definition at line 54 of file TestActionVPTimerTool.cxx.

55 {
56 ATH_MSG_DEBUG("Constructing a TestActionVPTimer");
57 auto action = std::make_unique<TestActionVPTimer>(m_config);
58 actionList.runActions.push_back( action.get() );
59 actionList.eventActions.push_back( action.get() );
60 actionList.steppingActions.push_back( action.get() );
61 return action;
62 }
#define ATH_MSG_DEBUG(x)

◆ TimerPrint()

void G4UA::TestActionVPTimerTool::TimerPrint ( std::pair< VolTree, TestActionVPTimer::volumeData > vp,
const double tTotal,
const int depth = 0 ) const
inlineprivate

Definition at line 144 of file TestActionVPTimerTool.cxx.

146 {
147 G4VPhysicalVolume* pv = vp.first.back().first;
148 std::string physical = stringify(pv->GetName());
149 std::string copyNo = stringify(vp.first.back().second);
150 std::string mother = "";
151 if (vp.first.size() != 1) mother = stringify( (vp.first.end()-2)->first->GetName() );
152 ATH_MSG_INFO(vPrFmt(vp.second.tTotal, m_report.nev, tTotal, depth-1, physical+"_"+copyNo+" "+mother) );
153 ATH_MSG_INFO(vPrFmt(vp.second.tElectron, m_report.nev, tTotal, depth-1, " - electrons & positrons") );
154 ATH_MSG_INFO(vPrFmt(vp.second.tPhoton, m_report.nev, tTotal, depth-1, " - photons") );
155 ATH_MSG_INFO(vPrFmt(vp.second.tNeutron, m_report.nev, tTotal, depth-1, " - neutrons") );
156 ATH_MSG_INFO(vPrFmt(vp.second.tPion, m_report.nev, tTotal, depth-1, " - pions") );
157
158 double tOther = vp.second.tTotal - vp.second.tElectron - vp.second.tPhoton - vp.second.tNeutron - vp.second.tPion;
159 ATH_MSG_INFO(vPrFmt(tOther, m_report.nev, m_report.runTime, depth-1, " - other particles") );
160 }
std::string stringify(T obj)
std::string depth
tag string for intendation
Definition fastadd.cxx:46

◆ TreeOut()

void G4UA::TestActionVPTimerTool::TreeOut ( const VolTree & id,
const double tAtlas,
int depth = 0 )
private

Definition at line 128 of file TestActionVPTimerTool.cxx.

129 {
130 VolIt v = m_report.time_index.find(id);
131 if (v != m_report.time_index.end()) {
132 depth++;
133 for (VolIt c = m_report.time_index.begin(); c != m_report.time_index.end(); ++c) {
134 VolTree check = c->first;
135 check.pop_back();
136 if (id == check) TreeOut(c->first, tAtlas, depth);
137 }
138 TimerPrint(*v, tAtlas, depth);
139 }
140 }
void TimerPrint(std::pair< VolTree, TestActionVPTimer::volumeData >, const double tTotal, const int depth=0) const
VolMap::const_iterator VolIt

Member Data Documentation

◆ m_actions

Thread-specific storage of the user action.

Definition at line 70 of file UserActionToolBase.h.

◆ m_config

TestActionVPTimer::Config G4UA::TestActionVPTimerTool::m_config
private

holds the runtime configuration

Definition at line 42 of file TestActionVPTimerTool.h.

◆ m_report

TestActionVPTimer::Report G4UA::TestActionVPTimerTool::m_report
private

holds data to be reported at end of run

Definition at line 44 of file TestActionVPTimerTool.h.


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