LDMX Software
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ldmx::EcalID Class Reference

Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid. More...

#include <EcalID.h>

Public Member Functions

 EcalID ()
 Empty ECAL id (but not null!)
 
 EcalID (RawValue rawid)
 Create from raw number.
 
 EcalID (const DetectorID id)
 Create from a DetectorID, but check.
 
 EcalID (unsigned int layer, unsigned int module, unsigned int cell)
 Create from pieces.
 
 EcalID (unsigned int layer, unsigned int module, unsigned int u, unsigned int v)
 Create from pieces including u/v cell.
 
 EcalID (unsigned int layer, unsigned int module, std::pair< unsigned int, unsigned int > uv)
 Create from pieces including u/v cell.
 
int module () const
 Get the value of the module field from the ID.
 
int getModuleID () const
 Get the value of the module field from the ID.
 
int layer () const
 Get the value of the layer field from the ID.
 
int getLayerID () const
 Get the value of the layer field from the ID.
 
int cell () const
 Get the value of the cell field from the ID.
 
int getCellID () const
 Get the value of the cell field from the ID.
 
std::pair< unsigned int, unsigned int > getCellUV () const
 Get the cell u,v index assuming a CMS-standard 432-cell sensor.
 
- Public Member Functions inherited from ldmx::EcalAbstractID
 EcalAbstractID ()
 Empty ECAL id (but not null!)
 
 EcalAbstractID (RawValue rawid)
 Create from raw number.
 
 EcalAbstractID (const DetectorID id)
 Create from a DetectorID, but check.
 
 EcalAbstractID (unsigned int cell_type, unsigned int payload)
 Create from pieces.
 
int cell_type () const
 Get the value of the cell field from the ID.
 
int payload () const
 Get the value of the payload field from the ID.
 
- Public Member Functions inherited from ldmx::DetectorID
 DetectorID ()
 Class constructor for a null DetectorID.
 
 DetectorID (RawValue rawid)
 Class constructor from a raw 32-bit integer.
 
 DetectorID (SubdetectorIDType sdtype, RawValue raw_subpayload)
 Class constructor from a subdetector id and a subdetector-specific section (masked to.
 
bool null () const
 
SubdetectorIDType subdet () const
 
RawValue raw () const
 
void setRawValue (RawValue rawValue)
 Set the raw value of the detector ID.
 
bool operator< (const DetectorID &id) const
 
bool operator== (const DetectorID &id) const
 
bool operator!= (const DetectorID &id) const
 

Static Public Member Functions

static void createInterpreters ()
 

Static Public Attributes

static const RawValue LAYER_MASK {0x3F}
 
static const RawValue LAYER_SHIFT {17}
 
static const RawValue MODULE_MASK {0x1F}
 
static const RawValue MODULE_SHIFT {12}
 
static const RawValue CELL_MASK {0xFFF}
 
static const RawValue CELL_SHIFT {0}
 
- Static Public Attributes inherited from ldmx::EcalAbstractID
static const RawValue CELL_TYPE_MASK
 
static const RawValue CELL_TYPE_SHIFT {23}
 
static const RawValue ECAL_PAYLOAD_MASK {0x007FFFFF}
 
- Static Public Attributes inherited from ldmx::DetectorID
static const RawValue SUBDETECTORID_MASK {0x3F}
 
static const RawValue SUBDETECTORID_SHIFT {26}
 
static const RawValue SUBDETECTOR_PAYLOAD_MASK {0x3FFFFFF}
 

Additional Inherited Members

- Public Types inherited from ldmx::EcalAbstractID
enum  EcalCellType { PrecisionGlobal = 0 , PrecisionLocal = 1 , TriggerCell = 2 , Special = 7 }
 
- Public Types inherited from ldmx::DetectorID
typedef uint32_t RawValue
 
- Protected Attributes inherited from ldmx::DetectorID
RawValue id_
 The raw, packed value of the ID.
 

Detailed Description

Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.

Definition at line 20 of file EcalID.h.

Constructor & Destructor Documentation

◆ EcalID() [1/6]

ldmx::EcalID::EcalID ( )
inline

Empty ECAL id (but not null!)

Definition at line 32 of file EcalID.h.

32: EcalAbstractID() {}
EcalAbstractID()
Empty ECAL id (but not null!)

◆ EcalID() [2/6]

ldmx::EcalID::EcalID ( RawValue  rawid)
inline

Create from raw number.

Definition at line 37 of file EcalID.h.

37 : EcalAbstractID(rawid) {
38 if (!null() && cell_type() != PrecisionGlobal &&
39 cell_type() != PrecisionLocal) {
40 EXCEPTION_RAISE(
41 "DetectorIDMismatch",
42 "Attempted to create EcalID from mismatched Ecal cell_type " +
43 std::to_string(cell_type()));
44 }
45 }
bool null() const
Definition DetectorID.h:60
int cell_type() const
Get the value of the cell field from the ID.

References ldmx::EcalAbstractID::cell_type(), and ldmx::DetectorID::null().

◆ EcalID() [3/6]

ldmx::EcalID::EcalID ( const DetectorID  id)
inline

Create from a DetectorID, but check.

Definition at line 50 of file EcalID.h.

50 : EcalAbstractID(id) {
51 if (!null() && cell_type() != PrecisionGlobal &&
52 cell_type() != PrecisionLocal) {
53 EXCEPTION_RAISE(
54 "DetectorIDMismatch",
55 "Attempted to create EcalID from mismatched Ecal cell_type " +
56 std::to_string(cell_type()));
57 }
58 }

References ldmx::EcalAbstractID::cell_type(), and ldmx::DetectorID::null().

◆ EcalID() [4/6]

ldmx::EcalID::EcalID ( unsigned int  layer,
unsigned int  module,
unsigned int  cell 
)
inline

Create from pieces.

Definition at line 63 of file EcalID.h.

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 }
RawValue id_
The raw, packed value of the ID.
Definition DetectorID.h:84
int cell() const
Get the value of the cell field from the ID.
Definition EcalID.h:111
int layer() const
Get the value of the layer field from the ID.
Definition EcalID.h:99

References cell(), ldmx::DetectorID::id_, and layer().

◆ EcalID() [5/6]

ldmx::EcalID::EcalID ( unsigned int  layer,
unsigned int  module,
unsigned int  u,
unsigned int  v 
)

Create from pieces including u/v cell.

Definition at line 42 of file EcalID.cxx.

44 : EcalAbstractID(EcalAbstractID::PrecisionGlobal, 0) {
45 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
46 id_ |= (module & MODULE_MASK) << MODULE_SHIFT;
47
48 unsigned int cell = 0;
49 if (v > max_v) {
50 EXCEPTION_RAISE("InvalidIdException",
51 "Attempted to create EcalID with invalid (u,v)=(" +
52 std::to_string(u) + "," + std::to_string(v) + ")");
53 }
54
55 if (v <= v_middle) { // simple case...
56 if (u > (base_row_w - 1 + v)) {
57 EXCEPTION_RAISE("InvalidIdException",
58 "Attempted to create EcalID with invalid (u,v)=(" +
59 std::to_string(u) + "," + std::to_string(v) + ")");
60 }
61 cell = u + v * base_row_w + (v - 1) * v / 2;
62 } else {
63 unsigned int umin = v - v_middle;
64 static unsigned int umax = 23; // constant
65 unsigned int vrel = v - v_middle - 1;
66 if (u < umin || u > umax) {
67 EXCEPTION_RAISE("InvalidIdException",
68 "Attempted to create EcalID with invalid (u,v)=(" +
69 std::to_string(u) + "," + std::to_string(v) + ")");
70 }
71 cell = 222 + (u - umin) + vrel * base_row_w + 55 -
72 (v_middle - vrel - 1) * (v_middle - vrel) / 2;
73 }
74 id_ |= (cell & CELL_MASK) << CELL_SHIFT;
75}

References cell(), ldmx::DetectorID::id_, and layer().

◆ EcalID() [6/6]

ldmx::EcalID::EcalID ( unsigned int  layer,
unsigned int  module,
std::pair< unsigned int, unsigned int >  uv 
)
inline

Create from pieces including u/v cell.

Definition at line 79 of file EcalID.h.

81 : EcalID(layer, module, uv.first, uv.second) {}
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

Member Function Documentation

◆ cell()

int ldmx::EcalID::cell ( ) const
inline

Get the value of the cell field from the ID.

Returns
The value of the cell field.

Definition at line 111 of file EcalID.h.

111{ return (id_ >> CELL_SHIFT) & CELL_MASK; }

References ldmx::DetectorID::id_.

Referenced by ecal::EcalTriggerGeometry::belongsTo(), EcalID(), EcalID(), getCellUV(), ecal::EcalTriggerGeometry::localPosition(), and TEST_CASE().

◆ createInterpreters()

void ldmx::EcalID::createInterpreters ( )
static

Definition at line 14 of file EcalID.cxx.

14 {
16 fields.push_back(new IDField("subdetector", 0, SUBDETECTORID_SHIFT, 31));
17 fields.push_back(
18 new IDField("layer", 1, LAYER_SHIFT,
19 LAYER_SHIFT + IDField::countOnes(LAYER_MASK) - 1));
20 fields.push_back(
21 new IDField("module", 2, MODULE_SHIFT,
22 MODULE_SHIFT + IDField::countOnes(MODULE_MASK) - 1));
23 fields.push_back(new IDField("cell", 3, CELL_SHIFT,
24 CELL_SHIFT + IDField::countOnes(CELL_MASK) - 1));
25
27 SD_ECAL,
28 EcalAbstractID::CELL_TYPE_MASK << EcalAbstractID::CELL_TYPE_SHIFT,
29 EcalAbstractID::PrecisionGlobal << EcalAbstractID::CELL_TYPE_SHIFT,
30 fields);
32 SD_ECAL,
33 EcalAbstractID::CELL_TYPE_MASK << EcalAbstractID::CELL_TYPE_SHIFT,
34 EcalAbstractID::PrecisionLocal << EcalAbstractID::CELL_TYPE_SHIFT,
35 fields);
36}
static void registerInterpreter(SubdetectorIDType idtype, const IDField::IDFieldList &fieldList)
Register a new field interpreter for a given subdetector id.
static unsigned countOnes(unsigned mask)
Utility for counting number of 1 in a mask.
Definition IDField.cxx:33
std::vector< IDField * > IDFieldList
List of fields.
Definition IDField.h:25

◆ getCellID()

int ldmx::EcalID::getCellID ( ) const
inline

Get the value of the cell field from the ID.

Returns
The value of the cell field.

Definition at line 117 of file EcalID.h.

117{ return (id_ >> CELL_SHIFT) & CELL_MASK; }

References ldmx::DetectorID::id_.

Referenced by getCellUV(), and TEST_CASE().

◆ getCellUV()

std::pair< unsigned int, unsigned int > ldmx::EcalID::getCellUV ( ) const

Get the cell u,v index assuming a CMS-standard 432-cell sensor.

Returns
Pair providing a U/V index

Definition at line 81 of file EcalID.cxx.

81 {
82 int cell = getCellID();
83 unsigned int v;
84 for (v = 0; v < max_v && cell >= row_starts[v + 1]; v++)
85 ; // find the right v value
86 unsigned int u = cell - row_starts[v];
87 if (v > v_middle) u += (v - v_middle);
88 return std::pair<unsigned int, unsigned int>(u, v);
89}
int getCellID() const
Get the value of the cell field from the ID.
Definition EcalID.h:117

References cell(), and getCellID().

◆ getLayerID()

int ldmx::EcalID::getLayerID ( ) const
inline

Get the value of the layer field from the ID.

Returns
The value of the layer field.

Definition at line 105 of file EcalID.h.

105{ return (id_ >> LAYER_SHIFT) & LAYER_MASK; }

References ldmx::DetectorID::id_.

Referenced by TEST_CASE().

◆ getModuleID()

int ldmx::EcalID::getModuleID ( ) const
inline

Get the value of the module field from the ID.

Returns
The value of the module field.

Definition at line 93 of file EcalID.h.

93{ return (id_ >> MODULE_SHIFT) & MODULE_MASK; }

References ldmx::DetectorID::id_.

Referenced by TEST_CASE().

◆ layer()

int ldmx::EcalID::layer ( ) const
inline

Get the value of the layer field from the ID.

Returns
The value of the layer field.

Definition at line 99 of file EcalID.h.

99{ return (id_ >> LAYER_SHIFT) & LAYER_MASK; }

References ldmx::DetectorID::id_.

Referenced by ecal::EcalTriggerGeometry::belongsTo(), EcalID(), EcalID(), and TEST_CASE().

◆ module()

int ldmx::EcalID::module ( ) const
inline

Get the value of the module field from the ID.

Returns
The value of the module field.

Definition at line 87 of file EcalID.h.

87{ return (id_ >> MODULE_SHIFT) & MODULE_MASK; }

References ldmx::DetectorID::id_.

Referenced by ecal::EcalTriggerGeometry::belongsTo(), and TEST_CASE().

Member Data Documentation

◆ CELL_MASK

const RawValue ldmx::EcalID::CELL_MASK {0xFFF}
static

Definition at line 26 of file EcalID.h.

26{0xFFF}; // space for 4096 cells/module (!)

◆ CELL_SHIFT

const RawValue ldmx::EcalID::CELL_SHIFT {0}
static

Definition at line 27 of file EcalID.h.

27{0};

◆ LAYER_MASK

const RawValue ldmx::EcalID::LAYER_MASK {0x3F}
static

Definition at line 22 of file EcalID.h.

22{0x3F}; // space for up to 64 layers

◆ LAYER_SHIFT

const RawValue ldmx::EcalID::LAYER_SHIFT {17}
static

Definition at line 23 of file EcalID.h.

23{17};

◆ MODULE_MASK

const RawValue ldmx::EcalID::MODULE_MASK {0x1F}
static

Definition at line 24 of file EcalID.h.

24{0x1F}; // space for up to 32 modules/layer

◆ MODULE_SHIFT

const RawValue ldmx::EcalID::MODULE_SHIFT {12}
static

Definition at line 25 of file EcalID.h.

25{12};

The documentation for this class was generated from the following files: