LDMX Software
HCalDQM.cxx
1
2#include "DQM/HCalDQM.h"
3
4#include <map>
5
7namespace dqm {
8
9HCalDQM::HCalDQM(const std::string& name, framework::Process& process)
10 : framework::Analyzer(name, process) {}
11
13 rec_coll_name_ = ps.get<std::string>("rec_coll_name");
14 rec_pass_name_ = ps.get<std::string>("rec_pass_name");
15 sim_coll_name_ = ps.get<std::string>("sim_coll_name");
16 sim_pass_name_ = ps.get<std::string>("sim_pass_name");
17 pe_veto_threshold_ = ps.get<double>("pe_veto_threshold");
18 section_ = ps.get<int>("section");
19 max_hit_time_ = ps.get<double>("max_hit_time");
20}
21
23 // Get the collection of HCalDQM digitized hits if the exists
24 const auto& hcal_hits{
25 event.getCollection<ldmx::HcalHit>(rec_coll_name_, rec_pass_name_)};
26
27 const auto& hcal_sim_hits{event.getCollection<ldmx::SimCalorimeterHit>(
29 analyzeSimHits(hcal_sim_hits);
30 analyzeRecHits(hcal_hits);
31}
32void HCalDQM::analyzeSimHits(const std::vector<ldmx::SimCalorimeterHit>& hits) {
33 const auto& geometry = getCondition<ldmx::HcalGeometry>(
35
36 std::map<ldmx::HcalID, double> sim_energy_per_bar;
37 int hit_multiplicity{0};
38
39 for (const auto& hit : hits) {
40 ldmx::HcalID id(hit.getID());
41 if (skipHit(id)) {
42 continue;
43 }
44 const auto energy{hit.getEdep()};
45 if (sim_energy_per_bar.count(id) == 0) {
46 sim_energy_per_bar[id] = energy;
47 } else {
48 sim_energy_per_bar[id] += energy;
49 }
50 const auto orientation{geometry.getScintillatorOrientation(id)};
51 const auto layer{id.layer()};
52 const auto strip{id.strip()};
53 const auto pos{hit.getPosition()};
54 const auto x{pos[0]};
55 const auto y{pos[1]};
56 const auto z{pos[2]};
57 const auto t{hit.getTime()};
58 hit_multiplicity++;
59 histograms_.fill("sim_hit_time", t);
60 histograms_.fill("sim_layer", layer);
61 histograms_.fill("sim_layer:strip", layer, strip);
62 histograms_.fill("sim_energy", energy);
63 switch (orientation) {
64 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
65 histograms_.fill("sim_along_x", x);
66 break;
67 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
68 histograms_.fill("sim_along_y", y);
69 break;
70 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
71 histograms_.fill("sim_along_z", z);
72 break;
73 }
74 }
75
76 histograms_.fill("sim_hit_multiplicity", hit_multiplicity);
77 histograms_.fill("sim_num_bars_hit", sim_energy_per_bar.size());
78
79 double total_energy{0};
80 for (const auto [id, energy] : sim_energy_per_bar) {
81 histograms_.fill("sim_energy_per_bar", energy);
82 total_energy += energy;
83 }
84 histograms_.fill("sim_total_energy", total_energy);
85}
86void HCalDQM::analyzeRecHits(const std::vector<ldmx::HcalHit>& hits) {
87 const auto& geometry = getCondition<ldmx::HcalGeometry>(
89
90 float total_pe{0};
91 float max_pe{-1};
92 float max_pe_time{-1};
93 float max_pe_adc{-1};
94 float max_pe_adc_time{-1};
95 float total_e{0};
96 int vetoable_hit_multiplicity{0};
97 int hit_multiplicity{0};
98
99 for (const ldmx::HcalHit& hit : hits) {
100 ldmx::HcalID id(hit.getID());
101 const auto orientation{geometry.getScintillatorOrientation(id)};
102 const auto section{id.section()};
103 const auto layer{id.layer()};
104 const auto strip{id.strip()};
105 if (skipHit(id)) {
106 continue;
107 }
108
109 if (hit.isNoise()) {
110 histograms_.fill("noise", 1);
111 } else {
112 histograms_.fill("noise", 0);
113 }
114 if (hitPassesVeto(hit, section)) {
115 hit_multiplicity++;
116 } else {
117 hit_multiplicity++;
118 vetoable_hit_multiplicity++;
119 }
120 const auto pe{hit.getPE()};
121 const auto t{hit.getTime()};
122 const auto e{hit.getEnergy()};
123 const auto x{hit.getXPos()};
124 const auto y{hit.getYPos()};
125 const auto z{hit.getZPos()};
126 switch (orientation) {
127 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
128 histograms_.fill("along_x", x);
129 break;
130 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
131 histograms_.fill("along_y", y);
132 break;
133 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
134 histograms_.fill("along_z", z);
135 break;
136 }
137 total_e += e;
138 total_pe += pe;
139
140 if (pe > max_pe) {
141 max_pe = pe;
142 max_pe_time = t;
143 }
144
145 // Track max PE for ADC mode only
146 if (hit.getIsADC()) {
147 if (pe > max_pe_adc) {
148 max_pe_adc = pe;
149 max_pe_adc_time = t;
150 }
151 }
152
153 histograms_.fill("layer:strip", layer, strip);
154 histograms_.fill("pe", pe);
155 histograms_.fill("hit_time", t);
156 histograms_.fill("layer", layer);
157 histograms_.fill("noise", hit.isNoise());
158 histograms_.fill("energy", e);
159 histograms_.fill("hit_z", z);
160 }
161 histograms_.fill("total_energy", total_e);
162 histograms_.fill("total_pe", total_pe);
163 histograms_.fill("max_pe", max_pe);
164 histograms_.fill("max_pe_time", max_pe_time);
165 histograms_.fill("max_pe_adc", max_pe_adc);
166 histograms_.fill("max_pe_adc_time", max_pe_adc_time);
167 histograms_.fill("hit_multiplicity", hit_multiplicity);
168 histograms_.fill("vetoable_hit_multiplicity", vetoable_hit_multiplicity);
169}
170
171} // namespace dqm
172
#define DECLARE_ANALYZER(CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
Class that translates HCal ID into positions of strip hits.
std::string sim_pass_name_
Hcal Sim Hits pass name.
Definition HCalDQM.h:67
HCalDQM(const std::string &name, framework::Process &process)
Constructor.
Definition HCalDQM.cxx:9
void analyze(const framework::Event &event) override
Process the event and make histograms ro summaries.
Definition HCalDQM.cxx:22
std::string rec_pass_name_
Hcal Rec Hits pass name.
Definition HCalDQM.h:72
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
Definition HCalDQM.cxx:12
std::string rec_coll_name_
Hcal Rec Hits collection name.
Definition HCalDQM.h:69
std::string sim_coll_name_
Hcal Sim Hits collection name.
Definition HCalDQM.h:64
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:40
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Class which represents the process under execution.
Definition Process.h:34
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
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.