Belle II Software  release-06-01-15
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/dataobjects/Particle.h>
12 #include <analysis/VertexFitting/RaveInterface/RaveSetup.h>
13 
14 #include <mdst/dataobjects/TrackFitResult.h>
15 //std
16 #include <string>
17 
18 //root
19 #include <TMatrixFSym.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 
28 #include <iostream>
29 
30 namespace Belle2 {
36  namespace analysis {
43  public:
46 
47  //RaveKinematicVertexFitter(std::string howToInterfaceRave);
50 
52  void addTrack(const Particle* aParticlePtr);
53 
55  void addMother(const Particle* aMotherParticlePtr);
56 
58  void setMother(const Particle* aMotherParticlePtr);
59 
62  int fit();
63 
65  TVector3 getPos() ;
66 
68  double getPValue();
69 
71  double getNdf();
72 
74  double getChi2() ;
75 
77  TMatrixDSym getCov();
78 
80  TMatrixDSym getVertexErrorMatrix();
81 
83  void useBeamSpot(bool beamSpot = true)
84  {
85  if (beamSpot == true) {
86  if (RaveSetup::getRawInstance()->m_useBeamSpot == false) {
87  B2ERROR("Beam spot information cannot be used because the beam spot position and covariance was not set in RaveSetup");
88  throw;
89  }
90  m_useBeamSpot = true;
91  } else {
92  m_useBeamSpot = false;
93  }
94  }
95 
98 
100  void updateMother();
101 
103  void updateDaughters();
104 
106  void clearTracks()
107  {
108  m_inputParticles.clear();
109  m_motherParticlePtr = nullptr;
110  }
111 
113  void setMassConstFit(bool isConstFit = true);
114 
116  void setVertFit(bool isVertFit = true);
117 
119  void Print() const
120  {
121  B2INFO("useBeamSpot: " << m_useBeamSpot);
122  B2INFO("number of rave::Tracks: " << m_inputParticles.size());
123  }
124 
125 
126 
127 
128  protected:
129 
132 
135 
137  std::string m_raveAlgorithm;
138 
140  rave::KinematicTree m_fittedResult;
141 
143  std::vector<rave::Track> m_raveTracks;
144 
146  std::vector < rave::Vertex > m_raveVertices;
147 
149  std::vector< rave::KinematicParticle > m_inputParticles;
151  rave::KinematicParticle m_fittedParticle;
152 
154  std::vector<Particle*> m_belleDaughters;
155 
159  bool m_vertFit;
161  double m_fittedNdf;
165  double m_fittedChi2;
167  TVector3 m_fittedPos;
169  TLorentzVector m_fitted4Vector;
171  TMatrixFSym m_fitted7Cov;
172 
173 
174  private:
175 
177  TMatrixDSym ErrorMatrixMassToEnergy(const TLorentzVector& p4, const TMatrixDSym& MassErr);
178 
180  TMatrixDSym ErrorMatrixEnergyToMass(const TLorentzVector& p4, const TMatrixDSym& EnergyErr);
181 
186  };
187  }
188 
190 }
191 
Simple RAII guard for output interceptor.
Definition: IOIntercept.h:301
Class to store reconstructed particles.
Definition: Particle.h:74
The RaveKinematicVertexFitter class is part of the RaveInterface together with RaveSetup.
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, ...)
IOIntercept::InterceptorScopeGuard< IOIntercept::OutputToLogMessages > captureOutput()
Start capturing the output of rave and divert it to log messages.
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.
TLorentzVector m_fitted4Vector
4 momentum of the mother particle after the fit
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.
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
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
TVector3 getPos()
get the position of the fitted vertex.
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
TMatrixDSym ErrorMatrixMassToEnergy(const TLorentzVector &p4, const TMatrixDSym &MassErr)
Convert the error matrix from P-M to P-E.
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
TMatrixDSym ErrorMatrixEnergyToMass(const TLorentzVector &p4, const TMatrixDSym &EnergyErr)
Convert the error matrix from P-E to P-M.
static RaveSetup * getRawInstance()
Same as getInstance(), but no check if the instance is initialised.
Definition: RaveSetup.cc:27
Abstract base class for different kinds of events.