4#include "DQM/HcalGeometryVerifier.h"
12 hcal_sim_hits_collection_ = parameters.
get<std::string>(
"sim_coll_name");
13 hcal_rec_hits_collection_ = parameters.
get<std::string>(
"rec_coll_name");
14 hcal_sim_hits_pass_name_ = parameters.
get<std::string>(
"sim_pass_name");
15 hcal_rec_hits_pass_name_ = parameters.
get<std::string>(
"rec_pass_name");
16 stop_on_error_ = parameters.
get<
bool>(
"stop_on_error");
17 tolerance_ = parameters.
get<
double>(
"tolerance_");
21 hcal_sim_hits_collection_, hcal_sim_hits_pass_name_);
22 const auto hcal_rec_hits =
event.getCollection<
ldmx::HcalHit>(
23 hcal_rec_hits_collection_, hcal_rec_hits_pass_name_);
25 for (
const auto& hit : hcal_sim_hits) {
26 const ldmx::HcalID id{
static_cast<unsigned int>(hit.getID())};
27 const auto position{hit.getPosition()};
28 auto ok{hitOk(
id, {position[0], position[1], position[2]})};
30 switch (
id.section()) {
31 case ldmx::HcalID::HcalSection::BACK:
34 case ldmx::HcalID::HcalSection::TOP:
37 case ldmx::HcalID::HcalSection::BOTTOM:
40 case ldmx::HcalID::HcalSection::LEFT:
43 case ldmx::HcalID::HcalSection::RIGHT:
48 for (
const auto& hit : hcal_rec_hits) {
49 const ldmx::HcalID id{
static_cast<unsigned int>(hit.getID())};
50 auto ok{hitOk(
id, {hit.getXPos(), hit.getYPos(), hit.getZPos()})};
52 switch (
id.section()) {
53 case ldmx::HcalID::HcalSection::BACK:
56 case ldmx::HcalID::HcalSection::TOP:
59 case ldmx::HcalID::HcalSection::BOTTOM:
62 case ldmx::HcalID::HcalSection::LEFT:
65 case ldmx::HcalID::HcalSection::RIGHT:
73 const std::array<double, 3>& position) {
76 auto [index_along, index_across, index_through]{determineIndices(
id)};
77 const auto center_vec = geometry.getStripCenterPosition(
id);
78 const std::array<double, 3> center{center_vec.X(), center_vec.Y(),
80 const auto length{geometry.getScintillatorLength(
id)};
81 bool outside_bounds_along{
82 std::abs(position[index_along] - center[index_along]) >
83 length / 2 + tolerance_};
85 const auto width{geometry.getScintillatorWidth()};
86 bool outside_bounds_across{
87 std::abs(position[index_across] - center[index_across]) >
88 width / 2 + tolerance_};
90 const auto thickness{geometry.getScintillatorThickness()};
91 bool outside_bounds_through{
92 std::abs(position[index_through] - center[index_through]) >
93 thickness / 2 + tolerance_};
95 if (outside_bounds_along || outside_bounds_across || outside_bounds_through) {
102 ss.precision(-std::log10(tolerance_) + 1);
104 ss << std::boolalpha;
105 double x{position[0]};
106 double y{position[1]};
107 double z{position[2]};
108 ss <<
id <<
" has hit position at (" << x <<
", " << y <<
", " << z
109 <<
")\nwhich is not within the bounds of the Hcal strip center ("
110 << center[0] <<
", " << center[1] <<
", " << center[2]
111 <<
") with tolerance_ " << tolerance_ << std::endl;
112 ss <<
"Position along the bar: " << position[index_along] <<
" outside "
113 << center[index_along] <<
" +- " << length / 2 <<
"? "
114 << outside_bounds_along << std::endl;
115 ss <<
"Position across the bar: " << position[index_across] <<
" outside "
116 << center[index_across] <<
" +- " << width / 2 <<
"? "
117 << outside_bounds_across << std::endl;
118 ss <<
"Position through the bar: " << position[index_through] <<
" outside "
119 << center[index_through] <<
" +- " << thickness / 2 <<
"? "
120 << outside_bounds_through << std::endl;
122 if (stop_on_error_) {
123 EXCEPTION_RAISE(
"InvalidPosition", ss.str());
125 ldmx_log(warn) << ss.str();
131std::array<int, 3> HcalGeometryVerifier::determineIndices(
135 const auto orientation{geometry.getScintillatorOrientation(
id)};
136 const auto is_lr{
id.section() == ldmx::HcalID::HcalSection::LEFT ||
137 id.section() == ldmx::HcalID::HcalSection::RIGHT};
142 if (
id.section() == ldmx::HcalID::HcalSection::BACK) {
145 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
152 }
else if (geometry.hasSide3DReadout()) {
153 switch (orientation) {
154 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
160 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
166 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
183 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
191 return {index_along, index_across, index_through};
#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.
Class that stores Stores reconstructed hit information from the HCAL.
Class which stores simulated calorimeter hit information.
void configure(framework::config::Parameters ¶meters) override
Callback for the EventProcessor to configure itself from the given set of parameters.
void analyze(const framework::Event &event) override
Process the event and make histograms or summaries.
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.
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
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.
Implements detector ids for HCal subdetector.
Stores simulated calorimeter hit information.