CbmRoot
Loading...
Searching...
No Matches
KfMeasurementXy.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov [committer], Sergei Zharko */
4
7
8#pragma once // include this header only once per compilation unit
9
10
11#include "KfDefs.h"
12#include "KfUtils.h"
13
14#include <boost/serialization/access.hpp>
15
16#include <string>
17
18namespace cbm::algo::kf
19{
27 template<typename DataT>
28 class alignas(VcMemAlign) MeasurementXy {
29 public:
30 friend class boost::serialization::access;
31
33 MeasurementXy() = default;
34
47 MeasurementXy(DataT x, DataT y, DataT dx2, DataT dy2, DataT dxy, DataT ndfX, DataT ndfY)
48 : fX(x)
49 , fY(y)
50 , fDx2(dx2)
51 , fDy2(dy2)
52 , fDxy(dxy)
53 , fNdfX(ndfX)
54 , fNdfY(ndfY)
55 {
56 }
57
58
62 template<typename DataTb>
64 {
66 }
67
70 void Set(const MeasurementXy<fvec>& m, const int im) { CopyBase<fvec, true, false>(0, m, im); }
71
74 template<typename DataTb>
75 void SetOneEntry(const int i, const MeasurementXy<DataTb>& m)
76 {
78 }
79
82 void SetOneEntry(const int i, const MeasurementXy<fvec>& m, const int im)
83 {
85 }
86
87
90
91 void SetX(DataT x) { fX = x; }
92 void SetY(DataT y) { fY = y; }
93 void SetDx2(DataT dx2) { fDx2 = dx2; }
94 void SetDy2(DataT dy2) { fDy2 = dy2; }
95 void SetDxy(DataT dxy) { fDxy = dxy; }
96 void SetNdfX(DataT ndfX) { fNdfX = ndfX; }
97 void SetNdfY(DataT ndfY) { fNdfY = ndfY; }
98 void SetCov(DataT dx2, DataT dxy, DataT dy2)
99 {
100 fDx2 = dx2;
101 fDxy = dxy;
102 fDy2 = dy2;
103 }
104
105 DataT X() const { return fX; }
106 DataT Y() const { return fY; }
107 DataT Dx2() const { return fDx2; }
108 DataT Dy2() const { return fDy2; }
109 DataT Dxy() const { return fDxy; }
110 DataT NdfX() const { return fNdfX; }
111 DataT NdfY() const { return fNdfY; }
112
115
116 DataT& X() { return fX; }
117 DataT& Y() { return fY; }
118 DataT& Dx2() { return fDx2; }
119 DataT& Dy2() { return fDy2; }
120 DataT& Dxy() { return fDxy; }
121 DataT& NdfX() { return fNdfX; }
122 DataT& NdfY() { return fNdfY; }
123
126
129 std::string ToString(int indentLevel = 0) const;
130
132 bool IsFinite() const
133 {
136 }
137
145
147 friend class boost::serialization::access;
148 template<class Archive>
149 void serialize(Archive& ar, const unsigned int)
150 {
151 ar& fX;
152 ar& fY;
153 ar& fDx2;
154 ar& fDy2;
155 ar& fDxy;
156 ar& fNdfX;
157 ar& fNdfY;
158 }
159
160 private:
168 template<typename TdataB, bool TDoAllA, bool TDoAllB>
169 void CopyBase(const int ia, const MeasurementXy<TdataB>& Tb, const int ib);
170
171 private:
174
175 // Initializing parameters with NANs spoils the track fit where
176 // the masked-out SIMD entries are suppressed by a multication by 0.
177 // Therefore, we initialize the data members here with finite numbers.
178 // For the numerical safety, with some reasonable numbers.
179
180 DataT fX{0.};
181 DataT fY{0.};
182 DataT fDx2{1.};
183 DataT fDy2{1.};
184 DataT fDxy{0.};
185
189
190 DataT fNdfX = 0.;
191 DataT fNdfY = 0.;
192
194
195
196 // ---------------------------------------------------------------------------------------------------------------------
197 //
198 template<typename TdataA>
199 template<typename TdataB, bool TDoAllA, bool TDoAllB>
200 inline void MeasurementXy<TdataA>::CopyBase(const int ia, const MeasurementXy<TdataB>& Tb, const int ib)
201 {
202 auto copy = [&](TdataA& a, const TdataB& b) {
204 };
205
206 copy(fX, Tb.X());
207 copy(fY, Tb.Y());
208 copy(fDx2, Tb.Dx2());
209 copy(fDy2, Tb.Dy2());
210 copy(fDxy, Tb.Dxy());
211 copy(fNdfX, Tb.NdfX());
212 copy(fNdfY, Tb.NdfY());
213 } // CopyBase
214
215} // namespace cbm::algo::kf
std::string ToString(CbmCutId id)
Convert CbmCutId to a string representation.
Definition CbmCutId.cxx:7
Common constant definitions for the Kalman Filter library.
DataT fX
x coordinate of the measurement
void Set(const MeasurementXy< DataTb > &m)
MeasurementXy()=default
default constructor
DataT fDx2
rms^2 of the x coordinate measurement
DataT fDxy
covariance of the x and y coordinate measurements
bool IsUndefined() const
Checks, if some fields are undefined.
DataT fNdfX
ndf for the x coordinate measurement
MeasurementXy(DataT x, DataT y, DataT dx2, DataT dy2, DataT dxy, DataT ndfX, DataT ndfY)
void SetOneEntry(const int i, const MeasurementXy< fvec > &m, const int im)
DataT fY
y coordinate of the measurement
void SetCov(DataT dx2, DataT dxy, DataT dy2)
DataT fNdfY
ndf for the y coordinate measurement
void Set(const MeasurementXy< fvec > &m, const int im)
void serialize(Archive &ar, const unsigned int)
void CopyBase(const int ia, const MeasurementXy< TdataB > &Tb, const int ib)
Copies all/one entries from the other class.
bool IsFinite() const
Checks, if all fields are finite.
void SetOneEntry(const int i, const MeasurementXy< DataTb > &m)
DataT fDy2
rms^2 of the y coordinate measurement
static void CopyEntries(TdataA &a, int ia, const TdataB &b, int ib)
Definition KfUtils.h:181
bool IsFinite(const T &val)
Checks whether a variable of a particular type is finite.
Definition KfUtils.h:100
bool IsUndefined(const T &val)
Checks whether a variable of a particular type defined.
Definition KfUtils.h:78
class cbm::algo::kf::MeasurementTime _fvecalignment