PandaRoot
Fitter.h
Go to the documentation of this file.
1 // ******************************************************
2 // DecayTreeFitter Package
3 // We thank the original author Wouter Hulsbergen
4 // (BaBar, LHCb) for providing the sources.
5 // http://arxiv.org/abs/physics/0503191v1 (2005)
6 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
7 // Adjustment for fully neutral reactions: Jean Noel (2023)
8 // *********************************************************************************
9 // $Id: Fitter.h,v 1.7 2010-05-29 13:39:56 ibelyaev Exp $
10 // =================================================================================
11 #ifndef DECAYTREEFITTER_FITTER_H
12 #define DECAYTREEFITTER_FITTER_H 1
13 // =================================================================================
14 // Include files
15 // =================================================================================
16 // STD & STL
17 // =================================================================================
18 #include <vector>
19 // =================================================================================
20 // GaudiKernel
21 // =================================================================================
22 //#include "GaudiKernel/SmartIF.h"
23 // =================================================================================
24 // Track interfaces
25 // =================================================================================
26 //#include "TrackInterfaces/ITrackStateProvider.h"
27 // =================================================================================
28 // LHCbMath
29 // =================================================================================
30 //#include "LHCbMath/ValueWithError.h"
31 //#include "LHCbMath/ParticleParams.h"
32 // =================================================================================
33 // DaVinciTypes
34 // =================================================================================
35 //#include "Kernel/DecayTree.h"
36 // =================================================================================
37 #include "RecoTrackStateProvider.h"
38 #include "Rtypes.h"
39 
40 #include "RhoDoubleErr.h"
41 #include "RhoCandidate.h"
42 #include "RhoFitterBase.h"
43 
44 namespace DecayTreeFitter {
45 class DecayChain;
46 class FitParams;
47 class ParticleBase;
48 class ChiSquare;
49 
50 // ==========================================================================
55 class Fitter : public RhoFitterBase {
56  public:
57  // ========================================================================
59  // ========================================================================
60  public:
61  // ========================================================================
63  Fitter(RhoCandidate *bc, RecoTrackStateProvider *extrapolator, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
65  Fitter(RhoCandidate *bc, const RhoVector3Err &pv, RecoTrackStateProvider *extrapolator = nullptr, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
67  Fitter(RhoCandidate *bc, const RhoLorentzVectorErr &lv, RecoTrackStateProvider *extrapolator, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
69  Fitter(RhoCandidate *bc, const RhoLorentzVectorErr &lv, const RhoVector3Err &pv, RecoTrackStateProvider *extrapolator = nullptr, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
71  virtual ~Fitter(); // destructor
72  // ========================================================================
73  public:
74  // ========================================================================
76  void setMassConstraint(RhoCandidate *cand, bool add = true);
78  void setMassConstraint(RhoCandidate *cand, double mass);
80  // TODO void setMassConstraint ( RhoCandidateID& pid , bool add = true ) ;
82  // TODO void setMassConstraint ( RhoCandidateID& pid , double mass ) ;
84  Bool_t Fit(int maxNumberOfIterations = 10, double deltaChisquareConverged = 0.01)
85  {
86  fit(maxNumberOfIterations, deltaChisquareConverged);
87  bool check = updateTree(m_particle);
88  check = check && (m_status == 0);
89  return check;
90  };
91  Bool_t FitAll(int maxit = 10, double dchiq = 0.01) { return Fit(maxit, dchiq); };
93  std::string print() const;
95  std::ostream &fillStream(std::ostream &s) const;
97  RhoCandidate *particle() const { return m_particle; }
102  RhoCandidate *fitParams(RhoCandidate *p = 0) const { return p->GetFit(); };
104  // double chiSquare () const { return m_chiSquare ; }
105  double chiSquare() const { return fChiSquare; }
107  int nDof() const;
109  FitStatus status() const { return m_status; }
111  int nIter() const { return m_niter; }
113  ChiSquare chiSquare(RhoCandidate *p) const;
122  // LHCb::DecayTree getFittedTree() const ;
127  // RhoCandidate getFitted() const ;
132  // RhoCandidate getFitted(RhoCandidate* cand) const ;
134  bool updateCand(RhoCandidate *cand) const;
136  bool updateTree(RhoCandidate *cand) const;
138  int errCode() { return m_errCode; }
140  void setVerbose(int i);
141  void SetToleranceZ(double z)
142  {
143  if (m_extrapolator)
145  };
146 
147  // FIXME ######@^$E&$#%#^!#@&*(####### REMOVE!
148  DecayChain *GetDecayChainDirty() { return m_decaychain; }
149 
150  // ========================================================================
151  public:
152  // ========================================================================
156  void setStateProvider(RecoTrackStateProvider *extrapolator);
157  // ========================================================================
158  protected:
159  // ========================================================================
160  // expert interface. not yet for real consumption
161  // Gaudi::Math::ParticleParams
162  // fitParams(const ParticleBase& pb) const ;
164  std::string name(RhoCandidate *cand) const;
165  // ========================================================================
166  RhoDoubleErr decayLengthSum(const ParticleBase &, const ParticleBase &) const;
167  // ========================================================================
168  DecayChain *decaychain() { return m_decaychain; }
169  FitParams *fitparams() { return m_fitparams; }
170  const DecayChain *decaychain() const { return m_decaychain; }
171  const FitParams *fitparams() const { return m_fitparams; }
172  // ========================================================================
173  double globalChiSquare() const;
174  // ========================================================================
175  // must be moved to derived class or so ...
176  double add(RhoCandidate *cand);
177  double remove(RhoCandidate *cand);
178  void updateIndex();
179  // ========================================================================
181  void fit(int maxNumberOfIterations = 10, double deltaChisquareConverged = 0.01);
183  void fitOneStep();
184  // ========================================================================
185 
186  RhoCandidate *fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const;
187  void updateCand(const ParticleBase &pb, RhoCandidate *cand) const;
188  // ========================================================================
189  private:
190  // ========================================================================
192  Fitter(); // default constructor is disabled
194  Fitter(const Fitter &); // copy constructor is disabled
196  Fitter &operator=(const Fitter &); // assignement operator is disabled
197  // ========================================================================
198  private:
199  // ========================================================================
200  RhoCandidate *m_particle;
201  DecayChain *m_decaychain;
202  FitParams *m_fitparams;
203  FitStatus m_status;
204  // double m_chiSquare ;
205  int m_niter;
206  int m_errCode;
207  // ========================================================================
208  // FIXME not being used???
209  // typedef std::map<RhoCandidate*, Gaudi::Math::ParticleParams> Map ;
210  // mutable Map m_map ;
211  // ========================================================================
212  protected:
214  RecoTrackStateProvider *m_extrapolator; // track extrapolator
215  // ========================================================================
216  ClassDef(Fitter, 1)
217 };
218 // ==========================================================================
219 } // namespace DecayTreeFitter
220 // ============================================================================
221 // The END
222 // ============================================================================
223 #endif
RecoTrackStateProvider * m_extrapolator
track extrapolator (if needed)
Definition: Fitter.h:214
FitStatus status() const
Status of fit.
Definition: Fitter.h:109
bool updateTree(RhoCandidate *cand) const
update a particlular candidate in the tree
const FitParams * fitparams() const
Definition: Fitter.h:171
std::string print() const
Print the result of the fit.
DecayChain * GetDecayChainDirty()
Definition: Fitter.h:148
void fit(int maxNumberOfIterations=10, double deltaChisquareConverged=0.01)
Fit the decay tree.
RhoDoubleErr decayLengthSum(RhoCandidate *, RhoCandidate *) const
double globalChiSquare() const
unsigned int i
Definition: P4_F32vec4.h:21
RhoCandidate * fitParams(RhoCandidate *p=0) const
Definition: Fitter.h:102
int nIter() const
Number of iterations used by vertex fit.
Definition: Fitter.h:111
FitParams * fitparams()
Definition: Fitter.h:169
double add(RhoCandidate *cand)
std::ostream & fillStream(std::ostream &s) const
Print the result of the fit.
int nDof() const
Total number of DOFs.
Bool_t FitAll(int maxit=10, double dchiq=0.01)
Definition: Fitter.h:91
int errCode()
error code
Definition: Fitter.h:138
virtual ~Fitter()
destructor
void setMassConstraint(RhoCandidate *cand, bool add=true)
Add or remove a mass constraint.
void setStateProvider(RecoTrackStateProvider *extrapolator)
set the track extrapolator
bool updateCand(RhoCandidate *cand) const
update a particlular candidate in the tree
void setVerbose(int i)
set the verbosity level (for debugging only)
void fitOneStep()
Fit just one step.
const DecayChain * decaychain() const
Definition: Fitter.h:170
double fChiSquare
Definition: RhoFitterBase.h:72
DecayChain * decaychain()
Definition: Fitter.h:168
std::string name(RhoCandidate *cand) const
Name of a particle in the decay tree.
RecoTrackStateProvider * extrapolator()
get the extrapolator
Definition: Fitter.h:154
Bool_t Fit()
Bool_t Fit(int maxNumberOfIterations=10, double deltaChisquareConverged=0.01)
Add or remove a mass constraintfor a certain ParticleID.
Definition: Fitter.h:84
RhoCandidate * fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const
RhoCandidate * particle() const
The top level particle that is fitted.
Definition: Fitter.h:97
double chiSquare() const
Total chisquare.
Definition: Fitter.h:105
RhoCandidate * GetFit() const
Definition: RhoCandidate.h:287
void SetToleranceZ(double z)
Definition: Fitter.h:141