12#define BOOST_TEST_MODULE Test MCHRaw ROFFinder
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
17#include <boost/test/unit_test.hpp>
18#include <fmt/format.h>
21BOOST_AUTO_TEST_SUITE(o2_mch_raw)
23BOOST_AUTO_TEST_SUITE(timeclustering)
32static
ROFVector makeROFs(
std::vector<
int> binEntries, uint32_t winSize, uint32_t nBinsInOneWindow)
34 uint32_t binWidth = winSize / nBinsInOneWindow;
37 size_t nBins = binEntries.size();
40 int firstDigitIdx = 0;
41 for (
int bin = 0; bin < nBins; bin++) {
44 if (binEntries[bin] == 0) {
48 rofRecords.emplace_back(
ir, firstDigitIdx, binEntries[bin], 4);
49 firstDigitIdx += binEntries[bin];
55static ROFVector makeTimeROFs(std::vector<int> binEntries, uint32_t winSize, uint32_t nBinsInOneWindow)
57 const auto& rofRecords = makeROFs(binEntries, winSize, nBinsInOneWindow);
58 const std::vector<o2::mch::Digit>
digits;
61 rofProcessor.process();
63 const auto& rofTimeRecords = rofProcessor.getROFRecords();
65 return rofTimeRecords;
69static std::vector<int> getBinIntegral(std::vector<int> binEntries)
71 std::vector<int> integral = binEntries;
72 for (
size_t i = 1;
i < integral.size();
i++) {
73 integral[
i] += integral[
i - 1];
74 std::cout << fmt::format(
"bin[{}]={} integral[{}]={}",
i, binEntries[
i],
i, integral[
i]) << std::endl;
80static void checkROF(
const ROFRecord rof, std::vector<int> binEntries, uint32_t winSize, uint32_t nBinsInOneWindow,
int start,
int width)
82 uint32_t binWidth = winSize / nBinsInOneWindow;
85 std::vector<int> binIntegral = getBinIntegral(binEntries);
88 int firstIdx = binIntegral[
start] - binEntries[
start];
96 int bcWidth = (
width - 1) * binWidth + 4;
105 uint32_t winSize = 1000 / 25;
107 std::vector<int> binEntries = {1, 2, 5, 1, 2};
108 std::vector<int> binIntegral = getBinIntegral(binEntries);
110 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
113 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 5);
121 uint32_t winSize = 1500 / 25;
123 std::vector<int> binEntries = {1, 2, 5, 1, 2};
124 std::vector<int> binIntegral = getBinIntegral(binEntries);
126 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
129 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 5);
137 uint32_t winSize = 1200 / 25;
139 std::vector<int> binEntries = {1, 2, 1, 5, 1, 3, 2};
140 std::vector<int> binIntegral = getBinIntegral(binEntries);
142 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
145 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 7);
153 uint32_t winSize = 1000 / 25;
155 std::vector<int> binEntries = {0, 1, 2, 5, 1};
156 std::vector<int> binIntegral = getBinIntegral(binEntries);
158 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
161 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 1, 4);
169 uint32_t winSize = 1000 / 25;
171 std::vector<int> binEntries = {1, 2, 5, 1, 0};
172 std::vector<int> binIntegral = getBinIntegral(binEntries);
174 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
177 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 4);
185 uint32_t winSize = 1000 / 25;
187 std::vector<int> binEntries = {1, 2, 5, 1, 2, 2, 1, 6, 3, 1};
188 std::vector<int> binIntegral = getBinIntegral(binEntries);
190 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
193 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 5);
194 checkROF(rofTimeRecords[1], binEntries, winSize, nBins, 5, 5);
202 uint32_t winSize = 1000 / 25;
204 std::vector<int> binEntries = {1, 2, 5, 1, 2, 0, 2, 1, 6, 3, 1};
205 std::vector<int> binIntegral = getBinIntegral(binEntries);
207 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
210 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 5);
211 checkROF(rofTimeRecords[1], binEntries, winSize, nBins, 6, 5);
218 uint32_t winSize = 1000 / 25;
220 std::vector<int> binEntries = {1, 2, 5, 1, 2, 4, 5, 2, 1, 6, 3, 1};
221 std::vector<int> binIntegral = getBinIntegral(binEntries);
223 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
226 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 5);
227 checkROF(rofTimeRecords[1], binEntries, winSize, nBins, 5, 2);
228 checkROF(rofTimeRecords[2], binEntries, winSize, nBins, 7, 5);
235 uint32_t winSize = 1000 / 25;
237 std::vector<int> binEntries = {1, 2, 5, 1, 6, 4, 5};
238 std::vector<int> binIntegral = getBinIntegral(binEntries);
240 const auto& rofTimeRecords = makeTimeROFs(binEntries, winSize, nBins);
243 checkROF(rofTimeRecords[0], binEntries, winSize, nBins, 0, 2);
244 checkROF(rofTimeRecords[1], binEntries, winSize, nBins, 2, 5);
247BOOST_AUTO_TEST_SUITE_END()
248BOOST_AUTO_TEST_SUITE_END()
Class to group the fired pads according to their time stamp.
int getNEntries() const
get the number of associated objects
const BCData & getBCData() const
get the interaction record
int getFirstIdx() const
get the index of the first associated object
int getBCWidth() const
get the time span by this ROF, in BC unit
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
BOOST_AUTO_TEST_CASE(OneTimeCluster)
std::vector< ROFRecord > ROFVector
o2::InteractionRecord ir(0, 0)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
std::vector< Digit > digits