Belle II Software light-2406-ragdoll
KFitTrack.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * External Contributor: J. Tanaka *
5 * *
6 * See git log for contributors and copyright holders. *
7 * This file is licensed under LGPL-3.0, see LICENSE.md. *
8 **************************************************************************/
9
10
11#include <cstdio>
12
13#include <analysis/VertexFitting/KFit/KFitTrack.h>
14
15using namespace CLHEP;
16using namespace std;
17using namespace Belle2;
18using namespace Belle2::analysis;
19
20
22{
23 this->m_PXEBefore.m_P = HepLorentzVector();
24 this->m_PXEBefore.m_X = HepPoint3D();
25 this->m_PXEBefore.m_E = HepSymMatrix(KFitConst::kNumber7, 0);
26 this->m_PXEAfter. m_P = HepLorentzVector();
27 this->m_PXEAfter. m_X = HepPoint3D();
28 this->m_PXEAfter. m_E = HepSymMatrix(KFitConst::kNumber7, 0);
29 this->m_Charge = 0.;
30 this->m_Mass = 0.;
31 this->m_Vertex = HepPoint3D();
32 this->m_VertexError = HepSymMatrix(3, 0);
33}
34
35
36KFitTrack::KFitTrack(const KFitTrack& a) = default;
37
38
40(
41 const CLHEP::HepLorentzVector& p, const HepPoint3D& x, const CLHEP::HepSymMatrix& e, const double charge,
42 const int flag
43)
44{
45 checkFlag(flag);
47
48 switch (flag) {
50 m_PXEBefore.m_P = p;
51 m_PXEBefore.m_X = x;
52 m_PXEBefore.m_E = e;
53 m_PXEAfter.m_P = HepLorentzVector();
54 m_PXEAfter.m_X = HepPoint3D();
55 m_PXEAfter.m_E = HepSymMatrix(KFitConst::kNumber7, 0);
56 break;
57
59 m_PXEBefore.m_P = HepLorentzVector();
60 m_PXEBefore.m_X = HepPoint3D();
61 m_PXEBefore.m_E = HepSymMatrix(KFitConst::kNumber7, 0);
62 m_PXEAfter.m_P = p;
63 m_PXEAfter.m_X = x;
64 m_PXEAfter.m_E = e;
65 break;
66 }
67
68 m_Charge = charge;
69 m_Mass = p.mag();
70 m_Vertex = HepPoint3D();
71 m_VertexError = HepSymMatrix(3, 0);
72}
73
74
75KFitTrack::~KFitTrack() = default;
76
77
80{
81 if (this != &a) {
82 this->m_PXEBefore = a.m_PXEBefore;
83 this->m_PXEAfter = a.m_PXEAfter;
84 this->m_Charge = a.m_Charge;
85 this->m_Mass = a.m_Mass;
86 this->m_Vertex = a.m_Vertex;
88 }
89
90 return *this;
91}
92
93
94void
95KFitTrack::setMomentum(const HepLorentzVector& p, const int flag)
96{
97 checkFlag(flag);
98
99 if (flag == KFitConst::kBeforeFit)
100 m_PXEBefore.m_P = p;
101 else
102 m_PXEAfter.m_P = p;
103
104 m_Mass = p.mag();
105}
106
107
108void
109KFitTrack::setPosition(const HepPoint3D& x, const int flag)
110{
111 checkFlag(flag);
112
113 if (flag == KFitConst::kBeforeFit)
114 m_PXEBefore.m_X = x;
115 else
116 m_PXEAfter.m_X = x;
117}
118
119
120void
121KFitTrack::setError(const HepSymMatrix& e, const int flag)
122{
123 checkFlag(flag);
125
126 if (flag == KFitConst::kBeforeFit)
127 m_PXEBefore.m_E = e;
128 else
129 m_PXEAfter.m_E = e;
130}
131
132
133void
134KFitTrack::setCharge(const double charge)
135{
136 m_Charge = charge;
137}
138
139
140void
141KFitTrack::setVertex(const HepPoint3D& v)
142{
143 m_Vertex = v;
144}
145
146
147void
148KFitTrack::setVertexError(const HepSymMatrix& ve)
149{
151 m_VertexError = ve;
152}
153
154
155const HepLorentzVector
156KFitTrack::getMomentum(const int flag) const
157{
158 checkFlag(flag);
160}
161
162
163const HepPoint3D
164KFitTrack::getPosition(const int flag) const
165{
166 checkFlag(flag);
168}
169
170
171const HepSymMatrix
172KFitTrack::getError(const int flag) const
173{
174 checkFlag(flag);
176}
177
178
179double
181{
182 return m_Charge;
183}
184
185
186double
188{
189 return m_Mass;
190}
191
192
193const HepPoint3D
195{
196 return m_Vertex;
197}
198
199
200const HepSymMatrix
202{
203 return m_VertexError;
204}
205
206
207double
208KFitTrack::getFitParameter(const int which, const int flag) const
209{
210 checkFlag(flag);
211
212 const struct KFitPXE& pxe = flag == KFitConst::kBeforeFit ? m_PXEBefore : m_PXEAfter;
213
214 switch (which) {
215 case 0: return pxe.m_P.x();
216 case 1: return pxe.m_P.y();
217 case 2: return pxe.m_P.z();
218 case 3: return pxe.m_X.x();
219 case 4: return pxe.m_X.y();
220 case 5: return pxe.m_X.z();
221 default: {
222 char buf[1024];
223 sprintf(buf, "%s:%s(): which=%d out of range", __FILE__, __func__, which);
224 B2FATAL(buf);
225 }
226 }
227
228 /* NEVER REACHED */
229 return -999.;
230}
231
232
233const HepMatrix
234KFitTrack::getFitParameter(const int flag) const
235{
236 HepMatrix a(KFitConst::kNumber6, 1, 0);
237
238 for (int i = 0; i <= 5; i++)
239 a[i][0] = getFitParameter(i, flag);
240
241 return a;
242}
243
244
245const HepSymMatrix
246KFitTrack::getFitError(const int flag) const
247{
248 checkFlag(flag);
249 HepSymMatrix err(KFitConst::kNumber6, 0);
250
251 const HepSymMatrix& e = flag == KFitConst::kBeforeFit ? m_PXEBefore.m_E : m_PXEAfter.m_E;
252
253
254 for (int i = 0; i < 3; i++) {
255 for (int j = i; j < 3; j++) {
256 err[i][j] = e[i][j];
257 err[3 + i][3 + j] = e[4 + i][4 + j];
258 }
259 }
260
261 for (int i = 0; i < 3; i++) {
262 for (int j = 0; j < 3; j++) {
263 err[i][3 + j] = e[i][4 + j];
264 }
265 }
266
267 return err;
268}
269
270
271const HepMatrix
272KFitTrack::getMomPos(const int flag) const
273{
274 HepMatrix a(KFitConst::kNumber7, 1, 0);
275
276 switch (flag) {
278 a[0][0] = m_PXEBefore.m_P.x();
279 a[1][0] = m_PXEBefore.m_P.y();
280 a[2][0] = m_PXEBefore.m_P.z();
281 a[3][0] = m_PXEBefore.m_P.t();
282 a[4][0] = m_PXEBefore.m_X.x();
283 a[5][0] = m_PXEBefore.m_X.y();
284 a[6][0] = m_PXEBefore.m_X.z();
285 break;
286
288 a[0][0] = m_PXEAfter.m_P.x();
289 a[1][0] = m_PXEAfter.m_P.y();
290 a[2][0] = m_PXEAfter.m_P.z();
291 a[3][0] = m_PXEAfter.m_P.t();
292 a[4][0] = m_PXEAfter.m_X.x();
293 a[5][0] = m_PXEAfter.m_X.y();
294 a[6][0] = m_PXEAfter.m_X.z();
295 }
296
297 return a;
298}
KFitTrack is a container of the track information (Lorentz vector, position, and error matrix),...
Definition: KFitTrack.h:38
void checkMatrixDimension(const CLHEP::HepSymMatrix &m, const int dim) const
Check if the matrix size is intended one.
Definition: KFitTrack.h:173
void checkFlag(const int flag) const
Check if the flag is one of KFitConst::kBeforeFit or KFitConst::kAfterFit.
Definition: KFitTrack.h:164
double m_Charge
Charge of the track.
Definition: KFitTrack.h:187
double m_Mass
Mass of the track.
Definition: KFitTrack.h:189
KFitTrack & operator=(const KFitTrack &)
Operator: assignment operator.
Definition: KFitTrack.cc:79
KFitTrack(void)
Construct an object with no argument.
Definition: KFitTrack.cc:21
void setCharge(const double q)
Set a charge of the track.
Definition: KFitTrack.cc:134
~KFitTrack(void)
Destruct the object.
const CLHEP::HepLorentzVector getMomentum(const int flag=KFitConst::kAfterFit) const
Get a Lorentz vector of the track.
Definition: KFitTrack.cc:156
void setPosition(const HepPoint3D &x, const int flag=KFitConst::kBeforeFit)
Set a position of the track.
Definition: KFitTrack.cc:109
const HepPoint3D getVertex(void) const
Get a vertex position associated to the track.
Definition: KFitTrack.cc:194
const CLHEP::HepSymMatrix getVertexError(void) const
Get a vertex error matrix associated to the track.
Definition: KFitTrack.cc:201
HepPoint3D m_Vertex
Vertex position associated to the track.
Definition: KFitTrack.h:192
void setVertexError(const CLHEP::HepSymMatrix &ve)
Set a vertex error matrix associated to the track.
Definition: KFitTrack.cc:148
CLHEP::HepSymMatrix m_VertexError
Vertex error matrix associated to the track.
Definition: KFitTrack.h:194
const CLHEP::HepSymMatrix getError(const int flag=KFitConst::kAfterFit) const
Get an error matrix of the track.
Definition: KFitTrack.cc:172
const CLHEP::HepSymMatrix getFitError(const int flag) const
Get an error matrix of the track.
Definition: KFitTrack.cc:246
void setVertex(const HepPoint3D &v)
Set a vertex position associated to the track.
Definition: KFitTrack.cc:141
double getCharge(void) const
Get a charge of the track.
Definition: KFitTrack.cc:180
void setMomentum(const CLHEP::HepLorentzVector &p, const int flag=KFitConst::kBeforeFit)
Set a Lorentz vector of the track.
Definition: KFitTrack.cc:95
struct KFitPXE m_PXEBefore
Lorentz vector, position, and error matrix of the track before the fit.
Definition: KFitTrack.h:181
double getFitParameter(const int which, const int flag) const
Get a parameter of the track.
Definition: KFitTrack.cc:208
void setError(const CLHEP::HepSymMatrix &e, const int flag=KFitConst::kBeforeFit)
Set an error matrix of the track.
Definition: KFitTrack.cc:121
const HepPoint3D getPosition(const int flag=KFitConst::kAfterFit) const
Get a position of the track.
Definition: KFitTrack.cc:164
const CLHEP::HepMatrix getMomPos(const int flag) const
Get a combination of Lorentz vector and position of the track.
Definition: KFitTrack.cc:272
struct KFitPXE m_PXEAfter
Lorentz vector, position, and error matrix of the track after the fit.
Definition: KFitTrack.h:184
double getMass(void) const
Get a mass of the track.
Definition: KFitTrack.cc:187
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24
STL namespace.
static const int kNumber6
Constant 6 to check matrix size (internal use)
Definition: KFitConst.h:30
static const int kAfterFit
Input parameter to specify after-fit when setting/getting a track attribute.
Definition: KFitConst.h:37
static const int kBeforeFit
Input parameter to specify before-fit when setting/getting a track attribute.
Definition: KFitConst.h:35
static const int kNumber7
Constant 7 to check matrix size (internal use)
Definition: KFitConst.h:32
KFitPXE is a container of the track information (Lorentz vector, position, and error matrix).
Definition: KFitTrack.h:43
HepPoint3D m_X
Position of the track.
Definition: KFitTrack.h:47
CLHEP::HepSymMatrix m_E
(7x7) error matrix of the track
Definition: KFitTrack.h:49
CLHEP::HepLorentzVector m_P
Lorentz vector of the track.
Definition: KFitTrack.h:45