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
48
49template <int NLayers>
51
52template <int NLayers>
54
55template <int NLayers>
57{
58 mPrimaryVertices.emplace_back(vert);
59 if (!isBeamPositionOverridden) {
60 const float w = vert.getNContributors();
61 mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vert.getX() * w) / (mBeamPosWeight + w);
62 mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vert.getY() * w) / (mBeamPosWeight + w);
63 mBeamPosWeight += w;
64 }
65}
66
67template <int NLayers>
68void TimeFrame<NLayers>::loadROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
69 gsl::span<const itsmft::CompClusterExt> clusters,
70 gsl::span<const unsigned char>::iterator& pattIt,
72 int layer,
74{
77 resetROFrameData(layer);
78 prepareROFrameData(clusters, layer);
79
80 // check for missing/empty/unset rofs
81 // the code requires consistent monotonically increasing input without gaps
82 const auto& timing = mROFOverlapTableView.getLayer(layer >= 0 ? layer : 0);
83 if (timing.mNROFsTF != rofs.size()) {
84 LOGP(fatal, "Received inconsistent number of rofs on layer:{} expected:{} received:{}", layer, timing.mNROFsTF, rofs.size());
85 }
86
87 for (int32_t iRof{0}; iRof < rofs.size(); ++iRof) {
88 const auto& rof = rofs[iRof];
89 for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
90 const auto& c = clusters[clusterId];
91 int lay = geom->getLayer(c.getSensorID());
92 auto pattID = c.getPatternID();
94 float sigmaY2 = DefClusError2Row, sigmaZ2 = DefClusError2Col, sigmaYZ = 0; // Dummy COG errors (about half pixel size)
95 unsigned int clusterSize{0};
97 sigmaY2 = dict->getErr2X(pattID);
98 sigmaZ2 = dict->getErr2Z(pattID);
99 if (!dict->isGroup(pattID)) {
100 locXYZ = dict->getClusterCoordinates(c);
101 clusterSize = dict->getNpixels(pattID);
102 } else {
103 o2::itsmft::ClusterPattern patt(pattIt);
104 locXYZ = dict->getClusterCoordinates(c, patt);
105 clusterSize = patt.getNPixels();
106 }
107 } else {
108 o2::itsmft::ClusterPattern patt(pattIt);
109 locXYZ = dict->getClusterCoordinates(c, patt, false);
110 clusterSize = patt.getNPixels();
111 }
112 mClusterSize[layer >= 0 ? layer : 0][clusterId] = std::clamp(clusterSize, 0u, 255u);
113 auto sensorID = c.getSensorID();
114 // Inverse transformation to the local --> tracking
115 auto trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
116 // Transformation to the local --> global
117 auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
118 addTrackingFrameInfoToLayer(lay, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), geom->getSensorRefAlpha(sensorID),
119 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
120 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
122 addClusterToLayer(lay, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), mUnsortedClusters[lay].size());
123 addClusterExternalIndexToLayer(lay, clusterId);
124 }
125 // effectively calculating an exclusive sum
126 if (layer >= 0) {
127 mROFramesClusters[layer][iRof + 1] = mUnsortedClusters[layer].size();
128 } else {
129 for (unsigned int iL{0}; iL < mUnsortedClusters.size(); ++iL) {
130 mROFramesClusters[iL][iRof + 1] = mUnsortedClusters[iL].size();
131 }
132 }
133 }
134
135 if (layer == 1 || layer == -1) {
136 for (auto i = 0; i < mNTrackletsPerCluster.size(); ++i) {
137 mNTrackletsPerCluster[i].resize(mUnsortedClusters[1].size());
138 mNTrackletsPerClusterSum[i].resize(mUnsortedClusters[1].size() + 1);
139 }
140 }
141
142 if (mcLabels != nullptr) {
143 mClusterLabels[layer >= 0 ? layer : 0] = mcLabels;
144 } else {
145 mClusterLabels[layer >= 0 ? layer : 0] = nullptr;
146 }
147}
148
149template <int NLayers>
151{
152 if (layer >= 0) {
153 deepVectorClear(mUnsortedClusters[layer], getMaybeFrameworkHostResource());
154 deepVectorClear(mTrackingFrameInfo[layer], getMaybeFrameworkHostResource());
155 deepVectorClear(mClusterExternalIndices[layer], mMemoryPool.get());
156 clearResizeBoundedVector(mROFramesClusters[layer], mROFOverlapTableView.getLayer(layer).mNROFsTF + 1, getMaybeFrameworkHostResource());
157 } else {
158 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
159 deepVectorClear(mUnsortedClusters[iLayer], getMaybeFrameworkHostResource());
160 deepVectorClear(mTrackingFrameInfo[iLayer], getMaybeFrameworkHostResource());
161 deepVectorClear(mClusterExternalIndices[iLayer], mMemoryPool.get());
162 clearResizeBoundedVector(mROFramesClusters[iLayer], mROFOverlapTableView.getLayer(iLayer).mNROFsTF + 1, getMaybeFrameworkHostResource());
163 }
164 }
165}
166
167template <int NLayers>
168void TimeFrame<NLayers>::prepareROFrameData(gsl::span<const itsmft::CompClusterExt> clusters, int layer)
169{
170 if (layer >= 0) {
171 mUnsortedClusters[layer].reserve(clusters.size());
172 mTrackingFrameInfo[layer].reserve(clusters.size());
173 mClusterExternalIndices[layer].reserve(clusters.size());
174 clearResizeBoundedVector(mClusterSize[layer], clusters.size(), mMemoryPool.get());
175 } else {
176 auto* geom = GeometryTGeo::Instance();
177 clearResizeBoundedVector(mClusterSize[0], clusters.size(), mMemoryPool.get());
178 std::array<size_t, NLayers> clusterCountPerLayer{0};
179 for (const auto& cls : clusters) {
180 ++clusterCountPerLayer[geom->getLayer(cls.getChipID())];
181 }
182 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
183 mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
184 mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
185 mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
186 }
187 }
190template <int NLayers>
191void TimeFrame<NLayers>::prepareClusters(const TrackingParameters& trkParam, const int maxLayers)
192{
193 const int numBins{trkParam.PhiBins * trkParam.ZBins};
194 const int stride{numBins + 1};
195 const int stopLayer = std::min(trkParam.NLayers, maxLayers);
196
197 tbb::parallel_for(0, stopLayer, [&](const int iLayer) {
198 bounded_vector<ClusterHelper> cHelper(mMemoryPool.get());
199 bounded_vector<int> clsPerBin(numBins, 0, mMemoryPool.get());
200 bounded_vector<int> lutPerBin(numBins, 0, mMemoryPool.get());
201 float minR{mMinR[iLayer]};
202 float maxR{mMaxR[iLayer]};
203 int bogus{0};
204
205 for (int rof{0}; rof < getNrof(iLayer); ++rof) {
206 if (!mROFMaskView.isROFEnabled(iLayer, rof)) {
207 continue;
208 }
209 const auto& unsortedClusters{getUnsortedClustersOnLayer(rof, iLayer)};
210 const int clustersNum{static_cast<int>(unsortedClusters.size())};
211 auto* tableBase = mIndexTables[iLayer].data() + rof * stride;
212
213 if (static_cast<int>(cHelper.size()) < clustersNum) {
214 cHelper.resize(clustersNum);
215 }
216
217 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
218 const Cluster& c = unsortedClusters[iCluster];
219 ClusterHelper& h = cHelper[iCluster];
220
221 const float x = c.xCoordinate - mBeamPos[0];
222 const float y = c.yCoordinate - mBeamPos[1];
223 const float z = c.zCoordinate;
224
225 float phi = math_utils::computePhi(x, y);
226 int zBin{mIndexTableUtils.getZBinIndex(iLayer, z)};
227 if (zBin < 0 || zBin >= trkParam.ZBins) {
228 zBin = std::clamp(zBin, 0, trkParam.ZBins - 1);
229 ++bogus;
230 }
231 int bin = mIndexTableUtils.getBinIndex(zBin, mIndexTableUtils.getPhiBinIndex(phi));
232 h.phi = phi;
233 h.r = math_utils::hypot(x, y);
234 minR = o2::gpu::GPUCommonMath::Min(h.r, minR);
235 maxR = o2::gpu::GPUCommonMath::Max(h.r, maxR);
236 h.bin = bin;
237 h.ind = clsPerBin[bin]++;
239 std::exclusive_scan(clsPerBin.begin(), clsPerBin.end(), lutPerBin.begin(), 0);
240
241 auto clusters2beSorted{getClustersOnLayer(rof, iLayer)};
242 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
243 const ClusterHelper& h = cHelper[iCluster];
244 Cluster& c = clusters2beSorted[lutPerBin[h.bin] + h.ind];
245
246 c = unsortedClusters[iCluster];
247 c.phi = h.phi;
248 c.radius = h.r;
249 c.indexTableBinIndex = h.bin;
250 }
251 std::copy_n(lutPerBin.data(), clsPerBin.size(), tableBase);
252 std::fill_n(tableBase + clsPerBin.size(), stride - clsPerBin.size(), clustersNum);
253
254 std::fill(clsPerBin.begin(), clsPerBin.end(), 0);
255 }
256
257 mMinR[iLayer] = minR;
258 mMaxR[iLayer] = maxR;
259 mBogusClusters[iLayer] += bogus;
260 });
261}
262
263template <int NLayers>
265{
266 mVertexingTopology.init(3, trkParam.MaxHoles, trkParam.HoleLayerMask);
267}
268
269template <int NLayers>
271{
272 if (maxLayers < trkParam.NLayers) {
273 LOGP(fatal, "Default tracking topology limited to {} layers, but the tracking parameters expect {}", maxLayers, trkParam.NLayers);
274 }
275 mDefaultTrackingTopology.init(trkParam.NLayers, trkParam.MaxHoles, trkParam.HoleLayerMask, trkParam.getSeedingLayerMask());
276}
277
278template <int NLayers>
279void TimeFrame<NLayers>::initTrackerTopologies(gsl::span<const TrackingParameters> trkParams, const int maxLayers)
280{
281 mTrackerTopologies.resize(trkParams.size());
282 for (size_t iteration = 0; iteration < trkParams.size(); ++iteration) {
283 if (maxLayers < trkParams[iteration].NLayers) {
284 LOGP(fatal, "Iteration {}: tracking topology limited to {} layers, but the tracking parameters expect {}", iteration, maxLayers, trkParams[iteration].NLayers);
285 }
286 const int nActiveLayers = trkParams[iteration].getActiveLayerMask().count();
287 if (trkParams[iteration].MinTrackLength > nActiveLayers) {
288 LOGP(fatal, "Iteration {}: MinTrackLength {} cannot be satisfied with {} active layers", iteration, trkParams[iteration].MinTrackLength, nActiveLayers);
289 }
290 mTrackerTopologies[iteration].init(trkParams[iteration].NLayers, trkParams[iteration].MaxHoles, trkParams[iteration].HoleLayerMask, trkParams[iteration].getSeedingLayerMask());
291 }
292}
293
294template <int NLayers>
295void TimeFrame<NLayers>::initialise(const TrackingParameters& trkParam, const int maxLayers, const int iteration)
296{
297 resetTrackExtensionCounters();
298 mTrackingTopologyView = iteration != constants::UnusedIndex ? mTrackerTopologies[iteration].getView() : (maxLayers == 3 ? mVertexingTopology.getView() : mDefaultTrackingTopology.getView());
299
300 if (trkParam.PassFlags[IterationStep::FirstPass]) {
301 deepVectorClear(mTracks);
302 deepVectorClear(mTracksLabel);
303 deepVectorClear(mLines);
304 deepVectorClear(mLinesLabels);
306 deepVectorClear(mPrimaryVertices);
307 deepVectorClear(mPrimaryVerticesLabels);
308 }
309 clearResizeBoundedVector(mLinesLabels, getNrof(1), mMemoryPool.get());
310 mIndexTableUtils.setTrackingParameters(trkParam);
311 clearResizeBoundedVector(mPositionResolution, trkParam.NLayers, mMemoryPool.get());
312 clearResizeBoundedVector(mBogusClusters, trkParam.NLayers, mMemoryPool.get());
313 deepVectorClear(mTrackletClusters);
314 for (unsigned int iLayer{0}; iLayer < std::min((int)mClusters.size(), maxLayers); ++iLayer) {
315 clearResizeBoundedVector(mClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeFrameworkHostResource(maxLayers != NLayers));
316 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeFrameworkHostResource(maxLayers != NLayers));
317 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt((0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer])) + (trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]));
318 }
319 clearResizeBoundedVector(mLines, getNrof(1), mMemoryPool.get());
320 clearResizeBoundedVector(mTrackletClusters, getNrof(1), mMemoryPool.get());
321
322 for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
323 clearResizeBoundedVector(mIndexTables[iLayer], getNrof(iLayer) * ((trkParam.ZBins * trkParam.PhiBins) + 1), getMaybeFrameworkHostResource());
324 }
325 for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
326 if (trkParam.SystErrorY2[iLayer] > 0.f || trkParam.SystErrorZ2[iLayer] > 0.f) {
327 for (auto& tfInfo : mTrackingFrameInfo[iLayer]) {
329 tfInfo.covarianceTrackingFrame[0] += trkParam.SystErrorY2[iLayer];
330 tfInfo.covarianceTrackingFrame[2] += trkParam.SystErrorZ2[iLayer];
331 }
332 }
333 }
334
335 mMinR.fill(std::numeric_limits<float>::max());
336 mMaxR.fill(std::numeric_limits<float>::min());
337 }
338 clearResizeBoundedVector(mCells, mTrackingTopologyView.nCells, mMemoryPool.get());
339 clearResizeBoundedVector(mCellsLookupTable, mTrackingTopologyView.nCells, mMemoryPool.get());
340 clearResizeBoundedVector(mCellsNeighbours, mTrackingTopologyView.nCells, mMemoryPool.get());
341 clearResizeBoundedVector(mCellsNeighboursTopology, mTrackingTopologyView.nCells, mMemoryPool.get());
342 clearResizeBoundedVector(mCellsNeighboursLUT, mTrackingTopologyView.nCells, mMemoryPool.get());
343 clearResizeBoundedVector(mCellLabels, mTrackingTopologyView.nCells, mMemoryPool.get());
344 clearResizeBoundedVector(mTracklets, mTrackingTopologyView.nLinks, mMemoryPool.get());
345 clearResizeBoundedVector(mTrackletLabels, mTrackingTopologyView.nLinks, mMemoryPool.get());
346 clearResizeBoundedVector(mTrackletsLookupTable, mTrackingTopologyView.nLinks, mMemoryPool.get());
347 clearResizeBoundedVector(mLinkPhiCuts, mTrackingTopologyView.nLinks, mMemoryPool.get());
348 clearResizeBoundedVector(mLinkMSAngles, mTrackingTopologyView.nLinks, mMemoryPool.get());
349 mNTrackletsPerROF.resize(2);
350 for (auto& v : mNTrackletsPerROF) {
351 v = bounded_vector<int>(getNrof(1) + 1, 0, mMemoryPool.get());
352 }
354 prepareClusters(trkParam, maxLayers);
355 }
356 mTotalTracklets = {0, 0};
357 if (maxLayers < trkParam.NLayers) { // Vertexer only, but in both iterations
358 for (size_t iLayer{0}; iLayer < maxLayers; ++iLayer) {
359 deepVectorClear(mUsedClusters[iLayer]);
360 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), mMemoryPool.get());
361 }
362 }
363
364 // estimate MS per layer
365 std::array<float, NLayers> msAngles{};
366 for (unsigned int iLayer{0}; iLayer < NLayers; ++iLayer) {
367 msAngles[iLayer] = math_utils::MSangle(0.14f, trkParam.TrackletMinPt, trkParam.LayerxX0[iLayer]);
368 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt((0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer])) + (trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]));
369 }
370
371 // for each link calculate the phi-cuts + integrated MS
372 float oneOverR{0.001f * 0.3f * std::abs(mBz) / trkParam.TrackletMinPt};
373 for (int linkId{0}; linkId < (int)mTracklets.size(); ++linkId) {
374 const auto& link = mTrackingTopologyView.getLink(linkId);
375 float ms2 = 0.;
376 for (int layer = link.fromLayer; layer < link.toLayer; ++layer) {
377 ms2 += math_utils::Sq(msAngles[layer]);
378 }
379 mLinkMSAngles[linkId] = o2::gpu::CAMath::Sqrt(ms2);
380 const float& r1 = trkParam.LayerRadii[link.fromLayer];
381 const float& r2 = trkParam.LayerRadii[link.toLayer];
382 oneOverR = (0.5 * oneOverR >= 1.f / r2) ? (2.f / r2) - o2::constants::math::Almost0 : oneOverR;
383 const float res1 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[link.fromLayer]);
384 const float res2 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[link.toLayer]);
385 const float cosTheta1half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r1 * oneOverR));
386 const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r2 * oneOverR));
387 float x = (r2 * cosTheta1half) - (r1 * cosTheta2half);
388 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)));
390 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);
391
392 // some cleanup
393 deepVectorClear(mTracklets[linkId]);
394 deepVectorClear(mTrackletLabels[linkId]);
395 deepVectorClear(mTrackletsLookupTable[linkId]);
396 mTrackletsLookupTable[linkId].resize(mClusters[link.fromLayer].size() + 1, 0);
397 }
398
399 for (int cellId{0}; cellId < (int)mCells.size(); ++cellId) {
400 deepVectorClear(mCells[cellId]);
401 deepVectorClear(mCellsLookupTable[cellId]);
402 deepVectorClear(mCellsNeighbours[cellId]);
403 deepVectorClear(mCellsNeighboursTopology[cellId]);
404 deepVectorClear(mCellsNeighboursLUT[cellId]);
405 deepVectorClear(mCellLabels[cellId]);
406 }
407}
408
409template <int NLayers>
411{
412 unsigned long size{0};
413 for (const auto& trkl : mTracklets) {
414 size += sizeof(Tracklet) * trkl.size();
415 }
416 for (const auto& cells : mCells) {
417 size += sizeof(CellSeed) * cells.size();
418 }
419 for (const auto& cellsN : mCellsNeighbours) {
420 size += sizeof(int) * cellsN.size();
421 }
422 for (const auto& cellsN : mCellsNeighboursTopology) {
423 size += sizeof(int) * cellsN.size();
424 }
425 return size;
426}
427
428template <int NLayers>
430{
431 LOGP(info, "TimeFrame: Artefacts occupy {:.2f} MB", getArtefactsMemory() / constants::MB);
432}
433
434template <int NLayers>
436{
437 for (ushort iLayer = 0; iLayer < 2; ++iLayer) {
438 for (unsigned int iRof{0}; iRof < getNrof(1); ++iRof) {
439 if (mROFMaskView.isROFEnabled(1, iRof)) {
440 mTotalTracklets[iLayer] += mNTrackletsPerROF[iLayer][iRof];
441 }
442 }
443 std::exclusive_scan(mNTrackletsPerROF[iLayer].begin(), mNTrackletsPerROF[iLayer].end(), mNTrackletsPerROF[iLayer].begin(), 0);
444 std::exclusive_scan(mNTrackletsPerCluster[iLayer].begin(), mNTrackletsPerCluster[iLayer].end(), mNTrackletsPerClusterSum[iLayer].begin(), 0);
445 }
446}
447
448template <int NLayers>
449void TimeFrame<NLayers>::setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool)
450{
451 mMemoryPool = pool;
452
453 auto initVector = [&]<typename T>(bounded_vector<T>& vec, bool useExternal = false) {
454 std::pmr::memory_resource* mr = (useExternal) ? mExtMemoryPool.get() : mMemoryPool.get();
455 deepVectorClear(vec, mr);
456 };
457
458 auto initContainers = [&]<typename Container>(Container& container, bool useExternal = false) {
459 for (auto& v : container) {
460 initVector(v, useExternal);
461 }
462 };
463
464 // these will only reside on the host for the cpu part
465 initContainers(mClusterExternalIndices);
466 initContainers(mNTrackletsPerCluster);
467 initContainers(mNTrackletsPerClusterSum);
468 initContainers(mNClustersPerROF);
469 initVector(mPrimaryVertices);
470 initVector(mLinkPhiCuts);
471 initVector(mLinkMSAngles);
472 initVector(mPositionResolution);
473 initContainers(mClusterSize);
474 initVector(mPValphaX);
475 initVector(mBogusClusters);
476 initContainers(mTrackletsIndexROF);
477 initVector(mTracks);
478 initContainers(mTracklets);
479 initContainers(mCells);
480 initContainers(mCellsNeighbours);
481 initContainers(mCellsLookupTable);
482 // MC info (we don't know if we have MC)
483 initVector(mPrimaryVerticesLabels);
484 initContainers(mLinesLabels);
485 initContainers(mTrackletLabels);
486 initContainers(mCellLabels);
487 initVector(mTracksLabel);
488 // these will use possibly an externally provided allocator
489 initContainers(mClusters, hasFrameworkAllocator());
490 initContainers(mUsedClusters, hasFrameworkAllocator());
491 initContainers(mUnsortedClusters, hasFrameworkAllocator());
492 initContainers(mIndexTables, hasFrameworkAllocator());
493 initContainers(mTrackingFrameInfo, hasFrameworkAllocator());
494 initContainers(mROFramesClusters, hasFrameworkAllocator());
495}
496
497template <int NLayers>
499{
500 mExternalAllocator = ext;
501 mExtMemoryPool = std::make_shared<BoundedMemoryResource>(mExternalAllocator);
502}
503
504template <int NLayers>
506{
507 resetTrackExtensionCounters();
508 deepVectorClear(mTracks);
509 deepVectorClear(mTracklets);
510 deepVectorClear(mCells);
511 deepVectorClear(mCellsNeighbours);
512 deepVectorClear(mCellsNeighboursTopology);
513 deepVectorClear(mCellsLookupTable);
514 deepVectorClear(mPrimaryVertices);
515 deepVectorClear(mTrackletsLookupTable);
516 deepVectorClear(mClusterExternalIndices);
517 deepVectorClear(mNTrackletsPerCluster);
518 deepVectorClear(mNTrackletsPerClusterSum);
519 deepVectorClear(mNClustersPerROF);
520 deepVectorClear(mLinkPhiCuts);
521 deepVectorClear(mLinkMSAngles);
522 deepVectorClear(mPositionResolution);
523 deepVectorClear(mClusterSize);
524 deepVectorClear(mPValphaX);
525 deepVectorClear(mBogusClusters);
526 deepVectorClear(mTrackletsIndexROF);
527 deepVectorClear(mTrackletClusters);
528 deepVectorClear(mLines);
529 // if we use the external host allocator then the assumption is that we
530 // don't clear the memory ourself
531 if (!hasFrameworkAllocator()) {
532 deepVectorClear(mClusters);
533 deepVectorClear(mUsedClusters);
534 deepVectorClear(mUnsortedClusters);
535 deepVectorClear(mIndexTables);
536 deepVectorClear(mTrackingFrameInfo);
537 deepVectorClear(mROFramesClusters);
538 }
539 // only needed to clear if we have MC info
540 if (hasMCinformation()) {
541 deepVectorClear(mLinesLabels);
542 deepVectorClear(mPrimaryVerticesLabels);
543 deepVectorClear(mTrackletLabels);
544 deepVectorClear(mCellLabels);
545 deepVectorClear(mTracksLabel);
546 }
547}
548
549template class TimeFrame<7>;
550// ALICE3 upgrade
551#ifdef ENABLE_UPGRADES
552template class TimeFrame<11>;
553template class TimeFrame<13>;
554#endif
555
556} // 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 float Almost0
constexpr float PI
constexpr int UnusedIndex
Definition Constants.h:32
constexpr float MB
Definition Constants.h:26
void deepVectorClear(std::vector< T > &vec)
std::pmr::vector< T > bounded_vector
const int end
constexpr float DefClusError2Col
Definition TimeFrame.cxx:47
constexpr float DefClusError2Row
Definition TimeFrame.cxx:46
constexpr float DefClusErrorRow
Definition TimeFrame.cxx:44
constexpr float DefClusErrorCol
Definition TimeFrame.cxx:45
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:56
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:68
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
static constexpr int L2G
Definition Cartesian.h:55
static constexpr int T2L
Definition Cartesian.h:56
std::vector< o2::ctf::BufferType > vec
std::vector< Cluster > clusters
std::vector< Cell > cells