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