LDMX Software
SimSpecialID.h
1
2#ifndef DETDESCR_SIMSPECIALID_H
3#define DETDESCR_SIMSPECIALID_H
4
5// LDMX
6#include "DetDescr/DetectorID.h"
7
8namespace ldmx {
9
15class SimSpecialID : public DetectorID {
16 public:
20 enum SimSpecialType { SCORING_PLANE = 1 };
21
22 static const RawValue SUBTYPE_MASK{0xF}; // space for up to 15 subtypes
23 static const RawValue SUBTYPE_SHIFT{22};
24 static const RawValue SUBTYPE_DATA_MASK{0x3FFFFF};
25
26 // scoring plane only
27 static const RawValue PLANE_MASK{
28 0xFFF}; // space for up to 4096 scoring planes
29 static const RawValue PLANE_SHIFT{0};
30
34 SimSpecialID() : DetectorID(SD_SIM_SPECIAL, 0) {}
35
39 SimSpecialID(RawValue rawid) : DetectorID(rawid) {
40 SUBDETECTORID_TEST("SimSpecialID", SD_SIM_SPECIAL);
41 }
42
47 SUBDETECTORID_TEST("SimSpecialID", SD_SIM_SPECIAL);
48 }
49
53 SimSpecialID(SimSpecialType sst, RawValue rawfield)
54 : DetectorID(SD_SIM_SPECIAL, 0) {
55 id_ |= ((sst & SUBTYPE_MASK) << SUBTYPE_SHIFT);
56 id_ |= rawfield & SUBTYPE_DATA_MASK;
57 }
58
63 return SimSpecialID(SCORING_PLANE, (plane & PLANE_MASK) << PLANE_SHIFT);
64 }
65
66 /*
67 * Get the value of the 'section' field from the ID.
68 * @return The value of the 'strip' field.
69 */
70 SimSpecialType getSubtype() const {
71 return SimSpecialType((id_ >> SUBTYPE_SHIFT) & SUBTYPE_MASK);
72 }
73
78 int plane() const {
79 return (getSubtype() == SCORING_PLANE) ? ((id_ >> PLANE_SHIFT) & PLANE_MASK)
80 : (-1);
81 }
82
86 RawValue subtypePayload() const { return id_ & SUBTYPE_DATA_MASK; }
87
88 static void createInterpreters();
89};
90} // namespace ldmx
91
92std::ostream& operator<<(std::ostream&, const ldmx::SimSpecialID&);
93
94#endif
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
Definition DetectorID.h:35
RawValue id_
The raw, packed value of the ID.
Definition DetectorID.h:84
Implements detector ids for special simulation-derived hits like scoring planes.
SimSpecialID(SimSpecialType sst, RawValue rawfield)
Create from a subtype number and raw field.
SimSpecialID(RawValue rawid)
Create from raw number.
SimSpecialID()
Empty id (but not null!)
static SimSpecialID ScoringPlaneID(int plane)
Create a scoring id from pieces.
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.
SimSpecialID(const DetectorID id)
Create from a DetectorID, but check.
SimSpecialType
Encodes which of several possible special types this SimSpecial ID is.