Belle II Software  release-05-01-25
FitManager.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * right(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributor: Wouter Hulsbergen, Francesco Tenchini, Jo-Frederik Krohn *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <analysis/dataobjects/Particle.h>
13 #include <analysis/VertexFitting/TreeFitter/ErrCode.h>
14 #include <analysis/VertexFitting/TreeFitter/ConstraintConfiguration.h>
15 
16 namespace TreeFitter {
17  class DecayChain;
18  class FitParams;
19  class ParticleBase;
20  class ConstraintConfiguration;
21 
23  class FitManager {
24  public:
25 
27  enum VertexStatus { Success = 0, NonConverged, BadInput, Failed, UnFitted };
28 
31  m_chiSquare(-1), m_niter(-1), m_prec(0.01), m_updateDaugthers(false), m_ndf(0),
32  m_fitparams(0), m_useReferencing(false)
33  {}
34 
37  const ConstraintConfiguration& config,
38  double prec = 0.01,
39  bool updateDaughters = false,
40  const bool useReferencing = false
41  );
42 
44  FitManager(const FitManager& other) = delete;
45 
47  FitManager& operator=(const FitManager& other) = delete;
48 
50  ~FitManager();
51 
53  bool fit();
54 
56  void setExtraInfo(Belle2::Particle* part, const std::string& name, const double value) const;
57 
59  bool updateCand(Belle2::Particle& particle, const bool isTreeHead) const;
60 
62  void updateCand(const ParticleBase& pb, Belle2::Particle& cand, const bool isTreeHead) const;
63 
65  void updateTree(Belle2::Particle& particle, const bool isTreeHead) const;
66 
68  void getCovFromPB(const ParticleBase* pb, TMatrixFSym& returncov) const;
69 
71  std::tuple<double, double> getLifeTime(Belle2::Particle& cand) const;
72 
74  std::tuple<double, double> getDecayLength(const ParticleBase* pb) const;
75 
77  std::tuple<double, double> getDecayLength(const ParticleBase* pb, const FitParams& fitparams) const;
78 
80  std::tuple<double, double> getDecayLength(Belle2::Particle& cand) const;
81 
84 
87 
90 
92  double chiSquare() const { return m_chiSquare ; }
93 
95  int nDof() const;
96 
98  int status() const { return m_status; }
99 
101  int nIter() const { return m_niter; }
102 
104  const ErrCode& errCode() { return m_errCode; }
105 
107  const DecayChain* decaychain() const { return m_decaychain; }
108 
110  Belle2::Particle* particle() { return m_particle; }
111 
112  private:
115 
118 
120  int m_status;
121 
123  double m_chiSquare;
124 
126  int m_niter;
127 
129  double m_prec;
130 
133 
135  const bool m_updateDaugthers;
136 
138  int m_ndf;
139 
142 
144  bool m_useReferencing;
145 
148  };
149 }
TreeFitter::FitManager::m_fitparams
FitParams * m_fitparams
parameters to be fitted
Definition: FitManager.h:149
TreeFitter::FitManager::FitManager
FitManager()
constructor
Definition: FitManager.h:38
TreeFitter::FitManager::m_config
const ConstraintConfiguration m_config
config container
Definition: FitManager.h:155
TreeFitter::FitManager::tauIndex
int tauIndex(Belle2::Particle *particle) const
getter for the index of tau, the lifetime in the statevector
Definition: FitManager.cc:165
TreeFitter::FitManager
this class
Definition: FitManager.h:31
TreeFitter::FitManager::m_prec
double m_prec
precision that is needed for status:converged (delta chi2)
Definition: FitManager.h:137
TreeFitter::FitManager::nIter
int nIter() const
getter for the current iteration number of the newton iteration
Definition: FitManager.h:109
TreeFitter::FitManager::momIndex
int momIndex(Belle2::Particle *particle) const
getter for the index of the momentum in the state vector
Definition: FitManager.cc:160
TreeFitter::FitManager::errCode
const ErrCode & errCode()
getter for some errorcode flag FIXME isn't this covered by the statusflag?
Definition: FitManager.h:112
TreeFitter::FitManager::operator=
FitManager & operator=(const FitManager &other)=delete
use default assignment op
TreeFitter::ConstraintConfiguration
constainer
Definition: ConstraintConfiguration.h:25
TreeFitter::FitManager::getCovFromPB
void getCovFromPB(const ParticleBase *pb, TMatrixFSym &returncov) const
extract cov from particle base
Definition: FitManager.cc:171
TreeFitter::ErrCode
abstract errorocode be aware that the default is succes
Definition: ErrCode.h:23
TreeFitter::ParticleBase
base class for all particles
Definition: ParticleBase.h:36
TreeFitter::FitManager::setExtraInfo
void setExtraInfo(Belle2::Particle *part, const std::string &name, const double value) const
add extrainfo to particle
Definition: FitManager.cc:63
TreeFitter::FitParams
Class to store and manage fitparams (statevector)
Definition: FitParams.h:29
TreeFitter::FitManager::m_decaychain
DecayChain * m_decaychain
the decay tree
Definition: FitManager.h:125
TreeFitter::FitManager::getLifeTime
std::tuple< double, double > getLifeTime(Belle2::Particle &cand) const
get lifetime
Definition: FitManager.cc:309
TreeFitter::FitManager::posIndex
int posIndex(Belle2::Particle *particle) const
getter for the index of the vertex position in the state vector
Definition: FitManager.cc:155
TreeFitter::FitManager::chiSquare
double chiSquare() const
getter for chi2 of the newton iteration
Definition: FitManager.h:100
TreeFitter::FitManager::getDecayLength
std::tuple< double, double > getDecayLength(const ParticleBase *pb) const
get decay length
Definition: FitManager.cc:352
TreeFitter::DecayChain
this class does a lot of stuff: Build decaytree structure allowing to index particles and handle the ...
Definition: DecayChain.h:34
TreeFitter::FitManager::m_chiSquare
double m_chiSquare
chi2 of the current iteration
Definition: FitManager.h:131
TreeFitter::FitManager::status
int status() const
getter for the status of the newton iteration
Definition: FitManager.h:106
TreeFitter::FitManager::decaychain
const DecayChain * decaychain() const
const getter for the decay chain
Definition: FitManager.h:115
TreeFitter::FitManager::m_errCode
ErrCode m_errCode
errorcode
Definition: FitManager.h:140
TreeFitter::FitManager::m_ndf
int m_ndf
number of degrees of freedom for this topology
Definition: FitManager.h:146
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
TreeFitter::FitManager::fit
bool fit()
main fit function that uses the kalman filter
Definition: FitManager.cc:74
TreeFitter::FitManager::updateCand
bool updateCand(Belle2::Particle &particle, const bool isTreeHead) const
update particles parameters with the fit results
Definition: FitManager.cc:235
TreeFitter::FitManager::m_niter
int m_niter
iteration index
Definition: FitManager.h:134
TreeFitter::FitManager::m_updateDaugthers
const bool m_updateDaugthers
if this is set all daughters will be updated otherwise only the head of the tree
Definition: FitManager.h:143
TreeFitter::FitManager::updateTree
void updateTree(Belle2::Particle &particle, const bool isTreeHead) const
update the Belle2::Particles with the fit results
Definition: FitManager.cc:296
TreeFitter::FitManager::m_particle
Belle2::Particle * m_particle
head of the tree
Definition: FitManager.h:122
TreeFitter::FitManager::~FitManager
~FitManager()
destructor does stuff
Definition: FitManager.cc:57
TreeFitter::FitManager::VertexStatus
VertexStatus
status flag of the fit-itereation (the step in the newton method)
Definition: FitManager.h:35
TreeFitter::FitManager::nDof
int nDof() const
getter for degrees of freedom of the fitparameters
Definition: FitManager.cc:150
TreeFitter::FitManager::m_useReferencing
bool m_useReferencing
use referencing
Definition: FitManager.h:152
TreeFitter::FitManager::m_status
int m_status
status of the current iteration
Definition: FitManager.h:128
TreeFitter::FitManager::particle
Belle2::Particle * particle()
getter for the head of the tree
Definition: FitManager.h:118