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