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