FairRoot/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 {
45  class DecayChain ;
46  class FitParams ;
47  class ParticleBase ;
48  class ChiSquare ;
49 
50  // ==========================================================================
55  class Fitter : public RhoFitterBase
56  {
57  public:
58  // ========================================================================
59  enum FitStatus {
60  UnFitted = -1 ,
61  Success = 0 ,
65  } ;
66  // ========================================================================
67  public:
68  // ========================================================================
70  Fitter ( RhoCandidate* bc ,
72  int verbosity = 0) ;
74  Fitter ( RhoCandidate* bc ,
75  const RhoVector3Err& pv ,
77  int verbosity = 0) ;
79  Fitter ( RhoCandidate* bc ,
80  const RhoLorentzVectorErr& lv ,
82  int verbosity = 0) ;
84  Fitter ( RhoCandidate* bc ,
85  const RhoLorentzVectorErr& lv ,
86  const RhoVector3Err& pv ,
88  int verbosity = 0) ;
90  virtual ~Fitter() ; // destructor
91  // ========================================================================
92  public:
93  // ========================================================================
95  void setMassConstraint ( RhoCandidate* cand , bool add = true ) ;
97  void setMassConstraint ( RhoCandidate* cand , double mass ) ;
99  //TODO void setMassConstraint ( RhoCandidateID& pid , bool add = true ) ;
101  //TODO void setMassConstraint ( RhoCandidateID& pid , double mass ) ;
103  Bool_t Fit ( int maxNumberOfIterations = 10 , double deltaChisquareConverged = 0.01 )
104  {
105  fit(maxNumberOfIterations,deltaChisquareConverged);
106  bool check = updateTree(m_particle);
107  check = check && (m_status==0);
108  return check;
109  };
110  Bool_t FitAll ( int maxit = 10 , double dchiq = 0.01 ) { return Fit(maxit,dchiq); };
112  std::string print() const ;
114  std::ostream& fillStream ( std::ostream& s ) const ;
116  RhoCandidate* particle() const { return m_particle ; }
121  RhoCandidate* fitParams ( RhoCandidate* p = 0 ) const {return p->GetFit();};
123  //double chiSquare () const { return m_chiSquare ; }
124  double chiSquare () const { return fChiSquare ; }
126  int nDof () const ;
128  FitStatus status () const { return m_status ; }
130  int nIter () const { return m_niter ; }
132  ChiSquare chiSquare( RhoCandidate* p ) const ;
142  // LHCb::DecayTree getFittedTree() const ;
147  // RhoCandidate getFitted() const ;
152  // RhoCandidate getFitted(RhoCandidate* cand) const ;
154  bool updateCand ( RhoCandidate* cand ) const ;
156  bool updateTree ( RhoCandidate* cand ) const ;
158  int errCode () { return m_errCode ; }
160  void setVerbose(int i) ;
162 
163 
164  //FIXME ######@^$E&$#%#^!#@&*(####### REMOVE!
166 
167 
168  // ========================================================================
169  public:
170  // ========================================================================
175  // ========================================================================
176  protected:
177  // ========================================================================
178  // expert interface. not yet for real consumption
179  // Gaudi::Math::ParticleParams
180  // fitParams(const ParticleBase& pb) const ;
182  std::string name ( RhoCandidate* cand) const ;
183  // ========================================================================
185  decayLengthSum(const ParticleBase&,const ParticleBase&) const ;
186  // ========================================================================
188  FitParams* fitparams () { return m_fitparams ; }
189  const DecayChain* decaychain () const { return m_decaychain ; }
190  const FitParams* fitparams () const { return m_fitparams ; }
191  // ========================================================================
192  double globalChiSquare() const ;
193  // ========================================================================
194  // must be moved to derived class or so ...
195  double add ( RhoCandidate* cand ) ;
196  double remove ( RhoCandidate* cand ) ;
197  void updateIndex() ;
198  // ========================================================================
200  void fit ( int maxNumberOfIterations = 10 , double deltaChisquareConverged = 0.01 ) ;
202  void fitOneStep() ;
203  // ========================================================================
204 
206  RhoCandidate* headoftree ) const ;
207  void updateCand ( const ParticleBase& pb ,
208  RhoCandidate* cand ) const ;
209  // ========================================================================
210  private:
211  // ========================================================================
213  Fitter () ; // default constructor is disabled
215  Fitter ( const Fitter& ) ; // copy constructor is disabled
217  Fitter& operator=( const Fitter& ) ; // assignement operator is disabled
218  // ========================================================================
219  private:
220  // ========================================================================
225  //double m_chiSquare ;
226  int m_niter ;
227  int m_errCode ;
228  // ========================================================================
229  //FIXME not being used???
230  // typedef std::map<RhoCandidate*, Gaudi::Math::ParticleParams> Map ;
231  // mutable Map m_map ;
232  // ========================================================================
233  protected:
235  RecoTrackStateProvider* m_extrapolator ; // track extrapolator
236  // ========================================================================
237  ClassDef ( Fitter,1 )
238  } ;
239  // ==========================================================================
240 }
241 // ============================================================================
242 // The END
243 // ============================================================================
244 #endif
bool updateTree(RhoCandidate *cand) const
update a particlular candidate in the tree
Definition: Fitter.cxx:894
RecoTrackStateProvider * m_extrapolator
track extrapolator (if needed)
Definition: Fitter.h:235
const FitParams * fitparams() const
Definition: Fitter.h:190
RhoCandidate * fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const
Int_t i
Definition: run_full.C:25
DecayChain * GetDecayChainDirty()
Definition: Fitter.h:165
RhoCandidate * particle() const
The top level particle that is fitted.
Definition: Fitter.h:116
TLorentzVector s
Definition: Pnd2DStar.C:50
void fit(int maxNumberOfIterations=10, double deltaChisquareConverged=0.01)
Fit the decay tree.
Definition: Fitter.cxx:171
Fitter & operator=(const Fitter &)
assignement operator is disabled
int nIter() const
Number of iterations used by vertex fit.
Definition: Fitter.h:130
FitParams * m_fitparams
Definition: Fitter.h:223
const DecayChain * decaychain() const
Definition: Fitter.h:189
std::string name(RhoCandidate *cand) const
Name of a particle in the decay tree.
Definition: Fitter.cxx:539
Double_t p
Definition: anasim.C:58
FitParams * fitparams()
Definition: Fitter.h:188
double add(RhoCandidate *cand)
Definition: Fitter.cxx:324
FitStatus m_status
Definition: Fitter.h:224
FitStatus status() const
Status of fit.
Definition: Fitter.h:128
DecayChain * m_decaychain
Definition: Fitter.h:222
Bool_t FitAll(int maxit=10, double dchiq=0.01)
Definition: Fitter.h:110
int errCode()
error code
Definition: Fitter.h:158
double globalChiSquare() const
Definition: Fitter.cxx:427
Double_t z
void setMassConstraint(RhoCandidate *cand, bool add=true)
Add or remove a mass constraint.
Definition: Fitter.cxx:394
void setStateProvider(RecoTrackStateProvider *extrapolator)
set the track extrapolator
Definition: Fitter.cxx:154
bool updateCand(RhoCandidate *cand) const
update a particlular candidate in the tree
Definition: Fitter.cxx:875
std::ostream & fillStream(std::ostream &s) const
Print the result of the fit.
Definition: Fitter.cxx:908
void setVerbose(int i)
set the verbosity level (for debugging only)
Definition: Fitter.cxx:158
void fitOneStep()
Fit just one step.
Definition: Fitter.cxx:294
int nDof() const
Total number of DOFs.
Definition: Fitter.cxx:319
Fitter()
default constructor is disabled
double fChiSquare
Definition: RhoFitterBase.h:74
DecayChain * decaychain()
Definition: Fitter.h:187
RhoDoubleErr decayLengthSum(RhoCandidate *, RhoCandidate *) const
Definition: Fitter.cxx:514
double chiSquare() const
Total chisquare.
Definition: Fitter.h:124
virtual ~Fitter()
destructor
Definition: Fitter.cxx:160
RecoTrackStateProvider * extrapolator()
get the extrapolator
Definition: Fitter.h:172
RhoCandidate * fitParams(RhoCandidate *p=0) const
Definition: Fitter.h:121
Bool_t Fit(int maxNumberOfIterations=10, double deltaChisquareConverged=0.01)
Add or remove a mass constraintfor a certain ParticleID.
Definition: Fitter.h:103
RhoCandidate * m_particle
Definition: Fitter.h:221
std::string print() const
Print the result of the fit.
Definition: Fitter.cxx:307
void SetToleranceZ(double z)
Definition: Fitter.h:161