Project
Loading...
Searching...
No Matches
testEventFinder.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17// test pattern:
18// BC : 0 4 8 12 16 20 24 28 32
19// MCH ROF: [- - - -|- - - -|- - - -]- - - - - - - -[- - - -]- - - - - - - - -
20// MID ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
21
22#define BOOST_TEST_MODULE Test MCHTriggering EventFinder
23#define BOOST_TEST_DYN_LINK
24
25#include <initializer_list>
26#include <utility>
27#include <vector>
28
29#include <boost/test/unit_test.hpp>
30#include <boost/property_tree/ptree.hpp>
31
39
40BOOST_AUTO_TEST_SUITE(mchtriggering)
41
42using ObjLabel = std::pair<uint32_t, o2::MCCompLabel>;
43
44o2::dataformats::MCLabelContainer createLabels(std::initializer_list<ObjLabel> objLabels)
45{
47 for (const auto& objLabel : objLabels) {
48 labels.addElement(objLabel.first, objLabel.second);
49 }
50 return labels;
51}
52
53std::vector<o2::mch::ROFRecord> mchROFs = {
54 {{0, 0}, 0, 2, 4}, // contains digit #1,2
55 {{4, 0}, 2, 1, 4}, // contains digit #3
56 {{8, 0}, 3, 3, 4}, // contains digit #4,5,6
57 {{20, 0}, 6, 1, 4}}; // contains digit #7
58
59std::vector<o2::mch::Digit> mchDigits = {
60 {100, 0, 10, 0, 1, false}, // #1
61 {100, 1, 10, 0, 1, false}, // #2
62 {100, 2, 10, 4, 1, false}, // #3
63 {100, 2, 10, 8, 1, true}, // #4
64 {100, 3, 10, 8, 1, false}, // #5
65 {100, 0, 10, 8, 1, false}, // #6
66 {100, 2, 10, 20, 1, false}}; // #7
67
69 {{0, {0, 0, 0}}, // digit #1
70 {1, {1, 0, 0}}, // digit #2
71 {1, {2, 0, 0}}, // digit #2
72 {2, {0, 1, 0}}, // digit #3
73 {3, {0, 2, 0}}, // digit #4
74 {3, {true}}, // digit #4
75 {4, {1, 2, 0}}, // digit #5
76 {5, {2, 2, 0}}, // digit #6
77 {6, {0, 3, 0}}}); // digit #7
78
79std::vector<o2::mid::ROFRecord> midROFs = {
80 {{3, 0}, o2::mid::EventType::Standard, 0, 1},
81 {{13, 0}, o2::mid::EventType::Standard, 0, 1},
82 {{20, 0}, o2::mid::EventType::Standard, 0, 1}};
83
84template <typename T>
85void compare(const std::vector<T>& output, const std::vector<T>& expected)
86{
87 BOOST_CHECK_EQUAL_COLLECTIONS(output.begin(), output.end(),
88 expected.begin(), expected.end());
89}
90
92{
93 BOOST_CHECK_EQUAL(output.getIndexedSize(), expected.getIndexedSize());
94
95 for (int i = 0; i < output.getIndexedSize(); ++i) {
96 const auto outputLabels = output.getLabels(i);
97 const auto expectedLabels = expected.getLabels(i);
98 BOOST_CHECK_EQUAL_COLLECTIONS(outputLabels.begin(), outputLabels.end(),
99 expectedLabels.begin(), expectedLabels.end());
100 }
101}
102
103BOOST_AUTO_TEST_CASE(TriggerWidth1BC)
104{
105 // BC : 0 4 8 12 16 20 24 28 32
106 // MCH ROF: [- - - -|- - - -|- - - -]- - - - - - - -[- - - -]- - - - - - - - -
107 // MID ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
108 // TRG rge: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
109 // OUT ROF: - - -[-]- - - - - - - - - - - - - - - -[-]- - - - - - - - - - - -
110 // OUT ROF #1 contains digits from MCH ROF #1
111 // OUT ROF #2 contains digits from MCH ROF #4
112
113 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[0]", 0);
114 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[1]", 1);
115
116 o2::mch::EventFinder eventFinder{};
117 eventFinder.run(mchROFs, mchDigits, &mchLabels, midROFs);
118
119 std::vector<o2::mch::ROFRecord> expectedROFs = {
120 {{3, 0}, 0, 2, 1}, // contains digit #1,2
121 {{20, 0}, 2, 1, 1}}; // contains digit #7
122
123 std::vector<o2::mch::Digit> expectedDigits = {
124 {100, 0, 10, 0, 1, false}, // #1
125 {100, 1, 10, 0, 1, false}, // #2
126 {100, 2, 10, 20, 1, false}}; // #7
127
129 {{0, {0, 0, 0}}, // digit #1
130 {1, {1, 0, 0}}, // digit #2
131 {1, {2, 0, 0}}, // digit #2
132 {2, {0, 3, 0}}}); // digit #7
133
134 compare(eventFinder.getOutputROFs(), expectedROFs);
135 compare(eventFinder.getOutputDigits(), expectedDigits);
136 compare(eventFinder.getOutputLabels(), expectedLabels);
137}
138
139BOOST_AUTO_TEST_CASE(TriggerWidth4BC)
140{
141 // BC : 0 4 8 12 16 20 24 28 32
142 // MCH ROF: [- - - -|- - - -|- - - -]- - - - - - - -[- - - -]- - - - - - - - -
143 // MID ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
144 // TRG rge: -[- - - -]- - - - - -[- - - -]- - -[- - - -]- - - - - - - - - - -
145 // OUT ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
146 // OUT ROF #1 contains digits from MCH ROF #1,2
147 // OUT ROF #2 contains digits from MCH ROF #3
148 // OUT ROF #3 contains digits from MCH ROF #4
149
150 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[0]", -2);
151 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[1]", 2);
152
153 o2::mch::EventFinder eventFinder{};
154 eventFinder.run(mchROFs, mchDigits, &mchLabels, midROFs);
155
156 std::vector<o2::mch::ROFRecord> expectedROFs = {
157 {{3, 0}, 0, 3, 1}, // contains digit #1,2,3
158 {{13, 0}, 3, 3, 1}, // contains digit #4,5,6
159 {{20, 0}, 6, 1, 1}}; // contains digit #7
160
161 std::vector<o2::mch::Digit> expectedDigits = {
162 {100, 0, 10, 0, 1, false}, // #1
163 {100, 1, 10, 0, 1, false}, // #2
164 {100, 2, 10, 4, 1, false}, // #3
165 {100, 2, 10, 8, 1, true}, // #4
166 {100, 3, 10, 8, 1, false}, // #5
167 {100, 0, 10, 8, 1, false}, // #6
168 {100, 2, 10, 20, 1, false}}; // #7
169
171 {{0, {0, 0, 0}}, // digit #1
172 {1, {1, 0, 0}}, // digit #2
173 {1, {2, 0, 0}}, // digit #2
174 {2, {0, 1, 0}}, // digit #3
175 {3, {0, 2, 0}}, // digit #4
176 {3, {true}}, // digit #4
177 {4, {1, 2, 0}}, // digit #5
178 {5, {2, 2, 0}}, // digit #6
179 {6, {0, 3, 0}}}); // digit #7
180
181 compare(eventFinder.getOutputROFs(), expectedROFs);
182 compare(eventFinder.getOutputDigits(), expectedDigits);
183 compare(eventFinder.getOutputLabels(), expectedLabels);
184}
185
186BOOST_AUTO_TEST_CASE(TriggerWidth9BC)
187{
188 // BC : 0 4 8 12 16 20 24 28 32
189 // MCH ROF: [- - - -|- - - -|- - - -]- - - - - - - -[- - - -]- - - - - - - - -
190 // MID ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
191 // TRG rge: [- - - - - - - - -]-[- - - - - - -[- -]- - - - - - -]- - - - - - -
192 // OUT ROF: - - -[- - - - - - - - - - -]- - - - - -[-]- - - - - - - - - - - -
193 // OUT ROF #1 contains digits from MCH ROF #1,2,3
194 // OUT ROF #2 contains digits from MCH ROF #4
195
196 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[0]", -3);
197 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[1]", 6);
198
199 o2::mch::EventFinder eventFinder{};
200 eventFinder.run(mchROFs, mchDigits, &mchLabels, midROFs);
201
202 std::vector<o2::mch::ROFRecord> expectedROFs = {
203 {{3, 0}, 0, 4, 11}, // contains digit #1+6,2,3+4,5
204 {{20, 0}, 4, 1, 1}}; // contains digit #7
205
206 std::vector<o2::mch::Digit> expectedDigits = {
207 {100, 0, 20, 0, 2, false}, // #1+6
208 {100, 1, 10, 0, 1, false}, // #2
209 {100, 2, 20, 4, 2, true}, // #3+4
210 {100, 3, 10, 8, 1, false}, // #5
211 {100, 2, 10, 20, 1, false}}; // #7
212
214 {{0, {0, 0, 0}}, // digit #1+6
215 {0, {2, 2, 0}}, // digit #1+6
216 {1, {1, 0, 0}}, // digit #2
217 {1, {2, 0, 0}}, // digit #2
218 {2, {0, 1, 0}}, // digit #3+4
219 {2, {0, 2, 0}}, // digit #3+4
220 {2, {true}}, // digit #3+4
221 {3, {1, 2, 0}}, // digit #5
222 {4, {0, 3, 0}}}); // digit #7
223
224 compare(eventFinder.getOutputROFs(), expectedROFs);
225 compare(eventFinder.getOutputDigits(), expectedDigits);
226 compare(eventFinder.getOutputLabels(), expectedLabels);
227}
228
229BOOST_AUTO_TEST_CASE(TriggerWidth15BC)
230{
231 // BC : 0 4 8 12 16 20 24 28 32
232 // MCH ROF: [- - - -|- - - -|- - - -]- - - - - - - -[- - - -]- - - - - - - - -
233 // MID ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
234 // TRG rge:[.- - - - - - - -[- - - - -]- -[- - - - - - - -]- - - - - - -]- - -
235 // OUT ROF: - - -[- - - - - - - - - - - - - - - - - -]- - - - - - - - - - - -
236 // OUT ROF #1 contains digits from MCH ROF #1,2,3,4
237
238 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[0]", -5);
239 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[1]", 10);
240
241 o2::mch::EventFinder eventFinder{};
242 eventFinder.run(mchROFs, mchDigits, &mchLabels, midROFs);
243
244 std::vector<o2::mch::ROFRecord> expectedROFs = {
245 {{3, 0}, 0, 4, 18}}; // contains digit #1+6,2,3+4+7,5
246
247 std::vector<o2::mch::Digit> expectedDigits = {
248 {100, 0, 20, 0, 2, false}, // #1+6
249 {100, 1, 10, 0, 1, false}, // #2
250 {100, 2, 30, 4, 3, true}, // #3+4+7
251 {100, 3, 10, 8, 1, false}}; // #5
252
254 {{0, {0, 0, 0}}, // digit #1+6
255 {0, {2, 2, 0}}, // digit #1+6
256 {1, {1, 0, 0}}, // digit #2
257 {1, {2, 0, 0}}, // digit #2
258 {2, {0, 1, 0}}, // digit #3+4+7
259 {2, {0, 2, 0}}, // digit #3+4+7
260 {2, {true}}, // digit #3+4+7
261 {2, {0, 3, 0}}, // digit #3+4+7
262 {3, {1, 2, 0}}}); // digit #5
263
264 compare(eventFinder.getOutputROFs(), expectedROFs);
265 compare(eventFinder.getOutputDigits(), expectedDigits);
266 compare(eventFinder.getOutputLabels(), expectedLabels);
267}
268
269BOOST_AUTO_TEST_CASE(TriggerWidth4BCShift10BC)
270{
271 // BC : 0 4 8 12 16 20 24 28 32
272 // MCH ROF: [- - - -|- - - -|- - - -]- - - - - - - -[- - - -]- - - - - - - - -
273 // MID ROF: - - -[-]- - - - - - - - -[-]- - - - - -[-]- - - - - - - - - - - -
274 // TRG rge: - - - - - - - - - - -[- - - -]- - - - - -[- - - -]- - -[- - - -]-
275 // OUT ROF: - - -[-]- - - - - - - - -[-]- - - - - - - - - - - - - - - - - - -
276 // OUT ROF #1 contains digits from MCH ROF #3
277 // OUT ROF #2 contains digits from MCH ROF #4
278
279 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[0]", 8);
280 o2::conf::ConfigurableParam::setValue("MCHTriggering", "triggerRange[1]", 12);
281
282 o2::mch::EventFinder eventFinder{};
283 eventFinder.run(mchROFs, mchDigits, &mchLabels, midROFs);
284
285 std::vector<o2::mch::ROFRecord> expectedROFs = {
286 {{3, 0}, 0, 3, 1}, // contains digit #4,5,6
287 {{13, 0}, 3, 1, 1}}; // contains digit #7
288
289 std::vector<o2::mch::Digit> expectedDigits = {
290 {100, 2, 10, 8, 1, true}, // #4
291 {100, 3, 10, 8, 1, false}, // #5
292 {100, 0, 10, 8, 1, false}, // #6
293 {100, 2, 10, 20, 1, false}}; // #7
294
296 {{0, {0, 2, 0}}, // digit #4
297 {0, {true}}, // digit #4
298 {1, {1, 2, 0}}, // digit #5
299 {2, {2, 2, 0}}, // digit #6
300 {3, {0, 3, 0}}}); // digit #7
301
302 compare(eventFinder.getOutputROFs(), expectedROFs);
303 compare(eventFinder.getOutputDigits(), expectedDigits);
304 compare(eventFinder.getOutputLabels(), expectedLabels);
305}
306
307BOOST_AUTO_TEST_SUITE_END()
Definition of a class to group MCH digits based on MID information.
int32_t i
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the MCH ROFrame record.
Definition of the MID event record.
static void setValue(std::string const &mainkey, std::string const &subkey, T x)
void addElement(uint32_t dataindex, TruthElement const &element, bool noElement=false)
Class to group MCH digits based on MID information.
Definition EventFinder.h:39
void run(const gsl::span< const mch::ROFRecord > &mchROFs, const gsl::span< const mch::Digit > &digits, const dataformats::MCLabelContainer *labels, const gsl::span< const mid::ROFRecord > &midROFs)
run the event finder algorithm
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
std::map< std::string, ID > expected
BOOST_AUTO_TEST_CASE(TriggerWidth1BC)
std::pair< uint32_t, o2::MCCompLabel > ObjLabel
std::vector< o2::mid::ROFRecord > midROFs
o2::dataformats::MCLabelContainer mchLabels
void compare(const std::vector< T > &output, const std::vector< T > &expected)
std::vector< o2::mch::Digit > mchDigits
o2::dataformats::MCLabelContainer createLabels(std::initializer_list< ObjLabel > objLabels)
std::vector< o2::mch::ROFRecord > mchROFs
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())