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; }
69 bool isMatLUT() const;
70 virtual const char* getName() const noexcept { return "CPU"; }
71 virtual bool isGPU() const noexcept { return false; }
72 void setMemoryPool(std::shared_ptr<BoundedMemoryResource>& pool) noexcept { mMemoryPool = pool; }
73 auto getMemoryPool() const noexcept { return mMemoryPool; }
74
75 // Others
76 GPUhd() static consteval int4 getEmptyBinsRect() { return int4{0, 0, 0, 0}; }
77 const int4 getBinsRect(int layer, float phi, float maxdeltaphi, float z, float maxdeltaz) const noexcept { return getBinsRect(layer, phi, maxdeltaphi, z, z, maxdeltaz); }
78 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); }
79 const int4 getBinsRect(int layer, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept;
81 void setSmoothing(bool v) { mApplySmoothing = v; }
82 bool getSmoothing() const { return mApplySmoothing; }
83 void setNThreads(int n);
84 int getNThreads() const { return mNThreads; }
85
87
88 // TimeFrame information forwarding
89 virtual int getTFNumberOfClusters() const { return mTimeFrame->getNumberOfClusters(); }
90 virtual int getTFNumberOfTracklets() const { return mTimeFrame->getNumberOfTracklets(); }
91 virtual int getTFNumberOfCells() const { return mTimeFrame->getNumberOfCells(); }
92
93 private:
94 track::TrackParCov buildTrackSeed(const Cluster& cluster1, const Cluster& cluster2, const TrackingFrameInfo& tf3);
95 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);
96
97 int mNThreads = 1;
98 bool mApplySmoothing = false;
99 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
100 tbb::task_arena mTaskArena;
101
102 protected:
106 std::vector<TrackingParameters> mTrkParams;
107
108 float mBz{-999.f};
109 bool mIsZeroField{false};
110};
111
112template <int nLayers>
113inline const int4 TrackerTraits<nLayers>::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept
114{
115 const float zRangeMin = o2::gpu::GPUCommonMath::Min(z1, z2) - maxdeltaz;
116 const float phiRangeMin = (maxdeltaphi > constants::math::Pi) ? 0.f : phi - maxdeltaphi;
117 const float zRangeMax = o2::gpu::GPUCommonMath::Max(z1, z2) + maxdeltaz;
118 const float phiRangeMax = (maxdeltaphi > constants::math::Pi) ? constants::math::TwoPi : phi + maxdeltaphi;
119
120 if (zRangeMax < -mTrkParams[0].LayerZ[layerIndex] ||
121 zRangeMin > mTrkParams[0].LayerZ[layerIndex] || zRangeMin > zRangeMax) {
122 return getEmptyBinsRect();
123 }
124
125 const IndexTableUtils& utils{mTimeFrame->mIndexTableUtils};
126 return int4{o2::gpu::GPUCommonMath::Max(0, utils.getZBinIndex(layerIndex, zRangeMin)),
127 utils.getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMin)),
128 o2::gpu::GPUCommonMath::Min(mTrkParams[0].ZBins - 1, utils.getZBinIndex(layerIndex, zRangeMax)), // /!\ trkParams can potentially change across iterations
129 utils.getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMax))};
130}
131
132} // namespace its
133} // namespace o2
134
135#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)
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
void setCorrType(const o2::base::PropagatorImpl< float >::MatCorrType type)
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
o2::base::PropagatorImpl< float >::MatCorrType mCorrType
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
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
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 VeryBig
constexpr float Pi
Definition Constants.h:45
constexpr float TwoPi
Definition Constants.h:46
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)
int getNumberOfTracklets() const
Definition TimeFrame.h:631
int getNumberOfCells() const
Definition TimeFrame.h:621
int getNumberOfClusters() const
Definition TimeFrame.h:611