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 deepVectorClear(mUnsortedClusters[layer], getMaybeFrameworkHostResource());
157 deepVectorClear(mTrackingFrameInfo[layer], getMaybeFrameworkHostResource());
158 deepVectorClear(mClusterExternalIndices[layer], mMemoryPool.get());
159 clearResizeBoundedVector(mROFramesClusters[layer], mROFOverlapTableView.getLayer(layer).mNROFsTF + 1, getMaybeFrameworkHostResource());
160 } else {
161 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
162 deepVectorClear(mUnsortedClusters[iLayer], getMaybeFrameworkHostResource());
163 deepVectorClear(mTrackingFrameInfo[iLayer], getMaybeFrameworkHostResource());
164 deepVectorClear(mClusterExternalIndices[iLayer], mMemoryPool.get());
165 clearResizeBoundedVector(mROFramesClusters[iLayer], mROFOverlapTableView.getLayer(iLayer).mNROFsTF + 1, getMaybeFrameworkHostResource());
166 }
167 }
168}
169
170template <int NLayers>
171void TimeFrame<NLayers>::prepareROFrameData(gsl::span<const itsmft::CompClusterExt> clusters, int layer)
172{
173 if (layer >= 0) {
174 mUnsortedClusters[layer].reserve(clusters.size());
175 mTrackingFrameInfo[layer].reserve(clusters.size());
176 mClusterExternalIndices[layer].reserve(clusters.size());
177 clearResizeBoundedVector(mClusterSize[layer], clusters.size(), mMemoryPool.get());
178 } else {
179 auto* geom = GeometryTGeo::Instance();
180 clearResizeBoundedVector(mClusterSize[0], clusters.size(), mMemoryPool.get());
181 std::array<size_t, NLayers> clusterCountPerLayer{0};
182 for (const auto& cls : clusters) {
183 ++clusterCountPerLayer[geom->getLayer(cls.getChipID())];
184 }
185 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
186 mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
187 mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
188 mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
189 }
190 }
191}
193template <int NLayers>
194void TimeFrame<NLayers>::prepareClusters(const TrackingParameters& trkParam, const int maxLayers)
196 const int numBins{trkParam.PhiBins * trkParam.ZBins};
197 const int stride{numBins + 1};
198 const int stopLayer = std::min(trkParam.NLayers, maxLayers);
199
200 tbb::parallel_for(0, stopLayer, [&](const int iLayer) {
201 bounded_vector<ClusterHelper> cHelper(mMemoryPool.get());
202 bounded_vector<int> clsPerBin(numBins, 0, mMemoryPool.get());
203 bounded_vector<int> lutPerBin(numBins, 0, mMemoryPool.get());
204 float minR{mMinR[iLayer]};
205 float maxR{mMaxR[iLayer]};
206 int bogus{0};
207
208 for (int rof{0}; rof < getNrof(iLayer); ++rof) {
209 if (!mROFMaskView.isROFEnabled(iLayer, rof)) {
210 continue;
211 }
212 const auto& unsortedClusters{getUnsortedClustersOnLayer(rof, iLayer)};
213 const int clustersNum{static_cast<int>(unsortedClusters.size())};
214 auto* tableBase = mIndexTables[iLayer].data() + rof * stride;
215
216 if (static_cast<int>(cHelper.size()) < clustersNum) {
217 cHelper.resize(clustersNum);
218 }
219
220 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
221 const Cluster& c = unsortedClusters[iCluster];
222 ClusterHelper& h = cHelper[iCluster];
223
224 const float x = c.xCoordinate - mBeamPos[0];
225 const float y = c.yCoordinate - mBeamPos[1];
226 const float z = c.zCoordinate;
227
228 float phi = math_utils::computePhi(x, y);
229 int zBin{mIndexTableUtils.getZBinIndex(iLayer, z)};
230 if (zBin < 0 || zBin >= trkParam.ZBins) {
231 zBin = std::clamp(zBin, 0, trkParam.ZBins - 1);
232 ++bogus;
234 int bin = mIndexTableUtils.getBinIndex(zBin, mIndexTableUtils.getPhiBinIndex(phi));
235 h.phi = phi;
236 h.r = math_utils::hypot(x, y);
237 minR = o2::gpu::GPUCommonMath::Min(h.r, minR);
238 maxR = o2::gpu::GPUCommonMath::Max(h.r, maxR);
239 h.bin = bin;
240 h.ind = clsPerBin[bin]++;
241 }
242 std::exclusive_scan(clsPerBin.begin(), clsPerBin.end(), lutPerBin.begin(), 0);
243
244 auto clusters2beSorted{getClustersOnLayer(rof, iLayer)};
245 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
246 const ClusterHelper& h = cHelper[iCluster];
247 Cluster& c = clusters2beSorted[lutPerBin[h.bin] + h.ind];
248
249 c = unsortedClusters[iCluster];
250 c.phi = h.phi;
251 c.radius = h.r;
252 c.indexTableBinIndex = h.bin;
253 }
254 std::copy_n(lutPerBin.data(), clsPerBin.size(), tableBase);
255 std::fill_n(tableBase + clsPerBin.size(), stride - clsPerBin.size(), clustersNum);
256
257 std::fill(clsPerBin.begin(), clsPerBin.end(), 0);
258 }
259
260 mMinR[iLayer] = minR;
261 mMaxR[iLayer] = maxR;
262 mBogusClusters[iLayer] += bogus;
263 });
264}
265
266template <int NLayers>
268{
269 mVertexingTopology.init(3, trkParam.MaxHoles, trkParam.HoleLayerMask);
270}
271
272template <int NLayers>
274{
275 if (maxLayers < trkParam.NLayers) {
276 LOGP(fatal, "Default tracking topology limited to {} layers, but the tracking parameters expect {}", maxLayers, trkParam.NLayers);
277 }
278 mDefaultTrackingTopology.init(trkParam.NLayers, trkParam.MaxHoles, trkParam.HoleLayerMask, trkParam.getSeedingLayerMask());
279}
280
281template <int NLayers>
282void TimeFrame<NLayers>::initTrackerTopologies(gsl::span<const TrackingParameters> trkParams, const int maxLayers)
283{
284 mTrackerTopologies.resize(trkParams.size());
285 for (size_t iteration = 0; iteration < trkParams.size(); ++iteration) {
286 if (maxLayers < trkParams[iteration].NLayers) {
287 LOGP(fatal, "Iteration {}: tracking topology limited to {} layers, but the tracking parameters expect {}", iteration, maxLayers, trkParams[iteration].NLayers);
288 }
289 const int nActiveLayers = trkParams[iteration].getActiveLayerMask().count();
290 if (trkParams[iteration].MinTrackLength > nActiveLayers) {
291 LOGP(fatal, "Iteration {}: MinTrackLength {} cannot be satisfied with {} active layers", iteration, trkParams[iteration].MinTrackLength, nActiveLayers);
292 }
293 mTrackerTopologies[iteration].init(trkParams[iteration].NLayers, trkParams[iteration].MaxHoles, trkParams[iteration].HoleLayerMask, trkParams[iteration].getSeedingLayerMask());
294 }
295}
296
297template <int NLayers>
298void TimeFrame<NLayers>::initialise(const TrackingParameters& trkParam, const int maxLayers, const int iteration)
299{
300 resetTrackExtensionCounters();
301 mTrackingTopologyView = iteration != constants::UnusedIndex ? mTrackerTopologies[iteration].getView() : (maxLayers == 3 ? mVertexingTopology.getView() : mDefaultTrackingTopology.getView());
302
303 if (trkParam.PassFlags[IterationStep::FirstPass]) {
304 deepVectorClear(mTracks);
305 deepVectorClear(mTracksLabel);
306 deepVectorClear(mLines);
307 deepVectorClear(mLinesLabels);
309 deepVectorClear(mPrimaryVertices);
310 deepVectorClear(mPrimaryVerticesLabels);
311 }
312 clearResizeBoundedVector(mLinesLabels, getNrof(1), mMemoryPool.get());
313 mIndexTableUtils.setTrackingParameters(trkParam);
314 clearResizeBoundedVector(mPositionResolution, trkParam.NLayers, mMemoryPool.get());
315 clearResizeBoundedVector(mBogusClusters, trkParam.NLayers, mMemoryPool.get());
316 deepVectorClear(mTrackletClusters);
317 for (unsigned int iLayer{0}; iLayer < std::min((int)mClusters.size(), maxLayers); ++iLayer) {
318 clearResizeBoundedVector(mClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeFrameworkHostResource(maxLayers != NLayers));
319 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeFrameworkHostResource(maxLayers != NLayers));
320 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt((0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer])) + (trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]));
321 }
322 clearResizeBoundedVector(mLines, getNrof(1), mMemoryPool.get());
323 clearResizeBoundedVector(mTrackletClusters, getNrof(1), mMemoryPool.get());
324
325 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
326 clearResizeBoundedVector(mIndexTables[iLayer], getNrof(iLayer) * ((trkParam.ZBins * trkParam.PhiBins) + 1), getMaybeFrameworkHostResource());
327 }
328 for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
329 if (trkParam.SystErrorY2[iLayer] > 0.f || trkParam.SystErrorZ2[iLayer] > 0.f) {
330 for (auto& tfInfo : mTrackingFrameInfo[iLayer]) {
332 tfInfo.covarianceTrackingFrame[0] += trkParam.SystErrorY2[iLayer];
333 tfInfo.covarianceTrackingFrame[2] += trkParam.SystErrorZ2[iLayer];
334 }
335 }
336 }
337
338 mMinR.fill(std::numeric_limits<float>::max());
339 mMaxR.fill(std::numeric_limits<float>::min());
340 }
341 clearResizeBoundedVector(mCells, mTrackingTopologyView.nCells, mMemoryPool.get());
342 clearResizeBoundedVector(mCellsLookupTable, mTrackingTopologyView.nCells, mMemoryPool.get());
343 clearResizeBoundedVector(mCellsNeighbours, mTrackingTopologyView.nCells, mMemoryPool.get());
344 clearResizeBoundedVector(mCellsNeighboursTopology, mTrackingTopologyView.nCells, mMemoryPool.get());
345 clearResizeBoundedVector(mCellsNeighboursLUT, mTrackingTopologyView.nCells, mMemoryPool.get());
346 clearResizeBoundedVector(mCellLabels, mTrackingTopologyView.nCells, mMemoryPool.get());
347 clearResizeBoundedVector(mTracklets, mTrackingTopologyView.nLinks, mMemoryPool.get());
348 clearResizeBoundedVector(mTrackletLabels, mTrackingTopologyView.nLinks, mMemoryPool.get());
349 clearResizeBoundedVector(mTrackletsLookupTable, mTrackingTopologyView.nLinks, mMemoryPool.get());
350 clearResizeBoundedVector(mLinkPhiCuts, mTrackingTopologyView.nLinks, mMemoryPool.get());
351 clearResizeBoundedVector(mLinkMSAngles, mTrackingTopologyView.nLinks, mMemoryPool.get());
352 mNTrackletsPerROF.resize(2);
353 for (auto& v : mNTrackletsPerROF) {
354 v = bounded_vector<int>(getNrof(1) + 1, 0, mMemoryPool.get());
355 }
357 prepareClusters(trkParam, maxLayers);
358 }
359 mTotalTracklets = {0, 0};
360 if (maxLayers < trkParam.NLayers) { // Vertexer only, but in both iterations
361 for (size_t iLayer{0}; iLayer < maxLayers; ++iLayer) {
362 deepVectorClear(mUsedClusters[iLayer]);
363 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), mMemoryPool.get());
364 }
365 }
366
367 // estimate MS per layer
368 std::array<float, NLayers> msAngles{};
369 for (unsigned int iLayer{0}; iLayer < NLayers; ++iLayer) {
370 msAngles[iLayer] = math_utils::MSangle(0.14f, trkParam.TrackletMinPt, trkParam.LayerxX0[iLayer]);
371 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt((0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer])) + (trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]));
372 }
373
374 // for each link calculate the phi-cuts + integrated MS
375 float oneOverR{0.001f * 0.3f * std::abs(mBz) / trkParam.TrackletMinPt};
376 for (int linkId{0}; linkId < (int)mTracklets.size(); ++linkId) {
377 const auto& link = mTrackingTopologyView.getLink(linkId);
378 float ms2 = 0.;
379 for (int layer = link.fromLayer; layer < link.toLayer; ++layer) {
380 ms2 += math_utils::Sq(msAngles[layer]);
381 }
382 mLinkMSAngles[linkId] = o2::gpu::CAMath::Sqrt(ms2);
383 const float& r1 = trkParam.LayerRadii[link.fromLayer];
384 const float& r2 = trkParam.LayerRadii[link.toLayer];
385 oneOverR = (0.5 * oneOverR >= 1.f / r2) ? (2.f / r2) - o2::constants::math::Almost0 : oneOverR;
386 const float res1 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[link.fromLayer]);
387 const float res2 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[link.toLayer]);
388 const float cosTheta1half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r1 * oneOverR));
389 const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r2 * oneOverR));
390 float x = (r2 * cosTheta1half) - (r1 * cosTheta2half);
391 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)));
393 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);
394
395 // some cleanup
396 deepVectorClear(mTracklets[linkId]);
397 deepVectorClear(mTrackletLabels[linkId]);
398 deepVectorClear(mTrackletsLookupTable[linkId]);
399 mTrackletsLookupTable[linkId].resize(mClusters[link.fromLayer].size() + 1, 0);
400 }
401
402 for (int cellId{0}; cellId < (int)mCells.size(); ++cellId) {
403 deepVectorClear(mCells[cellId]);
404 deepVectorClear(mCellsLookupTable[cellId]);
405 deepVectorClear(mCellsNeighbours[cellId]);
406 deepVectorClear(mCellsNeighboursTopology[cellId]);
407 deepVectorClear(mCellsNeighboursLUT[cellId]);
408 deepVectorClear(mCellLabels[cellId]);
409 }
410}
411
412template <int NLayers>
414{
415 unsigned long size{0};
416 for (const auto& trkl : mTracklets) {
417 size += sizeof(Tracklet) * trkl.size();
418 }
419 for (const auto& cells : mCells) {
420 size += sizeof(CellSeed) * cells.size();
421 }
422 for (const auto& cellsN : mCellsNeighbours) {
423 size += sizeof(int) * cellsN.size();
424 }
425 for (const auto& cellsN : mCellsNeighboursTopology) {
426 size += sizeof(int) * cellsN.size();
427 }
428 return size;
429}
430
431template <int NLayers>
433{
434 LOGP(info, "TimeFrame: Artefacts occupy {:.2f} MB", getArtefactsMemory() / constants::MB);
435}
436
437template <int NLayers>
439{
440 for (ushort iLayer = 0; iLayer < 2; ++iLayer) {
441 for (unsigned int iRof{0}; iRof < getNrof(1); ++iRof) {
442 if (mROFMaskView.isROFEnabled(1, iRof)) {
443 mTotalTracklets[iLayer] += mNTrackletsPerROF[iLayer][iRof];
444 }
445 }
446 std::exclusive_scan(mNTrackletsPerROF[iLayer].begin(), mNTrackletsPerROF[iLayer].end(), mNTrackletsPerROF[iLayer].begin(), 0);
447 std::exclusive_scan(mNTrackletsPerCluster[iLayer].begin(), mNTrackletsPerCluster[iLayer].end(), mNTrackletsPerClusterSum[iLayer].begin(), 0);
448 }
449}
450
451template <int NLayers>
452void TimeFrame<NLayers>::setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool)
453{
454 mMemoryPool = pool;
455
456 auto initVector = [&]<typename T>(bounded_vector<T>& vec, bool useExternal = false) {
457 std::pmr::memory_resource* mr = (useExternal) ? mExtMemoryPool.get() : mMemoryPool.get();
458 deepVectorClear(vec, mr);
459 };
460
461 auto initContainers = [&]<typename Container>(Container& container, bool useExternal = false) {
462 for (auto& v : container) {
463 initVector(v, useExternal);
464 }
465 };
466
467 // these will only reside on the host for the cpu part
468 initContainers(mClusterExternalIndices);
469 initContainers(mNTrackletsPerCluster);
470 initContainers(mNTrackletsPerClusterSum);
471 initContainers(mNClustersPerROF);
472 initVector(mPrimaryVertices);
473 initVector(mLinkPhiCuts);
474 initVector(mLinkMSAngles);
475 initVector(mPositionResolution);
476 initContainers(mClusterSize);
477 initVector(mPValphaX);
478 initVector(mBogusClusters);
479 initContainers(mTrackletsIndexROF);
480 initVector(mTracks);
481 initContainers(mTracklets);
482 initContainers(mCells);
483 initContainers(mCellsNeighbours);
484 initContainers(mCellsLookupTable);
485 // MC info (we don't know if we have MC)
486 initVector(mPrimaryVerticesLabels);
487 initContainers(mLinesLabels);
488 initContainers(mTrackletLabels);
489 initContainers(mCellLabels);
490 initVector(mTracksLabel);
491 // these will use possibly an externally provided allocator
492 initContainers(mClusters, hasFrameworkAllocator());
493 initContainers(mUsedClusters, hasFrameworkAllocator());
494 initContainers(mUnsortedClusters, hasFrameworkAllocator());
495 initContainers(mIndexTables, hasFrameworkAllocator());
496 initContainers(mTrackingFrameInfo, hasFrameworkAllocator());
497 initContainers(mROFramesClusters, hasFrameworkAllocator());
498}
499
500template <int NLayers>
502{
503 mExternalAllocator = ext;
504 mExtMemoryPool = std::make_shared<BoundedMemoryResource>(std::make_unique<ExternalAllocatorAdaptor>(mExternalAllocator));
505}
506
507template <int NLayers>
509{
510 resetTrackExtensionCounters();
511 deepVectorClear(mTracks);
512 deepVectorClear(mTracklets);
513 deepVectorClear(mCells);
514 deepVectorClear(mCellsNeighbours);
515 deepVectorClear(mCellsNeighboursTopology);
516 deepVectorClear(mCellsLookupTable);
517 deepVectorClear(mPrimaryVertices);
518 deepVectorClear(mTrackletsLookupTable);
519 deepVectorClear(mClusterExternalIndices);
520 deepVectorClear(mNTrackletsPerCluster);
521 deepVectorClear(mNTrackletsPerClusterSum);
522 deepVectorClear(mNClustersPerROF);
523 deepVectorClear(mLinkPhiCuts);
524 deepVectorClear(mLinkMSAngles);
525 deepVectorClear(mPositionResolution);
526 deepVectorClear(mClusterSize);
527 deepVectorClear(mPValphaX);
528 deepVectorClear(mBogusClusters);
529 deepVectorClear(mTrackletsIndexROF);
530 deepVectorClear(mTrackletClusters);
531 deepVectorClear(mLines);
532 // if we use the external host allocator then the assumption is that we
533 // don't clear the memory ourself
534 if (!hasFrameworkAllocator()) {
535 deepVectorClear(mClusters);
536 deepVectorClear(mUsedClusters);
537 deepVectorClear(mUnsortedClusters);
538 deepVectorClear(mIndexTables);
539 deepVectorClear(mTrackingFrameInfo);
540 deepVectorClear(mROFramesClusters);
541 }
542 // only needed to clear if we have MC info
543 if (hasMCinformation()) {
544 deepVectorClear(mLinesLabels);
545 deepVectorClear(mPrimaryVerticesLabels);
546 deepVectorClear(mTrackletLabels);
547 deepVectorClear(mCellLabels);
548 deepVectorClear(mTracksLabel);
549 }
550}
551
552template class TimeFrame<7>;
553// ALICE3 upgrade
554#ifdef ENABLE_UPGRADES
555template class TimeFrame<11>;
556template class TimeFrame<13>;
557#endif
558
559} // namespace o2::its
Definition of the ITSMFT compact cluster.
Definition of the ClusterTopology class.
int32_t i
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
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 GLenum GLboolean GLsizei stride
Definition glcorearb.h:867
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLboolean r
Definition glcorearb.h:1233
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
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
void deepVectorClear(std::vector< T > &vec)
void clearResizeBoundedVector(bounded_vector< T > &vec, size_t sz, std::pmr::memory_resource *mr=nullptr, T def=T())
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 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