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

Implements detector ids for HCal subdetector. More...

#include <HcalID.h>

Public Types

enum  HcalSection {
  BACK = 0 , TOP = 1 , BOTTOM = 2 , RIGHT = 3 ,
  LEFT = 4
}
 Encodes the section of the HCal based on the 'section' field value. More...
 
- Public Types inherited from ldmx::HcalAbstractID
enum  HcalBarType { Global = 0 , Digi = 1 , Trigger = 2 , Special = 7 }
 Encodes whether the side of the strips of the HCal is saved. More...
 
- Public Types inherited from ldmx::DetectorID
typedef uint32_t RawValue
 

Public Member Functions

 HcalID ()
 Empty HCAL id (but not null!)
 
 HcalID (RawValue rawid)
 Create from raw number.
 
 HcalID (const HcalAbstractID id)
 Create from a DetectorID, but check.
 
 HcalID (unsigned int section, unsigned int layer, unsigned int strip)
 Create from pieces.
 
unsigned int getSection () const
 
unsigned int section () const
 
unsigned int layer () const
 Get the value of the layer field from the ID.
 
unsigned int getLayerID () const
 Get the value of the layer field from the ID.
 
unsigned int getStrip () const
 Get the value of the 'strip' field from the ID.
 
unsigned int strip () const
 Get the value of the 'strip' field from the ID.
 
- Public Member Functions inherited from ldmx::HcalAbstractID
 HcalAbstractID ()
 Empty HCAL id (but not null!)
 
 HcalAbstractID (RawValue rawid)
 Create from raw number.
 
 HcalAbstractID (const DetectorID id)
 Create from a DetectorID, but check.
 
 HcalAbstractID (unsigned int bar_type, unsigned int payload)
 Create from pieces.
 
int bar_type () const
 Get the value of the bar 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 SECTION_MASK {0x7}
 
static const RawValue SECTION_SHIFT {18}
 
static const RawValue LAYER_MASK {0xFF}
 
static const RawValue LAYER_SHIFT {10}
 
static const RawValue STRIP_MASK {0xFF}
 
static const RawValue STRIP_SHIFT {0}
 
- Static Public Attributes inherited from ldmx::HcalAbstractID
static const RawValue BAR_TYPE_MASK {0x7}
 
static const RawValue BAR_TYPE_SHIFT {23}
 
static const RawValue HCAL_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

- Protected Attributes inherited from ldmx::DetectorID
RawValue id_
 The raw, packed value of the ID.
 

Detailed Description

Implements detector ids for HCal subdetector.

Definition at line 19 of file HcalID.h.

Member Enumeration Documentation

◆ HcalSection

Encodes the section of the HCal based on the 'section' field value.

Definition at line 24 of file HcalID.h.

24{ BACK = 0, TOP = 1, BOTTOM = 2, RIGHT = 3, LEFT = 4 };

Constructor & Destructor Documentation

◆ HcalID() [1/4]

ldmx::HcalID::HcalID ( )
inline

Empty HCAL id (but not null!)

Definition at line 36 of file HcalID.h.

36: HcalAbstractID() {}
HcalAbstractID()
Empty HCAL id (but not null!)

◆ HcalID() [2/4]

ldmx::HcalID::HcalID ( RawValue  rawid)
inline

Create from raw number.

Definition at line 41 of file HcalID.h.

41 : HcalAbstractID(rawid) {
42 if (!null() && bar_type() != Global) {
43 EXCEPTION_RAISE(
44 "DetectorIDMismatch",
45 "Attempted to create HcalID from mismatched Hcal bar_type " +
46 std::to_string(bar_type()));
47 }
48 }
bool null() const
Definition DetectorID.h:60
int bar_type() const
Get the value of the bar field from the ID.

References ldmx::HcalAbstractID::bar_type(), and ldmx::DetectorID::null().

◆ HcalID() [3/4]

ldmx::HcalID::HcalID ( const HcalAbstractID  id)
inline

Create from a DetectorID, but check.

Definition at line 53 of file HcalID.h.

53 : HcalAbstractID(id) {
54 if (!null() && bar_type() != Global) {
55 EXCEPTION_RAISE(
56 "DetectorIDMismatch",
57 "Attempted to create HcalID from mismatched Hcal bar_type " +
58 std::to_string(bar_type()));
59 }
60 }

References ldmx::HcalAbstractID::bar_type(), and ldmx::DetectorID::null().

◆ HcalID() [4/4]

ldmx::HcalID::HcalID ( unsigned int  section,
unsigned int  layer,
unsigned int  strip 
)
inline

Create from pieces.

Definition at line 65 of file HcalID.h.

66 : HcalAbstractID(Global, 0) {
67 id_ |= (section & SECTION_MASK) << SECTION_SHIFT;
68 id_ |= (layer & LAYER_MASK) << LAYER_SHIFT;
69 id_ |= (strip & STRIP_MASK) << STRIP_SHIFT;
70 }
RawValue id_
The raw, packed value of the ID.
Definition DetectorID.h:84
unsigned int strip() const
Get the value of the 'strip' field from the ID.
Definition HcalID.h:108
unsigned int layer() const
Get the value of the layer field from the ID.
Definition HcalID.h:90

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

Member Function Documentation

◆ createInterpreters()

void ldmx::HcalID::createInterpreters ( )
static

Definition at line 12 of file HcalID.cxx.

12 {
14 fields.push_back(new IDField("subdetector", 0, SUBDETECTORID_SHIFT, 31));
15 fields.push_back(
16 new IDField("section", 1, SECTION_SHIFT,
17 SECTION_SHIFT + IDField::countOnes(SECTION_MASK) - 1));
18 fields.push_back(
19 new IDField("layer", 2, LAYER_SHIFT,
20 LAYER_SHIFT + IDField::countOnes(LAYER_MASK) - 1));
21 fields.push_back(
22 new IDField("strip", 3, STRIP_SHIFT,
23 STRIP_SHIFT + IDField::countOnes(STRIP_MASK) - 1));
24
26 SD_HCAL, HcalAbstractID::BAR_TYPE_MASK << HcalAbstractID::BAR_TYPE_SHIFT,
27 HcalAbstractID::Global << HcalAbstractID::BAR_TYPE_SHIFT, fields);
28}
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

◆ getLayerID()

unsigned int ldmx::HcalID::getLayerID ( ) const
inline

Get the value of the layer field from the ID.

Returns
The value of the layer field.

Definition at line 96 of file HcalID.h.

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

References ldmx::DetectorID::id_.

Referenced by TEST_CASE().

◆ getSection()

unsigned int ldmx::HcalID::getSection ( ) const
inline

Definition at line 76 of file HcalID.h.

76 {
77 return (id_ >> SECTION_SHIFT) & SECTION_MASK;
78 }

◆ getStrip()

unsigned int ldmx::HcalID::getStrip ( ) const
inline

Get the value of the 'strip' field from the ID.

Returns
The value of 'strip' field.

Definition at line 102 of file HcalID.h.

102{ return (id_ >> STRIP_SHIFT) & STRIP_MASK; }

References ldmx::DetectorID::id_.

Referenced by TEST_CASE().

◆ layer()

unsigned int ldmx::HcalID::layer ( ) const
inline

Get the value of the layer field from the ID.

Returns
The value of the layer field.

Definition at line 90 of file HcalID.h.

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

References ldmx::DetectorID::id_.

Referenced by HcalID(), hcal::HcalDigiProducer::produce(), and TEST_CASE().

◆ section()

unsigned int ldmx::HcalID::section ( ) const
inline

Definition at line 84 of file HcalID.h.

84{ return (id_ >> SECTION_SHIFT) & SECTION_MASK; }

◆ strip()

unsigned int ldmx::HcalID::strip ( ) const
inline

Get the value of the 'strip' field from the ID.

Returns
The value of 'strip' field.

Definition at line 108 of file HcalID.h.

108{ return (id_ >> STRIP_SHIFT) & STRIP_MASK; }

References ldmx::DetectorID::id_.

Referenced by HcalID(), hcal::HcalDigiProducer::produce(), and TEST_CASE().

Member Data Documentation

◆ LAYER_MASK

const RawValue ldmx::HcalID::LAYER_MASK {0xFF}
static

Definition at line 28 of file HcalID.h.

28{0xFF}; // space for up to 255 layers

◆ LAYER_SHIFT

const RawValue ldmx::HcalID::LAYER_SHIFT {10}
static

Definition at line 29 of file HcalID.h.

29{10};

◆ SECTION_MASK

const RawValue ldmx::HcalID::SECTION_MASK {0x7}
static

Definition at line 26 of file HcalID.h.

26{0x7}; // space for up to 7 sections

◆ SECTION_SHIFT

const RawValue ldmx::HcalID::SECTION_SHIFT {18}
static

Definition at line 27 of file HcalID.h.

27{18};

◆ STRIP_MASK

const RawValue ldmx::HcalID::STRIP_MASK {0xFF}
static

Definition at line 30 of file HcalID.h.

30{0xFF}; // space for 255 strips/layer

◆ STRIP_SHIFT

const RawValue ldmx::HcalID::STRIP_SHIFT {0}
static

Definition at line 31 of file HcalID.h.

31{0};

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