Project
Loading...
Searching...
No Matches
GPUTPCTrackParam.cxx
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#include "GPUTPCTrackParam.h"
17#include "GPUTPCGeometry.h"
18
19using namespace o2::gpu;
20
21//
22// Circle in XY:
23//
24// kCLight = 0.000299792458f;
25// Kappa = -Bz*kCLight*QPt;
26// R = 1/CAMath::Abs(Kappa);
27// Xc = X - CAMath::Sin(Phi)/Kappa;
28// Yc = Y + CAMath::Cos(Phi)/Kappa;
29//
30
31GPUd() float GPUTPCTrackParam::GetDist2(const GPUTPCTrackParam& GPUrestrict() t) const
32{
33 // get squared distance between tracks
34
35 float dx = GetX() - t.GetX();
36 float dy = GetY() - t.GetY();
37 float dz = GetZ() - t.GetZ();
38 return dx * dx + dy * dy + dz * dz;
39}
40
41GPUd() float GPUTPCTrackParam::GetDistXZ2(const GPUTPCTrackParam& GPUrestrict() t) const
42{
43 // get squared distance between tracks in X&Z
44
45 float dx = GetX() - t.GetX();
46 float dz = GetZ() - t.GetZ();
47 return dx * dx + dz * dz;
48}
49
50GPUd() float GPUTPCTrackParam::GetS(float x, float y, float Bz) const
51{
52 //* Get XY path length to the given point
53
54 float k = GetKappa(Bz);
55 float ex = GetCosPhi();
56 float ey = GetSinPhi();
57 x -= GetX();
58 y -= GetY();
59 float dS = x * ex + y * ey;
60 if (CAMath::Abs(k) > 1.e-4f) {
61 dS = CAMath::ATan2(k * dS, 1 + k * (x * ey - y * ex)) / k;
62 }
63 return dS;
64}
65
66GPUd() void GPUTPCTrackParam::GetDCAPoint(float x, float y, float z, float& GPUrestrict() xp, float& GPUrestrict() yp, float& GPUrestrict() zp, float Bz) const
67{
68 //* Get the track point closest to the (x,y,z)
69
70 float x0 = GetX();
71 float y0 = GetY();
72 float k = GetKappa(Bz);
73 float ex = GetCosPhi();
74 float ey = GetSinPhi();
75 float dx = x - x0;
76 float dy = y - y0;
77 float ax = dx * k + ey;
78 float ay = dy * k - ex;
79 float a = CAMath::Sqrt(ax * ax + ay * ay);
80 xp = x0 + (dx - ey * ((dx * dx + dy * dy) * k - 2 * (-dx * ey + dy * ex)) / (a + 1)) / a;
81 yp = y0 + (dy + ex * ((dx * dx + dy * dy) * k - 2 * (-dx * ey + dy * ex)) / (a + 1)) / a;
82 float s = GetS(x, y, Bz);
83 zp = GetZ() + GetDzDs() * s;
84 if (CAMath::Abs(k) > 1.e-2f) {
85 float dZ = CAMath::Abs(GetDzDs() * CAMath::TwoPi() / k);
86 if (dZ > .1f) {
87 zp += CAMath::Round((z - zp) / dZ) * dZ;
88 }
89 }
90}
91
92//*
93//* Transport routines
94//*
95
96GPUd() bool GPUTPCTrackParam::TransportToX(float x, GPUTPCTrackLinearisation& GPUrestrict() t0, float Bz, float maxSinPhi, float* GPUrestrict() DL)
97{
98 //* Transport the track parameters to X=x, using linearization at t0, and the field value Bz
99 //* maxSinPhi is the max. allowed value for |t0.SinPhi()|
100 //* linearisation of trajectory t0 is also transported to X=x,
101 //* returns 1 if OK
102 //*
103
104 float ex = t0.CosPhi();
105 float ey = t0.SinPhi();
106 float k = -t0.QPt() * Bz;
107 float dx = x - X();
108
109 float ey1 = k * dx + ey;
110 float ex1;
111
112 // check for intersection with X=x
113
114 if (CAMath::Abs(ey1) > maxSinPhi) {
115 return 0;
116 }
117
118 ex1 = CAMath::Sqrt(1 - ey1 * ey1);
119 if (ex < 0) {
120 ex1 = -ex1;
121 }
122
123 float dx2 = dx * dx;
124 float ss = ey + ey1;
125 float cc = ex + ex1;
126
127 if (CAMath::Abs(cc) < 1.e-4f || CAMath::Abs(ex) < 1.e-4f || CAMath::Abs(ex1) < 1.e-4f) {
128 return 0;
129 }
130
131 float tg = ss / cc; // CAMath::Tan((phi1+phi)/2)
132
133 float dy = dx * tg;
134 float dl = dx * CAMath::Sqrt(1 + tg * tg);
135
136 if (cc < 0) {
137 dl = -dl;
138 }
139 float dSin = dl * k / 2;
140 if (dSin > 1) {
141 dSin = 1;
142 }
143 if (dSin < -1) {
144 dSin = -1;
145 }
146 float dS = (CAMath::Abs(k) > 1.e-4f) ? (2 * CAMath::ASin(dSin) / k) : dl;
147 float dz = dS * t0.DzDs();
148
149 if (DL) {
150 *DL = -dS * CAMath::Sqrt(1 + t0.DzDs() * t0.DzDs());
151 }
152
153 float cci = 1.f / cc;
154 float exi = 1.f / ex;
155 float ex1i = 1.f / ex1;
156
157 float d[5] = {0, 0, GetPar(2) - t0.SinPhi(), GetPar(3) - t0.DzDs(), GetPar(4) - t0.QPt()};
158
159 // float H0[5] = { 1,0, h2, 0, h4 };
160 // float H1[5] = { 0, 1, 0, dS, 0 };
161 // float H2[5] = { 0, 0, 1, 0, dxBz };
162 // float H3[5] = { 0, 0, 0, 1, 0 };
163 // float H4[5] = { 0, 0, 0, 0, 1 };
164
165 float h2 = dx * (1 + ey * ey1 + ex * ex1) * exi * ex1i * cci;
166 float h4 = dx2 * (cc + ss * ey1 * ex1i) * cci * cci * (-Bz);
167 float dxBz = dx * (-Bz);
168
169 t0.SetCosPhi(ex1);
170 t0.SetSinPhi(ey1);
171
172 SetX(X() + dx);
173 SetPar(0, Y() + dy + h2 * d[2] + h4 * d[4]);
174 SetPar(1, Z() + dz + dS * d[3]);
175 SetPar(2, t0.SinPhi() + d[2] + dxBz * d[4]);
176
177 float c00 = mParam.mC[0];
178 float c10 = mParam.mC[1];
179 float c11 = mParam.mC[2];
180 float c20 = mParam.mC[3];
181 float c21 = mParam.mC[4];
182 float c22 = mParam.mC[5];
183 float c30 = mParam.mC[6];
184 float c31 = mParam.mC[7];
185 float c32 = mParam.mC[8];
186 float c33 = mParam.mC[9];
187 float c40 = mParam.mC[10];
188 float c41 = mParam.mC[11];
189 float c42 = mParam.mC[12];
190 float c43 = mParam.mC[13];
191 float c44 = mParam.mC[14];
192
193 mParam.mC[0] = c00 + h2 * h2 * c22 + h4 * h4 * c44 + 2 * (h2 * c20 + h4 * c40 + h2 * h4 * c42);
194
195 mParam.mC[1] = c10 + h2 * c21 + h4 * c41 + dS * (c30 + h2 * c32 + h4 * c43);
196 mParam.mC[2] = c11 + 2 * dS * c31 + dS * dS * c33;
197
198 mParam.mC[3] = c20 + h2 * c22 + h4 * c42 + dxBz * (c40 + h2 * c42 + h4 * c44);
199 mParam.mC[4] = c21 + dS * c32 + dxBz * (c41 + dS * c43);
200 mParam.mC[5] = c22 + 2 * dxBz * c42 + dxBz * dxBz * c44;
201
202 mParam.mC[6] = c30 + h2 * c32 + h4 * c43;
203 mParam.mC[7] = c31 + dS * c33;
204 mParam.mC[8] = c32 + dxBz * c43;
205 mParam.mC[9] = c33;
206
207 mParam.mC[10] = c40 + h2 * c42 + h4 * c44;
208 mParam.mC[11] = c41 + dS * c43;
209 mParam.mC[12] = c42 + dxBz * c44;
210 mParam.mC[13] = c43;
211 mParam.mC[14] = c44;
212
213 return 1;
214}
215
216GPUd() bool GPUTPCTrackParam::TransportToX(float x, float sinPhi0, float cosPhi0, float Bz, float maxSinPhi)
217{
218 //* Transport the track parameters to X=x, using linearization at phi0 with 0 curvature,
219 //* and the field value Bz
220 //* maxSinPhi is the max. allowed value for |t0.SinPhi()|
221 //* linearisation of trajectory t0 is also transported to X=x,
222 //* returns 1 if OK
223 //*
224
225 float ex = cosPhi0;
226 float ey = sinPhi0;
227 float dx = x - X();
228
229 if (CAMath::Abs(ex) < 1.e-4f) {
230 return 0;
231 }
232 float exi = 1.f / ex;
233
234 float dxBz = dx * (-Bz);
235 float dS = dx * exi;
236 float h2 = dS * exi * exi;
237 float h4 = .5f * h2 * dxBz;
238
239 // float H0[5] = { 1,0, h2, 0, h4 };
240 // float H1[5] = { 0, 1, 0, dS, 0 };
241 // float H2[5] = { 0, 0, 1, 0, dxBz };
242 // float H3[5] = { 0, 0, 0, 1, 0 };
243 // float H4[5] = { 0, 0, 0, 0, 1 };
244
245 float sinPhi = SinPhi() + dxBz * QPt();
246 if (maxSinPhi > 0 && CAMath::Abs(sinPhi) > maxSinPhi) {
247 return 0;
248 }
249
250 SetX(X() + dx);
251 SetPar(0, GetPar(0) + dS * ey + h2 * (SinPhi() - ey) + h4 * QPt());
252 SetPar(1, GetPar(1) + dS * DzDs());
253 SetPar(2, sinPhi);
254
255 float c00 = mParam.mC[0];
256 float c10 = mParam.mC[1];
257 float c11 = mParam.mC[2];
258 float c20 = mParam.mC[3];
259 float c21 = mParam.mC[4];
260 float c22 = mParam.mC[5];
261 float c30 = mParam.mC[6];
262 float c31 = mParam.mC[7];
263 float c32 = mParam.mC[8];
264 float c33 = mParam.mC[9];
265 float c40 = mParam.mC[10];
266 float c41 = mParam.mC[11];
267 float c42 = mParam.mC[12];
268 float c43 = mParam.mC[13];
269 float c44 = mParam.mC[14];
270
271 // This is not the correct propagation!!! The max ensures the positional error does not decrease during track finding.
272 // A different propagation method is used for the fit.
273 mParam.mC[0] = CAMath::Max(c00, c00 + h2 * h2 * c22 + h4 * h4 * c44 + 2 * (h2 * c20 + h4 * c40 + h2 * h4 * c42));
274
275 mParam.mC[1] = c10 + h2 * c21 + h4 * c41 + dS * (c30 + h2 * c32 + h4 * c43);
276 mParam.mC[2] = CAMath::Max(c11, c11 + 2 * dS * c31 + dS * dS * c33);
277
278 mParam.mC[3] = c20 + h2 * c22 + h4 * c42 + dxBz * (c40 + h2 * c42 + h4 * c44);
279 mParam.mC[4] = c21 + dS * c32 + dxBz * (c41 + dS * c43);
280 mParam.mC[5] = c22 + 2 * dxBz * c42 + dxBz * dxBz * c44;
281
282 mParam.mC[6] = c30 + h2 * c32 + h4 * c43;
283 mParam.mC[7] = c31 + dS * c33;
284 mParam.mC[8] = c32 + dxBz * c43;
285 mParam.mC[9] = c33;
286
287 mParam.mC[10] = c40 + h2 * c42 + h4 * c44;
288 mParam.mC[11] = c41 + dS * c43;
289 mParam.mC[12] = c42 + dxBz * c44;
290 mParam.mC[13] = c43;
291 mParam.mC[14] = c44;
292
293 return 1;
294}
295
296GPUd() bool GPUTPCTrackParam::TransportToX(float x, float Bz, float maxSinPhi)
297{
298 //* Transport the track parameters to X=x
300 return TransportToX(x, t0, Bz, maxSinPhi);
301}
302
303GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, GPUTPCTrackLinearisation& GPUrestrict() t0, GPUTPCTrackFitParam& GPUrestrict() par, float Bz, float maxSinPhi)
304{
305 //* Transport the track parameters to X=x taking into account material budget
306
307 constexpr float kRho = 1.025e-3f; // [g/cm^3]
308 constexpr float kRadLen = 28811.7f; //[cm]
309
310 constexpr float kRadLenInv = 1.f / kRadLen;
311 float dl;
312
313 if (!TransportToX(x, t0, Bz, maxSinPhi, &dl)) {
314 return 0;
315 }
316
317 CorrectForMeanMaterial(dl * kRadLenInv, dl * kRho, par);
318 return 1;
319}
320
321GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, GPUTPCTrackFitParam& GPUrestrict() par, float Bz, float maxSinPhi)
322{
323 //* Transport the track parameters to X=x taking into account material budget
324
326 return TransportToXWithMaterial(x, t0, par, Bz, maxSinPhi);
327}
328
329GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, float Bz, float maxSinPhi)
330{
331 //* Transport the track parameters to X=x taking into account material budget
332
333 GPUTPCTrackFitParam par;
334 CalculateFitParameters(par);
335 return TransportToXWithMaterial(x, par, Bz, maxSinPhi);
336}
337
338//*
339//* Multiple scattering and energy losses
340//*
341GPUd() float GPUTPCTrackParam::BetheBlochGeant(float bg2, float kp0, float kp1, float kp2, float kp3, float kp4)
342{
343 //
344 // This is the parameterization of the Bethe-Bloch formula inspired by Geant.
345 //
346 // bg2 - (beta*gamma)^2
347 // kp0 - density [g/cm^3]
348 // kp1 - density effect first junction point
349 // kp2 - density effect second junction point
350 // kp3 - mean excitation energy [GeV]
351 // kp4 - mean Z/A
352 //
353 // The default values for the kp* parameters are for silicon.
354 // The returned value is in [GeV/(g/cm^2)].
355 //
356
357 const float mK = 0.307075e-3f; // [GeV*cm^2/g]
358 const float me = 0.511e-3f; // [GeV/c^2]
359 const float rho = kp0;
360 const float x0 = kp1 * 2.303f;
361 const float x1 = kp2 * 2.303f;
362 const float mI = kp3;
363 const float mZA = kp4;
364 const float maxT = 2 * me * bg2; // neglecting the electron mass
365
366 //*** Density effect
367 float d2 = 0.f;
368 const float x = 0.5f * CAMath::Log(bg2);
369 const float lhwI = CAMath::Log(28.816f * 1e-9f * CAMath::Sqrt(rho * mZA) / mI);
370 if (x > x1) {
371 d2 = lhwI + x - 0.5f;
372 } else if (x > x0) {
373 const float r = (x1 - x) / (x1 - x0);
374 d2 = lhwI + x - 0.5f + (0.5f - lhwI - x0) * r * r * r;
375 }
376
377 return mK * mZA * (1 + bg2) / bg2 * (0.5f * CAMath::Log(2 * me * bg2 * maxT / (mI * mI)) - bg2 / (1 + bg2) - d2);
378}
379
380GPUd() float GPUTPCTrackParam::BetheBlochSolid(float bg)
381{
382 //------------------------------------------------------------------
383 // This is an approximation of the Bethe-Bloch formula,
384 // reasonable for solid materials.
385 // All the parameters are, in fact, for Si.
386 // The returned value is in [GeV]
387 //------------------------------------------------------------------
388
389 return BetheBlochGeant(bg);
390}
391
392GPUd() float GPUTPCTrackParam::BetheBlochGas(float bg)
393{
394 //------------------------------------------------------------------
395 // This is an approximation of the Bethe-Bloch formula,
396 // reasonable for gas materials.
397 // All the parameters are, in fact, for Ne.
398 // The returned value is in [GeV]
399 //------------------------------------------------------------------
400
401 const float rho = 0.9e-3f;
402 const float x0 = 2.f;
403 const float x1 = 4.f;
404 const float mI = 140.e-9f;
405 const float mZA = 0.49555f;
406
407 return BetheBlochGeant(bg, rho, x0, x1, mI, mZA);
408}
409
410GPUd() float GPUTPCTrackParam::ApproximateBetheBloch(float beta2)
411{
412 //------------------------------------------------------------------
413 // This is an approximation of the Bethe-Bloch formula with
414 // the density effect taken into account at beta*gamma > 3.5
415 // (the approximation is reasonable only for solid materials)
416 //------------------------------------------------------------------
417 if (beta2 >= 1) {
418 return 0;
419 }
420
421 if (beta2 / (1 - beta2) > 3.5f * 3.5f) {
422 return 0.153e-3f / beta2 * (CAMath::Log(3.5f * 5940) + 0.5f * CAMath::Log(beta2 / (1 - beta2)) - beta2);
423 }
424 return 0.153e-3f / beta2 * (CAMath::Log(5940 * beta2 / (1 - beta2)) - beta2);
425}
426
427GPUd() void GPUTPCTrackParam::CalculateFitParameters(GPUTPCTrackFitParam& par, float mass)
428{
429 //*!
430
431 float qpt = GetPar(4);
432 if (mParam.mC[14] >= 1.f) {
433 qpt = 1.f / 0.35f;
434 }
435
436 float p2 = (1.f + GetPar(3) * GetPar(3));
437 float k2 = qpt * qpt;
438 float mass2 = mass * mass;
439 float beta2 = p2 / (p2 + mass2 * k2);
440
441 float pp2 = (k2 > 1.e-8f) ? p2 / k2 : 10000; // impuls 2
442
443 // par.bethe = BetheBlochGas( pp2/mass2);
444 par.bethe = ApproximateBetheBloch(pp2 / mass2);
445 par.e = CAMath::Sqrt(pp2 + mass2);
446 par.theta2 = 14.1f * 14.1f / (beta2 * pp2 * 1e6f);
447 par.EP2 = par.e / pp2;
448
449 // Approximate energy loss fluctuation (M.Ivanov)
450
451 const float knst = 0.0007f; // To be tuned.
452 par.sigmadE2 = knst * par.EP2 * qpt;
453 par.sigmadE2 = par.sigmadE2 * par.sigmadE2;
454
455 par.k22 = (1.f + GetPar(3) * GetPar(3));
456 par.k33 = par.k22 * par.k22;
457 par.k43 = 0;
458 par.k44 = GetPar(3) * GetPar(3) * k2;
459}
460
461GPUd() bool GPUTPCTrackParam::CorrectForMeanMaterial(float xOverX0, float xTimesRho, const GPUTPCTrackFitParam& par)
462{
463 //------------------------------------------------------------------
464 // This function corrects the track parameters for the crossed material.
465 // "xOverX0" - X/X0, the thickness in units of the radiation length.
466 // "xTimesRho" - is the product length*density (g/cm^2).
467 //------------------------------------------------------------------
468
469 float& mC22 = mParam.mC[5];
470 float& mC33 = mParam.mC[9];
471 float& mC40 = mParam.mC[10];
472 float& mC41 = mParam.mC[11];
473 float& mC42 = mParam.mC[12];
474 float& mC43 = mParam.mC[13];
475 float& mC44 = mParam.mC[14];
476
477 // Energy losses************************
478
479 float dE = par.bethe * xTimesRho;
480 if (CAMath::Abs(dE) > 0.3f * par.e) {
481 return 0; // 30% energy loss is too much!
482 }
483 float corr = (1.f - par.EP2 * dE);
484 if (corr < 0.3f || corr > 1.3f) {
485 return 0;
486 }
487
488 SetPar(4, GetPar(4) * corr);
489 mC40 *= corr;
490 mC41 *= corr;
491 mC42 *= corr;
492 mC43 *= corr;
493 mC44 *= corr * corr;
494 mC44 += par.sigmadE2 * CAMath::Abs(dE);
495
496 // Multiple scattering******************
497
498 float theta2 = par.theta2 * CAMath::Abs(xOverX0);
499 mC22 += theta2 * par.k22 * (1.f - GetPar(2)) * (1.f + GetPar(2));
500 mC33 += theta2 * par.k33;
501 mC43 += theta2 * par.k43;
502 mC44 += theta2 * par.k44;
503
504 return 1;
505}
506
507//*
508//* Rotation
509//*
510GPUd() bool GPUTPCTrackParam::Rotate(float alpha, float maxSinPhi)
511{
512 //* Rotate the coordinate system in XY on the angle alpha
513
514 float cA = CAMath::Cos(alpha);
515 float sA = CAMath::Sin(alpha);
516 float x = X(), y = Y(), sP = SinPhi(), cP = GetCosPhi();
517 float cosPhi = cP * cA + sP * sA;
518 float sinPhi = -cP * sA + sP * cA;
519
520 if (CAMath::Abs(sinPhi) > maxSinPhi || CAMath::Abs(cosPhi) < 1.e-2f || CAMath::Abs(cP) < 1.e-2f) {
521 return 0;
522 }
523
524 float j0 = cP / cosPhi;
525 float j2 = cosPhi / cP;
526
527 SetX(x * cA + y * sA);
528 SetY(-x * sA + y * cA);
529 SetSignCosPhi(cosPhi);
530 SetSinPhi(sinPhi);
531
532 // float J[5][5] = { { j0, 0, 0, 0, 0 }, // Y
533 // { 0, 1, 0, 0, 0 }, // Z
534 // { 0, 0, j2, 0, 0 }, // SinPhi
535 // { 0, 0, 0, 1, 0 }, // DzDs
536 // { 0, 0, 0, 0, 1 } }; // Kappa
537 // cout<<"alpha="<<alpha<<" "<<x<<" "<<y<<" "<<sP<<" "<<cP<<" "<<j0<<" "<<j2<<endl;
538 // cout<<" "<<mParam.mC[0]<<" "<<mParam.mC[1]<<" "<<mParam.mC[6]<<" "<<mParam.mC[10]<<" "<<mParam.mC[4]<<" "<<mParam.mC[5]<<" "<<mParam.mC[8]<<" "<<mParam.mC[12]<<endl;
539 mParam.mC[0] *= j0 * j0;
540 mParam.mC[1] *= j0;
541 mParam.mC[3] *= j0;
542 mParam.mC[6] *= j0;
543 mParam.mC[10] *= j0;
544
545 mParam.mC[3] *= j2;
546 mParam.mC[4] *= j2;
547 mParam.mC[5] *= j2 * j2;
548 mParam.mC[8] *= j2;
549 mParam.mC[12] *= j2;
550
551 if (cosPhi < 0) {
552 SetSinPhi(-SinPhi());
553 SetDzDs(-DzDs());
554 SetQPt(-QPt());
555 mParam.mC[3] = -mParam.mC[3];
556 mParam.mC[4] = -mParam.mC[4];
557 mParam.mC[6] = -mParam.mC[6];
558 mParam.mC[7] = -mParam.mC[7];
559 mParam.mC[10] = -mParam.mC[10];
560 mParam.mC[11] = -mParam.mC[11];
561 }
562
563 // cout<<" "<<mParam.mC[0]<<" "<<mParam.mC[1]<<" "<<mParam.mC[6]<<" "<<mParam.mC[10]<<" "<<mParam.mC[4]<<" "<<mParam.mC[5]<<" "<<mParam.mC[8]<<" "<<mParam.mC[12]<<endl;
564 return 1;
565}
566
567GPUd() bool GPUTPCTrackParam::Rotate(float alpha, GPUTPCTrackLinearisation& t0, float maxSinPhi)
568{
569 //* Rotate the coordinate system in XY on the angle alpha
570
571 float cA = CAMath::Cos(alpha);
572 float sA = CAMath::Sin(alpha);
573 float x0 = X(), y0 = Y(), sP = t0.SinPhi(), cP = t0.CosPhi();
574 float cosPhi = cP * cA + sP * sA;
575 float sinPhi = -cP * sA + sP * cA;
576
577 if (CAMath::Abs(sinPhi) > maxSinPhi || CAMath::Abs(cosPhi) < 1.e-2f || CAMath::Abs(cP) < 1.e-2f) {
578 return 0;
579 }
580
581 // float J[5][5] = { { j0, 0, 0, 0, 0 }, // Y
582 // { 0, 1, 0, 0, 0 }, // Z
583 // { 0, 0, j2, 0, 0 }, // SinPhi
584 // { 0, 0, 0, 1, 0 }, // DzDs
585 // { 0, 0, 0, 0, 1 } }; // Kappa
586
587 float j0 = cP / cosPhi;
588 float j2 = cosPhi / cP;
589 float d[2] = {Y() - y0, SinPhi() - sP};
590
591 SetX(x0 * cA + y0 * sA);
592 SetY(-x0 * sA + y0 * cA + j0 * d[0]);
593 t0.SetCosPhi(cosPhi);
594 t0.SetSinPhi(sinPhi);
595
596 SetSinPhi(sinPhi + j2 * d[1]);
597
598 mParam.mC[0] *= j0 * j0;
599 mParam.mC[1] *= j0;
600 mParam.mC[3] *= j0;
601 mParam.mC[6] *= j0;
602 mParam.mC[10] *= j0;
603
604 mParam.mC[3] *= j2;
605 mParam.mC[4] *= j2;
606 mParam.mC[5] *= j2 * j2;
607 mParam.mC[8] *= j2;
608 mParam.mC[12] *= j2;
609
610 return 1;
611}
612
613GPUd() bool GPUTPCTrackParam::Filter(float y, float z, float err2Y, float err2Z, float maxSinPhi, bool paramOnly)
614{
615 //* Add the y,z measurement with the Kalman filter
616
617 float c00 = mParam.mC[0], c11 = mParam.mC[2], c20 = mParam.mC[3], c31 = mParam.mC[7], c40 = mParam.mC[10];
618
619 err2Y += c00;
620 err2Z += c11;
621
622 float z0 = y - GetPar(0), z1 = z - GetPar(1);
623
624 if (err2Y < 1.e-8f || err2Z < 1.e-8f) {
625 return 0;
626 }
627
628 float mS0 = 1.f / err2Y;
629 float mS2 = 1.f / err2Z;
630
631 // K = CHtS
632
633 float k00, k11, k20, k31, k40;
634
635 k00 = c00 * mS0;
636 k20 = c20 * mS0;
637 k40 = c40 * mS0;
638
639 k11 = c11 * mS2;
640 k31 = c31 * mS2;
641
642 float sinPhi = GetPar(2) + k20 * z0;
643
644 if (maxSinPhi > 0 && CAMath::Abs(sinPhi) >= maxSinPhi) {
645 return 0;
646 }
647
648 SetPar(0, GetPar(0) + k00 * z0);
649 SetPar(1, GetPar(1) + k11 * z1);
650 SetPar(2, sinPhi);
651 SetPar(3, GetPar(3) + k31 * z1);
652 SetPar(4, GetPar(4) + k40 * z0);
653 if (paramOnly) {
654 return true;
655 }
656
657 mNDF += 2;
658 mChi2 += mS0 * z0 * z0 + mS2 * z1 * z1;
659
660 mParam.mC[0] -= k00 * c00;
661 mParam.mC[3] -= k20 * c00;
662 mParam.mC[5] -= k20 * c20;
663 mParam.mC[10] -= k40 * c00;
664 mParam.mC[12] -= k40 * c20;
665 mParam.mC[14] -= k40 * c40;
666
667 mParam.mC[2] -= k11 * c11;
668 mParam.mC[7] -= k31 * c11;
669 mParam.mC[9] -= k31 * c31;
670
671 return 1;
672}
673
674GPUd() bool GPUTPCTrackParam::CheckNumericalQuality() const
675{
676 //* Check that the track parameters and covariance matrix are reasonable
677
678 bool ok = CAMath::Finite(GetX()) && CAMath::Finite(mSignCosPhi) && CAMath::Finite(mChi2);
679
680 const float* c = Cov();
681 for (int32_t i = 0; i < 15; i++) {
682 ok = ok && CAMath::Finite(c[i]);
683 }
684 for (int32_t i = 0; i < 5; i++) {
685 ok = ok && CAMath::Finite(Par()[i]);
686 }
687
688 if (c[0] <= 0 || c[2] <= 0 || c[5] <= 0 || c[9] <= 0 || c[14] <= 0) {
689 ok = 0;
690 }
691 if (c[0] > 5.f || c[2] > 5.f || c[5] > 2.f || c[9] > 2
692 //|| ( CAMath::Abs( QPt() ) > 1.e-2f && c[14] > 2.f )
693 ) {
694 ok = 0;
695 }
696
697 if (CAMath::Abs(SinPhi()) > constants::MAX_SIN_PHI) {
698 ok = 0;
699 }
700 if (CAMath::Abs(QPt()) > 1.f / 0.05f) {
701 ok = 0;
702 }
703 if (ok) {
704 ok = ok && (c[1] * c[1] <= c[2] * c[0]) && (c[3] * c[3] <= c[5] * c[0]) && (c[4] * c[4] <= c[5] * c[2]) && (c[6] * c[6] <= c[9] * c[0]) && (c[7] * c[7] <= c[9] * c[2]) && (c[8] * c[8] <= c[9] * c[5]) && (c[10] * c[10] <= c[14] * c[0]) && (c[11] * c[11] <= c[14] * c[2]) &&
705 (c[12] * c[12] <= c[14] * c[5]) && (c[13] * c[13] <= c[14] * c[9]);
706 }
707 return ok;
708}
709
710GPUd() void GPUTPCTrackParam::ConstrainZ(float& z, uint32_t sector, float& z0, float& lastZ)
711{
712 if (sector < GPUTPCGeometry::NSECTORS / 2) {
713 if (z < 0) {
714 mParam.mZOffset += z;
715 mParam.mP[1] -= z;
716 z0 -= z;
717 lastZ -= z;
718 z = 0;
719 } else if (z > GPUTPCGeometry::TPCLength()) {
720 float shift = z - GPUTPCGeometry::TPCLength();
721 mParam.mZOffset += shift;
722 mParam.mP[1] -= shift;
723 z0 -= shift;
724 lastZ -= shift;
725 z = GPUTPCGeometry::TPCLength();
726 }
727 } else {
728 if (z > 0) {
729 mParam.mZOffset += z;
730 mParam.mP[1] -= z;
731 z0 -= z;
732 lastZ -= z;
733 z = 0;
734 } else if (z < -GPUTPCGeometry::TPCLength()) {
735 float shift = -GPUTPCGeometry::TPCLength() - z;
736 mParam.mZOffset -= shift;
737 mParam.mP[1] += shift;
738 z0 += shift;
739 lastZ += shift;
740 z = -GPUTPCGeometry::TPCLength();
741 }
742 }
743}
744
745GPUd() void GPUTPCTrackParam::ShiftZ(float z1, float z2, float x1, float x2, float bz, float defaultZOffsetOverR)
746{
747 const float r1 = CAMath::Max(0.0001f, CAMath::Abs(mParam.mP[4] * bz));
748 float deltaZ = 0.f;
749 bool beamlineReached = false;
750
751 if (r1 < 0.01501) { // 100 MeV @ 0.5T ~ 0.66m cutof
752 const float dist2 = mParam.mX * mParam.mX + mParam.mP[0] * mParam.mP[0];
753 const float dist1r2 = dist2 * r1 * r1;
754 if (dist1r2 < 4) {
755 const float alpha = CAMath::ACos(1 - 0.5f * dist1r2); // Angle of a circle, such that |(cosa, sina) - (1,0)| == dist
756 const float beta = CAMath::ATan2(mParam.mP[0], mParam.mX);
757 const int32_t comp = mParam.mP[2] > CAMath::Sin(beta);
758 const float sinab = CAMath::Sin((comp ? 0.5f : -0.5f) * alpha + beta); // Angle of circle through origin and track position, to be compared to Snp
759 const float res = CAMath::Abs(sinab - mParam.mP[2]);
760
761 if (res < 0.2f) {
762 const float r = 1.f / r1;
763 const float dS = alpha * r;
764 float z0 = dS * mParam.mP[3];
765 if (CAMath::Abs(z0) > GPUTPCGeometry::TPCLength()) {
766 z0 = z0 > 0 ? GPUTPCGeometry::TPCLength() : -GPUTPCGeometry::TPCLength();
767 }
768 deltaZ = mParam.mP[1] - z0;
769 beamlineReached = true;
770 }
771 }
772 }
773
774 if (!beamlineReached) {
775 float basez, basex;
776 if (CAMath::Abs(z1) < CAMath::Abs(z2)) {
777 basez = z1;
778 basex = x1;
779 } else {
780 basez = z2;
781 basex = x2;
782 }
783 float refZ = ((basez > 0) ? defaultZOffsetOverR : -defaultZOffsetOverR) * basex;
784 deltaZ = basez - refZ - mParam.mZOffset;
785 }
786 mParam.mZOffset += deltaZ;
787 mParam.mP[1] -= deltaZ;
788 deltaZ = 0;
789 float zMax = CAMath::Max(z1, z2);
790 float zMin = CAMath::Min(z1, z2);
791 if (zMin < 0 && zMin - mParam.mZOffset < -GPUTPCGeometry::TPCLength()) {
792 deltaZ = zMin - mParam.mZOffset + GPUTPCGeometry::TPCLength();
793 } else if (zMax > 0 && zMax - mParam.mZOffset > GPUTPCGeometry::TPCLength()) {
794 deltaZ = zMax - mParam.mZOffset - GPUTPCGeometry::TPCLength();
795 }
796 if (zMin < 0 && zMax - (mParam.mZOffset + deltaZ) > 0) {
797 deltaZ = zMax - mParam.mZOffset;
798 } else if (zMax > 0 && zMin - (mParam.mZOffset + deltaZ) < 0) {
799 deltaZ = zMin - mParam.mZOffset;
800 }
801 mParam.mZOffset += deltaZ;
802 mParam.mP[1] -= deltaZ;
803}
804
805#if !defined(GPUCA_GPUCODE)
806#include <iostream>
807#endif
808
809GPUd() void GPUTPCTrackParam::Print() const
810{
811 //* print parameters
812
813#if !defined(GPUCA_GPUCODE)
814 std::cout << "track: x=" << GetX() << " c=" << GetSignCosPhi() << ", P= " << GetY() << " " << GetZ() << " " << GetSinPhi() << " " << GetDzDs() << " " << GetQPt() << std::endl;
815 std::cout << "errs2: " << Err2Y() << " " << Err2Z() << " " << Err2SinPhi() << " " << Err2DzDs() << " " << Err2QPt() << std::endl;
816#endif
817}
818
819GPUd() int32_t GPUTPCTrackParam::GetPropagatedYZ(float bz, float x, float& projY, float& projZ) const
820{
821 float k = mParam.mP[4] * bz;
822 float dx = x - mParam.mX;
823 float ey = mParam.mP[2];
824 float ex = CAMath::Sqrt(1 - ey * ey);
825 if (SignCosPhi() < 0) {
826 ex = -ex;
827 }
828 float ey1 = ey - k * dx;
829 if (CAMath::Abs(ey1) > constants::MAX_SIN_PHI) {
830 return 0;
831 }
832 float ss = ey + ey1;
833 float ex1 = CAMath::Sqrt(1.f - ey1 * ey1);
834 if (SignCosPhi() < 0) {
835 ex1 = -ex1;
836 }
837 float cc = ex + ex1;
838 float dxcci = dx / cc;
839 float dy = dxcci * ss;
840 float norm2 = 1.f + ey * ey1 + ex * ex1;
841 float dl = dxcci * CAMath::Sqrt(norm2 + norm2);
842 float dS;
843 {
844 float dSin = 0.5f * k * dl;
845 float a = dSin * dSin;
846 const float k2 = 1.f / 6.f;
847 const float k4 = 3.f / 40.f;
848 dS = dl + dl * a * (k2 + a * (k4));
849 }
850 float dz = dS * mParam.mP[3];
851 projY = mParam.mP[0] + dy;
852 projZ = mParam.mP[1] + dz;
853 return 1;
854}
int32_t i
#define GPUrestrict()
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
GPUd() float GPUTPCTrackParam
float float float & zMax
constexpr int p2()
float zMin
uint32_t res
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLfloat GLfloat GLfloat x1
Definition glcorearb.h:5034
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat x0
Definition glcorearb.h:5034
GLboolean r
Definition glcorearb.h:1233
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint GLfloat GLfloat y0
Definition glcorearb.h:5034
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
float float x2
Definition MathUtils.h:49
float float float float float z2
Definition MathUtils.h:83
const float k2
Definition MathUtils.h:75
float float float float z1
Definition MathUtils.h:82
const float dx2
Definition MathUtils.h:57
o2::track::TrackParametrization< float > par
const float const float const float bz
constexpr value_T me
Definition TrackUtils.h:128
kp1 *kp2 *value_T bg2
Definition TrackUtils.h:131
value_T d2
Definition TrackUtils.h:135
kp1 *kp2 *value_T beta2
Definition TrackUtils.h:131
value_T maxT
Definition TrackUtils.h:132
constexpr value_T mK
Definition TrackUtils.h:127
value_T rho
Definition TrackUtils.h:36
const value_T lhwI
Definition TrackUtils.h:137
std::vector< o2::mch::ChannelCode > cc