Project
Loading...
Searching...
No Matches
TrackParametrizationWithError.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#ifndef INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATIONWITHERROR_H_
18#define INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATIONWITHERROR_H_
19
21#include <MathUtils/Cartesian.h>
22
23namespace o2
24{
25namespace track
26{
27
28class TrackParCovFwd; // fwd declaration for conversion method
29
30template <typename value_T = float>
32{ // track+error parameterization
33 public:
38
39#ifndef GPUCA_GPUCODE_DEVICE
40 static_assert(std::is_floating_point_v<value_t>);
41#endif
42
43 using covMat_t = std::array<value_t, kCovMatSize>;
46
51
58
59 using TrackParametrization<value_T>::set;
61 GPUd() void set(value_t x, value_t alpha, const value_t* par, const value_t* cov, int charge = 1, const PID pid = PID::Pion);
62 GPUd() void set(const dim3_t& xyz, const dim3_t& pxpypz, const std::array<value_t, kLabCovMatSize>& cv, int sign, bool sectorAlpha = true, const PID pid = PID::Pion);
63 GPUd() const covMat_t& getCov() const;
64 GPUd() value_t getSigmaY2() const;
65 GPUd() value_t getSigmaZY() const;
66 GPUd() value_t getSigmaZ2() const;
67 GPUd() value_t getSigmaSnpY() const;
68 GPUd() value_t getSigmaSnpZ() const;
69 GPUd() value_t getSigmaSnp2() const;
70 GPUd() value_t getSigmaTglY() const;
71 GPUd() value_t getSigmaTglZ() const;
72 GPUd() value_t getSigmaTglSnp() const;
73 GPUd() value_t getSigmaTgl2() const;
74 GPUd() value_t getSigma1PtY() const;
75 GPUd() value_t getSigma1PtZ() const;
76 GPUd() value_t getSigma1PtSnp() const;
77 GPUd() value_t getSigma1PtTgl() const;
78 GPUd() value_t getSigma1Pt2() const;
79 GPUd() value_t getCovarElem(int i, int j) const;
80 GPUd() value_t getDiagError2(int i) const;
81
82 GPUd() bool getCovXYZPxPyPzGlo(std::array<value_t, kLabCovMatSize>& c) const;
83
84 GPUd() void print() const;
85 GPUd() void printHexadecimal();
86#ifndef GPUCA_ALIGPUCODE
87 bool toFwdTrackParCov(TrackParCovFwd& t) const;
88 std::string asString() const;
89 std::string asStringHexadecimal();
90#endif
91
92 // parameters + covmat manipulation
93 GPUd() bool testRotate(value_t alpha) const;
94 GPUd() bool rotate(value_t alpha);
96 GPUd() bool propagateTo(value_t xk, value_t bz);
97 GPUd() bool propagateTo(value_t xk, TrackParametrization<value_T>& linRef, value_t bz);
98 GPUd() bool propagateTo(value_t xk, value_t bz, TrackParametrization<value_T>* linRef) { return linRef ? propagateTo(xk, *linRef, bz) : propagateTo(xk, bz); }
99 GPUd() bool propagateTo(value_t xk, const dim3_t& b);
100 GPUd() bool propagateTo(value_t xk, TrackParametrization<value_T>& linRef, const dim3_t& b);
101 GPUd() bool propagateTo(value_t xk, const dim3_t& b, TrackParametrization<value_T>* linRef) { return linRef ? propagateTo(xk, *linRef, b) : propagateTo(xk, b); }
102 GPUd() bool propagateToDCA(const o2::dataformats::VertexBase& vtx, value_t bz, o2::dataformats::DCA* dca = nullptr, value_t maxD = 999.f);
103 GPUd() void invert();
104 GPUd() value_t getPredictedChi2(const dim2_t& p, const dim3_t& cov) const;
105 GPUd() value_t getPredictedChi2Quiet(const dim2_t& p, const dim3_t& cov) const;
106 GPUd() value_t getPredictedChi2(const value_t* p, const value_t* cov) const;
107 GPUd() value_t getPredictedChi2Quiet(const value_t* p, const value_t* cov) const;
108
109 template <typename T>
110 GPUd() value_t getPredictedChi2(const BaseCluster<T>& p) const;
111 template <typename T>
112 GPUd() value_t getPredictedChi2Quiet(const BaseCluster<T>& p) const;
113
114 GPUd() void buildCombinedCovMatrix(const TrackParametrizationWithError& rhs, MatrixDSym5& cov) const;
117 GPUd() value_t getPredictedChi2Quiet(const TrackParametrizationWithError& rhs) const;
120
121 GPUd() bool update(const dim2_t& p, const dim3_t& cov);
122 GPUd() bool update(const value_t* p, const value_t* cov);
123 GPUd() value_T update(const o2::dataformats::VertexBase& vtx, value_T maxChi2 = 1e15);
124
125 template <typename T>
126 GPUd() bool update(const BaseCluster<T>& p);
127
128 GPUd() bool correctForMaterial(value_t x2x0, value_t xrho, bool anglecorr = false);
129 GPUd() bool correctForMaterial(TrackParametrization<value_T>& linRef, value_t x2x0, value_t xrho, bool anglecorr = false);
130 GPUd() void resetCovariance(value_t s2 = 0);
131 GPUd() void checkCovariance();
132 GPUd() void checkCorrelations();
133 GPUd() void setCov(value_t v, size_t i, size_t j);
134 GPUd() void setCov(value_t v, int i);
135 GPUd() void setCov(const covMat_t& mat);
136
137 GPUd() void updateCov(const covMat_t& delta);
138 GPUd() void updateCov(value_t delta, size_t i, size_t j);
139 GPUd() void updateCov(value_t delta, size_t i);
140
141 GPUd() void updateCov(const params_t delta2, bool preserveCorrelations);
142 GPUd() void updateCov(const value_t* delta2, bool preserveCorrelations);
143
144 GPUd() void updateCovCorr(const params_t delta2);
145 GPUd() void updateCovCorr(const value_t* delta2);
146
147 GPUd() void updateCov(const params_t delta2);
148 GPUd() void updateCov(const value_t* delta2);
149
150 protected:
151 covMat_t mC{0.f}; // 15 covariance matrix elements
152
154};
155
156//__________________________________________________________________________
157template <typename value_T>
159{
160}
161
162//__________________________________________________________________________
163template <typename value_T>
164GPUdi() TrackParametrizationWithError<value_T>::TrackParametrizationWithError(value_t x, value_t alpha, const params_t& par,
165 const covMat_t& cov, int charge, const PID pid)
166 : TrackParametrization<value_T>{
167 x, alpha, par, charge, pid}
168{
169 // explicit constructor
170 for (int i = 0; i < kCovMatSize; i++) {
171 mC[i] = cov[i];
172 }
173}
174
175//__________________________________________________________________________
176template <typename value_T>
177GPUdi() void TrackParametrizationWithError<value_T>::set(value_t x, value_t alpha, const params_t& par, const covMat_t& cov, int charge, const PID pid)
178{
179 set(x, alpha, par.data(), cov.data(), charge, pid);
180}
181
182//__________________________________________________________________________
183template <typename value_T>
184GPUdi() void TrackParametrizationWithError<value_T>::set(value_t x, value_t alpha, const value_t* par, const value_t* cov, int charge, const PID pid)
185{
186 TrackParametrization<value_T>::set(x, alpha, par, charge, pid);
187 for (int i = 0; i < kCovMatSize; i++) {
188 mC[i] = cov[i];
189 }
190}
191
192//__________________________________________________________________________
193template <typename value_T>
194GPUdi() auto TrackParametrizationWithError<value_T>::getCov() const -> const covMat_t&
195{
196 return mC;
197}
198
199//__________________________________________________________________________
200template <typename value_T>
201GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaY2() const -> value_t
202{
203 return mC[kSigY2];
204}
205
206//__________________________________________________________________________
207template <typename value_T>
208GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaZY() const -> value_t
209{
210 return mC[kSigZY];
211}
212
213//__________________________________________________________________________
214template <typename value_T>
215GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaZ2() const -> value_t
216{
217 return mC[kSigZ2];
218}
219
220//__________________________________________________________________________
221template <typename value_T>
222GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaSnpY() const -> value_t
223{
224 return mC[kSigSnpY];
225}
226
227//__________________________________________________________________________
228template <typename value_T>
229GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaSnpZ() const -> value_t
230{
231 return mC[kSigSnpZ];
232}
233
234//__________________________________________________________________________
235template <typename value_T>
236GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaSnp2() const -> value_t
237{
238 return mC[kSigSnp2];
239}
240
241//__________________________________________________________________________
242template <typename value_T>
243GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaTglY() const -> value_t
244{
245 return mC[kSigTglY];
246}
247
248//__________________________________________________________________________
249template <typename value_T>
250GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaTglZ() const -> value_t
251{
252 return mC[kSigTglZ];
253}
254
255//__________________________________________________________________________
256template <typename value_T>
257GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaTglSnp() const -> value_t
258{
259 return mC[kSigTglSnp];
260}
261
262//__________________________________________________________________________
263template <typename value_T>
264GPUdi() auto TrackParametrizationWithError<value_T>::getSigmaTgl2() const -> value_t
265{
266 return mC[kSigTgl2];
267}
268
269//__________________________________________________________________________
270template <typename value_T>
271GPUdi() auto TrackParametrizationWithError<value_T>::getSigma1PtY() const -> value_t
272{
273 return mC[kSigQ2PtY];
274}
275
276//__________________________________________________________________________
277template <typename value_T>
278GPUdi() auto TrackParametrizationWithError<value_T>::getSigma1PtZ() const -> value_t
279{
280 return mC[kSigQ2PtZ];
281}
282
283//__________________________________________________________________________
284template <typename value_T>
285GPUdi() auto TrackParametrizationWithError<value_T>::getSigma1PtSnp() const -> value_t
286{
287 return mC[kSigQ2PtSnp];
288}
289
290//__________________________________________________________________________
291template <typename value_T>
292GPUdi() auto TrackParametrizationWithError<value_T>::getSigma1PtTgl() const -> value_t
293{
294 return mC[kSigQ2PtTgl];
295}
296
297//__________________________________________________________________________
298template <typename value_T>
299GPUdi() auto TrackParametrizationWithError<value_T>::getSigma1Pt2() const -> value_t
300{
301 return mC[kSigQ2Pt2];
302}
303
304//__________________________________________________________________________
305template <typename value_T>
306GPUdi() auto TrackParametrizationWithError<value_T>::getCovarElem(int i, int j) const -> value_t
307{
308 return mC[CovarMap[i][j]];
309}
310
311//__________________________________________________________________________
312template <typename value_T>
313GPUdi() auto TrackParametrizationWithError<value_T>::getDiagError2(int i) const -> value_t
314{
315 return mC[DiagMap[i]];
316}
317
318//__________________________________________________________________________
319template <typename value_T>
320template <typename T>
321GPUdi() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const BaseCluster<T>& p) const -> value_t
322{
323 const dim2_t pyz = {value_T(p.getY()), value_T(p.getZ())};
324 const dim3_t cov = {value_T(p.getSigmaY2()), value_T(p.getSigmaYZ()), value_T(p.getSigmaZ2())};
325 return getPredictedChi2(pyz, cov);
326}
327
328//__________________________________________________________________________
329template <typename value_T>
330template <typename T>
331GPUdi() auto TrackParametrizationWithError<value_T>::getPredictedChi2Quiet(const BaseCluster<T>& p) const -> value_t
332{
333 const dim2_t pyz = {value_T(p.getY()), value_T(p.getZ())};
334 const dim3_t cov = {value_T(p.getSigmaY2()), value_T(p.getSigmaYZ()), value_T(p.getSigmaZ2())};
335 return getPredictedChi2Quiet(pyz, cov);
336}
337
338//______________________________________________
339template <typename value_T>
340GPUdi() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const dim2_t& p, const dim3_t& cov) const -> value_t
341{
342 return getPredictedChi2(p.data(), cov.data());
343}
344
345//______________________________________________
346template <typename value_T>
347GPUdi() auto TrackParametrizationWithError<value_T>::getPredictedChi2Quiet(const dim2_t& p, const dim3_t& cov) const -> value_t
348{
349 return getPredictedChi2Quiet(p.data(), cov.data());
350}
351
352//______________________________________________
353template <typename value_T>
354GPUdi() bool TrackParametrizationWithError<value_T>::update(const dim2_t& p, const dim3_t& cov)
355{
356 return update(p.data(), cov.data());
357}
358
359//__________________________________________________________________________
360template <typename value_T>
361template <typename T>
362GPUdi() bool TrackParametrizationWithError<value_T>::update(const BaseCluster<T>& p)
363{
364 const dim2_t pyz = {value_T(p.getY()), value_T(p.getZ())};
365 const dim3_t cov = {value_T(p.getSigmaY2()), value_T(p.getSigmaYZ()), value_T(p.getSigmaZ2())};
366 return update(pyz, cov);
367}
368
369//__________________________________________________________________________
370template <typename value_T>
371GPUdi() void TrackParametrizationWithError<value_T>::setCov(value_t v, int i)
372{
373 mC[i] = v;
374}
375
376//__________________________________________________________________________
377template <typename value_T>
378GPUdi() void TrackParametrizationWithError<value_T>::setCov(value_t v, size_t i, size_t j)
379{
380 mC[CovarMap[i][j]] = v;
381}
382
383template <typename value_T>
384GPUdi() void TrackParametrizationWithError<value_T>::setCov(const covMat_t& cov)
385{
386 mC = cov;
387}
388
389//__________________________________________________________________________
390template <typename value_T>
391GPUdi() void TrackParametrizationWithError<value_T>::updateCov(value_t delta, size_t i, size_t j)
392{
393 mC[CovarMap[i][j]] += delta;
394}
395
396//__________________________________________________________________________
397template <typename value_T>
398GPUdi() void TrackParametrizationWithError<value_T>::updateCov(value_t delta, size_t i)
399{
400 mC[i] += delta;
401}
402
403//__________________________________________________________________________
404template <typename value_T>
405GPUdi() void TrackParametrizationWithError<value_T>::updateCov(const covMat_t& delta)
406{
407 for (size_t i = 0; i < kCovMatSize; ++i) {
408 mC[i] += delta[i];
409 }
410}
411
412//__________________________________________________________________________
413template <typename value_T>
414GPUdi() void TrackParametrizationWithError<value_T>::updateCov(const params_t delta2)
415{
416 // Increment cov.matrix diagonal elements by the vector of squared deltas
417 updateCov(delta2.data());
418}
419
420//__________________________________________________________________________
421template <typename value_T>
422GPUdi() void TrackParametrizationWithError<value_T>::updateCov(const value_t* delta2)
423{
424 // Increment cov.matrix diagonal elements by the vector of squared deltas
425 for (int i = 0; i < kNParams; i++) {
426 mC[DiagMap[i]] += delta2[i];
427 }
428}
429
430//__________________________________________________________________________
431template <typename value_T>
432GPUdi() void TrackParametrizationWithError<value_T>::updateCovCorr(const params_t delta2)
433{
434 // Increment cov.matrix diagonal elements by the vector of squared deltas, modify non-diagonal elements to preserve correlations
435 updateCovCorr(delta2.data());
436}
437
438//__________________________________________________________________________
439template <typename value_T>
440GPUdi() void TrackParametrizationWithError<value_T>::updateCovCorr(const value_t* delta2)
441{
442 // Increment cov.matrix diagonal elements by the vector of squared deltas, modify non-diagonal elements to preserve correlations
443#pragma GCC diagnostic push // FIXME: remove in the future, GCC compiler bug reports incorrect uninitialized warning for oldDiag
444#pragma GCC diagnostic ignored "-Wuninitialized"
445 value_t oldDiag[kNParams];
446 for (int i = 0; i < kNParams; i++) {
447 auto diagI = DiagMap[i];
448 oldDiag[i] = mC[diagI];
449 mC[diagI] += delta2[i];
450 for (int j = 0; j < i; j++) {
451 mC[CovarMap[i][j]] *= gpu::CAMath::Sqrt(mC[diagI] * mC[DiagMap[j]] / (oldDiag[i] * oldDiag[j]));
452 }
453 }
454#pragma GCC diagnostic pop
455}
456
457//__________________________________________________________________________
458template <typename value_T>
459GPUdi() void TrackParametrizationWithError<value_T>::updateCov(const params_t delta2, bool preserveCorrelations)
460{
461 // Increment cov.matrix diagonal elements by the vector of squared deltas. If requested, modify non-diagonal elements to preserve correlations
462 updateCov(delta2.data(), preserveCorrelations);
463}
464
465//__________________________________________________________________________
466template <typename value_T>
467GPUdi() void TrackParametrizationWithError<value_T>::updateCov(const value_t* delta2, bool preserveCorrelations)
468{
469 // Increment cov.matrix diagonal elements by the vector of squared deltas. If requested, modify non-diagonal elements to preserve correlations
470 if (preserveCorrelations) {
471 updateCovCorr(delta2);
472 } else {
473 updateCov(delta2);
474 }
475}
476
477} // namespace track
478} // namespace o2
479#endif /* INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATIONWITHERROR_H_ */
int16_t charge
Definition RawEventData.h:5
void print() const
int32_t i
#define GPUhdDefault()
#define protected
uint32_t j
Definition RawData.h:0
uint16_t pid
Definition RawData.h:2
uint32_t c
Definition RawData.h:2
const dim3_t const std::array< value_t, kLabCovMatSize > int bool sectorAlpha
const dim3_t const std::array< value_t, kLabCovMatSize > & cv
GPUd() TrackParametrizationWithError(value_t x
const dim3_t const std::array< value_t, kLabCovMatSize > int sign
value_t const params_t const covMat_t & cov
ClassDefNV(TrackParametrizationWithError, 2)
value_t const params_t const covMat_t int charge
GPUhd() TrackParametrizationWithError()
GPUdDefault() ~TrackParametrizationWithError()=default
value_t const params_t const covMat_t int const PID pid
TrackParametrization< value_T > value_t bz
GPUd() bool testRotate(value_t alpha) const
std::array< value_t, kNParams > params_t
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 invert
Definition glcorearb.h:543
void set(T *h, size_t v)
Definition PageParser.h:107
typename trackParam_t::dim3_t dim3_t
Definition utils.h:32
typename trackParam_t::dim2_t dim2_t
Definition utils.h:31
typename trackParam_t::value_t value_t
Definition utils.h:30
Node par(int index)
Parameters.
GPUhdi() uint16_t TrackParametrization< value_T >
GPUdi() TrackParametrization< value_T >
constexpr int kCovMatSize
constexpr int kNParams
constexpr int kLabCovMatSize
const value_T x
Definition TrackUtils.h:136
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.