Belle II Software development
RaveKinematicVertexFitter.h
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#pragma once
10
11#include <analysis/VertexFitting/RaveInterface/RaveSetup.h>
12
13//std
14#include <string>
15
16//root
17#include <TMatrixFSym.h>
18#include <Math/Vector3D.h>
19#include <Math/Vector4D.h>
20//rave
21#include <rave/Vertex.h>
22#include <rave/Track.h>
23#include <rave/KinematicTree.h>
24
25// for intercepting rave output
26#include <framework/utilities/IOIntercept.h>
27
28namespace Belle2 {
33 class Particle;
34
35 namespace analysis {
42 public:
45
46 //RaveKinematicVertexFitter(std::string howToInterfaceRave);
49
51 void addTrack(const Particle* aParticlePtr);
52
54 void addMother(const Particle* aMotherParticlePtr);
55
57 void setMother(const Particle* aMotherParticlePtr);
58
61 int fit();
62
64 ROOT::Math::XYZVector getPos() ;
65
67 double getPValue();
68
70 double getNdf();
71
73 double getChi2() ;
74
76 TMatrixDSym getCov();
77
79 TMatrixDSym getVertexErrorMatrix();
80
82 void useBeamSpot(bool beamSpot = true)
83 {
84 if (beamSpot == true) {
86 B2FATAL("Beam spot information cannot be used because the beam spot position and covariance was not set in RaveSetup");
87 }
88 m_useBeamSpot = true;
89 } else {
90 m_useBeamSpot = false;
91 }
92 }
93
96
98 void updateMother();
99
101 void updateDaughters();
102
105 {
106 m_inputParticles.clear();
107 m_motherParticlePtr = nullptr;
108 }
109
111 void setMassConstFit(bool isConstFit = true);
112
114 void setVertFit(bool isVertFit = true);
115
117 void Print() const
118 {
119 B2INFO("useBeamSpot: " << m_useBeamSpot);
120 B2INFO("number of rave::Tracks: " << m_inputParticles.size());
121 }
122
123
124
125
126 protected:
127
130
133
135 std::string m_raveAlgorithm;
136
138 rave::KinematicTree m_fittedResult;
139
141 std::vector<rave::Track> m_raveTracks;
142
144 std::vector < rave::Vertex > m_raveVertices;
145
147 std::vector< rave::KinematicParticle > m_inputParticles;
149 rave::KinematicParticle m_fittedParticle;
150
152 std::vector<Particle*> m_belleDaughters;
153
165 ROOT::Math::XYZVector m_fittedPos;
167 ROOT::Math::PxPyPzEVector m_fitted4Vector;
169 TMatrixFSym m_fitted7Cov;
170
171
172 private:
173
175 TMatrixDSym ErrorMatrixMassToEnergy(const ROOT::Math::PxPyPzEVector& p4, const TMatrixDSym& MassErr);
176
178 TMatrixDSym ErrorMatrixEnergyToMass(const ROOT::Math::PxPyPzEVector& p4, const TMatrixDSym& EnergyErr);
179
184 };
185 }
186
188}
189
Simple RAII guard for output interceptor.
Class to store reconstructed particles.
Definition Particle.h:76
std::vector< Particle * > m_belleDaughters
Belle Particle pointers input.
void useBeamSpot(bool beamSpot=true)
Overwrite the global option in ReveSetup that tells the fitter if beam spot info should be used or no...
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 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.
std::vector< rave::Vertex > m_raveVertices
holds the fitted vertices after fit() was called in the format used by Rave
void setMassConstFit(bool isConstFit=true)
Set mass constrained fit.
Particle * getMother()
returns a pointer to the mother particle
void clearTracks()
Delete all information of previously added tracks and fitted results.
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
void Print() const
Print all attributes of this object to terminal.
std::vector< rave::Track > m_raveTracks
holds the tracks that were added to a RaveVertexFitter object in the format used by Rave
ROOT::Math::XYZVector m_fittedPos
Fitted vertex position.
static RaveSetup * getRawInstance()
Same as getInstance(), but no check if the instance is initialised.
Definition RaveSetup.cc:29
Abstract base class for different kinds of events.