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
25
27#include "ITStracking/Cell.h"
28#include "ITStracking/Cluster.h"
40
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{
60
64
65namespace gpu
66{
67template <int>
68class TimeFrameGPU;
69}
70
71template <int NLayers>
72struct TimeFrame {
79 friend class gpu::TimeFrameGPU<NLayers>;
80
82 virtual ~TimeFrame();
83 TimeFrame(const TimeFrame&) = delete;
84 TimeFrame& operator=(const TimeFrame&) = delete;
85
86 const Vertex& getPrimaryVertex(const int ivtx) const { return mPrimaryVertices[ivtx]; }
88 auto getPrimaryVerticesNum() { return mPrimaryVertices.size(); };
89 const auto& getPrimaryVertices() const { return mPrimaryVertices; };
91 gsl::span<const Vertex> getPrimaryVertices(int layer, int rofId) const;
92 void addPrimaryVertex(const Vertex& vertex);
94
95 // read-in data
96 void loadROFrameData(gsl::span<const o2::itsmft::ROFRecord> rofs,
97 gsl::span<const itsmft::CompClusterExt> clusters,
98 gsl::span<const unsigned char>::iterator& pattIt,
100 int layer,
101 const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
102 void resetROFrameData(int iLayer);
103 void prepareROFrameData(gsl::span<const itsmft::CompClusterExt> clusters, int layer);
104
105 int getTotalClusters() const;
106 bool empty() const { return getTotalClusters() == 0; }
107 int getSortedIndex(int rofId, int layer, int idx) const { return mROFramesClusters[layer][rofId] + idx; }
108 int getSortedStartIndex(const int rofId, const int layer) const { return mROFramesClusters[layer][rofId]; }
109 int getNrof(int layer) const { return mROFramesClusters[layer].size() - 1; }
110
111 void resetBeamXY(const float x, const float y, const float w = 0);
112 void setBeamPosition(const float x, const float y, const float s2, const float base = 50.f, const float systematic = 0.f)
113 {
115 resetBeamXY(x, y, s2 / o2::gpu::CAMath::Sqrt((base * base) + systematic));
116 }
117
118 float getBeamX() const { return mBeamPos[0]; }
119 float getBeamY() const { return mBeamPos[1]; }
121 std::array<float, 2>& getBeamXY() { return mBeamPos; }
122
123 auto& getMinRs() { return mMinR; }
124 auto& getMaxRs() { return mMaxR; }
125 float getMinR(int layer) const { return mMinR[layer]; }
126 float getMaxR(int layer) const { return mMaxR[layer]; }
127 float getLinkPhiCut(int linkId) const { return mLinkPhiCuts[linkId]; }
128 float getLinkMSAngle(int linkId) const { return mLinkMSAngles[linkId]; }
129 auto& getLinkPhiCuts() { return mLinkPhiCuts; }
130 auto& getLinkMSAngles() { return mLinkMSAngles; }
133
134 gsl::span<Cluster> getClustersOnLayer(int rofId, int layerId);
135 gsl::span<const Cluster> getClustersOnLayer(int rofId, int layerId) const;
136 gsl::span<const Cluster> getClustersPerROFrange(int rofMin, int range, int layerId) const;
137 gsl::span<const Cluster> getUnsortedClustersOnLayer(int rofId, int layerId) const;
138 gsl::span<uint8_t> getUsedClustersROF(int rofId, int layerId);
139 gsl::span<const uint8_t> getUsedClustersROF(int rofId, int layerId) const;
140 gsl::span<const int> getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const;
141 gsl::span<const int> getROFrameClusters(int layerId) const;
142 gsl::span<const int> getNClustersROFrange(int rofMin, int range, int layerId) const;
143 gsl::span<int> getIndexTable(int rofId, int layerId);
144 const auto& getTrackingFrameInfoOnLayer(int layerId) const { return mTrackingFrameInfo[layerId]; }
145
146 // navigation tables
147 const auto& getIndexTableUtils() const { return mIndexTableUtils; }
148 const auto& getROFOverlapTable() const { return mROFOverlapTable; }
149 const auto& getROFOverlapTableView() const { return mROFOverlapTableView; }
150 const auto& getTrackerTopologies() const { return mTrackerTopologies; }
151 const auto& getTrackingTopologyView() const { return mTrackingTopologyView; }
153 {
154 mROFOverlapTable = std::move(table);
156 }
157 const auto& getROFVertexLookupTable() const { return mROFVertexLookupTable; }
166 {
167 mMultiplicityCutMask = std::move(cutMask);
168 mROFMaskView = mROFMask->getView();
169 }
170 void useMultiplictyMask() noexcept
171 {
173 mROFMaskView = mROFMask->getView();
174 }
175 void setUPCCutMask(ROFMaskTableN cutMask) { mUPCCutMask = std::move(cutMask); }
176 void setSeedingUPCMask(ROFMaskTableN cutMask) { mSeedingUPCMask = std::move(cutMask); }
177 void useSeedingUPCMask() noexcept
178 {
180 mROFMaskView = mROFMask->getView();
181 }
182 void useUPCMask() noexcept
183 {
185 mROFMaskView = mROFMask->getView();
186 }
187 const auto& getROFMaskView() const { return mROFMaskView; }
188
189 const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const;
190 gsl::span<const MCCompLabel> getClusterLabels(int layerId, const Cluster& cl) const { return getClusterLabels(layerId, cl.clusterId); }
191 gsl::span<const MCCompLabel> getClusterLabels(int layerId, const int clId) const { return mClusterLabels[((mIsStaggered) ? layerId : 0)]->getLabels(mClusterExternalIndices[layerId][clId]); }
192 int getClusterExternalIndex(int layerId, const int clId) const { return mClusterExternalIndices[layerId][clId]; }
193 int getClusterSize(int layer, int clusterId) const { return mClusterSize[layer][clusterId]; }
194 void setClusterSize(int layer, bounded_vector<uint8_t>& v) { mClusterSize[layer] = std::move(v); }
195
197 auto& getCellsLabel(int layer) { return mCellLabels[layer]; }
198
199 bool hasMCinformation() const { return mClusterLabels[0] != nullptr; }
200 void initVertexingTopology(const TrackingParameters& trkParam);
201 void initDefaultTrackingTopology(const TrackingParameters& trkParam, const int maxLayers = NLayers);
202 void initTrackerTopologies(gsl::span<const TrackingParameters> trkParams, const int maxLayers = NLayers);
203 void initialise(const TrackingParameters& trkParam, const int maxLayers = NLayers, const int iteration = constants::UnusedIndex);
204
205 bool isClusterUsed(int layer, int clusterId) const { return mUsedClusters[layer][clusterId]; }
206 void markUsedCluster(int layer, int clusterId) { mUsedClusters[layer][clusterId] = true; }
207 gsl::span<unsigned char> getUsedClusters(const int layer);
208
209 auto& getTracklets() { return mTracklets; }
211
212 auto& getClusters() { return mClusters; }
214 int getClusterROF(int iLayer, int iCluster);
215 auto& getCells() { return mCells; }
216
221 auto& getTracks() { return mTracks; }
222 auto& getTracksLabel() { return mTracksLabel; }
223 auto& getLinesLabel(const int rofId) { return mLinesLabels[rofId]; }
224
225 size_t getNumberOfClusters() const;
226 virtual size_t getNumberOfCells() const;
227 virtual size_t getNumberOfTracklets() const;
228 virtual size_t getNumberOfNeighbours() const;
229 size_t getNumberOfTracks() const;
232 void addTrackExtensionCounters(size_t nTracks, size_t nClusters);
233 size_t getNExtendedTracks() const { return mNExtendedTracks; }
234 size_t getNExtendedClusters() const { return mNExtendedClusters; }
235
237 void setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool);
238 auto& getMemoryPool() const noexcept { return mMemoryPool; }
239 bool checkMemory(unsigned long max) { return getArtefactsMemory() < max; }
240 unsigned long getArtefactsMemory() const;
241 void printArtefactsMemory() const;
242
244 void setIsStaggered(bool b) noexcept { mIsStaggered = b; }
245
248
249 // Vertexer
252 int& getNTrackletsROF(int rofId, int combId) { return mNTrackletsPerROF[combId][rofId]; }
253 auto& getLines(int rofId) { return mLines[rofId]; }
254 auto& getLinesQuality(int rofId) { return mLinesQuality[rofId]; }
255 const auto& getLinesQuality(int rofId) const { return mLinesQuality[rofId]; }
256 int getNLinesTotal() const noexcept { return mTotalLines; }
257 void setNLinesTotal(uint32_t a) noexcept { mTotalLines = a; }
258 auto& getTrackletClusters(int rofId) { return mTrackletClusters[rofId]; }
259 gsl::span<const Tracklet> getFoundTracklets(int rofId, int combId) const;
260 gsl::span<Tracklet> getFoundTracklets(int rofId, int combId);
261 gsl::span<const MCCompLabel> getLabelsFoundTracklets(int rofId, int combId) const;
262 gsl::span<int> getNTrackletsCluster(int rofId, int combId);
263 gsl::span<int> getExclusiveNTrackletsCluster(int rofId, int combId);
264 uint32_t getTotalTrackletsTF(const int iLayer) { return mTotalTracklets[iLayer]; }
265 int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const;
266 // \Vertexer
267
268 int hasBogusClusters() const { return std::accumulate(mBogusClusters.begin(), mBogusClusters.end(), 0); }
269
270 void setBz(float bz) { mBz = bz; }
271 float getBz() const { return mBz; }
272
275 std::shared_ptr<BoundedMemoryResource> mExtMemoryPool; // host memory pool managed by the framework
278 bool hasFrameworkAllocator() const noexcept { return mExternalAllocator != nullptr; }
279 std::pmr::memory_resource* getMaybeFrameworkHostResource(bool forceHost = false) { return (hasFrameworkAllocator() && !forceHost) ? mExtMemoryPool.get() : mMemoryPool.get(); }
280
281 // Propagator
283 virtual void setDevicePropagator(const o2::base::PropagatorImpl<float>* /*unused*/) {};
284
285 template <typename... T>
286 void addClusterToLayer(int layer, T&&... args);
287 template <typename... T>
288 void addTrackingFrameInfoToLayer(int layer, T&&... args);
289 void addClusterExternalIndexToLayer(int layer, const int idx) { mClusterExternalIndices[layer].push_back(idx); }
290
291 std::array<bounded_vector<Cluster>, NLayers> mClusters;
292 std::array<bounded_vector<TrackingFrameInfo>, NLayers> mTrackingFrameInfo;
294 std::array<bounded_vector<int>, NLayers> mClusterExternalIndices;
295 std::array<bounded_vector<int>, NLayers> mROFramesClusters;
296 std::array<const dataformats::MCTruthContainer<MCCompLabel>*, NLayers> mClusterLabels{nullptr};
297 std::array<bounded_vector<int>, 2> mNTrackletsPerCluster;
298 std::array<bounded_vector<int>, 2> mNTrackletsPerClusterSum;
299 std::array<bounded_vector<int>, NLayers> mNClustersPerROF;
300 std::array<bounded_vector<int>, NLayers> mIndexTables;
301 std::vector<bounded_vector<int>> mTrackletsLookupTable;
302 std::array<bounded_vector<uint8_t>, NLayers> mUsedClusters;
303
304 std::array<bounded_vector<Cluster>, NLayers> mUnsortedClusters;
305 std::vector<bounded_vector<Tracklet>> mTracklets;
306 std::vector<bounded_vector<CellSeed>> mCells;
307 bounded_vector<TrackITSExt> mTracks;
308 bounded_vector<MCCompLabel> mTracksLabel;
311 std::vector<bounded_vector<int>> mCellsNeighbours;
312 std::vector<bounded_vector<int>> mCellsNeighboursTopology;
313 std::vector<bounded_vector<int>> mCellsLookupTable;
314
315 const o2::base::PropagatorImpl<float>* mPropagatorDevice = nullptr; // Needed only for GPU
316
317 virtual void wipe();
318
319 // interface
320 virtual bool isGPU() const noexcept { return false; }
321 virtual const char* getName() const noexcept { return "CPU"; }
322
323 protected:
324 virtual void prepareClusters(const TrackingParameters& trkParam, const int maxLayers = NLayers);
325 virtual void allocateClusterSortStorage(const TrackingParameters& trkParam, const int maxLayers);
326 float mBz = 5.;
327 unsigned int mNTotalLowPtVertices = 0;
329 std::array<float, 2> mBeamPos = {0.f, 0.f};
331 std::array<float, NLayers> mMinR;
332 std::array<float, NLayers> mMaxR;
333 bounded_vector<float> mLinkPhiCuts;
334 bounded_vector<float> mLinkMSAngles;
335 bounded_vector<float> mPositionResolution;
336 std::array<bounded_vector<uint8_t>, NLayers> mClusterSize;
337
338 bounded_vector<std::array<float, 2>> mPValphaX;
339 std::vector<bounded_vector<MCCompLabel>> mTrackletLabels;
340 std::vector<bounded_vector<MCCompLabel>> mCellLabels;
341 std::vector<bounded_vector<int>> mCellsNeighboursLUT;
342 bounded_vector<int> mBogusClusters;
343
345
346 // Vertexer
347 bounded_vector<Vertex> mPrimaryVertices;
348 bounded_vector<VertexLabel> mPrimaryVerticesLabels;
349 std::vector<bounded_vector<int>> mNTrackletsPerROF;
350 std::vector<bounded_vector<Line>> mLines;
351 std::vector<bounded_vector<LineQuality>> mLinesQuality; // lockstep with mLines, see getLinesQuality()
352 std::vector<bounded_vector<ClusterLines>> mTrackletClusters;
353 std::array<bounded_vector<int>, 2> mTrackletsIndexROF;
354 std::vector<bounded_vector<MCCompLabel>> mLinesLabels;
355 std::array<uint32_t, 2> mTotalTracklets = {0, 0};
356 uint32_t mTotalLines = 0;
357 // \Vertexer
358
359 // lookup tables
362 ROFOverlapTableN::View mROFOverlapTableView;
365 std::vector<TrackingTopologyN> mTrackerTopologies;
366 typename TrackingTopologyN::View mTrackingTopologyView;
368 ROFVertexLookupTableN::View mROFVertexLookupTableView;
373 ROFMaskTableN::View mROFMaskView;
374
375 bool mIsStaggered{false};
376
377 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
378};
379
380template <int NLayers>
381gsl::span<const Vertex> TimeFrame<NLayers>::getPrimaryVertices(int layer, int rofId) const
382{
383 if (rofId < 0 || rofId >= getNrof(layer)) {
384 return {};
385 }
386 const auto& entry = mROFVertexLookupTableView.getVertices(layer, rofId);
387 return {&mPrimaryVertices[entry.getFirstEntry()], static_cast<gsl::span<const Vertex>::size_type>(entry.getEntries())};
388}
389
390template <int NLayers>
391inline void TimeFrame<NLayers>::resetBeamXY(const float x, const float y, const float w)
392{
393 mBeamPos[0] = x;
394 mBeamPos[1] = y;
395 mBeamPosWeight = w;
396}
397
398template <int NLayers>
399inline gsl::span<const int> TimeFrame<NLayers>::getROFrameClusters(int layerId) const
400{
401 return {&mROFramesClusters[layerId][0], static_cast<gsl::span<const int>::size_type>(mROFramesClusters[layerId].size())};
402}
403
404template <int NLayers>
405inline gsl::span<Cluster> TimeFrame<NLayers>::getClustersOnLayer(int rofId, int layerId)
406{
407 if (rofId < 0 || rofId >= getNrof(layerId)) {
408 return {};
409 }
410 int startIdx{mROFramesClusters[layerId][rofId]};
411 return {&mClusters[layerId][startIdx], static_cast<gsl::span<Cluster>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
412}
413
414template <int NLayers>
415inline gsl::span<const Cluster> TimeFrame<NLayers>::getClustersOnLayer(int rofId, int layerId) const
416{
417 if (rofId < 0 || rofId >= getNrof(layerId)) {
418 return {};
419 }
420 int startIdx{mROFramesClusters[layerId][rofId]};
421 return {&mClusters[layerId][startIdx], static_cast<gsl::span<const Cluster>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
422}
423
424template <int NLayers>
425inline gsl::span<uint8_t> TimeFrame<NLayers>::getUsedClustersROF(int rofId, int layerId)
426{
427 if (rofId < 0 || rofId >= getNrof(layerId)) {
428 return {};
429 }
430 int startIdx{mROFramesClusters[layerId][rofId]};
431 return {&mUsedClusters[layerId][startIdx], static_cast<gsl::span<uint8_t>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
432}
433
434template <int NLayers>
435inline gsl::span<const uint8_t> TimeFrame<NLayers>::getUsedClustersROF(int rofId, int layerId) const
436{
437 if (rofId < 0 || rofId >= getNrof(layerId)) {
438 return {};
439 }
440 int startIdx{mROFramesClusters[layerId][rofId]};
441 return {&mUsedClusters[layerId][startIdx], static_cast<gsl::span<const uint8_t>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
442}
443
444template <int NLayers>
445inline gsl::span<const Cluster> TimeFrame<NLayers>::getClustersPerROFrange(int rofMin, int range, int layerId) const
446{
447 if (rofMin < 0 || rofMin >= getNrof(layerId)) {
448 return {};
449 }
450 int startIdx{mROFramesClusters[layerId][rofMin]}; // First cluster of rofMin
451 int endIdx{mROFramesClusters[layerId][o2::gpu::CAMath::Min(rofMin + range, getNrof(layerId))]};
452 return {&mClusters[layerId][startIdx], static_cast<gsl::span<Cluster>::size_type>(endIdx - startIdx)};
453}
454
455template <int NLayers>
456inline gsl::span<const int> TimeFrame<NLayers>::getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const
457{
458 int chkdRange{o2::gpu::CAMath::Min(range, getNrof(layerId) - rofMin)};
459 return {&mROFramesClusters[layerId][rofMin], static_cast<gsl::span<int>::size_type>(chkdRange)};
460}
461
462template <int NLayers>
463inline gsl::span<const int> TimeFrame<NLayers>::getNClustersROFrange(int rofMin, int range, int layerId) const
464{
465 int chkdRange{o2::gpu::CAMath::Min(range, getNrof(layerId) - rofMin)};
466 return {&mNClustersPerROF[layerId][rofMin], static_cast<gsl::span<int>::size_type>(chkdRange)};
467}
468
469template <int NLayers>
470inline int TimeFrame<NLayers>::getTotalClustersPerROFrange(int rofMin, int range, int layerId) const
471{
472 int startIdx{rofMin}; // First cluster of rofMin
473 int endIdx{o2::gpu::CAMath::Min(rofMin + range, getNrof(layerId))};
474 return mROFramesClusters[layerId][endIdx] - mROFramesClusters[layerId][startIdx];
475}
476
477template <int NLayers>
478inline int TimeFrame<NLayers>::getClusterROF(int iLayer, int iCluster)
479{
480 return std::lower_bound(mROFramesClusters[iLayer].begin(), mROFramesClusters[iLayer].end(), iCluster + 1) - mROFramesClusters[iLayer].begin() - 1;
481}
482
483template <int NLayers>
484inline gsl::span<const Cluster> TimeFrame<NLayers>::getUnsortedClustersOnLayer(int rofId, int layerId) const
485{
486 if (rofId < 0 || rofId >= getNrof(layerId)) {
487 return {};
488 }
489 int startIdx{mROFramesClusters[layerId][rofId]};
490 return {&mUnsortedClusters[layerId][startIdx], static_cast<gsl::span<Cluster>::size_type>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
491}
492
493template <int NLayers>
494inline gsl::span<int> TimeFrame<NLayers>::getIndexTable(int rofId, int layer)
495{
496 if (rofId < 0 || rofId >= getNrof(layer)) {
497 return {};
498 }
499 const int tableSize = mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1;
500 return {&mIndexTables[layer][rofId * tableSize], static_cast<gsl::span<int>::size_type>(tableSize)};
501}
502
503template <int NLayers>
504template <typename... T>
506{
507 mUnsortedClusters[layer].emplace_back(std::forward<T>(values)...);
508}
509
510template <int NLayers>
511template <typename... T>
513{
514 mTrackingFrameInfo[layer].emplace_back(std::forward<T>(values)...);
515}
516
517template <int NLayers>
518inline gsl::span<uint8_t> TimeFrame<NLayers>::getUsedClusters(const int layer)
519{
520 return {&mUsedClusters[layer][0], static_cast<gsl::span<uint8_t>::size_type>(mUsedClusters[layer].size())};
521}
522
523template <int NLayers>
524inline gsl::span<int> TimeFrame<NLayers>::getNTrackletsCluster(int rofId, int combId)
525{
526 if (rofId < 0 || rofId >= getNrof(1)) {
527 return {};
528 }
529 auto startIdx{mROFramesClusters[1][rofId]};
530 return {&mNTrackletsPerCluster[combId][startIdx], static_cast<gsl::span<int>::size_type>(mROFramesClusters[1][rofId + 1] - startIdx)};
531}
532
533template <int NLayers>
534inline gsl::span<int> TimeFrame<NLayers>::getExclusiveNTrackletsCluster(int rofId, int combId)
535{
536 if (rofId < 0 || rofId >= getNrof(1)) {
537 return {};
538 }
539 auto clusStartIdx{mROFramesClusters[1][rofId]};
540
541 return {&mNTrackletsPerClusterSum[combId][clusStartIdx], static_cast<gsl::span<int>::size_type>(mROFramesClusters[1][rofId + 1] - clusStartIdx)};
542}
543
544template <int NLayers>
545inline gsl::span<Tracklet> TimeFrame<NLayers>::getFoundTracklets(int rofId, int combId)
546{
547 if (rofId < 0 || rofId >= getNrof(1) || mTracklets[combId].empty()) {
548 return {};
549 }
550 auto startIdx{mNTrackletsPerROF[combId][rofId]};
551 return {&mTracklets[combId][startIdx], static_cast<gsl::span<Tracklet>::size_type>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
552}
553
554template <int NLayers>
555inline gsl::span<const Tracklet> TimeFrame<NLayers>::getFoundTracklets(int rofId, int combId) const
556{
557 if (rofId < 0 || rofId >= getNrof(1)) {
558 return {};
559 }
560 auto startIdx{mNTrackletsPerROF[combId][rofId]};
561 return {&mTracklets[combId][startIdx], static_cast<gsl::span<Tracklet>::size_type>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
562}
563
564template <int NLayers>
565inline gsl::span<const MCCompLabel> TimeFrame<NLayers>::getLabelsFoundTracklets(int rofId, int combId) const
566{
567 if (rofId < 0 || rofId >= getNrof(1) || !hasMCinformation()) {
568 return {};
569 }
570 auto startIdx{mNTrackletsPerROF[combId][rofId]};
571 return {&mTrackletLabels[combId][startIdx], static_cast<gsl::span<Tracklet>::size_type>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
572}
573
574template <int NLayers>
576{
577 size_t totalClusters{0};
578 for (const auto& clusters : mUnsortedClusters) {
579 totalClusters += clusters.size();
580 }
581 return int(totalClusters);
582}
583
584template <int NLayers>
586{
587 size_t nClusters{0};
588 for (const auto& layer : mClusters) {
589 nClusters += layer.size();
590 }
591 return nClusters;
592}
593
594template <int NLayers>
596{
597 size_t nCells{0};
598 for (const auto& layer : mCells) {
599 nCells += layer.size();
600 }
601 return nCells;
602}
603
604template <int NLayers>
606{
607 size_t nTracklets{0};
608 for (const auto& layer : mTracklets) {
609 nTracklets += layer.size();
610 }
611 return nTracklets;
612}
613
614template <int NLayers>
616{
617 size_t neigh{0};
618 for (const auto& l : mCellsNeighbours) {
619 neigh += l.size();
620 }
621 return neigh;
622}
623
624template <int NLayers>
626{
627 return mTracks.size();
628}
629
630template <int NLayers>
632{
633 size_t nClusters = 0;
634 for (const auto& layer : mUsedClusters) {
635 nClusters += std::count(layer.begin(), layer.end(), true);
636 }
637 return nClusters;
638}
639
640template <int NLayers>
642{
643 mNExtendedTracks = 0;
644 mNExtendedClusters = 0;
645}
646
647template <int NLayers>
649{
650 mNExtendedTracks += nTracks;
651 mNExtendedClusters += nClusters;
652}
653
654} // namespace its
655} // namespace o2
656
657#endif
Cross-timeframe output-size prediction.
uint64_t vertex
Definition RawEventData.h:9
small types shared by the host and device seeding vertexers, describing lines projected onto the beam...
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the ITS track.
int nClusters
A container to hold and manage MC truth information/labels.
HMPID cluster implementation.
Definition Cluster.h:27
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint entry
Definition glcorearb.h:5735
const GLdouble * v
Definition glcorearb.h:832
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLenum GLint * range
Definition glcorearb.h:1899
GLint y
Definition glcorearb.h:270
GLenum GLsizei GLsizei GLint * values
Definition glcorearb.h:1576
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
constexpr int UnusedIndex
Definition Constants.h:32
std::pair< o2::MCCompLabel, float > VertexLabel
Definition Vertex.h:27
const int end
const int tableSize
std::pmr::vector< T > bounded_vector
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void empty(int)
size_t mNExtendedClusters
Definition TimeFrame.h:310
ROFVertexLookupTable< NLayers > ROFVertexLookupTableN
Definition TimeFrame.h:75
virtual size_t getNumberOfCells() const
Definition TimeFrame.h:595
virtual void prepareClusters(const TrackingParameters &trkParam, const int maxLayers=NLayers)
std::vector< TrackingTopologyN > mTrackerTopologies
Definition TimeFrame.h:365
std::vector< bounded_vector< Line > > mLines
Definition TimeFrame.h:350
std::vector< bounded_vector< int > > mTrackletsLookupTable
Definition TimeFrame.h:301
bounded_vector< int > mBogusClusters
Definition TimeFrame.h:342
std::array< float, NLayers > mMaxR
Definition TimeFrame.h:332
const TrackingFrameInfo & getClusterTrackingFrameInfo(int layerId, const Cluster &cl) const
virtual void setDevicePropagator(const o2::base::PropagatorImpl< float > *)
Definition TimeFrame.h:283
const auto & getROFVertexLookupTableView() const
Definition TimeFrame.h:158
size_t getNumberOfUsedClusters() const
Definition TimeFrame.h:631
std::array< bounded_vector< int >, NLayers > mIndexTables
Definition TimeFrame.h:300
ROFMaskTableN mUPCCutMask
Definition TimeFrame.h:370
gsl::span< const Cluster > getUnsortedClustersOnLayer(int rofId, int layerId) const
Definition TimeFrame.h:484
std::array< bounded_vector< int >, 2 > mNTrackletsPerClusterSum
Definition TimeFrame.h:298
size_t getNumberOfClusters() const
Definition TimeFrame.h:585
gsl::span< const Cluster > getClustersOnLayer(int rofId, int layerId) const
Definition TimeFrame.h:415
void setSeedingUPCMask(ROFMaskTableN cutMask)
Definition TimeFrame.h:176
void initDefaultTrackingTopology(const TrackingParameters &trkParam, const int maxLayers=NLayers)
auto & getPositionResolutions()
Definition TimeFrame.h:132
bounded_vector< MCCompLabel > mTracksLabel
Definition TimeFrame.h:308
void useMultiplictyMask() noexcept
Definition TimeFrame.h:170
bool checkMemory(unsigned long max)
Definition TimeFrame.h:239
ROFMaskTableN * mROFMask
Definition TimeFrame.h:372
const auto & getTrackingFrameInfoOnLayer(int layerId) const
Definition TimeFrame.h:144
std::array< uint32_t, 2 > mTotalTracklets
Definition TimeFrame.h:355
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > pool)
memory management
size_t getNumberOfTracks() const
Definition TimeFrame.h:625
void resetBeamXY(const float x, const float y, const float w=0)
Definition TimeFrame.h:391
void computeTracletsPerClusterScans()
auto & getTrackletsLabel(int layer)
Definition TimeFrame.h:196
uint32_t mTotalLines
Definition TimeFrame.h:356
ROFOverlapTableN mROFOverlapTable
Definition TimeFrame.h:361
std::shared_ptr< BoundedMemoryResource > mExtMemoryPool
Definition TimeFrame.h:275
bounded_vector< TrackITSExt > mTracks
Definition TimeFrame.h:307
auto getFrameworkAllocator()
Definition TimeFrame.h:276
virtual size_t getNumberOfNeighbours() const
Definition TimeFrame.h:615
ROFVertexLookupTableN::View mROFVertexLookupTableView
Definition TimeFrame.h:368
gsl::span< Tracklet > getFoundTracklets(int rofId, int combId)
Definition TimeFrame.h:545
void initVertexingTopology(const TrackingParameters &trkParam)
TrackSeed< NLayers > TrackSeedN
Definition TimeFrame.h:78
gsl::span< uint8_t > getUsedClustersROF(int rofId, int layerId)
Definition TimeFrame.h:425
std::array< const dataformats::MCTruthContainer< MCCompLabel > *, NLayers > mClusterLabels
Definition TimeFrame.h:296
std::vector< bounded_vector< CellSeed > > mCells
Definition TimeFrame.h:306
gsl::span< const MCCompLabel > getLabelsFoundTracklets(int rofId, int combId) const
Definition TimeFrame.h:565
void printArtefactsMemory() const
bool empty() const
Definition TimeFrame.h:106
void useUPCMask() noexcept
Definition TimeFrame.h:182
float getBz() const
Definition TimeFrame.h:271
CapacityEstimator & getCapacityEstimator() noexcept
Definition TimeFrame.h:246
ROFOverlapTableN::View mROFOverlapTableView
Definition TimeFrame.h:362
gsl::span< const Tracklet > getFoundTracklets(int rofId, int combId) const
Definition TimeFrame.h:555
const Vertex & getPrimaryVertex(const int ivtx) const
Definition TimeFrame.h:86
virtual const char * getName() const noexcept
Definition TimeFrame.h:321
const o2::base::PropagatorImpl< float > * getDevicePropagator() const
Definition TimeFrame.h:282
gsl::span< const Cluster > getClustersPerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:445
int getClusterSize(int layer, int clusterId) const
Definition TimeFrame.h:193
void updateROFVertexLookupTable()
Definition TimeFrame.h:164
float getBeamY() const
Definition TimeFrame.h:119
size_t mNExtendedTracks
Definition TimeFrame.h:309
void setFrameworkAllocator(ExternalAllocator *ext)
auto & getCellsNeighboursTopology()
Definition TimeFrame.h:219
void setClusterSize(int layer, bounded_vector< uint8_t > &v)
Definition TimeFrame.h:194
void initialise(const TrackingParameters &trkParam, const int maxLayers=NLayers, const int iteration=constants::UnusedIndex)
const auto & getIndexTableUtils() const
Definition TimeFrame.h:147
void addPrimaryVertexLabel(const VertexLabel &label)
Definition TimeFrame.h:93
bool hasFrameworkAllocator() const noexcept
Definition TimeFrame.h:278
size_t getNExtendedClusters() const
Definition TimeFrame.h:234
gsl::span< const int > getNClustersROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:463
int getSortedStartIndex(const int rofId, const int layer) const
Definition TimeFrame.h:108
auto & getUnsortedClusters()
Definition TimeFrame.h:213
const auto & getROFMaskView() const
Definition TimeFrame.h:187
auto & getLinkMSAngles()
Definition TimeFrame.h:130
void prepareROFrameData(gsl::span< const itsmft::CompClusterExt > clusters, int layer)
TimeFrame(const TimeFrame &)=delete
gsl::span< unsigned char > getUsedClusters(const int layer)
Definition TimeFrame.h:518
TrackingTopologyN mDefaultTrackingTopology
Definition TimeFrame.h:364
auto & getLines(int rofId)
Definition TimeFrame.h:253
void addClusterExternalIndexToLayer(int layer, const int idx)
Definition TimeFrame.h:289
virtual bool isGPU() const noexcept
Definition TimeFrame.h:320
void useSeedingUPCMask() noexcept
Definition TimeFrame.h:177
const auto & getPrimaryVertices() const
Definition TimeFrame.h:89
void markUsedCluster(int layer, int clusterId)
Definition TimeFrame.h:206
gsl::span< int > getIndexTable(int rofId, int layerId)
Definition TimeFrame.h:494
void computeTrackletsPerROFScans()
const o2::base::PropagatorImpl< float > * mPropagatorDevice
Definition TimeFrame.h:315
std::vector< bounded_vector< MCCompLabel > > mLinesLabels
Definition TimeFrame.h:354
auto & getTracklets()
Definition TimeFrame.h:209
std::array< bounded_vector< TrackingFrameInfo >, NLayers > mTrackingFrameInfo
Definition TimeFrame.h:292
void addPrimaryVertex(const Vertex &vertex)
Definition TimeFrame.cxx:59
int getNrof(int layer) const
Definition TimeFrame.h:109
int hasBogusClusters() const
Definition TimeFrame.h:268
std::array< bounded_vector< uint8_t >, NLayers > mUsedClusters
Definition TimeFrame.h:302
void loadROFrameData(gsl::span< const o2::itsmft::ROFRecord > rofs, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, const itsmft::TopologyDictionary *dict, int layer, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
Definition TimeFrame.cxx:71
std::vector< bounded_vector< int > > mCellsNeighbours
Definition TimeFrame.h:311
std::array< float, 2 > & getBeamXY()
Definition TimeFrame.h:121
bounded_vector< float > mLinkPhiCuts
Definition TimeFrame.h:333
auto & getCellsNeighbours()
Definition TimeFrame.h:218
void addTrackingFrameInfoToLayer(int layer, T &&... args)
Definition TimeFrame.h:512
std::vector< bounded_vector< MCCompLabel > > mTrackletLabels
PV x and alpha for track propagation.
Definition TimeFrame.h:339
std::vector< bounded_vector< LineQuality > > mLinesQuality
Definition TimeFrame.h:351
CapacityEstimator mCapacityEstimator
keep track of clusters with wild coordinates
Definition TimeFrame.h:344
ROFMaskTableN::View mROFMaskView
Definition TimeFrame.h:373
void resetROFrameData(int iLayer)
void initTrackerTopologies(gsl::span< const TrackingParameters > trkParams, const int maxLayers=NLayers)
TrackingTopologyN mVertexingTopology
Definition TimeFrame.h:363
virtual void allocateClusterSortStorage(const TrackingParameters &trkParam, const int maxLayers)
auto & getClusters()
Definition TimeFrame.h:212
int getSortedIndex(int rofId, int layer, int idx) const
Definition TimeFrame.h:107
auto & getCellsLookupTable()
Definition TimeFrame.h:217
const auto & getTrackerTopologies() const
Definition TimeFrame.h:150
std::array< float, 2 > mBeamPos
Definition TimeFrame.h:329
std::vector< bounded_vector< int > > mCellsNeighboursTopology
Definition TimeFrame.h:312
void setUPCCutMask(ROFMaskTableN cutMask)
Definition TimeFrame.h:175
float getBeamX() const
Definition TimeFrame.h:118
void setROFVertexLookupTable(ROFVertexLookupTableN table)
Definition TimeFrame.h:159
unsigned int mNTotalLowPtVertices
Definition TimeFrame.h:327
int getTotalClusters() const
Definition TimeFrame.h:575
bool isBeamOverridden() const
Definition TimeFrame.h:120
TrackingTopologyN::View mTrackingTopologyView
Definition TimeFrame.h:366
uint32_t getTotalTrackletsTF(const int iLayer)
Definition TimeFrame.h:264
std::vector< bounded_vector< int > > mNTrackletsPerROF
Definition TimeFrame.h:349
auto & getMemoryPool() const noexcept
Definition TimeFrame.h:238
gsl::span< const int > getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:456
ExternalAllocator * mExternalAllocator
State if memory will be externally managed by the GPU framework.
Definition TimeFrame.h:274
std::array< bounded_vector< int >, NLayers > mNClustersPerROF
Definition TimeFrame.h:299
int getClusterROF(int iLayer, int iCluster)
Definition TimeFrame.h:478
int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const
Definition TimeFrame.h:470
auto getPrimaryVerticesNum()
Definition TimeFrame.h:88
std::array< bounded_vector< int >, 2 > mTrackletsIndexROF
Definition TimeFrame.h:353
void resetTrackExtensionCounters()
Definition TimeFrame.h:641
virtual void wipe()
bounded_vector< float > mPositionResolution
Definition TimeFrame.h:335
std::array< bounded_vector< Cluster >, NLayers > mUnsortedClusters
Definition TimeFrame.h:304
std::vector< bounded_vector< Tracklet > > mTracklets
Definition TimeFrame.h:305
std::vector< bounded_vector< MCCompLabel > > mCellLabels
Definition TimeFrame.h:340
const auto & getTrackingTopologyView() const
Definition TimeFrame.h:151
auto & getLinesLabel(const int rofId)
Definition TimeFrame.h:223
void setBeamPosition(const float x, const float y, const float s2, const float base=50.f, const float systematic=0.f)
Definition TimeFrame.h:112
std::vector< bounded_vector< ClusterLines > > mTrackletClusters
Definition TimeFrame.h:352
auto & getTracksLabel()
Definition TimeFrame.h:222
ROFMaskTableN mMultiplicityCutMask
Definition TimeFrame.h:369
auto & getLinkPhiCuts()
Definition TimeFrame.h:129
auto & getPrimaryVertices()
Definition TimeFrame.h:87
std::vector< bounded_vector< int > > mCellsNeighboursLUT
Definition TimeFrame.h:341
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const int clId) const
Definition TimeFrame.h:191
void addTrackExtensionCounters(size_t nTracks, size_t nClusters)
Definition TimeFrame.h:648
bounded_vector< VertexLabel > mPrimaryVerticesLabels
Definition TimeFrame.h:348
gsl::span< const uint8_t > getUsedClustersROF(int rofId, int layerId) const
Definition TimeFrame.h:435
virtual size_t getNumberOfTracklets() const
Definition TimeFrame.h:605
bool hasMCinformation() const
Definition TimeFrame.h:199
TrackingTopology< NLayers > TrackingTopologyN
Definition TimeFrame.h:77
float getPositionResolution(int layer) const
Definition TimeFrame.h:131
float getLinkPhiCut(int linkId) const
Definition TimeFrame.h:127
std::array< bounded_vector< uint8_t >, NLayers > mClusterSize
Definition TimeFrame.h:336
ROFMaskTableN mSeedingUPCMask
Definition TimeFrame.h:371
gsl::span< const int > getROFrameClusters(int layerId) const
Definition TimeFrame.h:399
std::pmr::memory_resource * getMaybeFrameworkHostResource(bool forceHost=false)
Definition TimeFrame.h:279
virtual ~TimeFrame()
std::array< bounded_vector< int >, NLayers > mClusterExternalIndices
Definition TimeFrame.h:294
const auto & getLinesQuality(int rofId) const
Definition TimeFrame.h:255
auto & getCellsLabel(int layer)
Definition TimeFrame.h:197
std::shared_ptr< BoundedMemoryResource > mMemoryPool
Definition TimeFrame.h:377
float getMinR(int layer) const
Definition TimeFrame.h:125
const auto & getROFOverlapTableView() const
Definition TimeFrame.h:149
gsl::span< Cluster > getClustersOnLayer(int rofId, int layerId)
Definition TimeFrame.h:405
IndexTableUtilsN mIndexTableUtils
Definition TimeFrame.h:360
std::array< bounded_vector< int >, NLayers > mROFramesClusters
Definition TimeFrame.h:295
void setBz(float bz)
Definition TimeFrame.h:270
float getLinkMSAngle(int linkId) const
Definition TimeFrame.h:128
const auto & getROFVertexLookupTable() const
Definition TimeFrame.h:157
void setNLinesTotal(uint32_t a) noexcept
Definition TimeFrame.h:257
void addClusterToLayer(int layer, T &&... args)
Definition TimeFrame.h:505
unsigned long getArtefactsMemory() const
ROFOverlapTable< NLayers > ROFOverlapTableN
Definition TimeFrame.h:74
float getMaxR(int layer) const
Definition TimeFrame.h:126
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const Cluster &cl) const
Definition TimeFrame.h:190
std::array< bounded_vector< Cluster >, NLayers > mClusters
Definition TimeFrame.h:291
std::vector< bounded_vector< int > > mCellsLookupTable
Definition TimeFrame.h:313
bool isBeamPositionOverridden
Definition TimeFrame.h:330
auto & getPrimaryVerticesLabels()
Definition TimeFrame.h:90
const CapacityEstimator & getCapacityEstimator() const noexcept
Definition TimeFrame.h:247
gsl::span< const Vertex > getPrimaryVertices(int layer, int rofId) const
Definition TimeFrame.h:381
void setIsStaggered(bool b) noexcept
staggering
Definition TimeFrame.h:244
int getNLinesTotal() const noexcept
Definition TimeFrame.h:256
auto & getLinesQuality(int rofId)
Definition TimeFrame.h:254
auto & getTrackletClusters(int rofId)
Definition TimeFrame.h:258
bool isClusterUsed(int layer, int clusterId) const
Definition TimeFrame.h:205
bounded_vector< Vertex > mPrimaryVertices
Definition TimeFrame.h:347
void setROFOverlapTable(ROFOverlapTableN table)
Definition TimeFrame.h:152
gsl::span< int > getExclusiveNTrackletsCluster(int rofId, int combId)
Definition TimeFrame.h:534
void setMultiplicityCutMask(ROFMaskTableN cutMask)
Definition TimeFrame.h:165
bounded_vector< std::array< float, 2 > > mPValphaX
Definition TimeFrame.h:338
auto & getTrackletsLookupTable()
Definition TimeFrame.h:210
ROFVertexLookupTableN mROFVertexLookupTable
Definition TimeFrame.h:367
ROFMaskTable< NLayers > ROFMaskTableN
Definition TimeFrame.h:76
bounded_vector< float > mLinkMSAngles
Definition TimeFrame.h:334
LayerMask mSystErrorsApplied
Definition TimeFrame.h:293
int getClusterExternalIndex(int layerId, const int clId) const
Definition TimeFrame.h:192
std::array< float, NLayers > mMinR
Definition TimeFrame.h:331
const auto & getROFOverlapTable() const
Definition TimeFrame.h:148
int & getNTrackletsROF(int rofId, int combId)
Definition TimeFrame.h:252
gsl::span< int > getNTrackletsCluster(int rofId, int combId)
Definition TimeFrame.h:524
TimeFrame & operator=(const TimeFrame &)=delete
auto & getCellsNeighboursLUT()
Definition TimeFrame.h:220
std::array< bounded_vector< int >, 2 > mNTrackletsPerCluster
Definition TimeFrame.h:297
size_t getNExtendedTracks() const
Definition TimeFrame.h:233
constexpr size_t max
std::vector< Cluster > clusters