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 for (int i = 0; i < kNParams; i++) {
281 mP[i] = par[i];
282 }
283}
284
285//____________________________________________________________
286template <typename value_T>
287GPUdi() void TrackParametrization<value_T>::set(value_t x, value_t alpha, const params_t& par, int charge, const PID pid)
288{
289 set(x, alpha, par.data(), charge, pid);
290}
291
292//____________________________________________________________
293template <typename value_T>
294GPUdi() void TrackParametrization<value_T>::set(value_t x, value_t alpha, const value_t* par, int charge, const PID pid)
295{
296 mX = x;
297 mAlpha = alpha;
298 mAbsCharge = char(gpu::CAMath::Abs(charge));
299 for (int i = 0; i < kNParams; i++) {
300 mP[i] = par[i];
301 }
302 mPID = pid;
303}
304
305//____________________________________________________________
306template <typename value_T>
307GPUdi() auto TrackParametrization<value_T>::getParams() const -> const value_t*
308{
309 return mP;
310}
311
312//____________________________________________________________
313template <typename value_T>
314GPUdi() auto TrackParametrization<value_T>::getParam(int i) const -> value_t
315{
316 return mP[i];
317}
318
319//____________________________________________________________
320template <typename value_T>
321GPUdi() auto TrackParametrization<value_T>::getX() const -> value_t
322{
323 return mX;
324}
325
326//____________________________________________________________
327template <typename value_T>
328GPUdi() auto TrackParametrization<value_T>::getAlpha() const -> value_t
329{
330 return mAlpha;
331}
332
333//____________________________________________________________
334template <typename value_T>
335GPUdi() auto TrackParametrization<value_T>::getY() const -> value_t
336{
337 return mP[kY];
338}
339
340//____________________________________________________________
341template <typename value_T>
342GPUdi() auto TrackParametrization<value_T>::getZ() const -> value_t
343{
344 return mP[kZ];
345}
346
347//____________________________________________________________
348template <typename value_T>
349GPUdi() auto TrackParametrization<value_T>::getSnp() const -> value_t
350{
351 return mP[kSnp];
352}
353
354//____________________________________________________________
355template <typename value_T>
356GPUdi() auto TrackParametrization<value_T>::getTgl() const -> value_t
357{
358 return mP[kTgl];
359}
360
361//____________________________________________________________
362template <typename value_T>
363GPUhdi() auto TrackParametrization<value_T>::getQ2Pt() const -> value_t
364{
365 return mP[kQ2Pt];
366}
367
368//____________________________________________________________
369template <typename value_T>
370GPUdi() auto TrackParametrization<value_T>::getCharge2Pt() const -> value_t
371{
372 return mAbsCharge ? mP[kQ2Pt] : 0.f;
373}
374
375//____________________________________________________________
376template <typename value_T>
377GPUdi() int TrackParametrization<value_T>::getAbsCharge() const
378{
379 return mAbsCharge;
380}
381
382//____________________________________________________________
383template <typename value_T>
384GPUdi() PID TrackParametrization<value_T>::getPID() const
385{
386 return mPID;
387}
388
389//____________________________________________________________
390template <typename value_T>
391GPUdi() void TrackParametrization<value_T>::setPID(const PID pid, bool passCharge)
392{
393 mPID = pid;
394 if (passCharge) {
395 setAbsCharge(pid.getCharge()); // If needed, user should change the charge via corr. setter
396 }
397}
398
399//____________________________________________________________
400template <typename value_T>
401GPUdi() auto TrackParametrization<value_T>::getCsp2() const -> value_t
402{
403 const value_t csp2 = (1.f - mP[kSnp]) * (1.f + mP[kSnp]);
405}
406
407//____________________________________________________________
408template <typename value_T>
409GPUdi() auto TrackParametrization<value_T>::getCsp() const -> value_t
410{
411 return gpu::CAMath::Sqrt(getCsp2());
412}
413
414//____________________________________________________________
415template <typename value_T>
416GPUdi() void TrackParametrization<value_T>::setX(value_t v)
417{
418 mX = v;
419}
420
421//____________________________________________________________
422template <typename value_T>
423GPUdi() void TrackParametrization<value_T>::setParam(value_t v, int i)
424{
425 mP[i] = v;
426}
427
428//____________________________________________________________
429template <typename value_T>
430GPUdi() void TrackParametrization<value_T>::setAlpha(value_t v)
431{
432 mAlpha = v;
433}
434
435//____________________________________________________________
436template <typename value_T>
437GPUdi() void TrackParametrization<value_T>::setY(value_t v)
438{
439 mP[kY] = v;
440}
441
442//____________________________________________________________
443template <typename value_T>
444GPUdi() void TrackParametrization<value_T>::setZ(value_t v)
445{
446 mP[kZ] = v;
447}
448
449//____________________________________________________________
450template <typename value_T>
451GPUdi() void TrackParametrization<value_T>::setSnp(value_t v)
452{
453 mP[kSnp] = v;
454}
455
456//____________________________________________________________
457template <typename value_T>
458GPUdi() void TrackParametrization<value_T>::setTgl(value_t v)
459{
460 mP[kTgl] = v;
461}
462
463//____________________________________________________________
464template <typename value_T>
465GPUdi() void TrackParametrization<value_T>::setQ2Pt(value_t v)
466{
467 mP[kQ2Pt] = v;
468}
469
470//____________________________________________________________
471template <typename value_T>
472GPUdi() void TrackParametrization<value_T>::setAbsCharge(int q)
473{
474 mAbsCharge = gpu::CAMath::Abs(q);
475}
476
477//_______________________________________________________
478template <typename value_T>
479GPUdi() void TrackParametrization<value_T>::getCircleParamsLoc(value_t bz, o2::math_utils::CircleXY<value_t>& c) const
480{
481 // get circle params in track local frame, for straight line just set to local coordinates
482 c.rC = getCurvature(bz);
483 // treat as straight track if sagitta between the vertex and middle of TPC is below 0.01 cm
484 constexpr value_t MinSagitta = 0.01f, TPCMidR = 160.f, MinCurv = 8 * MinSagitta / (TPCMidR * TPCMidR);
485 if (gpu::CAMath::Abs(c.rC) > MinCurv) {
486 c.rC = 1.f / getCurvature(bz);
487 value_t sn = getSnp(), cs = gpu::CAMath::Sqrt((1.f - sn) * (1.f + sn));
488 c.xC = getX() - sn * c.rC; // center in tracking
489 c.yC = getY() + cs * c.rC; // frame. Note: r is signed!!!
490 c.rC = gpu::CAMath::Abs(c.rC);
491 } else {
492 c.rC = 0.f; // signal straight line
493 c.xC = getX();
494 c.yC = getY();
495 }
496}
497
498//_______________________________________________________
499template <typename value_T>
500GPUdi() void TrackParametrization<value_T>::getCircleParams(value_t bz, o2::math_utils::CircleXY<value_t>& c, value_t& sna, value_t& csa) const
501{
502 // get circle params in loc and lab frame, for straight line just set to global coordinates
503 getCircleParamsLoc(bz, c);
504 o2::math_utils::detail::sincos(getAlpha(), sna, csa);
505 o2::math_utils::detail::rotateZ<value_t>(c.xC, c.yC, c.xC, c.yC, sna, csa); // center in global frame
506}
507
508//_______________________________________________________
509template <typename value_T>
510GPUdi() void TrackParametrization<value_T>::getLineParams(o2::math_utils::IntervalXY<value_t>& ln, value_t& sna, value_t& csa) const
511{
512 // get line parameterization as { x = x0 + xSlp*t, y = y0 + ySlp*t }
513 o2::math_utils::detail::sincos(getAlpha(), sna, csa);
514 o2::math_utils::detail::rotateZ<value_t>(getX(), getY(), ln.getX0(), ln.getY0(), sna, csa); // reference point in global frame
515 value_t snp = getSnp(), csp = gpu::CAMath::Sqrt((1.f - snp) * (1.f + snp));
516 ln.setDX(csp * csa - snp * sna);
517 ln.setDY(snp * csa + csp * sna);
518}
519
520//____________________________________________________________
521template <typename value_T>
522GPUdi() auto TrackParametrization<value_T>::getCurvature(value_t b) const -> value_t
523{
524 return mAbsCharge ? mP[kQ2Pt] * b * o2::constants::math::B2C : 0.;
525}
526
527//____________________________________________________________
528template <typename value_T>
529GPUdi() int TrackParametrization<value_T>::getCharge() const
530{
531 return getSign() > 0 ? mAbsCharge : -mAbsCharge;
532}
533
534//____________________________________________________________
535template <typename value_T>
536GPUdi() int TrackParametrization<value_T>::getSign() const
537{
538 return mAbsCharge ? (mP[kQ2Pt] > 0.f ? 1 : -1) : 0;
539}
540
541//_______________________________________________________
542template <typename value_T>
543GPUdi() auto TrackParametrization<value_T>::getPhi() const -> value_t
544{
545 // track pt direction phi (in 0:2pi range)
546 value_t phi = gpu::CAMath::ASin(getSnp()) + getAlpha();
547 math_utils::detail::bringTo02Pi<value_t>(phi);
548 return phi;
549}
550
551//_______________________________________________________
552template <typename value_T>
553GPUdi() auto TrackParametrization<value_T>::getPhiPos() const -> value_t
554{
555 // angle of track position (in -pi:pi range)
556 value_t phi = gpu::CAMath::ATan2(getY(), getX()) + getAlpha();
557 math_utils::detail::bringTo02Pi<value_t>(phi);
558 return phi;
559}
560
561//____________________________________________________________
562template <typename value_T>
563GPUdi() auto TrackParametrization<value_T>::getQ2P2() const -> value_t
564{
565 // return the (q/p)^2
566 value_t q2pt2 = mP[kQ2Pt] * mP[kQ2Pt];
567 if (q2pt2 < MinPTInv * MinPTInv) {
568 q2pt2 = MinPTInv * MinPTInv;
569 }
570 return q2pt2 / (1.f + getTgl() * getTgl());
571}
572
573//____________________________________________________________
574template <typename value_T>
575GPUdi() auto TrackParametrization<value_T>::getPtInv() const -> value_t
576{
577 // return the inverted track pT
578 value_t ptInv = gpu::CAMath::Abs(mP[kQ2Pt]);
579 if (ptInv < MinPTInv) {
580 ptInv = MinPTInv;
581 }
582 return (mAbsCharge > 1) ? ptInv / mAbsCharge : ptInv;
583}
584
585//____________________________________________________________
586template <typename value_T>
587GPUdi() auto TrackParametrization<value_T>::getP2Inv() const -> value_t
588{
589 // return the inverted track momentum^2
590 value_t p2 = getPtInv();
591 return p2 * p2 / (1.f + getTgl() * getTgl());
592}
593
594//____________________________________________________________
595template <typename value_T>
596GPUdi() auto TrackParametrization<value_T>::getP2() const -> value_t
597{
598 // return the track momentum^2
599 return 1.f / getP2Inv(); // getP2Inv is protected against being 0, full charge accounted
600}
601
602//____________________________________________________________
603template <typename value_T>
604GPUdi() auto TrackParametrization<value_T>::getPInv() const -> value_t
605{
606 // return the inverted track momentum
607 return getPtInv() / gpu::CAMath::Sqrt(1.f + getTgl() * getTgl()); // getPtInv() is protected against being 0, full charge accounted
608}
609
610//____________________________________________________________
611template <typename value_T>
612GPUdi() auto TrackParametrization<value_T>::getP() const -> value_t
613{
614 // return the track momentum
615 return 1.f / getPInv(); // getPInv is already protected against being 0
616}
617
618//____________________________________________________________
619template <typename value_T>
620GPUdi() auto TrackParametrization<value_T>::getE2() const -> value_t
621{
622 // return the track energy^2
623 return getP2() + getPID().getMass2();
624}
625
626//____________________________________________________________
627template <typename value_T>
628GPUdi() auto TrackParametrization<value_T>::getE() const -> value_t
629{
630 // return the track energy
631 return gpu::CAMath::Sqrt(getE2());
632}
633
634//____________________________________________________________
635template <typename value_T>
636GPUdi() auto TrackParametrization<value_T>::getPt() const -> value_t
637{
638 // return the track transverse momentum
639 return 1.f / getPtInv(); // getPtInv is already protected against being 0
640}
641
642//____________________________________________________________
643template <typename value_T>
644GPUdi() auto TrackParametrization<value_T>::getTheta() const -> value_t
645{
646 return constants::math::PIHalf - gpu::CAMath::ATan(mP[3]);
647}
648
649//____________________________________________________________
650template <typename value_T>
651GPUdi() auto TrackParametrization<value_T>::getEta() const -> value_t
652{
653 return -gpu::CAMath::Log(gpu::CAMath::Tan(0.5f * getTheta()));
654}
655
656//_______________________________________________________
657template <typename value_T>
658GPUdi() auto TrackParametrization<value_T>::getXYZGlo() const -> math_utils::Point3D<value_t>
659{
660#ifndef GPUCA_ALIGPUCODE
661 return math_utils::Rotation2D<value_t>(getAlpha())(math_utils::Point3D<value_t>(getX(), getY(), getZ()));
662#else // mockup on GPU without ROOT
663 float sina, cosa;
664 gpu::CAMath::SinCos(getAlpha(), sina, cosa);
665 return math_utils::Point3D<value_t>(cosa * getX() - sina * getY(), cosa * getY() + sina * getX(), getZ());
666#endif
667}
668
669//_______________________________________________________
670template <typename value_T>
671GPUdi() void TrackParametrization<value_T>::getXYZGlo(dim3_t& xyz) const
672{
673 // track coordinates in lab frame
674 xyz[0] = getX();
675 xyz[1] = getY();
676 xyz[2] = getZ();
677 math_utils::detail::rotateZ<value_t>(xyz, getAlpha());
678}
679
680//_______________________________________________________
681template <typename value_T>
682GPUdi() auto TrackParametrization<value_T>::getXYZGloAt(value_t xk, value_t b, bool& ok) const -> math_utils::Point3D<value_t>
683{
684 //----------------------------------------------------------------
685 // estimate global X,Y,Z in global frame at given X
686 //----------------------------------------------------------------
687 value_t y = 0.f, z = 0.f;
688 ok = getYZAt(xk, b, y, z);
689 if (ok) {
690#ifndef GPUCA_ALIGPUCODE
691 return math_utils::Rotation2D<value_t>(getAlpha())(math_utils::Point3D<value_t>(xk, y, z));
692#else // mockup on GPU without ROOT
693 float sina, cosa;
694 gpu::CAMath::SinCos(getAlpha(), sina, cosa);
695 return math_utils::Point3D<value_t>(cosa * xk - sina * y, cosa * y + sina * xk, z);
696#endif
697 } else {
698 return math_utils::Point3D<value_t>();
699 }
700}
701
702//____________________________________________________________
703template <typename value_T>
704GPUdi() bool TrackParametrization<value_T>::isValid() const
705{
706 return mX != InvalidX;
707}
708
709//____________________________________________________________
710template <typename value_T>
711GPUdi() void TrackParametrization<value_T>::invalidate()
712{
713 mX = InvalidX;
714}
715
716template <typename value_T>
717GPUhdi() uint16_t TrackParametrization<value_T>::getUserField() const
718{
719 return mUserField;
720}
721
722template <typename value_T>
723GPUhdi() void TrackParametrization<value_T>::setUserField(uint16_t v)
724{
725 mUserField = v;
726}
727
728//____________________________________________________________
729template <typename value_T>
730GPUdi() void TrackParametrization<value_T>::updateParam(value_t delta, int i)
731{
732 mP[i] += delta;
733}
734
735//____________________________________________________________
736template <typename value_T>
737GPUdi() void TrackParametrization<value_T>::updateParams(const params_t& delta)
738{
739 updateParams(delta.data());
740}
741
742//____________________________________________________________
743template <typename value_T>
744GPUdi() void TrackParametrization<value_T>::updateParams(const value_t* delta)
745{
746 for (int i = kNParams; i--;) {
747 mP[i] += delta[i];
748 }
749 // make sure that snp is in the valid range
750 if (mP[kSnp] > constants::math::Almost1) {
752 } else if (mP[kSnp] < -constants::math::Almost1) {
754 }
755}
756
757#ifndef GPUCA_ALIGPUCODE
758template <typename value_T>
759size_t TrackParametrization<value_T>::hash(float x, float alp, float y, float z, float snp, float tgl, float q2pt)
760{
761 size_t h = std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(x, 0xFFFFFFF0));
762 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(alp, 0xFFFFFFF0)) << 1;
763 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(y, 0xFFFFFFF0)) << 1;
764 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(z, 0xFFFFFFF0)) << 1;
765 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(snp, 0xFFFFFF00)) << 1;
766 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(tgl, 0xFFFFFF00)) << 1;
767 h ^= std::hash<float>{}(o2::math_utils::detail::truncateFloatFraction(q2pt, 0xFFFFFC00)) << 1;
768 return h;
769}
770#endif
771
772} // namespace track
773} // namespace o2
774
775#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)