LDMX Software
HCalDQM.cxx
1
2#include "DQM/HCalDQM.h"
3namespace dqm {
4
5HCalDQM::HCalDQM(const std::string &name, framework::Process &process)
6 : framework::Analyzer(name, process) {}
7
9 rec_coll_name_ = ps.getParameter<std::string>("rec_coll_name");
10 rec_pass_name_ = ps.getParameter<std::string>("rec_pass_name");
11 sim_coll_name_ = ps.getParameter<std::string>("sim_coll_name");
12 sim_pass_name_ = ps.getParameter<std::string>("sim_pass_name");
13 pe_veto_threshold = ps.getParameter<double>("pe_veto_threshold");
14 section_ = ps.getParameter<int>("section");
15 max_hit_time_ = ps.getParameter<double>("max_hit_time");
16}
17
19 // Get the collection of HCalDQM digitized hits if the exists
20 const auto &hcalHits{
21 event.getCollection<ldmx::HcalHit>(rec_coll_name_, rec_pass_name_)};
22
23 const auto &hcalSimHits{event.getCollection<ldmx::SimCalorimeterHit>(
25 analyzeSimHits(hcalSimHits);
26 analyzeRecHits(hcalHits);
27}
28void HCalDQM::analyzeSimHits(const std::vector<ldmx::SimCalorimeterHit> &hits) {
29 const auto &geometry = getCondition<ldmx::HcalGeometry>(
31
32 std::map<ldmx::HcalID, double> simEnergyPerBar;
33 int hitMultiplicity{0};
34
35 for (const auto &hit : hits) {
36 ldmx::HcalID id(hit.getID());
37 if (skipHit(id)) {
38 continue;
39 }
40 const auto energy{hit.getEdep()};
41 if (simEnergyPerBar.count(id) == 0) {
42 simEnergyPerBar[id] = energy;
43 } else {
44 simEnergyPerBar[id] += energy;
45 }
46 const auto orientation{geometry.getScintillatorOrientation(id)};
47 const auto layer{id.layer()};
48 const auto strip{id.strip()};
49 const auto pos{hit.getPosition()};
50 const auto x{pos[0]};
51 const auto y{pos[1]};
52 const auto z{pos[2]};
53 const auto t{hit.getTime()};
54 hitMultiplicity++;
55 histograms_.fill("sim_hit_time", t);
56 histograms_.fill("sim_layer", layer);
57 histograms_.fill("sim_layer:strip", layer, strip);
58 histograms_.fill("sim_energy", energy);
59 switch (orientation) {
60 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
61 histograms_.fill("sim_along_x", x);
62 break;
63 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
64 histograms_.fill("sim_along_y", y);
65 break;
66 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
67 histograms_.fill("sim_along_z", z);
68 break;
69 }
70 }
71
72 histograms_.fill("sim_hit_multiplicity", hitMultiplicity);
73 histograms_.fill("sim_num_bars_hit", simEnergyPerBar.size());
74
75 double total_energy{0};
76 for (const auto [id, energy] : simEnergyPerBar) {
77 histograms_.fill("sim_energy_per_bar", energy);
78 total_energy += energy;
79 }
80 histograms_.fill("sim_total_energy", total_energy);
81}
82void HCalDQM::analyzeRecHits(const std::vector<ldmx::HcalHit> &hits) {
83 const auto &geometry = getCondition<ldmx::HcalGeometry>(
85
86 float totalPE{0};
87 float maxPE{-1};
88 float maxPETime{-1};
89 float totalE{0};
90 int vetoableHitMultiplicity{0};
91 int hitMultiplicity{0};
92
93 for (const ldmx::HcalHit &hit : hits) {
94 ldmx::HcalID id(hit.getID());
95 const auto orientation{geometry.getScintillatorOrientation(id)};
96 const auto section{id.section()};
97 const auto layer{id.layer()};
98 const auto strip{id.strip()};
99 if (skipHit(id)) {
100 continue;
101 }
102
103 if (hit.isNoise()) {
104 histograms_.fill("noise", 1);
105 } else {
106 histograms_.fill("noise", 0);
107 }
108 if (hitPassesVeto(hit, section)) {
109 hitMultiplicity++;
110 } else {
111 hitMultiplicity++;
112 vetoableHitMultiplicity++;
113 }
114 const auto pe{hit.getPE()};
115 const auto t{hit.getTime()};
116 const auto e{hit.getEnergy()};
117 const auto x{hit.getXPos()};
118 const auto y{hit.getYPos()};
119 const auto z{hit.getZPos()};
120 switch (orientation) {
121 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
122 histograms_.fill("along_x", x);
123 break;
124 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
125 histograms_.fill("along_y", y);
126 break;
127 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
128 histograms_.fill("along_z", z);
129 break;
130 }
131 totalE += e;
132 totalPE += pe;
133
134 if (pe > maxPE) {
135 maxPE = pe;
136 maxPETime = t;
137 }
138 histograms_.fill("layer:strip", layer, strip);
139 histograms_.fill("pe", pe);
140 histograms_.fill("hit_time", t);
141 histograms_.fill("layer", layer);
142 histograms_.fill("noise", hit.isNoise());
143 histograms_.fill("energy", e);
144 histograms_.fill("hit_z", z);
145 }
146 histograms_.fill("total_energy", totalE);
147 histograms_.fill("total_pe", totalPE);
148 histograms_.fill("max_pe", maxPE);
149 histograms_.fill("max_pe_time", maxPETime);
150 histograms_.fill("hit_multiplicity", hitMultiplicity);
151 histograms_.fill("vetoable_hit_multiplicity", vetoableHitMultiplicity);
152}
153
154} // namespace dqm
155
156DECLARE_ANALYZER_NS(dqm, HCalDQM)
#define DECLARE_ANALYZER_NS(NS, CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
std::string sim_pass_name_
Hcal Sim Hits pass name.
Definition HCalDQM.h:74
HCalDQM(const std::string &name, framework::Process &process)
Constructor.
Definition HCalDQM.cxx:5
void analyze(const framework::Event &event) override
Process the event and make histograms ro summaries.
Definition HCalDQM.cxx:18
std::string rec_pass_name_
Hcal Rec Hits pass name.
Definition HCalDQM.h:79
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
Definition HCalDQM.cxx:8
std::string rec_coll_name_
Hcal Rec Hits collection name.
Definition HCalDQM.h:76
std::string sim_coll_name_
Hcal Sim Hits collection name.
Definition HCalDQM.h:71
HistogramHelper histograms_
Interface class for making and filling histograms.
Implements an event buffer system for storing event data.
Definition Event.h:41
void fill(const std::string &name, const double &val)
Fill a 1D histogram.
Definition Histograms.h:166
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:23
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
Stores simulated calorimeter hit information.
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45