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