Test for DetectorID function.
First argument is name of this test. Second argument is tags to group tests together.
22 {
23 using namespace ldmx;
31
33
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);
41 }
42 SECTION("EcalID") {
44 EcalID eid_raw(0x14002020);
45
46 REQUIRE_THROWS(
EcalID(did_raw));
47 REQUIRE_THROWS(
EcalID(0x829018));
48 REQUIRE_NOTHROW(
EcalID(did_ecal));
49 REQUIRE_NOTHROW(
EcalID(did_ecal.raw()));
50
52
53 REQUIRE(eid.raw() == 0x1464f1f4);
54
55 REQUIRE(eid.layer() == 50);
56 REQUIRE(eid.layer() == eid.getLayerID());
57 REQUIRE(eid.module() == 15);
58 REQUIRE(eid.module() == eid.getModuleID());
59 REQUIRE(eid.cell() == 500);
60 REQUIRE(eid.cell() == eid.getCellID());
61
62 std::stringstream ss;
63 ss << eid;
64
65 REQUIRE(ss.str() == "Ecal(50,15,500[92,23])");
66
68
69 CHECK(dii.getFieldValue("layer") == 50);
70 CHECK(dii.getFieldValue("module") == 15);
71 CHECK(dii.getFieldValue("cell") == 500);
72
73 dii.setFieldValue("layer", 23);
74 dii.setFieldValue("module", 13);
75 dii.setFieldValue("cell", 223);
76
78
79 CHECK(eid.layer() == 23);
80 CHECK(eid.module() == 13);
81 CHECK(eid.cell() == 223);
82 }
83 SECTION("HcalID") {
85 HcalID hid_raw(0x18002020);
86
87 REQUIRE_THROWS(
HcalID(did_raw));
88 REQUIRE_THROWS(
HcalID(0x829018));
89 REQUIRE_NOTHROW(
HcalID(did_hcal));
90 REQUIRE_NOTHROW(
HcalID(did_hcal.raw()));
91
92
93 HcalID hid(HcalID::LEFT, 250, 245);
94
95 REQUIRE(hid.raw() == 0x1813e8f5);
96
97 REQUIRE(hid.layer() == 250);
98 REQUIRE(hid.layer() == hid.getLayerID());
99 REQUIRE(hid.section() == HcalID::LEFT);
100 REQUIRE(hid.section() == hid.getSection());
101 REQUIRE(hid.strip() == 245);
102 REQUIRE(hid.strip() == hid.getStrip());
103
104 std::stringstream ss;
105 ss << hid;
106
107 REQUIRE(ss.str() == "Hcal(4,250,245)");
108
110
111 CHECK(dii.getFieldValue("layer") == 250);
112 CHECK(dii.getFieldValue("section") == 4);
113 CHECK(dii.getFieldValue("strip") == 245);
114
115 dii.setFieldValue("layer", 23);
116 dii.setFieldValue("section", 1);
117 dii.setFieldValue("strip", 223);
118
119 hid =
HcalID(dii.getId());
120
121 CHECK(hid.layer() == 23);
122 CHECK(hid.section() == 1);
123 CHECK(hid.strip() == 223);
124 }
125
126 SECTION("TrackerID") {
129
133 REQUIRE_NOTHROW(
TrackerID(did_tk.raw()));
134
135
136 TrackerID tid(SD_TRACKER_TAGGER, 250, 30);
137
138 TrackerID tid2(SD_TRACKER_RECOIL, 220, 17);
139
140 REQUIRE(tid.raw() == 0x4001efa);
141 REQUIRE(tid2.raw() == 0x100011dc);
142
143 REQUIRE(tid.layer() == 250);
144 REQUIRE(tid.module() == 30);
145
146 REQUIRE(tid2.layer() == 220);
147 REQUIRE(tid2.module() == 17);
148
149 std::stringstream ss;
150 ss << tid << tid2;
151
152 REQUIRE(ss.str() == "Tagger(250,30)Recoil(220,17)");
153
155
156 CHECK(dii.getFieldValue("layer") == 250);
157 CHECK(dii.getFieldValue("module") == 30);
158
159 dii.setFieldValue("layer", 213);
160 dii.setFieldValue("module", 23);
161
163
164 CHECK(tid.layer() == 213);
165 CHECK(tid.module() == 23);
166 }
167 SECTION("TrigScintID") {
170
175
176
178
179 CHECK(ts_id.raw() == 0x800faf5);
180
181 REQUIRE(ts_id.module() == 250);
182 REQUIRE(ts_id.getModule() == 250);
183 REQUIRE(ts_id.bar() == 245);
184 REQUIRE(ts_id.bar() == ts_id.getBarID());
185
186 std::stringstream ss;
187 ss << ts_id;
188
189 REQUIRE(ss.str() == "TrigScint(250,245)");
190
192
193 CHECK(dii.getFieldValue("bar") == 245);
194 CHECK(dii.getFieldValue("module") == 250);
195
196 dii.setFieldValue("bar", 213);
197 dii.setFieldValue("module", 23);
198
200
201 CHECK(ts_id.bar() == 213);
202 CHECK(ts_id.module() == 23);
203 }
204 SECTION("SimSpecialID") {
207
212
213
216
217 CHECK(ssid.
raw() == 0x1c400c8a);
218 CHECK(ssid2.raw() == 0x1c4fedcb);
219
220 REQUIRE(ssid.getSubtype() == SimSpecialID::SCORING_PLANE);
221 REQUIRE(ssid2.getSubtype() == 1);
222
223 REQUIRE(ssid.
plane() == 3210);
224 REQUIRE(ssid2.plane() == 3531);
226 REQUIRE(ssid2.subtypePayload() == 0xfedcb);
227
228 std::stringstream ss;
229 ss << ssid << ssid2;
230
231 REQUIRE(ss.str() ==
232 "SimSpecial(ScoringPlane 3210)SimSpecial(ScoringPlane 3531)");
233
235
236 CHECK(dii.getFieldValue("subtype") == 1);
237 CHECK(dii.getFieldValue("payload") == 3210);
238 }
239}
Class provides an "introspection" capability for the 32-bit packed IDs used for uniquely identifying ...
Defines a 32-bit packed ID for uniquely identifying hits and detector components.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Implements detector ids for HCal subdetector.
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.
Class that defines the detector ID of the trigger scintillator.