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,
21 SD_TRACKER_TESTSTAND = 8,
23 EID_TRIGGER_SCINT = 17,
38 typedef uint32_t RawValue;
40 static const RawValue SUBDETECTORID_MASK{0x3F};
41 static const RawValue SUBDETECTORID_SHIFT{26};
42 static const RawValue SUBDETECTOR_PAYLOAD_MASK{0x3FFFFFF};
54 DetectorID(SubdetectorIDType sdtype, RawValue raw_subpayload) {
55 id_ = ((RawValue(sdtype) & DetectorID::SUBDETECTORID_MASK)
56 << DetectorID::SUBDETECTORID_SHIFT) |
57 (raw_subpayload & DetectorID::SUBDETECTOR_PAYLOAD_MASK);
65 return SubdetectorIDType((
id_ >> SUBDETECTORID_SHIFT) & SUBDETECTORID_MASK);
77 bool operator<(
const DetectorID&
id)
const {
return id_ <
id.id_; }
79 bool operator==(
const DetectorID&
id)
const {
return id_ ==
id.id_; }
81 bool operator!=(
const DetectorID&
id)
const {
return id_ !=
id.id_; }
90#define SUBDETECTORID_TEST(a, x) \
91 if (!null() && !(subdet() == x)) { \
92 EXCEPTION_RAISE("DetectorIDMismatch", "Attempted to create " + \
94 " from mismatched source " + \
95 std::to_string(subdet())); \
97#define SUBDETECTORID_TEST2(a, x, y) \
98 if (!null() && !(subdet() == x || subdet() == y)) { \
99 EXCEPTION_RAISE("DetectorIDMismatch", "Attempted to create " + \
101 " from mismatched source " + \
102 std::to_string(subdet())); \
104#define SUBDETECTORID_TEST3(a, x, y, z) \
105 if (!null() && !(subdet() == x || subdet() == y || subdet() == z)) { \
106 EXCEPTION_RAISE("DetectorIDMismatch", "Attempted to create " + \
108 " from mismatched source " + \
109 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.