Project
Loading...
Searching...
No Matches
TrackParametrization.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
16
17/*
18 24/09/2020: Added new data member for abs. charge. This is needed for uniform treatment of tracks with non-standard
19 charge: 0 (for V0s) and e.g. 2 for hypernuclei.
20 In the aliroot AliExternalTrackParam this was treated by derived classes using virtual methods, which we don't use in O2.
21 The meaning of mP[kQ2Pt] remains exactly the same, except for q=0 case: in this case the mP[kQ2Pt] is just an alias to
22 1/pT, regardless of its sign, and the getCurvature() will 0 (because mAbsCharge is 0).
23 The methods returning lab momentum or its combination account for eventual q>1.
24 */
25
26#ifndef INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATION_H_
27#define INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATION_H_
28
29#include "GPUCommonDef.h"
30#include "GPUCommonRtypes.h"
31#include "GPUCommonMath.h"
32#include "GPUROOTCartesianFwd.h"
33
34#ifndef GPUCA_GPUCODE_DEVICE
35#include <algorithm>
36#include <cfloat>
37#include <cmath>
38#include <cstring>
39#include <iosfwd>
40#include <type_traits>
41#include <array>
42#endif
43
44#ifndef GPUCA_ALIGPUCODE // Used only by functions that are hidden on the GPU
46#include <string>
47#endif
48
50#include "MathUtils/Utils.h"
53
55
56namespace o2
57{
58template <typename T>
59class BaseCluster;
60
61namespace dataformats
62{
63class VertexBase;
64class DCA;
65} // namespace dataformats
66
67namespace track
68{
69
70class TrackParFwd; // fwd declaration for conversion method
71
72// aliases for track elements
73enum ParLabels : int { kY,
95
96enum DirType : int { DirInward = -1,
99
100GPUglobalconstexpr() int kNParams = 5, kCovMatSize = 15, kLabCovMatSize = 21;
101
102GPUglobalconstexpr() float kCY2max = 100 * 100, // SigmaY<=100cm
103 kCZ2max = 100 * 100, // SigmaZ<=100cm
104 kCSnp2max = 1 * 1, // SigmaSin<=1
105 kCTgl2max = 1 * 1, // SigmaTan<=1
106 kC1Pt2max = 100 * 100, // Sigma1/Pt<=100 1/GeV
107 kMostProbablePt = 0.6f, // Most Probable Pt (GeV), for running with Bz=0
108 kCalcdEdxAuto = -999.f; // value indicating request for dedx calculation
109
110// access to covariance matrix by row and column
111GPUconstexpr() int CovarMap[kNParams][kNParams] = {{0, 1, 3, 6, 10},
112 {1, 2, 4, 7, 11},
113 {3, 4, 5, 8, 12},
114 {6, 7, 8, 9, 13},
115 {10, 11, 12, 13, 14}};
116
117// access to covariance matrix diagonal elements
118GPUconstexpr() int DiagMap[kNParams] = {0, 2, 5, 9, 14};
119
120GPUglobalconstexpr() float HugeF = o2::constants::math::VeryBig;
121GPUglobalconstexpr() float MaxPT = 100000.; // do not allow pTs exceeding this value (to avoid NANs)
122GPUglobalconstexpr() float MinPTInv = 1. / MaxPT; // do not allow q/pTs less this value (to avoid NANs)
123GPUglobalconstexpr() float ELoss2EKinThreshInv = 1. / 0.025; // do not allow E.Loss correction step with dE/Ekin above the inverse of this value
124GPUglobalconstexpr() int MaxELossIter = 50; // max number of iteration for the ELoss to account for BB dependence on beta*gamma
125GPUglobalconstexpr() float DefaultDCA = 999.f; // default DCA value
126GPUglobalconstexpr() float DefaultDCACov = 999.f; // default DCA cov value
127
128// uncomment this to enable correction for BB dependence on beta*gamma via BB derivative
129// #define _BB_NONCONST_CORR_
130
131template <typename value_T = float>
133{ // track parameterization, kinematics only.
134
135 public:
136 using value_t = value_T;
137 using dim2_t = std::array<value_t, 2>;
138 using dim3_t = std::array<value_t, 3>;
139 using params_t = std::array<value_t, kNParams>;
140
141 struct yzerr_t { // 2 measurement with error
144 };
145
146#ifndef GPUCA_GPUCODE_DEVICE
147 static_assert(std::is_floating_point_v<value_t>);
148#endif
149
151 GPUd() TrackParametrization(value_t x, value_t alpha, const params_t& par, int charge = 1, const PID pid = PID::Pion);
152 GPUd() TrackParametrization(const dim3_t& xyz, const dim3_t& pxpypz, int charge, bool sectorAlpha = true, const PID pid = PID::Pion);
158
159 GPUd() void set(value_t x, value_t alpha, const params_t& par, int charge = 1, const PID pid = PID::Pion);
160 GPUd() void set(value_t x, value_t alpha, const value_t* par, int charge = 1, const PID pid = PID::Pion);
161 GPUd() const value_t* getParams() const;
162 GPUd() value_t getParam(int i) const;
163 GPUd() value_t getX() const;
164 GPUd() value_t getAlpha() const;
165 GPUd() value_t getY() const;
166 GPUd() value_t getZ() const;
167 GPUd() value_t getSnp() const;
168 GPUd() value_t getTgl() const;
169 GPUhd() value_t getQ2Pt() const;
170 GPUd() value_t getCharge2Pt() const;
171 GPUd() value_t getR2() const;
172 GPUd() value_t getR() const;
173 GPUd() int getAbsCharge() const;
174 GPUd() PID getPID() const;
175 GPUd() void setPID(const PID pid, bool passCharge = false);
176
178 GPUd() value_t getCsp2() const;
179 GPUd() value_t getCsp() const;
180
181 GPUd() void setX(value_t v);
182 GPUd() void setParam(value_t v, int i);
183 GPUd() void setAlpha(value_t v);
184 GPUd() void setY(value_t v);
185 GPUd() void setZ(value_t v);
186 GPUd() void setSnp(value_t v);
187 GPUd() void setTgl(value_t v);
188 GPUd() void setQ2Pt(value_t v);
189 GPUd() void setAbsCharge(int q);
190
191 // derived getters
192 GPUd() bool getXatLabR(value_t r, value_t& x, value_t bz, DirType dir = DirAuto) const;
193 GPUd() void getCircleParamsLoc(value_t bz, o2::math_utils::CircleXY<value_t>& circle) const;
194 GPUd() void getCircleParams(value_t bz, o2::math_utils::CircleXY<value_t>& circle, value_t& sna, value_t& csa) const;
195 GPUd() void getLineParams(o2::math_utils::IntervalXY<value_t>& line, value_t& sna, value_t& csa) const;
196 GPUd() value_t getCurvature(value_t b) const;
197 GPUd() int getCharge() const;
198 GPUd() int getSign() const;
199 GPUd() value_t getPhi() const;
200 GPUd() value_t getPhiPos() const;
201
202 GPUd() value_t getQ2P2() const;
203 GPUd() value_t getPtInv() const;
204 GPUd() value_t getP2Inv() const;
205 GPUd() value_t getP2() const;
206 GPUd() value_t getPInv() const;
207 GPUd() value_t getP() const;
208 GPUd() value_t getPt() const;
209 GPUd() value_t getE2() const;
210 GPUd() value_t getE() const;
211 GPUdi() static value_t getdEdxBB(value_t betagamma) { return BetheBlochSolid(betagamma); }
212 GPUdi() static value_t getdEdxBBOpt(value_t betagamma) { return BetheBlochSolidOpt(betagamma); }
213
214 GPUdi() int nELossSteps(value_T dE, value_T ekin) const noexcept
215 {
216 const int n = 1 + int(gpu::CAMath::Abs(dE) / ekin * ELoss2EKinThreshInv);
217 return n > MaxELossIter ? MaxELossIter : n;
218 }
219 GPUd() int getELossSteps(value_t xrho, bool anglecorr) const;
220 GPUdi() static value_t getBetheBlochSolidDerivativeApprox(value_T dedx, value_T bg) { return BetheBlochSolidDerivative(dedx, bg); }
221
222 GPUd() value_t getTheta() const;
223 GPUd() value_t getEta() const;
224 GPUd() math_utils::Point3D<value_t> getXYZGlo() const;
225 GPUd() void getXYZGlo(dim3_t& xyz) const;
226 GPUd() bool getPxPyPzGlo(dim3_t& pxyz) const;
227 GPUd() bool getPosDirGlo(std::array<value_t, 9>& posdirp) const;
228
229 // methods for track params estimate at other point
230 GPUd() bool getYZAt(value_t xk, value_t b, value_t& y, value_t& z) const;
231 GPUd() value_t getZAt(value_t xk, value_t b) const;
232 GPUd() value_t getYAt(value_t xk, value_t b) const;
233 GPUd() value_t getSnpAt(value_t xk, value_t b) const;
234 GPUd() value_t getSnpAt(value_t alpha, value_t xk, value_t b) const;
235 GPUd() value_t getPhiAt(value_t xk, value_t b) const;
236 GPUd() value_t getPhiPosAt(value_t xk, value_t b) const;
237 GPUd() value_t getDCAYtoMV(value_t b, value_t xmv = 0.f, value_t ymv = 0.f, value_t zmv = 0.f) const;
238 GPUd() value_t getDCAZtoMV(value_t b, value_t xmv = 0.f, value_t ymv = 0.f, value_t zmv = 0.f) const;
239 GPUd() math_utils::Point3D<value_t> getXYZGloAt(value_t xk, value_t b, bool& ok) const;
240
241 // parameters manipulation
242 GPUd() bool correctForELoss(value_t xrho, bool anglecorr = false);
243 GPUd() bool rotateParam(value_t alpha);
244 GPUd() bool rotateParam(value_t& alpha, value_t& ca, value_t& sa);
245 GPUd() bool propagateParamTo(value_t xk, value_t b);
246 GPUd() bool propagateParamTo(value_t xk, const dim3_t& b);
247 GPUd() void invertParam();
248 GPUd() bool propagateParamToDCA(const math_utils::Point3D<value_t>& vtx, value_t b, dim2_t* dca = nullptr, value_t maxD = 999.f);
249 // aliases
250 GPUd() bool rotate(value_t alpha) { return rotateParam(alpha); }
251 GPUd() bool propagateTo(value_t xk, value_t b) { return propagateParamTo(xk, b); }
252 GPUd() bool propagateTo(value_t xk, const dim3_t& b) { return propagateParamTo(xk, b); }
253 GPUd() void invert() { invertParam(); }
254 GPUd() bool propagateToDCA(const math_utils::Point3D<value_t>& vtx, value_t b, dim2_t* dca = nullptr, value_t maxD = 999.f) { return propagateParamToDCA(vtx, b, dca, maxD); }
255
256 GPUd() bool isValid() const;
257 GPUd() void invalidate();
258
259 GPUhd() uint16_t getUserField() const;
260 GPUhd() void setUserField(uint16_t v);
261
262 GPUd() void printParam() const;
263 GPUd() void printParamHexadecimal();
264#ifndef GPUCA_ALIGPUCODE
266 std::string asString() const;
267 std::string asStringHexadecimal();
268 size_t hash() const { return hash(getX(), getAlpha(), getY(), getZ(), getSnp(), getTgl(), getQ2Pt()); }
269 static size_t hash(float x, float alp, float y, float z, float snp, float tgl, float q2pt);
270#endif
271
272 GPUd() void updateParam(value_t delta, int i);
273 GPUd() void updateParams(const params_t& delta);
274 GPUd() void updateParams(const value_t* delta);
275
276 GPUd() yzerr_t getVertexInTrackFrame(const o2::dataformats::VertexBase& vtx) const;
277
278 private:
279 //
280 static GPUglobalconstexpr() value_t InvalidX = -99999.f;
281 value_t mX = 0.f;
282 value_t mAlpha = 0.f;
283 value_t mP[kNParams] = {0.f};
284 char mAbsCharge = 1;
285 PID mPID{PID::Pion};
286 uint16_t mUserField = 0;
287
288 ClassDefNV(TrackParametrization, 3);
289};
290
291//____________________________________________________________
292template <typename value_T>
293GPUdi() TrackParametrization<value_T>::TrackParametrization(value_t x, value_t alpha, const params_t& par, int charge, const PID pid)
294 : mX{x}, mAlpha{alpha}, mAbsCharge{char(gpu::CAMath::Abs(charge))}, mPID{pid}
295{
296 // explicit constructor
297 math_utils::detail::bringToPMPi<value_t>(mAlpha);
298 for (int i = 0; i < kNParams; i++) {
299 mP[i] = par[i];
300 }
301}
302
303//____________________________________________________________
304template <typename value_T>
305GPUdi() void TrackParametrization<value_T>::set(value_t x, value_t alpha, const params_t& par, int charge, const PID pid)
306{
307 set(x, alpha, par.data(), charge, pid);
308}
309
310//____________________________________________________________
311template <typename value_T>
312GPUdi() void TrackParametrization<value_T>::set(value_t x, value_t alpha, const value_t* par, int charge, const PID pid)
313{
314 mX = x;
315 mAlpha = alpha;
316 math_utils::detail::bringToPMPi<value_t>(mAlpha);
317 mAbsCharge = char(gpu::CAMath::Abs(charge));
318 for (int i = 0; i < kNParams; i++) {
319 mP[i] = par[i];
320 }
321 mPID = pid;
322}
323
324//____________________________________________________________
325template <typename value_T>
326GPUdi() auto TrackParametrization<value_T>::getParams() const -> const value_t*
327{
328 return mP;
329}
330
331//____________________________________________________________
332template <typename value_T>
333GPUdi() auto TrackParametrization<value_T>::getParam(int i) const -> value_t
334{
335 return mP[i];
336}
337
338//____________________________________________________________
339template <typename value_T>
340GPUdi() auto TrackParametrization<value_T>::getX() const -> value_t
341{
342 return mX;
343}
344
345//____________________________________________________________
346template <typename value_T>
347GPUdi() auto TrackParametrization<value_T>::getAlpha() const -> value_t
348{
349 return mAlpha;
350}
351
352//____________________________________________________________
353template <typename value_T>
354GPUdi() auto TrackParametrization<value_T>::getY() const -> value_t
355{
356 return mP[kY];
357}
358
359//____________________________________________________________
360template <typename value_T>
361GPUdi() auto TrackParametrization<value_T>::getZ() const -> value_t
362{
363 return mP[kZ];
364}
365
366//____________________________________________________________
367template <typename value_T>
368GPUdi() auto TrackParametrization<value_T>::getSnp() const -> value_t
369{
370 return mP[kSnp];
371}
372
373//____________________________________________________________
374template <typename value_T>
375GPUdi() auto TrackParametrization<value_T>::getTgl() const -> value_t
376{
377 return mP[kTgl];
378}
379
380//____________________________________________________________
381template <typename value_T>
382GPUhdi() auto TrackParametrization<value_T>::getQ2Pt() const -> value_t
383{
384 return mP[kQ2Pt];
385}
386
387//____________________________________________________________
388template <typename value_T>
389GPUdi() auto TrackParametrization<value_T>::getCharge2Pt() const -> value_t
390{
391 return mAbsCharge ? mP[kQ2Pt] : 0.f;
392}
393
394//____________________________________________________________
395template <typename value_T>
396GPUdi() auto TrackParametrization<value_T>::getR2() const -> value_t
397{
398 return mX * mX + mP[kY] * mP[kY];
399}
400
401//____________________________________________________________
402template <typename value_T>
403GPUdi() auto TrackParametrization<value_T>::getR() const -> value_t
404{
405 return gpu::CAMath::Sqrt(getR2());
406}
407
408//____________________________________________________________
409template <typename value_T>
410GPUdi() int TrackParametrization<value_T>::getAbsCharge() const
411{
412 return mAbsCharge;
413}
414
415//____________________________________________________________
416template <typename value_T>
417GPUdi() PID TrackParametrization<value_T>::getPID() const
418{
419 return mPID;
420}
421
422//____________________________________________________________
423template <typename value_T>
424GPUdi() void TrackParametrization<value_T>::setPID(const PID pid, bool passCharge)
425{
426 mPID = pid;
427 if (passCharge) {
428 setAbsCharge(pid.getCharge()); // If needed, user should change the charge via corr. setter
429 }
430}
431
432//____________________________________________________________
433template <typename value_T>
434GPUdi() auto TrackParametrization<value_T>::getCsp2() const -> value_t
435{
436 const value_t csp2 = (1.f - mP[kSnp]) * (1.f + mP[kSnp]);
437 return csp2 > o2::constants::math::Almost0 ? csp2 : o2::constants::math::Almost0;
438}
439
440//____________________________________________________________
441template <typename value_T>
442GPUdi() auto TrackParametrization<value_T>::getCsp() const -> value_t
443{
444 return gpu::CAMath::Sqrt(getCsp2());
445}
446
447//____________________________________________________________
448template <typename value_T>
449GPUdi() void TrackParametrization<value_T>::setX(value_t v)
450{
451 mX = v;
452}
453
454//____________________________________________________________
455template <typename value_T>
456GPUdi() void TrackParametrization<value_T>::setParam(value_t v, int i)
457{
458 mP[i] = v;
459}
460
461//____________________________________________________________
462template <typename value_T>
463GPUdi() void TrackParametrization<value_T>::setAlpha(value_t v)
464{
465 mAlpha = v;
466 math_utils::detail::bringToPMPi<value_t>(mAlpha);
467}
468
469//____________________________________________________________
470template <typename value_T>
471GPUdi() void TrackParametrization<value_T>::setY(value_t v)
472{
473 mP[kY] = v;
474}
475
476//____________________________________________________________
477template <typename value_T>
478GPUdi() void TrackParametrization<value_T>::setZ(value_t v)
479{
480 mP[kZ] = v;
481}
482
483//____________________________________________________________
484template <typename value_T>
485GPUdi() void TrackParametrization<value_T>::setSnp(value_t v)
486{
487 mP[kSnp] = v;
488}
489
490//____________________________________________________________
491template <typename value_T>
492GPUdi() void TrackParametrization<value_T>::setTgl(value_t v)
493{
494 mP[kTgl] = v;
495}
496
497//____________________________________________________________
498template <typename value_T>
499GPUdi() void TrackParametrization<value_T>::setQ2Pt(value_t v)
500{
501 mP[kQ2Pt] = v;
502}
503
504//____________________________________________________________
505template <typename value_T>
506GPUdi() void TrackParametrization<value_T>::setAbsCharge(int q)
507{
508 mAbsCharge = gpu::CAMath::Abs(q);
509}
510
511//_______________________________________________________
512template <typename value_T>
513GPUdi() void TrackParametrization<value_T>::getCircleParamsLoc(value_t bz, o2::math_utils::CircleXY<value_t>& c) const
514{
515 // get circle params in track local frame, for straight line just set to local coordinates
516 c.rC = getCurvature(bz);
517 // treat as straight track if sagitta between the vertex and middle of TPC is below 0.01 cm
518 constexpr value_t MinSagitta = 0.01f, TPCMidR = 160.f, MinCurv = 8 * MinSagitta / (TPCMidR * TPCMidR);
519 if (gpu::CAMath::Abs(c.rC) > MinCurv) {
520 c.rC = 1.f / getCurvature(bz);
521 value_t sn = getSnp(), cs = gpu::CAMath::Sqrt((1.f - sn) * (1.f + sn));
522 c.xC = getX() - sn * c.rC; // center in tracking
523 c.yC = getY() + cs * c.rC; // frame. Note: r is signed!!!
524 c.rC = gpu::CAMath::Abs(c.rC);
525 } else {
526 c.rC = 0.f; // signal straight line
527 c.xC = getX();
528 c.yC = getY();
529 }
530}
531
532//_______________________________________________________
533template <typename value_T>
534GPUdi() void TrackParametrization<value_T>::getCircleParams(value_t bz, o2::math_utils::CircleXY<value_t>& c, value_t& sna, value_t& csa) const
535{
536 // get circle params in loc and lab frame, for straight line just set to global coordinates
537 getCircleParamsLoc(bz, c);
538 o2::math_utils::detail::sincos(getAlpha(), sna, csa);
539 o2::math_utils::detail::rotateZ<value_t>(c.xC, c.yC, c.xC, c.yC, sna, csa); // center in global frame
540}
541
542//_______________________________________________________
543template <typename value_T>
544GPUdi() void TrackParametrization<value_T>::getLineParams(o2::math_utils::IntervalXY<value_t>& ln, value_t& sna, value_t& csa) const
545{
546 // get line parameterization as { x = x0 + xSlp*t, y = y0 + ySlp*t }
547 o2::math_utils::detail::sincos(getAlpha(), sna, csa);
548 o2::math_utils::detail::rotateZ<value_t>(getX(), getY(), ln.getX0(), ln.getY0(), sna, csa); // reference point in global frame
549 value_t snp = getSnp(), csp = gpu::CAMath::Sqrt((1.f - snp) * (1.f + snp));
550 ln.setDX(csp * csa - snp * sna);
551 ln.setDY(snp * csa + csp * sna);
552}
553
554//____________________________________________________________
555template <typename value_T>
556GPUdi() auto TrackParametrization<value_T>::getCurvature(value_t b) const -> value_t
557{
558 return mAbsCharge ? mP[kQ2Pt] * b * o2::constants::math::B2C : value_T(0);
559}
560
561//____________________________________________________________
562template <typename value_T>
563GPUdi() int TrackParametrization<value_T>::getCharge() const
564{
565 return getSign() > 0 ? mAbsCharge : -mAbsCharge;
566}
567
568//____________________________________________________________
569template <typename value_T>
570GPUdi() int TrackParametrization<value_T>::getSign() const
571{
572 return mAbsCharge ? (mP[kQ2Pt] > 0.f ? 1 : -1) : 0;
573}
574
575//_______________________________________________________
576template <typename value_T>
577GPUdi() auto TrackParametrization<value_T>::getPhi() const -> value_t
578{
579 // track pt direction phi (in 0:2pi range)
580 value_t phi = gpu::CAMath::ASin(getSnp()) + getAlpha();
581 math_utils::detail::bringTo02Pi<value_t>(phi);
582 return phi;
583}
584
585//_______________________________________________________
586template <typename value_T>
587GPUdi() auto TrackParametrization<value_T>::getPhiPos() const -> value_t
588{
589 // angle of track position (in -pi:pi range)
590 value_t phi = gpu::CAMath::ATan2(getY(), getX()) + getAlpha();
591 math_utils::detail::bringTo02Pi<value_t>(phi);
592 return phi;
593}
594
595//____________________________________________________________
596template <typename value_T>
597GPUdi() auto TrackParametrization<value_T>::getQ2P2() const -> value_t
598{
599 // return the (q/p)^2
600 value_t q2pt2 = mP[kQ2Pt] * mP[kQ2Pt];
601 if (q2pt2 < MinPTInv * MinPTInv) {
602 q2pt2 = MinPTInv * MinPTInv;
603 }
604 return q2pt2 / (1.f + getTgl() * getTgl());
605}
606
607//____________________________________________________________
608template <typename value_T>
609GPUdi() auto TrackParametrization<value_T>::getPtInv() const -> value_t
610{
611 // return the inverted track pT
612 value_t ptInv = gpu::CAMath::Abs(mP[kQ2Pt]);
613 if (ptInv < MinPTInv) {
614 ptInv = MinPTInv;
615 }
616 return (mAbsCharge > 1) ? ptInv / mAbsCharge : ptInv;
617}
618
619//____________________________________________________________
620template <typename value_T>
621GPUdi() auto TrackParametrization<value_T>::getP2Inv() const -> value_t
622{
623 // return the inverted track momentum^2
624 value_t p2 = getPtInv();
625 return p2 * p2 / (1.f + getTgl() * getTgl());
626}
627
628//____________________________________________________________
629template <typename value_T>
630GPUdi() auto TrackParametrization<value_T>::getP2() const -> value_t
631{
632 // return the track momentum^2
633 return 1.f / getP2Inv(); // getP2Inv is protected against being 0, full charge accounted
634}
635
636//____________________________________________________________
637template <typename value_T>
638GPUdi() auto TrackParametrization<value_T>::getPInv() const -> value_t
639{
640 // return the inverted track momentum
641 return getPtInv() / gpu::CAMath::Sqrt(1.f + getTgl() * getTgl()); // getPtInv() is protected against being 0, full charge accounted
642}
643
644//____________________________________________________________
645template <typename value_T>
646GPUdi() auto TrackParametrization<value_T>::getP() const -> value_t
647{
648 // return the track momentum
649 return 1.f / getPInv(); // getPInv is already protected against being 0
650}
651
652//____________________________________________________________
653template <typename value_T>
654GPUdi() auto TrackParametrization<value_T>::getE2() const -> value_t
655{
656 // return the track energy^2
657 return getP2() + getPID().getMass2();
658}
659
660//____________________________________________________________
661template <typename value_T>
662GPUdi() auto TrackParametrization<value_T>::getE() const -> value_t
663{
664 // return the track energy
665 return gpu::CAMath::Sqrt(getE2());
666}
667
668//____________________________________________________________
669template <typename value_T>
670GPUdi() auto TrackParametrization<value_T>::getPt() const -> value_t
671{
672 // return the track transverse momentum
673 return 1.f / getPtInv(); // getPtInv is already protected against being 0
674}
675
676//____________________________________________________________
677template <typename value_T>
678GPUdi() auto TrackParametrization<value_T>::getTheta() const -> value_t
679{
680 return constants::math::PIHalf - gpu::CAMath::ATan(mP[3]);
681}
682
683//____________________________________________________________
684template <typename value_T>
685GPUdi() auto TrackParametrization<value_T>::getEta() const -> value_t
686{
687 return -gpu::CAMath::Log(gpu::CAMath::Tan(0.5f * getTheta()));
688}
689
690//_______________________________________________________
691template <typename value_T>
692GPUdi() auto TrackParametrization<value_T>::getXYZGlo() const -> math_utils::Point3D<value_t>
693{
694#ifndef GPUCA_ALIGPUCODE
695 return math_utils::Rotation2D<value_t>(getAlpha())(math_utils::Point3D<value_t>(getX(), getY(), getZ()));
696#else // mockup on GPU without ROOT
697 float sina, cosa;
698 gpu::CAMath::SinCos(getAlpha(), sina, cosa);
699 return math_utils::Point3D<value_t>(cosa * getX() - sina * getY(), cosa * getY() + sina * getX(), getZ());
700#endif
701}
702
703//_______________________________________________________
704template <typename value_T>
705GPUdi() void TrackParametrization<value_T>::getXYZGlo(dim3_t& xyz) const
706{
707 // track coordinates in lab frame
708 xyz[0] = getX();
709 xyz[1] = getY();
710 xyz[2] = getZ();
711 math_utils::detail::rotateZ<value_t>(xyz, getAlpha());
712}
713
714//_______________________________________________________
715template <typename value_T>
716GPUdi() auto TrackParametrization<value_T>::getXYZGloAt(value_t xk, value_t b, bool& ok) const -> math_utils::Point3D<value_t>
717{
718 //----------------------------------------------------------------
719 // estimate global X,Y,Z in global frame at given X
720 //----------------------------------------------------------------
721 value_t y = 0.f, z = 0.f;
722 ok = getYZAt(xk, b, y, z);
723 if (ok) {
724#ifndef GPUCA_ALIGPUCODE
725 return math_utils::Rotation2D<value_t>(getAlpha())(math_utils::Point3D<value_t>(xk, y, z));
726#else // mockup on GPU without ROOT
727 float sina, cosa;
728 gpu::CAMath::SinCos(getAlpha(), sina, cosa);
729 return math_utils::Point3D<value_t>(cosa * xk - sina * y, cosa * y + sina * xk, z);
730#endif
731 } else {
732 return math_utils::Point3D<value_t>();
733 }
734}
735
736//____________________________________________________________
737template <typename value_T>
738GPUdi() bool TrackParametrization<value_T>::isValid() const
739{
740 return mX != InvalidX;
741}
742
743//____________________________________________________________
744template <typename value_T>
745GPUdi() void TrackParametrization<value_T>::invalidate()
746{
747 mX = InvalidX;
748}
749
750template <typename value_T>
751GPUhdi() uint16_t TrackParametrization<value_T>::getUserField() const
752{
753 return mUserField;
754}
755
756template <typename value_T>
757GPUhdi() void TrackParametrization<value_T>::setUserField(uint16_t v)
758{
759 mUserField = v;
760}
761
762//____________________________________________________________
763template <typename value_T>
764GPUdi() void TrackParametrization<value_T>::updateParam(value_t delta, int i)
765{
766 mP[i] += delta;
767}
768
769//____________________________________________________________
770template <typename value_T>
771GPUdi() void TrackParametrization<value_T>::updateParams(const params_t& delta)
772{
773 updateParams(delta.data());
774}
775
776//____________________________________________________________
777template <typename value_T>
778GPUdi() void TrackParametrization<value_T>::updateParams(const value_t* delta)
779{
780 for (int i = kNParams; i--;) {
781 mP[i] += delta[i];
782 }
783 // make sure that snp is in the valid range
784 if (mP[kSnp] > constants::math::Almost1) {
785 mP[kSnp] = constants::math::Almost1;
786 } else if (mP[kSnp] < -constants::math::Almost1) {
787 mP[kSnp] = -constants::math::Almost1;
788 }
789}
790
791#ifndef GPUCA_ALIGPUCODE
792template <typename value_T>
793size_t TrackParametrization<value_T>::hash(float x, float alp, float y, float z, float snp, float tgl, float q2pt)
794{
795 size_t h = std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(x, 0xFFFFFFF0));
796 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(alp, 0xFFFFFFF0)) << 1;
797 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(y, 0xFFFFFFF0)) << 1;
798 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(z, 0xFFFFFFF0)) << 1;
799 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(snp, 0xFFFFFF00)) << 1;
800 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(tgl, 0xFFFFFF00)) << 1;
801 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(q2pt, 0xFFFFFC00)) << 1;
802 return h;
803}
804#endif
805
806} // namespace track
807} // namespace o2
808
809#endif /* INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATION_H_ */
General auxilliary methods.
particle ids, masses, names class definition
int16_t charge
Definition RawEventData.h:5
int32_t i
#define GPUhdDefault()
#define GPUdDefault()
#define GPUhd()
constexpr int p2()
useful math constants
Declarations of 2D primitives.
uint16_t pid
Definition RawData.h:2
uint32_t c
Definition RawData.h:2
Class for time synchronization of RawReader instances.
void toFwdTrackPar(TrackParFwd &t) const
static size_t hash(float x, float alp, float y, float z, float snp, float tgl, float q2pt)
GPUdi() int nELossSteps(value_T dE
std::array< value_t, kNParams > params_t
GPUd() value_t getTheta() const
GPUd() bool propagateTo(value_t xk
std::string asString() const
GPUdDefault() TrackParametrization()=default
GPUd() bool propagateToDCA(const math_utils
GPUdi() static value_t getdEdxBBOpt(value_t betagamma)
GPUd() void updateParam(value_t delta
GPUd() bool isValid() const
GLdouble n
Definition glcorearb.h:1982
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLenum array
Definition glcorearb.h:4274
GLdouble f
Definition glcorearb.h:310
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean r
Definition glcorearb.h:1233
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GLboolean invert
Definition glcorearb.h:543
typename trackParam_t::value_t value_t
Definition utils.h:30
Node par(int index)
Parameters.
o2::dataformats::DCA DCA
const bool const int TrackITSInternal< NLayers > & track
double * getX(double *xyDxy, int N)
double * getY(double *xyDxy, int N)
value_T bg
Definition TrackUtils.h:194
GPUhdi() uint16_t TrackParametrization< value_T >
GPUdi() TrackParametrization< value_T >
GPUconstexpr() int CovarMap[kNParams][kNParams]
const value_T x
Definition TrackUtils.h:136
GPUd() value_T BetheBlochSolid(value_T bg
GPUglobalconstexpr() int kNParams
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
bool isValid(std::string alias)