1#include "DQM/HcalGeometryVerifier.h"
6 hcal_sim_hits_collection_ = parameters.
get<std::string>(
"sim_coll_name");
7 hcal_rec_hits_collection_ = parameters.
get<std::string>(
"rec_coll_name");
8 hcal_sim_hits_pass_name_ = parameters.
get<std::string>(
"sim_pass_name");
9 hcal_rec_hits_pass_name_ = parameters.
get<std::string>(
"rec_pass_name");
10 stop_on_error_ = parameters.
get<
bool>(
"stop_on_error");
11 tolerance_ = parameters.
get<
double>(
"tolerance_");
15 hcal_sim_hits_collection_, hcal_sim_hits_pass_name_);
16 const auto hcal_rec_hits =
event.getCollection<
ldmx::HcalHit>(
17 hcal_rec_hits_collection_, hcal_rec_hits_pass_name_);
19 for (
const auto &hit : hcal_sim_hits) {
20 const ldmx::HcalID id{
static_cast<unsigned int>(hit.getID())};
21 const auto position{hit.getPosition()};
22 auto ok{hitOk(
id, {position[0], position[1], position[2]})};
24 switch (
id.section()) {
25 case ldmx::HcalID::HcalSection::BACK:
28 case ldmx::HcalID::HcalSection::TOP:
31 case ldmx::HcalID::HcalSection::BOTTOM:
34 case ldmx::HcalID::HcalSection::LEFT:
37 case ldmx::HcalID::HcalSection::RIGHT:
42 for (
const auto &hit : hcal_rec_hits) {
43 const ldmx::HcalID id{
static_cast<unsigned int>(hit.getID())};
44 auto ok{hitOk(
id, {hit.getXPos(), hit.getYPos(), hit.getZPos()})};
46 switch (
id.section()) {
47 case ldmx::HcalID::HcalSection::BACK:
50 case ldmx::HcalID::HcalSection::TOP:
53 case ldmx::HcalID::HcalSection::BOTTOM:
56 case ldmx::HcalID::HcalSection::LEFT:
59 case ldmx::HcalID::HcalSection::RIGHT:
67 const std::array<double, 3> &position) {
70 auto [index_along, index_across, index_through]{determineIndices(
id)};
71 const auto center_vec = geometry.getStripCenterPosition(
id);
72 const std::array<double, 3> center{center_vec.X(), center_vec.Y(),
74 const auto length{geometry.getScintillatorLength(
id)};
75 bool outside_bounds_along{
76 std::abs(position[index_along] - center[index_along]) >
77 length / 2 + tolerance_};
79 const auto width{geometry.getScintillatorWidth()};
80 bool outside_bounds_across{
81 std::abs(position[index_across] - center[index_across]) >
82 width / 2 + tolerance_};
84 const auto thickness{geometry.getScintillatorThickness()};
85 bool outside_bounds_through{
86 std::abs(position[index_through] - center[index_through]) >
87 thickness / 2 + tolerance_};
89 if (outside_bounds_along || outside_bounds_across || outside_bounds_through) {
96 ss.precision(-std::log10(tolerance_) + 1);
99 double x{position[0]};
100 double y{position[1]};
101 double z{position[2]};
102 ss <<
id <<
" has hit position at (" << x <<
", " << y <<
", " << z
103 <<
")\nwhich is not within the bounds of the Hcal strip center ("
104 << center[0] <<
", " << center[1] <<
", " << center[2]
105 <<
") with tolerance_ " << tolerance_ << std::endl;
106 ss <<
"Position along the bar: " << position[index_along] <<
" outside "
107 << center[index_along] <<
" +- " << length / 2 <<
"? "
108 << outside_bounds_along << std::endl;
109 ss <<
"Position across the bar: " << position[index_across] <<
" outside "
110 << center[index_across] <<
" +- " << width / 2 <<
"? "
111 << outside_bounds_across << std::endl;
112 ss <<
"Position through the bar: " << position[index_through] <<
" outside "
113 << center[index_through] <<
" +- " << thickness / 2 <<
"? "
114 << outside_bounds_through << std::endl;
116 if (stop_on_error_) {
117 EXCEPTION_RAISE(
"InvalidPosition", ss.str());
119 ldmx_log(warn) << ss.str();
125std::array<int, 3> HcalGeometryVerifier::determineIndices(
129 const auto orientation{geometry.getScintillatorOrientation(
id)};
130 const auto is_lr{
id.section() == ldmx::HcalID::HcalSection::LEFT ||
131 id.section() == ldmx::HcalID::HcalSection::RIGHT};
136 if (
id.section() == ldmx::HcalID::HcalSection::BACK) {
139 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
146 }
else if (geometry.hasSide3DReadout()) {
147 switch (orientation) {
148 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
154 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
160 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
177 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
185 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.
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.