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