Project
Loading...
Searching...
No Matches
testITSMFTCAWriterContract.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// Pin the shared ITS and MFT common-CA writer specifications.
13
14#define BOOST_TEST_MODULE ITSMFT ITSMFTCAWriterContract
15#define BOOST_TEST_MAIN
16#define BOOST_TEST_DYN_LINK
17#include <boost/test/unit_test.hpp>
18
19#include <algorithm>
20#include <string>
21
26
27using namespace o2::framework;
28
29namespace
30{
31bool hasInput(const std::vector<InputSpec>& specs, const std::string& binding)
32{
33 return std::any_of(specs.begin(), specs.end(), [&binding](const InputSpec& s) { return s.binding == binding; });
34}
35
36bool sameShape(const DataProcessorSpec& a, const DataProcessorSpec& b)
37{
38 if (a.name != b.name || a.inputs.size() != b.inputs.size() || a.outputs.size() != b.outputs.size()) {
39 return false;
40 }
41 for (size_t i = 0; i < a.inputs.size(); ++i) {
42 if (a.inputs[i].binding != b.inputs[i].binding || DataSpecUtils::describe(a.inputs[i]) != DataSpecUtils::describe(b.inputs[i])) {
43 return false;
44 }
45 }
46 return true;
47}
48} // namespace
49
50BOOST_AUTO_TEST_CASE(ITSWriterSpecContract)
51{
52 const auto spec = o2::its::ca::getTrackWriterSpec(false);
53 BOOST_CHECK_EQUAL(spec.name, "its-ca-track-writer");
54 BOOST_CHECK(hasInput(spec.inputs, "tracks"));
55 BOOST_CHECK(hasInput(spec.inputs, "trackClIdx"));
56 BOOST_CHECK(hasInput(spec.inputs, "ROframes"));
57 BOOST_CHECK(!hasInput(spec.inputs, "labels"));
58}
59
60BOOST_AUTO_TEST_CASE(ITSWriterSpecMCContractAddsLabels)
61{
62 const auto spec = o2::its::ca::getTrackWriterSpec(true);
63 BOOST_CHECK(hasInput(spec.inputs, "labels"));
64}
65
66BOOST_AUTO_TEST_CASE(ITSWriterSpecIsDeterministicAcrossCallers)
67{
68 const auto first = o2::its::ca::getTrackWriterSpec(true);
69 const auto second = o2::its::ca::getTrackWriterSpec(true);
70 BOOST_CHECK(sameShape(first, second));
71}
72
73BOOST_AUTO_TEST_CASE(MFTWriterSpecContract)
74{
75 const auto spec = o2::mft::getTrackWriterSpec(false);
76 BOOST_CHECK_EQUAL(spec.name, "mft-track-writer");
77 BOOST_CHECK(hasInput(spec.inputs, "tracks"));
78 BOOST_CHECK(hasInput(spec.inputs, "trackClIdx"));
79 BOOST_CHECK(!hasInput(spec.inputs, "trackSeedPat"));
80 BOOST_CHECK(hasInput(spec.inputs, "ROframes"));
81 BOOST_CHECK(!hasInput(spec.inputs, "labels"));
82}
83
84BOOST_AUTO_TEST_CASE(MFTWriterSpecMCContractAddsLabels)
85{
86 const auto spec = o2::mft::getTrackWriterSpec(true);
87 BOOST_CHECK(hasInput(spec.inputs, "labels"));
88}
89
90BOOST_AUTO_TEST_CASE(MFTWriterSpecDefaultUseCAIsFalseMatchingLegacyCaller)
91{
92 // RecoWorkflow.cxx (legacy o2-mft-reco-workflow) calls
93 // getTrackWriterSpec(useMC) with useCA left at its default -- must stay
94 // false so the legacy writer's own contract is unchanged.
95 const auto legacyShape = o2::mft::getTrackWriterSpec(false);
96 const auto explicitFalse = o2::mft::getTrackWriterSpec(false, false);
97 BOOST_CHECK(sameShape(legacyShape, explicitFalse));
98}
99
100BOOST_AUTO_TEST_CASE(MFTWriterSpecIsDeterministicAcrossCallersUseCATrue)
101{
102 const auto first = o2::mft::getTrackWriterSpec(true, true);
103 const auto second = o2::mft::getTrackWriterSpec(true, true);
104 BOOST_CHECK(sameShape(first, second));
105 BOOST_CHECK(hasInput(first.inputs, "trackSeedPat"));
106}
std::string binding
int32_t i
Vertex-free ITS common-CA track writer. Writes a distinct file (o2trac_its_ca.root) with no vertex br...
GLint first
Definition glcorearb.h:399
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
o2::framework::DataProcessorSpec getTrackWriterSpec(bool useMC)
Write ITS CA tracks to o2trac_its_ca.root without vertex branches.
o2::framework::DataProcessorSpec getTrackWriterSpec(bool useMC, bool useCA=false)
Write MFT tracks to a ROOT file.
static std::string describe(InputSpec const &spec)
BOOST_AUTO_TEST_CASE(ITSWriterSpecContract)
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())