ATLAS Offline Software
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 
7 namespace 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
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 
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
G4UA::G4AtlasUserActions
Struct for passing around user actions.
Definition: IUserActionTool.h:32
G4UA::StepHistogram::Report
this holds all the data from individual threads that needs to be merged at EoR
Definition: StepHistogram.h:43
hotSpotInTAG.suffix
string suffix
Definition: hotSpotInTAG.py:186
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
G4UA::StepHistogram::HistoMapMap_t
std::map< G4String, HistoMap_t > HistoMapMap_t
Definition: StepHistogram.h:39
G4UA::StepHistogram
Definition: StepHistogram.h:32
G4UA::StepHistogram::Config::do2DHistograms
bool do2DHistograms
Definition: StepHistogram.h:108
checkTP.report
report
Definition: checkTP.py:127
G4UA::StepHistogram::Report::merge
void merge(const Report &rep)
Definition: StepHistogram.cxx:286
G4UA::ThreadSpecificUserAction::accumulate
void accumulate(ResultType &result, Mapper mapOp, Reducer reduceOp)
Accumulate results across user actions with specified operations.
Definition: ThreadSpecificUserAction.h:88
x
#define x
G4UA::StepHistogramTool::StepHistogramTool
StepHistogramTool(const std::string &type, const std::string &name, const IInterface *parent)
standard tool ctor
Definition: StepHistogramTool.cxx:9
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
G4UA::UserActionToolBase< StepHistogram >::m_actions
ThreadSpecificUserAction< StepHistogram > m_actions
Thread-specific storage of the user action.
Definition: UserActionToolBase.h:63
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
G4UA::StepHistogramTool::m_config
StepHistogram::Config m_config
Definition: StepHistogramTool.h:42
G4UA::StepHistogramTool::finalize
virtual StatusCode finalize() override
Definition: StepHistogramTool.cxx:53
StepHistogramTool.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
G4UA::StepHistogramTool::makeAndFillAction
virtual std::unique_ptr< StepHistogram > makeAndFillAction(G4AtlasUserActions &) override final
Create action for this thread.
Definition: StepHistogramTool.cxx:21
G4UA::G4AtlasUserActions::runActions
std::vector< G4UserRunAction * > runActions
Definition: IUserActionTool.h:33
G4UA::UserActionToolBase
abstract template utility base-class for G4 user-action tools.
Definition: UserActionToolBase.h:33
G4UA::StepHistogram::getReport
const Report & getReport() const
Definition: StepHistogram.h:115
G4UA::StepHistogramTool::BookHistograms
void BookHistograms(StepHistogram::HistoMapMap_t &hMap, const char *suffix, const char *subfolder="")
Definition: StepHistogramTool.cxx:36
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
G4UA::StepHistogram::Config::doGeneralHistograms
bool doGeneralHistograms
Definition: StepHistogram.h:109
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
G4UA::G4AtlasUserActions::eventActions
std::vector< G4UserEventAction * > eventActions
Definition: IUserActionTool.h:34
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
G4UA::G4AtlasUserActions::steppingActions
std::vector< G4UserSteppingAction * > steppingActions
Definition: IUserActionTool.h:36
G4UA::StepHistogramTool::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: StepHistogramTool.h:44
G4UA::StepHistogramTool::initialize
virtual StatusCode initialize() override
return the event action
Definition: StepHistogramTool.cxx:31