Project
Loading...
Searching...
No Matches
TimeFrame.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.
15
16#include <limits>
17#include <numeric>
18
19#include "Framework/Logger.h"
20#include <tbb/parallel_for.h>
21
30
31namespace
32{
33struct ClusterHelper {
34 float phi;
35 float r;
36 int bin;
37 int ind;
38};
39} // namespace
40
41namespace o2::its
42{
43
46
51
52template <int NLayers>
54
55template <int NLayers>
57
58template <int NLayers>
60{
61 mPrimaryVertices.emplace_back(vert);
62 if (!isBeamPositionOverridden) {
63 const float w = vert.getNContributors();
64 mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vert.getX() * w) / (mBeamPosWeight + w);
65 mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vert.getY() * w) / (mBeamPosWeight + w);
66 mBeamPosWeight += w;
67 }
68}
69
70template <int NLayers>
71void TimeFrame<NLayers>::loadROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
72 gsl::span<const itsmft::CompClusterExt> clusters,
73 gsl::span<const unsigned char>::iterator& pattIt,
75 int layer,
77{
79 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
80 resetROFrameData(layer);
81 prepareROFrameData(clusters, layer);
82
83 // check for missing/empty/unset rofs
84 // the code requires consistent monotonically increasing input without gaps
85 const auto& timing = mROFOverlapTableView.getLayer(layer >= 0 ? layer : 0);
86 if (timing.mNROFsTF != rofs.size()) {
87 LOGP(fatal, "Received inconsistent number of rofs on layer:{} expected:{} received:{}", layer, timing.mNROFsTF, rofs.size());
88 }
89
90 for (int32_t iRof{0}; iRof < rofs.size(); ++iRof) {
91 const auto& rof = rofs[iRof];
92 for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
93 const auto& c = clusters[clusterId];
94 int lay = geom->getLayer(c.getSensorID());
95 auto pattID = c.getPatternID();
97 float sigmaY2 = DefClusError2Row, sigmaZ2 = DefClusError2Col, sigmaYZ = 0; // Dummy COG errors (about half pixel size)
98 unsigned int clusterSize{0};
100 sigmaY2 = dict->getErr2X(pattID);
101 sigmaZ2 = dict->getErr2Z(pattID);
102 if (!dict->isGroup(pattID)) {
103 locXYZ = dict->getClusterCoordinates(c);
104 clusterSize = dict->getNpixels(pattID);
105 } else {
106 o2::itsmft::ClusterPattern patt(pattIt);
107 locXYZ = dict->getClusterCoordinates(c, patt);
108 clusterSize = patt.getNPixels();
109 }
110 } else {
111 o2::itsmft::ClusterPattern patt(pattIt);
112 locXYZ = dict->getClusterCoordinates(c, patt, false);
113 clusterSize = patt.getNPixels();
114 }
115 mClusterSize[layer >= 0 ? layer : 0][clusterId] = std::clamp(clusterSize, 0u, 255u);
116 auto sensorID = c.getSensorID();
117 // Inverse transformation to the local --> tracking
118 auto trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
119 // Transformation to the local --> global
120 auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
121 addTrackingFrameInfoToLayer(lay, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), geom->getSensorRefAlpha(sensorID),
122 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
123 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
125 addClusterToLayer(lay, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), mUnsortedClusters[lay].size());
126 addClusterExternalIndexToLayer(lay, clusterId);
127 }
128 // effectively calculating an exclusive sum
129 if (layer >= 0) {
130 mROFramesClusters[layer][iRof + 1] = mUnsortedClusters[layer].size();
131 } else {
132 for (unsigned int iL{0}; iL < mUnsortedClusters.size(); ++iL) {
133 mROFramesClusters[iL][iRof + 1] = mUnsortedClusters[iL].size();
134 }
135 }
136 }
137
138 if (layer == 1 || layer == -1) {
139 for (auto i = 0; i < mNTrackletsPerCluster.size(); ++i) {
140 mNTrackletsPerCluster[i].resize(mUnsortedClusters[1].size());
141 mNTrackletsPerClusterSum[i].resize(mUnsortedClusters[1].size() + 1);
142 }
143 }
144
145 if (mcLabels != nullptr) {
146 mClusterLabels[layer >= 0 ? layer : 0] = mcLabels;
147 } else {
148 mClusterLabels[layer >= 0 ? layer : 0] = nullptr;
149 }
150}
151
152template <int NLayers>
154{
155 if (layer >= 0) {
156 LayerMask cleared{};
157 cleared.set(layer);
158 mSystErrorsApplied &= ~cleared; // this layer's covariances are about to be refilled
159 deepVectorClear(mUnsortedClusters[layer], getMaybeFrameworkHostResource());
160 deepVectorClear(mTrackingFrameInfo[layer], getMaybeFrameworkHostResource());
161 deepVectorClear(mClusterExternalIndices[layer], mMemoryPool.get());
162 clearResizeBoundedVector(mROFramesClusters[layer], mROFOverlapTableView.getLayer(layer).mNROFsTF + 1, getMaybeFrameworkHostResource());
163 } else {
164 mSystErrorsApplied = LayerMask{};
165 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
166 deepVectorClear(mUnsortedClusters[iLayer], getMaybeFrameworkHostResource());
167 deepVectorClear(mTrackingFrameInfo[iLayer], getMaybeFrameworkHostResource());
168 deepVectorClear(mClusterExternalIndices[iLayer], mMemoryPool.get());
169 clearResizeBoundedVector(mROFramesClusters[iLayer], mROFOverlapTableView.getLayer(iLayer).mNROFsTF + 1, getMaybeFrameworkHostResource());
170 }
171 }
172}
173
174template <int NLayers>
175void TimeFrame<NLayers>::prepareROFrameData(gsl::span<const itsmft::CompClusterExt> clusters, int layer)
176{
177 if (layer >= 0) {
178 mUnsortedClusters[layer].reserve(clusters.size());
179 mTrackingFrameInfo[layer].reserve(clusters.size());
180 mClusterExternalIndices[layer].reserve(clusters.size());
181 clearResizeBoundedVector(mClusterSize[layer], clusters.size(), mMemoryPool.get());
182 } else {
183 auto* geom = GeometryTGeo::Instance();
184 clearResizeBoundedVector(mClusterSize[0], clusters.size(), mMemoryPool.get());
185 std::array<size_t, NLayers> clusterCountPerLayer{0};
186 for (const auto& cls : clusters) {
187 ++clusterCountPerLayer[geom->getLayer(cls.getChipID())];
188 }
189 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
190 mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
191 mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
192 mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
193 }
194 }
195}
196
197template <int NLayers>
199{
200 for (unsigned int iLayer{0}; iLayer < std::min((int)mClusters.size(), maxLayers); ++iLayer) {
201 clearResizeBoundedVector(mClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeFrameworkHostResource(maxLayers != NLayers));
203 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
204 clearResizeBoundedVector(mIndexTables[iLayer], getNrof(iLayer) * ((trkParam.ZBins * trkParam.PhiBins) + 1), getMaybeFrameworkHostResource());
205 }
206}
207
208template <int NLayers>
209void TimeFrame<NLayers>::prepareClusters(const TrackingParameters& trkParam, const int maxLayers)
210{
211 const int numBins{trkParam.PhiBins * trkParam.ZBins};
212 const int stride{numBins + 1};
213 const int stopLayer = std::min(trkParam.NLayers, maxLayers);
214
215 tbb::parallel_for(0, stopLayer, [&](const int iLayer) {
216 bounded_vector<ClusterHelper> cHelper(mMemoryPool.get());
217 bounded_vector<int> clsPerBin(numBins, 0, mMemoryPool.get());
218 bounded_vector<int> lutPerBin(numBins, 0, mMemoryPool.get());
219 float minR{mMinR[iLayer]};
220 float maxR{mMaxR[iLayer]};
221 int bogus{0};
222
223 for (int rof{0}; rof < getNrof(iLayer); ++rof) {
224 if (!mROFMaskView.isROFEnabled(iLayer, rof)) {
225 continue;
226 }
227 const auto& unsortedClusters{getUnsortedClustersOnLayer(rof, iLayer)};
228 const int clustersNum{static_cast<int>(unsortedClusters.size())};
229 auto* tableBase = mIndexTables[iLayer].data() + rof * stride;
230
231 if (static_cast<int>(cHelper.size()) < clustersNum) {
232 cHelper.resize(clustersNum);
233 }
234
235 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
236 const Cluster& c = unsortedClusters[iCluster];
237 ClusterHelper& h = cHelper[iCluster];
238
239 const float x = c.xCoordinate - mBeamPos[0];
240 const float y = c.yCoordinate - mBeamPos[1];
241 const float z = c.zCoordinate;
242
243 float phi = math_utils::computePhi(x, y);
244 int zBin{mIndexTableUtils.getZBinIndex(iLayer, z)};
245 if (zBin < 0 || zBin >= trkParam.ZBins) {
246 zBin = std::clamp(zBin, 0, trkParam.ZBins - 1);
247 ++bogus;
248 }
249 int bin = mIndexTableUtils.getBinIndex(zBin, mIndexTableUtils.getPhiBinIndex(phi));
250 h.phi = phi;
251 h.r = math_utils::hypot(x, y);
252 minR = o2::gpu::GPUCommonMath::Min(h.r, minR);
253 maxR = o2::gpu::GPUCommonMath::Max(h.r, maxR);
254 h.bin = bin;
255 h.ind = clsPerBin[bin]++;
256 }
257 std::exclusive_scan(clsPerBin.begin(), clsPerBin.end(), lutPerBin.begin(), 0);
258
259 auto clusters2beSorted{getClustersOnLayer(rof, iLayer)};
260 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
261 const ClusterHelper& h = cHelper[iCluster];
262 Cluster& c = clusters2beSorted[lutPerBin[h.bin] + h.ind];
263
264 c = unsortedClusters[iCluster];
265 c.phi = h.phi;
266 c.radius = h.r;
267 c.indexTableBinIndex = h.bin;
268 }
269 std::copy_n(lutPerBin.data(), clsPerBin.size(), tableBase);
270 std::fill_n(tableBase + clsPerBin.size(), stride - clsPerBin.size(), clustersNum);
271
272 std::fill(clsPerBin.begin(), clsPerBin.end(), 0);
273 }
274
275 mMinR[iLayer] = minR;
276 mMaxR[iLayer] = maxR;
277 mBogusClusters[iLayer] += bogus;
278 });
279}
280
281template <int NLayers>
283{
284 mVertexingTopology.init(3, trkParam.MaxHoles, trkParam.HoleLayerMask);
285}
286
287template <int NLayers>
289{
290 if (maxLayers < trkParam.NLayers) {
291 LOGP(fatal, "Default tracking topology limited to {} layers, but the tracking parameters expect {}", maxLayers, trkParam.NLayers);
292 }
293 mDefaultTrackingTopology.init(trkParam.NLayers, trkParam.MaxHoles, trkParam.HoleLayerMask, trkParam.getSeedingLayerMask());
294}
295
296template <int NLayers>
297void TimeFrame<NLayers>::initTrackerTopologies(gsl::span<const TrackingParameters> trkParams, const int maxLayers)
298{
299 mTrackerTopologies.resize(trkParams.size());
300 for (size_t iteration = 0; iteration < trkParams.size(); ++iteration) {
301 if (maxLayers < trkParams[iteration].NLayers) {
302 LOGP(fatal, "Iteration {}: tracking topology limited to {} layers, but the tracking parameters expect {}", iteration, maxLayers, trkParams[iteration].NLayers);
303 }
304 const int nActiveLayers = trkParams[iteration].getActiveLayerMask().count();
305 if (trkParams[iteration].MinTrackLength > nActiveLayers) {
306 LOGP(fatal, "Iteration {}: MinTrackLength {} cannot be satisfied with {} active layers", iteration, trkParams[iteration].MinTrackLength, nActiveLayers);
307 }
308 mTrackerTopologies[iteration].init(trkParams[iteration].NLayers, trkParams[iteration].MaxHoles, trkParams[iteration].HoleLayerMask, trkParams[iteration].getSeedingLayerMask());
309 }
310}
311
312template <int NLayers>
313void TimeFrame<NLayers>::initialise(const TrackingParameters& trkParam, const int maxLayers, const int iteration)
314{
315 resetTrackExtensionCounters();
316 mTrackingTopologyView = iteration != constants::UnusedIndex ? mTrackerTopologies[iteration].getView() : (maxLayers == 3 ? mVertexingTopology.getView() : mDefaultTrackingTopology.getView());
318 if (trkParam.PassFlags[IterationStep::FirstPass]) {
319 deepVectorClear(mTracks);
320 deepVectorClear(mTracksLabel);
321 deepVectorClear(mLines);
322 deepVectorClear(mLinesQuality);
323 deepVectorClear(mLinesLabels);
325 deepVectorClear(mPrimaryVertices);
326 deepVectorClear(mPrimaryVerticesLabels);
327 }
328 clearResizeBoundedVector(mLinesLabels, getNrof(1), mMemoryPool.get());
329 mIndexTableUtils.setTrackingParameters(trkParam);
330 clearResizeBoundedVector(mPositionResolution, NLayers, mMemoryPool.get());
331 clearResizeBoundedVector(mBogusClusters, NLayers, mMemoryPool.get());
332 deepVectorClear(mTrackletClusters);
333 for (unsigned int iLayer{0}; iLayer < std::min((int)mClusters.size(), maxLayers); ++iLayer) {
334 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeFrameworkHostResource(maxLayers != NLayers));
335 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt((0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer])) + (trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]));
336 }
337 clearResizeBoundedVector(mLines, getNrof(1), mMemoryPool.get());
338 clearResizeBoundedVector(mLinesQuality, getNrof(1), mMemoryPool.get());
339 clearResizeBoundedVector(mTrackletClusters, getNrof(1), mMemoryPool.get());
340 allocateClusterSortStorage(trkParam, maxLayers);
341 for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
342 if (mSystErrorsApplied.has(iLayer)) {
343 continue;
344 }
345 if (trkParam.SystErrorY2[iLayer] > 0.f || trkParam.SystErrorZ2[iLayer] > 0.f) {
346 mSystErrorsApplied.set(iLayer);
347 for (auto& tfInfo : mTrackingFrameInfo[iLayer]) {
348 tfInfo.covarianceTrackingFrame[0] += trkParam.SystErrorY2[iLayer];
349 tfInfo.covarianceTrackingFrame[2] += trkParam.SystErrorZ2[iLayer];
350 }
351 }
352 }
353
354 mMinR.fill(std::numeric_limits<float>::max());
355 mMaxR.fill(std::numeric_limits<float>::min());
356 }
357 clearResizeBoundedVector(mCells, mTrackingTopologyView.nCells, mMemoryPool.get());
358 clearResizeBoundedVector(mCellsLookupTable, mTrackingTopologyView.nCells, mMemoryPool.get());
359 clearResizeBoundedVector(mCellsNeighbours, mTrackingTopologyView.nCells, mMemoryPool.get());
360 clearResizeBoundedVector(mCellsNeighboursTopology, mTrackingTopologyView.nCells, mMemoryPool.get());
361 clearResizeBoundedVector(mCellsNeighboursLUT, mTrackingTopologyView.nCells, mMemoryPool.get());
362 clearResizeBoundedVector(mCellLabels, mTrackingTopologyView.nCells, mMemoryPool.get());
363 clearResizeBoundedVector(mTracklets, mTrackingTopologyView.nLinks, mMemoryPool.get());
364 clearResizeBoundedVector(mTrackletLabels, mTrackingTopologyView.nLinks, mMemoryPool.get());
365 clearResizeBoundedVector(mTrackletsLookupTable, mTrackingTopologyView.nLinks, mMemoryPool.get());
366 clearResizeBoundedVector(mLinkPhiCuts, mTrackingTopologyView.nLinks, mMemoryPool.get());
367 clearResizeBoundedVector(mLinkMSAngles, mTrackingTopologyView.nLinks, mMemoryPool.get());
368 mNTrackletsPerROF.resize(2);
369 for (auto& v : mNTrackletsPerROF) {
370 v = bounded_vector<int>(getNrof(1) + 1, 0, mMemoryPool.get());
371 }
372 for (int i = 0; i < 2; ++i) {
373 mNTrackletsPerCluster[i].assign(mUnsortedClusters[1].size(), 0);
374 mNTrackletsPerClusterSum[i].assign(mUnsortedClusters[1].size() + 1, 0);
375 }
377 prepareClusters(trkParam, maxLayers);
378 }
379 mTotalTracklets = {0, 0};
380 if (maxLayers < trkParam.NLayers) { // Vertexer only, but in both iterations
381 for (size_t iLayer{0}; iLayer < maxLayers; ++iLayer) {
382 deepVectorClear(mUsedClusters[iLayer]);
383 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), mMemoryPool.get());
384 }
385 }
386
387 // estimate MS per layer
388 std::array<float, NLayers> msAngles{};
389 for (unsigned int iLayer{0}; iLayer < NLayers; ++iLayer) {
390 msAngles[iLayer] = math_utils::MSangle(0.14f, trkParam.TrackletMinPt, trkParam.LayerxX0[iLayer]);
391 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt((0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer])) + (trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]));
392 }
393
394 // for each link calculate the phi-cuts + integrated MS
395 float oneOverR{0.001f * 0.3f * std::abs(mBz) / trkParam.TrackletMinPt};
396 for (int linkId{0}; linkId < (int)mTracklets.size(); ++linkId) {
397 const auto& link = mTrackingTopologyView.getLink(linkId);
398 float ms2 = 0.;
399 for (int layer = link.fromLayer; layer < link.toLayer; ++layer) {
400 ms2 += math_utils::Sq(msAngles[layer]);
401 }
402 mLinkMSAngles[linkId] = o2::gpu::CAMath::Sqrt(ms2);
403 const float& r1 = trkParam.LayerRadii[link.fromLayer];
404 const float& r2 = trkParam.LayerRadii[link.toLayer];
405 oneOverR = (0.5 * oneOverR >= 1.f / r2) ? (2.f / r2) - o2::constants::math::Almost0 : oneOverR;
406 const float res1 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[link.fromLayer]);
407 const float res2 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[link.toLayer]);
408 const float cosTheta1half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r1 * oneOverR));
409 const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r2 * oneOverR));
410 float x = (r2 * cosTheta1half) - (r1 * cosTheta2half);
411 float delta = o2::gpu::CAMath::Sqrt(1.f / (1.f - 0.25f * math_utils::Sq(x * oneOverR)) * (math_utils::Sq((0.25f * r1 * r2 * math_utils::Sq(oneOverR) / cosTheta2half) + cosTheta1half) * math_utils::Sq(res1) + math_utils::Sq((0.25f * r1 * r2 * math_utils::Sq(oneOverR) / cosTheta1half) + cosTheta2half) * math_utils::Sq(res2)));
413 mLinkPhiCuts[linkId] = o2::gpu::CAMath::Min(o2::gpu::CAMath::ASin(0.5f * x * oneOverR) + 2.f * mLinkMSAngles[linkId] + delta, o2::constants::math::PI * 0.5f);
414
415 // some cleanup
416 deepVectorClear(mTracklets[linkId]);
417 deepVectorClear(mTrackletLabels[linkId]);
418 deepVectorClear(mTrackletsLookupTable[linkId]);
419 mTrackletsLookupTable[linkId].resize(mClusters[link.fromLayer].size() + 1, 0);
420 }
421
422 for (int cellId{0}; cellId < (int)mCells.size(); ++cellId) {
423 deepVectorClear(mCells[cellId]);
424 deepVectorClear(mCellsLookupTable[cellId]);
425 deepVectorClear(mCellsNeighbours[cellId]);
426 deepVectorClear(mCellsNeighboursTopology[cellId]);
427 deepVectorClear(mCellsNeighboursLUT[cellId]);
428 deepVectorClear(mCellLabels[cellId]);
429 }
430}
431
432template <int NLayers>
434{
435 unsigned long size{0};
436 for (const auto& trkl : mTracklets) {
437 size += sizeof(Tracklet) * trkl.size();
438 }
439 for (const auto& cells : mCells) {
440 size += sizeof(CellSeed) * cells.size();
441 }
442 for (const auto& cellsN : mCellsNeighbours) {
443 size += sizeof(int) * cellsN.size();
444 }
445 for (const auto& cellsN : mCellsNeighboursTopology) {
446 size += sizeof(int) * cellsN.size();
447 }
448 return size;
449}
450
451template <int NLayers>
453{
454 LOGP(info, "TimeFrame: Artefacts occupy {:.2f} MB", getArtefactsMemory() / constants::MB);
455}
456
457template <int NLayers>
459{
460 for (ushort iLayer = 0; iLayer < 2; ++iLayer) {
461 for (unsigned int iRof{0}; iRof < getNrof(1); ++iRof) {
462 if (mROFMaskView.isROFEnabled(1, iRof)) {
463 mTotalTracklets[iLayer] += mNTrackletsPerROF[iLayer][iRof];
464 }
465 }
466 std::exclusive_scan(mNTrackletsPerROF[iLayer].begin(), mNTrackletsPerROF[iLayer].end(), mNTrackletsPerROF[iLayer].begin(), 0);
467 std::exclusive_scan(mNTrackletsPerCluster[iLayer].begin(), mNTrackletsPerCluster[iLayer].end(), mNTrackletsPerClusterSum[iLayer].begin(), 0);
468 }
469}
470
471template <int NLayers>
472void TimeFrame<NLayers>::setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool)
473{
474 mMemoryPool = pool;
475
476 auto initVector = [&]<typename T>(bounded_vector<T>& vec, bool useExternal = false) {
477 std::pmr::memory_resource* mr = (useExternal) ? mExtMemoryPool.get() : mMemoryPool.get();
478 deepVectorClear(vec, mr);
479 };
480
481 auto initContainers = [&]<typename Container>(Container& container, bool useExternal = false) {
482 for (auto& v : container) {
483 initVector(v, useExternal);
484 }
485 };
486
487 // these will only reside on the host for the cpu part
488 initContainers(mClusterExternalIndices);
489 initContainers(mNTrackletsPerCluster);
490 initContainers(mNTrackletsPerClusterSum);
491 initContainers(mNClustersPerROF);
492 initVector(mPrimaryVertices);
493 initVector(mLinkPhiCuts);
494 initVector(mLinkMSAngles);
495 initVector(mPositionResolution);
496 initContainers(mClusterSize);
497 initVector(mPValphaX);
498 initVector(mBogusClusters);
499 initContainers(mTrackletsIndexROF);
500 initVector(mTracks);
501 initContainers(mTracklets);
502 initContainers(mCells);
503 initContainers(mCellsNeighbours);
504 initContainers(mCellsLookupTable);
505 // MC info (we don't know if we have MC)
506 initVector(mPrimaryVerticesLabels);
507 initContainers(mLinesLabels);
508 initContainers(mTrackletLabels);
509 initContainers(mCellLabels);
510 initVector(mTracksLabel);
511 // these will use possibly an externally provided allocator
512 initContainers(mClusters, hasFrameworkAllocator());
513 initContainers(mUsedClusters, hasFrameworkAllocator());
514 initContainers(mUnsortedClusters, hasFrameworkAllocator());
515 initContainers(mIndexTables, hasFrameworkAllocator());
516 initContainers(mTrackingFrameInfo, hasFrameworkAllocator());
517 initContainers(mROFramesClusters, hasFrameworkAllocator());
518}
519
520template <int NLayers>
522{
523 mExternalAllocator = ext;
524 mExtMemoryPool = std::make_shared<BoundedMemoryResource>(std::make_unique<ExternalAllocatorAdaptor>(mExternalAllocator));
525}
526
527template <int NLayers>
529{
530 resetTrackExtensionCounters();
531 deepVectorClear(mTracks);
532 deepVectorClear(mTracklets);
533 deepVectorClear(mCells);
534 deepVectorClear(mCellsNeighbours);
535 deepVectorClear(mCellsNeighboursTopology);
536 deepVectorClear(mCellsLookupTable);
537 deepVectorClear(mPrimaryVertices);
538 deepVectorClear(mTrackletsLookupTable);
539 deepVectorClear(mClusterExternalIndices);
540 deepVectorClear(mNTrackletsPerCluster);
541 deepVectorClear(mNTrackletsPerClusterSum);
542 deepVectorClear(mNClustersPerROF);
543 deepVectorClear(mLinkPhiCuts);
544 deepVectorClear(mLinkMSAngles);
545 deepVectorClear(mPositionResolution);
546 deepVectorClear(mClusterSize);
547 deepVectorClear(mPValphaX);
548 deepVectorClear(mBogusClusters);
549 deepVectorClear(mTrackletsIndexROF);
550 deepVectorClear(mTrackletClusters);
551 deepVectorClear(mLines);
552 deepVectorClear(mLinesQuality);
553 // if we use the external host allocator then the assumption is that we
554 // don't clear the memory ourself
555 if (!hasFrameworkAllocator()) {
556 deepVectorClear(mClusters);
557 deepVectorClear(mUsedClusters);
558 deepVectorClear(mUnsortedClusters);
559 deepVectorClear(mIndexTables);
560 deepVectorClear(mTrackingFrameInfo);
561 mSystErrorsApplied = LayerMask{};
562 deepVectorClear(mROFramesClusters);
563 }
564 // only needed to clear if we have MC info
565 if (hasMCinformation()) {
566 deepVectorClear(mLinesLabels);
567 deepVectorClear(mPrimaryVerticesLabels);
568 deepVectorClear(mTrackletLabels);
569 deepVectorClear(mCellLabels);
570 deepVectorClear(mTracksLabel);
571 }
572}
573
574template class TimeFrame<7>;
575// ALICE3 upgrade
576#ifdef ENABLE_UPGRADES
577template class TimeFrame<11>;
578template class TimeFrame<13>;
579#endif
580
581} // namespace o2::its
Definition of the ITSMFT compact cluster.
Definition of the ClusterTopology class.
int32_t i
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
Shared budgeted host allocation and bounded-vector utilities.
Definition of the GeometryTGeo class.
Definition of the ITSMFT ROFrame (trigger) record.
uint32_t c
Definition RawData.h:2
Definition of the SegmentationAlpide class.
int clusterSize
Class for time synchronization of RawReader instances.
A container to hold and manage MC truth information/labels.
const Mat3D & getMatrixL2G(int sensID) const
HMPID cluster implementation.
Definition Cluster.h:27
CellSeed: connections of three clusters.
Definition Cell.h:81
const Mat3D & getMatrixT2L(int lay, int hba, int sta, int det) const
float getSensorRefAlpha(int isn) const
static GeometryTGeo * Instance()
int getLayer(int index) const final
Get chip layer, from 0.
void fillMatrixCache(int mask) override
int getNPixels() const
Returns the number of fired pixels.
static constexpr unsigned short InvalidPatternID
Definition CompCluster.h:46
static constexpr float PitchCol
static constexpr float PitchRow
math_utils::Point3D< T > getClusterCoordinates(const CompCluster &cl) const
float getErr2X(int n) const
Returns the error^2 on the x position of the COG for the n_th element.
int getNpixels(int n) const
Returns the number of fired pixels of the n_th element.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
float getErr2Z(int n) const
Returns the error^2 on the z position of the COG for the n_th element.
GLint GLenum GLint x
Definition glcorearb.h:403
GLsizeiptr size
Definition glcorearb.h:659
const GLdouble * v
Definition glcorearb.h:832
GLint y
Definition glcorearb.h:270
GLint GLenum GLboolean GLsizei stride
Definition glcorearb.h:867
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
uint8_t int statusCode int
void clearResizeBoundedVector(bounded_vector< T > &vec, size_t sz, std::pmr::memory_resource *mr=nullptr, T def=T())
void deepVectorClear(std::vector< T > &vec)
constexpr int UnusedIndex
Definition Constants.h:32
constexpr float MB
Definition Constants.h:26
const int end
constexpr float DefClusError2Col
Definition TimeFrame.cxx:50
constexpr float DefClusError2Row
Definition TimeFrame.cxx:49
constexpr float DefClusErrorRow
Definition TimeFrame.cxx:47
constexpr float DefClusErrorCol
Definition TimeFrame.cxx:48
virtual void prepareClusters(const TrackingParameters &trkParam, const int maxLayers=NLayers)
void initDefaultTrackingTopology(const TrackingParameters &trkParam, const int maxLayers=NLayers)
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > pool)
memory management
void initVertexingTopology(const TrackingParameters &trkParam)
void printArtefactsMemory() const
void setFrameworkAllocator(ExternalAllocator *ext)
void initialise(const TrackingParameters &trkParam, const int maxLayers=NLayers, const int iteration=constants::UnusedIndex)
void prepareROFrameData(gsl::span< const itsmft::CompClusterExt > clusters, int layer)
void computeTrackletsPerROFScans()
void addPrimaryVertex(const Vertex &vertex)
Definition TimeFrame.cxx:59
void loadROFrameData(gsl::span< const o2::itsmft::ROFRecord > rofs, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, const itsmft::TopologyDictionary *dict, int layer, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
Definition TimeFrame.cxx:71
void resetROFrameData(int iLayer)
void initTrackerTopologies(gsl::span< const TrackingParameters > trkParams, const int maxLayers=NLayers)
virtual void allocateClusterSortStorage(const TrackingParameters &trkParam, const int maxLayers)
virtual void wipe()
virtual ~TimeFrame()
unsigned long getArtefactsMemory() const
std::vector< float > LayerRadii
std::vector< float > SystErrorY2
std::vector< float > SystErrorZ2
float TrackletMinPt
Trackleting cuts.
LayerMask getSeedingLayerMask() const noexcept
std::vector< float > LayerResolution
std::vector< float > LayerxX0
std::vector< o2::ctf::BufferType > vec
std::vector< Cluster > clusters
std::vector< Cell > cells