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