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
78const HepPoint3D
79MassVertexFitKFit::getVertex(const int flag) const
80{
81 if (flag == KFitConst::kAfterFit && !isFitted()) return HepPoint3D();
82
83 switch (flag) {
85 return m_BeforeVertex;
86
88 return m_AfterVertex;
89
90 default:
91 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kOutOfRange);
92 return HepPoint3D();
93 }
94}
95
96
97const HepSymMatrix
102
103
104double
109
110
111double
113{
114 return m_CHIsq;
115}
116
117
118const HepMatrix
120{
121 if (!isTrackIDInRange(id)) return HepMatrix(3, KFitConst::kNumber7, 0);
122
123 return m_AfterTrackVertexError[id];
124}
125
126
127double
129{
130 if (!isFitted()) return -1;
131 if (!isTrackIDInRange(id)) return -1;
132
133 if (m_IsFixMass[id]) {
134
135 HepMatrix da(m_Tracks[id].getFitParameter(KFitConst::kBeforeFit) - m_Tracks[id].getFitParameter(KFitConst::kAfterFit));
136 int err_inverse = 0;
137 const double chisq = (da.T() * (m_Tracks[id].getFitError(KFitConst::kBeforeFit).inverse(err_inverse)) * da)[0][0];
138
139 if (err_inverse) {
140 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kCannotGetMatrixInverse);
141 return -1;
142 }
143
144 return chisq;
145
146 } else {
147
148 HepMatrix da(m_Tracks[id].getMomPos(KFitConst::kBeforeFit) - m_Tracks[id].getMomPos(KFitConst::kAfterFit));
149 int err_inverse = 0;
150 const double chisq = (da.T() * (m_Tracks[id].getError(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}
160
161
162const HepMatrix
163MassVertexFitKFit::getCorrelation(const int id1, const int id2, const int flag) const
164{
165 if (flag == KFitConst::kAfterFit && !isFitted()) return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
166 if (!isTrackIDInRange(id1)) return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
167 if (!isTrackIDInRange(id2)) return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
168
169 switch (flag) {
171 return KFitBase::getCorrelation(id1, id2, flag);
172
174 return makeError3(
175 this->getTrackMomentum(id1),
176 this->getTrackMomentum(id2),
177 m_V_al_1.sub(KFitConst::kNumber7 * id1 + 1, KFitConst::kNumber7 * (id1 + 1), KFitConst::kNumber7 * id2 + 1,
178 KFitConst::kNumber7 * (id2 + 1)),
179 m_IsFixMass[id1],
180 m_IsFixMass[id2]);
181
182 default:
183 KFitError::displayError(__FILE__, __LINE__, __func__, KFitError::kOutOfRange);
184 return HepMatrix(KFitConst::kNumber7, KFitConst::kNumber7, 0);
185 }
186}
187
188
193
194
198 {
200 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
201 return m_ErrorCode;
202 }
203
204
205 if (m_IsFixMass.size() == 0)
206 {
207 // If no fix_mass flag at all,
208 // all tracks are considered to be fixed at mass.
209 for (int i = 0; i < m_TrackCount; i++) this->fixMass();
210 } else if (m_IsFixMass.size() != (unsigned int)m_TrackCount)
211 {
213 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
214 return m_ErrorCode;
215 }
216
217
218 int index = 0;
219 m_al_0 = HepMatrix(KFitConst::kNumber7 * m_TrackCount, 1, 0);
220 m_property = HepMatrix(m_TrackCount, 3, 0);
221 m_V_al_0 = HepSymMatrix(KFitConst::kNumber7 * m_TrackCount, 0);
222
223 for (const auto& track : m_Tracks)
224 {
225 // momentum x,y,z and position x,y,z
226 m_al_0[index * KFitConst::kNumber7 + 0][0] = track.getMomentum(KFitConst::kBeforeFit).x();
227 m_al_0[index * KFitConst::kNumber7 + 1][0] = track.getMomentum(KFitConst::kBeforeFit).y();
228 m_al_0[index * KFitConst::kNumber7 + 2][0] = track.getMomentum(KFitConst::kBeforeFit).z();
229 m_al_0[index * KFitConst::kNumber7 + 3][0] = track.getMomentum(KFitConst::kBeforeFit).t();
230 m_al_0[index * KFitConst::kNumber7 + 4][0] = track.getPosition(KFitConst::kBeforeFit).x();
231 m_al_0[index * KFitConst::kNumber7 + 5][0] = track.getPosition(KFitConst::kBeforeFit).y();
232 m_al_0[index * KFitConst::kNumber7 + 6][0] = track.getPosition(KFitConst::kBeforeFit).z();
233 // these error
234 m_V_al_0.sub(index * KFitConst::kNumber7 + 1, track.getError(KFitConst::kBeforeFit));
235 // charge, mass, a
236 m_property[index][0] = track.getCharge();
237 m_property[index][1] = track.getMass();
238 const double c = Const::speedOfLight * 1e-4;
239 m_property[index][2] = -c * m_MagneticField * track.getCharge();
240 index++;
241 }
242
243 // error between track and track
245 {
246 this->prepareCorrelation();
248 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
249 return m_ErrorCode;
250 }
251 }
252
253 // vertex
254 m_v_a[0][0] = m_BeforeVertex.x();
255 m_v_a[1][0] = m_BeforeVertex.y();
256 m_v_a[2][0] = m_BeforeVertex.z();
257
258 // set member matrix
259 m_al_1 = m_al_0;
260
263 m_E = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 3);
264 m_d = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 1);
265 m_V_D = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, m_TrackCount * 2 + 1);
266 m_lam = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 1);
267 m_lam0 = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, 1);
268 m_V_Dt = m_V_al_1.sub(1, m_TrackCount * 2 + 1, 1, m_TrackCount * 2 + 1);
270
272}
273
274
277 // vertex
278 for (int i = 0; i < 3; i++) m_v[i][0] = m_v_a[i][0];
279
281}
282
283
286 if (m_BeforeCorrelation.size() != static_cast<unsigned int>(m_TrackCount * (m_TrackCount - 1) / 2))
287 {
289 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
290 return m_ErrorCode;
291 }
292
293 int row = 0, col = 0;
294
295 for (const auto& hm : m_BeforeCorrelation)
296 {
297 // counter
298 row++;
299 if (row == m_TrackCount) {
300 col++;
301 row = col + 1;
302 }
303
304 int ii = 0, jj = 0;
305 for (int i = KFitConst::kNumber7 * row; i < KFitConst::kNumber7 * (row + 1); i++) {
306 for (int j = KFitConst::kNumber7 * col; j < KFitConst::kNumber7 * (col + 1); j++) {
307 m_V_al_0[i][j] = hm[ii][jj];
308 jj++;
309 }
310 jj = 0;
311 ii++;
312 }
313 }
314
316}
317
318
321 Hep3Vector h3v;
322 int index = 0;
323 for (auto& pdata : m_Tracks)
324 {
325 // tracks
326 // momentum
327 h3v.setX(m_al_1[index * KFitConst::kNumber7 + 0][0]);
328 h3v.setY(m_al_1[index * KFitConst::kNumber7 + 1][0]);
329 h3v.setZ(m_al_1[index * KFitConst::kNumber7 + 2][0]);
330 if (m_IsFixMass[index])
331 pdata.setMomentum(HepLorentzVector(h3v, sqrt(h3v.mag2() + pdata.getMass()*pdata.getMass())), KFitConst::kAfterFit);
332 else
333 pdata.setMomentum(HepLorentzVector(h3v, m_al_1[index * KFitConst::kNumber7 + 3][0]), KFitConst::kAfterFit);
334 // position
335 pdata.setPosition(HepPoint3D(
336 m_al_1[index * KFitConst::kNumber7 + 4][0],
337 m_al_1[index * KFitConst::kNumber7 + 5][0],
339 // error of the tracks
340 pdata.setError(this->makeError3(pdata.getMomentum(),
341 m_V_al_1.sub(
342 index * KFitConst::kNumber7 + 1,
343 (index + 1)*KFitConst::kNumber7,
344 index * KFitConst::kNumber7 + 1,
345 (index + 1)*KFitConst::kNumber7), m_IsFixMass[index]),
347 if (m_ErrorCode != KFitError::kNoError) break;
348 index++;
349 }
350
351 // vertex
352 m_AfterVertex.setX(m_v_a[0][0]);
353 m_AfterVertex.setY(m_v_a[1][0]);
354 m_AfterVertex.setZ(m_v_a[2][0]);
355 // error of the vertex
356 for (int i = 0; i < 3; i++) for (int j = i; j < 3; j++)
357 {
358 m_AfterVertexError[i][j] = m_V_E[i][j];
359 }
360 // error between vertex and tracks
361 for (int i = 0; i < m_TrackCount; i++)
362 {
363 HepMatrix hm(3, KFitConst::kNumber7, 0);
364 for (int j = 0; j < 3; j++) for (int k = 0; k < KFitConst::kNumber7; k++) {
365 hm[j][k] = m_Cov_v_al_1[j][KFitConst::kNumber7 * i + k];
366 }
367 if (m_IsFixMass[i])
368 m_AfterTrackVertexError.push_back(this->makeError4(m_Tracks[i].getMomentum(), hm));
369 else
370 m_AfterTrackVertexError.push_back(hm);
371 }
372
374}
375
376
379 // Mass Constraint
380 HepMatrix al_1_prime(m_al_1);
381 HepMatrix Sum_al_1(4, 1, 0);
382 std::vector<double> energy(m_TrackCount);
383 double a;
384
385 for (int i = 0; i < m_TrackCount; i++)
386 {
387 a = m_property[i][2];
388 al_1_prime[i * KFitConst::kNumber7 + 0][0] -= a * (m_v_a[1][0] - al_1_prime[i * KFitConst::kNumber7 + 5][0]);
389 al_1_prime[i * KFitConst::kNumber7 + 1][0] += a * (m_v_a[0][0] - al_1_prime[i * KFitConst::kNumber7 + 4][0]);
390 energy[i] = sqrt(al_1_prime[i * KFitConst::kNumber7 + 0][0] * al_1_prime[i * KFitConst::kNumber7 + 0][0] +
391 al_1_prime[i * KFitConst::kNumber7 + 1][0] * al_1_prime[i * KFitConst::kNumber7 + 1][0] +
392 al_1_prime[i * KFitConst::kNumber7 + 2][0] * al_1_prime[i * KFitConst::kNumber7 + 2][0] +
393 m_property[i][1] * m_property[i][1]);
394 if (m_IsFixMass[i])
395 Sum_al_1[3][0] += energy[i];
396 else
397 Sum_al_1[3][0] += al_1_prime[i * KFitConst::kNumber7 + 3][0];
398 }
399
400 for (int i = 0; i < m_TrackCount; i++)
401 {
402 for (int j = 0; j < 3; j++) Sum_al_1[j][0] += al_1_prime[i * KFitConst::kNumber7 + j][0];
403 }
404
405 m_d[2 * m_TrackCount][0] =
406 + Sum_al_1[3][0] * Sum_al_1[3][0] - Sum_al_1[0][0] * Sum_al_1[0][0]
407 - Sum_al_1[1][0] * Sum_al_1[1][0] - Sum_al_1[2][0] * Sum_al_1[2][0]
409
410 double Sum_a = 0., Sum_tmpx = 0., Sum_tmpy = 0.;
411 for (int i = 0; i < m_TrackCount; i++)
412 {
413 if (energy[i] == 0) {
415 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
416 return m_ErrorCode;
417 }
418
419 a = m_property[i][2];
420
421 if (m_IsFixMass[i]) {
422 double invE = 1. / energy[i];
423 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 0] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 0][0] * invE -
424 Sum_al_1[0][0]);
425 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 1] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 1][0] * invE -
426 Sum_al_1[1][0]);
427 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 2] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 2][0] * invE -
428 Sum_al_1[2][0]);
429 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 3] = 0.;
430 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 4] = -2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 1][0] * invE -
431 Sum_al_1[1][0]) * a;
432 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 5] = 2.*(Sum_al_1[3][0] * al_1_prime[i * KFitConst::kNumber7 + 0][0] * invE -
433 Sum_al_1[0][0]) * a;
434 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 6] = 0.;
435 Sum_tmpx += al_1_prime[i * KFitConst::kNumber7 + 0][0] * invE * a;
436 Sum_tmpy += al_1_prime[i * KFitConst::kNumber7 + 1][0] * invE * a;
437 } else {
438 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 0] = -2.*Sum_al_1[0][0];
439 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 1] = -2.*Sum_al_1[1][0];
440 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 2] = -2.*Sum_al_1[2][0];
441 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 3] = 2.*Sum_al_1[3][0];
442 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 4] = 2.*Sum_al_1[1][0] * a;
443 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 5] = -2.*Sum_al_1[0][0] * a;
444 m_D[2 * m_TrackCount][i * KFitConst::kNumber7 + 6] = 0.;
445 }
446 Sum_a += a;
447 }
448
449 // m_E
450 m_E[2 * m_TrackCount][0] = -2.*Sum_al_1[1][0] * Sum_a + 2.*Sum_al_1[3][0] * Sum_tmpy;
451 m_E[2 * m_TrackCount][1] = 2.*Sum_al_1[0][0] * Sum_a - 2.*Sum_al_1[3][0] * Sum_tmpx;
452 m_E[2 * m_TrackCount][2] = 0.;
453
454 for (int i = 0; i < m_TrackCount; i++)
455 {
456 double S, U;
457 double sininv;
458
459 double px = m_al_1[i * KFitConst::kNumber7 + 0][0];
460 double py = m_al_1[i * KFitConst::kNumber7 + 1][0];
461 double pz = m_al_1[i * KFitConst::kNumber7 + 2][0];
462 double x = m_al_1[i * KFitConst::kNumber7 + 4][0];
463 double y = m_al_1[i * KFitConst::kNumber7 + 5][0];
464 double z = m_al_1[i * KFitConst::kNumber7 + 6][0];
465 a = m_property[i][2];
466
467 double pt = sqrt(px * px + py * py);
468
469 if (pt == 0) {
471 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
472 return m_ErrorCode;
473 }
474
475 double invPt = 1. / pt;
476 double invPt2 = invPt * invPt;
477 double dlx = m_v_a[0][0] - x;
478 double dly = m_v_a[1][0] - y;
479 double dlz = m_v_a[2][0] - z;
480 double a1 = -dlx * py + dly * px;
481 double a2 = dlx * px + dly * py;
482 double r2d2 = dlx * dlx + dly * dly;
483 double Rx = dlx - 2.*px * a2 * invPt2;
484 double Ry = dly - 2.*py * a2 * invPt2;
485
486 if (a != 0.) { // charged
487
488 double B = a * a2 * invPt2;
489 if (fabs(B) > 1.) {
491 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
492 return m_ErrorCode;
493 }
494 // sin^(-1)(B)
495 sininv = asin(B);
496 double tmp0 = 1.0 - B * B;
497 if (tmp0 == 0) {
499 KFitError::displayError(__FILE__, __LINE__, __func__, m_ErrorCode);
500 return m_ErrorCode;
501 }
502 // 1/sqrt(1-B^2)
503 double sqrtag = 1.0 / sqrt(tmp0);
504 S = sqrtag * invPt2;
505 U = dlz - pz * sininv / a;
506
507 } else { // neutral
508
509 sininv = 0.0;
510 S = invPt2;
511 U = dlz - pz * a2 * invPt2;
512
513 }
514
515 // d
516 m_d[i * 2 + 0][0] = a1 - 0.5 * a * r2d2;
517 m_d[i * 2 + 1][0] = U * pt;
518
519 // D
520 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 0] = dly;
521 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 1] = -dlx;
522 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 2] = 0.0;
523 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 4] = py + a * dlx;
524 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 5] = -px + a * dly;
525 m_D[i * 2 + 0][i * KFitConst::kNumber7 + 6] = 0.0;
526 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 0] = -pz * pt * S * Rx + U * px * invPt;
527 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 1] = -pz * pt * S * Ry + U * py * invPt;
528 if (a != 0.)
529 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 2] = -sininv * pt / a;
530 else
531 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 2] = -a2 * invPt;
532 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 4] = px * pz * pt * S;
533 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 5] = py * pz * pt * S;
534 m_D[i * 2 + 1][i * KFitConst::kNumber7 + 6] = -pt;
535
536 // E
537 m_E[i * 2 + 0][0] = -py - a * dlx;
538 m_E[i * 2 + 0][1] = px - a * dly;
539 m_E[i * 2 + 0][2] = 0.0;
540 m_E[i * 2 + 1][0] = -px * pz * pt * S;
541 m_E[i * 2 + 1][1] = -py * pz * pt * S;
542 m_E[i * 2 + 1][2] = pt;
543 }
544
546}
547
548
555
557{
558 MakeMotherKFit kmm;
560 unsigned n = getTrackCount();
561 for (unsigned i = 0; i < n; ++i) {
563 getTrack(i).getCharge());
565 for (unsigned j = i + 1; j < n; ++j) {
567 }
568 }
569 kmm.setVertex(getVertex());
571 m_ErrorCode = kmm.doMake();
573 return m_ErrorCode;
574 double chi2 = getCHIsq();
575 int ndf = getNDF();
576 double prob = TMath::Prob(chi2, ndf);
577 //
578 bool haschi2 = mother->hasExtraInfo("chiSquared");
579 if (haschi2) {
580 mother->setExtraInfo("chiSquared", chi2);
581 mother->setExtraInfo("ndf", ndf);
582 } else {
583 mother->addExtraInfo("chiSquared", chi2);
584 mother->addExtraInfo("ndf", ndf);
585 }
586
587 mother->updateMomentum(
588 CLHEPToROOT::getLorentzVector(kmm.getMotherMomentum()),
589 CLHEPToROOT::getXYZVector(kmm.getMotherPosition()),
590 CLHEPToROOT::getTMatrixFSym(kmm.getMotherError()),
591 prob);
593 return m_ErrorCode;
594}
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
static CLHEP::HepSymMatrix makeError3(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e, const bool is_fix_mass)
Rebuild an error matrix from a Lorentz vector and an error matrix.
Definition KFitBase.cc:320
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
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
static CLHEP::HepMatrix makeError4(const CLHEP::HepLorentzVector &p, const CLHEP::HepMatrix &e)
Rebuild an error matrix from a Lorentz vector and an error matrix.
Definition KFitBase.cc:439
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
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 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.
~MassVertexFitKFit(void) override
Destruct the object.
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.
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.
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