LDMX Software
EcalID.h
Go to the documentation of this file.
1
7#ifndef DETDESCR_ECALDETECTORID_H_
8#define DETDESCR_ECALDETECTORID_H_
9
10// LDMX
12
13namespace ldmx {
14
20class EcalID : public EcalAbstractID {
21 public:
22 static const RawValue LAYER_MASK{0x3F}; // space for up to 64 layers
23 static const RawValue LAYER_SHIFT{17};
24 static const RawValue MODULE_MASK{0x1F}; // space for up to 32 modules/layer
25 static const RawValue MODULE_SHIFT{12};
26 static const RawValue CELL_MASK{0xFFF}; // space for 4096 cells/module (!)
27 static const RawValue CELL_SHIFT{0};
28
33
37 EcalID(RawValue rawid) : EcalAbstractID(rawid) {
38 if (!null() && cellType() != PrecisionGlobal &&
39 cellType() != PrecisionLocal) {
40 EXCEPTION_RAISE(
41 "DetectorIDMismatch",
42 "Attempted to create EcalID from mismatched Ecal cell_type " +
43 std::to_string(cellType()));
44 }
45 }
46
51 if (!null() && cellType() != PrecisionGlobal &&
52 cellType() != PrecisionLocal) {
53 EXCEPTION_RAISE(
54 "DetectorIDMismatch",
55 "Attempted to create EcalID from mismatched Ecal cell_type " +
56 std::to_string(cellType()));
57 }
58 }
59
63 EcalID(unsigned int layer, unsigned int module, unsigned int cell)
64 : EcalAbstractID(PrecisionGlobal, 0) {
65 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
66 id_ |= (module & MODULE_MASK) << MODULE_SHIFT;
67 id_ |= (cell & CELL_MASK) << CELL_SHIFT;
68 }
69
73 EcalID(unsigned int layer, unsigned int module, unsigned int u,
74 unsigned int v);
75
79 EcalID(unsigned int layer, unsigned int module,
80 std::pair<unsigned int, unsigned int> uv)
81 : EcalID(layer, module, uv.first, uv.second) {}
82
87 int module() const { return (id_ >> MODULE_SHIFT) & MODULE_MASK; }
88
93 int getModuleID() const { return (id_ >> MODULE_SHIFT) & MODULE_MASK; }
94
99 int layer() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
100
105 int getLayerID() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
106
111 int cell() const { return (id_ >> CELL_SHIFT) & CELL_MASK; }
112
117 int getCellID() const { return (id_ >> CELL_SHIFT) & CELL_MASK; }
118
123 std::pair<unsigned int, unsigned int> getCellUV() const;
124
125 friend std::ostream& operator<<(std::ostream& o, const ldmx::EcalID& d);
126
127 static void createInterpreters();
128};
129
130} // namespace ldmx
131
132#endif
Class that serves as a parent for ECal 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 precision and trigger EcalIDs.
int cellType() const
Get the value of the cell field from the ID.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
EcalID(unsigned int layer, unsigned int module, unsigned int cell)
Create from pieces.
Definition EcalID.h:63
int cell() const
Get the value of the cell field from the ID.
Definition EcalID.h:111
int getCellID() const
Get the value of the cell field from the ID.
Definition EcalID.h:117
std::pair< unsigned int, unsigned int > getCellUV() const
Get the cell u,v index assuming a CMS-standard 432-cell sensor.
Definition EcalID.cxx:81
int getLayerID() const
Get the value of the layer field from the ID.
Definition EcalID.h:105
int getModuleID() const
Get the value of the module field from the ID.
Definition EcalID.h:93
EcalID(unsigned int layer, unsigned int module, std::pair< unsigned int, unsigned int > uv)
Create from pieces including u/v cell.
Definition EcalID.h:79
EcalID(const DetectorID id)
Create from a DetectorID, but check.
Definition EcalID.h:50
EcalID()
Empty ECAL id (but not null!)
Definition EcalID.h:32
int module() const
Get the value of the module field from the ID.
Definition EcalID.h:87
EcalID(RawValue rawid)
Create from raw number.
Definition EcalID.h:37
int layer() const
Get the value of the layer field from the ID.
Definition EcalID.h:99