LDMX Software
HcalElectronicsID.h
1
2#ifndef DETDESCR_HCALELECTRONICSID_H_
3#define DETDESCR_HCALELECTRONICSID_H_
4
5// LDMX
6#include "DetDescr/DetectorID.h"
8
9namespace ldmx {
10
27 public:
28 static const RawValue INDEX_MASK{0xFFFFFF};
29 // PackedIndex for channel (field 0) and elink (field 1), fiber (field 2)
30 typedef PackedIndex<38, 48, 97> Index;
31 // Maximum value of any packed index here
32 static const unsigned int MAX_INDEX{38 * 48 * 200};
33
37 HcalElectronicsID() : DetectorID(EID_HCAL, 0) {}
38
42 HcalElectronicsID(RawValue rawid) : DetectorID(rawid) {
43 SUBDETECTORID_TEST("HcalElectronicsID", EID_HCAL);
44 }
45
50 SUBDETECTORID_TEST("HcalElectronicsID", EID_HCAL);
51 }
52
56 HcalElectronicsID(unsigned int fiber, unsigned int elink,
57 unsigned int channel)
58 : DetectorID(EID_HCAL, 0) {
59 Index index(channel, elink, fiber);
60 id_ |= index.value();
61 }
62
71 static HcalElectronicsID idFromIndex(unsigned int index) {
73 eid.id_ |= index;
74 return eid;
75 }
76
81 int fiber() const { return Index(id_ & INDEX_MASK).field2(); }
86 int elink() const { return Index(id_ & INDEX_MASK).field1(); }
91 int channel() const { return Index(id_ & INDEX_MASK).field0(); }
92
96 unsigned int index() const { return id_ & INDEX_MASK; }
97};
98
99} // namespace ldmx
100
101std::ostream& operator<<(std::ostream& s, const ldmx::HcalElectronicsID& id);
102
103#endif // DETDESCR_HCALELECTRONICSID_H_
Class which represents a maximally-packed index of up to four fields.
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
Definition DetectorID.h:35
RawValue id_
The raw, packed value of the ID.
Definition DetectorID.h:84
Identifies a location in the Hcal readout chain.
unsigned int index() const
Get the compact index value.
int elink() const
Get the value of the elink from the ID.
int fiber() const
Get the value of the fiber from the ID.
HcalElectronicsID(RawValue rawid)
Create from raw number.
HcalElectronicsID(unsigned int fiber, unsigned int elink, unsigned int channel)
Create from pieces.
int channel() const
Get the value of the channel from the ID.
static HcalElectronicsID idFromIndex(unsigned int index)
Construct an electronics id from an index.
HcalElectronicsID()
Empty HCAL id (but not null!)
HcalElectronicsID(const DetectorID id)
Create from a DetectorID, but check.
A maximally-packed index of up to four different fields.
Definition PackedIndex.h:32