LDMX Software
EcalTriggerID.h
Go to the documentation of this file.
1
7#ifndef DETDESCR_ECALTRIGGERDETECTORID_H_
8#define DETDESCR_ECALTRIGGERDETECTORID_H_
9
10// LDMX
12
13namespace ldmx {
14
21 public:
22 static const RawValue LAYER_MASK{0x3F}; // space for up to 64 layers
23 static const RawValue LAYER_SHIFT{12};
24 static const RawValue MODULE_MASK{0x1F}; // space for up to 32 modules/layer
25 static const RawValue MODULE_SHIFT{7};
26 static const RawValue CELL_MASK{
27 0x7F}; // space for 128 trigger cells/module (!)
28 static const RawValue CELL_SHIFT{0};
29
34
38 EcalTriggerID(RawValue rawid) : EcalAbstractID(rawid) {
39 if (!null() && cell_type() != TriggerCell) {
40 EXCEPTION_RAISE(
41 "DetectorIDMismatch",
42 "Attempted to create EcalTriggerID from mismatched Ecal cell_type " +
43 std::to_string(cell_type()));
44 }
45 }
46
51 if (!null() && cell_type() != TriggerCell) {
52 EXCEPTION_RAISE(
53 "DetectorIDMismatch",
54 "Attempted to create EcalTriggerID from mismatched Ecal cell_type " +
55 std::to_string(cell_type()));
56 }
57 }
58
62 EcalTriggerID(unsigned int layer, unsigned int module, unsigned int cell)
63 : EcalAbstractID(TriggerCell, 0) {
64 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
65 id_ |= (module & MODULE_MASK) << MODULE_SHIFT;
66 id_ |= (cell & CELL_MASK) << CELL_SHIFT;
67 }
68
73 int module() const { return (id_ >> MODULE_SHIFT) & MODULE_MASK; }
74
79 int getModuleID() const { return (id_ >> MODULE_SHIFT) & MODULE_MASK; }
80
85 int layer() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
86
91 int getLayerID() const { return (id_ >> LAYER_SHIFT) & LAYER_MASK; }
92
97 int triggercell() const { return (id_ >> CELL_SHIFT) & CELL_MASK; }
98
103 int getTriggerCellID() const { return (id_ >> CELL_SHIFT) & CELL_MASK; }
104
105 // Note: When this function is implemented, it can be added to
106 // DetectorIDBindings
111 std::pair<unsigned int, unsigned int> getCellUV() const;
112
113 static void createInterpreters();
114};
115
116} // namespace ldmx
117
118std::ostream& operator<<(std::ostream&, const ldmx::EcalTriggerID&);
119
120#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 cell_type() const
Get the value of the cell field from the ID.
Extension of DetectorID providing access to ECal trigger cell information.
std::pair< unsigned int, unsigned int > getCellUV() const
Get the cell u,v index assuming a CMS-standard 432-cell sensor.
int layer() const
Get the value of the layer field from the ID.
EcalTriggerID()
Empty ECAL id (but not null!)
EcalTriggerID(RawValue rawid)
Create from raw number.
int module() const
Get the value of the module field from the ID.
int getLayerID() const
Get the value of the layer field from the ID.
EcalTriggerID(const DetectorID id)
Create from a DetectorID, but check.
int triggercell() const
Get the value of the trigger cell field from the ID.
int getTriggerCellID() const
Get the value of the trigger cell field from the ID.
EcalTriggerID(unsigned int layer, unsigned int module, unsigned int cell)
Create from pieces.
int getModuleID() const
Get the value of the module field from the ID.