100 auto evtsWriter = builderE.
cursor<aod::Events>();
101 for (
auto i = 0;
i < 20; ++
i) {
102 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
104 auto evtTable = builderE.
finalize();
107 auto trksWriter = builderT.
cursor<aod::TrksX>();
108 for (
auto i = 0;
i < 20; ++
i) {
109 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
110 trksWriter(0,
i, 0.5f *
j);
113 auto trkTable = builderT.
finalize();
114 aod::Events e{evtTable};
115 aod::TrksX t{trkTable};
116 REQUIRE(e.size() == 20);
117 REQUIRE(t.size() == 10 * 20);
119 auto tt = std::make_tuple(t);
121 auto s = slices.updateCacheEntry(0, trkTable);
125 for (
auto& slice :
g) {
126 auto as = slice.associatedTables();
127 auto gg = slice.groupingElement();
128 REQUIRE(gg.globalIndex() ==
count);
129 auto trks = std::get<aod::TrksX>(as);
130 REQUIRE(trks.size() == 10);
131 for (
auto& trk : trks) {
132 REQUIRE(trk.eventId() ==
count);
141 auto evtsWriter = builderE.
cursor<aod::Events>();
142 for (
auto i = 0;
i < 20; ++
i) {
143 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
145 auto evtTable = builderE.
finalize();
148 auto trksWriterX = builderTX.
cursor<aod::TrksX>();
150 auto trksWriterY = builderTY.
cursor<aod::TrksY>();
152 auto trksWriterZ = builderTZ.
cursor<aod::TrksZ>();
155 auto trksWriterXYZ = builderTXYZ.
cursor<aod::TrksU>();
157 for (
auto i = 0;
i < 20; ++
i) {
158 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
159 trksWriterX(0,
i, 0.5f *
j);
161 for (
auto j = 0.f;
j < 10;
j += 0.5f) {
162 trksWriterY(0,
i, 0.5f *
j);
164 for (
auto j = 0.f;
j < 15;
j += 0.5f) {
165 trksWriterZ(0,
i, 0.5f *
j);
168 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
169 trksWriterXYZ(0, 0.5f *
j, 2.f *
j, 2.5f *
j);
172 auto trkTableX = builderTX.
finalize();
173 auto trkTableY = builderTY.finalize();
174 auto trkTableZ = builderTZ.finalize();
176 auto trkTableXYZ = builderTXYZ.finalize();
178 aod::Events e{evtTable};
179 aod::TrksX tx{trkTableX};
180 aod::TrksY ty{trkTableY};
181 aod::TrksZ tz{trkTableZ};
183 aod::TrksU tu{trkTableXYZ};
185 REQUIRE(e.size() == 20);
186 REQUIRE(tx.size() == 10 * 20);
187 REQUIRE(ty.size() == 20 * 20);
188 REQUIRE(tz.size() == 30 * 20);
190 REQUIRE(tu.size() == 10 * 20);
192 auto tt = std::make_tuple(tx, ty, tz, tu);
195 {soa::getLabelFromType<aod::TrksY>(),
key},
196 {soa::getLabelFromType<aod::TrksZ>(),
key}});
197 auto s = slices.updateCacheEntry(0, {trkTableX});
198 s = slices.updateCacheEntry(1, {trkTableY});
199 s = slices.updateCacheEntry(2, {trkTableZ});
203 for (
auto& slice :
g) {
204 auto as = slice.associatedTables();
205 auto gg = slice.groupingElement();
206 REQUIRE(gg.globalIndex() ==
count);
207 auto trksx = std::get<aod::TrksX>(as);
208 auto trksy = std::get<aod::TrksY>(as);
209 auto trksz = std::get<aod::TrksZ>(as);
211 auto trksu = std::get<aod::TrksU>(as);
213 REQUIRE(trksx.size() == 10);
214 REQUIRE(trksy.size() == 20);
215 REQUIRE(trksz.size() == 30);
217 REQUIRE(trksu.size() == 10 * 20);
219 for (
auto& trk : trksx) {
220 REQUIRE(trk.eventId() ==
count);
222 for (
auto& trk : trksy) {
223 REQUIRE(trk.eventId() ==
count);
225 for (
auto& trk : trksz) {
226 REQUIRE(trk.eventId() ==
count);
236 auto evtsWriter = builderE.
cursor<aod::Events>();
237 for (
auto i = 0;
i < 20; ++
i) {
238 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
240 auto evtTable = builderE.
finalize();
243 auto trksWriter = builderT.
cursor<aod::TrksX>();
244 for (
auto i = 0;
i < 20; ++
i) {
245 if (
i == 3 ||
i == 10 ||
i == 12 ||
i == 16 ||
i == 19) {
248 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
249 trksWriter(0,
i, 0.5f *
j);
252 auto trkTable = builderT.
finalize();
253 aod::Events e{evtTable};
254 aod::TrksX t{trkTable};
255 REQUIRE(e.size() == 20);
256 REQUIRE(t.size() == 10 * (20 - 5));
258 auto tt = std::make_tuple(t);
260 auto s = slices.updateCacheEntry(0, trkTable);
264 for (
auto& slice :
g) {
265 auto as = slice.associatedTables();
266 auto gg = slice.groupingElement();
267 REQUIRE(gg.globalIndex() ==
count);
268 auto trks = std::get<aod::TrksX>(as);
270 REQUIRE(trks.size() == 0);
272 REQUIRE(trks.size() == 10);
274 for (
auto& trk : trks) {
275 REQUIRE(trk.eventId() ==
count);
284 auto evtsWriter = builderE.
cursor<aod::Events>();
285 for (
auto i = 0;
i < 20; ++
i) {
286 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
288 auto evtTable = builderE.
finalize();
293 auto trksWriter = builderT.
cursor<aod::TrksX>();
294 for (
auto i = 0;
i < 20; ++
i) {
295 if (
i == 3 ||
i == 10 ||
i == 12 ||
i == 16 ||
i == 19) {
296 for (
auto iz = 0; iz < 5; ++iz) {
297 trksWriter(0, -1 - skip, 0.123f * iz + 1.654f);
302 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
303 trksWriter(0,
i, 0.5f *
j);
306 for (
auto i = 0;
i < 5; ++
i) {
307 trksWriter(0, -6, 0.123f *
i + 1.654f);
309 auto trkTable = builderT.
finalize();
311 aod::Events e{evtTable};
312 aod::TrksX t{trkTable};
313 REQUIRE(e.size() == 20);
314 REQUIRE(t.size() == (30 + 10 * (20 - 5)));
316 auto tt = std::make_tuple(t);
318 auto s = slices.updateCacheEntry(0, trkTable);
322 for (
auto& slice :
g) {
323 auto as = slice.associatedTables();
324 auto gg = slice.groupingElement();
325 REQUIRE(gg.globalIndex() ==
count);
326 auto trks = std::get<aod::TrksX>(as);
328 REQUIRE(trks.size() == 0);
330 REQUIRE(trks.size() == 10);
332 for (
auto& trk : trks) {
333 REQUIRE(trk.eventId() ==
count);
342 auto evtsWriter = builderE.
cursor<aod::Events>();
343 for (
auto i = 0;
i < 20; ++
i) {
344 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
346 auto evtTable = builderE.
finalize();
349 auto trksWriter = builderT.
cursor<aod::TrksX>();
350 for (
auto i = 0;
i < 20; ++
i) {
351 if (
i == 3 ||
i == 10 ||
i == 12 ||
i == 16) {
354 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
355 trksWriter(0,
i, 0.5f *
j);
358 auto trkTable = builderT.
finalize();
361 FilteredEvents e{{evtTable}, {2, 4, 10, 9, 15}};
362 aod::TrksX t{trkTable};
363 REQUIRE(e.size() == 5);
364 REQUIRE(t.size() == 10 * (20 - 4));
366 auto tt = std::make_tuple(t);
368 auto s = slices.updateCacheEntry(0, trkTable);
373 for (
auto& slice :
g) {
374 auto as = slice.associatedTables();
375 auto gg = slice.groupingElement();
376 REQUIRE(gg.globalIndex() ==
rows[
count]);
377 auto trks = std::get<aod::TrksX>(as);
379 REQUIRE(trks.size() == 0);
381 REQUIRE(trks.size() == 10);
383 for (
auto& trk : trks) {
393 auto evtsWriter = builderE.
cursor<aod::Events>();
394 for (
auto i = 0;
i < 20; ++
i) {
395 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
397 auto evtTable = builderE.
finalize();
400 auto trksWriter = builderT.
cursor<aod::TrksXU>();
401 std::vector<int> randomized{10, 2, 1, 0, 15, 3, 6, 4, 14, 5, 7, 9, 8, 19, 11, 13, 17, 12, 18, 19};
402 std::vector<int64_t> sel;
403 sel.resize(10 * (20 - 4));
404 std::iota(sel.begin(), sel.end(), 0);
405 for (
auto i : randomized) {
406 if (
i == 3 ||
i == 10 ||
i == 12 ||
i == 16) {
409 for (
auto j = 0.f;
j < 5;
j += 0.5f) {
410 trksWriter(0,
i, 0.5f *
j);
413 auto trkTable = builderT.
finalize();
416 auto trksWriterE = builderTE.
cursor<aod::TrksXU>();
417 auto trkTableE = builderTE.
finalize();
421 FilteredEvents e{{evtTable}, {2, 4, 10, 9, 15}};
424 REQUIRE(e.size() == 5);
425 REQUIRE(t.size() == 10 * (20 - 4));
427 auto tt = std::make_tuple(t);
429 auto s = slices.updateCacheEntryUnsorted(0, trkTable);
432 unsigned int count = 0;
434 for (
auto& slice :
g) {
435 auto as = slice.associatedTables();
436 auto gg = slice.groupingElement();
437 REQUIRE(gg.globalIndex() ==
rows[
count]);
438 auto trks = std::get<soa::SmallGroups<aod::TrksXU>>(as);
440 REQUIRE(trks.size() == 0);
442 REQUIRE(trks.size() == 10);
444 for (
auto& trk : trks) {
450 std::vector<int64_t> sele;
452 auto tte = std::make_tuple(te);
456 for (
auto& slice : ge) {
457 auto as = slice.associatedTables();
458 auto gg = slice.groupingElement();
459 REQUIRE(gg.globalIndex() ==
rows[
count]);
460 auto trks = std::get<soa::SmallGroups<aod::TrksXU>>(as);
461 REQUIRE(trks.size() == 0);
466 auto ttu = std::make_tuple(tu);
470 for (
auto& slice : gu) {
471 auto as = slice.associatedTables();
472 auto gg = slice.groupingElement();
473 REQUIRE(gg.globalIndex() ==
rows[
count]);
474 auto trks = std::get<soa::SmallGroupsUnfiltered<aod::TrksXU>>(as);
476 REQUIRE(trks.size() == 0);
478 REQUIRE(trks.size() == 10);
509TEST_CASE(
"GroupSlicerMismatchedUnsortedFilteredGroupsWithSelfIndex")
512 auto evtsWriter = builderE.
cursor<aod::Events>();
513 for (
auto i = 0;
i < 20; ++
i) {
514 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
516 auto evtTable = builderE.
finalize();
519 auto partsWriter = builderP.
cursor<aod::Parts>();
521 std::random_device
rd;
522 std::mt19937
gen(
rd());
523 std::uniform_int_distribution<> distrib(0, 99);
525 for (
auto i = 0;
i < 100; ++
i) {
527 filler[0] = distrib(
gen);
528 filler[1] = distrib(
gen);
529 if (filler[0] > filler[1]) {
530 std::swap(filler[0], filler[1]);
532 partsWriter(0, std::floor(
i / 10.),
i, filler);
534 auto partsTable = builderP.
finalize();
537 auto thingsWriter = builderT.
cursor<aod::Things>();
538 for (
auto i = 0;
i < 10; ++
i) {
539 thingsWriter(0,
i, distrib(
gen));
541 auto thingsTable = builderT.
finalize();
543 aod::Events e{evtTable};
545 aod::Things t{thingsTable};
549 for (
auto i = 0;
i <
size; ++
i) {
552 FilteredParts fp{{partsTable},
rows};
553 auto associatedTuple = std::make_tuple(fp, t);
555 {soa::getLabelFromType<aod::Things>(),
"fIndex" +
o2::framework::cutString(soa::getLabelFromType<aod::Events>())}});
557 auto s1 = slices.updateCacheEntry(1, thingsTable);
560 overwriteInternalIndices(associatedTuple, associatedTuple);
563 for (
auto& slice :
g) {
564 auto as = slice.associatedTables();
565 auto gg = slice.groupingElement();
566 overwriteInternalIndices(as, associatedTuple);
567 auto& ts = std::get<1>(as);
568 ts.bindExternalIndices(&e, &std::get<0>(associatedTuple));
569 for (
auto& thing : ts) {
570 if (thing.has_part()) {
571 auto part = thing.part_as<FilteredParts>();
572 REQUIRE(std::same_as<std::decay_t<
decltype(part)>::parent_t, FilteredParts>);
573 auto rs = part.relatives_as<std::decay_t<
decltype(part)::parent_t>>();
574 REQUIRE(std::same_as<std::decay_t<
decltype(rs)>, FilteredParts>);
576 REQUIRE(std::same_as<std::decay_t<
decltype(
r)>::parent_t, FilteredParts>);
577 auto rss =
r.relatives_as<std::decay_t<
decltype(
r)>::parent_t>();
578 REQUIRE(std::same_as<std::decay_t<
decltype(rss)>, FilteredParts>);
579 for (
auto&
rr : rss) {
580 REQUIRE(std::same_as<std::decay_t<
decltype(
rr)>::parent_t, FilteredParts>);
581 auto rsss =
rr.relatives_as<std::decay_t<
decltype(
rr)>::parent_t>();
582 REQUIRE(std::same_as<std::decay_t<
decltype(rsss)>, FilteredParts>);
583 for (
auto& rrr : rsss) {
584 REQUIRE(std::same_as<std::decay_t<
decltype(rrr)>::parent_t, FilteredParts>);
585 auto rssss = rrr.relatives_as<std::decay_t<
decltype(rrr)>::parent_t>();
586 REQUIRE(std::same_as<std::decay_t<
decltype(rssss)>, FilteredParts>);
598 auto evtsWriter = builderE.
cursor<aod::Events>();
599 for (
auto i = 0;
i < 20; ++
i) {
600 evtsWriter(0,
i, 0.5f *
i, 2.f *
i, 3.f *
i);
602 auto evtTable = builderE.
finalize();
605 auto trksWriter = builderT.
cursor<aod::TrksX>();
606 auto trkTable = builderT.
finalize();
608 aod::Events e{evtTable};
609 aod::TrksX t{trkTable};
610 REQUIRE(e.size() == 20);
611 REQUIRE(t.size() == 0);
613 auto tt = std::make_tuple(t);
615 auto s = slices.updateCacheEntry(0, trkTable);
618 unsigned int count = 0;
619 for (
auto& slice :
g) {
620 auto as = slice.associatedTables();
621 auto gg = slice.groupingElement();
622 auto trks = std::get<aod::TrksX>(as);
623 REQUIRE(gg.globalIndex() ==
count);
624 REQUIRE(trks.size() == 0);
631 int counts[] = {5, 5, 5, 4, 1};
632 int offsets[] = {0, 5, 10, 15, 19, 20};
633 int ids[] = {0, 1, 2, 3, 4};
634 int sizes[] = {4, 1, 12, 5, 2};
639 auto evtsWriter = builderE.
cursor<aod::Events>();
641 for (
auto i = 0;
i < 20; ++
i) {
645 evtsWriter(0,
ids[step], 0.5f *
i, 2.f *
i, 3.f *
i);
647 auto evtTable = builderE.
finalize();
650 auto evtsEWriter = builderEE.
cursor<aod::EventExtra>();
653 for (
auto i = 0;
i < 20; ++
i) {
657 float arr[3] = {0.1f *
i, 0.2f *
i, 0.3f *
i};
658 std::vector<double> d;
659 for (
auto z = 0;
z <
sizes[step]; ++
z) {
660 d.push_back((
double)
z * 0.5);
662 evtsEWriter(0, arr,
i % 2 == 0, d);
664 auto evtETable = builderEE.
finalize();
666 aod::Events e{evtTable};
667 aod::EventExtra ee{evtETable};
668 BigE b_e{{evtTable, evtETable}};
670 std::vector<std::shared_ptr<arrow::ChunkedArray>> slices_array;
671 std::vector<std::shared_ptr<arrow::ChunkedArray>> slices_bool;
672 std::vector<std::shared_ptr<arrow::ChunkedArray>> slices_vec;
674 for (
auto i = 0u;
i < 5; ++
i) {
675 slices_array.emplace_back(evtETable->column(0)->Slice(
offset, counts[
i]));
676 slices_bool.emplace_back(evtETable->column(1)->Slice(
offset, counts[
i]));
677 slices_vec.emplace_back(evtETable->column(2)->Slice(
offset, counts[
i]));
679 REQUIRE(slices_array[
i]->
length() == counts[
i]);
680 REQUIRE(slices_bool[
i]->
length() == counts[
i]);
681 REQUIRE(slices_vec[
i]->
length() == counts[
i]);
684 std::vector<arrow::Datum> slices;
685 std::vector<uint64_t> offsts;
686 auto bk = std::make_pair(soa::getLabelFromType<aod::Events>(),
"fID");
688 auto s = cache.updateCacheEntry(0, {evtTable});
689 auto lcache = cache.getCacheFor(bk);
690 for (
auto i = 0u;
i < 5; ++
i) {
692 auto tbl = b_e.asArrowTable()->Slice(
offset,
count);
693 auto ca = tbl->GetColumnByName(
"fArr");
694 auto cb = tbl->GetColumnByName(
"fBoo");
695 auto cv = tbl->GetColumnByName(
"fLst");
696 REQUIRE(ca->length() == counts[
i]);
697 REQUIRE(cb->length() == counts[
i]);
698 REQUIRE(cv->length() == counts[
i]);
699 REQUIRE(ca->Equals(slices_array[
i]));
700 REQUIRE(cb->Equals(slices_bool[
i]));
701 REQUIRE(cv->Equals(slices_vec[
i]));
705 for (
auto i = 0u;
i < 5; ++
i) {
707 auto tbl = BigE{{b_e.asArrowTable()->Slice(
offset,
count)},
static_cast<uint64_t
>(
offset)};
708 REQUIRE(tbl.size() == counts[
i]);
709 for (
auto&
row : tbl) {
711 REQUIRE(
row.boo() == (
j % 2 == 0));
712 auto rid =
row.globalIndex();
713 auto arr =
row.arr();
714 REQUIRE(arr[0] == 0.1f * (
float)rid);
715 REQUIRE(arr[1] == 0.2f * (
float)rid);
716 REQUIRE(arr[2] == 0.3f * (
float)rid);
719 REQUIRE(d.size() == (
size_t)
sizes[
i]);
720 for (
auto z = 0u;
z < d.size(); ++
z) {
721 REQUIRE(d[
z] == 0.5 * (
double)
z);