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.get<std::string>("rec_coll_name");
10 rec_pass_name_ = ps.get<std::string>("rec_pass_name");
11 sim_coll_name_ = ps.get<std::string>("sim_coll_name");
12 sim_pass_name_ = ps.get<std::string>("sim_pass_name");
13 pe_veto_threshold_ = ps.get<double>("pe_veto_threshold");
14 section_ = ps.get<int>("section");
15 max_hit_time_ = ps.get<double>("max_hit_time");
16}
17
19 // Get the collection of HCalDQM digitized hits if the exists
20 const auto &hcal_hits{
21 event.getCollection<ldmx::HcalHit>(rec_coll_name_, rec_pass_name_)};
22
23 const auto &hcal_sim_hits{event.getCollection<ldmx::SimCalorimeterHit>(
25 analyzeSimHits(hcal_sim_hits);
26 analyzeRecHits(hcal_hits);
27}
28void HCalDQM::analyzeSimHits(const std::vector<ldmx::SimCalorimeterHit> &hits) {
29 const auto &geometry = getCondition<ldmx::HcalGeometry>(
31
32 std::map<ldmx::HcalID, double> sim_energy_per_bar;
33 int hit_multiplicity{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 (sim_energy_per_bar.count(id) == 0) {
42 sim_energy_per_bar[id] = energy;
43 } else {
44 sim_energy_per_bar[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 hit_multiplicity++;
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", hit_multiplicity);
73 histograms_.fill("sim_num_bars_hit", sim_energy_per_bar.size());
74
75 double total_energy{0};
76 for (const auto [id, energy] : sim_energy_per_bar) {
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 total_pe{0};
87 float max_pe{-1};
88 float max_pe_time{-1};
89 float max_pe_adc{-1};
90 float max_pe_adc_time{-1};
91 float total_e{0};
92 int vetoable_hit_multiplicity{0};
93 int hit_multiplicity{0};
94
95 for (const ldmx::HcalHit &hit : hits) {
96 ldmx::HcalID id(hit.getID());
97 const auto orientation{geometry.getScintillatorOrientation(id)};
98 const auto section{id.section()};
99 const auto layer{id.layer()};
100 const auto strip{id.strip()};
101 if (skipHit(id)) {
102 continue;
103 }
104
105 if (hit.isNoise()) {
106 histograms_.fill("noise", 1);
107 } else {
108 histograms_.fill("noise", 0);
109 }
110 if (hitPassesVeto(hit, section)) {
111 hit_multiplicity++;
112 } else {
113 hit_multiplicity++;
114 vetoable_hit_multiplicity++;
115 }
116 const auto pe{hit.getPE()};
117 const auto t{hit.getTime()};
118 const auto e{hit.getEnergy()};
119 const auto x{hit.getXPos()};
120 const auto y{hit.getYPos()};
121 const auto z{hit.getZPos()};
122 switch (orientation) {
123 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
124 histograms_.fill("along_x", x);
125 break;
126 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
127 histograms_.fill("along_y", y);
128 break;
129 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
130 histograms_.fill("along_z", z);
131 break;
132 }
133 total_e += e;
134 total_pe += pe;
135
136 if (pe > max_pe) {
137 max_pe = pe;
138 max_pe_time = t;
139 }
140
141 // Track max PE for ADC mode only
142 if (hit.getIsADC()) {
143 if (pe > max_pe_adc) {
144 max_pe_adc = pe;
145 max_pe_adc_time = t;
146 }
147 }
148
149 histograms_.fill("layer:strip", layer, strip);
150 histograms_.fill("pe", pe);
151 histograms_.fill("hit_time", t);
152 histograms_.fill("layer", layer);
153 histograms_.fill("noise", hit.isNoise());
154 histograms_.fill("energy", e);
155 histograms_.fill("hit_z", z);
156 }
157 histograms_.fill("total_energy", total_e);
158 histograms_.fill("total_pe", total_pe);
159 histograms_.fill("max_pe", max_pe);
160 histograms_.fill("max_pe_time", max_pe_time);
161 histograms_.fill("max_pe_adc", max_pe_adc);
162 histograms_.fill("max_pe_adc_time", max_pe_adc_time);
163 histograms_.fill("hit_multiplicity", hit_multiplicity);
164 histograms_.fill("vetoable_hit_multiplicity", vetoable_hit_multiplicity);
165}
166
167} // namespace dqm
168
#define DECLARE_ANALYZER(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
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
HistogramPool histograms_
helper object for making and filling histograms
Implements an event buffer system for storing event data.
Definition Event.h:42
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Class which represents the process under execution.
Definition Process.h:37
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
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:24
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.