ATLAS Offline Software
Loading...
Searching...
No Matches
StepHistogramTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "StepHistogramTool.h"
6
7namespace G4UA{
8
10 const std::string& name,
11 const IInterface* parent):
13 m_config(),
14 m_histSvc("THistSvc", name){
15
16 declareProperty("do2DHistograms", m_config.do2DHistograms);
17 declareProperty("doGeneralHistograms", m_config.doGeneralHistograms);
18 }
19
20 std::unique_ptr<StepHistogram>
22 {
23 ATH_MSG_DEBUG("Constructing a TestActionTimer");
24 auto action = std::make_unique<StepHistogram>(m_config);
25 actionList.runActions.push_back( action.get() );
26 actionList.eventActions.push_back( action.get() );
27 actionList.steppingActions.push_back( action.get() );
28 return action;
29 }
30
32 ATH_CHECK(m_histSvc.retrieve());
33 return StatusCode::SUCCESS;
34 }
35
36 void StepHistogramTool::BookHistograms(StepHistogram::HistoMapMap_t &hMap, const char* suffix, const char* subfolder)
37 {
38 for (auto const& x : hMap)
39 {
40 ATH_MSG_INFO("Currently in volume:\t" << x.first << " got histoMap " << x.second);
41 for (auto const& hm : x.second)
42 {
43 ATH_MSG_INFO("Registering histogram:\t" << hm.first);
44 std::ostringstream stringStream;
45 stringStream << "/stepHisto/" << subfolder << x.first << "/" << suffix << hm.first;
46 if ( m_histSvc->regHist(stringStream.str().c_str(), hm.second).isFailure() ) {
47 ATH_MSG_ERROR("Could not register histogram!");
48 }
49 }
50 }
51 }
52
54 ATH_MSG_INFO("Preparing histograms...");
55
56 // Accumulate results across threads
58 m_actions.accumulate(report, &StepHistogram::getReport,
60
61 if (m_histSvc) {
62 BookHistograms(report.histoMapMap_vol_stepSize, "stepLength/", "volumes/");
63 BookHistograms(report.histoMapMap_vol_stepKineticEnergy, "stepKineticEnergy/", "volumes/");
64 BookHistograms(report.histoMapMap_vol_postStepKineticEnergy, "postStepKineticEnergy/", "volumes/");
65 BookHistograms(report.histoMapMap_vol_stepPseudorapidity, "stepPseudorapidity/", "volumes/");
66 BookHistograms(report.histoMapMap_vol_stepEnergyDeposit, "stepEnergyDeposit/", "volumes/");
67 BookHistograms(report.histoMapMap_vol_stepEnergyNonIonDeposit, "stepEnergyNonIonDeposit/", "volumes/");
68 BookHistograms(report.histoMapMap_vol_stepSecondaryKinetic, "stepSecondaryKinetic/", "volumes/");
69 BookHistograms(report.histoMapMap_vol_trackLengthPerInitialE, "trackLengthPerInitialE/", "volumes/");
70 BookHistograms(report.histoMapMap_vol_InitialE, "InitialE/", "volumes/");
71 BookHistograms(report.histoMapMap_vol_numberOfSteps, "numberOfSteps/", "volumes/");
72 BookHistograms(report.histoMapMap_vol_numberOfStepsPerInitialE, "numberOfStepsPerInitialE/", "volumes/");
73
74 BookHistograms(report.histoMapMap_mat_stepSize, "stepLength/", "materials/");
75 BookHistograms(report.histoMapMap_mat_stepKineticEnergy, "stepKineticEnergy/", "materials/");
76 BookHistograms(report.histoMapMap_mat_stepPseudorapidity, "stepPseudorapidity/", "materials/");
77 BookHistograms(report.histoMapMap_mat_postStepKineticEnergy, "postStepKineticEnergy/", "materials/");
78 BookHistograms(report.histoMapMap_mat_stepEnergyDeposit, "stepEnergyDeposit/", "materials/");
79 BookHistograms(report.histoMapMap_mat_stepEnergyNonIonDeposit, "stepEnergyNonIonDeposit/", "materials/");
80 BookHistograms(report.histoMapMap_mat_stepSecondaryKinetic, "stepSecondaryKinetic/", "materials/");
81 BookHistograms(report.histoMapMap_mat_trackLengthPerInitialE, "trackLengthPerInitialE/", "materials/");
82 BookHistograms(report.histoMapMap_mat_InitialE, "InitialE/", "materials/");
83 BookHistograms(report.histoMapMap_mat_numberOfSteps, "numberOfSteps/", "materials/");
84 BookHistograms(report.histoMapMap_mat_numberOfStepsPerInitialE, "numberOfStepsPerInitialE/", "materials/");
85
86 BookHistograms(report.histoMapMap_prc_stepSize, "stepLength/", "processes/");
87 BookHistograms(report.histoMapMap_prc_stepKineticEnergy, "stepKineticEnergy/", "processes/");
88 BookHistograms(report.histoMapMap_prc_stepPseudorapidity, "stepPseudorapidity/", "processes/");
89 BookHistograms(report.histoMapMap_prc_postStepKineticEnergy, "postStepKineticEnergy/", "processes/");
90 BookHistograms(report.histoMapMap_prc_stepEnergyDeposit, "stepEnergyDeposit/", "processes/");
91 BookHistograms(report.histoMapMap_prc_stepEnergyNonIonDeposit, "stepEnergyNonIonDeposit/", "processes/");
92 BookHistograms(report.histoMapMap_prc_stepSecondaryKinetic, "stepSecondaryKinetic/", "processes/");
93 BookHistograms(report.histoMapMap_prc_trackLengthPerInitialE, "trackLengthPerInitialE/", "processes/");
94 BookHistograms(report.histoMapMap_prc_InitialE, "InitialE/", "processes/");
95 BookHistograms(report.histoMapMap_prc_numberOfSteps, "numberOfSteps/", "processes/");
96 BookHistograms(report.histoMapMap_prc_numberOfStepsPerInitialE, "numberOfStepsPerInitialE/", "processes/");
97
98 if (m_config.doGeneralHistograms) {
99 BookHistograms(report.histoMapMap_numberOfSteps, "numberOfSteps/", "nSteps/");
100 BookHistograms(report.histoMapMap_numberOfStepsPerInitialE, "numberOfStepsPerInitialE/", "nSteps/");
101 BookHistograms(report.histoMapMap_trackLengthPerInitialE, "trackLengthPerInitialE/", "nSteps/");
102 BookHistograms(report.histoMapMap_InitialE, "InitialE/", "nSteps/");
103 BookHistograms(report.histoMapMap_stepKinetic, "stepKineticEnergy/", "nSteps/");
104 BookHistograms(report.histoMapMap_postStepKinetic, "postStepKineticEnergy/", "nSteps/");
105 }
106
107 if (m_config.do2DHistograms) {
108 BookHistograms(report.histoMapMap2D_vol_RZ, "2DMaps/", "volumes/");
109 BookHistograms(report.histoMapMap2D_mat_RZ, "2DMaps/", "materials/");
110 BookHistograms(report.histoMapMap2D_prc_RZ, "2DMaps/", "processes/");
111 BookHistograms(report.histoMapMap2D_vol_RZ_E, "2DMaps_E/", "volumes/");
112 BookHistograms(report.histoMapMap2D_mat_RZ_E, "2DMaps_E/", "materials/");
113 }
114 }
115 else {
116 ATH_MSG_WARNING("HistSvc not initialized...");
117 }
118
119 return StatusCode::SUCCESS;
120 }
121
122} // namespace G4UA
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define x
StepHistogram::Config m_config
virtual std::unique_ptr< StepHistogram > makeAndFillAction(G4AtlasUserActions &) override final
Create action for this thread.
ServiceHandle< ITHistSvc > m_histSvc
void BookHistograms(StepHistogram::HistoMapMap_t &hMap, const char *suffix, const char *subfolder="")
virtual StatusCode initialize() override
return the event action
virtual StatusCode finalize() override
StepHistogramTool(const std::string &type, const std::string &name, const IInterface *parent)
standard tool ctor
std::map< G4String, HistoMap_t > HistoMapMap_t
const Report & getReport() const
ThreadSpecificUserAction< StepHistogram > m_actions
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Struct for passing around user actions.
std::vector< G4UserSteppingAction * > steppingActions
std::vector< G4UserEventAction * > eventActions
std::vector< G4UserRunAction * > runActions
this holds all the data from individual threads that needs to be merged at EoR
void merge(const Report &rep)