2#ifndef DETDESCR_DETECTORID_H_
3#define DETDESCR_DETECTORID_H_
8#include "Framework/Exception/Exception.h"
12typedef enum SubdetectorIDTypeEnum {
14 SD_TRACKER_TAGGER = 1,
17 SD_TRACKER_RECOIL = 4,
22 EID_TRIGGER_SCINT = 17,
37 typedef uint32_t RawValue;
39 static const RawValue SUBDETECTORID_MASK{0x3F};
40 static const RawValue SUBDETECTORID_SHIFT{26};
41 static const RawValue SUBDETECTOR_PAYLOAD_MASK{0x3FFFFFF};
53 DetectorID(SubdetectorIDType sdtype, RawValue raw_subpayload) {
54 id_ = ((RawValue(sdtype) & DetectorID::SUBDETECTORID_MASK)
55 << DetectorID::SUBDETECTORID_SHIFT) |
56 (raw_subpayload & DetectorID::SUBDETECTOR_PAYLOAD_MASK);
64 return SubdetectorIDType((
id_ >> SUBDETECTORID_SHIFT) & SUBDETECTORID_MASK);
76 bool operator<(
const DetectorID&
id)
const {
return id_ <
id.id_; }
78 bool operator==(
const DetectorID&
id)
const {
return id_ ==
id.id_; }
80 bool operator!=(
const DetectorID&
id)
const {
return id_ !=
id.id_; }
89#define SUBDETECTORID_TEST(a, x) \
90 if (!null() && !(subdet() == x)) { \
91 EXCEPTION_RAISE("DetectorIDMismatch", "Attempted to create " + \
93 " from mismatched source " + \
94 std::to_string(subdet())); \
96#define SUBDETECTORID_TEST2(a, x, y) \
97 if (!null() && !(subdet() == x || subdet() == y)) { \
98 EXCEPTION_RAISE("DetectorIDMismatch", "Attempted to create " + \
100 " from mismatched source " + \
101 std::to_string(subdet())); \
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
void setRawValue(RawValue rawValue)
Set the raw value of the detector ID.
DetectorID(RawValue rawid)
Class constructor from a raw 32-bit integer.
SubdetectorIDType subdet() const
RawValue id_
The raw, packed value of the ID.
DetectorID(SubdetectorIDType sdtype, RawValue raw_subpayload)
Class constructor from a subdetector id and a subdetector-specific section (masked to.
DetectorID()
Class constructor for a null DetectorID.