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