CbmRoot
Loading...
Searching...
No Matches
_GTestDigiEventSelector.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer] */
4
5#include "MicrosliceDescriptor.hpp"
10#include "gtest/gtest-spi.h"
11#include "gtest/gtest.h"
12
13#include <unordered_set>
14
15#include <yaml-cpp/yaml.h>
16
17using namespace cbm::algo;
18
19// FIXME: This test should be rewritten for main CBM
20
21TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple)
22{
23 SCOPED_TRACE("CheckDigiEventSelectorAlgorithSimple");
24
25
26 // --- Test number of digis per system
27 size_t nBmon = 1;
28 size_t nSts = 2;
29 size_t nMuch = 3;
30 size_t nRich = 4;
31 size_t nTrd = 5;
32 size_t nTrd2d = 6;
33 size_t nTof = 7;
34 size_t nPsd = 8;
35 size_t nFsd = 9;
36
37 DigiEvent event;
38 for (size_t i = 0; i < nBmon; i++)
39 event.fBmon.push_back(CbmBmonDigi());
40 for (size_t i = 0; i < nSts; i++)
41 event.fSts.push_back(CbmStsDigi());
42 for (size_t i = 0; i < nMuch; i++)
43 event.fMuch.push_back(CbmMuchDigi());
44 for (size_t i = 0; i < nRich; i++)
45 event.fRich.push_back(CbmRichDigi());
46 for (size_t i = 0; i < nTrd; i++)
47 event.fTrd.push_back(CbmTrdDigi());
48 for (size_t i = 0; i < nTrd2d; i++)
49 event.fTrd2d.push_back(CbmTrdDigi());
50 for (size_t i = 0; i < nTof; i++)
51 event.fTof.push_back(CbmTofDigi());
52 for (size_t i = 0; i < nPsd; i++)
53 event.fPsd.push_back(CbmPsdDigi());
54 for (size_t i = 0; i < nFsd; i++)
55 event.fFsd.push_back(CbmFsdDigi());
56
57 // Create a reco setup, which contains mTOF versions for nickel-2022 (but for some reason with 8 STS stations)
58 // NOTE: in this test, the setup does not contain information on the full and active volumes,
59 // only tracking station ID mappings
60 // FIXME: Provide a path to the file
61 auto recoSetup = std::make_shared<RecoSetup>();
62 {
63 {
64 std::pair<std::vector<GeoVolume>, std::vector<GeoVolume>> dummyStationVols;
65 std::vector<std::pair<uint32_t, int>> trkStationId = {
66 {std::numeric_limits<uint32_t>::max(), 0}, // unit 0
67 {std::numeric_limits<uint32_t>::max(), 1}, // unit 1
68 {std::numeric_limits<uint32_t>::max(), 2}, // unit 2
69 {std::numeric_limits<uint32_t>::max(), 3}, // unit 3
70 {std::numeric_limits<uint32_t>::max(), 4}, // unit 4
71 {std::numeric_limits<uint32_t>::max(), 5}, // unit 5
72 {std::numeric_limits<uint32_t>::max(), 6}, // unit 6
73 {std::numeric_limits<uint32_t>::max(), 7}, // unit 7
74 {std::numeric_limits<uint32_t>::max(), 8} // unit 8
75 };
76 recoSetup->SetSts(std::move(sts::RecoSetupUnit(std::move(dummyStationVols), std::move(trkStationId))));
77 }
78 { // TOF
79 using SmTypeInfo_t = tof::TrkStationIdMap::SmTypeInfo;
80 std::pair<std::vector<GeoVolume>, std::vector<GeoVolume>> dummyStationVols;
81 std::vector<SmTypeInfo_t> smTypeRpcMap = {
82 SmTypeInfo_t{.offset = 0, .nSm = 5, .nRpc = 5}, // iSmType 0: N = 25
83 SmTypeInfo_t{.offset = 25, .nSm = 0, .nRpc = 3}, // iSmType 1: N = 0
84 SmTypeInfo_t{.offset = 25, .nSm = 1, .nRpc = 5}, // iSmType 2: N = 5
85 SmTypeInfo_t{.offset = 30, .nSm = 0, .nRpc = 1}, // iSmType 3: N = 0
86 SmTypeInfo_t{.offset = 30, .nSm = 0, .nRpc = 1}, // iSmType 4: N = 0
87 SmTypeInfo_t{.offset = 30, .nSm = 1, .nRpc = 1}, // iSmType 5: N = 1
88 SmTypeInfo_t{.offset = 31, .nSm = 1, .nRpc = 2}, // iSmType 6: N = 2
89 SmTypeInfo_t{.offset = 33, .nSm = 1, .nRpc = 2}, // iSmType 7: N = 2
90 SmTypeInfo_t{.offset = 35, .nSm = 0, .nRpc = 1}, // iSmType 8: N = 0
91 SmTypeInfo_t{.offset = 35, .nSm = 1, .nRpc = 2} // iSmType 9: N = 2
92 };
93 std::vector<int> trkStationIdMap = {
94 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, // iSmType 0
95 2, 2, 2, 2, 2, // iSmType 2
96 -1, // iSmType 5
97 1, 1, // iSmType 6
98 1, 1, // iSmType 7
99 1, 2 // iSmType 9
100 };
101 tof::TrkStationIdMap stationIdMap(std::move(smTypeRpcMap), std::move(trkStationIdMap));
102 recoSetup->SetTof(std::move(tof::RecoSetupUnit(std::move(dummyStationVols), std::move(stationIdMap))));
103 }
104 }
105
106 YAML::Node node;
107 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kBmon))] = nBmon;
108 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kSts))] = nSts;
109 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kMuch))] = nMuch;
110 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kRich))] = nRich;
111 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kTrd))] = nTrd;
112 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kTrd2d))] = nTrd2d;
113 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kTof))] = nTof;
114 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kPsd))] = nPsd;
115 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kFsd))] = nFsd;
116
117 {
118 // --- Check with created numbers of digis - should pass
121 select.RegisterSetup(recoSetup);
122 EXPECT_EQ(select(event), true);
123 }
124
125 {
126 // --- Increment Bmon - should fail
127 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kBmon))] = nBmon + 1;
130 select.RegisterSetup(recoSetup);
131 EXPECT_EQ(select(event), false);
132 }
133
134 {
135 // --- Increment STS - should fail
136 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kSts))] = nSts + 1;
139 select.RegisterSetup(recoSetup);
140 EXPECT_EQ(select(event), false);
141 }
142
143 {
144 // --- Increment MUCH - should fail
145 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kMuch))] = nMuch + 1;
148 select.RegisterSetup(recoSetup);
149 EXPECT_EQ(select(event), false);
150 }
151
152 {
153 // --- Increment RICH - should fail
154 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kRich))] = nRich + 1;
157 select.RegisterSetup(recoSetup);
158 EXPECT_EQ(select(event), false);
159 }
160
161 {
162 // --- Increment TRD - should fail
163 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kTrd))] = nTrd + 1;
166 select.RegisterSetup(recoSetup);
167 EXPECT_EQ(select(event), false);
168 }
169
170 {
171 // --- Increment TRD2D - should fail
172 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kTrd2d))] = nTrd2d + 1;
175 select.RegisterSetup(recoSetup);
176 EXPECT_EQ(select(event), false);
177 }
178
179 {
180 // --- Increment TOF - should fail
181 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kTof))] = nTof + 1;
184 select.RegisterSetup(recoSetup);
185 EXPECT_EQ(select(event), false);
186 }
187
188 {
189 // --- Increment PSD - should fail
190 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kPsd))] = nPsd + 1;
193 select.RegisterSetup(recoSetup);
194 EXPECT_EQ(select(event), false);
195 }
196
197 {
198 // --- Increment FSD - should fail
199 node["minDigis"][std::string(cbm::util::ToString(ECbmModuleId::kFsd))] = nFsd + 1;
202 select.RegisterSetup(recoSetup);
203 EXPECT_EQ(select(event), false);
204 }
205
206 {
207 // --- Test number of STS stations
208 {
209 const uint maxStsStations = 8; // FIXME: it is a unit, not a station
210 const uint maxStsModules = 12;
211 const uint maxStsLadders = 4;
212
213 for (uint numStations = 1; numStations < maxStsStations; numStations++) {
214 //Prepare input
215 DigiEvent eventIn;
216 //Produce digi pairs with valid addresses
217 for (uint station = 0; station < numStations; station++) {
218 for (uint module = 0; module < maxStsModules; module++) {
219 for (uint ladder = 0; ladder < maxStsLadders; ladder++) {
220 for (uint halfladder = 0; halfladder <= 1; halfladder++) {
221 //add digis pairs
222 int32_t address = CbmStsAddress::GetAddress(station, ladder, halfladder, module);
223 eventIn.fSts.push_back(CbmStsDigi(address, 0, 0.0, 0.0));
224 eventIn.fSts.push_back(CbmStsDigi(address, 1024, 0.0, 0.0)); //other side channel
225
226 //add digis from next station without partner for intentionally failed test
227 int32_t nextAddress = CbmStsAddress::GetAddress(numStations, ladder, 0, module);
228 eventIn.fSts.push_back(CbmStsDigi(nextAddress, 1024, 0.0, 0.0));
229 }
230 }
231 }
232 }
233
234 YAML::Node node2;
235 //L_(info) << "tof min layers: " << numStations;
236 { // Test correct number of stations - should pass
237 node2["minLayers"][std::string(cbm::util::ToString(ECbmModuleId::kSts))] = numStations;
240 select.RegisterSetup(recoSetup);
241 EXPECT_EQ(select(eventIn), true);
242 }
243
244 {
245 // Test if digi without partner is properly disregarded
246 node2["minLayers"][std::string(cbm::util::ToString(ECbmModuleId::kSts))] = numStations + 1;
249 select.RegisterSetup(recoSetup);
250 EXPECT_EQ(select(eventIn), false);
251 }
252 }
253 }
254
255
256 // --- Test number of TOF layers
257 {
258 //Prepare input
259 DigiEvent eventIn;
260 std::unordered_set<int32_t> setTofStation;
261 const auto* tofUnit{recoSetup->GetTof()};
262 assert(tofUnit);
263 const auto& stationIdMap{tofUnit->GetTrkStationIdMap()};
264
265 for (uint16_t smType = 0; smType < stationIdMap.GetNofSmTypes(); smType++) {
266 for (uint16_t sm = 0; sm < stationIdMap.GetNofSm(smType); sm++) {
267 for (uint16_t rpc = 0; rpc < stationIdMap.GetNofRpc(smType); rpc++) {
268
269 uint32_t addrFront = CbmTofAddress::GetUniqueAddress(sm, rpc, 0, 0, smType, 0);
270 uint32_t addrBack = CbmTofAddress::GetUniqueAddress(sm, rpc, 0, 1, smType, 0);
271 eventIn.fTof.push_back(CbmTofDigi(addrFront, 0.0, 0.0));
272 eventIn.fTof.push_back(CbmTofDigi(addrBack, 0.0, 0.0));
273 int iTrkStation = stationIdMap.GetTrackingStationIndex(smType, sm, rpc);
274 if (iTrkStation > -1) {
275 // Some of RPCs are disabled in tracking: => don't count it (e.g. smType=5 is BMON, its address
276 // gives iTrkStation = -1 by definition)
277 setTofStation.insert(iTrkStation);
278 }
279
280 YAML::Node node2;
281
282 { // Test actual number of layers -- should pass
283 node2["minLayers"][std::string(cbm::util::ToString(ECbmModuleId::kTof))] = setTofStation.size();
286 select.RegisterSetup(recoSetup);
287 EXPECT_EQ(select(eventIn), true);
288 }
289
290 { // Test with one more station - should fail
291 node2["minLayers"][std::string(cbm::util::ToString(ECbmModuleId::kTof))] = setTofStation.size() + 1;
294 select.RegisterSetup(recoSetup);
295 EXPECT_EQ(select(eventIn), false);
296 }
297 }
298 }
299 }
300 }
301 }
302}
@ kTrd
Transition Radiation Detector.
Definition CbmDefs.h:51
@ kTof
Time-of-flight Detector.
Definition CbmDefs.h:52
@ kPsd
Projectile spectator detector.
Definition CbmDefs.h:54
@ kSts
Silicon Tracking System.
Definition CbmDefs.h:48
@ kTrd2d
TRD-FASP Detector (FIXME)
Definition CbmDefs.h:58
@ kMuch
Muon detection system.
Definition CbmDefs.h:50
@ kFsd
Forward spectator detector.
Definition CbmDefs.h:59
@ kBmon
Bmon Counter.
Definition CbmDefs.h:57
@ kRich
Ring-Imaging Cherenkov Detector.
Definition CbmDefs.h:49
This file contains the definition of the ParFiles class.
A structure to keep parameter files for reconstruction.
TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple)
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:31
Data class for FSD digital information.
Definition CbmFsdDigi.h:36
Data class for PSD digital information.
Definition CbmPsdDigi.h:36
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47
Configuration of the DigiEventSelector class.
Algorithm to select CbmDigiEvents based on the number of digis and the number of activated layers in ...
void RegisterSetup(std::shared_ptr< RecoSetup > pSetup)
Registers tracking setup.
TOF detector representation in online/offline reconstruction.
A mapper for TOF tracking stations.
int32_t GetAddress(uint32_t unit=0, uint32_t ladder=0, uint32_t halfladder=0, uint32_t module=0, uint32_t sensor=0, uint32_t side=0, uint32_t version=kCurrentVersion)
Construct address.
std::string_view ToString(T t)
Definition CbmEnumDict.h:64
PODVector< CbmRichDigi > fRich
Unpacked RICH digis.
Definition DigiData.h:41
PODVector< CbmTrdDigi > fTrd
Unpacked TRD digis.
Definition DigiData.h:39
PODVector< CbmStsDigi > fSts
Unpacked STS digis.
Definition DigiData.h:34
PODVector< CbmTrdDigi > fTrd2d
Unpacked TRD2D digis.
Definition DigiData.h:40
PODVector< CbmFsdDigi > fFsd
Unpacked FSD digis.
Definition DigiData.h:43
PODVector< CbmTofDigi > fTof
Unpacked TOF digis.
Definition DigiData.h:37
PODVector< CbmPsdDigi > fPsd
Unpacked PSD digis.
Definition DigiData.h:42
PODVector< CbmMuchDigi > fMuch
Unpacked MUCH digis.
Definition DigiData.h:35
PODVector< CbmBmonDigi > fBmon
Unpacked Bmon digis.
Definition DigiData.h:38
Event data with event number and trigger time.
Definition DigiData.h:82
Information on RPC offsets for each SM type.