Belle II Software development
RaveKinematicVertexFitter.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/VertexFitting/RaveInterface/RaveKinematicVertexFitter.h>
10#include <analysis/VertexFitting/RaveInterface/RaveSetup.h>
11
12//root
13#include <Math/ProbFunc.h>
14#include <TMatrix.h>
15
16#include <rave/TransientTrackKinematicParticle.h>
17#include <rave/impl/RaveBase/Converters/interface/RaveStreamers.h>
18
19#include <rave/KinematicTreeFactory.h>
20#include <rave/KinematicConstraint.h>
21#include <rave/KinematicConstraintBuilder.h>
22#include <rave/VertexFactory.h>
23
24
25//#include <analysis/dataobjects/Particle.h>
26
27//c++ std lib
28using std::string;
29#include <vector>
30using std::vector;
31#include <iostream>
32
33using namespace Belle2;
34using namespace analysis;
35
36
37
39 m_massConstFit(false), m_vertFit(true)
40{
41 if (RaveSetup::getRawInstance() == nullptr) {
42 B2FATAL("RaveSetup::initialize was not called. It has to be called before RaveSetup or RaveKinematicVertexFitter are used");
43 }
45}
46
52
53
55
56
58{
59 m_massConstFit = isConstFit;
60}
61
63{
64 m_vertFit = isVertFit;
65}
66
67
68
70{
71 rave::Vector7D raveState(aParticlePtr->getX(), aParticlePtr->getY(), aParticlePtr->getZ(), aParticlePtr->getPx(),
72 aParticlePtr->getPy(), aParticlePtr->getPz(), aParticlePtr->getMass());
73 TMatrixDSym covP = aParticlePtr->getMomentumVertexErrorMatrix();
74
75 TMatrixDSym covE(7);
76 for (int i = 0; i < 7; i++) {
77 for (int j = 0; j < 7; j++) {
78 if (i < 3 && j < 3) covE(i, j) = covP(i + 4, j + 4);
79 if (i > 2 && j > 2) covE(i, j) = covP(i - 3, j - 3);
80 if (i < 3 && j > 2) covE(i, j) = covP(i + 4, j - 3);
81 if (i > 2 && j < 3) covE(i, j) = covP(i - 3, j + 4);
82 }
83 }
84
85 TMatrixDSym cov = ErrorMatrixEnergyToMass(aParticlePtr->get4Vector(), covE);
86
87 rave::Covariance7D raveCov(cov(0, 0), cov(0, 1), cov(0, 2), // x x , x y, x z
88 cov(1, 1), cov(1, 2), cov(2, 2), // y y , y z, z z
89 cov(0, 3), cov(0, 4), cov(0, 5), // x px , x py, x pz
90 cov(1, 3), cov(1, 4), cov(1, 5), // y px , y py, y pz
91 cov(2, 3), cov(2, 4), cov(2, 5), // z px , z py, z pz
92 cov(3, 3), cov(3, 4), cov(3, 5), // px px , px py, px pz
93 cov(4, 4), cov(4, 5), cov(5, 5), // py py , py pz, pz pz
94 cov(0, 6), cov(1, 6), cov(2, 6), // x m , y m, z m
95 cov(3, 6), cov(4, 6), cov(5, 6), // px m, py m, pz m
96 cov(6, 6)); // mm
97
98 rave::TransientTrackKinematicParticle aRaveParticle(raveState, raveCov, rave::Charge(aParticlePtr->getCharge()), 1, 1);
99 // 1 and 1 are dummy values for chi2 and ndf. the are not used for the vertex fit
100
101 m_inputParticles.push_back(aRaveParticle);
102 m_belleDaughters.push_back(const_cast<Particle*>(aParticlePtr));
103
104}
105
106void RaveKinematicVertexFitter::addMother(const Particle* aMotherParticlePtr)
107{
108 vector<Particle*> daughters = aMotherParticlePtr->getDaughters();
109
110 int nDaughters = daughters.size();
111 for (int i = 0; i not_eq nDaughters; ++i) {
112 addTrack(daughters[i]);
113 }
114
115 //store input pointer so fit results can be written to the mother particle after the fit
116 auto* tmp = const_cast<Particle*>(aMotherParticlePtr);
118
119}
120
121
122void RaveKinematicVertexFitter::setMother(const Particle* aMotherParticlePtr)
123{
124 auto* tmp = const_cast<Particle*>(aMotherParticlePtr);
126}
127
128
129
131{
132 // make sure all output in this function is converted to log messages
133 auto output_capture = captureOutput();
134
135 if (m_inputParticles.size() < 2 && m_vertFit) {
136 return -1;
137 }
138 int nOfVertices = -100;
139 if (m_useBeamSpot == true) {
140 const ROOT::Math::XYZVector& bsPos = RaveSetup::getRawInstance()->m_beamSpot;
141 const TMatrixDSym& bsCov = RaveSetup::getRawInstance()->m_beamSpotCov;
142 const rave::Covariance3D bsCovRave(bsCov(0, 0), bsCov(0, 1), bsCov(0, 2), bsCov(1, 1), bsCov(1, 2), bsCov(2, 2));
143 RaveSetup::getRawInstance()->m_raveVertexFactory->setBeamSpot(rave::Ellipsoid3D(rave::Point3D(bsPos.X(), bsPos.Y(), bsPos.Z()),
144 bsCovRave));
145 }
146
147 if (m_vertFit && m_massConstFit) {
148
149 rave::KinematicConstraint cs2 = rave::KinematicConstraintBuilder().createMultiTrackMassKinematicConstraint(
150 m_motherParticlePtr->getPDGMass(), m_inputParticles.size());
151 try {
153 m_fittedParticle = m_fittedResult.topParticle();
154 } catch (...) {
155 nOfVertices = 0;
156 }
157 } else {
158
159 if (m_vertFit) {
160 if (!m_massConstFit) {
161 try {
163 m_fittedParticle = m_fittedResult.topParticle();
164 } catch (...) {
165 nOfVertices = 0;
166 }
167 }
168
169 }
170
171 if (!m_vertFit && m_massConstFit) {
172
173 try {
174
175 Particle* aParticlePtr = m_motherParticlePtr;
176
177 rave::Vector7D raveState(aParticlePtr->getX(), aParticlePtr->getY(), aParticlePtr->getZ(), aParticlePtr->getPx(),
178 aParticlePtr->getPy(), aParticlePtr->getPz(), aParticlePtr->getMass());
179 TMatrixFSym covP = aParticlePtr->getMomentumVertexErrorMatrix();
180
181 float chi2 = 1;
182 float ndf = 1.;
183
184 TMatrixDSym covE(7);
185 for (int i = 0; i < 7; i++) {
186 for (int j = 0; j < 7; j++) {
187 if (i < 3 && j < 3) covE(i, j) = covP(i + 4, j + 4);
188 if (i > 2 && j > 2) covE(i, j) = covP(i - 3, j - 3);
189 if (i < 3 && j > 2) covE(i, j) = covP(i + 4, j - 3);
190 if (i > 2 && j < 3) covE(i, j) = covP(i - 3, j + 4);
191 }
192 }
193
194 TMatrixDSym cov = ErrorMatrixEnergyToMass(aParticlePtr->get4Vector(), covE);
195
196 rave::Covariance7D raveCov(cov(0, 0), cov(0, 1), cov(0, 2), // x x , x y, x z
197 cov(1, 1), cov(1, 2), cov(2, 2), // y y , y z, z z
198 cov(0, 3), cov(0, 4), cov(0, 5), // x px , x py, x pz
199 cov(1, 3), cov(1, 4), cov(1, 5), // y px , y py, y pz
200 cov(2, 3), cov(2, 4), cov(2, 5), // z px , z py, z pz
201 cov(3, 3), cov(3, 4), cov(3, 5), // px px , px py, px pz
202 cov(4, 4), cov(4, 5), cov(5, 5), // py py , py pz, pz pz
203 cov(0, 6), cov(1, 6), cov(2, 6), // x m , y m, z m
204 cov(3, 6), cov(4, 6), cov(5, 6), // px m, py m, pz m
205 cov(6, 6)); // mm
206
207 rave::TransientTrackKinematicParticle aRaveParticle(raveState, raveCov, rave::Charge(aParticlePtr->getCharge()), chi2, ndf);
208
209 std::vector< rave::KinematicParticle > parts; parts.push_back(aRaveParticle);
210
211 rave::KinematicConstraint constraint = rave::KinematicConstraintBuilder().createMassKinematicConstraint(
212 m_motherParticlePtr->getPDGMass(), 0.);
213
214 if (m_motherParticlePtr->getMomentumVertexErrorMatrix().Determinant() != 0) {
215
216 std::vector< rave::KinematicParticle > refitted = RaveSetup::getRawInstance()->m_raveKinematicTreeFactory->useParticleFitter(parts,
217 constraint, "ppf:lppf");
218
219 m_fittedParticle = refitted[0];
220
221 } else {
222 B2ERROR("[RaveKinematicVertexFitter]: VertexException saying ParentParticleFitter::error inverting covariance matrix occurred");
223 nOfVertices = 0;
224 }
225
226
227 } catch (...) {
228 nOfVertices = 0;
229 }
230 }
231
232 }
233
234
235 rave::Vector7D fittedState;
236 rave::Covariance7D fittedCov;
237
238 try {
239 fittedState = m_fittedParticle.fullstate();
240 fittedCov = m_fittedParticle.fullerror();
241 } catch (...) {
242 nOfVertices = 0;
243 }
244
245
246 for (auto& i : m_inputParticles) i.unlink();
247 m_inputParticles.clear();
248 //
249
250 if (nOfVertices == 0) { // vertex fit not successful
251 return 0;
252 }
253
254 if (m_vertFit) {
255 rave::KinematicVertex fittedVertex = m_fittedResult.currentDecayVertex();
256
257 m_fittedNdf = fittedVertex.ndf();
258 m_fittedChi2 = fittedVertex.chiSquared();
259 m_fittedPValue = ROOT::Math::chisquared_cdf_c(m_fittedChi2, m_fittedNdf);
260 m_fittedPos.SetXYZ(fittedVertex.position().x(), fittedVertex.position().y(), fittedVertex.position().z());
261
262 } else {
265 m_fittedPValue = ROOT::Math::chisquared_cdf_c(m_fittedChi2, m_fittedNdf);
267 }
268
269
270 m_fitted4Vector.SetXYZT(fittedState.p4().p3().x(), fittedState.p4().p3().y(), fittedState.p4().p3().z(), fittedState.p4().energy());
271
272 m_fitted7Cov.ResizeTo(7, 7);
273
274 TMatrixDSym fitted7CovM(7);
275
276 fitted7CovM(3, 6) = fittedCov.dpxm(); fitted7CovM(6, 3) = fitted7CovM(3, 6);
277 fitted7CovM(4, 6) = fittedCov.dpym(); fitted7CovM(6, 4) = fitted7CovM(4, 6);
278 fitted7CovM(5, 6) = fittedCov.dpzm(); fitted7CovM(6, 5) = fitted7CovM(5, 6);
279 fitted7CovM(6, 6) = fittedCov.dmm(); fitted7CovM(6, 6) = fitted7CovM(6, 6);
280 fitted7CovM(0, 6) = fittedCov.dxm(); fitted7CovM(6, 0) = fitted7CovM(0, 6);
281 fitted7CovM(1, 6) = fittedCov.dym(); fitted7CovM(6, 1) = fitted7CovM(1, 6);
282 fitted7CovM(2, 6) = fittedCov.dzm(); fitted7CovM(6, 2) = fitted7CovM(2, 6);
283
284 fitted7CovM(3, 3) = fittedCov.dpxpx(); fitted7CovM(3, 3) = fitted7CovM(3, 3);
285 fitted7CovM(3, 4) = fittedCov.dpxpy(); fitted7CovM(4, 3) = fitted7CovM(3, 4);
286 fitted7CovM(3, 5) = fittedCov.dpxpz(); fitted7CovM(5, 3) = fitted7CovM(3, 5);
287 fitted7CovM(3, 0) = fittedCov.dxpx(); fitted7CovM(0, 3) = fitted7CovM(3, 0);
288 fitted7CovM(3, 1) = fittedCov.dypx(); fitted7CovM(1, 3) = fitted7CovM(3, 1);
289 fitted7CovM(3, 2) = fittedCov.dzpx(); fitted7CovM(2, 3) = fitted7CovM(3, 2);
290
291 fitted7CovM(4, 4) = fittedCov.dpypy(); fitted7CovM(4, 4) = fitted7CovM(4, 4);
292 fitted7CovM(4, 5) = fittedCov.dpypz(); fitted7CovM(5, 4) = fitted7CovM(4, 5);
293 fitted7CovM(4, 0) = fittedCov.dxpy(); fitted7CovM(0, 4) = fitted7CovM(4, 0);
294 fitted7CovM(4, 1) = fittedCov.dypy(); fitted7CovM(1, 4) = fitted7CovM(4, 1);
295 fitted7CovM(4, 2) = fittedCov.dzpy(); fitted7CovM(2, 4) = fitted7CovM(4, 2);
296
297 fitted7CovM(5, 5) = fittedCov.dpzpz(); fitted7CovM(5, 5) = fitted7CovM(5, 5);
298 fitted7CovM(5, 0) = fittedCov.dxpz(); fitted7CovM(0, 5) = fitted7CovM(5, 0);
299 fitted7CovM(5, 1) = fittedCov.dypz(); fitted7CovM(1, 5) = fitted7CovM(5, 1);
300 fitted7CovM(5, 2) = fittedCov.dzpz(); fitted7CovM(2, 5) = fitted7CovM(5, 2);
301
302 fitted7CovM(0, 0) = fittedCov.dxx(); fitted7CovM(0, 0) = fitted7CovM(0, 0);
303 fitted7CovM(0, 1) = fittedCov.dxy(); fitted7CovM(1, 0) = fitted7CovM(0, 1);
304 fitted7CovM(0, 2) = fittedCov.dxz(); fitted7CovM(2, 0) = fitted7CovM(0, 2);
305
306 fitted7CovM(1, 1) = fittedCov.dyy(); fitted7CovM(1, 1) = fitted7CovM(1, 1);
307 fitted7CovM(1, 2) = fittedCov.dyz(); fitted7CovM(2, 1) = fitted7CovM(1, 2);
308
309 fitted7CovM(2, 2) = fittedCov.dzz(); fitted7CovM(2, 2) = fitted7CovM(2, 2);
310
311 TMatrixDSym fitted7CovE = ErrorMatrixMassToEnergy(m_fitted4Vector, fitted7CovM);
312
313 for (int i = 0; i < 7; i++) {
314 for (int j = 0; j < 7; j++) {
315 if (i < 4 && j < 4) m_fitted7Cov(i, j) = fitted7CovE(i + 3, j + 3);
316 if (i > 3 && j > 3) m_fitted7Cov(i, j) = fitted7CovE(i - 4, j - 4);
317 if (i < 4 && j > 3) m_fitted7Cov(i, j) = fitted7CovE(i + 3, j - 4);
318 if (i > 3 && j < 4) m_fitted7Cov(i, j) = fitted7CovE(i - 4, j + 3);
319 }
320 }
321
322 return 1;
323}
324
329
331{
332
333 m_fittedResult.topParticle();
334 std::vector< rave::KinematicParticle > rDau = m_fittedResult.daughterParticles();
335 std::vector<Belle2::Particle*> bDau = m_belleDaughters;
336 if (rDau.size() == bDau.size()) {
337 for (unsigned ii = 0; ii < bDau.size(); ii++) {
338 rave::Vector7D fittedState;
339 rave::Covariance7D fittedCov;
340 fittedState = rDau[ii].fullstate();
341 fittedCov = rDau[ii].fullerror();
342
343 ROOT::Math::PxPyPzEVector p4(fittedState.p4().p3().x(), fittedState.p4().p3().y(), fittedState.p4().p3().z(),
344 fittedState.p4().energy());
345
346 ROOT::Math::XYZVector x3(fittedState.x(), fittedState.y(), fittedState.z());
347
348
349 TMatrixDSym fitted7CovM(7);
350 fitted7CovM(3, 6) = fittedCov.dpxm(); fitted7CovM(6, 3) = fitted7CovM(3, 6);
351 fitted7CovM(4, 6) = fittedCov.dpym(); fitted7CovM(6, 4) = fitted7CovM(4, 6);
352 fitted7CovM(5, 6) = fittedCov.dpzm(); fitted7CovM(6, 5) = fitted7CovM(5, 6);
353 fitted7CovM(6, 6) = fittedCov.dmm(); fitted7CovM(6, 6) = fitted7CovM(6, 6);
354 fitted7CovM(0, 6) = fittedCov.dxm(); fitted7CovM(6, 0) = fitted7CovM(0, 6);
355 fitted7CovM(1, 6) = fittedCov.dym(); fitted7CovM(6, 1) = fitted7CovM(1, 6);
356 fitted7CovM(2, 6) = fittedCov.dzm(); fitted7CovM(6, 2) = fitted7CovM(2, 6);
357
358 fitted7CovM(3, 3) = fittedCov.dpxpx(); fitted7CovM(3, 3) = fitted7CovM(3, 3);
359 fitted7CovM(3, 4) = fittedCov.dpxpy(); fitted7CovM(4, 3) = fitted7CovM(3, 4);
360 fitted7CovM(3, 5) = fittedCov.dpxpz(); fitted7CovM(5, 3) = fitted7CovM(3, 5);
361 fitted7CovM(3, 0) = fittedCov.dxpx(); fitted7CovM(0, 3) = fitted7CovM(3, 0);
362 fitted7CovM(3, 1) = fittedCov.dypx(); fitted7CovM(1, 3) = fitted7CovM(3, 1);
363 fitted7CovM(3, 2) = fittedCov.dzpx(); fitted7CovM(2, 3) = fitted7CovM(3, 2);
364
365 fitted7CovM(4, 4) = fittedCov.dpypy(); fitted7CovM(4, 4) = fitted7CovM(4, 4);
366 fitted7CovM(4, 5) = fittedCov.dpypz(); fitted7CovM(5, 4) = fitted7CovM(4, 5);
367 fitted7CovM(4, 0) = fittedCov.dxpy(); fitted7CovM(0, 4) = fitted7CovM(4, 0);
368 fitted7CovM(4, 1) = fittedCov.dypy(); fitted7CovM(1, 4) = fitted7CovM(4, 1);
369 fitted7CovM(4, 2) = fittedCov.dzpy(); fitted7CovM(2, 4) = fitted7CovM(4, 2);
370
371 fitted7CovM(5, 5) = fittedCov.dpzpz(); fitted7CovM(5, 5) = fitted7CovM(5, 5);
372 fitted7CovM(5, 0) = fittedCov.dxpz(); fitted7CovM(0, 5) = fitted7CovM(5, 0);
373 fitted7CovM(5, 1) = fittedCov.dypz(); fitted7CovM(1, 5) = fitted7CovM(5, 1);
374 fitted7CovM(5, 2) = fittedCov.dzpz(); fitted7CovM(2, 5) = fitted7CovM(5, 2);
375
376 fitted7CovM(0, 0) = fittedCov.dxx(); fitted7CovM(0, 0) = fitted7CovM(0, 0);
377 fitted7CovM(0, 1) = fittedCov.dxy(); fitted7CovM(1, 0) = fitted7CovM(0, 1);
378 fitted7CovM(0, 2) = fittedCov.dxz(); fitted7CovM(2, 0) = fitted7CovM(0, 2);
379
380 fitted7CovM(1, 1) = fittedCov.dyy(); fitted7CovM(1, 1) = fitted7CovM(1, 1);
381 fitted7CovM(1, 2) = fittedCov.dyz(); fitted7CovM(2, 1) = fitted7CovM(1, 2);
382
383 fitted7CovM(2, 2) = fittedCov.dzz(); fitted7CovM(2, 2) = fitted7CovM(2, 2);
384
385 TMatrixDSym fitted7CovE = ErrorMatrixMassToEnergy(m_fitted4Vector, fitted7CovM);
386
387 TMatrixDSym fitted7CovDauM(7);
388 for (int i = 0; i < 7; i++) {
389 for (int j = 0; j < 7; j++) {
390 if (i < 4 && j < 4) fitted7CovDauM(i, j) = fitted7CovE(i + 3, j + 3);
391 if (i > 3 && j > 3) fitted7CovDauM(i, j) = fitted7CovE(i - 4, j - 4);
392 if (i < 4 && j > 3) fitted7CovDauM(i, j) = fitted7CovE(i + 3, j - 4);
393 if (i > 3 && j < 4) fitted7CovDauM(i, j) = fitted7CovE(i - 4, j + 3);
394 }
395 }
396
397 float pValDau = rDau[ii].chi2();
398
399 bDau[ii]->updateMomentum(p4, x3, fitted7CovDauM, pValDau);
400
401 }
402
403 } else B2ERROR("Error in Daughters update");
404
405}
406
411
413{
414 return m_fittedPos;
415}
416
421
423{
424 return m_fittedNdf;
425}
426
431
433{
434 return m_fitted7Cov;
435}
436
438{
439 TMatrixDSym posErr(3);
440 posErr(0, 0) = m_fitted7Cov(4, 4);
441 posErr(0, 1) = m_fitted7Cov(4, 5);
442 posErr(0, 2) = m_fitted7Cov(4, 6);
443 posErr(1, 0) = m_fitted7Cov(5, 4);
444 posErr(1, 1) = m_fitted7Cov(5, 5);
445 posErr(1, 2) = m_fitted7Cov(5, 6);
446 posErr(2, 0) = m_fitted7Cov(6, 4);
447 posErr(2, 1) = m_fitted7Cov(6, 5);
448 posErr(2, 2) = m_fitted7Cov(6, 6);
449
450 return posErr;
451}
452
453
454TMatrixDSym RaveKinematicVertexFitter::ErrorMatrixMassToEnergy(const ROOT::Math::PxPyPzEVector& p4, const TMatrixDSym& MassErr)
455{
456
457 TMatrix jac(7, 7);
458 for (int i = 0; i < 7; i++) {
459 for (int j = 0; j < 7; j++) {
460 if (i == j) jac(i, j) = 1;
461 else jac(i, j) = 0;
462 }
463 }
464 jac(6, 3) = p4.Px() / p4.E();
465 jac(6, 4) = p4.Py() / p4.E();
466 jac(6, 5) = p4.Pz() / p4.E();
467 jac(6, 6) = p4.M() / p4.E();
468
469
470 TMatrix jact(7, 7); jact.Transpose(jac);
471 TMatrix EnergyErrPart(7, 7); EnergyErrPart.Mult(jac, MassErr);
472 TMatrix EnergyErrTemp(7, 7); EnergyErrTemp.Mult(EnergyErrPart, jact);
473
474 TMatrixDSym EnergyErr(7);
475 for (int i = 0; i < 7; i++) {
476 for (int j = 0; j < 7; j++) {
477 EnergyErr(i, j) = EnergyErrTemp(i, j);
478 }
479 }
480
481 return EnergyErr;
482}
483
484TMatrixDSym RaveKinematicVertexFitter::ErrorMatrixEnergyToMass(const ROOT::Math::PxPyPzEVector& p4, const TMatrixDSym& EnergyErr)
485{
486
487 TMatrix jac(7, 7);
488 for (int i = 0; i < 7; i++) {
489 for (int j = 0; j < 7; j++) {
490 if (i == j) jac(i, j) = 1;
491 else jac(i, j) = 0;
492 }
493 }
494 jac(6, 3) = -1 * p4.Px() / p4.M();
495 jac(6, 4) = -1 * p4.Py() / p4.M();
496 jac(6, 5) = -1 * p4.Pz() / p4.M();
497 jac(6, 6) = p4.E() / p4.M();
498
499 TMatrix jact(7, 7); jact.Transpose(jac);
500 TMatrix MassErrPart(7, 7); MassErrPart.Mult(jac, EnergyErr);
501 TMatrix MassErrTemp(7, 7); MassErrTemp.Mult(MassErrPart, jact);
502
503 TMatrixDSym MassErr(7);
504 for (int i = 0; i < 7; i++) {
505 for (int j = 0; j < 7; j++) {
506 MassErr(i, j) = MassErrTemp(i, j);
507 }
508 }
509
510 return MassErr;
511}
Simple RAII guard for output interceptor.
Capture stdout and stderr and convert into log messages.
@ c_Debug
Debug: for code development.
Definition LogConfig.h:26
Class to store reconstructed particles.
Definition Particle.h:76
double getPx() const
Returns x component of momentum.
Definition Particle.h:607
double getPz() const
Returns z component of momentum.
Definition Particle.h:625
double getX() const
Returns x component of vertex position.
Definition Particle.h:660
double getPy() const
Returns y component of momentum.
Definition Particle.h:616
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
Definition Particle.cc:668
double getZ() const
Returns z component of vertex position.
Definition Particle.h:678
double getCharge(void) const
Returns particle charge.
Definition Particle.cc:653
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition Particle.h:567
double getY() const
Returns y component of vertex position.
Definition Particle.h:669
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition Particle.cc:451
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition Particle.h:527
std::vector< Particle * > m_belleDaughters
Belle Particle pointers input.
std::string m_raveAlgorithm
Algorithm used by rave (kalman, avr, ...)
TMatrixDSym ErrorMatrixEnergyToMass(const ROOT::Math::PxPyPzEVector &p4, const TMatrixDSym &EnergyErr)
Convert the error matrix from P-E to P-M.
IOIntercept::InterceptorScopeGuard< IOIntercept::OutputToLogMessages > captureOutput()
Start capturing the output of rave and divert it to log messages.
ROOT::Math::PxPyPzEVector m_fitted4Vector
4 momentum of the mother particle after the fit
TMatrixFSym m_fitted7Cov
7x7 error matrix of the mother particle after the fit
TMatrixDSym getCov()
get the covariance matrix (7x7).
rave::KinematicParticle m_fittedParticle
Particle fit output.
bool m_useBeamSpot
flag determines if the beam spot will be used or not.
void addMother(const Particle *aMotherParticlePtr)
All daughters of the argument of this function will be used as input for the vertex fit.
ROOT::Math::XYZVector getPos()
get the position of the fitted vertex.
void addTrack(const Particle *aParticlePtr)
add a track (in the format of a Belle2::Particle) to set of tracks that should be fitted to a vertex
bool m_massConstFit
flag determines if the mass fit is performed
TMatrixDSym ErrorMatrixMassToEnergy(const ROOT::Math::PxPyPzEVector &p4, const TMatrixDSym &MassErr)
Convert the error matrix from P-M to P-E.
void setMother(const Particle *aMotherParticlePtr)
Set Mother particle for Vertex/momentum update.
RaveKinematicVertexFitter()
The default constructor checks if RaveSetup was initialized and will set the attributes of RaveKinema...
rave::KinematicTree m_fittedResult
the output of the kinematic fit
int fit()
do the kinematic vertex fit with all tracks previously added with the addTrack or addMother function.
Particle * m_motherParticlePtr
pointer to the mother particle who's daughters will be used in the fit.
void setVertFit(bool isVertFit=true)
Set vertex fit: set false in case of mass fit only.
void setMassConstFit(bool isConstFit=true)
Set mass constrained fit.
Particle * getMother()
returns a pointer to the mother particle
double getPValue()
get the p value of the fitted vertex.
TMatrixDSym getVertexErrorMatrix()
get the covariance matrix (3x3) of the of the fitted vertex position.
double getChi2()
get the χ² of the fitted vertex.
std::vector< rave::KinematicParticle > m_inputParticles
input particles for vertex fit in rave format
double getNdf()
get the number of degrees of freedom (NDF) of the fitted vertex.
bool m_vertFit
flag determines if the vertex fit is performed
void updateDaughters()
update the Daughters particles
ROOT::Math::XYZVector m_fittedPos
Fitted vertex position.
TMatrixDSym m_beamSpotCov
beam spot position covariance matrix.
Definition RaveSetup.h:74
rave::KinematicTreeFactory * m_raveKinematicTreeFactory
< The RAVE Kinematic Tree factory is the principal interface offered by the RAVE for kinematic vertex...
Definition RaveSetup.h:81
bool m_useBeamSpot
flag determines if beam spot information should be used for vertex fit.
Definition RaveSetup.h:72
static RaveSetup * getRawInstance()
Same as getInstance(), but no check if the instance is initialised.
Definition RaveSetup.cc:29
ROOT::Math::XYZVector m_beamSpot
beam spot position.
Definition RaveSetup.h:73
rave::VertexFactory * m_raveVertexFactory
The RAVE vertex factory is the principal interface offered by the RAVE vertex fitting library.
Definition RaveSetup.h:77
InterceptorScopeGuard< T > start_intercept(T &interceptor)
Convenience wrapper to simplify use of InterceptorScopeGuard<T>.
Abstract base class for different kinds of events.