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