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