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

Implements detector ids for special simulation-derived hits like scoring planes. More...

#include <SimSpecialID.h>

Public Types

enum  SimSpecialType { SCORING_PLANE = 1 }
 Encodes which of several possible special types this SimSpecial ID is. More...
 
- Public Types inherited from ldmx::DetectorID
typedef uint32_t RawValue
 

Public Member Functions

 SimSpecialID ()
 Empty id (but not null!)
 
 SimSpecialID (RawValue rawid)
 Create from raw number.
 
 SimSpecialID (const DetectorID id)
 Create from a DetectorID, but check.
 
 SimSpecialID (SimSpecialType sst, RawValue rawfield)
 Create from a subtype number and raw field.
 
SimSpecialType getSubtype () const
 
int plane () const
 Get the value of the plane field from the ID, if it is a scoring plane.
 
RawValue subtypePayload () const
 Get the raw payload contents.
 
- 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 SimSpecialID ScoringPlaneID (int plane)
 Create a scoring id from pieces.
 
static void createInterpreters ()
 

Static Public Attributes

static const RawValue SUBTYPE_MASK {0xF}
 
static const RawValue SUBTYPE_SHIFT {22}
 
static const RawValue SUBTYPE_DATA_MASK {0x3FFFFF}
 
static const RawValue PLANE_MASK
 
static const RawValue PLANE_SHIFT {0}
 
- 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 special simulation-derived hits like scoring planes.

Definition at line 15 of file SimSpecialID.h.

Member Enumeration Documentation

◆ SimSpecialType

Encodes which of several possible special types this SimSpecial ID is.

Definition at line 20 of file SimSpecialID.h.

20{ SCORING_PLANE = 1 };

Constructor & Destructor Documentation

◆ SimSpecialID() [1/4]

ldmx::SimSpecialID::SimSpecialID ( )
inline

Empty id (but not null!)

Definition at line 34 of file SimSpecialID.h.

34: DetectorID(SD_SIM_SPECIAL, 0) {}
DetectorID()
Class constructor for a null DetectorID.
Definition DetectorID.h:44

Referenced by ScoringPlaneID().

◆ SimSpecialID() [2/4]

ldmx::SimSpecialID::SimSpecialID ( RawValue  rawid)
inline

Create from raw number.

Definition at line 39 of file SimSpecialID.h.

39 : DetectorID(rawid) {
40 SUBDETECTORID_TEST("SimSpecialID", SD_SIM_SPECIAL);
41 }

◆ SimSpecialID() [3/4]

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

Create from a DetectorID, but check.

Definition at line 46 of file SimSpecialID.h.

46 : DetectorID(id) {
47 SUBDETECTORID_TEST("SimSpecialID", SD_SIM_SPECIAL);
48 }

◆ SimSpecialID() [4/4]

ldmx::SimSpecialID::SimSpecialID ( SimSpecialType  sst,
RawValue  rawfield 
)
inline

Create from a subtype number and raw field.

Definition at line 53 of file SimSpecialID.h.

54 : DetectorID(SD_SIM_SPECIAL, 0) {
55 id_ |= ((sst & SUBTYPE_MASK) << SUBTYPE_SHIFT);
56 id_ |= rawfield & SUBTYPE_DATA_MASK;
57 }
RawValue id_
The raw, packed value of the ID.
Definition DetectorID.h:84

References ldmx::DetectorID::id_.

Member Function Documentation

◆ createInterpreters()

void ldmx::SimSpecialID::createInterpreters ( )
static

Definition at line 16 of file SimSpecialID.cxx.

16 {
18 fields.push_back(new IDField("subdetector", 0, SUBDETECTORID_SHIFT, 31));
19 fields.push_back(
20 new IDField("subtype", 1, SUBTYPE_SHIFT,
21 SUBTYPE_SHIFT + IDField::countOnes(SUBTYPE_MASK) - 1));
22 fields.push_back(
23 new IDField("payload", 2, 0, IDField::countOnes(SUBTYPE_DATA_MASK) - 1));
24
25 DetectorIDInterpreter::registerInterpreter(SD_SIM_SPECIAL, fields);
26}
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

◆ getSubtype()

SimSpecialType ldmx::SimSpecialID::getSubtype ( ) const
inline

Definition at line 70 of file SimSpecialID.h.

70 {
71 return SimSpecialType((id_ >> SUBTYPE_SHIFT) & SUBTYPE_MASK);
72 }
SimSpecialType
Encodes which of several possible special types this SimSpecial ID is.

◆ plane()

int ldmx::SimSpecialID::plane ( ) const
inline

Get the value of the plane field from the ID, if it is a scoring plane.

Returns
The value of the plane field or -1 if not a scoring plane

Definition at line 78 of file SimSpecialID.h.

78 {
79 return (getSubtype() == SCORING_PLANE) ? ((id_ >> PLANE_SHIFT) & PLANE_MASK)
80 : (-1);
81 }

References ldmx::DetectorID::id_.

Referenced by ecal::EcalVetoProcessor::produce(), ScoringPlaneID(), and TEST_CASE().

◆ ScoringPlaneID()

static SimSpecialID ldmx::SimSpecialID::ScoringPlaneID ( int  plane)
inlinestatic

Create a scoring id from pieces.

Definition at line 62 of file SimSpecialID.h.

62 {
63 return SimSpecialID(SCORING_PLANE, (plane & PLANE_MASK) << PLANE_SHIFT);
64 }
SimSpecialID()
Empty id (but not null!)
int plane() const
Get the value of the plane field from the ID, if it is a scoring plane.

References plane(), and SimSpecialID().

Referenced by simcore::ScoringPlaneSD::ProcessHits().

◆ subtypePayload()

RawValue ldmx::SimSpecialID::subtypePayload ( ) const
inline

Get the raw payload contents.

Definition at line 86 of file SimSpecialID.h.

86{ return id_ & SUBTYPE_DATA_MASK; }

References ldmx::DetectorID::id_.

Referenced by TEST_CASE().

Member Data Documentation

◆ PLANE_MASK

const RawValue ldmx::SimSpecialID::PLANE_MASK
static
Initial value:
{
0xFFF}

Definition at line 27 of file SimSpecialID.h.

27 {
28 0xFFF}; // space for up to 4096 scoring planes

◆ PLANE_SHIFT

const RawValue ldmx::SimSpecialID::PLANE_SHIFT {0}
static

Definition at line 29 of file SimSpecialID.h.

29{0};

◆ SUBTYPE_DATA_MASK

const RawValue ldmx::SimSpecialID::SUBTYPE_DATA_MASK {0x3FFFFF}
static

Definition at line 24 of file SimSpecialID.h.

24{0x3FFFFF};

◆ SUBTYPE_MASK

const RawValue ldmx::SimSpecialID::SUBTYPE_MASK {0xF}
static

Definition at line 22 of file SimSpecialID.h.

22{0xF}; // space for up to 15 subtypes

◆ SUBTYPE_SHIFT

const RawValue ldmx::SimSpecialID::SUBTYPE_SHIFT {22}
static

Definition at line 23 of file SimSpecialID.h.

23{22};

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