22 back_horizontal_parity_ = ps.
getParameter<
int>(
"back_horizontal_parity");
23 side_3d_readout_ = ps.
getParameter<
int>(
"side_3d_readout");
26 auto detectors_valid =
27 ps.
getParameter<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.
getParameter<std::vector<std::vector<double>>>(
"half_total_width");
41 ps.
getParameter<std::vector<std::vector<double>>>(
"scint_length");
50 const std::vector<double> &globalPosition,
const ldmx::HcalID &
id)
const {
51 const auto orientation{getScintillatorOrientation(
id)};
52 switch (
id.section()) {
53 case ldmx::HcalID::HcalSection::BACK:
54 switch (orientation) {
55 case ScintillatorOrientation::horizontal:
56 return {globalPosition[2], globalPosition[1], globalPosition[0]};
57 case ScintillatorOrientation::vertical:
58 return {globalPosition[2], globalPosition[0], globalPosition[1]};
60 EXCEPTION_RAISE(
"InvalidRotation",
61 "Attempted to rotate into an invalid "
62 "orientation for a scintillator bar!");
64 case ldmx::HcalID::HcalSection::TOP:
66 case ldmx::HcalID::HcalSection::BOTTOM:
67 switch (orientation) {
68 case ScintillatorOrientation::horizontal:
69 return {globalPosition[1], globalPosition[2], globalPosition[0]};
70 case ScintillatorOrientation::depth:
71 return {globalPosition[1], globalPosition[0], globalPosition[2]};
73 EXCEPTION_RAISE(
"InvalidRotation",
74 "Attempted to rotate into an invalid "
75 "orientation for a scintillator bar!");
77 case ldmx::HcalID::HcalSection::LEFT:
79 case ldmx::HcalID::HcalSection::RIGHT:
80 switch (orientation) {
81 case ScintillatorOrientation::vertical:
82 return {globalPosition[0], globalPosition[2], globalPosition[1]};
83 case ScintillatorOrientation::depth:
84 return globalPosition;
86 EXCEPTION_RAISE(
"InvalidRotation",
87 "Attempted to rotate into an invalid "
88 "orientation for a scintillator bar!");
94 EXCEPTION_RAISE(
"InvalidRotation",
95 "Attempted to rotate into an invalid "
96 "orientation for a scintillator bar!");
104 switch (
id.section()) {
105 case ldmx::HcalID::HcalSection::TOP:
106 case ldmx::HcalID::HcalSection::BOTTOM:
109 return id.layer() % 2 == 0 ? ScintillatorOrientation::horizontal
110 : ScintillatorOrientation::depth;
112 case ldmx::HcalID::HcalSection::LEFT:
113 case ldmx::HcalID::HcalSection::RIGHT:
116 return id.layer() % 2 == 0 ? ScintillatorOrientation::vertical
117 : ScintillatorOrientation::depth;
118 case ldmx::HcalID::HcalSection::BACK:
120 return id.layer() % 2 == back_horizontal_parity_
121 ? ScintillatorOrientation::horizontal
122 : ScintillatorOrientation::vertical;
129 return id.layer() % 2 == back_horizontal_parity_
130 ? ScintillatorOrientation::horizontal
131 : ScintillatorOrientation::vertical;
134 switch (
id.section()) {
137 case ldmx::HcalID::HcalSection::TOP:
138 case ldmx::HcalID::HcalSection::BOTTOM:
139 return ScintillatorOrientation::horizontal;
140 case ldmx::HcalID::HcalSection::LEFT:
141 case ldmx::HcalID::HcalSection::RIGHT:
142 return ScintillatorOrientation::vertical;
143 case ldmx::HcalID::HcalSection::BACK:
145 return id.layer() % 2 == back_horizontal_parity_
146 ? ScintillatorOrientation::horizontal
147 : ScintillatorOrientation::vertical;
152 EXCEPTION_RAISE(
"InvalidRotation",
153 "Attempted to rotate into an invalid "
154 "orientation for a scintillator bar!");
158 for (
int layer = 1; layer <=
num_layers_[section]; ++layer) {
159 for (
int strip = 0; strip <
getNumStrips(section, layer); ++strip) {
160 HcalID id(section, layer, strip);
162 auto x = centerPosition[0];
163 auto y = centerPosition[1];
164 auto z = centerPosition[2];
165 std::cout <<
id <<
": Center position: (" << x <<
", " << y <<
", " << z
173 for (
unsigned int section = 0; section <
num_sections_; section++) {
174 for (
unsigned int layer = 1; layer <=
num_layers_[section]; layer++) {
175 for (
unsigned int strip = 0; strip <
getNumStrips(section, layer);
178 double x{-99999}, y{-99999}, z{-99999};
185 const auto orientation{getScintillatorOrientation(
id)};
194 if (hcalsection == ldmx::HcalID::HcalSection::BACK) {
213 if (orientation == ScintillatorOrientation::horizontal) {
221 if (side_3d_readout_) {
232 switch (hcalsection) {
233 case ldmx::HcalID::HcalSection::BACK:
235 case ldmx::HcalID::HcalSection::LEFT:
236 case ldmx::HcalID::HcalSection::RIGHT:
237 if (orientation == ScintillatorOrientation::vertical) {
246 }
else if (orientation == ScintillatorOrientation::depth) {
253 if (section == ldmx::HcalID::HcalSection::LEFT) {
259 case ldmx::HcalID::HcalSection::BOTTOM:
260 case ldmx::HcalID::HcalSection::TOP:
261 if (orientation == ScintillatorOrientation::horizontal) {
276 if (orientation == ScintillatorOrientation::depth) {
283 if (section == ldmx::HcalID::HcalSection::BOTTOM) {
302 if (hcalsection == ldmx::HcalID::HcalSection::TOP or
303 hcalsection == ldmx::HcalID::HcalSection::BOTTOM) {
306 if (hcalsection == ldmx::HcalID::HcalSection::BOTTOM) {
314 if (hcalsection == ldmx::HcalID::HcalSection::RIGHT) {
Class that translates HCal ID into positions of strip hits.
Class encapsulating parameters for configuring a processor.
T getParameter(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?
TVector3 getStripCenterPosition(ldmx::HcalID id) const
Get a strip center position from a combined hcal ID.
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].
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::map< ldmx::HcalID, TVector3 > strip_position_map_
Map of the HcalID position of strip centers relative to world geometry.
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.