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