Project
Loading...
Searching...
No Matches
TimeFrame.h
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.
12
13#ifndef TRACKINGITSU_INCLUDE_TIMEFRAME_H_
14#define TRACKINGITSU_INCLUDE_TIMEFRAME_H_
15
16#include <array>
17#include <vector>
18#include <utility>
19#include <algorithm>
20#include <numeric>
21#include <gsl/gsl>
22
24
25#include "ITStracking/Cell.h"
26#include "ITStracking/Cluster.h"
31#include "ITStracking/Road.h"
36
39
42
43namespace o2
44{
45namespace gpu
46{
47class GPUChainITS;
48}
49
50namespace itsmft
51{
52class Cluster;
53class CompClusterExt;
54class TopologyDictionary;
55class ROFRecord;
56} // namespace itsmft
57
58namespace its
59{
60namespace gpu
61{
62template <int>
63class TimeFrameGPU;
64}
66
67template <int nLayers = 7>
68struct TimeFrame {
69 friend class gpu::TimeFrameGPU<nLayers>;
70 TimeFrame();
71 virtual ~TimeFrame();
72 const Vertex& getPrimaryVertex(const int ivtx) const { return mPrimaryVertices[ivtx]; }
73 gsl::span<const Vertex> getPrimaryVertices(int rofId) const;
74 gsl::span<const Vertex> getPrimaryVertices(int romin, int romax) const;
75 gsl::span<const std::pair<MCCompLabel, float>> getPrimaryVerticesMCRecInfo(const int rofId) const;
76 gsl::span<const MCCompLabel> getPrimaryVerticesContributors(const int rofId) const;
77 gsl::span<const std::array<float, 2>> getPrimaryVerticesXAlpha(int rofId) const;
79 int getPrimaryVerticesNum(int rofId = -1) const;
80 void addPrimaryVerticesLabels(bounded_vector<std::pair<MCCompLabel, float>>& labels);
82 void addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int iteration);
83 void addPrimaryVerticesInROF(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration);
84 void addPrimaryVerticesLabelsInROF(const bounded_vector<std::pair<MCCompLabel, float>>& labels, const int rofId);
86 void removePrimaryVerticesInROf(const int rofId);
87 int loadROFrameData(const o2::itsmft::ROFRecord& rof, gsl::span<const itsmft::Cluster> clusters,
88 const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
89
90 int loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
91 gsl::span<const itsmft::CompClusterExt> clusters,
92 gsl::span<const unsigned char>::iterator& pattIt,
94 const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
95 void resetROFrameData();
96
97 int getTotalClusters() const;
98 auto& getTotVertIteration() { return mTotVertPerIteration; }
99 bool empty() const { return getTotalClusters() == 0; }
100 int getSortedIndex(int rofId, int layer, int idx) const { return mROFramesClusters[layer][rofId] + idx; }
101 int getSortedStartIndex(const int rofId, const int layer) const { return mROFramesClusters[layer][rofId]; }
102 int getNrof() const { return mNrof; }
103
104 void resetBeamXY(const float x, const float y, const float w = 0);
105 void setBeamPosition(const float x, const float y, const float s2, const float base = 50.f, const float systematic = 0.f)
106 {
107 isBeamPositionOverridden = true;
108 resetBeamXY(x, y, s2 / o2::gpu::CAMath::Sqrt(base * base + systematic));
109 }
110
111 float getBeamX() const { return mBeamPos[0]; }
112 float getBeamY() const { return mBeamPos[1]; }
113 auto& getMinRs() { return mMinR; }
114 auto& getMaxRs() { return mMaxR; }
115 float getMinR(int layer) const { return mMinR[layer]; }
116 float getMaxR(int layer) const { return mMaxR[layer]; }
117 float getMSangle(int layer) const { return mMSangles[layer]; }
118 auto& getMSangles() { return mMSangles; }
119 float getPhiCut(int layer) const { return mPhiCuts[layer]; }
120 auto& getPhiCuts() { return mPhiCuts; }
121 float getPositionResolution(int layer) const { return mPositionResolution[layer]; }
122 auto& getPositionResolutions() { return mPositionResolution; }
123
124 gsl::span<Cluster> getClustersOnLayer(int rofId, int layerId);
125 gsl::span<const Cluster> getClustersOnLayer(int rofId, int layerId) const;
126 gsl::span<const Cluster> getClustersPerROFrange(int rofMin, int range, int layerId) const;
127 gsl::span<const Cluster> getUnsortedClustersOnLayer(int rofId, int layerId) const;
128 gsl::span<uint8_t> getUsedClustersROF(int rofId, int layerId);
129 gsl::span<const uint8_t> getUsedClustersROF(int rofId, int layerId) const;
130 gsl::span<const int> getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const;
131 gsl::span<const int> getROFrameClusters(int layerId) const;
132 gsl::span<const int> getNClustersROFrange(int rofMin, int range, int layerId) const;
133 gsl::span<const int> getIndexTablePerROFrange(int rofMin, int range, int layerId) const;
134 gsl::span<int> getIndexTable(int rofId, int layerId);
135 auto& getIndexTableWhole(int layerId) { return mIndexTables[layerId]; }
136 const auto& getTrackingFrameInfoOnLayer(int layerId) const { return mTrackingFrameInfo[layerId]; }
137
138 const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const;
139 gsl::span<const MCCompLabel> getClusterLabels(int layerId, const Cluster& cl) const { return getClusterLabels(layerId, cl.clusterId); }
140 gsl::span<const MCCompLabel> getClusterLabels(int layerId, const int clId) const { return mClusterLabels->getLabels(mClusterExternalIndices[layerId][clId]); }
141 int getClusterExternalIndex(int layerId, const int clId) const { return mClusterExternalIndices[layerId][clId]; }
142 int getClusterSize(int clusterId) const { return mClusterSize[clusterId]; }
143 void setClusterSize(bounded_vector<uint8_t>& v) { mClusterSize = std::move(v); }
144
145 auto& getTrackletsLabel(int layer) { return mTrackletLabels[layer]; }
146 auto& getCellsLabel(int layer) { return mCellLabels[layer]; }
147
148 bool hasMCinformation() const { return mClusterLabels; }
149 void initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers = 7, bool resetVertices = true);
151 {
153 mROFramesPV.resize(1, 0);
154 mTotVertPerIteration.resize(1);
155 }
156
157 bool isClusterUsed(int layer, int clusterId) const { return mUsedClusters[layer][clusterId]; }
158 void markUsedCluster(int layer, int clusterId) { mUsedClusters[layer][clusterId] = true; }
159 gsl::span<unsigned char> getUsedClusters(const int layer);
160
161 auto& getTracklets() { return mTracklets; }
163
164 auto& getClusters() { return mClusters; }
166 int getClusterROF(int iLayer, int iCluster);
167 auto& getCells() { return mCells; }
168
171 auto& getCellsNeighboursLUT() { return mCellsNeighboursLUT; }
172 auto& getRoads() { return mRoads; }
173 auto& getTracks(int rofId) { return mTracks[rofId]; }
174 auto& getTracksLabel(const int rofId) { return mTracksLabel[rofId]; }
175 auto& getLinesLabel(const int rofId) { return mLinesLabels[rofId]; }
176 auto& getVerticesMCRecInfo() { return mVerticesMCRecInfo; }
177
179 virtual int getNumberOfCells() const;
180 virtual int getNumberOfTracklets() const;
181 virtual int getNumberOfNeighbours() const;
182 size_t getNumberOfTracks() const;
186
188 void setMemoryPool(std::shared_ptr<BoundedMemoryResource>& pool);
189 auto& getMemoryPool() const noexcept { return mMemoryPool; }
190 bool checkMemory(unsigned long max) { return getArtefactsMemory() < max; }
191 unsigned long getArtefactsMemory() const;
192 void printArtefactsMemory() const;
193
195 int getROFCutClusterMult() const { return mCutClusterMult; };
196 int getROFCutVertexMult() const { return mCutVertexMult; };
197 int getROFCutAllMult() const { return mCutClusterMult + mCutVertexMult; }
198
199 // Vertexer
202 int& getNTrackletsROF(int rofId, int combId) { return mNTrackletsPerROF[combId][rofId]; }
203 auto& getLines(int rofId) { return mLines[rofId]; }
204 int getNLinesTotal() const
205 {
206 return std::accumulate(mLines.begin(), mLines.end(), 0, [](int sum, const auto& l) { return sum + l.size(); });
207 }
208 auto& getTrackletClusters(int rofId) { return mTrackletClusters[rofId]; }
209 gsl::span<const Tracklet> getFoundTracklets(int rofId, int combId) const;
210 gsl::span<Tracklet> getFoundTracklets(int rofId, int combId);
211 gsl::span<const MCCompLabel> getLabelsFoundTracklets(int rofId, int combId) const;
212 gsl::span<int> getNTrackletsCluster(int rofId, int combId);
213 gsl::span<int> getExclusiveNTrackletsCluster(int rofId, int combId);
214 uint32_t getTotalTrackletsTF(const int iLayer) { return mTotalTracklets[iLayer]; }
215 int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const;
216 std::array<float, 2>& getBeamXY() { return mBeamPos; }
217 unsigned int& getNoVertexROF() { return mNoVertexROF; }
218 void insertPastVertex(const Vertex& vertex, const int refROFId);
219 // \Vertexer
220
222 void setRoadLabel(int i, const unsigned long long& lab, bool fake);
223 const unsigned long long& getRoadLabel(int i) const { return mRoadLabels[i].first; }
224 bool isRoadFake(int i) const { return mRoadLabels[i].second; }
225
226 void setMultiplicityCutMask(const std::vector<uint8_t>& cutMask) { mMultiplicityCutMask = cutMask; }
227 void setROFMask(const std::vector<uint8_t>& rofMask) { mROFMask = rofMask; }
228 void swapMasks() { mMultiplicityCutMask.swap(mROFMask); }
229
230 int hasBogusClusters() const { return std::accumulate(mBogusClusters.begin(), mBogusClusters.end(), 0); }
231
232 void setBz(float bz) { mBz = bz; }
233 float getBz() const { return mBz; }
234
236 {
237 if (mIsGPU) {
238 LOGP(debug, "Setting timeFrame allocator to external");
239 mAllocator = allocator;
240 mExtAllocator = true; // to be removed
241 } else {
242 LOGP(fatal, "External allocator is currently only supported for GPU");
243 }
244 }
245
247
249 {
250 return;
251 };
253
254 template <typename... T>
255 void addClusterToLayer(int layer, T&&... args);
256 template <typename... T>
257 void addTrackingFrameInfoToLayer(int layer, T&&... args);
258 void addClusterExternalIndexToLayer(int layer, const int idx) { mClusterExternalIndices[layer].push_back(idx); }
259
260 void resetVectors();
261 void resetTracklets();
262
264 void checkTrackletLUTs();
265 void printROFoffsets();
266 void printNClsPerROF();
267 void printVertices();
268 void printTrackletLUTonLayer(int i);
269 void printCellLUTonLayer(int i);
270 void printTrackletLUTs();
271 void printCellLUTs();
272 void printSliceInfo(const int, const int);
273
275
276 bool mIsGPU = false;
277
278 std::array<bounded_vector<Cluster>, nLayers> mClusters;
279 std::array<bounded_vector<TrackingFrameInfo>, nLayers> mTrackingFrameInfo;
280 std::array<bounded_vector<int>, nLayers> mClusterExternalIndices;
281 std::array<bounded_vector<int>, nLayers> mROFramesClusters;
283 std::array<bounded_vector<int>, 2> mNTrackletsPerCluster;
284 std::array<bounded_vector<int>, 2> mNTrackletsPerClusterSum;
285 std::array<bounded_vector<int>, nLayers> mNClustersPerROF;
286 std::array<bounded_vector<int>, nLayers> mIndexTables;
287 std::vector<bounded_vector<int>> mTrackletsLookupTable;
288 std::array<bounded_vector<uint8_t>, nLayers> mUsedClusters;
289 int mNrof = 0;
294
295 // State if memory will be externally managed.
296 bool mExtAllocator = false;
298 bool getExtAllocator() const { return mExtAllocator; }
299
300 std::array<bounded_vector<Cluster>, nLayers> mUnsortedClusters;
301 std::vector<bounded_vector<Tracklet>> mTracklets;
302 std::vector<bounded_vector<CellSeed>> mCells;
304 std::vector<bounded_vector<TrackITSExt>> mTracks;
305 std::vector<bounded_vector<int>> mCellsNeighbours;
306 std::vector<bounded_vector<int>> mCellsLookupTable;
307 std::vector<uint8_t> mMultiplicityCutMask;
308
309 const o2::base::PropagatorImpl<float>* mPropagatorDevice = nullptr; // Needed only for GPU
310
311 virtual void wipe();
312
313 private:
314 void prepareClusters(const TrackingParameters& trkParam, const int maxLayers = nLayers);
315 float mBz = 5.;
316 unsigned int mNTotalLowPtVertices = 0;
317 int mBeamPosWeight = 0;
318 std::array<float, 2> mBeamPos = {0.f, 0.f};
319 bool isBeamPositionOverridden = false;
320 std::array<float, nLayers> mMinR;
321 std::array<float, nLayers> mMaxR;
322 bounded_vector<float> mMSangles;
323 bounded_vector<float> mPhiCuts;
324 bounded_vector<float> mPositionResolution;
325 bounded_vector<uint8_t> mClusterSize;
326
327 std::vector<uint8_t> mROFMask;
329 std::vector<bounded_vector<MCCompLabel>> mTrackletLabels;
330 std::vector<bounded_vector<MCCompLabel>> mCellLabels;
331 std::vector<bounded_vector<int>> mCellsNeighboursLUT;
332 std::vector<bounded_vector<MCCompLabel>> mTracksLabel;
333 bounded_vector<int> mBogusClusters;
334
336 int mCutClusterMult{-999};
337 int mCutVertexMult{-999};
338
339 // Vertexer
340 std::vector<bounded_vector<int>> mNTrackletsPerROF;
341 std::vector<bounded_vector<Line>> mLines;
342 std::vector<bounded_vector<ClusterLines>> mTrackletClusters;
343 std::array<bounded_vector<int>, 2> mTrackletsIndexROF;
344 std::vector<bounded_vector<MCCompLabel>> mLinesLabels;
345 std::vector<std::pair<MCCompLabel, float>> mVerticesMCRecInfo;
346 bounded_vector<MCCompLabel> mVerticesContributorLabels;
347 std::array<uint32_t, 2> mTotalTracklets = {0, 0};
348 unsigned int mNoVertexROF = 0;
349 bounded_vector<int> mTotVertPerIteration;
350 // \Vertexer
351
352 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
353};
354
355template <int nLayers>
356inline gsl::span<const Vertex> TimeFrame<nLayers>::getPrimaryVertices(int rofId) const
357{
358 if (mPrimaryVertices.empty()) {
359 return {};
360 }
361 const int start = mROFramesPV[rofId];
362 const int stop_idx = rofId >= mNrof - 1 ? mNrof : rofId + 1;
363 int delta = mMultiplicityCutMask[rofId] ? mROFramesPV[stop_idx] - start : 0; // return empty span if Rof is excluded
364 return {&mPrimaryVertices[start], static_cast<gsl::span<const Vertex>::size_type>(delta)};
365}
366
367template <int nLayers>
368inline gsl::span<const std::pair<MCCompLabel, float>> TimeFrame<nLayers>::getPrimaryVerticesMCRecInfo(const int rofId) const
369{
370 const int start = mROFramesPV[rofId];
371 const int stop_idx = rofId >= mNrof - 1 ? mNrof : rofId + 1;
372 int delta = mMultiplicityCutMask[rofId] ? mROFramesPV[stop_idx] - start : 0; // return empty span if Rof is excluded
373 return {&(mVerticesMCRecInfo[start]), static_cast<gsl::span<const std::pair<MCCompLabel, float>>::size_type>(delta)};
374}
375
376template <int nLayers>
377inline gsl::span<const MCCompLabel> TimeFrame<nLayers>::getPrimaryVerticesContributors(const int rofId) const
378{
379 // count the number of cont. in rofs before target rof
380 unsigned int start{0}, delta{0};
381 const auto& pvsBefore = getPrimaryVertices(0, rofId - 1);
382 for (const auto& pv : pvsBefore) {
383 start += pv.getNContributors();
384 }
385 const auto& pvsIn = getPrimaryVertices(rofId);
386 for (const auto& pv : pvsIn) {
387 delta += pv.getNContributors();
388 }
389 return {&(mVerticesContributorLabels[start]), static_cast<gsl::span<const MCCompLabel>::size_type>(delta)};
390}
391
392template <int nLayers>
393inline gsl::span<const Vertex> TimeFrame<nLayers>::getPrimaryVertices(int romin, int romax) const
394{
395 if (mPrimaryVertices.empty()) {
396 return {};
397 }
398 const int stop_idx = romax >= mNrof - 1 ? mNrof : romax + 1;
399 return {&mPrimaryVertices[mROFramesPV[romin]], static_cast<gsl::span<const Vertex>::size_type>(mROFramesPV[stop_idx] - mROFramesPV[romin])};
400}
401
402template <int nLayers>
403inline gsl::span<const std::array<float, 2>> TimeFrame<nLayers>::getPrimaryVerticesXAlpha(int rofId) const
404{
405 const int start = mROFramesPV[rofId];
406 const int stop_idx = rofId >= mNrof - 1 ? mNrof : rofId + 1;
407 int delta = mMultiplicityCutMask[rofId] ? mROFramesPV[stop_idx] - start : 0; // return empty span if Rof is excluded
408 return {&(mPValphaX[start]), static_cast<gsl::span<const std::array<float, 2>>::size_type>(delta)};
409}
410
411template <int nLayers>
413{
414 return rofId < 0 ? mPrimaryVertices.size() : mROFramesPV[rofId + 1] - mROFramesPV[rofId];
415}
416
417template <int nLayers>
418inline void TimeFrame<nLayers>::resetBeamXY(const float x, const float y, const float w)
419{
420 mBeamPos[0] = x;
421 mBeamPos[1] = y;
422 mBeamPosWeight = w;
423}
424
425template <int nLayers>
426inline gsl::span<const int> TimeFrame<nLayers>::getROFrameClusters(int layerId) const
427{
428 return {&mROFramesClusters[layerId][0], static_cast<gsl::span<const int>::size_type>(mROFramesClusters[layerId].size())};
429}
430
431template <int nLayers>
432inline gsl::span<Cluster> TimeFrame<nLayers>::getClustersOnLayer(int rofId, int layerId)
433{
434 if (rofId < 0 || rofId >= mNrof) {
435 return {};
436 }
437 int startIdx{mROFramesClusters[layerId][rofId]};
438 return {&mClusters[layerId][startIdx], static_cast<gsl::span<Cluster>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
439}
440
441template <int nLayers>
442inline gsl::span<const Cluster> TimeFrame<nLayers>::getClustersOnLayer(int rofId, int layerId) const
443{
444 if (rofId < 0 || rofId >= mNrof) {
445 return {};
446 }
447 int startIdx{mROFramesClusters[layerId][rofId]};
448 return {&mClusters[layerId][startIdx], static_cast<gsl::span<const Cluster>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
449}
450
451template <int nLayers>
452inline gsl::span<uint8_t> TimeFrame<nLayers>::getUsedClustersROF(int rofId, int layerId)
453{
454 if (rofId < 0 || rofId >= mNrof) {
455 return {};
456 }
457 int startIdx{mROFramesClusters[layerId][rofId]};
458 return {&mUsedClusters[layerId][startIdx], static_cast<gsl::span<uint8_t>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
459}
460
461template <int nLayers>
462inline gsl::span<const uint8_t> TimeFrame<nLayers>::getUsedClustersROF(int rofId, int layerId) const
463{
464 if (rofId < 0 || rofId >= mNrof) {
465 return {};
466 }
467 int startIdx{mROFramesClusters[layerId][rofId]};
468 return {&mUsedClusters[layerId][startIdx], static_cast<gsl::span<const uint8_t>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
469}
470
471template <int nLayers>
472inline gsl::span<const Cluster> TimeFrame<nLayers>::getClustersPerROFrange(int rofMin, int range, int layerId) const
473{
474 if (rofMin < 0 || rofMin >= mNrof) {
475 return {};
476 }
477 int startIdx{mROFramesClusters[layerId][rofMin]}; // First cluster of rofMin
478 int endIdx{mROFramesClusters[layerId][o2::gpu::CAMath::Min(rofMin + range, mNrof)]};
479 return {&mClusters[layerId][startIdx], static_cast<gsl::span<Cluster>::size_type>(endIdx - startIdx)};
480}
481
482template <int nLayers>
483inline gsl::span<const int> TimeFrame<nLayers>::getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const
484{
485 int chkdRange{o2::gpu::CAMath::Min(range, mNrof - rofMin)};
486 return {&mROFramesClusters[layerId][rofMin], static_cast<gsl::span<int>::size_type>(chkdRange)};
487}
488
489template <int nLayers>
490inline gsl::span<const int> TimeFrame<nLayers>::getNClustersROFrange(int rofMin, int range, int layerId) const
491{
492 int chkdRange{o2::gpu::CAMath::Min(range, mNrof - rofMin)};
493 return {&mNClustersPerROF[layerId][rofMin], static_cast<gsl::span<int>::size_type>(chkdRange)};
494}
495
496template <int nLayers>
497inline int TimeFrame<nLayers>::getTotalClustersPerROFrange(int rofMin, int range, int layerId) const
498{
499 int startIdx{rofMin}; // First cluster of rofMin
500 int endIdx{o2::gpu::CAMath::Min(rofMin + range, mNrof)};
501 return mROFramesClusters[layerId][endIdx] - mROFramesClusters[layerId][startIdx];
502}
503
504template <int nLayers>
505inline gsl::span<const int> TimeFrame<nLayers>::getIndexTablePerROFrange(int rofMin, int range, int layerId) const
506{
507 const int iTableSize{mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1};
508 int chkdRange{o2::gpu::CAMath::Min(range, mNrof - rofMin)};
509 return {&mIndexTables[layerId][rofMin * iTableSize], static_cast<gsl::span<int>::size_type>(chkdRange * iTableSize)};
510}
511
512template <int nLayers>
513inline int TimeFrame<nLayers>::getClusterROF(int iLayer, int iCluster)
514{
515 return std::lower_bound(mROFramesClusters[iLayer].begin(), mROFramesClusters[iLayer].end(), iCluster + 1) - mROFramesClusters[iLayer].begin() - 1;
516}
517
518template <int nLayers>
519inline gsl::span<const Cluster> TimeFrame<nLayers>::getUnsortedClustersOnLayer(int rofId, int layerId) const
520{
521 if (rofId < 0 || rofId >= mNrof) {
522 return {};
523 }
524 int startIdx{mROFramesClusters[layerId][rofId]};
525 return {&mUnsortedClusters[layerId][startIdx], static_cast<gsl::span<Cluster>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
526}
527
528template <int nLayers>
529inline gsl::span<int> TimeFrame<nLayers>::getIndexTable(int rofId, int layer)
530{
531 if (rofId < 0 || rofId >= mNrof) {
532 return {};
533 }
534 const int tableSize = mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1;
535 return {&mIndexTables[layer][rofId * tableSize], static_cast<gsl::span<int>::size_type>(tableSize)};
536}
537
538template <int nLayers>
539template <typename... T>
541{
542 mUnsortedClusters[layer].emplace_back(std::forward<T>(values)...);
543}
544
545template <int nLayers>
546template <typename... T>
548{
549 mTrackingFrameInfo[layer].emplace_back(std::forward<T>(values)...);
550}
551
552template <int nLayers>
553inline gsl::span<uint8_t> TimeFrame<nLayers>::getUsedClusters(const int layer)
554{
555 return {&mUsedClusters[layer][0], static_cast<gsl::span<uint8_t>::size_type>(mUsedClusters[layer].size())};
556}
557
558template <int nLayers>
560{
561 mRoadLabels.clear();
562 mRoadLabels.resize(mRoads.size());
563}
564
565template <int nLayers>
566inline void TimeFrame<nLayers>::setRoadLabel(int i, const unsigned long long& lab, bool fake)
567{
568 mRoadLabels[i].first = lab;
569 mRoadLabels[i].second = fake;
570}
571
572template <int nLayers>
573inline gsl::span<int> TimeFrame<nLayers>::getNTrackletsCluster(int rofId, int combId)
574{
575 if (rofId < 0 || rofId >= mNrof) {
576 return {};
577 }
578 auto startIdx{mROFramesClusters[1][rofId]};
579 return {&mNTrackletsPerCluster[combId][startIdx], static_cast<gsl::span<int>::size_type>(mROFramesClusters[1][rofId + 1] - startIdx)};
580}
581
582template <int nLayers>
583inline gsl::span<int> TimeFrame<nLayers>::getExclusiveNTrackletsCluster(int rofId, int combId)
584{
585 if (rofId < 0 || rofId >= mNrof) {
586 return {};
587 }
588 auto clusStartIdx{mROFramesClusters[1][rofId]};
589
590 return {&mNTrackletsPerClusterSum[combId][clusStartIdx], static_cast<gsl::span<int>::size_type>(mROFramesClusters[1][rofId + 1] - clusStartIdx)};
591}
592
593template <int nLayers>
594inline gsl::span<Tracklet> TimeFrame<nLayers>::getFoundTracklets(int rofId, int combId)
595{
596 if (rofId < 0 || rofId >= mNrof || mTracklets[combId].empty()) {
597 return {};
598 }
599 auto startIdx{mNTrackletsPerROF[combId][rofId]};
600 return {&mTracklets[combId][startIdx], static_cast<gsl::span<Tracklet>::size_type>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
601}
602
603template <int nLayers>
604inline gsl::span<const Tracklet> TimeFrame<nLayers>::getFoundTracklets(int rofId, int combId) const
605{
606 if (rofId < 0 || rofId >= mNrof) {
607 return {};
608 }
609 auto startIdx{mNTrackletsPerROF[combId][rofId]};
610 return {&mTracklets[combId][startIdx], static_cast<gsl::span<Tracklet>::size_type>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
611}
612
613template <int nLayers>
614inline gsl::span<const MCCompLabel> TimeFrame<nLayers>::getLabelsFoundTracklets(int rofId, int combId) const
615{
616 if (rofId < 0 || rofId >= mNrof || !hasMCinformation()) {
617 return {};
618 }
619 auto startIdx{mNTrackletsPerROF[combId][rofId]};
620 return {&mTrackletLabels[combId][startIdx], static_cast<gsl::span<Tracklet>::size_type>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
621}
622
623template <int nLayers>
625{
626 size_t totalClusters{0};
627 for (const auto& clusters : mUnsortedClusters) {
628 totalClusters += clusters.size();
629 }
630 return int(totalClusters);
631}
632
633template <int nLayers>
635{
636 int nClusters = 0;
637 for (const auto& layer : mClusters) {
638 nClusters += layer.size();
639 }
640 return nClusters;
641}
642
643template <int nLayers>
645{
646 int nCells = 0;
647 for (const auto& layer : mCells) {
648 nCells += layer.size();
649 }
650 return nCells;
651}
652
653template <int nLayers>
655{
656 int nTracklets = 0;
657 for (const auto& layer : mTracklets) {
658 nTracklets += layer.size();
659 }
660 return nTracklets;
661}
662
663template <int nLayers>
665{
666 int n{0};
667 for (const auto& l : mCellsNeighbours) {
668 n += l.size();
669 }
670 return n;
671}
672
673template <int nLayers>
675{
676 int nTracks = 0;
677 for (const auto& t : mTracks) {
678 nTracks += t.size();
679 }
680 return nTracks;
681}
682
683template <int nLayers>
685{
686 size_t nClusters = 0;
687 for (const auto& layer : mUsedClusters) {
688 nClusters += std::count(layer.begin(), layer.end(), true);
689 }
690 return nClusters;
691}
692
693template <int nLayers>
694inline void TimeFrame<nLayers>::insertPastVertex(const Vertex& vertex, const int iteration)
695{
696 int rofId = vertex.getTimeStamp().getTimeStamp();
697 mPrimaryVertices.insert(mPrimaryVertices.begin() + mROFramesPV[rofId], vertex);
698 for (int i = rofId + 1; i < mROFramesPV.size(); ++i) {
699 mROFramesPV[i]++;
700 }
701 mTotVertPerIteration[iteration]++;
702}
703
704} // namespace its
705} // namespace o2
706
707#endif
uint64_t vertex
Definition RawEventData.h:9
int32_t i
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the ITS track.
std::ostringstream debug
int nClusters
A container to hold and manage MC truth information/labels.
HMPID cluster implementation.
Definition Cluster.h:27
float sum(float s, o2::dcs::DataPointValue v)
Definition dcs-ccdb.cxx:39
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
GLenum GLint * range
Definition glcorearb.h:1899
GLint y
Definition glcorearb.h:270
GLenum GLsizei GLsizei GLint * values
Definition glcorearb.h:1576
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLuint start
Definition glcorearb.h:469
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
void deepVectorClear(std::vector< T > &vec)
std::pmr::vector< T > bounded_vector
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void empty(int)
auto & getPositionResolutions()
Definition TimeFrame.h:122
void addTrackingFrameInfoToLayer(int layer, T &&... args)
Definition TimeFrame.h:547
IndexTableUtils mIndexTableUtils
Definition TimeFrame.h:274
gsl::span< const MCCompLabel > getPrimaryVerticesContributors(const int rofId) const
Definition TimeFrame.h:377
void checkTrackletLUTs()
Debug and printing.
gsl::span< const Tracklet > getFoundTracklets(int rofId, int combId) const
Definition TimeFrame.h:604
bool checkMemory(unsigned long max)
Definition TimeFrame.h:190
int getClusterROF(int iLayer, int iCluster)
Definition TimeFrame.h:513
auto & getCellsLabel(int layer)
Definition TimeFrame.h:146
void printTrackletLUTonLayer(int i)
bool isClusterUsed(int layer, int clusterId) const
Definition TimeFrame.h:157
int getNrof() const
Definition TimeFrame.h:102
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
float getBeamX() const
Definition TimeFrame.h:111
float getMSangle(int layer) const
Definition TimeFrame.h:117
std::vector< bounded_vector< int > > mCellsLookupTable
Definition TimeFrame.h:306
bool hasMCinformation() const
Definition TimeFrame.h:148
auto & getIndexTableWhole(int layerId)
Definition TimeFrame.h:135
std::array< bounded_vector< int >, 2 > mNTrackletsPerClusterSum
Definition TimeFrame.h:284
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const int clId) const
Definition TimeFrame.h:140
auto & getTracks(int rofId)
Definition TimeFrame.h:173
size_t getNumberOfTracks() const
Definition TimeFrame.h:674
unsigned int & getNoVertexROF()
Definition TimeFrame.h:217
ExternalAllocator * mAllocator
Definition TimeFrame.h:297
virtual ~TimeFrame()
Definition TimeFrame.cxx:56
int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:497
virtual int getNumberOfTracklets() const
Definition TimeFrame.h:654
auto & getTrackletsLabel(int layer)
Definition TimeFrame.h:145
std::vector< bounded_vector< Tracklet > > mTracklets
Definition TimeFrame.h:301
gsl::span< const std::pair< MCCompLabel, float > > getPrimaryVerticesMCRecInfo(const int rofId) const
Definition TimeFrame.h:368
void computeTracletsPerClusterScans()
void setBz(float bz)
Definition TimeFrame.h:232
gsl::span< uint8_t > getUsedClustersROF(int rofId, int layerId)
Definition TimeFrame.h:452
const TrackingFrameInfo & getClusterTrackingFrameInfo(int layerId, const Cluster &cl) const
auto & getMSangles()
Definition TimeFrame.h:118
int getClusterExternalIndex(int layerId, const int clId) const
Definition TimeFrame.h:141
virtual void wipe()
void resetBeamXY(const float x, const float y, const float w=0)
Definition TimeFrame.h:418
void addPrimaryVerticesInROF(const bounded_vector< Vertex > &vertices, const int rofId, const int iteration)
Definition TimeFrame.cxx:90
gsl::span< const int > getIndexTablePerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:505
gsl::span< const Cluster > getClustersOnLayer(int rofId, int layerId) const
Definition TimeFrame.h:442
bounded_vector< int > mROFramesPV
Definition TimeFrame.h:292
std::array< float, 2 > & getBeamXY()
Definition TimeFrame.h:216
std::array< bounded_vector< int >, nLayers > mClusterExternalIndices
Definition TimeFrame.h:280
bool getExtAllocator() const
Definition TimeFrame.h:298
bool isRoadFake(int i) const
Definition TimeFrame.h:224
gsl::span< const Vertex > getPrimaryVertices(int romin, int romax) const
Definition TimeFrame.h:393
void printSliceInfo(const int, const int)
int getNLinesTotal() const
Definition TimeFrame.h:204
auto & getTrackletsLookupTable()
Definition TimeFrame.h:162
void setClusterSize(bounded_vector< uint8_t > &v)
Definition TimeFrame.h:143
float getBz() const
Definition TimeFrame.h:233
bounded_vector< Vertex > mPrimaryVertices
Definition TimeFrame.h:293
int getROFCutAllMult() const
Definition TimeFrame.h:197
int getROFCutVertexMult() const
Definition TimeFrame.h:196
std::array< bounded_vector< int >, nLayers > mROFramesClusters
Definition TimeFrame.h:281
std::vector< uint8_t > mMultiplicityCutMask
Definition TimeFrame.h:307
float getPhiCut(int layer) const
Definition TimeFrame.h:119
auto & getTracklets()
Definition TimeFrame.h:161
int getTotalClusters() const
Definition TimeFrame.h:624
gsl::span< int > getExclusiveNTrackletsCluster(int rofId, int combId)
Definition TimeFrame.h:583
void setMultiplicityCutMask(const std::vector< uint8_t > &cutMask)
Definition TimeFrame.h:226
auto & getTrackletClusters(int rofId)
Definition TimeFrame.h:208
std::vector< bounded_vector< int > > mTrackletsLookupTable
Definition TimeFrame.h:287
gsl::span< const Cluster > getUnsortedClustersOnLayer(int rofId, int layerId) const
Definition TimeFrame.h:519
const o2::base::PropagatorImpl< float > * getDevicePropagator() const
Definition TimeFrame.h:252
void computeTrackletsPerROFScans()
gsl::span< const std::array< float, 2 > > getPrimaryVerticesXAlpha(int rofId) const
Definition TimeFrame.h:403
size_t getNumberOfUsedClusters() const
Definition TimeFrame.h:684
gsl::span< int > getIndexTable(int rofId, int layerId)
Definition TimeFrame.h:529
void addPrimaryVerticesLabelsInROF(const bounded_vector< std::pair< MCCompLabel, float > > &labels, const int rofId)
auto & getCellsLookupTable()
Definition TimeFrame.h:169
void setBeamPosition(const float x, const float y, const float s2, const float base=50.f, const float systematic=0.f)
Definition TimeFrame.h:105
bounded_vector< Road< nLayers - 2 > > mRoads
Definition TimeFrame.h:303
std::array< bounded_vector< int >, nLayers > mIndexTables
Definition TimeFrame.h:286
const auto & getTrackingFrameInfoOnLayer(int layerId) const
Definition TimeFrame.h:136
auto & getTotVertIteration()
Definition TimeFrame.h:98
float getMaxR(int layer) const
Definition TimeFrame.h:116
auto & getVerticesMCRecInfo()
Definition TimeFrame.h:176
void insertPastVertex(const Vertex &vertex, const int refROFId)
Definition TimeFrame.h:694
gsl::span< const int > getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:483
float getPositionResolution(int layer) const
Definition TimeFrame.h:121
std::vector< bounded_vector< TrackITSExt > > mTracks
Definition TimeFrame.h:304
int getPrimaryVerticesNum(int rofId=-1) const
Definition TimeFrame.h:412
void addPrimaryVerticesContributorLabelsInROF(const bounded_vector< MCCompLabel > &labels, const int rofId)
void setROFMask(const std::vector< uint8_t > &rofMask)
Definition TimeFrame.h:227
gsl::span< unsigned char > getUsedClusters(const int layer)
Definition TimeFrame.h:553
void addClusterExternalIndexToLayer(int layer, const int idx)
Definition TimeFrame.h:258
void addPrimaryVerticesLabels(bounded_vector< std::pair< MCCompLabel, float > > &labels)
Definition TimeFrame.cxx:78
gsl::span< const MCCompLabel > getLabelsFoundTracklets(int rofId, int combId) const
Definition TimeFrame.h:614
int loadROFrameData(const o2::itsmft::ROFRecord &rof, gsl::span< const itsmft::Cluster > clusters, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
std::array< bounded_vector< int >, 2 > mNTrackletsPerCluster
Definition TimeFrame.h:283
virtual int getNumberOfCells() const
Definition TimeFrame.h:644
void setExternalAllocator(ExternalAllocator *allocator)
Definition TimeFrame.h:235
gsl::span< const Cluster > getClustersPerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:472
gsl::span< const Vertex > getPrimaryVertices(int rofId) const
Definition TimeFrame.h:356
void fillPrimaryVerticesXandAlpha()
const dataformats::MCTruthContainer< MCCompLabel > * mClusterLabels
Definition TimeFrame.h:282
void initialiseRoadLabels()
Definition TimeFrame.h:559
auto getNumberOfUsedExtendedClusters() const
Definition TimeFrame.h:185
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > &pool)
memory management
gsl::span< Cluster > getClustersOnLayer(int rofId, int layerId)
Definition TimeFrame.h:432
bool empty() const
Definition TimeFrame.h:99
auto & getPhiCuts()
Definition TimeFrame.h:120
auto & getLinesLabel(const int rofId)
Definition TimeFrame.h:175
int getSortedStartIndex(const int rofId, const int layer) const
Definition TimeFrame.h:101
auto & getClusters()
Definition TimeFrame.h:164
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const Cluster &cl) const
Definition TimeFrame.h:139
const Vertex & getPrimaryVertex(const int ivtx) const
Definition TimeFrame.h:72
ExternalAllocator * getExternalAllocator()
Definition TimeFrame.h:246
virtual void setDevicePropagator(const o2::base::PropagatorImpl< float > *)
Definition TimeFrame.h:248
std::vector< bounded_vector< int > > mCellsNeighbours
Definition TimeFrame.h:305
std::vector< bounded_vector< CellSeed > > mCells
Definition TimeFrame.h:302
gsl::span< Tracklet > getFoundTracklets(int rofId, int combId)
Definition TimeFrame.h:594
std::array< bounded_vector< Cluster >, nLayers > mUnsortedClusters
Definition TimeFrame.h:300
void addClusterToLayer(int layer, T &&... args)
Definition TimeFrame.h:540
unsigned long getArtefactsMemory() const
float getMinR(int layer) const
Definition TimeFrame.h:115
std::array< bounded_vector< uint8_t >, nLayers > mUsedClusters
Definition TimeFrame.h:288
gsl::span< const int > getROFrameClusters(int layerId) const
Definition TimeFrame.h:426
void removePrimaryVerticesInROf(const int rofId)
const o2::base::PropagatorImpl< float > * mPropagatorDevice
Definition TimeFrame.h:309
void printCellLUTonLayer(int i)
virtual int getNumberOfNeighbours() const
Definition TimeFrame.h:664
void printArtefactsMemory() const
auto & getTracksLabel(const int rofId)
Definition TimeFrame.h:174
float getBeamY() const
Definition TimeFrame.h:112
std::array< bounded_vector< int >, nLayers > mNClustersPerROF
Definition TimeFrame.h:285
int getROFCutClusterMult() const
ROF cuts.
Definition TimeFrame.h:195
std::array< bounded_vector< TrackingFrameInfo >, nLayers > mTrackingFrameInfo
Definition TimeFrame.h:279
gsl::span< int > getNTrackletsCluster(int rofId, int combId)
Definition TimeFrame.h:573
auto & getCellsNeighbours()
Definition TimeFrame.h:170
void markUsedCluster(int layer, int clusterId)
Definition TimeFrame.h:158
std::array< bounded_vector< Cluster >, nLayers > mClusters
Definition TimeFrame.h:278
uint32_t getTotalTrackletsTF(const int iLayer)
Definition TimeFrame.h:214
void addPrimaryVerticesContributorLabels(bounded_vector< MCCompLabel > &labels)
Definition TimeFrame.cxx:84
auto getNumberOfExtendedTracks() const
Definition TimeFrame.h:184
int hasBogusClusters() const
Definition TimeFrame.h:230
auto & getUnsortedClusters()
Definition TimeFrame.h:165
auto & getCellsNeighboursLUT()
Definition TimeFrame.h:171
int & getNTrackletsROF(int rofId, int combId)
Definition TimeFrame.h:202
int getNumberOfClusters() const
Definition TimeFrame.h:634
void setRoadLabel(int i, const unsigned long long &lab, bool fake)
Definition TimeFrame.h:566
auto & getMemoryPool() const noexcept
Definition TimeFrame.h:189
auto & getLines(int rofId)
Definition TimeFrame.h:203
int getClusterSize(int clusterId) const
Definition TimeFrame.h:142
gsl::span< const uint8_t > getUsedClustersROF(int rofId, int layerId) const
Definition TimeFrame.h:462
gsl::span< const int > getNClustersROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:490
int getSortedIndex(int rofId, int layer, int idx) const
Definition TimeFrame.h:100
const unsigned long long & getRoadLabel(int i) const
Definition TimeFrame.h:223
constexpr size_t max
std::vector< Cluster > clusters