LDMX Software
HcalDigiID.h
1#ifndef DETDESCR_HCALDIGIID_H_
2#define DETDESCR_HCALDIGIID_H_
3
4//---< DetDescr >---//
6
7namespace ldmx {
8
13class HcalDigiID : public HcalAbstractID {
14 public:
15 static const RawValue END_MASK{0x1}; // space for up to 2 ends of a strip
16 static const RawValue END_SHIFT{19};
17 static const RawValue SECTION_MASK{0x7}; // space for up to 7 sections
18 static const RawValue SECTION_SHIFT{16};
19 static const RawValue LAYER_MASK{0xFF}; // space for up to 255 layers
20 static const RawValue LAYER_SHIFT{8};
21 static const RawValue STRIP_MASK{0xFF}; // space for 255 strips/layer
22 static const RawValue STRIP_SHIFT{0};
23
28
32 HcalDigiID(RawValue rawid) : HcalAbstractID(rawid) {
33 if (!null() && bar_type() != Digi) {
34 EXCEPTION_RAISE(
35 "DetectorIDMismatch",
36 "Attempted to create HcalDigiID from mismatched Hcal bar_type " +
37 std::to_string(bar_type()));
38 }
39 }
40
45 if (!null() && bar_type() != Digi) {
46 EXCEPTION_RAISE(
47 "DetectorIDMismatch",
48 "Attempted to create HcalDigiID from mismatched Hcal bar_type " +
49 std::to_string(bar_type()));
50 }
51 }
52
56 HcalDigiID(unsigned int section, unsigned int layer, unsigned int strip,
57 unsigned int end)
58 : HcalAbstractID(Digi, 0) {
59 id_ |= (section & SECTION_MASK) << SECTION_SHIFT;
60 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
61 id_ |= (strip & STRIP_MASK) << STRIP_SHIFT;
62 id_ |= (end & END_MASK) << END_SHIFT;
63 }
64
69 int getSection() const { return (id_ >> SECTION_SHIFT) & SECTION_MASK; }
70
75 int section() const { return (id_ >> SECTION_SHIFT) & SECTION_MASK; }
76
81 int layer() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
82
87 int getLayerID() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
88
93 int getStrip() const { return (id_ >> STRIP_SHIFT) & STRIP_MASK; }
94
99 int strip() const { return (id_ >> STRIP_SHIFT) & STRIP_MASK; }
100
105 int end() const { return (id_ >> END_SHIFT) & END_MASK; }
106
111 bool isNegativeEnd() const {
112 if (end() == 1)
113 return true;
114 else
115 return false;
116 }
117
118 static void createInterpreters();
119};
120} // namespace ldmx
121
133std::ostream &operator<<(std::ostream &, const ldmx::HcalDigiID &id);
134
135#endif
Class that serves as a parent for HCal detector IDs of various types.
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
Definition DetectorID.h:35
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 HcalAbstractID providing access to HCal digi information.
Definition HcalDigiID.h:13
HcalDigiID()
Empty HCAL id (but not null!)
Definition HcalDigiID.h:27
HcalDigiID(RawValue rawid)
Create from raw number.
Definition HcalDigiID.h:32
HcalDigiID(const DetectorID id)
Create from a DetectorID, but check.
Definition HcalDigiID.h:44
int getStrip() const
Get the value of the 'strip' field from the ID.
Definition HcalDigiID.h:93
int getSection() const
Get the value of the 'section' field from the ID.
Definition HcalDigiID.h:69
int strip() const
Get the value of the 'strip' field from the ID.
Definition HcalDigiID.h:99
bool isNegativeEnd() const
Get whether the 'end' field from the ID is negative.
Definition HcalDigiID.h:111
int section() const
Get the value of the 'section' field from the ID.
Definition HcalDigiID.h:75
HcalDigiID(unsigned int section, unsigned int layer, unsigned int strip, unsigned int end)
Create from pieces.
Definition HcalDigiID.h:56
int layer() const
Get the value of the layer field from the ID.
Definition HcalDigiID.h:81
int getLayerID() const
Get the value of the layer field from the ID.
Definition HcalDigiID.h:87
int end() const
Get the value of the 'end' field from the ID.
Definition HcalDigiID.h:105
Definition objdef.h:26