Project
Loading...
Searching...
No Matches
testITSCATrackerDPLContract.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// Gate 3 workflow-onboarding Slice 2: focused tests for the DPL input/output
13// contract of o2::its::ca::getCATrackerSpec() -- MC/non-MC variants, and the
14// hard requirement that no vertex-related OutputSpec (VERTICES,
15// VERTICESROF, VERTICESMCTR, VERTICESMCPUR, or any fake substitute) is ever
16// declared by this opt-in tracker-only workflow.
17
18#define BOOST_TEST_MODULE ITSMFT ITSCATrackerDPLContract
19#define BOOST_TEST_MAIN
20#define BOOST_TEST_DYN_LINK
21#include <boost/test/unit_test.hpp>
22
23#include <algorithm>
24#include <array>
25#include <limits>
26#include <string>
27
31
32using namespace o2::framework;
33
34namespace
35{
36bool hasInput(const std::vector<InputSpec>& specs, const std::string& binding)
37{
38 return std::any_of(specs.begin(), specs.end(), [&binding](const InputSpec& s) { return s.binding == binding; });
39}
40
41bool hasOutput(const std::vector<OutputSpec>& specs, const std::string& desc)
42{
43 return std::any_of(specs.begin(), specs.end(),
44 [&desc](const OutputSpec& s) { return DataSpecUtils::describe(s).find(desc) != std::string::npos; });
45}
46} // namespace
47
48BOOST_AUTO_TEST_CASE(NonMCContractHasNoLabelsInputOrMCOutputs)
49{
50 const auto spec = o2::its::ca::getCATrackerSpec({.useMC = false});
51
52 BOOST_CHECK(hasInput(spec.inputs, "compClusters"));
53 BOOST_CHECK(hasInput(spec.inputs, "patterns"));
54 BOOST_CHECK(hasInput(spec.inputs, "ROframes"));
55 BOOST_CHECK(hasInput(spec.inputs, "itscldict"));
56 BOOST_CHECK(hasInput(spec.inputs, "itsTGeo")); // useGeom=false: geometry CCDB requested explicitly
57 BOOST_CHECK(!hasInput(spec.inputs, "labels"));
58
59 BOOST_CHECK(hasOutput(spec.outputs, "TRACKS"));
60 BOOST_CHECK(hasOutput(spec.outputs, "TRACKCLSID"));
61 BOOST_CHECK(hasOutput(spec.outputs, "ITSTrackROF"));
62 BOOST_CHECK(!hasOutput(spec.outputs, "TRACKSMCTR"));
63}
64
65BOOST_AUTO_TEST_CASE(MCContractAddsLabelsInputAndMCOutput)
66{
67 const auto spec = o2::its::ca::getCATrackerSpec({.useMC = true});
68
69 BOOST_CHECK(hasInput(spec.inputs, "labels"));
70 BOOST_CHECK(hasOutput(spec.outputs, "TRACKSMCTR"));
71}
72
73BOOST_AUTO_TEST_CASE(UseGeomOmitsExplicitGeometryInput)
74{
75 const auto spec = o2::its::ca::getCATrackerSpec({.useMC = false, .useFullGeometry = true});
76 BOOST_CHECK(!hasInput(spec.inputs, "itsTGeo"));
77}
78
79BOOST_AUTO_TEST_CASE(NoVertexRelatedOutputsArePresentEver)
80{
81 for (const bool useMC : {false, true}) {
82 const auto spec = o2::its::ca::getCATrackerSpec({.useMC = useMC});
83 for (const auto& out : spec.outputs) {
84 const auto desc = DataSpecUtils::describe(out);
85 BOOST_CHECK_MESSAGE(desc.find("VERTICES") == std::string::npos,
86 "unexpected vertex-related output present: " << desc);
87 BOOST_CHECK_MESSAGE(desc.find("VERTEX") == std::string::npos,
88 "unexpected vertex-related output present: " << desc);
89 }
90 }
91}
92
93BOOST_AUTO_TEST_CASE(DeviceNameIsStable)
94{
95 const auto spec = o2::its::ca::getCATrackerSpec({.useMC = false});
96 BOOST_CHECK_EQUAL(spec.name, "its-ca-tracker");
97}
98
99BOOST_AUTO_TEST_CASE(PublicationFlagsAreClearedOnEveryWorkflowExit)
100{
103 frame.getGenericTracks().resize(1);
105 parameters.AllowSharingFirstCluster = false;
106 const std::array<uint32_t, 1> indices{0};
107 for (bool fail : {false, true}) {
108 BOOST_REQUIRE(publication.completeAccepted(indices, parameters, frame, true));
109 BOOST_REQUIRE_EQUAL(publication.sharedClusterFlags().size(), 1u);
110 try {
111 auto cleanup = publication.cleanupOnExit();
112 BOOST_CHECK(publication.sharedClusterFlags().empty());
113 BOOST_REQUIRE(publication.completeAccepted(indices, parameters, frame, true));
114 BOOST_REQUIRE_EQUAL(publication.sharedClusterFlags().size(), 1u);
115 BOOST_CHECK_EQUAL(publication.sharedClusterFlags()[0], 0);
116 if (fail) {
117 throw std::runtime_error{"publication failure"};
118 }
119 } catch (const std::runtime_error&) {
120 BOOST_CHECK(fail);
121 }
122 BOOST_CHECK(publication.sharedClusterFlags().empty());
123 }
124}
125
126BOOST_AUTO_TEST_CASE(PublicationFlagsRequireFinalCompletionAndAcceptedIndices)
127{
130 frame.getGenericTracks().resize(3);
132 parameters.AllowSharingFirstCluster = false;
133 const std::array<uint32_t, 1> first{0}, last{2}, outOfRange{3};
134 BOOST_REQUIRE(publication.completeAccepted(first, parameters, frame, false));
135 BOOST_CHECK(publication.sharedClusterFlags().empty());
136 BOOST_REQUIRE(publication.completeAccepted(last, parameters, frame, true));
137 const auto flags = publication.sharedClusterFlags();
138 BOOST_REQUIRE_EQUAL(flags.size(), 3u);
140 BOOST_CHECK_EQUAL(flags[1], std::numeric_limits<uint8_t>::max());
142 BOOST_CHECK(!publication.completeAccepted(last, parameters, frame, true));
143 BOOST_CHECK(publication.sharedClusterFlags().empty());
144 publication.reset();
145 BOOST_CHECK(!publication.completeAccepted(outOfRange, parameters, frame, true));
146 const std::array<uint32_t, 2> reversed{2, 0}, repeated{0, 0};
147 BOOST_CHECK(!publication.completeAccepted(reversed, parameters, frame, true));
148 BOOST_CHECK(!publication.completeAccepted(repeated, parameters, frame, true));
149 BOOST_REQUIRE(publication.completeAccepted(first, parameters, frame, false));
150 BOOST_REQUIRE(publication.completeAccepted({}, parameters, frame, true));
151 BOOST_REQUIRE_EQUAL(publication.sharedClusterFlags().size(), 1u);
152 BOOST_CHECK_EQUAL(publication.sharedClusterFlags()[0], 0);
153}
std::string binding
ITS common-CA tracker DPL device with tracker-only outputs.
gsl::span< const uint8_t > sharedClusterFlags() const noexcept
bool completeAccepted(gsl::span< const uint32_t > trackIndices, const o2::itsmft::IterationParameters &params, const o2::itsmft::tracking::TimeFrame &frame, bool final)
GLint first
Definition glcorearb.h:399
GLsizei GLenum const void * indices
Definition glcorearb.h:400
GLbitfield flags
Definition glcorearb.h:1570
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
o2::framework::DataProcessorSpec getCATrackerSpec(const WorkflowOptions &options)
void cleanup()
static std::string describe(InputSpec const &spec)
BOOST_AUTO_TEST_CASE(NonMCContractHasNoLabelsInputOrMCOutputs)
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())