Belle II Software  release-05-02-19
RaveKinematicVertexFitter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Moritz Nadler, Luigi Li Gioi *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <analysis/dataobjects/Particle.h>
14 #include <analysis/VertexFitting/RaveInterface/RaveSetup.h>
15 
16 #include <mdst/dataobjects/TrackFitResult.h>
17 //std
18 #include <string>
19 
20 //root
21 #include <TMatrixFSym.h>
22 //rave
23 #include <rave/Vertex.h>
24 #include <rave/Track.h>
25 #include <rave/KinematicTree.h>
26 
27 // for intercepting rave output
28 #include <framework/utilities/IOIntercept.h>
29 
30 #include <iostream>
31 
32 namespace Belle2 {
38  namespace analysis {
44  class RaveKinematicVertexFitter {
45  public:
48 
49  //RaveKinematicVertexFitter(std::string howToInterfaceRave);
52 
54  void addTrack(const Particle* aParticlePtr);
55 
57  void addMother(const Particle* aMotherParticlePtr);
58 
60  void setMother(const Particle* aMotherParticlePtr);
61 
64  int fit();
65 
67  TVector3 getPos() ;
68 
70  double getPValue();
71 
73  double getNdf();
74 
76  double getChi2() ;
77 
79  TMatrixDSym getCov();
80 
82  TMatrixDSym getVertexErrorMatrix();
83 
85  void useBeamSpot(bool beamSpot = true)
86  {
87  if (beamSpot == true) {
88  if (RaveSetup::getRawInstance()->m_useBeamSpot == false) {
89  B2ERROR("Beam spot information cannot be used because the beam spot position and covariance was not set in RaveSetup");
90  throw;
91  }
92  m_useBeamSpot = true;
93  } else {
94  m_useBeamSpot = false;
95  }
96  }
97 
99  Particle* getMother();
100 
102  void updateMother();
103 
105  void updateDaughters();
106 
108  void clearTracks()
109  {
110  m_inputParticles.clear();
111  m_motherParticlePtr = NULL;
112  }
113 
115  void setMassConstFit(bool isConstFit = true);
116 
118  void setVertFit(bool isVertFit = true);
119 
121  void Print() const
122  {
123  B2INFO("useBeamSpot: " << m_useBeamSpot);
124  B2INFO("number of rave::Tracks: " << m_inputParticles.size());
125  }
126 
127 
128 
129 
130  protected:
131 
133  bool m_useBeamSpot;
134 
137 
139  std::string m_raveAlgorithm;
140 
142  rave::KinematicTree m_fittedResult;
143 
145  std::vector<rave::Track> m_raveTracks;
146 
148  std::vector < rave::Vertex > m_raveVertices;
149 
151  std::vector< rave::KinematicParticle > m_inputParticles;
153  rave::KinematicParticle m_fittedParticle;
154 
156  std::vector<Particle*> m_belleDaughters;
157 
161  bool m_vertFit;
163  double m_fittedNdf;
165  double m_fittedPValue;
167  double m_fittedChi2;
169  TVector3 m_fittedPos;
171  TLorentzVector m_fitted4Vector;
173  TMatrixFSym m_fitted7Cov;
174 
175 
176  private:
177 
179  TMatrixDSym ErrorMatrixMassToEnergy(const TLorentzVector& p4, const TMatrixDSym& MassErr);
180 
182  TMatrixDSym ErrorMatrixEnergyToMass(const TLorentzVector& p4, const TMatrixDSym& EnergyErr);
183 
188  };
189  }
190 
192 }
193 
Belle2::analysis::RaveKinematicVertexFitter::clearTracks
void clearTracks()
Delete all information of previously added tracks and fitted results.
Definition: RaveKinematicVertexFitter.h:116
Belle2::analysis::RaveKinematicVertexFitter::RaveKinematicVertexFitter
RaveKinematicVertexFitter()
The default constructor checks if RaveSetup was initialized and will set the attributes of RaveKinema...
Definition: RaveKinematicVertexFitter.cc:39
Belle2::analysis::RaveKinematicVertexFitter::m_massConstFit
bool m_massConstFit
flag determines if the mass fit is performed
Definition: RaveKinematicVertexFitter.h:167
Belle2::analysis::RaveKinematicVertexFitter::getChi2
double getChi2()
get the χ² of the fitted vertex.
Definition: RaveKinematicVertexFitter.cc:428
Belle2::analysis::RaveKinematicVertexFitter::m_fittedChi2
double m_fittedChi2
chi^2 of the vertex fit
Definition: RaveKinematicVertexFitter.h:175
Belle2::analysis::RaveKinematicVertexFitter::m_fittedParticle
rave::KinematicParticle m_fittedParticle
Particle fit output.
Definition: RaveKinematicVertexFitter.h:161
Belle2::analysis::RaveKinematicVertexFitter::getPValue
double getPValue()
get the p value of the fitted vertex.
Definition: RaveKinematicVertexFitter.cc:418
Belle2::analysis::RaveKinematicVertexFitter::ErrorMatrixMassToEnergy
TMatrixDSym ErrorMatrixMassToEnergy(const TLorentzVector &p4, const TMatrixDSym &MassErr)
Convert the error matrix from P-M to P-E.
Definition: RaveKinematicVertexFitter.cc:455
Belle2::analysis::RaveKinematicVertexFitter::m_inputParticles
std::vector< rave::KinematicParticle > m_inputParticles
input particles for vertex fit in rave format
Definition: RaveKinematicVertexFitter.h:159
Belle2::analysis::RaveKinematicVertexFitter::m_fittedResult
rave::KinematicTree m_fittedResult
the output of the kinematic fit
Definition: RaveKinematicVertexFitter.h:150
Belle2::analysis::RaveKinematicVertexFitter::getNdf
double getNdf()
get the number of degrees of freedom (NDF) of the fitted vertex.
Definition: RaveKinematicVertexFitter.cc:423
Belle2::analysis::RaveKinematicVertexFitter::getCov
TMatrixDSym getCov()
get the covariance matrix (7x7).
Definition: RaveKinematicVertexFitter.cc:433
Belle2::analysis::RaveKinematicVertexFitter::getMother
Particle * getMother()
returns a pointer to the mother particle
Definition: RaveKinematicVertexFitter.cc:408
Belle2::analysis::RaveKinematicVertexFitter::useBeamSpot
void useBeamSpot(bool beamSpot=true)
Overwrite the global option in ReveSetup that tells the fitter if beam spot info should be used or no...
Definition: RaveKinematicVertexFitter.h:93
Belle2::analysis::RaveKinematicVertexFitter::getVertexErrorMatrix
TMatrixDSym getVertexErrorMatrix()
get the covariance matrix (3x3) of the of the fitted vertex position.
Definition: RaveKinematicVertexFitter.cc:438
Belle2::analysis::RaveKinematicVertexFitter::updateMother
void updateMother()
update the mother particle
Definition: RaveKinematicVertexFitter.cc:326
Belle2::analysis::RaveKinematicVertexFitter::m_fittedNdf
double m_fittedNdf
Ndf of the vertex fit.
Definition: RaveKinematicVertexFitter.h:171
Belle2::analysis::RaveKinematicVertexFitter::captureOutput
IOIntercept::InterceptorScopeGuard< IOIntercept::OutputToLogMessages > captureOutput()
Start capturing the output of rave and divert it to log messages.
Definition: RaveKinematicVertexFitter.cc:48
Belle2::analysis::RaveKinematicVertexFitter::m_belleDaughters
std::vector< Particle * > m_belleDaughters
Belle Particle pointers input.
Definition: RaveKinematicVertexFitter.h:164
Belle2::analysis::RaveKinematicVertexFitter::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: RaveKinematicVertexFitter.cc:70
Belle2::analysis::RaveKinematicVertexFitter::ErrorMatrixEnergyToMass
TMatrixDSym ErrorMatrixEnergyToMass(const TLorentzVector &p4, const TMatrixDSym &EnergyErr)
Convert the error matrix from P-E to P-M.
Definition: RaveKinematicVertexFitter.cc:485
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::analysis::RaveKinematicVertexFitter::m_vertFit
bool m_vertFit
flag determines if the vertex fit is performed
Definition: RaveKinematicVertexFitter.h:169
Belle2::analysis::RaveKinematicVertexFitter::setVertFit
void setVertFit(bool isVertFit=true)
Set vertex fit: set false in case of mass fit only.
Definition: RaveKinematicVertexFitter.cc:63
Belle2::IOIntercept::InterceptorScopeGuard
Simple RAII guard for output interceptor.
Definition: IOIntercept.h:311
Belle2::analysis::RaveKinematicVertexFitter::fit
int fit()
do the kinematic vertex fit with all tracks previously added with the addTrack or addMother function.
Definition: RaveKinematicVertexFitter.cc:131
Belle2::analysis::RaveKinematicVertexFitter::m_motherParticlePtr
Particle * m_motherParticlePtr
pointer to the mother particle who's daughters will be used in the fit.
Definition: RaveKinematicVertexFitter.h:144
Belle2::analysis::RaveKinematicVertexFitter::addMother
void addMother(const Particle *aMotherParticlePtr)
All daughters of the argument of this function will be used as input for the vertex fit.
Definition: RaveKinematicVertexFitter.cc:107
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::analysis::RaveKinematicVertexFitter::updateDaughters
void updateDaughters()
update the Daughters particles
Definition: RaveKinematicVertexFitter.cc:331
Belle2::analysis::RaveKinematicVertexFitter::m_raveVertices
std::vector< rave::Vertex > m_raveVertices
holds the fitted vertices after fit() was called in the format used by Rave
Definition: RaveKinematicVertexFitter.h:156
Belle2::analysis::RaveKinematicVertexFitter::getPos
TVector3 getPos()
get the position of the fitted vertex.
Definition: RaveKinematicVertexFitter.cc:413
Belle2::analysis::RaveKinematicVertexFitter::m_useBeamSpot
bool m_useBeamSpot
flag determines if the beam spot will be used or not.
Definition: RaveKinematicVertexFitter.h:141
Belle2::analysis::RaveKinematicVertexFitter::m_raveTracks
std::vector< rave::Track > m_raveTracks
holds the tracks that were added to a RaveVertexFitter object in the format used by Rave
Definition: RaveKinematicVertexFitter.h:153
Belle2::analysis::RaveKinematicVertexFitter::m_fitted4Vector
TLorentzVector m_fitted4Vector
4 momentum of the mother particle after the fit
Definition: RaveKinematicVertexFitter.h:179
Belle2::analysis::RaveKinematicVertexFitter::Print
void Print() const
Print all attributes of this object to terminal.
Definition: RaveKinematicVertexFitter.h:129
Belle2::analysis::RaveSetup::getRawInstance
static RaveSetup * getRawInstance()
Same as getInstance(), but no check if the instance is initialised.
Definition: RaveSetup.cc:29
Belle2::analysis::RaveKinematicVertexFitter::setMother
void setMother(const Particle *aMotherParticlePtr)
Set Mother particle for Vertex/momentum update.
Definition: RaveKinematicVertexFitter.cc:123
Belle2::analysis::RaveKinematicVertexFitter::setMassConstFit
void setMassConstFit(bool isConstFit=true)
Set mass constrained fit
Definition: RaveKinematicVertexFitter.cc:58
Belle2::analysis::RaveKinematicVertexFitter::~RaveKinematicVertexFitter
~RaveKinematicVertexFitter()
Destructor.
Belle2::analysis::RaveKinematicVertexFitter::m_fitted7Cov
TMatrixFSym m_fitted7Cov
7x7 errror matrix of the mother particle after the fit
Definition: RaveKinematicVertexFitter.h:181
Belle2::analysis::RaveKinematicVertexFitter::m_fittedPos
TVector3 m_fittedPos
Fitted vertex position.
Definition: RaveKinematicVertexFitter.h:177
Belle2::analysis::RaveKinematicVertexFitter::m_raveAlgorithm
std::string m_raveAlgorithm
Algorithm used by rave (kalman, avr, ...)
Definition: RaveKinematicVertexFitter.h:147
Belle2::analysis::RaveKinematicVertexFitter::m_fittedPValue
double m_fittedPValue
Pvalue of the fit result.
Definition: RaveKinematicVertexFitter.h:173