Project
Loading...
Searching...
No Matches
TrackingParameterTestSupport.h
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#ifndef ALICEO2_ITSMFT_TRACKING_PARAMETER_TEST_SUPPORT_H_
13#define ALICEO2_ITSMFT_TRACKING_PARAMETER_TEST_SUPPORT_H_
18#include <functional>
20
22{
23template <typename T>
24concept HasDetectorRadii = requires(T value) { value.LayerRadii; };
25template <typename T>
26concept HasMemoryPolicy = requires(T value) { value.MaxMemory; };
27template <typename T>
28concept HasFailurePolicy = requires(T value) { value.DropTFUponFailure; };
33
34// Retain the old input shape only for independent numerical reference fixtures.
36 // Frozen pre-consolidation radii for independent numerical oracles.
37 std::vector<float> LayerRadii = {2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f};
38 std::vector<float> LayerxX0 = {5.e-3f, 5.e-3f, 5.e-3f, 1.e-2f, 1.e-2f, 1.e-2f, 1.e-2f};
39};
40// Fixed inputs for synthetic fixtures, independent of runtime configuration and field.
42{
43 TrackingParameters parameters;
44 if (detector == o2::detectors::DetID::MFT) {
45 parameters.NLayers = MFTNLayers;
46 parameters.LayerResolution.assign(MFTNLayers, 5.e-4f);
47 parameters.SystError2Row.assign(MFTNLayers, 0.f);
48 parameters.SystError2Col.assign(MFTNLayers, 0.f);
49 parameters.AddTimeError.assign(MFTNLayers, 0u);
50 parameters.ColBins = 64;
51 parameters.RowBins = 128;
52 parameters.UseDiamond = true;
53 parameters.PerPrimaryVertexProcessing = false;
54 parameters.StartLayerMask = (1u << MFTNLayers) - 1u;
55 parameters.MinPt.assign(MFTNLayers - 4 + 1, 0.f);
56 }
57 return parameters;
58}
60{
61 static_cast<TrackingParameters&>(parameters) = makeTestTrackingParameters(detector);
63 if (detector == o2::detectors::DetID::MFT) {
64 constexpr std::array<float, MFTNLayers> minima{2.1f, 2.1f, 2.1f, 2.1f, 2.1f, 2.1f, 3.1f, 3.1f, 3.5f, 3.5f};
65 constexpr std::array<float, MFTNLayers> maxima{12.5f, 12.5f, 12.5f, 12.5f, 14.f, 14.f, 17.f, 17.f, 17.5f, 17.5f};
66 parameters.LayerRadii.resize(MFTNLayers);
67 for (int layer = 0; layer < MFTNLayers; ++layer) {
68 parameters.LayerRadii[layer] = 0.5f * (minima[layer] + maxima[layer]);
69 }
70 }
71 parameters.LayerxX0.clear();
72 const auto catalog = detector == o2::detectors::DetID::ITS
75 for (uint32_t layer = 0; layer < catalog.nSurfaces; ++layer) {
76 parameters.LayerxX0.push_back(catalog.surfaces[layer].material.xOverX0);
77 }
78}
80{
81 return {parameters, parameters, {parameters}};
82}
84{
85 TrackingPlan plan{std::move(static_cast<DetectorParameters&>(parameters)), parameters, {}};
86 plan.iterations.push_back(std::move(static_cast<IterationParameters&>(parameters)));
87 return plan;
88}
89template <typename Parameters>
90TrackingPlan makeTrackingPlan(const std::vector<Parameters>& parameters)
91{
92 if (parameters.empty()) {
93 return {};
94 }
95 auto plan = makeTrackingPlan(parameters.front());
96 plan.iterations.assign(parameters.begin(), parameters.end());
97 return plan;
98}
99// Expand the split result solely to keep pre-refactor preset assertions intact.
100inline std::vector<TrackingParameters> expandTrackingPlan(const TrackingPlan& plan)
101{
102 std::vector<TrackingParameters> result;
103 for (const auto& iteration : plan.iterations) {
104 result.push_back({iteration, plan.detector, plan.execution});
105 }
106 return result;
107}
108inline std::vector<TrackingParameters> referenceTrackingParameters(o2::detectors::DetID::ID detector, TrackingMode::Type mode)
109{
111}
112// Synthetic decoding is confined to tests. Exercise the same normalization
113// and ROF bookkeeping as production without constructing detector geometry.
115 // Fixture-owned timing is bound separately after cluster loading.
118 std::function<DecodedCluster(const itsmft::CompClusterExt&, gsl::span<const unsigned char>::iterator&,
119 const itsmft::TopologyDictionary*, uint32_t)>
121
122 template <typename Decoder>
123 void setDecoder(const Decoder& decoder)
124 {
125 decode = [&decoder](const auto& cluster, auto& patterns, const auto* dictionary, uint32_t index) {
126 return decoder.decode(cluster, patterns, dictionary, index);
127 };
128 }
129};
130
131inline void loadSources(TimeFrame& frame, const SurfaceCatalogView& catalog,
132 gsl::span<const TestClusterSourceInput> sources, const o2::InteractionRecord&,
133 std::vector<std::vector<uint32_t>>* indices = nullptr,
134 std::vector<std::vector<uint32_t>>* sizes = nullptr, bool requireCompleteMapping = false)
135{
136 const std::vector<ClusterSourceInput> inputs(sources.begin(), sources.end());
137 detail::prepareSources(frame, catalog, inputs, indices, sizes, requireCompleteMapping);
138 std::vector<std::vector<uint32_t>> externalIndices(catalog.nSurfaces);
139 std::vector<std::vector<uint32_t>> clusterSizes(catalog.nSurfaces);
140 bool hasMCInformation = false;
141 for (const auto& source : sources) {
143 detail::loadDecodedSource(frame, catalog, source, [&](const auto& cluster, auto& patterns) {
144 const auto index = static_cast<uint32_t>(&cluster - source.clusters.data());
145 return source.decode(cluster, patterns, source.dictionary, index); }, externalIndices, clusterSizes);
146 hasMCInformation |= source.labels != nullptr;
147 }
148 frame.setHasMCInformation(hasMCInformation);
149 if (!sources.empty()) {
150 frame.setROFViews(sources.front().rofViews);
151 for (const auto& source : sources) {
152 for (uint16_t layer = 0; layer < source.layerToSurface.size(); ++layer) {
153 frame.setROFViews(source.layerToSurface[layer].value(), source.rofViews, layer);
154 }
155 }
156 }
157 if (indices != nullptr) {
158 *indices = std::move(externalIndices);
159 }
160 if (sizes != nullptr) {
161 *sizes = std::move(clusterSizes);
162 }
163}
164
165inline void loadTimeFrameSources(TimeFrame& frame, gsl::span<const TestClusterSourceInput> sources,
167 std::vector<std::vector<uint32_t>>* indices = nullptr,
168 std::vector<std::vector<uint32_t>>* sizes = nullptr)
169{
170 loadSources(frame, catalog, sources, origin, indices, sizes, true);
171}
172
173template <typename Decoder>
175 TimeFrame& frame,
176 const Decoder& decoder,
178 const o2::its::LayerTiming& timing,
179 gsl::span<const itsmft::CompClusterExt> clusters,
180 gsl::span<const unsigned char> patterns,
181 gsl::span<const o2::itsmft::ROFRecord> rofs,
182 const itsmft::TopologyDictionary* dictionary,
185 gsl::span<const LayerId> layerToSurface,
186 SurfaceCatalogView catalog,
187 std::vector<std::vector<uint32_t>>* externalIndicesBySurface = nullptr,
188 std::vector<std::vector<uint32_t>>* clusterSizesBySurface = nullptr)
189{
190 constexpr ClusterSourceId sourceId{0};
192 source.id = sourceId;
193 source.detector = detector;
194 source.clusters = clusters;
195 source.patterns = patterns;
196 source.rofs = rofs;
197 source.dictionary = dictionary;
198 source.labels = labels;
199 source.layerToSurface = layerToSurface;
200 source.timing = timing;
201 source.setDecoder(decoder);
202 source.rofViews = frame.getROFViews();
203 loadTimeFrameSources(frame, gsl::span<const TestClusterSourceInput>{&source, 1}, catalog, origin,
204 externalIndicesBySurface, clusterSizesBySurface);
205}
206
207} // namespace o2::itsmft::tracking::test
208#endif
header::DataOrigin origin
Shared CA tracking configuration for ITS and MFT.
Passive common TimeFrame owner.
Shared cluster I/O utilities for ITS and MFT (based on ITStracking/IOUtils.h)
std::vector< o2::MCCompLabel > labels
A container to hold and manage MC truth information/labels.
int ID
Detector identifiers: continuous, starting from 0.
Definition DetID.h:63
GLenum mode
Definition glcorearb.h:266
GLuint64EXT * result
Definition glcorearb.h:5662
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition glcorearb.h:2595
GLuint index
Definition glcorearb.h:781
GLsizei GLsizei GLchar * source
Definition glcorearb.h:798
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLsizei GLenum const void * indices
Definition glcorearb.h:400
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLsizei GLenum * sources
Definition glcorearb.h:2516
TrackingPlan getTrackingPlan(o2::detectors::DetID::ID detId, Type mode)
void loadDecodedSource(TimeFrame &frame, const SurfaceCatalogView &catalog, const ClusterSourceInput &src, const Decode &decode, std::vector< std::vector< uint32_t > > &externalIndices, std::vector< std::vector< uint32_t > > &clusterSizes)
Definition IOUtils.h:151
void validateClusterRanges(const ClusterSourceInput &)
Definition IOUtils.cxx:266
void prepareSources(TimeFrame &, const SurfaceCatalogView &, gsl::span< const ClusterSourceInput >, std::vector< std::vector< uint32_t > > *, std::vector< std::vector< uint32_t > > *, bool requireCompleteMapping=false)
Definition IOUtils.cxx:203
std::vector< TrackingParameters > expandTrackingPlan(const TrackingPlan &plan)
void resetReferenceTrackingParameters(ReferenceTrackingParameters &parameters, o2::detectors::DetID::ID detector)
std::vector< TrackingParameters > referenceTrackingParameters(o2::detectors::DetID::ID detector, TrackingMode::Type mode)
TrackingParameters makeTestTrackingParameters(o2::detectors::DetID::ID detector)
void loadTimeFrameSources(TimeFrame &frame, gsl::span< const TestClusterSourceInput > sources, SurfaceCatalogView catalog, const o2::InteractionRecord &origin, std::vector< std::vector< uint32_t > > *indices=nullptr, std::vector< std::vector< uint32_t > > *sizes=nullptr)
TrackingPlan makeTrackingPlan(const TrackingParameters &parameters)
void loadSources(TimeFrame &frame, const SurfaceCatalogView &catalog, gsl::span< const TestClusterSourceInput > sources, const o2::InteractionRecord &, std::vector< std::vector< uint32_t > > *indices=nullptr, std::vector< std::vector< uint32_t > > *sizes=nullptr, bool requireCompleteMapping=false)
void loadTimeFrameSource(TimeFrame &frame, const Decoder &decoder, const o2::InteractionRecord &origin, const o2::its::LayerTiming &timing, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char > patterns, gsl::span< const o2::itsmft::ROFRecord > rofs, const itsmft::TopologyDictionary *dictionary, const dataformats::MCTruthContainer< MCCompLabel > *labels, o2::detectors::DetID::ID detector, gsl::span< const LayerId > layerToSurface, SurfaceCatalogView catalog, std::vector< std::vector< uint32_t > > *externalIndicesBySurface=nullptr, std::vector< std::vector< uint32_t > > *clusterSizesBySurface=nullptr)
constexpr std::array< SurfaceDescriptor, MFTNLayers > kMFTSurfaces
constexpr int MFTNLayers
MFT CA half-disk layer count.
constexpr std::array< SurfaceDescriptor, ITSNLayers > kITSSurfaces
std::vector< uint32_t > AddTimeError
std::vector< float > SystError2Col
std::vector< float > SystError2Row
std::vector< float > LayerResolution
tracking::LayerMask StartLayerMask
TrackingExecutionPolicy execution
DetectorParameters detector
std::vector< IterationParameters > iterations
const o2::itsmft::TopologyDictionary * dictionary
Definition IOUtils.h:124
gsl::span< const unsigned char > patterns
Definition IOUtils.h:122
void setHasMCInformation(bool value) noexcept
Definition TimeFrame.h:87
const RuntimeROFViews & getROFViews() const noexcept
Definition TimeFrame.h:128
void setROFViews(RuntimeROFViews views) noexcept
std::function< DecodedCluster(const itsmft::CompClusterExt &, gsl::span< const unsigned char >::iterator &, const itsmft::TopologyDictionary *, uint32_t)> decode
std::vector< Cluster > clusters