PandaRoot
Fitter.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 // ******************************************************
14 // DecayTreeFitter Package
15 // We thank the original author Wouter Hulsbergen
16 // (BaBar, LHCb) for providing the sources.
17 // http://arxiv.org/abs/physics/0503191v1 (2005)
18 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
19 // Adjustment for fully neutral reactions: Jean Noel (2023)
20 // *********************************************************************************
21 // $Id: Fitter.h,v 1.7 2010-05-29 13:39:56 ibelyaev Exp $
22 // =================================================================================
23 #ifndef DECAYTREEFITTER_FITTER_H
24 #define DECAYTREEFITTER_FITTER_H 1
25 // =================================================================================
26 // Include files
27 // =================================================================================
28 // STD & STL
29 // =================================================================================
30 #include <vector>
31 // =================================================================================
32 // GaudiKernel
33 // =================================================================================
34 //#include "GaudiKernel/SmartIF.h"
35 // =================================================================================
36 // Track interfaces
37 // =================================================================================
38 //#include "TrackInterfaces/ITrackStateProvider.h"
39 // =================================================================================
40 // LHCbMath
41 // =================================================================================
42 //#include "LHCbMath/ValueWithError.h"
43 //#include "LHCbMath/ParticleParams.h"
44 // =================================================================================
45 // DaVinciTypes
46 // =================================================================================
47 //#include "Kernel/DecayTree.h"
48 // =================================================================================
49 #include "RecoTrackStateProvider.h"
50 #include "Rtypes.h"
51 
52 #include "RhoDoubleErr.h"
53 #include "RhoCandidate.h"
54 #include "RhoFitterBase.h"
55 
56 namespace DecayTreeFitter {
57 class DecayChain;
58 class FitParams;
59 class ParticleBase;
60 class ChiSquare;
61 
62 // ==========================================================================
67 class Fitter : public RhoFitterBase {
68  public:
69  // ========================================================================
71  // ========================================================================
72  public:
73  // ========================================================================
75  Fitter(RhoCandidate *bc, RecoTrackStateProvider *extrapolator, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
77  Fitter(RhoCandidate *bc, const RhoVector3Err &pv, RecoTrackStateProvider *extrapolator = nullptr, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
79  Fitter(RhoCandidate *bc, const RhoLorentzVectorErr &lv, RecoTrackStateProvider *extrapolator, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
81  Fitter(RhoCandidate *bc, const RhoLorentzVectorErr &lv, const RhoVector3Err &pv, RecoTrackStateProvider *extrapolator = nullptr, bool perform_vertex_fit = true, int verbosity = 0, bool freeParamZ = false);
83  virtual ~Fitter(); // destructor
84  // ========================================================================
85  public:
86  // ========================================================================
88  void setMassConstraint(RhoCandidate *cand, bool add = true);
90  void setMassConstraint(RhoCandidate *cand, double mass);
92  // TODO void setMassConstraint ( RhoCandidateID& pid , bool add = true ) ;
94  // TODO void setMassConstraint ( RhoCandidateID& pid , double mass ) ;
96  Bool_t Fit(int maxNumberOfIterations = 10, double deltaChisquareConverged = 0.01)
97  {
98  fit(maxNumberOfIterations, deltaChisquareConverged);
99  bool check = updateTree(m_particle);
100  check = check && (m_status == 0);
101  return check;
102  };
103  Bool_t FitAll(int maxit = 10, double dchiq = 0.01) { return Fit(maxit, dchiq); };
105  std::string print() const;
107  std::ostream &fillStream(std::ostream &s) const;
109  RhoCandidate *particle() const { return m_particle; }
114  RhoCandidate *fitParams(RhoCandidate *p = 0) const { return p->GetFit(); };
116  // double chiSquare () const { return m_chiSquare ; }
117  double chiSquare() const { return fChiSquare; }
119  int nDof() const;
121  FitStatus status() const { return m_status; }
123  int nIter() const { return m_niter; }
125  ChiSquare chiSquare(RhoCandidate *p) const;
134  // LHCb::DecayTree getFittedTree() const ;
139  // RhoCandidate getFitted() const ;
144  // RhoCandidate getFitted(RhoCandidate* cand) const ;
146  bool updateCand(RhoCandidate *cand) const;
148  bool updateTree(RhoCandidate *cand) const;
150  int errCode() { return m_errCode; }
152  void setVerbose(int i);
153  void SetToleranceZ(double z)
154  {
155  if (m_extrapolator)
157  };
158 
159  // FIXME ######@^$E&$#%#^!#@&*(####### REMOVE!
160  DecayChain *GetDecayChainDirty() { return m_decaychain; }
161 
162  // ========================================================================
163  public:
164  // ========================================================================
168  void setStateProvider(RecoTrackStateProvider *extrapolator);
169  // ========================================================================
170  protected:
171  // ========================================================================
172  // expert interface. not yet for real consumption
173  // Gaudi::Math::ParticleParams
174  // fitParams(const ParticleBase& pb) const ;
176  std::string name(RhoCandidate *cand) const;
177  // ========================================================================
178  RhoDoubleErr decayLengthSum(const ParticleBase &, const ParticleBase &) const;
179  // ========================================================================
180  DecayChain *decaychain() { return m_decaychain; }
181  FitParams *fitparams() { return m_fitparams; }
182  const DecayChain *decaychain() const { return m_decaychain; }
183  const FitParams *fitparams() const { return m_fitparams; }
184  // ========================================================================
185  double globalChiSquare() const;
186  // ========================================================================
187  // must be moved to derived class or so ...
188  double add(RhoCandidate *cand);
189  double remove(RhoCandidate *cand);
190  void updateIndex();
191  // ========================================================================
193  void fit(int maxNumberOfIterations = 10, double deltaChisquareConverged = 0.01);
195  void fitOneStep();
196  // ========================================================================
197 
198  RhoCandidate *fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const;
199  void updateCand(const ParticleBase &pb, RhoCandidate *cand) const;
200  // ========================================================================
201  private:
202  // ========================================================================
204  Fitter(); // default constructor is disabled
206  Fitter(const Fitter &); // copy constructor is disabled
208  Fitter &operator=(const Fitter &); // assignement operator is disabled
209  // ========================================================================
210  private:
211  // ========================================================================
212  RhoCandidate *m_particle;
213  DecayChain *m_decaychain;
214  FitParams *m_fitparams;
215  FitStatus m_status;
216  // double m_chiSquare ;
217  int m_niter;
218  int m_errCode;
219  // ========================================================================
220  // FIXME not being used???
221  // typedef std::map<RhoCandidate*, Gaudi::Math::ParticleParams> Map ;
222  // mutable Map m_map ;
223  // ========================================================================
224  protected:
226  RecoTrackStateProvider *m_extrapolator; // track extrapolator
227  // ========================================================================
228  ClassDef(Fitter, 1)
229 };
230 // ==========================================================================
231 } // namespace DecayTreeFitter
232 // ============================================================================
233 // The END
234 // ============================================================================
235 #endif
RecoTrackStateProvider * m_extrapolator
track extrapolator (if needed)
Definition: Fitter.h:226
FitStatus status() const
Status of fit.
Definition: Fitter.h:121
bool updateTree(RhoCandidate *cand) const
update a particlular candidate in the tree
const FitParams * fitparams() const
Definition: Fitter.h:183
std::string print() const
Print the result of the fit.
DecayChain * GetDecayChainDirty()
Definition: Fitter.h:160
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:33
RhoCandidate * fitParams(RhoCandidate *p=0) const
Definition: Fitter.h:114
int nIter() const
Number of iterations used by vertex fit.
Definition: Fitter.h:123
FitParams * fitparams()
Definition: Fitter.h:181
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:103
int errCode()
error code
Definition: Fitter.h:150
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:182
double fChiSquare
Definition: RhoFitterBase.h:84
DecayChain * decaychain()
Definition: Fitter.h:180
std::string name(RhoCandidate *cand) const
Name of a particle in the decay tree.
RecoTrackStateProvider * extrapolator()
get the extrapolator
Definition: Fitter.h:166
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:96
RhoCandidate * fittedCand(RhoCandidate *cand, RhoCandidate *headoftree) const
RhoCandidate * particle() const
The top level particle that is fitted.
Definition: Fitter.h:109
double chiSquare() const
Total chisquare.
Definition: Fitter.h:117
RhoCandidate * GetFit() const
Definition: RhoCandidate.h:299
void SetToleranceZ(double z)
Definition: Fitter.h:153