Belle II Software development
RaveKinematicVertexFitter Class Reference

The RaveKinematicVertexFitter class is part of the RaveInterface together with RaveSetup. More...

#include <RaveKinematicVertexFitter.h>

Public Member Functions

 RaveKinematicVertexFitter ()
 The default constructor checks if RaveSetup was initialized and will set the attributes of RaveKinematicVertexFitter.
 
 ~RaveKinematicVertexFitter ()
 Destructor.
 
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
 
void addMother (const Particle *aMotherParticlePtr)
 All daughters of the argument of this function will be used as input for the vertex fit.
 
void setMother (const Particle *aMotherParticlePtr)
 Set Mother particle for Vertex/momentum update.
 
int fit ()
 do the kinematic vertex fit with all tracks previously added with the addTrack or addMother function.
 
ROOT::Math::XYZVector getPos ()
 get the position of the fitted vertex.
 
double getPValue ()
 get the p value of the fitted vertex.
 
double getNdf ()
 get the number of degrees of freedom (NDF) of the fitted vertex.
 
double getChi2 ()
 get the χ² of the fitted vertex.
 
TMatrixDSym getCov ()
 get the covariance matrix (7x7).
 
TMatrixDSym getVertexErrorMatrix ()
 get the covariance matrix (3x3) of the of the fitted vertex position.
 
void useBeamSpot (bool beamSpot=true)
 Overwrite the global option in ReveSetup that tells the fitter if beam spot info should be used or not.
 
ParticlegetMother ()
 returns a pointer to the mother particle
 
void updateMother ()
 update the mother particle
 
void updateDaughters ()
 update the Daughters particles
 
void clearTracks ()
 Delete all information of previously added tracks and fitted results.
 
void setMassConstFit (bool isConstFit=true)
 Set mass constrained fit

 
void setVertFit (bool isVertFit=true)
 Set vertex fit: set false in case of mass fit only.
 
void Print () const
 Print all attributes of this object to terminal.
 

Protected Attributes

bool m_useBeamSpot
 flag determines if the beam spot will be used or not.
 
Particlem_motherParticlePtr
 pointer to the mother particle who's daughters will be used in the fit.
 
std::string m_raveAlgorithm
 Algorithm used by rave (kalman, avr, ...)
 
rave::KinematicTree m_fittedResult
 the output of the kinematic fit
 
std::vector< rave::Track > m_raveTracks
 holds the tracks that were added to a RaveVertexFitter object in the format used by Rave
 
std::vector< rave::Vertex > m_raveVertices
 holds the fitted vertices after fit() was called in the format used by Rave
 
std::vector< rave::KinematicParticle > m_inputParticles
 input particles for vertex fit in rave format
 
rave::KinematicParticle m_fittedParticle
 Particle fit output.
 
std::vector< Particle * > m_belleDaughters
 Belle Particle pointers input.
 
bool m_massConstFit
 flag determines if the mass fit is performed
 
bool m_vertFit
 flag determines if the vertex fit is performed
 
double m_fittedNdf
 Ndf of the vertex fit.
 
double m_fittedPValue
 Pvalue of the fit result.
 
double m_fittedChi2
 chi^2 of the vertex fit
 
ROOT::Math::XYZVector m_fittedPos
 Fitted vertex position.
 
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
 

Private Member Functions

TMatrixDSym ErrorMatrixMassToEnergy (const ROOT::Math::PxPyPzEVector &p4, const TMatrixDSym &MassErr)
 Convert the error matrix from P-M to P-E.
 
TMatrixDSym ErrorMatrixEnergyToMass (const ROOT::Math::PxPyPzEVector &p4, const TMatrixDSym &EnergyErr)
 Convert the error matrix from P-E to P-M.
 
IOIntercept::InterceptorScopeGuard< IOIntercept::OutputToLogMessagescaptureOutput ()
 Start capturing the output of rave and divert it to log messages.
 

Detailed Description

The RaveKinematicVertexFitter class is part of the RaveInterface together with RaveSetup.

To fit a vertex the user adds tracks (different formats are supported). Then calls the fit() function where the name of the fitting method and parameters can be passed as a string. RaveKinematicVertexFitter provides the getters to extract the results produced by Rave.

Definition at line 44 of file RaveKinematicVertexFitter.h.

Constructor & Destructor Documentation

◆ RaveKinematicVertexFitter()

The default constructor checks if RaveSetup was initialized and will set the attributes of RaveKinematicVertexFitter.

Definition at line 37 of file RaveKinematicVertexFitter.cc.

38 m_massConstFit(false), m_vertFit(true)
39{
40 if (RaveSetup::getRawInstance() == nullptr) {
41 B2FATAL("RaveSetup::initialize was not called. It has to be called before RaveSetup or RaveKinematicVertexFitter are used");
42 }
44}
std::string m_raveAlgorithm
Algorithm used by rave (kalman, avr, ...)
bool m_useBeamSpot
flag determines if the beam spot will be used or not.
bool m_massConstFit
flag determines if the mass fit is performed
Particle * m_motherParticlePtr
pointer to the mother particle who's daughters will be used in the fit.
bool m_vertFit
flag determines if the vertex fit is performed
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:27

Member Function Documentation

◆ addMother()

void addMother ( const Particle aMotherParticlePtr)

All daughters of the argument of this function will be used as input for the vertex fit.

Writes back the result directly to the mother particle

Definition at line 105 of file RaveKinematicVertexFitter.cc.

106{
107 vector<Particle*> daughters = aMotherParticlePtr->getDaughters();
108
109 int nDaughters = daughters.size();
110 for (int i = 0; i not_eq nDaughters; ++i) {
111 addTrack(daughters[i]);
112 }
113
114 //store input pointer so fit results can be written to the mother particle after the fit
115 auto* tmp = const_cast<Particle*>(aMotherParticlePtr);
117
118}
Class to store reconstructed particles.
Definition: Particle.h:75
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
Definition: Particle.cc:637
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

◆ addTrack()

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

Definition at line 68 of file RaveKinematicVertexFitter.cc.

69{
70 rave::Vector7D raveState(aParticlePtr->getX(), aParticlePtr->getY(), aParticlePtr->getZ(), aParticlePtr->getPx(),
71 aParticlePtr->getPy(), aParticlePtr->getPz(), aParticlePtr->getMass());
72 TMatrixDSym covP = aParticlePtr->getMomentumVertexErrorMatrix();
73
74 TMatrixDSym covE(7);
75 for (int i = 0; i < 7; i++) {
76 for (int j = 0; j < 7; j++) {
77 if (i < 3 && j < 3) covE(i, j) = covP(i + 4, j + 4);
78 if (i > 2 && j > 2) covE(i, j) = covP(i - 3, j - 3);
79 if (i < 3 && j > 2) covE(i, j) = covP(i + 4, j - 3);
80 if (i > 2 && j < 3) covE(i, j) = covP(i - 3, j + 4);
81 }
82 }
83
84 TMatrixDSym cov = ErrorMatrixEnergyToMass(aParticlePtr->get4Vector(), covE);
85
86 rave::Covariance7D raveCov(cov(0, 0), cov(0, 1), cov(0, 2), // x x , x y, x z
87 cov(1, 1), cov(1, 2), cov(2, 2), // y y , y z, z z
88 cov(0, 3), cov(0, 4), cov(0, 5), // x px , x py, x pz
89 cov(1, 3), cov(1, 4), cov(1, 5), // y px , y py, y pz
90 cov(2, 3), cov(2, 4), cov(2, 5), // z px , z py, z pz
91 cov(3, 3), cov(3, 4), cov(3, 5), // px px , px py, px pz
92 cov(4, 4), cov(4, 5), cov(5, 5), // py py , py pz, pz pz
93 cov(0, 6), cov(1, 6), cov(2, 6), // x m , y m, z m
94 cov(3, 6), cov(4, 6), cov(5, 6), // px m, py m, pz m
95 cov(6, 6)); // mm
96
97 rave::TransientTrackKinematicParticle aRaveParticle(raveState, raveCov, rave::Charge(aParticlePtr->getCharge()), 1, 1);
98 // 1 and 1 are dummy values for chi2 and ndf. the are not used for the vertex fit
99
100 m_inputParticles.push_back(aRaveParticle);
101 m_belleDaughters.push_back(const_cast<Particle*>(aParticlePtr));
102
103}
double getPx() const
Returns x component of momentum.
Definition: Particle.h:587
double getPz() const
Returns z component of momentum.
Definition: Particle.h:605
double getX() const
Returns x component of vertex position.
Definition: Particle.h:640
double getPy() const
Returns y component of momentum.
Definition: Particle.h:596
double getZ() const
Returns z component of vertex position.
Definition: Particle.h:658
double getCharge(void) const
Returns particle charge.
Definition: Particle.cc:622
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:547
double getY() const
Returns y component of vertex position.
Definition: Particle.h:649
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:420
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:507
std::vector< Particle * > m_belleDaughters
Belle Particle pointers input.
TMatrixDSym ErrorMatrixEnergyToMass(const ROOT::Math::PxPyPzEVector &p4, const TMatrixDSym &EnergyErr)
Convert the error matrix from P-E to P-M.
std::vector< rave::KinematicParticle > m_inputParticles
input particles for vertex fit in rave format

◆ captureOutput()

Start capturing the output of rave and divert it to log messages.

Capturing will finish as soon as the returned object goes out of scope

Definition at line 46 of file RaveKinematicVertexFitter.cc.

47{
49 return IOIntercept::start_intercept(s_captureOutput);
50}
Capture stdout and stderr and convert into log messages.
Definition: IOIntercept.h:226
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
InterceptorScopeGuard< T > start_intercept(T &interceptor)
Convenience wrapper to simplify use of InterceptorScopeGuard<T>.
Definition: IOIntercept.h:345

◆ clearTracks()

void clearTracks ( )
inline

Delete all information of previously added tracks and fitted results.

Definition at line 107 of file RaveKinematicVertexFitter.h.

108 {
109 m_inputParticles.clear();
110 m_motherParticlePtr = nullptr;
111 }

◆ ErrorMatrixEnergyToMass()

TMatrixDSym ErrorMatrixEnergyToMass ( const ROOT::Math::PxPyPzEVector &  p4,
const TMatrixDSym &  EnergyErr 
)
private

Convert the error matrix from P-E to P-M.

It Requires an input error matrix in the form X,P,E

Definition at line 483 of file RaveKinematicVertexFitter.cc.

484{
485
486 TMatrix jac(7, 7);
487 for (int i = 0; i < 7; i++) {
488 for (int j = 0; j < 7; j++) {
489 if (i == j) jac(i, j) = 1;
490 else jac(i, j) = 0;
491 }
492 }
493 jac(6, 3) = -1 * p4.Px() / p4.M();
494 jac(6, 4) = -1 * p4.Py() / p4.M();
495 jac(6, 5) = -1 * p4.Pz() / p4.M();
496 jac(6, 6) = p4.E() / p4.M();
497
498 TMatrix jact(7, 7); jact.Transpose(jac);
499 TMatrix MassErrPart(7, 7); MassErrPart.Mult(jac, EnergyErr);
500 TMatrix MassErrTemp(7, 7); MassErrTemp.Mult(MassErrPart, jact);
501
502 TMatrixDSym MassErr(7);
503 for (int i = 0; i < 7; i++) {
504 for (int j = 0; j < 7; j++) {
505 MassErr(i, j) = MassErrTemp(i, j);
506 }
507 }
508
509 return MassErr;
510}

◆ ErrorMatrixMassToEnergy()

TMatrixDSym ErrorMatrixMassToEnergy ( const ROOT::Math::PxPyPzEVector &  p4,
const TMatrixDSym &  MassErr 
)
private

Convert the error matrix from P-M to P-E.

It Requires an input error matrix in the form X,P,M

Definition at line 453 of file RaveKinematicVertexFitter.cc.

454{
455
456 TMatrix jac(7, 7);
457 for (int i = 0; i < 7; i++) {
458 for (int j = 0; j < 7; j++) {
459 if (i == j) jac(i, j) = 1;
460 else jac(i, j) = 0;
461 }
462 }
463 jac(6, 3) = p4.Px() / p4.E();
464 jac(6, 4) = p4.Py() / p4.E();
465 jac(6, 5) = p4.Pz() / p4.E();
466 jac(6, 6) = p4.M() / p4.E();
467
468
469 TMatrix jact(7, 7); jact.Transpose(jac);
470 TMatrix EnergyErrPart(7, 7); EnergyErrPart.Mult(jac, MassErr);
471 TMatrix EnergyErrTemp(7, 7); EnergyErrTemp.Mult(EnergyErrPart, jact);
472
473 TMatrixDSym EnergyErr(7);
474 for (int i = 0; i < 7; i++) {
475 for (int j = 0; j < 7; j++) {
476 EnergyErr(i, j) = EnergyErrTemp(i, j);
477 }
478 }
479
480 return EnergyErr;
481}

◆ fit()

int fit ( )

do the kinematic vertex fit with all tracks previously added with the addTrack or addMother function.

The return value is 1 if a vertex is successfully found. Return value 0 means the fit was not successful. -1 means not enough tracks were added

Definition at line 129 of file RaveKinematicVertexFitter.cc.

130{
131 // make sure all output in this function is converted to log messages
132 auto output_capture = captureOutput();
133
134 if (m_inputParticles.size() < 2 && m_vertFit) {
135 return -1;
136 }
137 int nOfVertices = -100;
138 if (m_useBeamSpot == true) {
140 const TMatrixDSym& bsCov = RaveSetup::getRawInstance()->m_beamSpotCov;
141 const rave::Covariance3D bsCovRave(bsCov(0, 0), bsCov(0, 1), bsCov(0, 2), bsCov(1, 1), bsCov(1, 2), bsCov(2, 2));
142 RaveSetup::getRawInstance()->m_raveVertexFactory->setBeamSpot(rave::Ellipsoid3D(rave::Point3D(bsPos.X(), bsPos.Y(), bsPos.Z()),
143 bsCovRave));
144 }
145
146 if (m_vertFit && m_massConstFit) {
147
148 rave::KinematicConstraint cs2 = rave::KinematicConstraintBuilder().createMultiTrackMassKinematicConstraint(
150 try {
152 m_fittedParticle = m_fittedResult.topParticle();
153 } catch (...) {
154 nOfVertices = 0;
155 }
156 } else {
157
158 if (m_vertFit) {
159 if (!m_massConstFit) {
160 try {
162 m_fittedParticle = m_fittedResult.topParticle();
163 } catch (...) {
164 nOfVertices = 0;
165 }
166 }
167
168 }
169
170 if (!m_vertFit && m_massConstFit) {
171
172 try {
173
174 Particle* aParticlePtr = m_motherParticlePtr;
175
176 rave::Vector7D raveState(aParticlePtr->getX(), aParticlePtr->getY(), aParticlePtr->getZ(), aParticlePtr->getPx(),
177 aParticlePtr->getPy(), aParticlePtr->getPz(), aParticlePtr->getMass());
178 TMatrixFSym covP = aParticlePtr->getMomentumVertexErrorMatrix();
179
180 float chi2 = 1;
181 float ndf = 1.;
182
183 TMatrixDSym covE(7);
184 for (int i = 0; i < 7; i++) {
185 for (int j = 0; j < 7; j++) {
186 if (i < 3 && j < 3) covE(i, j) = covP(i + 4, j + 4);
187 if (i > 2 && j > 2) covE(i, j) = covP(i - 3, j - 3);
188 if (i < 3 && j > 2) covE(i, j) = covP(i + 4, j - 3);
189 if (i > 2 && j < 3) covE(i, j) = covP(i - 3, j + 4);
190 }
191 }
192
193 TMatrixDSym cov = ErrorMatrixEnergyToMass(aParticlePtr->get4Vector(), covE);
194
195 rave::Covariance7D raveCov(cov(0, 0), cov(0, 1), cov(0, 2), // x x , x y, x z
196 cov(1, 1), cov(1, 2), cov(2, 2), // y y , y z, z z
197 cov(0, 3), cov(0, 4), cov(0, 5), // x px , x py, x pz
198 cov(1, 3), cov(1, 4), cov(1, 5), // y px , y py, y pz
199 cov(2, 3), cov(2, 4), cov(2, 5), // z px , z py, z pz
200 cov(3, 3), cov(3, 4), cov(3, 5), // px px , px py, px pz
201 cov(4, 4), cov(4, 5), cov(5, 5), // py py , py pz, pz pz
202 cov(0, 6), cov(1, 6), cov(2, 6), // x m , y m, z m
203 cov(3, 6), cov(4, 6), cov(5, 6), // px m, py m, pz m
204 cov(6, 6)); // mm
205
206 rave::TransientTrackKinematicParticle aRaveParticle(raveState, raveCov, rave::Charge(aParticlePtr->getCharge()), chi2, ndf);
207
208 std::vector< rave::KinematicParticle > parts; parts.push_back(aRaveParticle);
209
210 rave::KinematicConstraint constraint = rave::KinematicConstraintBuilder().createMassKinematicConstraint(
212
213 if (m_motherParticlePtr->getMomentumVertexErrorMatrix().Determinant() != 0) {
214
215 std::vector< rave::KinematicParticle > refitted = RaveSetup::getRawInstance()->m_raveKinematicTreeFactory->useParticleFitter(parts,
216 constraint, "ppf:lppf");
217
218 m_fittedParticle = refitted[0];
219
220 } else {
221 B2ERROR("[RaveKinematicVertexFitter]: VertexException saying ParentParticleFitter::error inverting covariance matrix occurred");
222 nOfVertices = 0;
223 }
224
225
226 } catch (...) {
227 nOfVertices = 0;
228 }
229 }
230
231 }
232
233
234 rave::Vector7D fittedState;
235 rave::Covariance7D fittedCov;
236
237 try {
238 fittedState = m_fittedParticle.fullstate();
239 fittedCov = m_fittedParticle.fullerror();
240 } catch (...) {
241 nOfVertices = 0;
242 }
243
244
245 for (auto& i : m_inputParticles) i.unlink();
246 m_inputParticles.clear();
247 //
248
249 if (nOfVertices == 0) { // vertex fit not successful
250 return 0;
251 }
252
253 if (m_vertFit) {
254 rave::KinematicVertex fittedVertex = m_fittedResult.currentDecayVertex();
255
256 m_fittedNdf = fittedVertex.ndf();
257 m_fittedChi2 = fittedVertex.chiSquared();
258 m_fittedPValue = ROOT::Math::chisquared_cdf_c(m_fittedChi2, m_fittedNdf);
259 m_fittedPos.SetXYZ(fittedVertex.position().x(), fittedVertex.position().y(), fittedVertex.position().z());
260
261 } else {
264 m_fittedPValue = ROOT::Math::chisquared_cdf_c(m_fittedChi2, m_fittedNdf);
266 }
267
268
269 m_fitted4Vector.SetXYZT(fittedState.p4().p3().x(), fittedState.p4().p3().y(), fittedState.p4().p3().z(), fittedState.p4().energy());
270
271 m_fitted7Cov.ResizeTo(7, 7);
272
273 TMatrixDSym fitted7CovM(7);
274
275 fitted7CovM(3, 6) = fittedCov.dpxm(); fitted7CovM(6, 3) = fitted7CovM(3, 6);
276 fitted7CovM(4, 6) = fittedCov.dpym(); fitted7CovM(6, 4) = fitted7CovM(4, 6);
277 fitted7CovM(5, 6) = fittedCov.dpzm(); fitted7CovM(6, 5) = fitted7CovM(5, 6);
278 fitted7CovM(6, 6) = fittedCov.dmm(); fitted7CovM(6, 6) = fitted7CovM(6, 6);
279 fitted7CovM(0, 6) = fittedCov.dxm(); fitted7CovM(6, 0) = fitted7CovM(0, 6);
280 fitted7CovM(1, 6) = fittedCov.dym(); fitted7CovM(6, 1) = fitted7CovM(1, 6);
281 fitted7CovM(2, 6) = fittedCov.dzm(); fitted7CovM(6, 2) = fitted7CovM(2, 6);
282
283 fitted7CovM(3, 3) = fittedCov.dpxpx(); fitted7CovM(3, 3) = fitted7CovM(3, 3);
284 fitted7CovM(3, 4) = fittedCov.dpxpy(); fitted7CovM(4, 3) = fitted7CovM(3, 4);
285 fitted7CovM(3, 5) = fittedCov.dpxpz(); fitted7CovM(5, 3) = fitted7CovM(3, 5);
286 fitted7CovM(3, 0) = fittedCov.dxpx(); fitted7CovM(0, 3) = fitted7CovM(3, 0);
287 fitted7CovM(3, 1) = fittedCov.dypx(); fitted7CovM(1, 3) = fitted7CovM(3, 1);
288 fitted7CovM(3, 2) = fittedCov.dzpx(); fitted7CovM(2, 3) = fitted7CovM(3, 2);
289
290 fitted7CovM(4, 4) = fittedCov.dpypy(); fitted7CovM(4, 4) = fitted7CovM(4, 4);
291 fitted7CovM(4, 5) = fittedCov.dpypz(); fitted7CovM(5, 4) = fitted7CovM(4, 5);
292 fitted7CovM(4, 0) = fittedCov.dxpy(); fitted7CovM(0, 4) = fitted7CovM(4, 0);
293 fitted7CovM(4, 1) = fittedCov.dypy(); fitted7CovM(1, 4) = fitted7CovM(4, 1);
294 fitted7CovM(4, 2) = fittedCov.dzpy(); fitted7CovM(2, 4) = fitted7CovM(4, 2);
295
296 fitted7CovM(5, 5) = fittedCov.dpzpz(); fitted7CovM(5, 5) = fitted7CovM(5, 5);
297 fitted7CovM(5, 0) = fittedCov.dxpz(); fitted7CovM(0, 5) = fitted7CovM(5, 0);
298 fitted7CovM(5, 1) = fittedCov.dypz(); fitted7CovM(1, 5) = fitted7CovM(5, 1);
299 fitted7CovM(5, 2) = fittedCov.dzpz(); fitted7CovM(2, 5) = fitted7CovM(5, 2);
300
301 fitted7CovM(0, 0) = fittedCov.dxx(); fitted7CovM(0, 0) = fitted7CovM(0, 0);
302 fitted7CovM(0, 1) = fittedCov.dxy(); fitted7CovM(1, 0) = fitted7CovM(0, 1);
303 fitted7CovM(0, 2) = fittedCov.dxz(); fitted7CovM(2, 0) = fitted7CovM(0, 2);
304
305 fitted7CovM(1, 1) = fittedCov.dyy(); fitted7CovM(1, 1) = fitted7CovM(1, 1);
306 fitted7CovM(1, 2) = fittedCov.dyz(); fitted7CovM(2, 1) = fitted7CovM(1, 2);
307
308 fitted7CovM(2, 2) = fittedCov.dzz(); fitted7CovM(2, 2) = fitted7CovM(2, 2);
309
310 TMatrixDSym fitted7CovE = ErrorMatrixMassToEnergy(m_fitted4Vector, fitted7CovM);
311
312 for (int i = 0; i < 7; i++) {
313 for (int j = 0; j < 7; j++) {
314 if (i < 4 && j < 4) m_fitted7Cov(i, j) = fitted7CovE(i + 3, j + 3);
315 if (i > 3 && j > 3) m_fitted7Cov(i, j) = fitted7CovE(i - 4, j - 4);
316 if (i < 4 && j > 3) m_fitted7Cov(i, j) = fitted7CovE(i + 3, j - 4);
317 if (i > 3 && j < 4) m_fitted7Cov(i, j) = fitted7CovE(i - 4, j + 3);
318 }
319 }
320
321 return 1;
322}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
Definition: Particle.cc:604
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
rave::KinematicParticle m_fittedParticle
Particle fit output.
TMatrixDSym ErrorMatrixMassToEnergy(const ROOT::Math::PxPyPzEVector &p4, const TMatrixDSym &MassErr)
Convert the error matrix from P-M to P-E.
rave::KinematicTree m_fittedResult
the output of the kinematic fit
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
B2Vector3D 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

◆ getChi2()

double getChi2 ( )

get the χ² of the fitted vertex.

Definition at line 426 of file RaveKinematicVertexFitter.cc.

427{
428 return m_fittedChi2;
429}

◆ getCov()

TMatrixDSym getCov ( )

get the covariance matrix (7x7).


Definition at line 431 of file RaveKinematicVertexFitter.cc.

432{
433 return m_fitted7Cov;
434}

◆ getMother()

Particle * getMother ( )

returns a pointer to the mother particle

Definition at line 406 of file RaveKinematicVertexFitter.cc.

407{
408 return m_motherParticlePtr;
409}

◆ getNdf()

double getNdf ( )

get the number of degrees of freedom (NDF) of the fitted vertex.


Definition at line 421 of file RaveKinematicVertexFitter.cc.

422{
423 return m_fittedNdf;
424}

◆ getPos()

ROOT::Math::XYZVector getPos ( )

get the position of the fitted vertex.


Definition at line 411 of file RaveKinematicVertexFitter.cc.

412{
413 return m_fittedPos;
414}

◆ getPValue()

double getPValue ( )

get the p value of the fitted vertex.


Definition at line 416 of file RaveKinematicVertexFitter.cc.

417{
418 return m_fittedPValue;
419}

◆ getVertexErrorMatrix()

TMatrixDSym getVertexErrorMatrix ( )

get the covariance matrix (3x3) of the of the fitted vertex position.


Definition at line 436 of file RaveKinematicVertexFitter.cc.

437{
438 TMatrixDSym posErr(3);
439 posErr(0, 0) = m_fitted7Cov(4, 4);
440 posErr(0, 1) = m_fitted7Cov(4, 5);
441 posErr(0, 2) = m_fitted7Cov(4, 6);
442 posErr(1, 0) = m_fitted7Cov(5, 4);
443 posErr(1, 1) = m_fitted7Cov(5, 5);
444 posErr(1, 2) = m_fitted7Cov(5, 6);
445 posErr(2, 0) = m_fitted7Cov(6, 4);
446 posErr(2, 1) = m_fitted7Cov(6, 5);
447 posErr(2, 2) = m_fitted7Cov(6, 6);
448
449 return posErr;
450}

◆ Print()

void Print ( ) const
inline

Print all attributes of this object to terminal.

Definition at line 120 of file RaveKinematicVertexFitter.h.

121 {
122 B2INFO("useBeamSpot: " << m_useBeamSpot);
123 B2INFO("number of rave::Tracks: " << m_inputParticles.size());
124 }

◆ setMassConstFit()

void setMassConstFit ( bool  isConstFit = true)

Set mass constrained fit

Definition at line 56 of file RaveKinematicVertexFitter.cc.

57{
58 m_massConstFit = isConstFit;
59}

◆ setMother()

void setMother ( const Particle aMotherParticlePtr)

Set Mother particle for Vertex/momentum update.

Not to be used with addMother

Definition at line 121 of file RaveKinematicVertexFitter.cc.

122{
123 auto* tmp = const_cast<Particle*>(aMotherParticlePtr);
125}

◆ setVertFit()

void setVertFit ( bool  isVertFit = true)

Set vertex fit: set false in case of mass fit only.

Definition at line 61 of file RaveKinematicVertexFitter.cc.

62{
63 m_vertFit = isVertFit;
64}

◆ updateDaughters()

void updateDaughters ( )

update the Daughters particles

Definition at line 329 of file RaveKinematicVertexFitter.cc.

330{
331
332 m_fittedResult.topParticle();
333 std::vector< rave::KinematicParticle > rDau = m_fittedResult.daughterParticles();
334 std::vector<Belle2::Particle*> bDau = m_belleDaughters;
335 if (rDau.size() == bDau.size()) {
336 for (unsigned ii = 0; ii < bDau.size(); ii++) {
337 rave::Vector7D fittedState;
338 rave::Covariance7D fittedCov;
339 fittedState = rDau[ii].fullstate();
340 fittedCov = rDau[ii].fullerror();
341
342 ROOT::Math::PxPyPzEVector p4(fittedState.p4().p3().x(), fittedState.p4().p3().y(), fittedState.p4().p3().z(),
343 fittedState.p4().energy());
344
345 ROOT::Math::XYZVector x3(fittedState.x(), fittedState.y(), fittedState.z());
346
347
348 TMatrixDSym fitted7CovM(7);
349 fitted7CovM(3, 6) = fittedCov.dpxm(); fitted7CovM(6, 3) = fitted7CovM(3, 6);
350 fitted7CovM(4, 6) = fittedCov.dpym(); fitted7CovM(6, 4) = fitted7CovM(4, 6);
351 fitted7CovM(5, 6) = fittedCov.dpzm(); fitted7CovM(6, 5) = fitted7CovM(5, 6);
352 fitted7CovM(6, 6) = fittedCov.dmm(); fitted7CovM(6, 6) = fitted7CovM(6, 6);
353 fitted7CovM(0, 6) = fittedCov.dxm(); fitted7CovM(6, 0) = fitted7CovM(0, 6);
354 fitted7CovM(1, 6) = fittedCov.dym(); fitted7CovM(6, 1) = fitted7CovM(1, 6);
355 fitted7CovM(2, 6) = fittedCov.dzm(); fitted7CovM(6, 2) = fitted7CovM(2, 6);
356
357 fitted7CovM(3, 3) = fittedCov.dpxpx(); fitted7CovM(3, 3) = fitted7CovM(3, 3);
358 fitted7CovM(3, 4) = fittedCov.dpxpy(); fitted7CovM(4, 3) = fitted7CovM(3, 4);
359 fitted7CovM(3, 5) = fittedCov.dpxpz(); fitted7CovM(5, 3) = fitted7CovM(3, 5);
360 fitted7CovM(3, 0) = fittedCov.dxpx(); fitted7CovM(0, 3) = fitted7CovM(3, 0);
361 fitted7CovM(3, 1) = fittedCov.dypx(); fitted7CovM(1, 3) = fitted7CovM(3, 1);
362 fitted7CovM(3, 2) = fittedCov.dzpx(); fitted7CovM(2, 3) = fitted7CovM(3, 2);
363
364 fitted7CovM(4, 4) = fittedCov.dpypy(); fitted7CovM(4, 4) = fitted7CovM(4, 4);
365 fitted7CovM(4, 5) = fittedCov.dpypz(); fitted7CovM(5, 4) = fitted7CovM(4, 5);
366 fitted7CovM(4, 0) = fittedCov.dxpy(); fitted7CovM(0, 4) = fitted7CovM(4, 0);
367 fitted7CovM(4, 1) = fittedCov.dypy(); fitted7CovM(1, 4) = fitted7CovM(4, 1);
368 fitted7CovM(4, 2) = fittedCov.dzpy(); fitted7CovM(2, 4) = fitted7CovM(4, 2);
369
370 fitted7CovM(5, 5) = fittedCov.dpzpz(); fitted7CovM(5, 5) = fitted7CovM(5, 5);
371 fitted7CovM(5, 0) = fittedCov.dxpz(); fitted7CovM(0, 5) = fitted7CovM(5, 0);
372 fitted7CovM(5, 1) = fittedCov.dypz(); fitted7CovM(1, 5) = fitted7CovM(5, 1);
373 fitted7CovM(5, 2) = fittedCov.dzpz(); fitted7CovM(2, 5) = fitted7CovM(5, 2);
374
375 fitted7CovM(0, 0) = fittedCov.dxx(); fitted7CovM(0, 0) = fitted7CovM(0, 0);
376 fitted7CovM(0, 1) = fittedCov.dxy(); fitted7CovM(1, 0) = fitted7CovM(0, 1);
377 fitted7CovM(0, 2) = fittedCov.dxz(); fitted7CovM(2, 0) = fitted7CovM(0, 2);
378
379 fitted7CovM(1, 1) = fittedCov.dyy(); fitted7CovM(1, 1) = fitted7CovM(1, 1);
380 fitted7CovM(1, 2) = fittedCov.dyz(); fitted7CovM(2, 1) = fitted7CovM(1, 2);
381
382 fitted7CovM(2, 2) = fittedCov.dzz(); fitted7CovM(2, 2) = fitted7CovM(2, 2);
383
384 TMatrixDSym fitted7CovE = ErrorMatrixMassToEnergy(m_fitted4Vector, fitted7CovM);
385
386 TMatrixDSym fitted7CovDauM(7);
387 for (int i = 0; i < 7; i++) {
388 for (int j = 0; j < 7; j++) {
389 if (i < 4 && j < 4) fitted7CovDauM(i, j) = fitted7CovE(i + 3, j + 3);
390 if (i > 3 && j > 3) fitted7CovDauM(i, j) = fitted7CovE(i - 4, j - 4);
391 if (i < 4 && j > 3) fitted7CovDauM(i, j) = fitted7CovE(i + 3, j - 4);
392 if (i > 3 && j < 4) fitted7CovDauM(i, j) = fitted7CovE(i - 4, j + 3);
393 }
394 }
395
396 float pValDau = rDau[ii].chi2();
397
398 bDau[ii]->updateMomentum(p4, x3, fitted7CovDauM, pValDau);
399
400 }
401
402 } else B2ERROR("Error in Daughters update");
403
404}

◆ updateMother()

void updateMother ( )

update the mother particle

Definition at line 324 of file RaveKinematicVertexFitter.cc.

325{
327}
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:386

◆ useBeamSpot()

void useBeamSpot ( bool  beamSpot = true)
inline

Overwrite the global option in ReveSetup that tells the fitter if beam spot info should be used or not.

The beam spot pos and cov must still be set in the RaveSetup class if you what to use it

Definition at line 85 of file RaveKinematicVertexFitter.h.

86 {
87 if (beamSpot == true) {
89 B2FATAL("Beam spot information cannot be used because the beam spot position and covariance was not set in RaveSetup");
90 }
91 m_useBeamSpot = true;
92 } else {
93 m_useBeamSpot = false;
94 }
95 }

Member Data Documentation

◆ m_belleDaughters

std::vector<Particle*> m_belleDaughters
protected

Belle Particle pointers input.

Definition at line 155 of file RaveKinematicVertexFitter.h.

◆ m_fitted4Vector

ROOT::Math::PxPyPzEVector m_fitted4Vector
protected

4 momentum of the mother particle after the fit

Definition at line 170 of file RaveKinematicVertexFitter.h.

◆ m_fitted7Cov

TMatrixFSym m_fitted7Cov
protected

7x7 error matrix of the mother particle after the fit

Definition at line 172 of file RaveKinematicVertexFitter.h.

◆ m_fittedChi2

double m_fittedChi2
protected

chi^2 of the vertex fit

Definition at line 166 of file RaveKinematicVertexFitter.h.

◆ m_fittedNdf

double m_fittedNdf
protected

Ndf of the vertex fit.

Definition at line 162 of file RaveKinematicVertexFitter.h.

◆ m_fittedParticle

rave::KinematicParticle m_fittedParticle
protected

Particle fit output.

Definition at line 152 of file RaveKinematicVertexFitter.h.

◆ m_fittedPos

ROOT::Math::XYZVector m_fittedPos
protected

Fitted vertex position.

Definition at line 168 of file RaveKinematicVertexFitter.h.

◆ m_fittedPValue

double m_fittedPValue
protected

Pvalue of the fit result.

Definition at line 164 of file RaveKinematicVertexFitter.h.

◆ m_fittedResult

rave::KinematicTree m_fittedResult
protected

the output of the kinematic fit

Definition at line 141 of file RaveKinematicVertexFitter.h.

◆ m_inputParticles

std::vector< rave::KinematicParticle > m_inputParticles
protected

input particles for vertex fit in rave format

Definition at line 150 of file RaveKinematicVertexFitter.h.

◆ m_massConstFit

bool m_massConstFit
protected

flag determines if the mass fit is performed

Definition at line 158 of file RaveKinematicVertexFitter.h.

◆ m_motherParticlePtr

Particle* m_motherParticlePtr
protected

pointer to the mother particle who's daughters will be used in the fit.

the fit result will be written back to the mother particle

Definition at line 135 of file RaveKinematicVertexFitter.h.

◆ m_raveAlgorithm

std::string m_raveAlgorithm
protected

Algorithm used by rave (kalman, avr, ...)

Definition at line 138 of file RaveKinematicVertexFitter.h.

◆ m_raveTracks

std::vector<rave::Track> m_raveTracks
protected

holds the tracks that were added to a RaveVertexFitter object in the format used by Rave

Definition at line 144 of file RaveKinematicVertexFitter.h.

◆ m_raveVertices

std::vector< rave::Vertex > m_raveVertices
protected

holds the fitted vertices after fit() was called in the format used by Rave

Definition at line 147 of file RaveKinematicVertexFitter.h.

◆ m_useBeamSpot

bool m_useBeamSpot
protected

flag determines if the beam spot will be used or not.

Overwrites the global flag in RaveSetup

Definition at line 132 of file RaveKinematicVertexFitter.h.

◆ m_vertFit

bool m_vertFit
protected

flag determines if the vertex fit is performed

Definition at line 160 of file RaveKinematicVertexFitter.h.


The documentation for this class was generated from the following files: