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 // ******************************************************
8 // $Id: Fitter.h,v 1.7 2010-05-29 13:39:56 ibelyaev Exp $
9 // ============================================================================
10 #ifndef DECAYTREEFITTER_FITTER_H
11 #define DECAYTREEFITTER_FITTER_H 1
12 // ============================================================================
13 // Include files
14 // ============================================================================
15 // STD & STL
16 // ============================================================================
17 #include <vector>
18 // ============================================================================
19 // GaudiKernel
20 // ============================================================================
21 //#include "GaudiKernel/SmartIF.h"
22 // ============================================================================
23 // Track interfaces
24 // ============================================================================
25 //#include "TrackInterfaces/ITrackStateProvider.h"
26 // ============================================================================
27 // LHCbMath
28 // ============================================================================
29 //#include "LHCbMath/ValueWithError.h"
30 //#include "LHCbMath/ParticleParams.h"
31 // ============================================================================
32 // DaVinciTypes
33 // ============================================================================
34 //#include "Kernel/DecayTree.h"
35 // ============================================================================
36 #include "RecoTrackStateProvider.h"
37 #include "Rtypes.h"
38 
39 #include "RhoDoubleErr.h"
40 #include "RhoCandidate.h"
41 #include "RhoFitterBase.h"
42 
43 namespace DecayTreeFitter {
44 class DecayChain;
45 class FitParams;
46 class ParticleBase;
47 class ChiSquare;
48 
49 // ==========================================================================
54 class Fitter : public RhoFitterBase {
55  public:
56  // ========================================================================
58  // ========================================================================
59  public:
60  // ========================================================================
62  Fitter(RhoCandidate *bc, RecoTrackStateProvider *extrapolator, int verbosity = 0);
64  Fitter(RhoCandidate *bc, const RhoVector3Err &pv, RecoTrackStateProvider *extrapolator = nullptr, int verbosity = 0);
66  Fitter(RhoCandidate *bc, const RhoLorentzVectorErr &lv, RecoTrackStateProvider *extrapolator, int verbosity = 0);
68  Fitter(RhoCandidate *bc, const RhoLorentzVectorErr &lv, const RhoVector3Err &pv, RecoTrackStateProvider *extrapolator = nullptr, int verbosity = 0);
70  virtual ~Fitter(); // destructor
71  // ========================================================================
72  public:
73  // ========================================================================
75  void setMassConstraint(RhoCandidate *cand, bool add = true);
77  void setMassConstraint(RhoCandidate *cand, double mass);
79  // TODO void setMassConstraint ( RhoCandidateID& pid , bool add = true ) ;
81  // TODO void setMassConstraint ( RhoCandidateID& pid , double mass ) ;
83  Bool_t Fit(int maxNumberOfIterations = 10, double deltaChisquareConverged = 0.01)
84  {
85  fit(maxNumberOfIterations, deltaChisquareConverged);
86  bool check = updateTree(m_particle);
87  check = check && (m_status == 0);
88  return check;
89  };
90  Bool_t FitAll(int maxit = 10, double dchiq = 0.01) { return Fit(maxit, dchiq); };
92  std::string print() const;
94  std::ostream &fillStream(std::ostream &s) const;
96  RhoCandidate *particle() const { return m_particle; }
101  RhoCandidate *fitParams(RhoCandidate *p = 0) const { return p->GetFit(); };
103  // double chiSquare () const { return m_chiSquare ; }
104  double chiSquare() const { return fChiSquare; }
106  int nDof() const;
108  FitStatus status() const { return m_status; }
110  int nIter() const { return m_niter; }
112  ChiSquare chiSquare(RhoCandidate *p) const;
121  // LHCb::DecayTree getFittedTree() const ;
126  // RhoCandidate getFitted() const ;
131  // RhoCandidate getFitted(RhoCandidate* cand) const ;
133  bool updateCand(RhoCandidate *cand) const;
135  bool updateTree(RhoCandidate *cand) const;
137  int errCode() { return m_errCode; }
139  void setVerbose(int i);
140  void SetToleranceZ(double z)
141  {
142  if (m_extrapolator)
144  };
145 
146  // FIXME ######@^$E&$#%#^!#@&*(####### REMOVE!
147  DecayChain *GetDecayChainDirty() { return m_decaychain; }
148 
149  // ========================================================================
150  public:
151  // ========================================================================
155  void setStateProvider(RecoTrackStateProvider *extrapolator);
156  // ========================================================================
157  protected:
158  // ========================================================================
159  // expert interface. not yet for real consumption
160  // Gaudi::Math::ParticleParams
161  // fitParams(const ParticleBase& pb) const ;
163  std::string name(RhoCandidate *cand) const;
164  // ========================================================================
165  RhoDoubleErr decayLengthSum(const ParticleBase &, const ParticleBase &) const;
166  // ========================================================================
167  DecayChain *decaychain() { return m_decaychain; }
168  FitParams *fitparams() { return m_fitparams; }
169  const DecayChain *decaychain() const { return m_decaychain; }
170  const FitParams *fitparams() const { return m_fitparams; }
171  // ========================================================================
172  double globalChiSquare() const;
173  // ========================================================================
174  // must be moved to derived class or so ...
175  double add(RhoCandidate *cand);
176  double remove(RhoCandidate *cand);
177  void updateIndex();
178  // ========================================================================
180  void fit(int maxNumberOfIterations = 10, double deltaChisquareConverged = 0.01);
182  void fitOneStep();
183  // ========================================================================
184 
185  RhoCandidate *fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const;
186  void updateCand(const ParticleBase &pb, RhoCandidate *cand) const;
187  // ========================================================================
188  private:
189  // ========================================================================
191  Fitter(); // default constructor is disabled
193  Fitter(const Fitter &); // copy constructor is disabled
195  Fitter &operator=(const Fitter &); // assignement operator is disabled
196  // ========================================================================
197  private:
198  // ========================================================================
199  RhoCandidate *m_particle;
200  DecayChain *m_decaychain;
201  FitParams *m_fitparams;
202  FitStatus m_status;
203  // double m_chiSquare ;
204  int m_niter;
205  int m_errCode;
206  // ========================================================================
207  // FIXME not being used???
208  // typedef std::map<RhoCandidate*, Gaudi::Math::ParticleParams> Map ;
209  // mutable Map m_map ;
210  // ========================================================================
211  protected:
213  RecoTrackStateProvider *m_extrapolator; // track extrapolator
214  // ========================================================================
215  ClassDef(Fitter, 1)
216 };
217 // ==========================================================================
218 } // namespace DecayTreeFitter
219 // ============================================================================
220 // The END
221 // ============================================================================
222 #endif
RecoTrackStateProvider * m_extrapolator
track extrapolator (if needed)
Definition: Fitter.h:213
FitStatus status() const
Status of fit.
Definition: Fitter.h:108
bool updateTree(RhoCandidate *cand) const
update a particlular candidate in the tree
const FitParams * fitparams() const
Definition: Fitter.h:170
std::string print() const
Print the result of the fit.
DecayChain * GetDecayChainDirty()
Definition: Fitter.h:147
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:101
int nIter() const
Number of iterations used by vertex fit.
Definition: Fitter.h:110
FitParams * fitparams()
Definition: Fitter.h:168
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:90
int errCode()
error code
Definition: Fitter.h:137
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:169
double fChiSquare
Definition: RhoFitterBase.h:72
DecayChain * decaychain()
Definition: Fitter.h:167
std::string name(RhoCandidate *cand) const
Name of a particle in the decay tree.
RecoTrackStateProvider * extrapolator()
get the extrapolator
Definition: Fitter.h:153
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:83
RhoCandidate * fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const
RhoCandidate * particle() const
The top level particle that is fitted.
Definition: Fitter.h:96
double chiSquare() const
Total chisquare.
Definition: Fitter.h:104
RhoCandidate * GetFit() const
Definition: RhoCandidate.h:287
void SetToleranceZ(double z)
Definition: Fitter.h:140