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