Project
Loading...
Searching...
No Matches
GPUTRDTracker.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.
11
14
16
17#ifndef GPUTRDTRACKER_H
18#define GPUTRDTRACKER_H
19
20#include "GPUCommonDef.h"
21#include "GPUProcessor.h"
22#include "GPUTRDDef.h"
23#include "GPUDef.h"
24#include "GPUTRDTrack.h"
25#include "GPUTRDSpacePoint.h"
26#include "GPULogging.h"
27#include "GPUTRDInterfaces.h"
28
29#ifndef GPUCA_GPUCODE_DEVICE
30#include <vector>
31#endif
32
33namespace o2::gpu
34{
35
36class GPUTRDTrackletWord;
37class GPUTRDGeometry;
38class GPUChainTracking;
39template <class T>
40class GPUTRDTrackerDebug;
41
42//-------------------------------------------------------------------------
43template <class TRDTRK, class PROP>
45{
46 public:
47#ifndef GPUCA_GPUCODE
49 GPUTRDTracker_t(const GPUTRDTracker_t& tracker) = delete;
50 GPUTRDTracker_t& operator=(const GPUTRDTracker_t& tracker) = delete;
52
56 void UpdateGeometry();
57 void* SetPointersBase(void* base);
58 void* SetPointersTracklets(void* base);
59 void* SetPointersTracks(void* base);
60
62 void SetNCandidates(int32_t n);
63 void PrintSettings() const;
64 bool IsInitialized() const { return mIsInitialized; }
65 void StartDebugging();
66#endif
67
72
74 // additional TRD track attributes which are transient
75 float mTime; // time estimate for seeding track in us
76 float mTimeAddMax; // max. time that can be added to this track seed in us
77 float mTimeSubMax; // max. time that can be subtracted to this track seed in us
78 int16_t mSide; // -1 : A-side, +1 : C-side (relevant only for TPC-only tracks)
79 GPUd() float GetTimeMin() const { return mTime - mTimeSubMax; }
80 GPUd() float GetTimeMax() const { return mTime + mTimeAddMax; }
82 };
83
84 struct Hypothesis {
85 int32_t mLayers; // number of layers with TRD space point
86 int32_t mCandidateId; // to which track candidate the hypothesis belongs
87 int32_t mTrackletId; // tracklet index to be used for update (global index within tracklet array)
88 float mChi2; // predicted chi2 for given space point
89
90 GPUd() float GetReducedChi2() { return mLayers > 0 ? mChi2 / mLayers : mChi2; }
91 GPUd() Hypothesis() : mLayers(0), mCandidateId(-1), mTrackletId(-1), mChi2(9999.f) {}
92 GPUd() Hypothesis(int32_t layers, int32_t candidateId, int32_t trackletId, float chi2) : mLayers(layers), mCandidateId(candidateId), mTrackletId(trackletId), mChi2(chi2) {}
93 };
94
95 int16_t MemoryPermanent() const { return mMemoryPermanent; }
96
97 GPUhd() void OverrideGPUGeometry(const GPUTRDGeometry* geo) { mGeo = geo; }
98 void Reset();
99 template <class T>
100 GPUd() bool PreCheckTrackTRDCandidate(const T& trk) const
101 {
102 return true;
103 }
104 GPUd() bool PreCheckTrackTRDCandidate(const GPUTPCGMMergedTrack& trk) const { return trk.OK() && !trk.Looper(); }
105 GPUd() bool CheckTrackTRDCandidate(const TRDTRK& trk) const;
106 GPUd() int32_t LoadTrack(const TRDTRK& trk, uint32_t tpcTrackId, bool checkTrack = true, HelperTrackAttributes* attribs = nullptr);
107
108 GPUd() int32_t GetCollisionIDs(int32_t iTrk, int32_t* collisionIds) const;
109 GPUd() void DoTrackingThread(int32_t iTrk, int32_t threadId = 0);
110 static GPUd() bool ConvertTrkltToSpacePoint(const GPUTRDGeometry& geo, GPUTRDTrackletWord& trklt, GPUTRDSpacePoint& sp);
111 GPUd() bool CalculateSpacePoints(int32_t iCollision = 0);
112 GPUd() bool FollowProlongation(PROP* prop, TRDTRK* t, int32_t iTrk, int32_t threadId, int32_t collisionId);
113 GPUd() int32_t GetDetectorNumber(const float zPos, const float alpha, const int32_t layer) const;
114 GPUd() bool AdjustSector(PROP* prop, TRDTRK* t) const;
115 GPUd() int32_t GetSector(float alpha) const;
116 GPUd() float GetAlphaOfSector(const int32_t sec) const;
117 GPUd() float GetRPhiRes(float snp) const { return (mRPhiA2 + mRPhiC2 * (snp - mRPhiB) * (snp - mRPhiB)); } // parametrization obtained from track-tracklet residuals:
118 GPUd() float GetAngularResolution(float snp) const { return mDyA2 + mDyC2 * (snp - mDyB) * (snp - mDyB); } // a^2 + c^2 * (snp - b)^2
119 GPUd() float ConvertAngleToDy(float snp) const { return mAngleToDyA + mAngleToDyB * snp + mAngleToDyC * snp * snp; } // a + b*snp + c*snp^2 is more accurate than sin(phi) = (dy / xDrift) / sqrt(1+(dy/xDrift)^2)
120 GPUd() float GetAngularPull(float dYtracklet, float snp) const;
121 GPUd() void RecalcTrkltCov(const float tilt, const float snp, const float rowSize, float (&cov)[3]);
122 GPUd() void FindChambersInRoad(const TRDTRK* t, const float roadY, const float roadZ, const int32_t iLayer, int32_t* det, const float zMax, const float alpha, const float zShiftTrk) const;
123 GPUd() bool IsGeoFindable(const TRDTRK* t, const int32_t layer, const float alpha, const float zShiftTrk) const;
124 GPUd() void InsertHypothesis(Hypothesis hypo, int32_t& nCurrHypothesis, int32_t idxOffset);
125
126 // settings
127 GPUd() void SetGenerateSpacePoints(bool flag) { mGenerateSpacePoints = flag; }
128 GPUd() bool GenerateSpacepoints() const { return mGenerateSpacePoints; }
129 GPUd() void SetProcessPerTimeFrame(bool flag) { mProcessPerTimeFrame = flag; }
130 GPUd() void EnableDebugOutput() { mDebugOutput = true; }
131 GPUd() void SetMaxEta(float maxEta) { mMaxEta = maxEta; }
132 GPUd() void SetRoadZ(float roadZ) { mRoadZ = roadZ; }
133 GPUd() void SetTPCVdrift(float vDrift) { mTPCVdrift = vDrift; }
134 GPUd() void SetTPCTDriftOffset(float t) { mTPCTDriftOffset = t; }
135
136 GPUd() bool GetIsDebugOutputOn() const { return mDebugOutput; }
137 GPUd() float GetMaxEta() const { return mMaxEta; }
138 GPUd() int32_t GetNCandidates() const { return mNCandidates; }
139 GPUd() float GetRoadZ() const { return mRoadZ; }
140
141 // output
142 GPUd() int32_t NTracks() const { return mNTracks; }
143 GPUd() GPUTRDSpacePoint* SpacePoints() const { return mSpacePoints; }
144 GPUd() TRDTRK* Tracks() const { return mTracks; }
145 GPUd() void DumpTracks();
146
147 // utility
148 GPUd() const typename PROP::propagatorParam* getPropagatorParam();
149
150 protected:
151 float* mR; // radial position of each TRD chamber, alignment taken into account, radial spread within chambers < 7mm
152 bool mIsInitialized; // flag is set upon initialization
153 bool mGenerateSpacePoints; // if true, only tracklets are provided as input and they will be converted into space points by the tracker
154 bool mProcessPerTimeFrame; // if true, tracking is done per time frame instead of on a single events basis
155 int16_t mNAngleHistogramBins; // number of bins per chamber for the angular difference histograms
156 float mAngleHistogramRange; // range of impact angles covered by each histogram
157 int16_t mMemoryPermanent; // memory id of permanent memory for the tracker
158 int16_t mMemoryTracklets; // memory id of memory for TRD tracklets
159 int16_t mMemoryTracks; // memory id of memory for tracks (used for i/o)
160 int32_t mNMaxCollisions; // max number of collisions to process (per time frame)
161 int32_t mNMaxTracks; // max number of tracks the tracker can handle (per event)
162 int32_t mNMaxSpacePoints; // max number of space points hold by the tracker (per event)
163 TRDTRK* mTracks; // array of trd-updated tracks
164 HelperTrackAttributes* mTrackAttribs; // array with additional (transient) track attributes
165 int32_t mNCandidates; // max. track hypothesis per layer
166 int32_t mNTracks; // number of TPC tracks to be matched
167 int32_t mNEvents; // number of processed events
168 int32_t mMaxBackendThreads; // maximum number of supported threads
169 // index of first tracklet for each chamber within tracklets array, last entry is total number of tracklets for given collision
170 // the array has (kNChambers + 1) * numberOfCollisions entries
171 // note, that for collision iColl one has to add an offset corresponding to the index of the first tracklet of iColl to the index stored in mTrackletIndexArray
173 Hypothesis* mHypothesis; // array with multiple track hypothesis
174 TRDTRK* mCandidates; // array of tracks for multiple hypothesis tracking
175 GPUTRDSpacePoint* mSpacePoints; // array with tracklet coordinates in global tracking frame
176 const GPUTRDGeometry* mGeo; // TRD geometry
178 float mRPhiA2; // parameterization for tracklet position resolution
179 float mRPhiB; // parameterization for tracklet position resolution
180 float mRPhiC2; // parameterization for tracklet position resolution
181 float mDyA2; // parameterization for tracklet angular resolution
182 float mDyB; // parameterization for tracklet angular resolution
183 float mDyC2; // parameterization for tracklet angular resolution
184 float mAngleToDyA; // parameterization for conversion track angle -> tracklet deflection
185 float mAngleToDyB; // parameterization for conversion track angle -> tracklet deflection
186 float mAngleToDyC; // parameterization for conversion track angle -> tracklet deflection
188 bool mDebugOutput; // store debug output
189 static constexpr const float sRadialOffset = -0.1f; // due to (possible) mis-calibration of t0 -> will become obsolete when tracklet conversion is done outside of the tracker
190 float mMaxEta; // TPC tracks with higher eta are ignored
191 float mRoadZ; // in z, a constant search road is used
192 float mZCorrCoefNRC; // tracklet z-position depends linearly on track dip angle
193 float mTPCVdrift; // TPC drift velocity used for shifting TPC tracks along Z
194 float mTPCTDriftOffset; // TPC drift time additive offset
195 GPUTRDTrackerDebug<TRDTRK>* mDebug; // debug output
196};
197} // namespace o2::gpu
198
199#endif // GPUTRDTRACKER_H
Struct to hold the position/direction information of the tracklets transformed in sector coordinates.
#define protected
GPUd() bool PreCheckTrackTRDCandidate(const GPUTPCGMMergedTrack &trk) const
GPUd() float GetRoadZ() const
GPUTRDTracker_t(const GPUTRDTracker_t &tracker)=delete
void * SetPointersTracks(void *base)
GPUd() void DumpTracks()
GPUd() int32_t GetCollisionIDs(int32_t iTrk
void * SetPointersBase(void *base)
GPUd() float GetAngularResolution(float snp) const
uint32_t bool HelperTrackAttributes * attribs
GPUd() void SetMaxEta(float maxEta)
GPUd() void SetProcessPerTimeFrame(bool flag)
const float const float float(& cov)[3]
GPUTRDTrackerDebug< TRDTRK > * mDebug
GPUd() void SetTPCVdrift(float vDrift)
GPUd() bool GetIsDebugOutputOn() const
GPUd() TRDTRK *Tracks() const
GPUd() int32_t NTracks() const
GPUTRDTracker_t & operator=(const GPUTRDTracker_t &tracker)=delete
void SetNCandidates(int32_t n)
GPUd() void SetRoadZ(float roadZ)
GPUd() bool GenerateSpacepoints() const
GPUhd() void OverrideGPUGeometry(const GPUTRDGeometry *geo)
GPUd() void SetTPCTDriftOffset(float t)
static GPUTRDTrackletWord GPUTRDSpacePoint & sp
GPUd() bool CheckTrackTRDCandidate(const TRDTRK &trk) const
GPUd() float ConvertAngleToDy(float snp) const
float mRPhiA2
-— error parametrization depending on magnetic field -—
const float const float const int32_t iLayer
GPUd() int32_t GetNCandidates() const
int32_t *collisionIds const
static constexpr const float sRadialOffset
static GPUTRDTrackletWord & trklt
void SetMaxData(const GPUTrackingInOutPointers &io)
const float const float roadZ
void PrepareTracking(GPUChainTracking *chainTracking)
GPUd() GPUTRDSpacePoint *SpacePoints() const
HelperTrackAttributes * mTrackAttribs
int16_t MemoryPermanent() const
int32_t int32_t idxOffset
TRDTRK int32_t int32_t int32_t collisionId
const float const float const int32_t int32_t const float zMax
const float const float const int32_t int32_t * det
const GPUTRDGeometry * mGeo
void * SetPointersTracklets(void *base)
GPUd() bool PreCheckTrackTRDCandidate(const T &trk) const
GPUd() void EnableDebugOutput()
const float const float rowSize
bool mDebugOutput
-— end error parametrization -—
GPUd() float GetMaxEta() const
GPUTRDSpacePoint * mSpacePoints
GLdouble n
Definition glcorearb.h:1982
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GPUChainTracking * chainTracking
GPUd() float GetReducedChi2()