LDMX Software
HcalGeometry.h
Go to the documentation of this file.
1
6#ifndef DETDESCR_HCALGEOMETRY_H_
7#define DETDESCR_HCALGEOMETRY_H_
8
9// LDMX
10#include "DetDescr/HcalID.h"
12#include "Framework/Configure/Parameters.h"
13
14// ROOT
15#include "Math/Vector3D.h" // IWYU pragma: keep
16
17// STL
18#include <map>
19
20namespace hcal {
21class HcalGeometryProvider;
22}
23
24namespace ldmx {
25
26class HcalGeometryProvider;
27
34 public:
41 static constexpr const char* CONDITIONS_OBJECT_NAME{"hcal_geometry"};
42
50 horizontal = 0,
51 vertical = 1,
52 depth = 2
53 };
54
60 ~HcalGeometry() = default;
61
62 ScintillatorOrientation getScintillatorOrientation(
63 const ldmx::HcalID id) const;
64
74 ROOT::Math::XYZVector getStripCenterPosition(ldmx::HcalID id) const {
75 return strip_position_map_.at(id);
76 }
77
81 std::map<ldmx::HcalID, ROOT::Math::XYZVector> getStripPositionMap() const {
83 }
84
89 bool backLayerIsHorizontal(const int layer) const {
90 return layer % 2 == back_horizontal_parity_;
91 }
99 double getHalfTotalWidth(int isection, int layer = 1) const {
100 // Layer numbering starts at 1, but a vector is zero-indexed
101 auto layer_index = layer - 1;
102 return half_total_width_.at(isection).at(layer_index);
103 }
104
111 return scint_length_.at(id.section()).at(id.layer() - 1);
112 }
116 double getScintillatorWidth() const { return scint_width_; }
117
122
126 int getNumSections() const { return num_sections_; }
127
131 int getNumLayers(int isection) const { return num_layers_.at(isection); }
132
136 int getNumStrips(int isection, int layer = 1) const {
137 auto layer_index = layer - 1;
138 return num_strips_.at(isection).at(layer_index);
139 }
140
144 int getZeroStrip(int isection, int layer = 1) const {
145 auto layer_index = layer - 1;
146 return zero_strip_.at(isection).at(layer_index);
147 }
148
152 double getEcalDx() const { return ecal_dx_; }
153
157 double getEcalDy() const { return ecal_dy_; }
158
165 bool hasSide3DReadout() const { return side_3d_readout_; }
166
167 /*
168 * Is the hcal geometry one of the geometries used for the CERN testbeam
169 * activities?
170 */
171 bool isPrototype() const { return is_prototype_; }
172
176 bool hasExplicitLayout() const { return !layer_z_.empty(); }
177
181 bool isDoubleEnded(int isection) const {
182 if (hasExplicitLayout()) return double_ended_.at(isection) != 0;
183 return isection == ldmx::HcalID::HcalSection::BACK;
184 }
185
192 double getDistanceAlongBar(ldmx::HcalID id, double x, double y,
193 double z) const;
194
217 std::vector<double> rotateGlobalToLocalBarPosition(
218 const std::vector<double>& globalPosition, const ldmx::HcalID& id) const;
219
220 private:
227 friend class hcal::HcalGeometryProvider;
228
246 void printPositionMap(int section) const;
253 void printPositionMap() const {
254 for (int section = 0; section < num_sections_; ++section) {
255 printPositionMap(section);
256 }
257 }
258
259 private:
262 int verbose_{0};
263
266
269
271 std::vector<double> zero_layer_;
272
274 std::vector<double> layer_thickness_;
275
277 std::vector<int> num_layers_;
278
281
283 double ecal_dx_;
284 double ecal_dy_;
285
286 // Offset of the entire Hcal geometry in y (mm)
287 double y_offset_;
288
289 // Defines what parity (0/1, i.e. even/odd parity) of a layer number in the
290 // geometry that corresponds to a horizontal layer (scintillator bar length
291 // along the x-axis) in the back HCal.
292 int back_horizontal_parity_{};
293
294 // 3D readout for side Hcal
295 int side_3d_readout_{};
296
298 std::vector<std::vector<int>> num_strips_;
300 std::vector<std::vector<double>> zero_strip_;
302 std::vector<std::vector<double>> half_total_width_;
304 std::vector<std::vector<double>> scint_length_;
305
306 bool is_prototype_{};
307
309 std::vector<std::vector<double>> layer_z_;
311 std::vector<std::vector<int>> layer_long_axis_;
313 std::vector<std::vector<double>> layer_bar_center_;
315 std::vector<std::vector<double>> layer_strip_zero_;
317 std::vector<int> double_ended_;
318
323 std::map<ldmx::HcalID, ROOT::Math::XYZVector> strip_position_map_;
324};
325
326} // namespace ldmx
327
328#endif
Base class for conditions information like pedestals, gains, electronics maps, etc.
Class that defines an HCal sensitive detector.
Base class for all conditions objects, very simple.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Implementation of HCal strip readout.
std::vector< double > layer_thickness_
Thickness of the layers in each section [mm].
int getNumLayers(int isection) const
Get the number of layers for that section.
bool hasSide3DReadout() const
Does the Side Hcal have 3D readout?
std::vector< int > double_ended_
Explicit layout: section read out at both ends.
double getEcalDx() const
Get the length of the Ecal in (x) for the side Hcal.
std::vector< double > zero_layer_
Front of HCal relative to world geometry for each section [mm].
std::map< ldmx::HcalID, ROOT::Math::XYZVector > getStripPositionMap() const
Get the strip position map.
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.
double getDistanceAlongBar(ldmx::HcalID id, double x, double y, double z) const
Signed distance along the bar from the strip center [mm].
int getZeroStrip(int isection, int layer=1) const
Get the location of the zeroStrip in a given section and layer.
int getNumSections() const
Get the number of sections.
bool hasExplicitLayout() const
Are the strip positions given layer by layer (e.g.
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....
std::vector< std::vector< double > > layer_bar_center_
Explicit layout: world along-bar coordinate of the bar centers [mm].
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...
double getScintillatorThickness() const
Get the scitillator thickness.
std::vector< std::vector< double > > scint_length_
Length of strips [mm].
std::vector< std::vector< double > > layer_z_
Explicit layout: world z of each layer center [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].
double getEcalDy() const
Get the length of the Ecal in (y) for the side Hcal.
std::vector< double > rotateGlobalToLocalBarPosition(const std::vector< double > &globalPosition, const ldmx::HcalID &id) const
Coordinates that are given by Geant4 are typically global.
bool isDoubleEnded(int isection) const
Are the bars of this section read out at both ends?
double getScintillatorWidth() const
Get the scitillator width.
double scint_thickness_
Thickness of scintillator.
bool backLayerIsHorizontal(const int layer) const
Check whether a given layer corresponds to a horizontal (scintillator length along the x-axis) or ver...
~HcalGeometry()=default
Class destructor.
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< double > > layer_strip_zero_
Explicit layout: world transverse coordinate of strip 0 [mm].
std::vector< std::vector< int > > num_strips_
Number of strips per layer in each section and each layer.
std::vector< std::vector< int > > layer_long_axis_
Explicit layout: 0 = bar long along x, 1 = along y.
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.
Definition HcalID.h:19