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