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