5#include <catch2/catch_test_macros.hpp>
8#include "DetDescr/DetectorID.h"
9#include "DetDescr/DetectorIDInterpreter.h"
12#include "DetDescr/SimSpecialID.h"
14#include "DetDescr/TrigScintID.h"
22TEST_CASE(
"DetectorID",
"[DetDescr][functionality]") {
34 SECTION(
"Detector ID") {
35 REQUIRE(did_null.
null());
36 REQUIRE(did_raw.
subdet() == EID_TRACKER);
37 REQUIRE(did_ecal.
subdet() == SD_ECAL);
38 REQUIRE(did_ecal.
raw() == 0x14001010);
39 REQUIRE(did_ecal < did_raw);
40 REQUIRE(did_ecal != did_null);
44 EcalID eid_raw(0x14002020);
46 REQUIRE_THROWS(
EcalID(did_raw));
47 REQUIRE_THROWS(
EcalID(0x829018));
48 REQUIRE_NOTHROW(
EcalID(did_ecal));
53 REQUIRE(eid.
raw() == 0x1464f1f4);
55 REQUIRE(eid.
layer() == 50);
57 REQUIRE(eid.
module() == 15);
59 REQUIRE(eid.
cell() == 500);
65 REQUIRE(ss.str() ==
"Ecal(50,15,500[92,23])");
79 CHECK(eid.
layer() == 23);
81 CHECK(eid.
cell() == 223);
85 HcalID hid_raw(0x18002020);
87 REQUIRE_THROWS(
HcalID(did_raw));
88 REQUIRE_THROWS(
HcalID(0x829018));
89 REQUIRE_NOTHROW(
HcalID(did_hcal));
93 HcalID hid(HcalID::LEFT, 250, 245);
95 REQUIRE(hid.
raw() == 0x1813e8f5);
97 REQUIRE(hid.
layer() == 250);
99 REQUIRE(hid.section() == HcalID::LEFT);
100 REQUIRE(hid.section() == hid.getSection());
101 REQUIRE(hid.
strip() == 245);
104 std::stringstream ss;
107 REQUIRE(ss.str() ==
"Hcal(4,250,245)");
121 CHECK(hid.
layer() == 23);
122 CHECK(hid.section() == 1);
123 CHECK(hid.
strip() == 223);
126 SECTION(
"TrackerID") {
136 TrackerID tid(SD_TRACKER_TAGGER, 250, 30);
138 TrackerID tid2(SD_TRACKER_RECOIL, 220, 17);
140 REQUIRE(tid.
raw() == 0x4001efa);
141 REQUIRE(tid2.
raw() == 0x100011dc);
143 REQUIRE(tid.
layer() == 250);
144 REQUIRE(tid.
module() == 30);
146 REQUIRE(tid2.
layer() == 220);
147 REQUIRE(tid2.
module() == 17);
149 std::stringstream ss;
152 REQUIRE(ss.str() ==
"Tagger(250,30)Recoil(220,17)");
164 CHECK(tid.
layer() == 213);
165 CHECK(tid.
module() == 23);
167 SECTION(
"TrigScintID") {
179 CHECK(ts_id.
raw() == 0x800faf5);
181 REQUIRE(ts_id.
module() == 250);
183 REQUIRE(ts_id.
bar() == 245);
186 std::stringstream ss;
189 REQUIRE(ss.str() ==
"TrigScint(250,245)");
201 CHECK(ts_id.
bar() == 213);
202 CHECK(ts_id.
module() == 23);
204 SECTION(
"SimSpecialID") {
217 CHECK(ssid.
raw() == 0x1c400c8a);
218 CHECK(ssid2.
raw() == 0x1c4fedcb);
220 REQUIRE(ssid.getSubtype() == SimSpecialID::SCORING_PLANE);
221 REQUIRE(ssid2.getSubtype() == 1);
223 REQUIRE(ssid.
plane() == 3210);
224 REQUIRE(ssid2.
plane() == 3531);
228 std::stringstream ss;
232 "SimSpecial(ScoringPlane 3210)SimSpecial(ScoringPlane 3531)");
TEST_CASE("DetectorID", "[DetDescr][functionality]")
Test for DetectorID function.
Class that defines an ECal detector ID with a cell number.
Class that defines an HCal sensitive detector.
Class that defines a Tracker detector ID with a module number.
Class provides an "introspection" capability for the 32-bit packed IDs used for uniquely identifying ...
FieldValue getFieldValue(int i) const
Decode and return a field's value from the raw ID.
DetectorID getId() const
Get the raw value of the detector ID.
void setFieldValue(int i, FieldValue value)
Set a field value by index in the field value list.
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
SubdetectorIDType subdet() const
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
int cell() const
Get the value of the cell field from the ID.
int getCellID() const
Get the value of the cell field from the ID.
int getLayerID() const
Get the value of the layer field from the ID.
int getModuleID() const
Get the value of the module field from the ID.
int module() const
Get the value of the module field from the ID.
int layer() const
Get the value of the layer field from the ID.
Implements detector ids for HCal subdetector.
unsigned int strip() const
Get the value of the 'strip' field from the ID.
unsigned int getStrip() const
Get the value of the 'strip' field from the ID.
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.
Implements detector ids for special simulation-derived hits like scoring planes.
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.
SimSpecialType
Encodes which of several possible special types this SimSpecial ID is.
Extension of DetectorID providing access to layer and module number for tracker IDs.
int module() const
Get the value of the module field from the ID.
int layer() const
Get the value of the layer field from the ID.
Class that defines the detector ID of the trigger scintillator.
int module() const
Get the value of the module field from the ID.
int getModule() const
Get the value of the module field from the ID.
int getBarID() const
Get the bar ID.
int bar() const
Get the value of the bar field from the ID.