Project
Loading...
Searching...
No Matches
testITSCATruthSeeding.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
12#define BOOST_TEST_MODULE ITS CA Truth Seeding
13#define BOOST_TEST_DYN_LINK
14#include <boost/test/unit_test.hpp>
15
16#include <array>
17#include <vector>
18
21
22using namespace o2::its::ca;
23using namespace o2::itsmft::tracking;
24
25BOOST_AUTO_TEST_CASE(ConsecutiveFramesSelectTheirOwnCollisionsAndLookupROFs)
26{
27 const o2::InteractionRecord firstOrigin{0, 40};
28 const std::array<o2::InteractionRecord, 2> collisions{firstOrigin + 50, firstOrigin + 250};
29 const std::array<float, 2> z{1.f, 7.f};
30 // Two ROFs with nonzero delay and bias, matching the cluster loader.
31 const o2::its::LayerTiming timing{.mNROFsTF = 2, .mROFLength = 100, .mROFDelay = 10, .mROFBias = 20};
32 for (int frame = 0; frame < 2; ++frame) {
33 const auto origin = firstOrigin + 200 * frame;
34 const std::array<o2::itsmft::ROFRecord, 2> rofs{{{origin, 0, 0, 0}, {origin + 100, 1, 0, 0}}};
35 const auto window = truthSeedingWindow(rofs, origin, timing);
36 BOOST_REQUIRE(window);
37 BOOST_CHECK_EQUAL(window->lower(), 30u);
38 BOOST_CHECK_EQUAL(window->upper(), 230u);
39 std::vector<o2::its::Vertex> vertices;
40 std::vector<int> eventIds;
41 for (int event = 0; event < 2; ++event) {
42 if (const auto time = truthSeedingTime(collisions[event], origin, *window, 50)) {
44 vertex.setXYZ(0.f, 0.f, z[event]);
45 vertex.getTimeStamp() = *time;
46 vertices.push_back(vertex);
47 eventIds.push_back(event);
48 }
49 }
50 BOOST_REQUIRE_EQUAL(vertices.size(), 1);
51 BOOST_CHECK_EQUAL(eventIds.front(), frame);
52 BOOST_CHECK_EQUAL(vertices.front().getZ(), z[frame]);
53 BOOST_CHECK_EQUAL(vertices.front().getTimeStamp().lower(), 50);
55 lookup.defineLayer(0, 2, 100, 10, 20, 0);
56 lookup.init();
57 lookup.update(vertices.data(), vertices.size());
58 BOOST_CHECK_EQUAL(lookup.getView().getVertices(0, 0).getEntries(), 1);
59 BOOST_CHECK_EQUAL(lookup.getView().getVertices(0, 1).getEntries(), 0);
60 }
61}
62
63BOOST_AUTO_TEST_CASE(TruthTimingPreservesOverlapAndRejectsOutOfFrameEvents)
64{
65 const o2::InteractionRecord origin{0, 40};
66 const o2::its::TimeEstBC window{0, 200};
67 const auto overlap = truthSeedingTime(origin - 10, origin, window, 50);
68 BOOST_REQUIRE(overlap);
69 BOOST_CHECK_EQUAL(overlap->lower(), 0);
70 BOOST_CHECK_EQUAL(overlap->upper(), 40);
71 BOOST_CHECK(!truthSeedingTime(origin - 50, origin, window, 50));
72 BOOST_CHECK(!truthSeedingTime(origin + 200, origin, window, 50));
76}
77
78BOOST_AUTO_TEST_CASE(TruthWindowUsesActualROFRecordsAndLegacyTimingFields)
79{
80 const o2::InteractionRecord origin{0, 40};
81 const std::array<o2::itsmft::ROFRecord, 2> rofs{{{origin, 0, 0, 0}, {origin + 1000, 1, 0, 0}}};
82 o2::its::LayerTiming timing{.mNROFsTF = 2, .mROFLength = 100, .mROFDelay = 10, .mROFBias = 20, .mROFAddTimeErr = 50};
83 const auto window = truthSeedingWindow(rofs, origin, timing);
84 BOOST_REQUIRE(window);
85 BOOST_CHECK_EQUAL(window->lower(), 0u);
86 BOOST_CHECK_EQUAL(window->upper(), 1180u);
88 timing.mROFLength = 0;
89 BOOST_CHECK(!truthSeedingWindow(rofs, origin, timing));
90 timing.mROFLength = std::numeric_limits<uint32_t>::max();
91 BOOST_CHECK(!truthSeedingWindow(rofs, origin, timing));
92}
header::DataOrigin origin
uint8_t lookup(const char input) noexcept
uint64_t vertex
Definition RawEventData.h:9
int16_t time
Definition RawEventData.h:4
struct _cl_event * event
Definition glcorearb.h:2982
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
std::optional< o2::its::TimeEstBC > truthSeedingWindow(gsl::span< const o2::itsmft::ROFRecord > rofs, const o2::InteractionRecord &origin, const o2::its::LayerTiming &timing) noexcept
std::optional< o2::its::TimeEstBC > truthSeedingTime(const o2::InteractionRecord &collision, const o2::InteractionRecord &origin, const o2::its::TimeEstBC &window, uint32_t duration) noexcept
BOOST_AUTO_TEST_CASE(ConsecutiveFramesSelectTheirOwnCollisionsAndLookupROFs)
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())