8#include "Framework/Exception/Exception.h"
21 ecal_dy_ = ps.
get<
double>(
"ecal_dy");
23 back_horizontal_parity_ = ps.
get<
int>(
"back_horizontal_parity");
24 side_3d_readout_ = ps.
get<
int>(
"side_3d_readout");
25 y_offset_ = ps.
get<
double>(
"y_offset");
27 auto detectors_valid = ps.
get<std::vector<std::string>>(
"detectors_valid");
30 is_prototype_ = std::find_if(detectors_valid.cbegin(), detectors_valid.cend(),
31 [](
const auto detector) {
32 return detector.find(
"ldmx-hcal-prototype") !=
34 }) != detectors_valid.cend();
38 ps.
get<std::vector<std::vector<double>>>(
"half_total_width");
39 zero_strip_ = ps.
get<std::vector<std::vector<double>>>(
"zero_strip");
49 const std::vector<double>& globalPosition,
const ldmx::HcalID&
id)
const {
50 const auto orientation{getScintillatorOrientation(
id)};
51 switch (
id.section()) {
52 case ldmx::HcalID::HcalSection::BACK:
53 switch (orientation) {
54 case ScintillatorOrientation::horizontal:
55 return {globalPosition[2], globalPosition[1], globalPosition[0]};
56 case ScintillatorOrientation::vertical:
57 return {globalPosition[2], globalPosition[0], globalPosition[1]};
59 EXCEPTION_RAISE(
"InvalidRotation",
60 "Attempted to rotate into an invalid "
61 "orientation for a scintillator bar!");
63 case ldmx::HcalID::HcalSection::TOP:
65 case ldmx::HcalID::HcalSection::BOTTOM:
66 switch (orientation) {
67 case ScintillatorOrientation::horizontal:
68 return {globalPosition[1], globalPosition[2], globalPosition[0]};
69 case ScintillatorOrientation::depth:
70 return {globalPosition[1], globalPosition[0], globalPosition[2]};
72 EXCEPTION_RAISE(
"InvalidRotation",
73 "Attempted to rotate into an invalid "
74 "orientation for a scintillator bar!");
76 case ldmx::HcalID::HcalSection::LEFT:
78 case ldmx::HcalID::HcalSection::RIGHT:
79 switch (orientation) {
80 case ScintillatorOrientation::vertical:
81 return {globalPosition[0], globalPosition[2], globalPosition[1]};
82 case ScintillatorOrientation::depth:
83 return globalPosition;
85 EXCEPTION_RAISE(
"InvalidRotation",
86 "Attempted to rotate into an invalid "
87 "orientation for a scintillator bar!");
93 EXCEPTION_RAISE(
"InvalidRotation",
94 "Attempted to rotate into an invalid "
95 "orientation for a scintillator bar!");
103 switch (
id.section()) {
104 case ldmx::HcalID::HcalSection::TOP:
105 case ldmx::HcalID::HcalSection::BOTTOM:
108 return id.layer() % 2 == 0 ? ScintillatorOrientation::horizontal
109 : ScintillatorOrientation::depth;
111 case ldmx::HcalID::HcalSection::LEFT:
112 case ldmx::HcalID::HcalSection::RIGHT:
115 return id.layer() % 2 == 0 ? ScintillatorOrientation::vertical
116 : ScintillatorOrientation::depth;
117 case ldmx::HcalID::HcalSection::BACK:
119 return id.layer() % 2 == back_horizontal_parity_
120 ? ScintillatorOrientation::horizontal
121 : ScintillatorOrientation::vertical;
128 return id.layer() % 2 == back_horizontal_parity_
129 ? ScintillatorOrientation::horizontal
130 : ScintillatorOrientation::vertical;
133 switch (
id.section()) {
136 case ldmx::HcalID::HcalSection::TOP:
137 case ldmx::HcalID::HcalSection::BOTTOM:
138 return ScintillatorOrientation::horizontal;
139 case ldmx::HcalID::HcalSection::LEFT:
140 case ldmx::HcalID::HcalSection::RIGHT:
141 return ScintillatorOrientation::vertical;
142 case ldmx::HcalID::HcalSection::BACK:
144 return id.layer() % 2 == back_horizontal_parity_
145 ? ScintillatorOrientation::horizontal
146 : ScintillatorOrientation::vertical;
151 EXCEPTION_RAISE(
"InvalidRotation",
152 "Attempted to rotate into an invalid "
153 "orientation for a scintillator bar!");
157 for (
int layer = 1; layer <=
num_layers_[section]; ++layer) {
158 for (
int strip = 0; strip <
getNumStrips(section, layer); ++strip) {
159 HcalID id(section, layer, strip);
161 auto x = center_position.X();
162 auto y = center_position.Y();
163 auto z = center_position.Z();
164 std::cout <<
id <<
": Center position: (" << x <<
", " << y <<
", " << z
172 for (
unsigned int section = 0; section <
num_sections_; section++) {
173 for (
unsigned int layer = 1; layer <=
num_layers_[section]; layer++) {
174 for (
unsigned int strip = 0; strip <
getNumStrips(section, layer);
177 double x{-99999}, y{-99999}, z{-99999};
184 const auto orientation{getScintillatorOrientation(
id)};
193 if (hcalsection == ldmx::HcalID::HcalSection::BACK) {
212 if (orientation == ScintillatorOrientation::horizontal) {
220 if (side_3d_readout_) {
231 switch (hcalsection) {
232 case ldmx::HcalID::HcalSection::BACK:
234 case ldmx::HcalID::HcalSection::LEFT:
235 case ldmx::HcalID::HcalSection::RIGHT:
236 if (orientation == ScintillatorOrientation::vertical) {
245 }
else if (orientation == ScintillatorOrientation::depth) {
252 if (section == ldmx::HcalID::HcalSection::LEFT) {
258 case ldmx::HcalID::HcalSection::BOTTOM:
259 case ldmx::HcalID::HcalSection::TOP:
260 if (orientation == ScintillatorOrientation::horizontal) {
275 if (orientation == ScintillatorOrientation::depth) {
282 if (section == ldmx::HcalID::HcalSection::BOTTOM) {
301 if (hcalsection == ldmx::HcalID::HcalSection::TOP or
302 hcalsection == ldmx::HcalID::HcalSection::BOTTOM) {
305 if (hcalsection == ldmx::HcalID::HcalSection::BOTTOM) {
313 if (hcalsection == ldmx::HcalID::HcalSection::RIGHT) {
322 ROOT::Math::XYZVector pos;
Class that translates HCal ID into positions of strip hits.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Implementation of HCal strip readout.
std::vector< double > layer_thickness_
Thickness of the layers in each section [mm].
bool hasSide3DReadout() const
Does the Side Hcal have 3D readout?
std::vector< double > zero_layer_
Front of HCal relative to world geometry for each section [mm].
double ecal_dx_
Lenght of the Ecal (in x and y)
void buildStripPositionMap()
Map builder of HcalID and position.
std::vector< std::vector< double > > zero_strip_
The plane of the zero'th strip of each section [mm].
ROOT::Math::XYZVector getStripCenterPosition(ldmx::HcalID id) const
Get a strip center position from a combined hcal ID.
std::map< ldmx::HcalID, ROOT::Math::XYZVector > strip_position_map_
Map of the HcalID position of strip centers relative to world geometry.
int getZeroStrip(int isection, int layer=1) const
Get the location of the zeroStrip in a given section and layer.
double getScintillatorLength(ldmx::HcalID id) const
Get the length of a scintillator bar.
void printPositionMap() const
Debugging utility, prints out the HcalID and corresponding value of all entries in the strip_position...
std::vector< std::vector< double > > scint_length_
Length of strips [mm].
HcalGeometry(const framework::config::Parameters &ps)
Class constructor, for use only by the provider.
int verbose_
Parameters that apply to all types of geometries Verbosity, not configurable but helpful if developin...
std::vector< std::vector< double > > half_total_width_
Half Total Width of Strips [mm].
double scint_width_
Width of Scintillator Strip [mm].
std::vector< double > rotateGlobalToLocalBarPosition(const std::vector< double > &globalPosition, const ldmx::HcalID &id) const
Coordinates that are given by Geant4 are typically global.
double getScintillatorWidth() const
Get the scitillator width.
double scint_thickness_
Thickness of scintillator.
std::vector< int > num_layers_
Number of layers in each section.
ScintillatorOrientation
Encodes the orientation of a bar.
int getNumStrips(int isection, int layer=1) const
Get the number of strips per layer for that section and layer.
std::vector< std::vector< int > > num_strips_
Number of strips per layer in each section and each layer.
double getHalfTotalWidth(int isection, int layer=1) const
Get the half total width of a layer for a given section(strip) for back(side) Hcal.
int num_sections_
Number of sections.
Implements detector ids for HCal subdetector.
HcalSection
Encodes the section of the HCal based on the 'section' field value.
All classes in the ldmx-sw project use this namespace.