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 <numeric>
17#include <sstream>
18
19#include "Framework/Logger.h"
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{
52 resetVectors();
53}
54
55template <int nLayers>
57{
58 wipe();
59}
60
61template <int nLayers>
62void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int iteration)
63{
64 for (const auto& vertex : vertices) {
65 mPrimaryVertices.emplace_back(vertex); // put a copy in the present
66 mTotVertPerIteration[iteration]++;
67 if (!isBeamPositionOverridden) { // beam position is updated only at first occurrence of the vertex. A bit sketchy if we have past/future vertices, it should not impact too much.
68 const float w = vertex.getNContributors();
69 mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
70 mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
71 mBeamPosWeight += w;
72 }
73 }
74 mROFramesPV.push_back(mPrimaryVertices.size()); // current rof must have number of vertices up to present
75}
76
77template <int nLayers>
78void TimeFrame<nLayers>::addPrimaryVerticesLabels(bounded_vector<std::pair<MCCompLabel, float>>& labels)
79{
80 mVerticesMCRecInfo.insert(mVerticesMCRecInfo.end(), labels.begin(), labels.end());
83template <int nLayers>
86 mVerticesContributorLabels.insert(mVerticesContributorLabels.end(), labels.begin(), labels.end());
87}
88
89template <int nLayers>
90void TimeFrame<nLayers>::addPrimaryVerticesInROF(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration)
91{
92 mPrimaryVertices.insert(mPrimaryVertices.begin() + mROFramesPV[rofId], vertices.begin(), vertices.end());
93 for (int i = rofId + 1; i < mROFramesPV.size(); ++i) {
94 mROFramesPV[i] += vertices.size();
95 }
96 mTotVertPerIteration[iteration] += vertices.size();
97}
98
99template <int nLayers>
100void TimeFrame<nLayers>::addPrimaryVerticesLabelsInROF(const bounded_vector<std::pair<MCCompLabel, float>>& labels, const int rofId)
101{
102 mVerticesMCRecInfo.insert(mVerticesMCRecInfo.begin() + mROFramesPV[rofId], labels.begin(), labels.end());
103}
104
105template <int nLayers>
107{
108 // count the number of cont. in rofs before and including the target rof
109 unsigned int n{0};
110 const auto& pvs = getPrimaryVertices(0, rofId);
111 for (const auto& pv : pvs) {
112 n += pv.getNContributors();
113 }
114 mVerticesContributorLabels.insert(mVerticesContributorLabels.begin() + n, labels.begin(), labels.end());
115}
116
117template <int nLayers>
118int TimeFrame<nLayers>::loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
119 gsl::span<const itsmft::CompClusterExt> clusters,
120 gsl::span<const unsigned char>::iterator& pattIt,
121 const itsmft::TopologyDictionary* dict,
123{
124 resetROFrameData();
125
128
129 mNrof = 0;
130 clearResizeBoundedVector(mClusterSize, clusters.size(), mMemoryPool.get());
131 for (auto& rof : rofs) {
132 for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
133 const auto& c = clusters[clusterId];
134
135 int layer = geom->getLayer(c.getSensorID());
136
137 auto pattID = c.getPatternID();
139 float sigmaY2 = DefClusError2Row, sigmaZ2 = DefClusError2Col, sigmaYZ = 0; // Dummy COG errors (about half pixel size)
140 unsigned int clusterSize{0};
142 sigmaY2 = dict->getErr2X(pattID);
143 sigmaZ2 = dict->getErr2Z(pattID);
144 if (!dict->isGroup(pattID)) {
145 locXYZ = dict->getClusterCoordinates(c);
146 clusterSize = dict->getNpixels(pattID);
147 } else {
148 o2::itsmft::ClusterPattern patt(pattIt);
149 locXYZ = dict->getClusterCoordinates(c, patt);
150 clusterSize = patt.getNPixels();
151 }
152 } else {
153 o2::itsmft::ClusterPattern patt(pattIt);
154 locXYZ = dict->getClusterCoordinates(c, patt, false);
155 clusterSize = patt.getNPixels();
156 }
157 mClusterSize[clusterId] = std::clamp(clusterSize, 0u, 255u);
158 auto sensorID = c.getSensorID();
159 // Inverse transformation to the local --> tracking
160 auto trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
161 // Transformation to the local --> global
162 auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
163
164 addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), geom->getSensorRefAlpha(sensorID),
165 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
166 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
167
169 addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), mUnsortedClusters[layer].size());
170 addClusterExternalIndexToLayer(layer, clusterId);
171 }
172 for (unsigned int iL{0}; iL < mUnsortedClusters.size(); ++iL) {
173 mROFramesClusters[iL].push_back(mUnsortedClusters[iL].size());
174 }
175 mNrof++;
176 }
177
178 for (auto i = 0; i < mNTrackletsPerCluster.size(); ++i) {
179 mNTrackletsPerCluster[i].resize(mUnsortedClusters[1].size());
180 mNTrackletsPerClusterSum[i].resize(mUnsortedClusters[1].size() + 1); // Exc sum "prepends" a 0
181 }
182
183 if (mcLabels != nullptr) {
184 mClusterLabels = mcLabels;
185 }
186
187 return mNrof;
189
190template <int nLayers>
193 for (int iLayer{0}; iLayer < nLayers; ++iLayer) {
194 deepVectorClear(mUnsortedClusters[iLayer], mMemoryPool.get());
195 deepVectorClear(mTrackingFrameInfo[iLayer], mMemoryPool.get());
196 deepVectorClear(mClusterExternalIndices[iLayer], mMemoryPool.get());
197 clearResizeBoundedVector(mROFramesClusters[iLayer], 1, mMemoryPool.get(), 0);
198
199 if (iLayer < 2) {
200 deepVectorClear(mTrackletsIndexROF[iLayer], mMemoryPool.get());
201 deepVectorClear(mNTrackletsPerCluster[iLayer], mMemoryPool.get());
202 deepVectorClear(mNTrackletsPerClusterSum[iLayer], mMemoryPool.get());
203 }
204 }
205}
206
207template <int nLayers>
208void TimeFrame<nLayers>::prepareClusters(const TrackingParameters& trkParam, const int maxLayers)
209{
210 const int numBins{trkParam.PhiBins * trkParam.ZBins};
211 const int stride{numBins + 1};
212 bounded_vector<ClusterHelper> cHelper(mMemoryPool.get());
213 bounded_vector<int> clsPerBin(numBins, 0, mMemoryPool.get());
214 bounded_vector<int> lutPerBin(numBins, 0, mMemoryPool.get());
215 for (int rof{0}; rof < mNrof; ++rof) {
216 if ((int)mMultiplicityCutMask.size() == mNrof && !mMultiplicityCutMask[rof]) {
217 continue;
218 }
219 for (int iLayer{0}, stopLayer = std::min(trkParam.NLayers, maxLayers); iLayer < stopLayer; ++iLayer) {
220 const auto& unsortedClusters{getUnsortedClustersOnLayer(rof, iLayer)};
221 const int clustersNum{static_cast<int>(unsortedClusters.size())};
222 auto* tableBase = mIndexTables[iLayer].data() + rof * stride;
223
224 cHelper.resize(clustersNum);
225
226 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
227 const Cluster& c = unsortedClusters[iCluster];
228 ClusterHelper& h = cHelper[iCluster];
229
230 const float x = c.xCoordinate - mBeamPos[0];
231 const float y = c.yCoordinate - mBeamPos[1];
232 const float z = c.zCoordinate;
233
234 float phi = math_utils::computePhi(x, y);
235 int zBin{mIndexTableUtils.getZBinIndex(iLayer, z)};
236 if (zBin < 0 || zBin >= trkParam.ZBins) {
237 zBin = std::clamp(zBin, 0, trkParam.ZBins - 1);
238 mBogusClusters[iLayer]++;
239 }
240 int bin = mIndexTableUtils.getBinIndex(zBin, mIndexTableUtils.getPhiBinIndex(phi));
241 h.phi = phi;
242 h.r = math_utils::hypot(x, y);
243 mMinR[iLayer] = o2::gpu::GPUCommonMath::Min(h.r, mMinR[iLayer]);
244 mMaxR[iLayer] = o2::gpu::GPUCommonMath::Max(h.r, mMaxR[iLayer]);
245 h.bin = bin;
246 h.ind = clsPerBin[bin]++;
247 }
248 std::exclusive_scan(clsPerBin.begin(), clsPerBin.end(), lutPerBin.begin(), 0);
249
250 auto clusters2beSorted{getClustersOnLayer(rof, iLayer)};
251 for (int iCluster{0}; iCluster < clustersNum; ++iCluster) {
252 const ClusterHelper& h = cHelper[iCluster];
253 Cluster& c = clusters2beSorted[lutPerBin[h.bin] + h.ind];
254
255 c = unsortedClusters[iCluster];
256 c.phi = h.phi;
257 c.radius = h.r;
258 c.indexTableBinIndex = h.bin;
259 }
260 std::copy_n(lutPerBin.data(), clsPerBin.size(), tableBase);
261 std::fill_n(tableBase + clsPerBin.size(), stride - clsPerBin.size(), clustersNum);
262
263 std::fill(clsPerBin.begin(), clsPerBin.end(), 0);
264 cHelper.clear();
269template <int nLayers>
270void TimeFrame<nLayers>::initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers, bool resetVertices)
272 if (iteration == 0) {
273 if (maxLayers < trkParam.NLayers && resetVertices) {
274 resetRofPV();
275 deepVectorClear(mTotVertPerIteration);
276 }
277 deepVectorClear(mTracks);
278 deepVectorClear(mTracksLabel);
279 deepVectorClear(mLines);
280 deepVectorClear(mLinesLabels);
281 if (resetVertices) {
282 deepVectorClear(mVerticesMCRecInfo);
283 deepVectorClear(mVerticesContributorLabels);
284 }
285 clearResizeBoundedVector(mTracks, mNrof, mMemoryPool.get());
286 clearResizeBoundedVector(mTracksLabel, mNrof, mMemoryPool.get());
287 clearResizeBoundedVector(mLinesLabels, mNrof, mMemoryPool.get());
288 clearResizeBoundedVector(mCells, trkParam.CellsPerRoad(), mMemoryPool.get());
289 clearResizeBoundedVector(mCellsLookupTable, trkParam.CellsPerRoad() - 1, mMemoryPool.get());
290 clearResizeBoundedVector(mCellsNeighbours, trkParam.CellsPerRoad() - 1, mMemoryPool.get());
291 clearResizeBoundedVector(mCellsNeighboursLUT, trkParam.CellsPerRoad() - 1, mMemoryPool.get());
292 clearResizeBoundedVector(mCellLabels, trkParam.CellsPerRoad(), mMemoryPool.get());
293 clearResizeBoundedVector(mTracklets, std::min(trkParam.TrackletsPerRoad(), maxLayers - 1), mMemoryPool.get());
294 clearResizeBoundedVector(mTrackletLabels, trkParam.TrackletsPerRoad(), mMemoryPool.get());
295 clearResizeBoundedVector(mTrackletsLookupTable, trkParam.TrackletsPerRoad(), mMemoryPool.get());
296 mIndexTableUtils.setTrackingParameters(trkParam);
297 clearResizeBoundedVector(mPositionResolution, trkParam.NLayers, mMemoryPool.get());
298 clearResizeBoundedVector(mBogusClusters, trkParam.NLayers, mMemoryPool.get());
299 deepVectorClear(mTrackletClusters);
300 for (unsigned int iLayer{0}; iLayer < std::min((int)mClusters.size(), maxLayers); ++iLayer) {
301 clearResizeBoundedVector(mClusters[iLayer], mUnsortedClusters[iLayer].size(), mMemoryPool.get());
302 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), mMemoryPool.get());
303 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt(0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer]) + trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]);
304 }
305 clearResizeBoundedArray(mIndexTables, mNrof * (trkParam.ZBins * trkParam.PhiBins + 1), mMemoryPool.get());
306 clearResizeBoundedVector(mLines, mNrof, mMemoryPool.get());
307 clearResizeBoundedVector(mTrackletClusters, mNrof, mMemoryPool.get());
308
309 for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
310 if (trkParam.SystErrorY2[iLayer] > 0.f || trkParam.SystErrorZ2[iLayer] > 0.f) {
311 for (auto& tfInfo : mTrackingFrameInfo[iLayer]) {
313 tfInfo.covarianceTrackingFrame[0] += trkParam.SystErrorY2[iLayer];
314 tfInfo.covarianceTrackingFrame[2] += trkParam.SystErrorZ2[iLayer];
315 }
316 }
317 }
318 }
319 mNTrackletsPerROF.resize(2);
320 for (auto& v : mNTrackletsPerROF) {
321 v = bounded_vector<int>(mNrof + 1, 0, mMemoryPool.get());
322 }
323 if (iteration == 0 || iteration == 3) {
324 prepareClusters(trkParam, maxLayers);
325 }
326 mTotalTracklets = {0, 0};
327 if (maxLayers < trkParam.NLayers) { // Vertexer only, but in both iterations
328 for (size_t iLayer{0}; iLayer < maxLayers; ++iLayer) {
329 deepVectorClear(mUsedClusters[iLayer]);
330 clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), mMemoryPool.get());
331 }
332 }
333
334 mTotVertPerIteration.resize(1 + iteration);
335 mNoVertexROF = 0;
336 deepVectorClear(mRoads);
337 deepVectorClear(mRoadLabels);
338
339 mMSangles.resize(trkParam.NLayers);
340 mPhiCuts.resize(mClusters.size() - 1, 0.f);
341
342 float oneOverR{0.001f * 0.3f * std::abs(mBz) / trkParam.TrackletMinPt};
343 for (unsigned int iLayer{0}; iLayer < nLayers; ++iLayer) {
344 mMSangles[iLayer] = math_utils::MSangle(0.14f, trkParam.TrackletMinPt, trkParam.LayerxX0[iLayer]);
345 mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt(0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer]) + trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]);
346 if (iLayer < mClusters.size() - 1) {
347 const float& r1 = trkParam.LayerRadii[iLayer];
348 const float& r2 = trkParam.LayerRadii[iLayer + 1];
349 const float res1 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[iLayer]);
350 const float res2 = o2::gpu::CAMath::Hypot(trkParam.PVres, mPositionResolution[iLayer + 1]);
351 const float cosTheta1half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r1 * oneOverR));
352 const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - math_utils::Sq(0.5f * r2 * oneOverR));
353 float x = r2 * cosTheta1half - r1 * cosTheta2half;
354 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)));
355 mPhiCuts[iLayer] = std::min(o2::gpu::CAMath::ASin(0.5f * x * oneOverR) + 2.f * mMSangles[iLayer] + delta, o2::constants::math::PI * 0.5f);
356 }
357 }
358
359 for (int iLayer{0}; iLayer < std::min((int)mTracklets.size(), maxLayers); ++iLayer) {
360 deepVectorClear(mTracklets[iLayer]);
361 deepVectorClear(mTrackletLabels[iLayer]);
362 if (iLayer < (int)mCells.size()) {
363 deepVectorClear(mCells[iLayer]);
364 deepVectorClear(mTrackletsLookupTable[iLayer]);
365 mTrackletsLookupTable[iLayer].resize(mClusters[iLayer + 1].size() + 1, 0);
366 deepVectorClear(mCellLabels[iLayer]);
367 }
368
369 if (iLayer < (int)mCells.size() - 1) {
370 deepVectorClear(mCellsLookupTable[iLayer]);
371 deepVectorClear(mCellsNeighbours[iLayer]);
372 deepVectorClear(mCellsNeighboursLUT[iLayer]);
373 }
374 }
375}
376
377template <int nLayers>
379{
380 unsigned long size{0};
381 for (const auto& trkl : mTracklets) {
382 size += sizeof(Tracklet) * trkl.size();
383 }
384 for (const auto& cells : mCells) {
385 size += sizeof(CellSeed) * cells.size();
386 }
387 for (const auto& cellsN : mCellsNeighbours) {
388 size += sizeof(int) * cellsN.size();
389 }
390 return size + sizeof(Road<nLayers - 2>) * mRoads.size();
391}
392
393template <int nLayers>
395{
396 LOGP(info, "TimeFrame: Artefacts occupy {:.2f} MB", getArtefactsMemory() / constants::MB);
397}
398
399template <int nLayers>
401{
402 deepVectorClear(mPValphaX);
403 mPValphaX.reserve(mPrimaryVertices.size());
404 for (auto& pv : mPrimaryVertices) {
405 mPValphaX.emplace_back(std::array<float, 2>{o2::gpu::CAMath::Hypot(pv.getX(), pv.getY()), math_utils::computePhi(pv.getX(), pv.getY())});
406 }
407}
408
409template <int nLayers>
411{
412 for (ushort iLayer = 0; iLayer < 2; ++iLayer) {
413 for (unsigned int iRof{0}; iRof < mNrof; ++iRof) {
414 if (mMultiplicityCutMask[iRof]) {
415 mTotalTracklets[iLayer] += mNTrackletsPerROF[iLayer][iRof];
416 }
417 }
418 std::exclusive_scan(mNTrackletsPerROF[iLayer].begin(), mNTrackletsPerROF[iLayer].end(), mNTrackletsPerROF[iLayer].begin(), 0);
419 std::exclusive_scan(mNTrackletsPerCluster[iLayer].begin(), mNTrackletsPerCluster[iLayer].end(), mNTrackletsPerClusterSum[iLayer].begin(), 0);
420 }
421}
422
423template <int nLayers>
425{
426 for (uint32_t iLayer{0}; iLayer < getTracklets().size(); ++iLayer) {
427 int prev{-1};
428 int count{0};
429 for (uint32_t iTracklet{0}; iTracklet < getTracklets()[iLayer].size(); ++iTracklet) {
430 auto& trk = getTracklets()[iLayer][iTracklet];
431 int currentId{trk.firstClusterIndex};
432 if (currentId < prev) {
433 LOG(info) << "First Cluster Index not increasing monotonically on L:T:ID:Prev " << iLayer << "\t" << iTracklet << "\t" << currentId << "\t" << prev;
434 } else if (currentId == prev) {
435 count++;
436 } else {
437 if (iLayer > 0) {
438 auto& lut{getTrackletsLookupTable()[iLayer - 1]};
439 if (count != lut[prev + 1] - lut[prev]) {
440 LOG(info) << "LUT count broken " << iLayer - 1 << "\t" << prev << "\t" << count << "\t" << lut[prev + 1] << "\t" << lut[prev];
441 }
442 }
443 count = 1;
444 }
445 prev = currentId;
446 if (iLayer > 0) {
447 auto& lut{getTrackletsLookupTable()[iLayer - 1]};
448 if (iTracklet >= (uint32_t)(lut[currentId + 1]) || iTracklet < (uint32_t)(lut[currentId])) {
449 LOG(info) << "LUT broken: " << iLayer - 1 << "\t" << currentId << "\t" << iTracklet;
450 }
451 }
452 }
453 }
454}
455
456template <int nLayers>
458{
459 mMinR.fill(10000.);
460 mMaxR.fill(-1.);
461 for (int iLayers{nLayers}; iLayers--;) {
462 mClusters[iLayers].clear();
463 mUnsortedClusters[iLayers].clear();
464 mTrackingFrameInfo[iLayers].clear();
465 mClusterExternalIndices[iLayers].clear();
466 mUsedClusters[iLayers].clear();
467 mROFramesClusters[iLayers].clear();
468 mNClustersPerROF[iLayers].clear();
469 }
470 for (int i{2}; i--;) {
471 mTrackletsIndexROF[i].clear();
472 }
473}
474
475template <int nLayers>
477{
478 for (auto& trkl : mTracklets) {
479 deepVectorClear(trkl);
480 }
481 deepVectorClear(mTrackletsLookupTable);
482}
483
484template <int nLayers>
486{
487 LOG(info) << "-------- Tracklet LUT " << i;
488 std::stringstream s;
489 for (int j : mTrackletsLookupTable[i]) {
490 s << j << "\t";
491 }
492 LOG(info) << s.str();
493 LOG(info) << "--------";
494}
495
496template <int nLayers>
498{
499 LOG(info) << "-------- Cell LUT " << i;
500 std::stringstream s;
501 for (int j : mCellsLookupTable[i]) {
502 s << j << "\t";
503 }
504 LOG(info) << s.str();
505 LOG(info) << "--------";
506}
507
508template <int nLayers>
510{
511 for (unsigned int i{0}; i < mTrackletsLookupTable.size(); ++i) {
512 printTrackletLUTonLayer(i);
513 }
514}
515
516template <int nLayers>
518{
519 for (unsigned int i{0}; i < mCellsLookupTable.size(); ++i) {
520 printCellLUTonLayer(i);
521 }
522}
523
524template <int nLayers>
526{
527 LOG(info) << "Vertices in ROF (nROF = " << mNrof << ", lut size = " << mROFramesPV.size() << ")";
528 for (unsigned int iR{0}; iR < mROFramesPV.size(); ++iR) {
529 LOG(info) << mROFramesPV[iR] << "\t";
530 }
531 LOG(info) << "\n\n Vertices:";
532 for (unsigned int iV{0}; iV < mPrimaryVertices.size(); ++iV) {
533 LOG(info) << mPrimaryVertices[iV].getX() << "\t" << mPrimaryVertices[iV].getY() << "\t" << mPrimaryVertices[iV].getZ();
534 }
535 LOG(info) << "--------";
536}
537
538template <int nLayers>
540{
541 LOG(info) << "--------";
542 for (unsigned int iLayer{0}; iLayer < mROFramesClusters.size(); ++iLayer) {
543 LOG(info) << "Layer " << iLayer;
544 std::stringstream s;
545 for (auto value : mROFramesClusters[iLayer]) {
546 s << value << "\t";
547 }
548 LOG(info) << s.str();
549 }
550}
551
552template <int nLayers>
554{
555 LOG(info) << "--------";
556 for (unsigned int iLayer{0}; iLayer < mNClustersPerROF.size(); ++iLayer) {
557 LOG(info) << "Layer " << iLayer;
558 std::stringstream s;
559 for (auto& value : mNClustersPerROF[iLayer]) {
560 s << value << "\t";
561 }
562 LOG(info) << s.str();
563 }
564}
565
566template <int nLayers>
567void TimeFrame<nLayers>::printSliceInfo(const int startROF, const int sliceSize)
568{
569 LOG(info) << "Dumping slice of " << sliceSize << " rofs:";
570 for (int iROF{startROF}; iROF < startROF + sliceSize; ++iROF) {
571 LOG(info) << "ROF " << iROF << " dump:";
572 for (unsigned int iLayer{0}; iLayer < mClusters.size(); ++iLayer) {
573 LOG(info) << "Layer " << iLayer << " has: " << getClustersOnLayer(iROF, iLayer).size() << " clusters.";
574 }
575 LOG(info) << "Number of seeding vertices: " << getPrimaryVertices(iROF).size();
576 int iVertex{0};
577 for (auto& v : getPrimaryVertices(iROF)) {
578 LOG(info) << "\t vertex " << iVertex++ << ": x=" << v.getX() << " " << " y=" << v.getY() << " z=" << v.getZ() << " has " << v.getNContributors() << " contributors.";
579 }
580 }
581}
582
583template <int nLayers>
584void TimeFrame<nLayers>::setMemoryPool(std::shared_ptr<BoundedMemoryResource>& pool)
585{
586 mMemoryPool = pool;
587
588 auto initVector = [&]<typename T>(bounded_vector<T>& vec) {
589 auto alloc = vec.get_allocator().resource();
590 if (alloc != mMemoryPool.get()) {
591 vec = bounded_vector<T>(mMemoryPool.get());
592 }
593 };
594 auto initArrays = [&]<typename T, size_t S>(std::array<bounded_vector<T>, S>& arr) {
595 for (size_t i{0}; i < S; ++i) {
596 auto alloc = arr[i].get_allocator().resource();
597 if (alloc != mMemoryPool.get()) {
598 arr[i] = bounded_vector<T>(mMemoryPool.get());
599 }
600 }
601 };
602 auto initVectors = [&]<typename T>(std::vector<bounded_vector<T>>& vec) {
603 for (size_t i{0}; i < vec.size(); ++i) {
604 auto alloc = vec[i].get_allocator().resource();
605 if (alloc != mMemoryPool.get()) {
606 vec[i] = bounded_vector<T>(mMemoryPool.get());
607 }
608 }
609 };
610
611 initVector(mTotVertPerIteration);
612 initVector(mPrimaryVertices);
613 initVector(mROFramesPV);
614 initArrays(mClusters);
615 initArrays(mTrackingFrameInfo);
616 initArrays(mClusterExternalIndices);
617 initArrays(mROFramesClusters);
618 initArrays(mNTrackletsPerCluster);
619 initArrays(mNTrackletsPerClusterSum);
620 initArrays(mNClustersPerROF);
621 initArrays(mIndexTables);
622 initArrays(mUsedClusters);
623 initArrays(mUnsortedClusters);
624 initVector(mROFramesPV);
625 initVector(mPrimaryVertices);
626 initVector(mRoads);
627 initVector(mRoadLabels);
628 initVector(mMSangles);
629 initVector(mPhiCuts);
630 initVector(mPositionResolution);
631 initVector(mClusterSize);
632 initVector(mPValphaX);
633 initVector(mBogusClusters);
634 initVector(mVerticesContributorLabels);
635 initArrays(mTrackletsIndexROF);
636 initVectors(mTracks);
637 initVectors(mTracklets);
638 initVectors(mCells);
639 initVectors(mCellsNeighbours);
640 initVectors(mCellsLookupTable);
641}
642
643template <int nLayers>
645{
646 deepVectorClear(mUnsortedClusters);
647 deepVectorClear(mTracks);
648 deepVectorClear(mTracklets);
649 deepVectorClear(mCells);
650 deepVectorClear(mRoads);
651 deepVectorClear(mCellsNeighbours);
652 deepVectorClear(mCellsLookupTable);
653 deepVectorClear(mTotVertPerIteration);
654 deepVectorClear(mPrimaryVertices);
655 deepVectorClear(mClusters);
656 deepVectorClear(mTrackletsLookupTable);
657 deepVectorClear(mTrackingFrameInfo);
658 deepVectorClear(mClusterExternalIndices);
659 deepVectorClear(mROFramesClusters);
660 deepVectorClear(mNTrackletsPerCluster);
661 deepVectorClear(mNTrackletsPerClusterSum);
662 deepVectorClear(mNClustersPerROF);
663 deepVectorClear(mIndexTables);
664 deepVectorClear(mUsedClusters);
665 deepVectorClear(mUnsortedClusters);
666 deepVectorClear(mROFramesPV);
667 deepVectorClear(mPrimaryVertices);
668 deepVectorClear(mRoads);
669 deepVectorClear(mRoadLabels);
670 deepVectorClear(mMSangles);
671 deepVectorClear(mPhiCuts);
672 deepVectorClear(mPositionResolution);
673 deepVectorClear(mClusterSize);
674 deepVectorClear(mPValphaX);
675 deepVectorClear(mBogusClusters);
676 deepVectorClear(mTrackletsIndexROF);
677 deepVectorClear(mPrimaryVertices);
678 deepVectorClear(mTrackletClusters);
679 deepVectorClear(mVerticesContributorLabels);
680 deepVectorClear(mLines);
681 deepVectorClear(mLinesLabels);
682}
683
684template class TimeFrame<7>;
685
686} // namespace o2::its
Definition of the ITSMFT compact cluster.
Definition of the ITSMFT cluster.
Definition of the ClusterTopology class.
uint64_t vertex
Definition RawEventData.h:9
int32_t i
Definition of the GeometryTGeo class.
Definition of the ITSMFT ROFrame (trigger) record.
uint32_t j
Definition RawData.h:0
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
const Mat3D & getMatrixT2L(int lay, int hba, int sta, int det) const
int getLayer(int index) const
Get chip layer, from 0.
float getSensorRefAlpha(int isn) const
static GeometryTGeo * Instance()
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.
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLint GLsizei count
Definition glcorearb.h:399
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
GLsizei const GLfloat * value
Definition glcorearb.h:819
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 PI
constexpr unsigned int nLayers
Definition SpecsV2.h:127
constexpr float MB
Definition Constants.h:23
void deepVectorClear(std::vector< T > &vec)
std::pmr::vector< T > bounded_vector
void clearResizeBoundedArray(std::array< bounded_vector< T >, S > &arr, size_t size, BoundedMemoryResource *bmr, T def=T())
constexpr float DefClusError2Col
Definition TimeFrame.cxx:47
constexpr float DefClusError2Row
Definition TimeFrame.cxx:46
void clearResizeBoundedVector(bounded_vector< T > &vec, size_t size, BoundedMemoryResource *bmr, T def=T())
constexpr float DefClusErrorRow
Definition TimeFrame.cxx:44
constexpr float DefClusErrorCol
Definition TimeFrame.cxx:45
void checkTrackletLUTs()
Debug and printing.
void printTrackletLUTonLayer(int i)
void initialise(const int iteration, const TrackingParameters &trkParam, const int maxLayers=7, bool resetVertices=true)
void addPrimaryVertices(const bounded_vector< Vertex > &vertices, const int iteration)
Definition TimeFrame.cxx:62
virtual ~TimeFrame()
Definition TimeFrame.cxx:56
virtual void wipe()
void addPrimaryVerticesInROF(const bounded_vector< Vertex > &vertices, const int rofId, const int iteration)
Definition TimeFrame.cxx:90
void printSliceInfo(const int, const int)
void computeTrackletsPerROFScans()
void addPrimaryVerticesLabelsInROF(const bounded_vector< std::pair< MCCompLabel, float > > &labels, const int rofId)
void addPrimaryVerticesContributorLabelsInROF(const bounded_vector< MCCompLabel > &labels, const int rofId)
void addPrimaryVerticesLabels(bounded_vector< std::pair< MCCompLabel, float > > &labels)
Definition TimeFrame.cxx:78
int loadROFrameData(const o2::itsmft::ROFRecord &rof, gsl::span< const itsmft::Cluster > clusters, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
void fillPrimaryVerticesXandAlpha()
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > &pool)
memory management
unsigned long getArtefactsMemory() const
void printCellLUTonLayer(int i)
void printArtefactsMemory() const
void addPrimaryVerticesContributorLabels(bounded_vector< MCCompLabel > &labels)
Definition TimeFrame.cxx:84
std::vector< float > LayerRadii
std::vector< float > SystErrorY2
std::vector< float > SystErrorZ2
float TrackletMinPt
Trackleting cuts.
std::vector< float > LayerResolution
std::vector< float > LayerxX0
int CellsPerRoad() const noexcept
int TrackletsPerRoad() const noexcept
static constexpr int L2G
Definition Cartesian.h:54
static constexpr int T2L
Definition Cartesian.h:55
std::vector< o2::ctf::BufferType > vec
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters
std::vector< Cell > cells