LDMX Software
HcalID.h
Go to the documentation of this file.
1
7#ifndef DETDESCR_HCALID_H_
8#define DETDESCR_HCALID_H_
9
10// LDMX
12
13namespace ldmx {
14
19class HcalID : public HcalAbstractID {
20 public:
24 enum HcalSection { BACK = 0, TOP = 1, BOTTOM = 2, RIGHT = 3, LEFT = 4 };
25
26 static const RawValue SECTION_MASK{0x7}; // space for up to 7 sections
27 static const RawValue SECTION_SHIFT{18};
28 static const RawValue LAYER_MASK{0xFF}; // space for up to 255 layers
29 static const RawValue LAYER_SHIFT{10};
30 static const RawValue STRIP_MASK{0xFF}; // space for 255 strips/layer
31 static const RawValue STRIP_SHIFT{0};
32
37
41 HcalID(RawValue rawid) : HcalAbstractID(rawid) {
42 if (!null() && bar_type() != Global) {
43 EXCEPTION_RAISE(
44 "DetectorIDMismatch",
45 "Attempted to create HcalID from mismatched Hcal bar_type " +
46 std::to_string(bar_type()));
47 }
48 }
49
54 if (!null() && bar_type() != Global) {
55 EXCEPTION_RAISE(
56 "DetectorIDMismatch",
57 "Attempted to create HcalID from mismatched Hcal bar_type " +
58 std::to_string(bar_type()));
59 }
60 }
61
65 HcalID(unsigned int section, unsigned int layer, unsigned int strip)
66 : HcalAbstractID(Global, 0) {
67 id_ |= (section & SECTION_MASK) << SECTION_SHIFT;
68 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
69 id_ |= (strip & STRIP_MASK) << STRIP_SHIFT;
70 }
71
72 /*
73 * Get the value of the 'section' field from the ID.
74 * @return The value of the 'strip' field.
75 */
76 unsigned int getSection() const {
77 return (id_ >> SECTION_SHIFT) & SECTION_MASK;
78 }
79
80 /*
81 * Get the value of the 'section' field from the ID.
82 * @return The value of the 'strip' field.
83 */
84 unsigned int section() const { return (id_ >> SECTION_SHIFT) & SECTION_MASK; }
85
90 unsigned int layer() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
91
96 unsigned int getLayerID() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
97
102 unsigned int getStrip() const { return (id_ >> STRIP_SHIFT) & STRIP_MASK; }
103
108 unsigned int strip() const { return (id_ >> STRIP_SHIFT) & STRIP_MASK; }
109
110 static void createInterpreters();
111};
112} // namespace ldmx
113
114std::ostream& operator<<(std::ostream&, const ldmx::HcalID&);
115
116#endif
Class that serves as a parent for HCal detector IDs of various types.
bool null() const
Definition DetectorID.h:60
RawValue id_
The raw, packed value of the ID.
Definition DetectorID.h:84
Parent of HcalIDs.
int bar_type() const
Get the value of the bar field from the ID.
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
unsigned int strip() const
Get the value of the 'strip' field from the ID.
Definition HcalID.h:108
unsigned int getStrip() const
Get the value of the 'strip' field from the ID.
Definition HcalID.h:102
unsigned int layer() const
Get the value of the layer field from the ID.
Definition HcalID.h:90
HcalID()
Empty HCAL id (but not null!)
Definition HcalID.h:36
unsigned int getLayerID() const
Get the value of the layer field from the ID.
Definition HcalID.h:96
HcalSection
Encodes the section of the HCal based on the 'section' field value.
Definition HcalID.h:24
HcalID(RawValue rawid)
Create from raw number.
Definition HcalID.h:41
HcalID(const HcalAbstractID id)
Create from a DetectorID, but check.
Definition HcalID.h:53
HcalID(unsigned int section, unsigned int layer, unsigned int strip)
Create from pieces.
Definition HcalID.h:65