@@ -115,6 +115,8 @@ GPUconstexpr() int CovarMap[kNParams][kNParams] = {{0, 1, 3, 6, 10},
115115GPUconstexpr () int DiagMap[kNParams ] = {0 , 2 , 5 , 9 , 14 };
116116
117117constexpr float HugeF = o2::constants::math::VeryBig;
118+ constexpr float MaxPT = 100000 .; // do not allow pTs exceeding this value (to avoid NANs)
119+ constexpr float MinPTInv = 1 . / MaxPT; // do not allow q/pTs less this value (to avoid NANs)
118120
119121template <typename value_T = float >
120122class TrackParametrization
@@ -541,7 +543,10 @@ template <typename value_T>
541543GPUdi () auto TrackParametrization<value_T>::getPtInv() const -> value_t
542544{
543545 // return the inverted track pT
544- const value_t ptInv = gpu::CAMath::Abs (mP [kQ2Pt ]);
546+ value_t ptInv = gpu::CAMath::Abs (mP [kQ2Pt ]);
547+ if (ptInv < MinPTInv) {
548+ ptInv = MinPTInv;
549+ }
545550 return (mAbsCharge > 1 ) ? ptInv / mAbsCharge : ptInv;
546551}
547552
@@ -550,47 +555,40 @@ template <typename value_T>
550555GPUdi () auto TrackParametrization<value_T>::getP2Inv() const -> value_t
551556{
552557 // return the inverted track momentum^2
553- const value_t p2 = mP [ kQ2Pt ] * mP [ kQ2Pt ] / ( 1 . f + getTgl () * getTgl () );
554- return ( mAbsCharge > 1 ) ? p2 / (mAbsCharge * mAbsCharge ) : p2 ;
558+ value_t p2 = getPtInv ( );
559+ return p2 * p2 / (1 . f + getTgl () * getTgl ()) ;
555560}
556561
557562// ____________________________________________________________
558563template <typename value_T>
559564GPUdi () auto TrackParametrization<value_T>::getP2() const -> value_t
560565{
561566 // return the track momentum^2
562- const value_t p2inv = getP2Inv ();
563- return (p2inv > o2::constants::math::Almost0) ? 1 .f / p2inv : o2::constants::math::VeryBig;
567+ return 1 .f / getP2Inv (); // getP2Inv is protected against being 0, full charge accounted
564568}
565569
566570// ____________________________________________________________
567571template <typename value_T>
568572GPUdi () auto TrackParametrization<value_T>::getPInv() const -> value_t
569573{
570- // return the inverted track momentum^2
571- const value_t pInv = gpu::CAMath::Abs (mP [kQ2Pt ]) / gpu::CAMath::Sqrt (1 .f + getTgl () * getTgl ());
572- return (mAbsCharge > 1 ) ? pInv / mAbsCharge : pInv;
574+ // return the inverted track momentum
575+ return getPtInv () / gpu::CAMath::Sqrt (1 .f + getTgl () * getTgl ()); // getPtInv() is protected against being 0, full charge accounted
573576}
574577
575578// ____________________________________________________________
576579template <typename value_T>
577580GPUdi () auto TrackParametrization<value_T>::getP() const -> value_t
578581{
579582 // return the track momentum
580- const value_t pInv = getPInv ();
581- return (pInv > o2::constants::math::Almost0) ? 1 .f / pInv : o2::constants::math::VeryBig;
583+ return 1 .f / getPInv (); // getPInv is already protected against being 0
582584}
583585
584586// ____________________________________________________________
585587template <typename value_T>
586588GPUdi () auto TrackParametrization<value_T>::getPt() const -> value_t
587589{
588590 // return the track transverse momentum
589- value_t ptI = gpu::CAMath::Abs (mP [kQ2Pt ]);
590- if (mAbsCharge > 1 ) {
591- ptI /= mAbsCharge ;
592- }
593- return (ptI > o2::constants::math::Almost0) ? 1 .f / ptI : o2::constants::math::VeryBig;
591+ return 1 .f / getPtInv (); // getPtInv is already protected against being 0
594592}
595593
596594// ____________________________________________________________
0 commit comments