Project
Loading...
Searching...
No Matches
Configuration.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#include <algorithm>
13#include <format>
14#include <limits>
15#include <string_view>
16#include <vector>
17
18#include "Framework/Logger.h"
22
23using namespace o2::its;
24
26{
27 std::string str = std::format("NZb:{} NPhB:{} PerVtx:{} DropFail:{} TtklMinPt:{:.2f} MinCl:{}", ZBins, PhiBins, PerPrimaryVertexProcessing, DropTFUponFailure, TrackletMinPt, MinTrackLength);
28 auto isSet = [](auto e) { return e >= 0; };
29 auto isAnySet = [&isSet](auto v) { return !v.empty() && std::any_of(v.begin(), v.end(), isSet); };
30 bool first = true;
31 for (int il = NLayers; il >= MinTrackLength; il--) {
32 int slot = NLayers - il;
33 if (slot < (int)MinPt.size() && MinPt[slot] > 0) {
34 if (first) {
35 first = false;
36 str += " MinPt: ";
37 }
38 str += std::format("L{}:{:.2f} ", il, MinPt[slot]);
39 }
40 }
41 if (isAnySet(SystErrorY2) || isAnySet(SystErrorZ2)) {
42 str += " SystErrY/Z:";
43 for (size_t i = 0; i < SystErrorY2.size(); i++) {
44 str += std::format("{:.2e}/{:.2e} ", SystErrorY2[i], SystErrorZ2[i]);
45 }
46 }
47 if (isAnySet(AddTimeError)) {
48 str += " AddTimeError:";
49 for (unsigned int i : AddTimeError) {
50 str += std::format("{} ", i);
51 }
52 }
54 str += std::format(" ShaMaxCls:{} ", SharedMaxClusters);
55 }
57 str += std::format(" ShaClsDPhi:{} ShaClsDEta:{} ShaClsSign:{}", SharedClusterMaxDeltaPhi, SharedClusterMaxDeltaEta, SharedClusterOppositeSign);
58 }
59 if (MaxHoles) {
60 str += std::format(" MaxHoles:{} HoleMask:{}", MaxHoles, HoleLayerMask.asString());
61 }
62 if (!InactiveLayerMask.empty()) {
63 str += std::format(" InactiveMask:{}", InactiveLayerMask.asString());
64 }
65 if (!SeedingLayers.empty()) {
66 str += std::format(" SeedingLayers:{}", SeedingLayers.asString());
67 }
70 str += std::format(" TrackFollower:{} NSigmaZ/Phi:{:.2f}/{:.2f}",
71 top && bot ? "mix" : (top ? "top" : "bot"),
75 str += std::format(" MaxHypotheses:{}", TrackFollowerMaxHypotheses);
76 }
77 }
78 if (std::numeric_limits<size_t>::max() != MaxMemory) {
79 str += std::format(" MemLimit {:.2f} GB", double(MaxMemory) / constants::GB);
80 }
81 return str;
82}
83
85{
86 std::string str = std::format("NZb:{} NPhB:{} MinVtxCont:{} SupLowMultDebris:{} MaxTrkltCls:{} ZCut:{} PhCut:{} PairCut:{} ClCut:{} SeedRad:{}x{}",
88 if (std::numeric_limits<size_t>::max() != MaxMemory) {
89 str += std::format(" MemLimit {:.2f} GB", double(MaxMemory) / constants::GB);
90 }
91 return str;
92}
93
94namespace
95{
96constexpr bool iequals(std::string_view a, std::string_view b)
97{
98 return std::equal(a.begin(), a.end(), b.begin(), b.end(),
99 [](char x, char y) { return std::tolower(x) == std::tolower(y); });
100}
101} // namespace
102
104{
105 constexpr std::array smodes = {
106 std::pair{"sync", Sync},
107 std::pair{"async", Async},
108 std::pair{"cosmics", Cosmics},
109 std::pair{"unset", Unset},
110 std::pair{"off", Off}};
111
112 auto it = std::find_if(smodes.begin(), smodes.end(), [&str](const auto& pair) {
113 return iequals(str, pair.first);
114 });
115 if (it == smodes.end()) {
116 LOGP(fatal, "Unrecognized tracking mode '{}'", str);
117 }
118 return it->second;
119}
120
122{
123 if (mode == TrackingMode::Sync) {
124 return "sync";
125 } else if (mode == TrackingMode::Async) {
126 return "async";
127 } else if (mode == TrackingMode::Cosmics) {
128 return "cosmics";
129 } else if (mode == TrackingMode::Unset) {
130 return "unset";
131 } else if (mode == TrackingMode::Off) {
132 return "off";
133 }
134 LOGP(fatal, "Unrecognized tracking mode '{}'", (int)mode);
135 return ""; // not reachable
136}
137
139{
140 const auto& tc = o2::its::TrackerParamConfig::Instance();
141 std::vector<TrackingParameters> trackParams;
142
143 if (mode == TrackingMode::Async) {
144 trackParams.resize(tc.doUPCIteration ? 4 : 3);
145 trackParams[1].TrackletMinPt = 0.2f;
146 trackParams[1].CellDeltaTanLambdaSigma *= 2.;
147 trackParams[2].TrackletMinPt = 0.1f;
148 trackParams[2].CellDeltaTanLambdaSigma *= 4.;
149
150 trackParams[0].MinPt[0] = 1.f / 12; // 7cl
151 trackParams[1].MinPt[0] = 1.f / 12; // 7cl
152
153 trackParams[2].MinTrackLength = 4;
154 trackParams[2].MinPt[0] = 1.f / 12; // 7cl
155 trackParams[2].MinPt[1] = 1.f / 5; // 6cl
156 trackParams[2].MinPt[2] = 1.f / 1; // 5cl
157 trackParams[2].MinPt[3] = 1.f / 6; // 4cl
158
159 trackParams[2].StartLayerMask = (1 << 6) + (1 << 3);
160 if (tc.doUPCIteration) {
161 trackParams[3].MinTrackLength = 4;
162 trackParams[3].TrackletMinPt = 0.1f;
163 trackParams[3].CellDeltaTanLambdaSigma *= 4.;
164 }
165 for (int ip = 0; ip < (int)trackParams.size(); ip++) {
166 auto& param = trackParams[ip];
167 param.ZBins = 64;
168 param.PhiBins = 32;
169 // check if something was overridden via configurable params
170 if (ip < constants::MaxIter) {
171 if (tc.startLayerMask[ip] > 0) {
172 param.StartLayerMask = tc.startLayerMask[ip];
173 }
174 if (tc.minTrackLgtIter[ip] > 0) {
175 param.MinTrackLength = tc.minTrackLgtIter[ip];
176 }
177 for (int ilg = tc.MaxTrackLength; ilg >= tc.MinTrackLength; ilg--) {
178 int lslot0 = (tc.MaxTrackLength - ilg), lslot = lslot0 + (ip * (tc.MaxTrackLength - tc.MinTrackLength + 1));
179 if (tc.minPtIterLgt[lslot] > 0.) {
180 param.MinPt[lslot0] = tc.minPtIterLgt[lslot];
181 }
182 }
183 }
184 }
185 } else if (mode == TrackingMode::Sync) {
186 trackParams.resize(1);
187 trackParams[0].ZBins = 64;
188 trackParams[0].PhiBins = 32;
189 trackParams[0].MinTrackLength = 4;
190 } else if (mode == TrackingMode::Cosmics) {
191 trackParams.resize(1);
192 trackParams[0].MinTrackLength = 4;
193 trackParams[0].CellDeltaTanLambdaSigma *= 10;
194 trackParams[0].PhiBins = 4;
195 trackParams[0].ZBins = 16;
196 trackParams[0].PVres = 1.e5f;
197 trackParams[0].MaxChi2ClusterAttachment = 60.;
198 trackParams[0].MaxChi2NDF = 40.;
199 } else {
200 LOGP(fatal, "Unsupported ITS tracking mode {} ", toString(mode));
201 }
202
203 for (auto& param : trackParams) {
204 param.PassFlags.reset();
205 }
206 trackParams[0].PassFlags.set(IterationStep::FirstPass, IterationStep::RebuildClusterLUT);
207 if (trackParams.size() > 3 && tc.doUPCIteration) {
209 }
210 float bFactor = std::abs(o2::base::Propagator::Instance()->getNominalBz()) / 5.0066791f;
211 float bFactorTracklets = bFactor < 0.01f ? 1.f : bFactor; // for tracklets only
212
213 // global parameters set for every iteration
214 for (auto& p : trackParams) {
215 // adjust pT settings to actual mag. field
216 p.TrackletMinPt *= bFactorTracklets;
217 for (int ilg = tc.MaxTrackLength; ilg >= tc.MinTrackLength; ilg--) {
218 int lslot = tc.MaxTrackLength - ilg;
219 p.MinPt[lslot] *= bFactor;
220 }
221 p.ReseedIfShorter = tc.reseedIfShorter;
222 p.RepeatRefitOut = tc.repeatRefitOut;
223 p.ShiftRefToCluster = tc.shiftRefToCluster;
224 p.CreateArtefactLabels = tc.createArtefactLabels;
225 p.TrackFollowerNSigmaCutZ = tc.trackFollowerNSigmaCutZ;
226 p.TrackFollowerNSigmaCutPhi = tc.trackFollowerNSigmaCutPhi;
227 p.TrackFollowerMaxHypotheses = std::max(1, tc.trackFollowerMaxHypotheses);
228
229 p.PrintMemory = tc.printMemory;
230 p.MaxMemory = tc.maxMemory;
231 p.DropTFUponFailure = tc.dropTFUponFailure;
232 p.SaveTimeBenchmarks = tc.saveTimeBenchmarks;
233 p.FataliseUponFailure = tc.fataliseUponFailure;
234 p.AllowSharingFirstCluster = tc.allowSharingFirstCluster;
235 p.SharedClusterMaxDeltaPhi = tc.sharedClusterMaxDeltaPhi;
236 p.SharedClusterMaxDeltaEta = tc.sharedClusterMaxDeltaEta;
237 p.SharedClusterOppositeSign = tc.sharedClusterOppositeSign;
238 const auto iter = &p - trackParams.data();
239 if (iter < constants::MaxIter) {
240 p.MaxHoles = tc.maxHolesIter[iter];
241 p.HoleLayerMask = tc.holeLayerMaskIter[iter];
242 if (tc.trackFollowerTop[iter]) {
243 p.PassFlags.set(IterationStep::TrackFollowerTop);
244 }
245 if (tc.trackFollowerBot[iter]) {
246 p.PassFlags.set(IterationStep::TrackFollowerBot);
247 }
248 }
249
250 if (tc.useMatCorrTGeo) {
252 } else if (tc.useFastMaterial) {
254 } else {
256 }
257
258 if (p.NLayers == 7) {
259 for (int i{0}; i < 7; ++i) {
260 p.SystErrorY2[i] = tc.sysErrY2[i] > 0 ? tc.sysErrY2[i] : p.SystErrorY2[i];
261 p.SystErrorZ2[i] = tc.sysErrZ2[i] > 0 ? tc.sysErrZ2[i] : p.SystErrorZ2[i];
262 }
263 }
264 for (int i{0}; i < 7; ++i) {
265 p.AddTimeError[i] = tc.addTimeError[i];
266 }
267 p.DoUPCIteration = tc.doUPCIteration;
268 p.MaxChi2ClusterAttachment = tc.maxChi2ClusterAttachment > 0 ? tc.maxChi2ClusterAttachment : p.MaxChi2ClusterAttachment;
269 p.MaxChi2NDF = tc.maxChi2NDF > 0 ? tc.maxChi2NDF : p.MaxChi2NDF;
270 p.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : p.PhiBins;
271 p.ZBins = tc.LUTbinsZ > 0 ? tc.LUTbinsZ : p.ZBins;
272 p.PVres = tc.pvRes > 0 ? tc.pvRes : p.PVres;
273 p.NSigmaCut *= tc.nSigmaCut > 0 ? tc.nSigmaCut : 1.f;
274 p.CellDeltaTanLambdaSigma *= tc.deltaTanLres > 0 ? tc.deltaTanLres : 1.f;
275 p.TrackletMinPt *= tc.minPt > 0 ? tc.minPt : 1.f;
276 p.PerPrimaryVertexProcessing = tc.perPrimaryVertexProcessing;
277 for (int iD{0}; iD < 3; ++iD) {
278 p.Diamond[iD] = tc.diamondPos[iD];
279 }
280 p.UseDiamond = tc.useDiamond;
281 }
282
283 if (trackParams.size() > tc.nIterations) {
284 trackParams.resize(tc.nIterations);
285 }
286
287 return trackParams;
288}
289
291{
293 std::vector<VertexingParameters> vertParams(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice
294 for (auto& param : vertParams) {
295 param.PassFlags.reset();
296 }
297 vertParams[0].PassFlags.set(IterationStep::FirstPass, IterationStep::ResetVertices);
299
300 // global parameters set for every iteration
301 for (auto& p : vertParams) {
302 p.vertPerRofThreshold = vc.vertPerRofThreshold;
303 p.SaveTimeBenchmarks = vc.saveTimeBenchmarks;
304 p.PrintMemory = vc.printMemory;
305 p.MaxMemory = vc.maxMemory;
306 p.DropTFUponFailure = vc.dropTFUponFailure;
307 p.NSigmaCut = vc.nSigmaCut;
308 p.maxZPositionAllowed = vc.maxZPositionAllowed;
309 p.clusterContributorsCut = vc.clusterContributorsCut;
310 p.suppressLowMultDebris = vc.suppressLowMultDebris;
311 p.seedMemberRadiusTime = vc.seedMemberRadiusTime;
312 p.seedMemberRadiusZ = vc.seedMemberRadiusZ;
313 p.phiSpan = vc.phiSpan;
314 p.nThreads = vc.nThreads;
315 p.ZBins = vc.ZBins;
316 p.PhiBins = vc.PhiBins;
317 p.useTruthSeeding = vc.useTruthSeeding;
318 p.maxTrackletsPerCluster = vc.maxTrackletsPerCluster;
319 p.zCut = vc.zCut;
320 p.phiCut = vc.phiCut;
321 p.pairCut = vc.pairCut;
322 p.clusterCut = vc.clusterCut;
323 p.coarseZWindow = vc.coarseZWindow;
324 p.seedDedupZCut = vc.seedDedupZCut;
325 p.refitDedupZCut = vc.refitDedupZCut;
326 p.duplicateZCut = vc.duplicateZCut;
327 p.finalSelectionZCut = vc.finalSelectionZCut;
328 p.duplicateDistance2Cut = vc.duplicateDistance2Cut;
329 p.tanLambdaCut = vc.tanLambdaCut;
330 }
331
332 if (mode == TrackingMode::Async) {
333 // relax for UPC iteration
334 vertParams[1].phiCut = 0.015f;
335 vertParams[1].tanLambdaCut = 0.015f;
336 vertParams[1].maxTrackletsPerCluster = 2000;
337 vertParams[1].suppressLowMultDebris = 0; // do not suppress low mult vertices in UPC mode
339 vertParams.resize(1);
340 } else {
341 LOGP(fatal, "Unsupported ITS vertexing mode {} ", toString(mode));
342 }
343
344 if (vertParams.size() > vc.nIterations) {
345 vertParams.resize(vc.nIterations);
346 }
347
348 return vertParams;
349}
int32_t i
std::string toString(CoderTag tag)
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:178
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum mode
Definition glcorearb.h:266
const GLdouble * v
Definition glcorearb.h:832
GLdouble GLdouble GLdouble GLdouble top
Definition glcorearb.h:4077
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLenum GLfloat param
Definition glcorearb.h:271
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
std::vector< VertexingParameters > getVertexingParameters(Type mode)
Type fromString(std::string_view str)
std::string toString(Type mode)
std::vector< TrackingParameters > getTrackingParameters(Type mode)
constexpr float GB
Definition Constants.h:27
constexpr int MaxIter
Definition Constants.h:36
std::string asString() const
int MinTrackLength
General parameters.
std::vector< float > SystErrorY2
std::vector< float > SystErrorZ2
float TrackletMinPt
Trackleting cuts.
std::vector< float > MinPt
std::vector< uint32_t > AddTimeError
std::string asString() const
const std::string str