LDMX Software
HcalTriggerID.h
Go to the documentation of this file.
1
7#ifndef DETDESCR_HCALTRIGGERID_H_
8#define DETDESCR_HCALTRIGGERID_H_
9
10// LDMX
12
13namespace ldmx {
14
20 public:
24 enum HcalSection { BACK = 0, TOP = 1, BOTTOM = 2, LEFT = 4, RIGHT = 3 };
25
26 static const RawValue END_MASK{0x3}; // space for 2 ends plus a combined TP
27 static const RawValue END_SHIFT{20};
28 static const RawValue SECTION_MASK{0x7}; // space for up to 7 sections
29 static const RawValue SECTION_SHIFT{16};
30 static const RawValue LAYER_MASK{0xFF}; // space for up to 255 layers
31 static const RawValue LAYER_SHIFT{8};
32 static const RawValue SUPERSTRIP_MASK{0xFF}; // space for 255 strips/layer
33 static const RawValue SUPERSTRIP_SHIFT{0};
34
39
43 HcalTriggerID(RawValue rawid) : HcalAbstractID(rawid) {
44 if (!null() && bar_type() != Trigger) {
45 EXCEPTION_RAISE(
46 "DetectorIDMismatch",
47 "Attempted to create HcalTriggerID from mismatched Hcal bar_type " +
48 std::to_string(bar_type()));
49 }
50 }
51
56 if (!null() && bar_type() != Trigger) {
57 EXCEPTION_RAISE(
58 "DetectorIDMismatch",
59 "Attempted to create HcalTriggerID from mismatched Hcal bar_type " +
60 std::to_string(bar_type()));
61 }
62 }
63
67 HcalTriggerID(unsigned int section, unsigned int layer,
68 unsigned int superstrip, unsigned int end)
69 : HcalAbstractID(Trigger, 0) {
70 id_ |= (section & SECTION_MASK) << SECTION_SHIFT;
71 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
72 id_ |= (superstrip & SUPERSTRIP_MASK) << SUPERSTRIP_SHIFT;
73 id_ |= (end & END_MASK) << END_SHIFT;
74 }
75
76 /*
77 * Get the value of the 'section' field from the ID.
78 * @return The value of the 'section' field.
79 */
80 int getSection() const { return (id_ >> SECTION_SHIFT) & SECTION_MASK; }
81
82 /*
83 * Get the value of the 'section' field from the ID.
84 * @return The value of the 'section' field.
85 */
86 int section() const { return (id_ >> SECTION_SHIFT) & SECTION_MASK; }
87
92 int layer() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
93
98 int getLayerID() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
99
104 int getSuperstrip() const {
105 return (id_ >> SUPERSTRIP_SHIFT) & SUPERSTRIP_MASK;
106 }
107
112 int superstrip() const { return (id_ >> SUPERSTRIP_SHIFT) & SUPERSTRIP_MASK; }
113
118 int end() const { return (id_ >> END_SHIFT) & END_MASK; }
119
124 bool isNegativeEnd() const { return end() == 1; }
125
130 bool isComposite() const { return end() == 2; }
131
132 static void createInterpreters();
133};
134} // namespace ldmx
135
136std::ostream& operator<<(std::ostream&, const ldmx::HcalTriggerID&);
137
138#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.
Extension of DetectorID providing access to HCal trigger cell.
int superstrip() const
Get the value of the 'superstrip' field from the ID.
HcalTriggerID()
Empty HCAL trigger id (but not null!)
int end() const
Get the value of the 'end' field from the ID.
int getLayerID() const
Get the value of the layer field from the ID.
HcalTriggerID(RawValue rawid)
Create from raw number.
HcalTriggerID(const HcalAbstractID id)
Create from a DetectorID, but check.
HcalTriggerID(unsigned int section, unsigned int layer, unsigned int superstrip, unsigned int end)
Create from pieces.
bool isComposite() const
Get whether the ID is the composite of two bar ends.
int getSuperstrip() const
Get the value of the 'superstrip' field from the ID.
bool isNegativeEnd() const
Get whether the 'end' field from the ID is negative.
HcalSection
Encodes the section of the HCal based on the 'section' field value.
int layer() const
Get the value of the layer field from the ID.