LDMX Software
EcalElectronicsID.h
Go to the documentation of this file.
1
7#ifndef DETDESCR_ECALELECTRONICSID_H_
8#define DETDESCR_ECALELECTRONICSID_H_
9
10// LDMX
11#include "DetDescr/DetectorID.h"
13
14namespace ldmx {
15
28 public:
29 static const RawValue INDEX_MASK{0xFFFFFF};
30 // PackedIndex for channel (field 0) and elink (field 1), fiber (field 2)
31 typedef PackedIndex<38, 48, 97> Index;
32 // Maximum value of any packed index here
33 static const unsigned int MAX_INDEX{38 * 48 * 200};
34
38 EcalElectronicsID() : DetectorID(EID_ECAL, 0) {}
39
46 EcalElectronicsID(RawValue rawid) : DetectorID(rawid) {
47 SUBDETECTORID_TEST("EcalElectronicsID", EID_ECAL);
48 }
49
54 SUBDETECTORID_TEST("EcalElectronicsID", EID_ECAL);
55 }
56
60 EcalElectronicsID(unsigned int fiber, unsigned int elink,
61 unsigned int channel)
62 : DetectorID(EID_ECAL, 0) {
63 Index index(channel, elink, fiber);
64 id_ |= index.value();
65 }
66
75 static EcalElectronicsID idFromIndex(unsigned int index) {
77 eid.id_ |= index;
78 return eid;
79 }
80
85 int fiber() const { return Index(id_ & INDEX_MASK).field2(); }
90 int elink() const { return Index(id_ & INDEX_MASK).field1(); }
95 int channel() const { return Index(id_ & INDEX_MASK).field0(); }
96
100 unsigned int index() const { return id_ & INDEX_MASK; }
101};
102
103} // namespace ldmx
104
105std::ostream& operator<<(std::ostream& s, const ldmx::EcalElectronicsID& id);
106
107#endif // DETDESCR_ECALELECTRONICSID_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 Ecal readout chain.
int elink() const
Get the value of the elink from the ID.
static EcalElectronicsID idFromIndex(unsigned int index)
Construct an electronics id from an index.
EcalElectronicsID(RawValue rawid)
Create from raw number.
EcalElectronicsID()
Empty ECAL id (but not null!)
unsigned int index() const
Get the compact index value.
EcalElectronicsID(const DetectorID id)
Create from a DetectorID, but check.
int channel() const
Get the value of the channel from the ID.
int fiber() const
Get the value of the fiber from the ID.
EcalElectronicsID(unsigned int fiber, unsigned int elink, unsigned int channel)
Create from pieces.
A maximally-packed index of up to four different fields.
Definition PackedIndex.h:32