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:{} NROFIt:{} PerVtx:{} DropFail:{} ClSh:{} TtklMinPt:{:.2f} MinCl:{}",
29 bool first = true;
30 for (int il = NLayers; il >= MinTrackLength; il--) {
31 int slot = NLayers - il;
32 if (slot < (int)MinPt.size() && MinPt[slot] > 0) {
33 if (first) {
34 first = false;
35 str += " MinPt: ";
36 }
37 str += std::format("L{}:{:.2f} ", il, MinPt[slot]);
38 }
39 }
40 str += " SystErrY/Z:";
41 for (size_t i = 0; i < SystErrorY2.size(); i++) {
42 str += std::format("{:.2e}/{:.2e} ", SystErrorY2[i], SystErrorZ2[i]);
43 }
44 if (std::numeric_limits<size_t>::max() != MaxMemory) {
45 str += std::format(" MemLimit {:.2f} GB", double(MaxMemory) / constants::GB);
46 }
47 return str;
48}
49
51{
52 std::string str = std::format("NZb:{} NPhB:{} DRof:{} ClsCont:{} MaxTrkltCls:{} ZCut:{} PhCut:{}", ZBins, PhiBins, deltaRof, clusterContributorsCut, maxTrackletsPerCluster, zCut, phiCut);
53 if (std::numeric_limits<size_t>::max() != MaxMemory) {
54 str += std::format(" MemLimit {:.2f} GB", double(MaxMemory) / constants::GB);
55 }
56 return str;
57}
58
59namespace
60{
61constexpr bool iequals(std::string_view a, std::string_view b)
62{
63 return std::equal(a.begin(), a.end(), b.begin(), b.end(),
64 [](char x, char y) { return std::tolower(x) == std::tolower(y); });
65}
66} // namespace
67
69{
70 constexpr std::array smodes = {
71 std::pair{"sync", Sync},
72 std::pair{"async", Async},
73 std::pair{"cosmics", Cosmics},
74 std::pair{"unset", Unset},
75 std::pair{"off", Off}};
76
77 auto it = std::find_if(smodes.begin(), smodes.end(), [&str](const auto& pair) {
78 return iequals(str, pair.first);
79 });
80 if (it == smodes.end()) {
81 LOGP(fatal, "Unrecognized tracking mode '{}'", str);
82 }
83 return it->second;
84}
85
87{
88 if (mode == TrackingMode::Sync) {
89 return "sync";
90 } else if (mode == TrackingMode::Async) {
91 return "async";
92 } else if (mode == TrackingMode::Cosmics) {
93 return "cosmics";
94 } else if (mode == TrackingMode::Unset) {
95 return "unset";
96 } else if (mode == TrackingMode::Off) {
97 return "off";
98 }
99 LOGP(fatal, "Unrecognized tracking mode '{}'", (int)mode);
100 return ""; // not reachable
101}
102
104{
105 const auto& tc = o2::its::TrackerParamConfig::Instance();
106 std::vector<TrackingParameters> trackParams;
107
108 if (mode == TrackingMode::Async) {
109 trackParams.resize(tc.doUPCIteration ? 4 : 3);
110 trackParams[1].TrackletMinPt = 0.2f;
111 trackParams[1].CellDeltaTanLambdaSigma *= 2.;
112 trackParams[2].TrackletMinPt = 0.1f;
113 trackParams[2].CellDeltaTanLambdaSigma *= 4.;
114
115 trackParams[0].MinPt[0] = 1.f / 12; // 7cl
116 trackParams[1].MinPt[0] = 1.f / 12; // 7cl
117
118 trackParams[2].MinTrackLength = 4;
119 trackParams[2].MinPt[0] = 1.f / 12; // 7cl
120 trackParams[2].MinPt[1] = 1.f / 5; // 6cl
121 trackParams[2].MinPt[2] = 1.f / 1; // 5cl
122 trackParams[2].MinPt[3] = 1.f / 6; // 4cl
123
124 trackParams[2].StartLayerMask = (1 << 6) + (1 << 3);
125 if (tc.doUPCIteration) {
126 trackParams[3].MinTrackLength = 4;
127 trackParams[3].TrackletMinPt = 0.1f;
128 trackParams[3].CellDeltaTanLambdaSigma *= 4.;
129 trackParams[3].DeltaROF = 0; // UPC specific setting
130 }
131 for (size_t ip = 0; ip < trackParams.size(); ip++) {
132 auto& param = trackParams[ip];
133 param.ZBins = 64;
134 param.PhiBins = 32;
135 param.CellsPerClusterLimit = 1.e3f;
136 param.TrackletsPerClusterLimit = 1.e3f;
137 // check if something was overridden via configurable params
138 if (ip < tc.MaxIter) {
139 if (tc.startLayerMask[ip] > 0) {
140 trackParams[2].StartLayerMask = tc.startLayerMask[ip];
141 }
142 if (tc.minTrackLgtIter[ip] > 0) {
143 param.MinTrackLength = tc.minTrackLgtIter[ip];
144 }
145 for (int ilg = tc.MaxTrackLength; ilg >= tc.MinTrackLength; ilg--) {
146 int lslot0 = (tc.MaxTrackLength - ilg), lslot = lslot0 + ip * (tc.MaxTrackLength - tc.MinTrackLength + 1);
147 if (tc.minPtIterLgt[lslot] > 0.) {
148 param.MinPt[lslot0] = tc.minPtIterLgt[lslot];
149 }
150 }
151 }
152 }
153 } else if (mode == TrackingMode::Sync) {
154 trackParams.resize(1);
155 trackParams[0].ZBins = 64;
156 trackParams[0].PhiBins = 32;
157 trackParams[0].MinTrackLength = 4;
158 } else if (mode == TrackingMode::Cosmics) {
159 trackParams.resize(1);
160 trackParams[0].MinTrackLength = 4;
161 trackParams[0].CellDeltaTanLambdaSigma *= 10;
162 trackParams[0].PhiBins = 4;
163 trackParams[0].ZBins = 16;
164 trackParams[0].PVres = 1.e5f;
165 trackParams[0].MaxChi2ClusterAttachment = 60.;
166 trackParams[0].MaxChi2NDF = 40.;
167 trackParams[0].TrackletsPerClusterLimit = 100.;
168 trackParams[0].CellsPerClusterLimit = 100.;
169 } else {
170 LOGP(fatal, "Unsupported ITS tracking mode {} ", toString(mode));
171 }
172
173 float bFactor = std::abs(o2::base::Propagator::Instance()->getNominalBz()) / 5.0066791;
174 float bFactorTracklets = bFactor < 0.01 ? 1. : bFactor; // for tracklets only
175 int nROFsPerIterations = tc.nROFsPerIterations > 0 ? tc.nROFsPerIterations : -1;
176
177 if (tc.nOrbitsPerIterations > 0) {
179 }
180
181 // global parameters set for every iteration
182 for (auto& p : trackParams) {
183 // adjust pT settings to actual mag. field
184 p.TrackletMinPt *= bFactorTracklets;
185 for (int ilg = tc.MaxTrackLength; ilg >= tc.MinTrackLength; ilg--) {
186 int lslot = tc.MaxTrackLength - ilg;
187 p.MinPt[lslot] *= bFactor;
188 }
189
190 p.PrintMemory = tc.printMemory;
191 p.MaxMemory = tc.maxMemory;
192 p.DropTFUponFailure = tc.dropTFUponFailure;
193 p.SaveTimeBenchmarks = tc.saveTimeBenchmarks;
194 p.FataliseUponFailure = tc.fataliseUponFailure;
195
196 if (tc.useMatCorrTGeo) {
198 } else if (tc.useFastMaterial) {
200 } else {
202 }
203
204 if (p.NLayers == 7) {
205 for (int i{0}; i < 7; ++i) {
206 p.SystErrorY2[i] = tc.sysErrY2[i] > 0 ? tc.sysErrY2[i] : p.SystErrorY2[i];
207 p.SystErrorZ2[i] = tc.sysErrZ2[i] > 0 ? tc.sysErrZ2[i] : p.SystErrorZ2[i];
208 }
209 }
210 p.DeltaROF = tc.deltaRof;
211 p.DoUPCIteration = tc.doUPCIteration;
212 p.MaxChi2ClusterAttachment = tc.maxChi2ClusterAttachment > 0 ? tc.maxChi2ClusterAttachment : p.MaxChi2ClusterAttachment;
213 p.MaxChi2NDF = tc.maxChi2NDF > 0 ? tc.maxChi2NDF : p.MaxChi2NDF;
214 p.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : p.PhiBins;
215 p.ZBins = tc.LUTbinsZ > 0 ? tc.LUTbinsZ : p.ZBins;
216 p.PVres = tc.pvRes > 0 ? tc.pvRes : p.PVres;
217 p.NSigmaCut *= tc.nSigmaCut > 0 ? tc.nSigmaCut : 1.f;
218 p.CellDeltaTanLambdaSigma *= tc.deltaTanLres > 0 ? tc.deltaTanLres : 1.f;
219 p.TrackletMinPt *= tc.minPt > 0 ? tc.minPt : 1.f;
220 p.nROFsPerIterations = nROFsPerIterations;
221 p.PerPrimaryVertexProcessing = tc.perPrimaryVertexProcessing;
222 for (int iD{0}; iD < 3; ++iD) {
223 p.Diamond[iD] = tc.diamondPos[iD];
224 }
225 p.UseDiamond = tc.useDiamond;
226 if (tc.useTrackFollower > 0) {
227 p.UseTrackFollower = true;
228 // Bit 0: Allow for mixing of top&bot extension --> implies Bits 1&2 set
229 // Bit 1: Allow for top extension
230 // Bit 2: Allow for bot extension
231 p.UseTrackFollowerMix = ((tc.useTrackFollower & (1 << 0)) != 0);
232 p.UseTrackFollowerTop = ((tc.useTrackFollower & (1 << 1)) != 0);
233 p.UseTrackFollowerBot = ((tc.useTrackFollower & (1 << 2)) != 0);
234 p.TrackFollowerNSigmaCutZ = tc.trackFollowerNSigmaZ;
235 p.TrackFollowerNSigmaCutPhi = tc.trackFollowerNSigmaPhi;
236 }
237 if (tc.cellsPerClusterLimit >= 0) {
238 p.CellsPerClusterLimit = tc.cellsPerClusterLimit;
239 }
240 if (tc.trackletsPerClusterLimit >= 0) {
241 p.TrackletsPerClusterLimit = tc.trackletsPerClusterLimit;
242 }
243 if (tc.findShortTracks >= 0) {
244 p.FindShortTracks = tc.findShortTracks;
245 }
246 }
247
248 if (trackParams.size() > tc.nIterations) {
249 trackParams.resize(tc.nIterations);
250 }
251
252 return trackParams;
253}
254
256{
258 std::vector<VertexingParameters> vertParams;
259 if (mode == TrackingMode::Async) {
260 vertParams.resize(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice
261 vertParams[1].phiCut = 0.015f;
262 vertParams[1].tanLambdaCut = 0.015f;
263 vertParams[1].vertPerRofThreshold = 0;
264 vertParams[1].deltaRof = 0;
265 } else if (mode == TrackingMode::Sync) {
266 vertParams.resize(1);
267 } else if (mode == TrackingMode::Cosmics) {
268 vertParams.resize(1);
269 } else {
270 LOGP(fatal, "Unsupported ITS vertexing mode {} ", toString(mode));
271 }
272
273 // global parameters set for every iteration
274 for (auto& p : vertParams) {
275 p.SaveTimeBenchmarks = vc.saveTimeBenchmarks;
276 p.PrintMemory = vc.printMemory;
277 p.MaxMemory = vc.maxMemory;
278 p.DropTFUponFailure = vc.dropTFUponFailure;
279 p.nIterations = vc.nIterations;
280 p.deltaRof = vc.deltaRof;
281 p.allowSingleContribClusters = vc.allowSingleContribClusters;
282 p.trackletSigma = vc.trackletSigma;
283 p.maxZPositionAllowed = vc.maxZPositionAllowed;
284 p.clusterContributorsCut = vc.clusterContributorsCut;
285 p.phiSpan = vc.phiSpan;
286 p.nThreads = vc.nThreads;
287 p.ZBins = vc.ZBins;
288 p.PhiBins = vc.PhiBins;
289
290 p.useTruthSeeding = vc.useTruthSeeding;
291 p.outputContLabels = vc.outputContLabels;
292 }
293 // set for now outside to not disturb status quo
294 vertParams[0].vertNsigmaCut = vc.vertNsigmaCut;
295 vertParams[0].vertRadiusSigma = vc.vertRadiusSigma;
296 vertParams[0].maxTrackletsPerCluster = vc.maxTrackletsPerCluster;
297 vertParams[0].lowMultBeamDistCut = vc.lowMultBeamDistCut;
298 vertParams[0].zCut = vc.zCut;
299 vertParams[0].phiCut = vc.phiCut;
300 vertParams[0].pairCut = vc.pairCut;
301 vertParams[0].clusterCut = vc.clusterCut;
302 vertParams[0].histPairCut = vc.histPairCut;
303 vertParams[0].tanLambdaCut = vc.tanLambdaCut;
304
305 return vertParams;
306}
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:143
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum mode
Definition glcorearb.h:266
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:24
std::string asString() const
std::vector< float > SystErrorY2
std::vector< float > SystErrorZ2
float TrackletMinPt
Trackleting cuts.
int ClusterSharing
General parameters.
std::vector< float > MinPt
std::string asString() const
const std::string str