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 if (tc.seedingVertexIteration && !trackParams.empty()) {
289 TrackingParameters seedingPass = trackParams.front();
292 seedingPass.PerPrimaryVertexProcessing = false;
293 seedingPass.CreateArtefactLabels = true;
294 seedingPass.UseDiamond = true; // PV-independent
295 seedingPass.NLayers = 3; // 3-layer {0,1,2} vertexing topology
296 seedingPass.MinTrackLength = 3; // only trackleting+celling on the 3 inner layers
297 seedingPass.ZBins = vc.ZBins;
298 seedingPass.PhiBins = vc.PhiBins;
299 seedingPass.Diamond[0] = tc.diamondPos[0];
300 seedingPass.Diamond[1] = tc.diamondPos[1];
301 seedingPass.Diamond[2] = tc.diamondPos[2];
302 seedingPass.NSigmaCut = tc.diamondTrackletingNSigmaCut;
303 seedingPass.PVres = tc.diamondTrackletingPVres;
304 seedingPass.CellDeltaTanLambdaSigma = tc.diamondTrackletingCellDeltaTanLambdaSigma;
305 seedingPass.CellDeltaTanLambdaNSigma = tc.diamondCellTanLambdaNSigma;
306 seedingPass.CellDeltaPhiMinPt = tc.diamondTrackletingCellDeltaPhiMinPt;
307 seedingPass.CellLineSharedClusterCut = tc.cellLineSharedClusterCut;
308 seedingPass.VertPerRofThreshold = vc.vertPerRofThreshold;
309 seedingPass.VtxPhiCut = vc.phiCut;
310 seedingPass.VtxLineMinPt = vc.lineMinPt;
311 seedingPass.VtxLineCurvatureScale = vc.lineCurvatureScale;
312 seedingPass.VtxMaxZPositionAllowed = vc.maxZPositionAllowed;
313 seedingPass.VtxClusterCut = vc.clusterCut;
314 seedingPass.VtxPairCut = vc.pairCut;
315 seedingPass.VtxNSigmaCut = vc.nSigmaCut;
316 seedingPass.VtxDuplicateZCut = vc.duplicateZCut;
317 seedingPass.VtxDuplicateZScale = vc.duplicateZScale;
318 seedingPass.VtxFineZWindow = vc.fineZWindow;
319 seedingPass.VtxFineMinDensity = vc.fineMinDensity;
320 seedingPass.VtxFineMaxDrift = vc.fineMaxDrift;
321 seedingPass.VtxGoodLineChi2Cut = vc.goodLineChi2Cut;
322 seedingPass.VtxGoodLinePtCut = vc.goodLinePtCut;
323 seedingPass.VtxGoodContributorsSignificance = vc.goodContributorsSignificance;
324 seedingPass.VtxClusterContributorsCut = vc.clusterContributorsCut;
325 seedingPass.VtxSuppressLowMultDebris = vc.suppressLowMultDebris;
326 seedingPass.VtxOverpopulatedRofNSigma = vc.overpopulatedRofNSigma;
327 std::vector<TrackingParameters> seedingPasses;
328 seedingPasses.push_back(seedingPass);
329
330 if (tc.doUPCIteration) {
331 TrackingParameters upcPass = seedingPass;
337 upcPass.VtxClusterContributorsCut = 2;
338 upcPass.VtxSuppressLowMultDebris = 0;
339 seedingPasses.push_back(upcPass);
340 }
341
342 trackParams.insert(trackParams.begin(), seedingPasses.begin(), seedingPasses.end());
343 }
344
345 if (!trackParams.empty()) {
346 trackParams.front().PassFlags.set(IterationStep::LoadPersistentTables);
347 }
348
349 if (trackParams.size() > static_cast<size_t>(constants::MaxIter + constants::MaxSeedingPasses)) {
350 LOGP(fatal, "{} tracking passes configured, but at most {} are supported (MaxIter={} + MaxSeedingPasses={})",
353 }
354
355 return trackParams;
356}
357
359{
361 std::vector<VertexingParameters> vertParams(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice
362 for (auto& param : vertParams) {
363 param.PassFlags.reset();
364 }
365 vertParams[0].PassFlags.set(IterationStep::FirstPass, IterationStep::ResetVertices);
367
368 // global parameters set for every iteration
369 for (auto& p : vertParams) {
370 p.vertPerRofThreshold = vc.vertPerRofThreshold;
371 p.SaveTimeBenchmarks = vc.saveTimeBenchmarks;
372 p.PrintMemory = vc.printMemory;
373 p.MaxMemory = vc.maxMemory;
374 p.DropTFUponFailure = vc.dropTFUponFailure;
375 p.NSigmaCut = vc.nSigmaCut;
376 p.maxZPositionAllowed = vc.maxZPositionAllowed;
377 p.clusterContributorsCut = vc.clusterContributorsCut;
378 p.suppressLowMultDebris = vc.suppressLowMultDebris;
379 p.seedMemberRadiusTime = vc.seedMemberRadiusTime;
380 p.seedMemberRadiusZ = vc.seedMemberRadiusZ;
381 p.phiSpan = vc.phiSpan;
382 p.nThreads = vc.nThreads;
383 p.ZBins = vc.ZBins;
384 p.PhiBins = vc.PhiBins;
385 p.useTruthSeeding = vc.useTruthSeeding;
386 p.maxTrackletsPerCluster = vc.maxTrackletsPerCluster;
387 p.zCut = vc.zCut;
388 p.phiCut = vc.phiCut;
389 p.pairCut = vc.pairCut;
390 p.clusterCut = vc.clusterCut;
391 p.coarseZWindow = vc.coarseZWindow;
392 p.seedDedupZCut = vc.seedDedupZCut;
393 p.refitDedupZCut = vc.refitDedupZCut;
394 p.duplicateZCut = vc.duplicateZCut;
395 p.finalSelectionZCut = vc.finalSelectionZCut;
396 p.duplicateDistance2Cut = vc.duplicateDistance2Cut;
397 p.tanLambdaCut = vc.tanLambdaCut;
398 }
399
400 if (mode == TrackingMode::Async) {
401 // relax for UPC iteration
402 vertParams[1].phiCut = 0.015f;
403 vertParams[1].tanLambdaCut = 0.015f;
404 vertParams[1].maxTrackletsPerCluster = 2000;
405 vertParams[1].suppressLowMultDebris = 0; // do not suppress low mult vertices in UPC mode
407 vertParams.resize(1);
408 } else {
409 LOGP(fatal, "Unsupported ITS vertexing mode {} ", toString(mode));
410 }
411
412 if (vertParams.size() > vc.nIterations) {
413 vertParams.resize(vc.nIterations);
414 }
415
416 return vertParams;
417}
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
std::string toString(CoderTag tag)
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:180
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLdouble GLdouble GLdouble GLdouble top
Definition glcorearb.h:4077
GLint first
Definition glcorearb.h:399
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
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 MaxSeedingPasses
Definition Constants.h:37
constexpr int MaxIter
Definition Constants.h:36
std::string asString() const
int MinTrackLength
General parameters.
std::vector< float > SystErrorY2
float CellDeltaTanLambdaSigma
Cell finding cuts.
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