1#include "DQM/HcalGeometryVerifier.h"
6 hcalSimHitsCollection_ =
8 hcalRecHitsCollection_ =
10 hcalSimHitsPassName_ = parameters.
getParameter<std::string>(
"sim_pass_name");
11 hcalRecHitsPassName_ = parameters.
getParameter<std::string>(
"rec_pass_name");
12 stop_on_error = parameters.
getParameter<
bool>(
"stop_on_error");
13 tolerance = parameters.
getParameter<
double>(
"tolerance");
17 hcalSimHitsCollection_, hcalSimHitsPassName_);
19 hcalRecHitsCollection_, hcalRecHitsPassName_);
21 for (
const auto &hit : hcalSimHits) {
22 const ldmx::HcalID id{
static_cast<unsigned int>(hit.getID())};
23 const auto position{hit.getPosition()};
24 auto ok{hit_ok(
id, {position[0], position[1], position[2]})};
26 switch (
id.section()) {
27 case ldmx::HcalID::HcalSection::BACK:
30 case ldmx::HcalID::HcalSection::TOP:
33 case ldmx::HcalID::HcalSection::BOTTOM:
36 case ldmx::HcalID::HcalSection::LEFT:
39 case ldmx::HcalID::HcalSection::RIGHT:
44 for (
const auto &hit : hcalRecHits) {
45 const ldmx::HcalID id{
static_cast<unsigned int>(hit.getID())};
46 auto ok{hit_ok(
id, {hit.getXPos(), hit.getYPos(), hit.getZPos()})};
48 switch (
id.section()) {
49 case ldmx::HcalID::HcalSection::BACK:
52 case ldmx::HcalID::HcalSection::TOP:
55 case ldmx::HcalID::HcalSection::BOTTOM:
58 case ldmx::HcalID::HcalSection::LEFT:
61 case ldmx::HcalID::HcalSection::RIGHT:
69 const std::array<double, 3> &position) {
70 const auto &geometry = getCondition<ldmx::HcalGeometry>(
72 auto [index_along, index_across, index_through]{determine_indices(
id)};
73 const auto center{geometry.getStripCenterPosition(
id)};
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;
117 EXCEPTION_RAISE(
"InvalidPosition", ss.str());
119 ldmx_log(warn) << ss.str();
125std::array<int, 3> HcalGeometryVerifier::determine_indices(
127 const auto &geometry = getCondition<ldmx::HcalGeometry>(
129 const auto orientation{geometry.getScintillatorOrientation(
id)};
130 const auto isLR{
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_NS(NS, 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.
HistogramHelper histograms_
Interface class for making and filling histograms.
Implements an event buffer system for storing event data.
void fill(const std::string &name, const double &val)
Fill a 1D histogram.
Class encapsulating parameters for configuring a processor.
T getParameter(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.