Project
Loading...
Searching...
No Matches
GPUTPCGMTrackParam.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
15#ifndef GPUTPCGMTRACKPARAM_H
16#define GPUTPCGMTRACKPARAM_H
17
18#include "GPUTPCDef.h"
20#include "GPUTPCGMMergerTypes.h"
21#include "GPUCommonMath.h"
22#include "GPUdEdxInfo.h"
23
24#ifndef GPUCA_GPUCODE_DEVICE
25#include <cstddef>
26#endif
27
28class AliExternalTrackParam;
29
30namespace o2::gpu
31{
32class GPUTPCGMMerger;
33class GPUTPCGMBorderTrack;
34struct GPUParam;
36class GPUTPCGMPolynomialField;
37class GPUTPCGMMergedTrack;
38class GPUTPCGMPropagator;
39
48{
49 public:
50 GPUd() float& X()
51 {
52 return mX;
53 }
54 GPUd() float& Y()
55 {
56 return mP[0];
57 }
58 GPUd() float& Z()
59 {
60 return mP[1];
61 }
62 GPUd() float& SinPhi()
63 {
64 return mP[2];
65 }
66 GPUd() float& DzDs()
67 {
68 return mP[3];
69 }
70 GPUd() float& QPt()
71 {
72 return mP[4];
73 }
74 GPUd() float& TZOffset()
75 {
76 return mTZOffset;
77 }
78
79 GPUhd() float GetX() const { return mX; }
80 GPUhd() float GetY() const { return mP[0]; }
81 GPUhd() float GetZ() const { return mP[1]; }
82 GPUd() float GetSinPhi() const { return mP[2]; }
83 GPUd() float GetDzDs() const { return mP[3]; }
84 GPUd() float GetQPt() const { return mP[4]; }
85 GPUd() float GetTZOffset() const { return mTZOffset; }
86
87 GPUd() float GetKappa(float Bz) const { return -mP[4] * Bz; }
88
89 GPUd() void SetX(float v) { mX = v; }
90
91 GPUd() float* Par()
92 {
93 return mP;
94 }
95 GPUd() const float* GetPar() const { return mP; }
96 GPUd() float GetPar(int32_t i) const { return (mP[i]); }
97 GPUd() void SetPar(int32_t i, float v) { mP[i] = v; }
98
99 GPUd() float& Chi2()
100 {
101 return mChi2;
102 }
103 GPUd() int32_t& NDF()
104 {
105 return mNDF;
106 }
107
108 GPUd() float Err2Y() const { return mC[0]; }
109 GPUd() float Err2Z() const { return mC[2]; }
110 GPUd() float Err2SinPhi() const { return mC[5]; }
111 GPUd() float Err2DzDs() const { return mC[9]; }
112 GPUd() float Err2QPt() const { return mC[14]; }
113
114 GPUd() float GetChi2() const { return mChi2; }
115 GPUd() int32_t GetNDF() const { return mNDF; }
116
117 GPUd() float GetCosPhi() const { return CAMath::Sqrt(float(1.f) - GetSinPhi() * GetSinPhi()); }
118
119 GPUd() float GetErr2Y() const { return mC[0]; }
120 GPUd() float GetErr2Z() const { return mC[2]; }
121 GPUd() float GetErr2SinPhi() const { return mC[5]; }
122 GPUd() float GetErr2DzDs() const { return mC[9]; }
123 GPUd() float GetErr2QPt() const { return mC[14]; }
124
125 GPUd() float* Cov()
126 {
127 return mC;
128 }
129
130 GPUd() const float* GetCov() const { return mC; }
131 GPUd() float GetCov(int32_t i) const { return mC[i]; }
132
133 GPUd() void SetCov(int32_t i, float v) { mC[i] = v; }
134 GPUd() void SetChi2(float v) { mChi2 = v; }
135 GPUd() void SetNDF(int32_t v) { mNDF = v; }
136
137 GPUd() float GetMirroredY(float Bz) const;
138
139 GPUd() void ResetCovariance();
140
141 GPUd() bool CheckNumericalQuality(float overrideCovYY = -1.f) const;
142 GPUd() bool CheckCov() const;
143
144 GPUd() bool Fit(GPUTPCGMMerger* merger, int32_t iTrk, GPUTPCGMMergedTrackHit* clusters, GPUTPCGMMergedTrackHitXYZ* clustersXYZ, int32_t& N, int32_t& NTolerated, float& Alpha, int32_t attempt = 0, float maxSinPhi = GPUCA_MAX_SIN_PHI, gputpcgmmergertypes::GPUTPCOuterParam* outerParam = nullptr);
145 GPUd() void MoveToReference(GPUTPCGMPropagator& prop, const GPUParam& param, float& alpha);
146 GPUd() void MirrorTo(GPUTPCGMPropagator& prop, float toY, float toZ, bool inFlyDirection, const GPUParam& param, uint8_t row, uint8_t clusterState, bool mirrorParameters, int8_t sector);
147 GPUd() int32_t MergeDoubleRowClusters(int32_t& ihit, int32_t wayDirection, GPUTPCGMMergedTrackHit* clusters, GPUTPCGMMergedTrackHitXYZ* clustersXYZ, const GPUTPCGMMerger* merger, GPUTPCGMPropagator& prop, float& xx, float& yy, float& zz, int32_t maxN, float clAlpha, uint8_t& clusterState, bool rejectChi2);
148
149 GPUd() bool AttachClustersPropagate(const GPUTPCGMMerger* GPUrestrict() Merger, int32_t sector, int32_t lastRow, int32_t toRow, int32_t iTrack, bool goodLeg, GPUTPCGMPropagator& prop, bool inFlyDirection, float maxSinPhi = GPUCA_MAX_SIN_PHI, bool checkdEdx = false);
150 GPUd() float AttachClusters(const GPUTPCGMMerger* GPUrestrict() Merger, int32_t sector, int32_t iRow, int32_t iTrack, bool goodLeg, GPUTPCGMPropagator& prop); // Returns uncorrectedY for later use
151 GPUd() float AttachClusters(const GPUTPCGMMerger* GPUrestrict() Merger, int32_t sector, int32_t iRow, int32_t iTrack, bool goodLeg, float Y, float Z);
152 // We force to compile these twice, for RefitLoop and for Fit, for better optimization
153 template <int32_t I>
154 GPUd() void AttachClustersMirror(const GPUTPCGMMerger* GPUrestrict() Merger, int32_t sector, int32_t iRow, int32_t iTrack, float toY, GPUTPCGMPropagator& prop, bool phase2 = false);
155 template <int32_t I>
156 GPUd() int32_t FollowCircle(const GPUTPCGMMerger* GPUrestrict() Merger, GPUTPCGMPropagator& prop, int32_t sector, int32_t iRow, int32_t iTrack, float toAlpha, float toX, float toY, int32_t toSector, int32_t toRow, bool inFlyDirection, bool phase2 = false);
157 GPUd() void StoreAttachMirror(const GPUTPCGMMerger* GPUrestrict() Merger, int32_t sector, int32_t iRow, int32_t iTrack, float toAlpha, float toY, float toX, int32_t toSector, int32_t toRow, bool inFlyDirection, float alpha);
158 GPUd() void StoreOuter(gputpcgmmergertypes::GPUTPCOuterParam* outerParam, const GPUTPCGMPropagator& prop, int32_t phase);
159 GPUd() static void RefitLoop(const GPUTPCGMMerger* GPUrestrict() Merger, int32_t loopIdx);
160
161 GPUd() void AddCovDiagErrors(const float* GPUrestrict() errors2);
162 GPUd() void AddCovDiagErrorsWithCorrelations(const float* GPUrestrict() errors2);
163
164 GPUdi() void MarkClusters(GPUTPCGMMergedTrackHit* GPUrestrict() clusters, int32_t ihitFirst, int32_t ihitLast, int32_t wayDirection, uint8_t state)
165 {
170 }
171 GPUdi() void UnmarkClusters(GPUTPCGMMergedTrackHit* GPUrestrict() clusters, int32_t ihitFirst, int32_t ihitLast, int32_t wayDirection, uint8_t state)
172 {
173 clusters[ihitFirst].state &= ~state;
174 while (ihitFirst != ihitLast) {
175 clusters[ihitFirst += wayDirection].state &= ~state;
176 }
177 }
178 GPUdi() static void NormalizeAlpha(float& alpha)
179 {
180 if (alpha > CAMath::Pi()) {
181 alpha -= CAMath::TwoPi();
182 } else if (alpha <= -CAMath::Pi()) {
183 alpha += CAMath::TwoPi();
184 }
185 }
186
187 GPUd() void Rotate(float alpha);
188 GPUd() void ShiftZ(const GPUTPCGMMerger* merger, int32_t sector, float tzInner, float tzOuter, float x1, float x2);
190
191 GPUd() static float Reciprocal(float x) { return 1.f / x; }
192 GPUdi() static void Assign(float& x, bool mask, float v)
193 {
194 if (mask) {
195 x = v;
196 }
197 }
198
199 GPUdi() static void Assign(int32_t& x, bool mask, int32_t v)
200 {
201 if (mask) {
202 x = v;
203 }
204 }
205
206 GPUd() static void RefitTrack(GPUTPCGMMergedTrack& track, int32_t iTrk, GPUTPCGMMerger* merger, int32_t attempt);
207
208 GPUdi() void ConstrainSinPhi(float limit = GPUCA_MAX_SIN_PHI)
209 {
210 if (mP[2] > limit) {
211 mP[2] = limit;
212 } else if (mP[2] < -limit) {
213 mP[2] = -limit;
214 }
215 }
216
217 private:
218 GPUd() bool FollowCircleChk(float lrFactor, float toY, float toX, bool up, bool right);
219 GPUd() int32_t initResetT0();
220
221 float mX; // x position
222 float mTZOffset; // Z offset with early transform, T offset otherwise
223 float mP[5]; // 'active' track parameters: Y, Z, SinPhi, DzDs, q/Pt
224 float mC[15]; // the covariance matrix for Y,Z,SinPhi,..
225 float mChi2; // the chi^2 value
226 int32_t mNDF; // the Number of Degrees of Freedom
227};
228
231 uint32_t track;
232 float toY;
233 float toX;
234 float alpha;
235 float toAlpha;
236 uint8_t sector;
237 uint8_t row;
238 int8_t toSector;
239 uint8_t toRow;
241};
242
243GPUdi() int32_t GPUTPCGMTrackParam::initResetT0()
244{
245 const float absQPt = CAMath::Abs(mP[4]);
246 if (absQPt < (150.f / 40.f)) {
247 return 150.f / 40.f;
248 }
249 return CAMath::Max(10.f, 150.f / mP[4]);
250}
251
252GPUdi() void GPUTPCGMTrackParam::ResetCovariance()
253{
254 mC[0] = 100.f;
255 mC[1] = 0.f;
256 mC[2] = 100.f;
257 mC[3] = 0.f;
258 mC[4] = 0.f;
259 mC[5] = 1.f;
260 mC[6] = 0.f;
261 mC[7] = 0.f;
262 mC[8] = 0.f;
263 mC[9] = 10.f;
264 mC[10] = 0.f;
265 mC[11] = 0.f;
266 mC[12] = 0.f;
267 mC[13] = 0.f;
268 mC[14] = 10.f;
269 mChi2 = 0;
270 mNDF = -5;
271}
272
273GPUdi() float GPUTPCGMTrackParam::GetMirroredY(float Bz) const
274{
275 // get Y of the point which has the same X, but located on the other side of trajectory
276 float qptBz = GetQPt() * Bz;
277 float cosPhi2 = 1.f - GetSinPhi() * GetSinPhi();
278 if (CAMath::Abs(qptBz) < 1.e-8f) {
279 qptBz = 1.e-8f;
280 }
281 if (cosPhi2 < 0.f) {
282 cosPhi2 = 0.f;
283 }
284 return GetY() - 2.f * CAMath::Sqrt(cosPhi2) / qptBz;
285}
286} // namespace o2::gpu
287
288#endif
uint64_t phase
Definition RawEventData.h:7
int32_t i
#define GPUrestrict()
#define GPUCA_MAX_SIN_PHI
GPUdi() void UnmarkClusters(GPUTPCGMMergedTrackHit *GPUrestrict() clusters
GPUTPCGMPropagator int32_t int32_t int32_t float toAlpha
GPUd() void Rotate(float alpha)
GPUd() void SetCov(int32_t i
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ int32_t & N
GPUd() float GetPar(int32_t i) const
GPUd() float GetKappa(float Bz) const
GPUd() void StoreOuter(gputpcgmmergertypes int32_t loopIdx
GPUd() float GetErr2Y() const
GPUd() float GetErr2QPt() const
GPUd() float GetQPt() const
GPUd() void SetPar(int32_t i
GPUd() void SetNDF(int32_t v)
GPUTPCGMPropagator int32_t int32_t int32_t float float toX
GPUd() float GetErr2Z() const
int32_t int32_t int32_t toRow
int32_t int32_t int32_t int32_t bool goodLeg
float float bool const GPUParam uint8_t uint8_t bool mirrorParameters
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ int32_t int32_t & NTolerated
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator float & xx
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ int32_t int32_t float int32_t attempt
GPUd() float Err2SinPhi() const
GPUd() void SetChi2(float v)
GPUTPCGMPropagator int32_t int32_t int32_t float float float int32_t toSector
GPUd() float GetChi2() const
int32_t float float float float x2
GPUd() int32_t GetNDF() const
float float bool const GPUParam uint8_t row
float float bool const GPUParam uint8_t uint8_t bool int8_t sector
float float bool const GPUParam uint8_t uint8_t clusterState
GPUd() float GetErr2SinPhi() const
GPUd() float GetMirroredY(float Bz) const
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ int32_t int32_t float & Alpha
GPUd() const float *GetPar() const
int32_t GPUTPCGMMergedTrackHit * clusters
GPUd() float GetTZOffset() const
GPUd() float GetCov(int32_t i) const
GPUdi() static void NormalizeAlpha(float &alpha)
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ int32_t int32_t float int32_t float gputpcgmmergertypes::GPUTPCOuterParam * outerParam
int32_t int32_t int32_t bool float float Z
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ * clustersXYZ
GPUd() float GetDzDs() const
int32_t int32_t int32_t uint8_t state
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator float float float int32_t float uint8_t bool rejectChi2
int32_t int32_t int32_t bool float Y
GPUd() float Err2DzDs() const
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator float float & yy
GPUd() float GetSinPhi() const
GPUd() float GetErr2DzDs() const
GPUdi() void MarkClusters(GPUTPCGMMergedTrackHit *GPUrestrict() clusters
int32_t int32_t int32_t float GPUTPCGMPropagator bool phase2
int32_t int32_t int32_t int32_t iTrack
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator float float float int32_t maxN
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator float float float & zz
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger * merger
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator float float float int32_t float clAlpha
GPUd() const float *GetCov() const
GPUd() float Err2QPt() const
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ const GPUTPCGMMerger GPUTPCGMPropagator & prop
GPUdi() static void Assign(float &x
GPUd() float GetCosPhi() const
int32_t GPUTPCGMMergedTrackHit GPUTPCGMMergedTrackHitXYZ int32_t int32_t float int32_t float maxSinPhi
int32_t int32_t int32_t int32_t bool GPUTPCGMPropagator bool float bool checkdEdx
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLuint GLfloat GLfloat GLfloat x1
Definition glcorearb.h:5034
GLdouble GLdouble right
Definition glcorearb.h:4077
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLfloat param
Definition glcorearb.h:271
GLint GLuint mask
Definition glcorearb.h:291