Belle II Software development
MassVertexFitKFit.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#include <analysis/VertexFitting/KFit/MassVertexFitKFit.h>
11
12#include <TMath.h>
13
14#include <analysis/dataobjects/Particle.h>
15#include <analysis/VertexFitting/KFit/MakeMotherKFit.h>
16#include <analysis/utility/CLHEPToROOT.h>
17#include <analysis/utility/ROOTToCLHEP.h>
18#include <framework/gearbox/Const.h>
19
20using namespace std;
21using namespace Belle2;
22using namespace Belle2::analysis;
23using namespace CLHEP;
24
26 m_BeforeVertex(HepPoint3D(0., 0., 0.)),
27 m_AfterVertexError(HepSymMatrix(3, 0))
28{
29 m_FlagFitted = false;
31 m_V_E = HepMatrix(3, 3, 0);
32 m_v = HepMatrix(3, 1, 0);
33 m_v_a = HepMatrix(3, 1, 0);
34 m_InvariantMass = -1.0;
35}
36
37
39
40
44
46}
47
48enum KFitError::ECode MassVertexFitKFit::setInitialVertex(const ROOT::Math::XYZVector& v)
49{
50 m_BeforeVertex = ROOTToCLHEP::getPoint3D(v);
52 return m_ErrorCode;
53}
54
61
62
65 m_IsFixMass.push_back(true);
66
68}
69
70
73 m_IsFixMass.push_back(false);
74
76}
77
78
82}
83
84
89
90
91const HepPoint3D
92MassVertexFitKFit::getVertex(const int flag) const
93{
94 if (flag == KFitConst::kAfterFit && !isFitted()) return HepPoint3D();
95
96 switch (flag) {
98 return m_BeforeVertex;
99
101 return m_AfterVertex;
102
103 default:
104 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kOutOfRange);
105 return HepPoint3D();
106 }
107}
108
109
110const HepSymMatrix
115
116
117double
122
123
124double
126{
127 return m_CHIsq;
128}
129
130
131const HepMatrix
133{
134 if (!isTrackIDInRange(id)) return HepMatrix(3, KFitConst::kNumber7, 0);
135
136 return m_AfterTrackVertexError[id];
137}
138
139
140double
142{
143 if (!isFitted()) return -1;
144 if (!isTrackIDInRange(id)) return -1;
145
146 if (m_IsFixMass[id]) {
147
148 HepMatrix da(m_Tracks[id].getFitParameter(KFitConst::kBeforeFit) - m_Tracks[id].getFitParameter(KFitConst::kAfterFit));
149 int err_inverse = 0;
150 const double chisq = (da.T() * (m_Tracks[id].getFitError(KFitConst::kBeforeFit).inverse(err_inverse)) * da)[0][0];
151
152 if (err_inverse) {
153 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kCannotGetMatrixInverse);
154 return -1;
155 }
156
157 return chisq;
158
159 } else {
160
161 HepMatrix da(m_Tracks[id].getMomPos(KFitConst::kBeforeFit) - m_Tracks[id].getMomPos(KFitConst::kAfterFit));
162 int err_inverse = 0;
163 const double chisq = (da.T() * (m_Tracks[id].getError(KFitConst::kBeforeFit).inverse(err_inverse)) * da)[0][0];
164
165 if (err_inverse) {
166 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kCannotGetMatrixInverse);
167 return -1;
168 }
169
170 return chisq;
171 }
172}
173
174
175const HepMatrix
176MassVertexFitKFit::getCorrelation(const int id1, const int id2, const int flag) const
177{
178 if (flag == KFitConst::kAfterFit && !isFitted()) return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
179 if (!isTrackIDInRange(id1)) return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
180 if (!isTrackIDInRange(id2)) return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
181
182 switch (flag) {
184 return KFitBase::getCorrelation(id1, id2, flag);
185
187 return makeError3(
188 this->getTrackMomentum(id1),
189 this->getTrackMomentum(id2),
190 m_V_al_1.sub(KFitConst::kNumber7 * id1 + 1, KFitConst::kNumber7 * (id1 + 1), KFitConst::kNumber7 * id2 + 1,
191 KFitConst::kNumber7 * (id2 + 1)),
192 m_IsFixMass[id1],
193 m_IsFixMass[id2]);
194
195 default:
196 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kOutOfRange);
197 return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
198 }
199}
200
201
206
207
211 {
213 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
214 return m_ErrorCode;
215 }
216
217
218 if (m_IsFixMass.size() == 0)
219 {
220 // If no fix_mass flag at all,
221 // all tracks are considered to be fixed at mass.
222 for (int i = 0; i < m_TrackCount; i++) this->fixMass();
223 } else if (m_IsFixMass.size() != (unsigned int)m_TrackCount)
224 {
226 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
227 return m_ErrorCode;
228 }
229
230
231 int index = 0;
232 m_al_0 = HepMatrix(KFitConst::kNumber7 * m_TrackCount, 1, 0);
233 m_property = HepMatrix(m_TrackCount, 3, 0);
234 m_V_al_0 = HepSymMatrix(KFitConst::kNumber7 * m_TrackCount, 0);
235
236 for (auto& track : m_Tracks)
237 {
238 // momentum x,y,z and position x,y,z
239 m_al_0[index * KFitConst::kNumber7 + 0][0] = track.getMomentum(KFitConst::kBeforeFit).x();
240 m_al_0[index * KFitConst::kNumber7 + 1][0] = track.getMomentum(KFitConst::kBeforeFit).y();
241 m_al_0[index * KFitConst::kNumber7 + 2][0] = track.getMomentum(KFitConst::kBeforeFit).z();
242 m_al_0[index * KFitConst::kNumber7 + 3][0] = track.getMomentum(KFitConst::kBeforeFit).t();
243 m_al_0[index * KFitConst::kNumber7 + 4][0] = track.getPosition(KFitConst::kBeforeFit).x();
244 m_al_0[index * KFitConst::kNumber7 + 5][0] = track.getPosition(KFitConst::kBeforeFit).y();
245 m_al_0[index * KFitConst::kNumber7 + 6][0] = track.getPosition(KFitConst::kBeforeFit).z();
246 // these error
247 m_V_al_0.sub(index * KFitConst::kNumber7 + 1, track.getError(KFitConst::kBeforeFit));
248 // charge, mass, a
249 m_property[index][0] = track.getCharge();
250 m_property[index][1] = track.getMass();
251 const double c = Const::speedOfLight * 1e-4;
252 m_property[index][2] = -c * m_MagneticField * track.getCharge();
253 index++;
254 }
255
256 // error between track and track
258 {
259 this->prepareCorrelation();
261 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
262 return m_ErrorCode;
263 }
264 }
265
266 // vertex
267 m_v_a[0][0] = m_BeforeVertex.x();
268 m_v_a[1][0] = m_BeforeVertex.y();
269 m_v_a[2][0] = m_BeforeVertex.z();
270
271 // set member matrix
272 m_al_1 = m_al_0;
273
276 m_E = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 3);
277 m_d = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 1);
278 m_V_D = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, m_TrackCount * 2 + 1);
279 m_lam = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 1);
280 m_lam0 = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 1);
281 m_V_Dt = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, m_TrackCount * 2 + 1);
283
285}
286
287
290 // vertex
291 for (int i = 0; i < 3; i++) m_v[i][0] = m_v_a[i][0];
292
294}
295
296
299 if (m_BeforeCorrelation.size() != static_cast<unsigned int>(m_TrackCount * (m_TrackCount - 1) / 2))
300 {
302 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
303 return m_ErrorCode;
304 }
305
306 int row = 0, col = 0;
307
308 for (auto& hm : m_BeforeCorrelation)
309 {
310 // counter
311 row++;
312 if (row == m_TrackCount) {
313 col++;
314 row = col + 1;
315 }
316
317 int ii = 0, jj = 0;
318 for (int i = KFitConst::kNumber7 * row; i < KFitConst::kNumber7 * (row + 1); i++) {
319 for (int j = KFitConst::kNumber7 * col; j < KFitConst::kNumber7 * (col + 1); j++) {
320 m_V_al_0[i][j] = hm[ii][jj];
321 jj++;
322 }
323 jj = 0;
324 ii++;
325 }
326 }
327
329}
330
331
334 Hep3Vector h3v;
335 int index = 0;
336 for (auto& pdata : m_Tracks)
337 {
338 // tracks
339 // momentum
340 h3v.setX(m_al_1[index * KFitConst::kNumber7 + 0][0]);
341 h3v.setY(m_al_1[index * KFitConst::kNumber7 + 1][0]);
342 h3v.setZ(m_al_1[index * KFitConst::kNumber7 + 2][0]);
343 if (m_IsFixMass[index])
344 pdata.setMomentum(HepLorentzVector(h3v, sqrt(h3v.mag2() + pdata.getMass()*pdata.getMass())), KFitConst::kAfterFit);
345 else
346 pdata.setMomentum(HepLorentzVector(h3v, m_al_1[index * KFitConst::kNumber7 + 3][0]), KFitConst::kAfterFit);
347 // position
348 pdata.setPosition(HepPoint3D(
349 m_al_1[index * KFitConst::kNumber7 + 4][0],
350 m_al_1[index * KFitConst::kNumber7 + 5][0],
352 // error of the tracks
353 pdata.setError(this->makeError3(pdata.getMomentum(),
354 m_V_al_1.sub(
355 index * KFitConst::kNumber7 + 1,
356 (index + 1)*KFitConst::kNumber7,
357 index * KFitConst::kNumber7 + 1,
358 (index + 1)*KFitConst::kNumber7), m_IsFixMass[index]),
360 if (m_ErrorCode != KFitError::kNoError) break;
361 index++;
362 }
363
364 // vertex
365 m_AfterVertex.setX(m_v_a[0][0]);
366 m_AfterVertex.setY(m_v_a[1][0]);
367 m_AfterVertex.setZ(m_v_a[2][0]);
368 // error of the vertex
369 for (int i = 0; i < 3; i++) for (int j = i; j < 3; j++)
370 {
371 m_AfterVertexError[i][j] = m_V_E[i][j];
372 }
373 // error between vertex and tracks
374 for (int i = 0; i < m_TrackCount; i++)
375 {
376 HepMatrix hm(3, KFitConst::kNumber7, 0);
377 for (int j = 0; j < 3; j++) for (int k = 0; k < KFitConst::kNumber7; k++) {
378 hm[j][k] = m_Cov_v_al_1[j][KFitConst::kNumber7 * i + k];
379 }
380 if (m_IsFixMass[i])
381 m_AfterTrackVertexError.push_back(this->makeError4(m_Tracks[i].getMomentum(), hm));
382 else
383 m_AfterTrackVertexError.push_back(hm);
384 }
385
387}
388
389
392 // Mass Constraint
393 HepMatrix al_1_prime(m_al_1);
394 HepMatrix Sum_al_1(4, 1, 0);
395 std::vector<double> energy(m_TrackCount);
396 double a;
397
398 for (int i = 0; i < m_TrackCount; i++)
399 {
400 a = m_property[i][2];
401 al_1_prime[i * KFitConst::kNumber7 + 0][0] -= a * (m_v_a[1][0] - al_1_prime[i * KFitConst::kNumber7 + 5][0]);
402 al_1_prime[i * KFitConst::kNumber7 + 1][0] += a * (m_v_a[0][0] - al_1_prime[i * KFitConst::kNumber7 + 4][0]);
403 energy[i] = sqrt(al_1_prime[i * KFitConst::kNumber7 + 0][0] * al_1_prime[i * KFitConst::kNumber7 + 0][0] +
404 al_1_prime[i * KFitConst::kNumber7 + 1][0] * al_1_prime[i * KFitConst::kNumber7 + 1][0] +
405 al_1_prime[i * KFitConst::kNumber7 + 2][0] * al_1_prime[i * KFitConst::kNumber7 + 2][0] +
406 m_property[i][1] * m_property[i][1]);
407 if (m_IsFixMass[i])
408 Sum_al_1[3][0] += energy[i];
409 else
410 Sum_al_1[3][0] += al_1_prime[i * KFitConst::kNumber7 + 3][0];
411 }
412
413 for (int i = 0; i < m_TrackCount; i++)
414 {
415 for (int j = 0; j < 3; j++) Sum_al_1[j][0] += al_1_prime[i * KFitConst::kNumber7 + j][0];
416 }
417
418 m_d[2 * m_TrackCount][0] =
419 + Sum_al_1[3][0] * Sum_al_1[3][0] - Sum_al_1[0][0] * Sum_al_1[0][0]
420 - Sum_al_1[1][0] * Sum_al_1[1][0] - Sum_al_1[2][0] * Sum_al_1[2][0]
422
423 double Sum_a = 0., Sum_tmpx = 0., Sum_tmpy = 0.;
424 for (int i = 0; i < m_TrackCount; i++)
425 {
426 if (energy[i] == 0) {
428 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
429 return m_ErrorCode;
430 }
431
432 a = m_property[i][2];
433
434 if (m_IsFixMass[i]) {
435 double invE = 1. / energy[i];
436 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 0] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 0][0] * invE -
437 Sum_al_1[0][0]);
438 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 1] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 1][0] * invE -
439 Sum_al_1[1][0]);
440 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 2] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 2][0] * invE -
441 Sum_al_1[2][0]);
442 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 3] = 0.;
443 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 4] = -2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 1][0] * invE -
444 Sum_al_1[1][0]) * a;
445 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 5] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 0][0] * invE -
446 Sum_al_1[0][0]) * a;
447 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 6] = 0.;
448 Sum_tmpx += al_1_prime[i * KFitConst::kNumber7 + 0][0] * invE * a;
449 Sum_tmpy += al_1_prime[i * KFitConst::kNumber7 + 1][0] * invE * a;
450 } else {
451 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 0] = -2.*Sum_al_1[0][0];
452 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 1] = -2.*Sum_al_1[1][0];
453 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 2] = -2.*Sum_al_1[2][0];
454 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 3] = 2.*Sum_al_1[3][0];
455 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 4] = 2.*Sum_al_1[1][0] * a;
456 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 5] = -2.*Sum_al_1[0][0] * a;
457 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 6] = 0.;
458 }
459 Sum_a += a;
460 }
461
462 // m_E
463 m_E[2 * m_TrackCount][0] = -2.*Sum_al_1[1][0] * Sum_a + 2.*Sum_al_1[3][0] * Sum_tmpy;
464 m_E[2 * m_TrackCount][1] = 2.*Sum_al_1[0][0] * Sum_a - 2.*Sum_al_1[3][0] * Sum_tmpx;
465 m_E[2 * m_TrackCount][2] = 0.;
466
467 for (int i = 0; i < m_TrackCount; i++)
468 {
469 double S, U;
470 double sininv;
471
472 double px = m_al_1[i * KFitConst::kNumber7 + 0][0];
473 double py = m_al_1[i * KFitConst::kNumber7 + 1][0];
474 double pz = m_al_1[i * KFitConst::kNumber7 + 2][0];
475 double x = m_al_1[i * KFitConst::kNumber7 + 4][0];
476 double y = m_al_1[i * KFitConst::kNumber7 + 5][0];
477 double z = m_al_1[i * KFitConst::kNumber7 + 6][0];
478 a = m_property[i][2];
479
480 double pt = sqrt(px * px + py * py);
481
482 if (pt == 0) {
484 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
485 return m_ErrorCode;
486 }
487
488 double invPt = 1. / pt;
489 double invPt2 = invPt * invPt;
490 double dlx = m_v_a[0][0] - x;
491 double dly = m_v_a[1][0] - y;
492 double dlz = m_v_a[2][0] - z;
493 double a1 = -dlx * py + dly * px;
494 double a2 = dlx * px + dly * py;
495 double r2d2 = dlx * dlx + dly * dly;
496 double Rx = dlx - 2.*px * a2 * invPt2;
497 double Ry = dly - 2.*py * a2 * invPt2;
498
499 if (a != 0.) { // charged
500
501 double B = a * a2 * invPt2;
502 if (fabs(B) > 1.) {
504 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
505 return m_ErrorCode;
506 }
507 // sin^(-1)(B)
508 sininv = asin(B);
509 double tmp0 = 1.0 - B * B;
510 if (tmp0 == 0) {
512 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
513 return m_ErrorCode;
514 }
515 // 1/sqrt(1-B^2)
516 double sqrtag = 1.0 / sqrt(tmp0);
517 S = sqrtag * invPt2;
518 U = dlz - pz * sininv / a;
519
520 } else { // neutral
521
522 sininv = 0.0;
523 S = invPt2;
524 U = dlz - pz * a2 * invPt2;
525
526 }
527
528 // d
529 m_d[i * 2 + 0][0] = a1 - 0.5 * a * r2d2;
530 m_d[i * 2 + 1][0] = U * pt;
531
532 // D
533 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 0] = dly;
534 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 1] = -dlx;
535 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 2] = 0.0;
536 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 4] = py + a * dlx;
537 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 5] = -px + a * dly;
538 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 6] = 0.0;
539 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 0] = -pz * pt * S * Rx + U * px * invPt;
540 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 1] = -pz * pt * S * Ry + U * py * invPt;
541 if (a != 0.)
542 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 2] = -sininv * pt / a;
543 else
544 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 2] = -a2 * invPt;
545 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 4] = px * pz * pt * S;
546 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 5] = py * pz * pt * S;
547 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 6] = -pt;
548
549 // E
550 m_E[i * 2 + 0][0] = -py - a * dlx;
551 m_E[i * 2 + 0][1] = px - a * dly;
552 m_E[i * 2 + 0][2] = 0.0;
553 m_E[i * 2 + 1][0] = -px * pz * pt * S;
554 m_E[i * 2 + 1][1] = -py * pz * pt * S;
555 m_E[i * 2 + 1][2] = pt;
556 }
557
559}
560
561
568
570{
571 MakeMotherKFit kmm;
573 unsigned n = getTrackCount();
574 for (unsigned i = 0; i < n; ++i) {
576 getTrack(i).getCharge());
578 for (unsigned j = i + 1; j < n; ++j) {
580 }
581 }
582 kmm.setVertex(getVertex());
584 m_ErrorCode = kmm.doMake();
586 return m_ErrorCode;
587 double chi2 = getCHIsq();
588 int ndf = getNDF();
589 double prob = TMath::Prob(chi2, ndf);
590 //
591 bool haschi2 = mother->hasExtraInfo("chiSquared");
592 if (haschi2) {
593 mother->setExtraInfo("chiSquared", chi2);
594 mother->setExtraInfo("ndf", ndf);
595 } else {
596 mother->addExtraInfo("chiSquared", chi2);
597 mother->addExtraInfo("ndf", ndf);
598 }
599
600 mother->updateMomentum(
601 CLHEPToROOT::getLorentzVector(kmm.getMotherMomentum()),
602 CLHEPToROOT::getXYZVector(kmm.getMotherPosition()),
603 CLHEPToROOT::getTMatrixFSym(kmm.getMotherError()),
604 prob);
606 return m_ErrorCode;
607}
static const double speedOfLight
[cm/ns]
Definition Const.h:695
Class to store reconstructed particles.
Definition Particle.h:76
void setExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
Definition Particle.cc:1402
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
Definition Particle.cc:1351
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
Definition Particle.cc:1421
void updateMomentum(const ROOT::Math::PxPyPzEVector &p4, const ROOT::Math::XYZVector &vertex, const TMatrixFSym &errMatrix, double pValue)
Sets Lorentz vector, position, 7x7 error matrix and p-value.
Definition Particle.h:397
int m_NecessaryTrackCount
Number needed tracks to perform fit.
Definition KFitBase.h:303
double m_MagneticField
Magnetic field.
Definition KFitBase.h:311
CLHEP::HepMatrix m_al_1
See J.Tanaka Ph.D (2001) p136 for definition.
Definition KFitBase.h:259
CLHEP::HepMatrix m_V_Dt
See J.Tanaka Ph.D (2001) p138 for definition.
Definition KFitBase.h:289
virtual enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &c)
Set a correlation matrix.
Definition KFitBase.cc:70
const CLHEP::HepSymMatrix makeError3(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e, const bool is_fix_mass) const
Rebuild an error matrix from a Lorentz vector and an error matrix.
Definition KFitBase.cc:320
const CLHEP::HepSymMatrix getTrackError(const int id) const
Get an error matrix of the track.
Definition KFitBase.cc:168
const CLHEP::HepLorentzVector getTrackMomentum(const int id) const
Get a Lorentz vector of the track.
Definition KFitBase.cc:154
CLHEP::HepMatrix m_lam
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:276
enum KFitError::ECode doFit2(void)
Perform a fit (used in VertexFitKFit::doFit() and MassVertexFitKFit::doFit()).
Definition KFitBase.cc:578
CLHEP::HepMatrix m_E
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:279
const HepPoint3D getTrackPosition(const int id) const
Get a position of the track.
Definition KFitBase.cc:161
CLHEP::HepMatrix m_property
Container of charges and masses.
Definition KFitBase.h:263
enum KFitError::ECode m_ErrorCode
Error code.
Definition KFitBase.h:243
virtual enum KFitError::ECode setZeroCorrelation(void)
Indicate no correlation between tracks.
Definition KFitBase.cc:85
CLHEP::HepMatrix m_V_al_1
See J.Tanaka Ph.D (2001) p138 for definition.
Definition KFitBase.h:274
virtual int getNDF(void) const
Get an NDF of the fit.
Definition KFitBase.cc:114
CLHEP::HepMatrix m_d
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:268
CLHEP::HepMatrix m_lam0
See J.Tanaka Ph.D (2001) p138 for definition.
Definition KFitBase.h:283
bool isFitted(void) const
Return false if fit is not performed yet or performed fit is failed; otherwise true.
Definition KFitBase.cc:728
CLHEP::HepMatrix m_D
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:266
CLHEP::HepMatrix m_V_D
See J.Tanaka Ph.D (2001) p138 for definition.
Definition KFitBase.h:271
bool isTrackIDInRange(const int id) const
Check if the id is in the range.
Definition KFitBase.cc:739
CLHEP::HepMatrix m_v_a
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:287
virtual const CLHEP::HepMatrix getCorrelation(const int id1, const int id2, const int flag=KFitConst::kAfterFit) const
Get a correlation matrix between two tracks.
Definition KFitBase.cc:183
bool m_FlagCorrelation
Flag whether a correlation among tracks exists.
Definition KFitBase.h:306
CLHEP::HepSymMatrix m_V_al_0
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:255
CLHEP::HepMatrix m_V_E
See J.Tanaka Ph.D (2001) p138 for definition.
Definition KFitBase.h:281
CLHEP::HepMatrix m_Cov_v_al_1
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:291
const KFitTrack getTrack(const int id) const
Get a specified track object.
Definition KFitBase.cc:175
std::vector< CLHEP::HepMatrix > m_BeforeCorrelation
Container of input correlation matrices.
Definition KFitBase.h:251
bool m_FlagFitted
Flag to indicate if the fit is performed and succeeded.
Definition KFitBase.h:245
double m_CHIsq
chi-square of the fit.
Definition KFitBase.h:297
int getTrackCount(void) const
Get the number of added tracks.
Definition KFitBase.cc:107
int m_NDF
NDF of the fit.
Definition KFitBase.h:295
std::vector< KFitTrack > m_Tracks
Container of input tracks.
Definition KFitBase.h:249
CLHEP::HepMatrix m_v
See J.Tanaka Ph.D (2001) p137 for definition.
Definition KFitBase.h:285
const CLHEP::HepMatrix makeError4(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e) const
Rebuild an error matrix from a Lorentz vector and an error matrix.
Definition KFitBase.cc:439
int m_TrackCount
Number of tracks.
Definition KFitBase.h:301
CLHEP::HepMatrix m_al_0
See J.Tanaka Ph.D (2001) p136 for definition.
Definition KFitBase.h:257
static void displayError(const char *file, const int line, const char *func, const enum ECode code)
Display a description of error and its location.
Definition KFitError.h:71
ECode
ECode is a error code enumerate.
Definition KFitError.h:33
@ kCannotGetMatrixInverse
Cannot calculate matrix inverse (bad track property or internal error)
Definition KFitError.h:57
@ kOutOfRange
Specified track-id out of range.
Definition KFitError.h:41
@ kDivisionByZero
Division by zero (bad track property or internal error)
Definition KFitError.h:55
@ kBadTrackSize
Track count too small to perform fit.
Definition KFitError.h:46
@ kBadCorrelationSize
Wrong correlation matrix size (internal error)
Definition KFitError.h:50
MakeMotherKFit is a class to build mother particle from kinematically fitted daughters.
enum KFitError::ECode setVertex(const HepPoint3D &v)
Set a vertex position of the mother particle.
enum KFitError::ECode addTrack(const KFitTrack &kp)
Add a track to the make-mother object.
enum KFitError::ECode doMake(void)
Perform a reconstruction of mother particle.
const CLHEP::HepSymMatrix getMotherError(void) const
Get an error matrix of the mother particle.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &e)
Set a correlation matrix.
const HepPoint3D getMotherPosition(void) const
Get a position of the mother particle.
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set a vertex error matrix of the mother particle.
enum KFitError::ECode setTrackVertexError(const CLHEP::HepMatrix &e)
Set a vertex error matrix of the child particle in the addTrack'ed order.
const CLHEP::HepLorentzVector getMotherMomentum(void) const
Get a Lorentz vector of the mother particle.
enum KFitError::ECode setMagneticField(const double mf)
Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
enum KFitError::ECode setZeroCorrelation(void) override
Indicate no correlation between tracks.
enum KFitError::ECode prepareInputMatrix(void) override
Build grand matrices for minimum search from input-track properties.
enum KFitError::ECode calculateNDF(void) override
Calculate an NDF of the fit.
enum KFitError::ECode setInitialVertex(const HepPoint3D &v)
Set an initial vertex point for the mass-vertex constraint fit.
double getCHIsq(void) const override
Get a chi-square of the fit.
std::vector< int > m_IsFixMass
Array of flags whether the track property is fixed at the mass.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
const CLHEP::HepSymMatrix getVertexError(void) const
Get a fitted vertex error matrix.
enum KFitError::ECode unfixMass(void)
Tell the object to unfix the last added track property at the invariant mass.
enum KFitError::ECode prepareInputSubMatrix(void) override
Build sub-matrices for minimum search from input-track properties.
~MassVertexFitKFit(void)
Destruct the object.
enum KFitError::ECode doFit(void)
Perform a mass-vertex-constraint fit.
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-vertex constraint fit.
enum KFitError::ECode makeCoreMatrix(void) override
Build matrices using the kinematical constraint.
enum KFitError::ECode prepareCorrelation(void) override
Build a grand correlation matrix from input-track properties.
MassVertexFitKFit(void)
Construct an object with no argument.
HepPoint3D m_AfterVertex
Vertex position after the fit.
enum KFitError::ECode setCorrelation(const CLHEP::HepMatrix &m) override
Set a correlation matrix.
std::vector< CLHEP::HepMatrix > m_AfterTrackVertexError
array of vertex error matrices after the fit.
const CLHEP::HepMatrix getCorrelation(const int id1, const int id2, const int flag=KFitConst::kAfterFit) const override
Get a correlation matrix between two tracks.
double getTrackCHIsq(const int id) const override
Get a chi-square of the track.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
CLHEP::HepSymMatrix m_AfterVertexError
Vertex error matrix after the fit.
enum KFitError::ECode prepareOutputMatrix(void) override
Build an output error matrix.
const CLHEP::HepMatrix getTrackVertexError(const int id) const
Get a vertex error matrix of the track.
HepPoint3D m_BeforeVertex
Vertex position before the fit.
enum KFitError::ECode fixMass(void)
Tell the object to fix the last added track property at the invariant mass.
double getInvariantMass(void) const
Get an invariant mass.
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.
static const int kMaxTrackCount
Maximum track size.
Definition KFitConst.h:38
static const int kAfterFit
Input parameter to specify after-fit when setting/getting a track attribute.
Definition KFitConst.h:35
static const int kBeforeFit
Input parameter to specify before-fit when setting/getting a track attribute.
Definition KFitConst.h:33
static const int kNumber7
Constant 7 to check matrix size (internal use)
Definition KFitConst.h:30