Belle II Software  release-05-02-19
RaveVertexFitter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - 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 //std
17 #include <string>
18 #include <iostream>
19 
20 //rave
21 #include <rave/Track.h>
22 #include <rave/Vertex.h>
23 
24 
25 namespace Belle2 {
30  class TrackFitResult;
31 
32  namespace analysis {
38  class RaveVertexFitter {
40  typedef std::vector<int>::size_type VecSize;
41  public:
42 
44  RaveVertexFitter(/*std::string howToInterfaceRave*/);
45 
48 
50  void addTrack(const Particle* const aParticlePtr);
51 
53  void addTrack(const TrackFitResult* const aTrackPtr);
54 
56  void addMother(const Particle* const aMotherParticlePtr);
57 
60  int fit(std::string options = "default");
61 
63  TVector3 getPos(VecSize vertexId = 0) const;
64 
66  double getPValue(VecSize vertexId = 0) const;
67 
69  double getNdf(VecSize vertexId = 0) const;
70 
72  double getChi2(VecSize vertexId = 0) const;
73 
75  TMatrixDSym getCov(VecSize vertexId = 0) const;
76 
78  double getWeight(int trackId, VecSize vertexId = 0) const;
79 
81  std::vector<int> getTrackIdsForOneVertex(VecSize vertexId = 0) const;
82 
84  void useBeamSpot(bool beamSpot = true)
85  {
86  if (beamSpot == true) {
87  if (RaveSetup::getRawInstance()->m_useBeamSpot == false) {
88  B2ERROR("Beam spot information cannot be used because the beam spot position and covariance was not set in RaveSetup");
89  throw;
90  }
91  m_useBeamSpot = true;
92  } else {
93  m_useBeamSpot = false;
94  }
95  }
96 
98  void clearTracks()
99  {
100  m_raveTracks.clear();
101  }
102 
103 
105  void Print() const
106  {
107  B2INFO("useBeamSpot: " << m_useBeamSpot);
108  B2INFO("number of rave::Tracks: " << m_raveTracks.size());
109  B2INFO("number of fitted rave::Vertices: " << m_raveVertices.size());
110 
111  }
113  int getNTracks() const
114  {
115  return m_raveTracks.size();
116  }
117 
119  void updateDaughters();
120 
121 
122  protected:
123 
124 // /** The default constructor checks if RaveSetup was initialized and will set the attributes of RaveVertexFitter */
125 // RaveVertexFitter();
127  void initBeamSpotMember();
129  void isVertexIdValid(const VecSize vertexId) const;
130 
132  rave::Track TrackFitResultToRaveTrack(const TrackFitResult* const aTrackPtr) const;
133  bool m_useBeamSpot;
136  //std::string m_raveAlgorithm;
137 
139  std::vector<rave::Track> m_raveTracks;
140 
142  std::vector < rave::Vertex > m_raveVertices;
143 
145  std::vector<Particle*> m_belleDaughters;
146 
147 
148  };
149  }
150 
152 }
153 
Belle2::analysis::RaveVertexFitter::isVertexIdValid
void isVertexIdValid(const VecSize vertexId) const
checks if the vertex the user requested via one of the getters it actually there
Definition: RaveVertexFitter.cc:155
Belle2::analysis::RaveVertexFitter::getPValue
double getPValue(VecSize vertexId=0) const
get the p value of the fitted vertex.
Definition: RaveVertexFitter.cc:206
Belle2::analysis::RaveVertexFitter::getNTracks
int getNTracks() const
return the number of tracks that where added via addTrack or addMother
Definition: RaveVertexFitter.h:121
Belle2::analysis::RaveVertexFitter::getPos
TVector3 getPos(VecSize vertexId=0) const
get the position of the fitted vertex.
Definition: RaveVertexFitter.cc:169
Belle2::analysis::RaveVertexFitter::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: RaveVertexFitter.h:92
Belle2::analysis::RaveVertexFitter::m_belleDaughters
std::vector< Particle * > m_belleDaughters
Belle Particle pointers input.
Definition: RaveVertexFitter.h:153
Belle2::analysis::RaveVertexFitter::clearTracks
void clearTracks()
Delete all information of previously added tracks and fitted results.
Definition: RaveVertexFitter.h:106
Belle2::analysis::RaveVertexFitter::getChi2
double getChi2(VecSize vertexId=0) const
get the χ² of the fitted vertex.
Definition: RaveVertexFitter.cc:222
Belle2::analysis::RaveVertexFitter::TrackFitResultToRaveTrack
rave::Track TrackFitResultToRaveTrack(const TrackFitResult *const aTrackPtr) const
converts a track from Belle2::TrackFitResult format to rave::Track format
Definition: RaveVertexFitter.cc:60
Belle2::TrackFitResult
Values of the result of a track fit with a given particle hypothesis.
Definition: TrackFitResult.h:59
Belle2::analysis::RaveVertexFitter::m_raveVertices
std::vector< rave::Vertex > m_raveVertices
holds the fitted vertices after fit() was called in the format used by Rave
Definition: RaveVertexFitter.h:150
Belle2::analysis::RaveVertexFitter::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: RaveVertexFitter.h:147
Belle2::analysis::RaveVertexFitter::m_useBeamSpot
bool m_useBeamSpot
flag determines if the beam spot will be used or not.
Definition: RaveVertexFitter.h:141
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::analysis::RaveVertexFitter::~RaveVertexFitter
~RaveVertexFitter()
Destructor.
Belle2::analysis::RaveVertexFitter::getNdf
double getNdf(VecSize vertexId=0) const
get the number of degrees of freedom (NDF) of the fitted vertex.
Definition: RaveVertexFitter.cc:214
Belle2::analysis::RaveVertexFitter::addTrack
void addTrack(const Particle *const aParticlePtr)
add a track (in the format of a Belle2::Particle) to set of tracks that should be fitted to a vertex
Definition: RaveVertexFitter.cc:87
Belle2::analysis::RaveVertexFitter::RaveVertexFitter
RaveVertexFitter()
The constructor.
Definition: RaveVertexFitter.cc:30
Belle2::analysis::RaveVertexFitter::getCov
TMatrixDSym getCov(VecSize vertexId=0) const
get the covariance matrix (3x3) of the of the fitted vertex position.
Definition: RaveVertexFitter.cc:230
Belle2::analysis::RaveVertexFitter::initBeamSpotMember
void initBeamSpotMember()
Initialize m_useBeamSpot.
Definition: RaveVertexFitter.cc:41
Belle2::analysis::RaveVertexFitter::getTrackIdsForOneVertex
std::vector< int > getTrackIdsForOneVertex(VecSize vertexId=0) const
get the ids of the tracks Rave associated with a specific vertex.
Definition: RaveVertexFitter.cc:194
Belle2::analysis::RaveVertexFitter::updateDaughters
void updateDaughters()
update the Daughters particles
Definition: RaveVertexFitter.cc:250
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::analysis::RaveVertexFitter::addMother
void addMother(const Particle *const aMotherParticlePtr)
All daughters of the argument of this function will be used as input for the vertex fit.
Definition: RaveVertexFitter.cc:110
Belle2::analysis::RaveVertexFitter::Print
void Print() const
Print all attributes of this object to terminal.
Definition: RaveVertexFitter.h:113
Belle2::analysis::RaveSetup::getRawInstance
static RaveSetup * getRawInstance()
Same as getInstance(), but no check if the instance is initialised.
Definition: RaveSetup.cc:29
Belle2::analysis::RaveVertexFitter::VecSize
std::vector< int >::size_type VecSize
I am using std::vector<int>::size_type because it is the official return value of ....
Definition: RaveVertexFitter.h:48
Belle2::analysis::RaveVertexFitter::fit
int fit(std::string options="default")
do the vertex fit with all tracks previously added with the addTrack or addMother function.
Definition: RaveVertexFitter.cc:121
Belle2::analysis::RaveVertexFitter::getWeight
double getWeight(int trackId, VecSize vertexId=0) const
get the weight Rave assigned to a specific input track.
Definition: RaveVertexFitter.cc:178