Project
Loading...
Searching...
No Matches
TrackerTraits.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.
15
16#ifndef TRACKINGITSU_INCLUDE_TRACKERTRAITS_H_
17#define TRACKINGITSU_INCLUDE_TRACKERTRAITS_H_
18
19#include <cmath>
20
26
27#include <oneapi/tbb.h>
28#include <oneapi/tbb/partitioner.h>
29
30// #define OPTIMISATION_OUTPUT
31
32namespace o2
33{
34namespace gpu
35{
36class GPUChainITS;
37}
38namespace its
39{
40class TrackITSExt;
41
42template <int nLayers = 7>
44{
45 public:
46 virtual ~TrackerTraits() = default;
48 virtual void initialiseTimeFrame(const int iteration) { mTimeFrame->initialise(iteration, mTrkParams[iteration], mTrkParams[iteration].NLayers); }
49
50 virtual void computeLayerTracklets(const int iteration, int iROFslice, int iVertex);
51 virtual void computeLayerCells(const int iteration);
52 virtual void findCellsNeighbours(const int iteration);
53 virtual void findRoads(const int iteration);
54
55 virtual bool supportsExtendTracks() const noexcept { return true; }
56 virtual void extendTracks(const int iteration);
57 virtual bool supportsFindShortPrimaries() const noexcept { return true; }
58 virtual void findShortPrimaries();
59
60 virtual bool trackFollowing(TrackITSExt* track, int rof, bool outward, const int iteration);
61 virtual void processNeighbours(int iLayer, int iLevel, const bounded_vector<CellSeed>& currentCellSeed, const bounded_vector<int>& currentCellId, bounded_vector<CellSeed>& updatedCellSeed, bounded_vector<int>& updatedCellId);
62
63 void updateTrackingParameters(const std::vector<TrackingParameters>& trkPars) { mTrkParams = trkPars; }
65
66 virtual void setBz(float bz);
67 float getBz() const { return mBz; }
68 bool isMatLUT() const;
69 virtual const char* getName() const noexcept { return "CPU"; }
70 virtual bool isGPU() const noexcept { return false; }
71 void setMemoryPool(std::shared_ptr<BoundedMemoryResource>& pool) noexcept { mMemoryPool = pool; }
72 auto getMemoryPool() const noexcept { return mMemoryPool; }
73
74 // Others
75 GPUhd() static consteval int4 getEmptyBinsRect() { return int4{0, 0, 0, 0}; }
76 const int4 getBinsRect(int layer, float phi, float maxdeltaphi, float z, float maxdeltaz) const noexcept { return getBinsRect(layer, phi, maxdeltaphi, z, z, maxdeltaz); }
77 const int4 getBinsRect(const Cluster& cls, int layer, float z1, float z2, float maxdeltaz, float maxdeltaphi) const noexcept { return getBinsRect(layer, cls.phi, maxdeltaphi, z1, z2, maxdeltaz); }
78 const int4 getBinsRect(int layer, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept;
80 void setSmoothing(bool v) { mApplySmoothing = v; }
81 bool getSmoothing() const { return mApplySmoothing; }
82 void setNThreads(int n, std::shared_ptr<tbb::task_arena>& arena);
83 int getNThreads() { return mTaskArena->max_concurrency(); }
84
86
87 // TimeFrame information forwarding
88 virtual int getTFNumberOfClusters() const { return mTimeFrame->getNumberOfClusters(); }
89 virtual int getTFNumberOfTracklets() const { return mTimeFrame->getNumberOfTracklets(); }
90 virtual int getTFNumberOfCells() const { return mTimeFrame->getNumberOfCells(); }
91
92 private:
93 track::TrackParCov buildTrackSeed(const Cluster& cluster1, const Cluster& cluster2, const TrackingFrameInfo& tf3);
94 bool fitTrack(TrackITSExt& track, int start, int end, int step, float chi2clcut = o2::constants::math::VeryBig, float chi2ndfcut = o2::constants::math::VeryBig, float maxQoverPt = o2::constants::math::VeryBig, int nCl = 0);
95
96 bool mApplySmoothing = false;
97 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
98 std::shared_ptr<tbb::task_arena> mTaskArena;
99
100 protected:
103 std::vector<TrackingParameters> mTrkParams;
104
105 float mBz{-999.f};
106 bool mIsZeroField{false};
107};
108
109template <int nLayers>
110inline const int4 TrackerTraits<nLayers>::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept
111{
112 const float zRangeMin = o2::gpu::GPUCommonMath::Min(z1, z2) - maxdeltaz;
113 const float phiRangeMin = (maxdeltaphi > o2::constants::math::PI) ? 0.f : phi - maxdeltaphi;
114 const float zRangeMax = o2::gpu::GPUCommonMath::Max(z1, z2) + maxdeltaz;
115 const float phiRangeMax = (maxdeltaphi > o2::constants::math::PI) ? o2::constants::math::TwoPI : phi + maxdeltaphi;
116
117 if (zRangeMax < -mTrkParams[0].LayerZ[layerIndex] ||
118 zRangeMin > mTrkParams[0].LayerZ[layerIndex] || zRangeMin > zRangeMax) {
119 return getEmptyBinsRect();
120 }
121
122 const IndexTableUtils& utils{mTimeFrame->mIndexTableUtils};
123 return int4{o2::gpu::GPUCommonMath::Max(0, utils.getZBinIndex(layerIndex, zRangeMin)),
124 utils.getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMin)),
125 o2::gpu::GPUCommonMath::Min(mTrkParams[0].ZBins - 1, utils.getZBinIndex(layerIndex, zRangeMax)), // /!\ trkParams can potentially change across iterations
126 utils.getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMax))};
127}
128
129} // namespace its
130} // namespace o2
131
132#endif /* TRACKINGITSU_INCLUDE_TRACKERTRAITS_H_ */
GPUChain * chain
virtual void initialiseTimeFrame(const int iteration)
virtual int getTFNumberOfTracklets() const
GPUhd() static const eval int4 getEmptyBinsRect()
TimeFrame< nLayers > * getTimeFrame()
virtual ~TrackerTraits()=default
virtual void findRoads(const int iteration)
void setNThreads(int n, std::shared_ptr< tbb::task_arena > &arena)
auto getMemoryPool() const noexcept
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > &pool) noexcept
virtual bool isGPU() const noexcept
virtual int getTFNumberOfClusters() const
virtual void processNeighbours(int iLayer, int iLevel, const bounded_vector< CellSeed > &currentCellSeed, const bounded_vector< int > &currentCellId, bounded_vector< CellSeed > &updatedCellSeed, bounded_vector< int > &updatedCellId)
void updateTrackingParameters(const std::vector< TrackingParameters > &trkPars)
virtual bool trackFollowing(TrackITSExt *track, int rof, bool outward, const int iteration)
virtual void computeLayerTracklets(const int iteration, int iROFslice, int iVertex)
virtual void adoptTimeFrame(TimeFrame< nLayers > *tf)
std::vector< TrackingParameters > mTrkParams
virtual void computeLayerCells(const int iteration)
void setSmoothing(bool v)
virtual bool supportsFindShortPrimaries() const noexcept
virtual void findShortPrimaries()
const int4 getBinsRect(int layer, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept
const int4 getBinsRect(const Cluster &cls, int layer, float z1, float z2, float maxdeltaz, float maxdeltaphi) const noexcept
virtual bool supportsExtendTracks() const noexcept
virtual void setBz(float bz)
virtual void findCellsNeighbours(const int iteration)
virtual void extendTracks(const int iteration)
const int4 getBinsRect(int layer, float phi, float maxdeltaphi, float z, float maxdeltaz) const noexcept
virtual const char * getName() const noexcept
TimeFrame< nLayers > * mTimeFrame
void SetRecoChain(o2::gpu::GPUChainITS *chain)
bool getSmoothing() const
virtual int getTFNumberOfCells() const
o2::gpu::GPUChainITS * getChain() const
o2::gpu::GPUChainITS * mChain
GLdouble n
Definition glcorearb.h:1982
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLuint start
Definition glcorearb.h:469
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr float TwoPI
constexpr float PI
constexpr float VeryBig
std::pmr::vector< T > bounded_vector
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Common utility functions.
std::unique_ptr< GPUReconstructionTimeframe > tf
void initialise(const int iteration, const TrackingParameters &trkParam, const int maxLayers=7, bool resetVertices=true)
virtual int getNumberOfTracklets() const
Definition TimeFrame.h:655
virtual int getNumberOfCells() const
Definition TimeFrame.h:645
int getNumberOfClusters() const
Definition TimeFrame.h:635