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 (std::numeric_limits<size_t>::max() != MaxMemory) {
63 str += std::format(" MemLimit {:.2f} GB", double(MaxMemory) / constants::GB);
64 }
65 return str;
66}
67
69{
70 std::string str = std::format("NZb:{} NPhB:{} MinVtxCont:{} SupLowMultDebris:{} MaxTrkltCls:{} ZCut:{} PhCut:{} PairCut:{} ClCut:{} SeedRad:{}x{}",
72 if (std::numeric_limits<size_t>::max() != MaxMemory) {
73 str += std::format(" MemLimit {:.2f} GB", double(MaxMemory) / constants::GB);
74 }
75 return str;
76}
77
78namespace
79{
80constexpr bool iequals(std::string_view a, std::string_view b)
81{
82 return std::equal(a.begin(), a.end(), b.begin(), b.end(),
83 [](char x, char y) { return std::tolower(x) == std::tolower(y); });
84}
85} // namespace
86
88{
89 constexpr std::array smodes = {
90 std::pair{"sync", Sync},
91 std::pair{"async", Async},
92 std::pair{"cosmics", Cosmics},
93 std::pair{"unset", Unset},
94 std::pair{"off", Off}};
95
96 auto it = std::find_if(smodes.begin(), smodes.end(), [&str](const auto& pair) {
97 return iequals(str, pair.first);
98 });
99 if (it == smodes.end()) {
100 LOGP(fatal, "Unrecognized tracking mode '{}'", str);
101 }
102 return it->second;
103}
104
106{
107 if (mode == TrackingMode::Sync) {
108 return "sync";
109 } else if (mode == TrackingMode::Async) {
110 return "async";
111 } else if (mode == TrackingMode::Cosmics) {
112 return "cosmics";
113 } else if (mode == TrackingMode::Unset) {
114 return "unset";
115 } else if (mode == TrackingMode::Off) {
116 return "off";
117 }
118 LOGP(fatal, "Unrecognized tracking mode '{}'", (int)mode);
119 return ""; // not reachable
120}
121
123{
124 const auto& tc = o2::its::TrackerParamConfig::Instance();
125 std::vector<TrackingParameters> trackParams;
126
127 if (mode == TrackingMode::Async) {
128 trackParams.resize(tc.doUPCIteration ? 4 : 3);
129 trackParams[1].TrackletMinPt = 0.2f;
130 trackParams[1].CellDeltaTanLambdaSigma *= 2.;
131 trackParams[2].TrackletMinPt = 0.1f;
132 trackParams[2].CellDeltaTanLambdaSigma *= 4.;
133
134 trackParams[0].MinPt[0] = 1.f / 12; // 7cl
135 trackParams[1].MinPt[0] = 1.f / 12; // 7cl
136
137 trackParams[2].MinTrackLength = 4;
138 trackParams[2].MinPt[0] = 1.f / 12; // 7cl
139 trackParams[2].MinPt[1] = 1.f / 5; // 6cl
140 trackParams[2].MinPt[2] = 1.f / 1; // 5cl
141 trackParams[2].MinPt[3] = 1.f / 6; // 4cl
142
143 trackParams[2].StartLayerMask = (1 << 6) + (1 << 3);
144 if (tc.doUPCIteration) {
145 trackParams[3].MinTrackLength = 4;
146 trackParams[3].TrackletMinPt = 0.1f;
147 trackParams[3].CellDeltaTanLambdaSigma *= 4.;
148 }
149 for (int ip = 0; ip < (int)trackParams.size(); ip++) {
150 auto& param = trackParams[ip];
151 param.ZBins = 64;
152 param.PhiBins = 32;
153 // check if something was overridden via configurable params
154 if (ip < constants::MaxIter) {
155 if (tc.startLayerMask[ip] > 0) {
156 param.StartLayerMask = tc.startLayerMask[ip];
157 }
158 if (tc.minTrackLgtIter[ip] > 0) {
159 param.MinTrackLength = tc.minTrackLgtIter[ip];
160 }
161 for (int ilg = tc.MaxTrackLength; ilg >= tc.MinTrackLength; ilg--) {
162 int lslot0 = (tc.MaxTrackLength - ilg), lslot = lslot0 + (ip * (tc.MaxTrackLength - tc.MinTrackLength + 1));
163 if (tc.minPtIterLgt[lslot] > 0.) {
164 param.MinPt[lslot0] = tc.minPtIterLgt[lslot];
165 }
166 }
167 }
168 }
169 } else if (mode == TrackingMode::Sync) {
170 trackParams.resize(1);
171 trackParams[0].ZBins = 64;
172 trackParams[0].PhiBins = 32;
173 trackParams[0].MinTrackLength = 4;
174 } else if (mode == TrackingMode::Cosmics) {
175 trackParams.resize(1);
176 trackParams[0].MinTrackLength = 4;
177 trackParams[0].CellDeltaTanLambdaSigma *= 10;
178 trackParams[0].PhiBins = 4;
179 trackParams[0].ZBins = 16;
180 trackParams[0].PVres = 1.e5f;
181 trackParams[0].MaxChi2ClusterAttachment = 60.;
182 trackParams[0].MaxChi2NDF = 40.;
183 } else {
184 LOGP(fatal, "Unsupported ITS tracking mode {} ", toString(mode));
185 }
186
187 for (auto& param : trackParams) {
188 param.PassFlags.reset();
189 }
190 trackParams[0].PassFlags.set(IterationStep::FirstPass, IterationStep::RebuildClusterLUT);
191 if (trackParams.size() > 3 && tc.doUPCIteration) {
193 }
194
195 float bFactor = std::abs(o2::base::Propagator::Instance()->getNominalBz()) / 5.0066791f;
196 float bFactorTracklets = bFactor < 0.01f ? 1.f : bFactor; // for tracklets only
197
198 // global parameters set for every iteration
199 for (auto& p : trackParams) {
200 // adjust pT settings to actual mag. field
201 p.TrackletMinPt *= bFactorTracklets;
202 for (int ilg = tc.MaxTrackLength; ilg >= tc.MinTrackLength; ilg--) {
203 int lslot = tc.MaxTrackLength - ilg;
204 p.MinPt[lslot] *= bFactor;
205 }
206 p.ReseedIfShorter = tc.reseedIfShorter;
207 p.RepeatRefitOut = tc.repeatRefitOut;
208 p.ShiftRefToCluster = tc.shiftRefToCluster;
209 p.CreateArtefactLabels = tc.createArtefactLabels;
210
211 p.PrintMemory = tc.printMemory;
212 p.MaxMemory = tc.maxMemory;
213 p.DropTFUponFailure = tc.dropTFUponFailure;
214 p.SaveTimeBenchmarks = tc.saveTimeBenchmarks;
215 p.FataliseUponFailure = tc.fataliseUponFailure;
216 p.AllowSharingFirstCluster = tc.allowSharingFirstCluster;
217 p.SharedClusterMaxDeltaPhi = tc.sharedClusterMaxDeltaPhi;
218 p.SharedClusterMaxDeltaEta = tc.sharedClusterMaxDeltaEta;
219 p.SharedClusterOppositeSign = tc.sharedClusterOppositeSign;
220 const auto iter = &p - trackParams.data();
221 if (iter < constants::MaxIter) {
222 p.MaxHoles = tc.maxHolesIter[iter];
223 p.HoleLayerMask = tc.holeLayerMaskIter[iter];
224 }
225
226 if (tc.useMatCorrTGeo) {
228 } else if (tc.useFastMaterial) {
230 } else {
232 }
233
234 if (p.NLayers == 7) {
235 for (int i{0}; i < 7; ++i) {
236 p.SystErrorY2[i] = tc.sysErrY2[i] > 0 ? tc.sysErrY2[i] : p.SystErrorY2[i];
237 p.SystErrorZ2[i] = tc.sysErrZ2[i] > 0 ? tc.sysErrZ2[i] : p.SystErrorZ2[i];
238 }
239 }
240 for (int i{0}; i < 7; ++i) {
241 p.AddTimeError[i] = tc.addTimeError[i];
242 }
243 p.DoUPCIteration = tc.doUPCIteration;
244 p.MaxChi2ClusterAttachment = tc.maxChi2ClusterAttachment > 0 ? tc.maxChi2ClusterAttachment : p.MaxChi2ClusterAttachment;
245 p.MaxChi2NDF = tc.maxChi2NDF > 0 ? tc.maxChi2NDF : p.MaxChi2NDF;
246 p.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : p.PhiBins;
247 p.ZBins = tc.LUTbinsZ > 0 ? tc.LUTbinsZ : p.ZBins;
248 p.PVres = tc.pvRes > 0 ? tc.pvRes : p.PVres;
249 p.NSigmaCut *= tc.nSigmaCut > 0 ? tc.nSigmaCut : 1.f;
250 p.CellDeltaTanLambdaSigma *= tc.deltaTanLres > 0 ? tc.deltaTanLres : 1.f;
251 p.TrackletMinPt *= tc.minPt > 0 ? tc.minPt : 1.f;
252 p.PerPrimaryVertexProcessing = tc.perPrimaryVertexProcessing;
253 for (int iD{0}; iD < 3; ++iD) {
254 p.Diamond[iD] = tc.diamondPos[iD];
255 }
256 p.UseDiamond = tc.useDiamond;
257 }
258
259 if (trackParams.size() > tc.nIterations) {
260 trackParams.resize(tc.nIterations);
261 }
262
263 return trackParams;
264}
265
267{
269 std::vector<VertexingParameters> vertParams(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice
270 for (auto& param : vertParams) {
271 param.PassFlags.reset();
272 }
273 vertParams[0].PassFlags.set(IterationStep::FirstPass, IterationStep::ResetVertices);
275
276 // global parameters set for every iteration
277 for (auto& p : vertParams) {
278 p.vertPerRofThreshold = vc.vertPerRofThreshold;
279 p.SaveTimeBenchmarks = vc.saveTimeBenchmarks;
280 p.PrintMemory = vc.printMemory;
281 p.MaxMemory = vc.maxMemory;
282 p.DropTFUponFailure = vc.dropTFUponFailure;
283 p.NSigmaCut = vc.nSigmaCut;
284 p.maxZPositionAllowed = vc.maxZPositionAllowed;
285 p.clusterContributorsCut = vc.clusterContributorsCut;
286 p.suppressLowMultDebris = vc.suppressLowMultDebris;
287 p.seedMemberRadiusTime = vc.seedMemberRadiusTime;
288 p.seedMemberRadiusZ = vc.seedMemberRadiusZ;
289 p.phiSpan = vc.phiSpan;
290 p.nThreads = vc.nThreads;
291 p.ZBins = vc.ZBins;
292 p.PhiBins = vc.PhiBins;
293 p.useTruthSeeding = vc.useTruthSeeding;
294 p.maxTrackletsPerCluster = vc.maxTrackletsPerCluster;
295 p.zCut = vc.zCut;
296 p.phiCut = vc.phiCut;
297 p.pairCut = vc.pairCut;
298 p.clusterCut = vc.clusterCut;
299 p.coarseZWindow = vc.coarseZWindow;
300 p.seedDedupZCut = vc.seedDedupZCut;
301 p.refitDedupZCut = vc.refitDedupZCut;
302 p.duplicateZCut = vc.duplicateZCut;
303 p.finalSelectionZCut = vc.finalSelectionZCut;
304 p.duplicateDistance2Cut = vc.duplicateDistance2Cut;
305 p.tanLambdaCut = vc.tanLambdaCut;
306 }
307
308 if (mode == TrackingMode::Async) {
309 // relax for UPC iteration
310 vertParams[1].phiCut = 0.015f;
311 vertParams[1].tanLambdaCut = 0.015f;
312 vertParams[1].maxTrackletsPerCluster = 2000;
314 vertParams.resize(1);
315 } else {
316 LOGP(fatal, "Unsupported ITS vertexing mode {} ", toString(mode));
317 }
318
319 if (vertParams.size() > vc.nIterations) {
320 vertParams.resize(vc.nIterations);
321 }
322
323 return vertParams;
324}
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
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