Project
Loading...
Searching...
No Matches
testITSCommonCATrackingModeConfiguration.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// Workflow-onboarding Slice 1: focused tests for the dedicated
13// ITSCommonCATrackerParam configuration type (TrackingConfigParam.h) and the
14// real ITS Sync and Async branches of TrackingMode::getTrackingParameters()
15// (Configuration.cxx). No workflow spec exists yet -- these tests call the
16// common-tracking library directly, the same way
17// the workflow loading tests already document that the
18// ITS branch of getTrackingParameters() used to unconditionally
19// LOGP(fatal, ...) regardless of mode; that fatal is now real per-mode
20// behaviour instead, exercised here.
21
22#define BOOST_TEST_MODULE ITSMFT ITSCommonCATrackingModeConfiguration
23#define BOOST_TEST_MAIN
24#define BOOST_TEST_DYN_LINK
26#include <boost/test/unit_test.hpp>
27
28#include <boost/property_tree/ptree.hpp>
29#include <fairlogger/Logger.h>
30#include <stdexcept>
31#include <TClass.h>
32#include <TDataMember.h>
33
40
41using namespace o2::itsmft;
42using namespace o2::itsmft::tracking;
43
44namespace
45{
46struct MagneticFieldFixture {
47 MagneticFieldFixture() { o2::base::Propagator::initFieldFromGRP(0.f, 0.f, true, false); }
48};
49} // namespace
50
51BOOST_TEST_GLOBAL_FIXTURE(MagneticFieldFixture);
52
53// --- Dedicated name is distinct from every other registered CA param name --
54
55BOOST_AUTO_TEST_CASE(DedicatedNameIsDistinctFromLegacyAndMFTNames)
56{
57 const auto& itsCommonCA = ITSCommonCATrackerParam::Instance();
58 const auto& itsLegacy = o2::its::TrackerParamConfig::Instance();
59 const auto& mftCommonCA = MFTCATrackerParam::Instance();
60
61 BOOST_CHECK_EQUAL(itsCommonCA.getName(), "ITSCommonCATrackerParam");
62 BOOST_CHECK_EQUAL(itsLegacy.getName(), "ITSCATrackerParam");
63 BOOST_CHECK_EQUAL(mftCommonCA.getName(), "MFTCATrackerParam");
64
65 BOOST_CHECK(itsCommonCA.getName() != itsLegacy.getName());
66 BOOST_CHECK(itsCommonCA.getName() != mftCommonCA.getName());
67 BOOST_CHECK(itsLegacy.getName() != mftCommonCA.getName());
68}
69
70// --- ITSCommonCATrackerParam defaults match the documented Sync baseline ---
71
72BOOST_AUTO_TEST_CASE(DedicatedDefaultsMatchDocumentedSyncBaseline)
73{
74 const auto& tc = ITSCommonCATrackerParam::Instance();
75 BOOST_CHECK_EQUAL(tc.dropTFUponFailure, false);
76 BOOST_CHECK_EQUAL(tc.maxMemory, std::numeric_limits<size_t>::max());
77 BOOST_CHECK_EQUAL(tc.useDiamond, false);
78 BOOST_CHECK_EQUAL(tc.diamondPos[0], 0.f);
79 BOOST_CHECK_EQUAL(tc.diamondPos[1], 0.f);
80 BOOST_CHECK_EQUAL(tc.diamondPos[2], 0.f);
81 BOOST_CHECK_EQUAL(tc.pvRes, -1.f);
82 BOOST_CHECK_EQUAL(tc.nThreads, 1);
83}
84
85// --- ITS Sync construction is valid, one-iteration, with expected values ---
86
87BOOST_AUTO_TEST_CASE(ITSSyncTrackingParametersAreValidOneIteration)
88{
89 const auto trackParams = o2::itsmft::tracking::test::referenceTrackingParameters(o2::detectors::DetID::ITS, TrackingMode::Sync);
90
91 BOOST_REQUIRE_EQUAL(trackParams.size(), 1u);
92 const auto& p = trackParams[0];
93
96 BOOST_CHECK_EQUAL(p.MinPt.size(), static_cast<size_t>(tracking::ITSNLayers -
98 BOOST_CHECK_EQUAL(p.StartLayerMask.count(), tracking::ITSNLayers); // default mask: all 7 barrel layers active
99
100 // Administrative fields wired straight from the dedicated config's defaults.
101 BOOST_CHECK_EQUAL(p.DropTFUponFailure, false);
102 BOOST_CHECK_EQUAL(p.MaxMemory, std::numeric_limits<size_t>::max());
103 BOOST_CHECK_EQUAL(p.UseDiamond, false);
104}
105
106BOOST_AUTO_TEST_CASE(ITSSyncTrackingParametersAreDeterministic)
107{
110 BOOST_REQUIRE_EQUAL(a.size(), b.size());
111 BOOST_CHECK_EQUAL(a[0].MinTrackLength, b[0].MinTrackLength);
112 BOOST_CHECK_EQUAL(a[0].NLayers, b[0].NLayers);
113 BOOST_CHECK(a[0].LayerResolution == b[0].LayerResolution);
114}
115
116BOOST_AUTO_TEST_CASE(ITSAsyncMatchesLegacySelectionParameters)
117{
118 const auto common = o2::itsmft::tracking::test::referenceTrackingParameters(o2::detectors::DetID::ITS, TrackingMode::Async);
120
121 BOOST_REQUIRE_EQUAL(common.size(), 3u);
122 BOOST_REQUIRE_EQUAL(common.size(), legacy.size());
123 for (size_t iteration = 0; iteration < common.size(); ++iteration) {
124 const auto& commonIteration = common[iteration];
125 const auto& legacyIteration = legacy[iteration];
126 BOOST_CHECK_EQUAL(commonIteration.ColBins, legacyIteration.ZBins);
127 BOOST_CHECK_EQUAL(commonIteration.RowBins, legacyIteration.PhiBins);
128 BOOST_CHECK_EQUAL(commonIteration.MinTrackLength, legacyIteration.MinTrackLength);
129 BOOST_CHECK_EQUAL(commonIteration.TrackletMinPt, legacyIteration.TrackletMinPt);
130 BOOST_CHECK_EQUAL(commonIteration.StartLayerMask.value(), legacyIteration.StartLayerMask.value());
131 BOOST_REQUIRE_EQUAL(commonIteration.MinPt.size(), legacyIteration.MinPt.size());
132 for (size_t length = 0; length < commonIteration.MinPt.size(); ++length) {
133 BOOST_CHECK_EQUAL(commonIteration.MinPt[length], legacyIteration.MinPt[length]);
134 }
135 }
136}
137
138// --- Every unsupported TrackingMode fails closed, none silently mapped -----
139//
140// LOGP(fatal, ...) normally terminates the process (FairLogger default). A
141// process-local OnFatal handler converts it into a catchable exception so
142// this remains a normal, non-crashing ctest case. Each ITSMFT test source
143// file builds its own executable (o2_add_test == one binary per SOURCES
144// file), so this handler cannot leak into unrelated test binaries.
145
146namespace
147{
148struct FatalToExceptionFixture {
149 FatalToExceptionFixture()
150 {
151 fair::Logger::OnFatal([]() { throw std::runtime_error("fatal"); });
152 }
153};
154} // namespace
155
156BOOST_FIXTURE_TEST_CASE(EveryUnsupportedITSModeFailsClosed, FatalToExceptionFixture)
157{
158 const std::array<TrackingMode::Type, 3> unsupported{
160
161 for (const auto mode : unsupported) {
162 BOOST_CHECK_THROW(o2::itsmft::tracking::test::referenceTrackingParameters(o2::detectors::DetID::ITS, mode), std::runtime_error);
163 }
164}
165
166BOOST_FIXTURE_TEST_CASE(SyncStillSucceedsAfterFatalHandlerInstalled, FatalToExceptionFixture)
167{
168 // The OnFatal fixture above must not turn the supported paths into false
169 // failures: Sync and Async should still construct normally.
172}
173
174BOOST_AUTO_TEST_CASE(MFTDefaultsUseTheCommonFourHitSelection)
175{
176 const auto plan = TrackingMode::getTrackingPlan(o2::detectors::DetID::MFT, TrackingMode::Sync);
177 BOOST_REQUIRE_EQUAL(plan.iterations.size(), 1);
178
180 BOOST_CHECK_EQUAL(plan.iterations.front().MinTrackLength, 4);
181 BOOST_CHECK_EQUAL(plan.iterations.front().MinPt.size(), static_cast<size_t>(tracking::MFTNLayers - 4 + 1));
182 BOOST_CHECK_EQUAL(plan.detector.ColBins, 64);
183 BOOST_CHECK_EQUAL(plan.detector.RowBins, 128);
184}
185
186BOOST_FIXTURE_TEST_CASE(MFTOffStillReturnsEmptyNotFatal, FatalToExceptionFixture)
187{
189 const auto trackParams = o2::itsmft::tracking::test::referenceTrackingParameters(o2::detectors::DetID::MFT, TrackingMode::Off);
190 BOOST_CHECK(trackParams.empty());
191 });
192}
193
194BOOST_AUTO_TEST_CASE(SharedSchemaKeepsDetectorArraySizesAndIndependentOverrides)
195{
196 const auto checkDictionary = []<typename Config>(const Config&) {
197 auto* dictionary = TClass::GetClass(typeid(Config));
198 BOOST_REQUIRE(dictionary);
199 for (const auto* name : {"addTimeError", "sysErr2Row", "sysErr2Col"}) {
200 auto* member = dictionary->GetDataMember(name);
201 BOOST_REQUIRE(member);
202 BOOST_CHECK_EQUAL(member->GetMaxIndex(0), Config::NLayers);
203 }
204 };
205 checkDictionary(ITSCommonCATrackerParam::Instance());
206 checkDictionary(MFTCATrackerParam::Instance());
207
209 for (const auto detector : {o2::detectors::DetID::ITS, o2::detectors::DetID::MFT}) {
210 const auto other = detector == o2::detectors::DetID::ITS ? o2::detectors::DetID::MFT : o2::detectors::DetID::ITS;
211 const std::string key = detector == o2::detectors::DetID::ITS ? "ITSCommonCATrackerParam." : "MFTCATrackerParam.";
212 struct Restore {
213 std::string key;
214 ~Restore()
215 {
216 ConfigurableParam::updateFromString(key + "nIterations=-1;" + key + "startLayerMask[0]=0;" +
217 key + "minTrackLgtIter[0]=0;" + key + "maxHolesIter[0]=0;" +
218 key + "maxChi2NDF=-1;" + key + "addTimeError[0]=0;" +
219 key + "sysErr2Row[0]=0");
220 }
221 } restore{key};
223 ConfigurableParam::updateFromString(key + "nIterations=2;" + key + "startLayerMask[0]=64;" +
224 key + "minTrackLgtIter[0]=5;" + key + "maxHolesIter[0]=1;" +
225 key + "maxChi2NDF=12;" + key + "addTimeError[0]=3;" +
226 key + "sysErr2Row[0]=0.01");
227 const auto plan = TrackingMode::getTrackingPlan(detector, TrackingMode::Async);
228 BOOST_REQUIRE_EQUAL(plan.iterations.size(), 2);
229 BOOST_CHECK_EQUAL(plan.iterations[0].StartLayerMask.value(), 64);
230 BOOST_CHECK_EQUAL(plan.iterations[0].MinTrackLength, 5);
231 BOOST_CHECK_EQUAL(plan.iterations[0].MaxHoles, 1);
232 BOOST_CHECK_EQUAL(plan.iterations[0].MaxChi2NDF, 12.f);
233 BOOST_CHECK_EQUAL(plan.detector.AddTimeError[0], 3);
234 BOOST_CHECK_EQUAL(plan.detector.SystError2Row[0], 0.01f);
236 BOOST_CHECK_EQUAL(unchanged.iterations.size(), baseline.iterations.size());
237 BOOST_CHECK_EQUAL(unchanged.iterations[0].MinTrackLength, baseline.iterations[0].MinTrackLength);
238 BOOST_CHECK_EQUAL(unchanged.detector.SystError2Row[0], baseline.detector.SystError2Row[0]);
239
240 ConfigurableParam::updateFromString(key + "minTrackLgtIter[0]=0;" + key + "nIterations=4");
241 BOOST_CHECK_THROW(TrackingMode::getTrackingPlan(detector, TrackingMode::Async), std::invalid_argument);
242 ConfigurableParam::updateFromString(key + "nIterations=-1;" + key + "startLayerMask[0]=1024");
243 BOOST_CHECK_THROW(TrackingMode::getTrackingPlan(detector, TrackingMode::Async), std::invalid_argument);
244 if (detector == o2::detectors::DetID::ITS) {
245 ConfigurableParam::updateFromString(key + "startLayerMask[0]=128");
246 BOOST_CHECK_THROW(TrackingMode::getTrackingPlan(detector, TrackingMode::Async), std::invalid_argument);
247 }
248 }
249}
250
251// --- workflow-onboarding Slice 2: diamondPos/pvRes are wired through -------
252//
253// Mutates the global ITSCommonCATrackerParam singleton via
254// ConfigurableParam::setValue -- deliberately placed last in this
255// translation unit so no other test observes the mutated state.
256
257BOOST_AUTO_TEST_CASE(DiamondPosAndPVresAreWiredIntoITSSyncTrackingParameters)
258{
259 o2::conf::ConfigurableParam::setValue<float>("ITSCommonCATrackerParam", "diamondPos[0]", 1.5f);
260 o2::conf::ConfigurableParam::setValue<float>("ITSCommonCATrackerParam", "diamondPos[1]", -2.5f);
261 o2::conf::ConfigurableParam::setValue<float>("ITSCommonCATrackerParam", "diamondPos[2]", 3.5f);
262 o2::conf::ConfigurableParam::setValue<float>("ITSCommonCATrackerParam", "pvRes", 0.25f);
263 o2::conf::ConfigurableParam::setValue<bool>("ITSCommonCATrackerParam", "useDiamond", true);
264
265 const auto trackParams = o2::itsmft::tracking::test::referenceTrackingParameters(o2::detectors::DetID::ITS, TrackingMode::Sync);
266 BOOST_REQUIRE_EQUAL(trackParams.size(), 1u);
267 const auto& p = trackParams[0];
268
269 BOOST_CHECK_EQUAL(p.UseDiamond, true);
270 BOOST_CHECK_EQUAL(p.Diamond[0], 1.5f);
271 BOOST_CHECK_EQUAL(p.Diamond[1], -2.5f);
272 BOOST_CHECK_EQUAL(p.Diamond[2], 3.5f);
273 BOOST_CHECK_EQUAL(p.PVres, 0.25f);
274}
Shared CA tracking configuration for ITS and MFT.
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this baseline(disable=0)") AddOptionRTC(maxConsecTimeBinAboveThreshold
StringRef key
static int initFieldFromGRP(const o2::parameters::GRPMagField *grp, bool verbose=false)
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
std::vector< TrackingParameters > getTrackingParameters(Type mode)
TrackingPlan getTrackingPlan(o2::detectors::DetID::ID detId, Type mode)
std::vector< TrackingParameters > referenceTrackingParameters(o2::detectors::DetID::ID detector, TrackingMode::Type mode)
constexpr int MFTNLayers
MFT CA half-disk layer count.
constexpr int ITSNLayers
ITS CA layer count.
constexpr int kCAMinTrackLength
Minimum accepted CA track length for the detector presets.
BOOST_AUTO_TEST_CASE(Cluster_messageable)
BOOST_TEST_GLOBAL_FIXTURE(MagneticFieldFixture)
BOOST_FIXTURE_TEST_CASE(EveryUnsupportedITSModeFailsClosed, FatalToExceptionFixture)
BOOST_CHECK_NO_THROW(algorithm::merge(target, other))
VectorOfTObjectPtrs other
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())