AliPhysics  4a7363b (4a7363b)
AliHFInvMassFitter.h
Go to the documentation of this file.
1 #ifndef ALIHFINVMASSFITTER_H
2 #define ALIHFINVMASSFITTER_H
3 
4 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice */
6 
7 
16 
17 
18 #include <TNamed.h>
19 #include "AliLog.h"
20 
21 class TF1;
22 class TH1F;
23 
24 class AliHFInvMassFitter : public TNamed {
25  public:
26 
27  enum ETypeOfBkg{ kExpo=0, kLin=1, kPol2=2, kNoBk=3, kPow=4, kPowEx=5};
30  AliHFInvMassFitter(const TH1F* histoToFit, Double_t minvalue, Double_t maxvalue, Int_t fittypeb=kExpo, Int_t fittypes=kGaus);
32 
33  void SetHistogramFit(const TH1F* histoToFit){
34  if (fHistoInvMass) delete fHistoInvMass;
35  fHistoInvMass=(TH1F*)histoToFit->Clone("fHistoInvMass");
36  fHistoInvMass->SetDirectory(0);
37  }
38  void SetRangeFit(Double_t minvalue, Double_t maxvalue){
39  fMinMass=minvalue; fMaxMass=maxvalue;
40  }
41  void SetFitFunctions(Int_t fittypeb, Int_t fittypes){
42  fTypeOfFit4Bkg=fittypeb; fTypeOfFit4Sgn=fittypes;
44  }
45 
49  void SetFitOption(TString opt){fFitOption=opt.Data();};
53  if(fTypeOfFit4Bkg!=6) AliFatal("fTypeOfFit4Bkg should be set to 6 to use higher order polynomials\n");
54  fPolDegreeBkg=deg;
56  }
64  fFixedMean=kTRUE;
65  }
68  fFixedSigma=kTRUE;
69  }
71  if(fTypeOfFit4Sgn!=k2Gaus) AliFatal("fTypeOfFit4Sgn should be set to k2Gaus to fix ratio between gaussians\n");
73  fFixedSigma2Gaus=kTRUE;
74  }
76  if(fTypeOfFit4Sgn!=k2Gaus && fTypeOfFit4Sgn!=k2GausSigmaRatioPar) AliFatal("fTypeOfFit4Sgn should be set to k2Gaus to fix relative integral of two gaussians\n");
77  SetInitialFrac2Gaus(frac);
78  fFixedFrac2Gaus=kTRUE;
79  }
81  if(fTypeOfFit4Sgn!=k2GausSigmaRatioPar) AliFatal("fTypeOfFit4Sgn should be set to k2GausSigmaRatioPar to fix ratio between gaussian sigmas\n");
82  SetInitialRatio2GausSigma(sigmafrac);
84  }
86  fFixedRawYield=yield;
87  }
90  }
91  TH1F* SetTemplateReflections(const TH1 *h, TString opt,Double_t minRange,Double_t maxRange);
93  void SetFixReflOverS(Double_t rovers){
94  SetInitialReflOverS(rovers);
95  fFixRflOverSig=kTRUE;
96  }
98 
100  fSecondPeak=kTRUE; fSecMass=mass; fSecWidth=width;
101  fFixSecMass=fixm; fFixSecWidth=fixw;
102  }
103  Double_t GetRawYield()const {return fRawYield;}
105  Double_t GetMean() const {return fMass;}
107  Double_t GetSigma()const {return fSigmaSgn;}
110  if(fRflFunc) return fRflFunc->GetParameter(0);
111  else return 0;
112  }
114  if(fRflFunc) return fRflFunc->GetParError(0);
115  else return 0;
116  }
119  TF1* GetBkgPlusReflFunc(){return fBkRFunc;}
120  TF1* GetSignalFunc(){return fSigFunc;}
121  TF1* GetMassFunc(){return fTotFunc;}
123  if(fTotFunc) return fTotFunc->GetChisquare();
124  else return -1;
125  }
127  if(fTotFunc) return fTotFunc->GetChisquare()/fTotFunc->GetNDF();
128  else return -1;
129  }
131  if(fTotFunc) return fTotFunc->GetProb();
132  else return -1;
133  }
134  TH1F* GetHistoClone() const{
135  TH1F* hout=(TH1F*)fHistoInvMass->Clone(Form("%scloned",fHistoInvMass->GetName()));
136  return hout;
137  }
138  Double_t GetRawYieldBinCounting(Double_t& errRyBC, Double_t nSigma=3., Int_t option=0, Int_t pdgCode=0) const;
140  Int_t MassFitter(Bool_t draw=kTRUE);
147  virtual void Signal(Double_t nOfSigma,Double_t &signal,Double_t &errsignal) const;
148  virtual void Signal(Double_t min,Double_t max,Double_t &signal,Double_t &errsignal) const;
149  void Background(Double_t nOfSigma, Double_t &background,Double_t &errbackground) const;
150  void Background(Double_t min, Double_t max, Double_t &background,Double_t &errbackground) const;
151  void DrawHere(TVirtualPad* c, Double_t nsigma=3,Int_t writeFitInfo=1);
152  void Significance(Double_t nOfSigma, Double_t &significance,Double_t &errsignificance) const;
153  void Significance(Double_t min, Double_t max, Double_t &significance,Double_t &errsignificance) const;
154  TH1F* GetResidualsAndPulls(TH1 *hPulls=0x0,TH1 *hResidualTrend=0x0,TH1 *hPullsTrend=0x0,Double_t minrange=0,Double_t maxrange=-1);
155  void PrintFunctions();
156 
157  private:
158  AliHFInvMassFitter(const AliHFInvMassFitter &source);
160 
161  void SetNumberOfParams();
163  TF1* CreateBackgroundFitFunction(TString fname, Double_t integral);
164  TF1* CreateSignalFitFunction(TString fname, Double_t integral);
165  TF1* CreateSecondPeakFunction(TString fname, Double_t integral);
166  TF1* CreateReflectionFunction(TString fname);
168  TF1* CreateTotalFitFunction(TString fname);
169  Bool_t PrepareHighPolFit(TF1 *fback);
171 
172  void DrawFit();
173 
202  TF1* fSigFunc;
203  TF1* fBkgFuncSb;
204  TF1* fBkgFunc;
213  TF1* fRflFunc;
214  TF1* fBkRFunc;
221  TF1* fSecFunc;
222  TF1* fTotFunc;
223 
225  ClassDef(AliHFInvMassFitter,5);
226 };
228 
229 #endif
Int_t fTypeOfFit4Sgn
pdg value of particle mass
Double_t GetMeanUncertainty() const
Double_t fSigmaSgnErr
signal gaussian sigma
Double_t GetReflOverSig() const
Bool_t fFixSecWidth
flag to fix the position of the 2nd peak
Double_t GetChiSquare() const
Double_t GetFitProbability() const
Double_t fRawYieldHelp
switch for smoothing of reflection template
double Double_t
Definition: External.C:58
void SetFixReflOverS(Double_t rovers)
Double_t fRawYield
L, LW or Chi2.
void DrawHere(TVirtualPad *c, Double_t nsigma=3, Int_t writeFitInfo=1)
void IncludeSecondGausPeak(Double_t mass, Bool_t fixm, Double_t width, Bool_t fixw)
TF1 * CreateReflectionFunction(TString fname)
Int_t fCurPolDegreeBkg
degree of polynomial expansion for back fit (option 6 for back)
Bool_t PrepareHighPolFit(TF1 *fback)
Bool_t fOnlySideBands
fit parameters in background fit function
virtual void Signal(Double_t nOfSigma, Double_t &signal, Double_t &errsignal) const
Bool_t fFixedRatio2GausSigma
initialization for ratio between two gaussian sigmas in case of k2GausSigmaRatioPar ...
Double_t FitFunction4SecPeak(Double_t *x, Double_t *par)
Double_t fMass
signal fit func
TF1 * CreateTotalFitFunction(TString fname)
Double_t mass
Double_t fRawYieldErr
signal gaussian integral
Int_t MassFitter(Bool_t draw=kTRUE)
Int_t fNParsBkg
fit parameters in signal fit function
AliHFInvMassFitter class for the fit of invariant mass distribution of charm hadrons.
void SetFixSecondGaussianSigma(Double_t sigma)
void SetFitOption(TString opt)
Int_t fNParsRfl
flag use/not use reflections
TCanvas * c
Definition: TestFitELoss.C:172
TF1 * CreateSecondPeakFunction(TString fname, Double_t integral)
Bool_t fFixedFrac2Gaus
initialization for fraction of 2nd gaussian in case of k2Gaus or k2GausSigmaRatioPar ...
TF1 * fTotFunc
fit function for second peak
Double_t fFixedRawYield
switch for fix Sigma of second gaussian in case of k2Gaus
void SetFixFrac2Gaus(Double_t frac)
void SetFitFunctions(Int_t fittypeb, Int_t fittypes)
Double_t GetSigma() const
Double_t FitFunction4Bkg(Double_t *x, Double_t *par)
Double_t fSigmaSgn
unc on signal gaussian mean value
void SetPolDegreeForBackgroundFit(Int_t deg)
Double_t fSecMass
fit parameters in 2nd peak fit function
Double_t GetParticlePdgMass()
void SetFixGaussianSigma(Double_t sigma)
Bool_t fFixSecMass
width of the 2nd peak
TF1 * fSecFunc
flag to fix the width of the 2nd peak
Double_t * sigma
void SetFixGaussianMean(Double_t mean)
TH1F * GetResidualsAndPulls(TH1 *hPulls=0x0, TH1 *hResidualTrend=0x0, TH1 *hPullsTrend=0x0, Double_t minrange=0, Double_t maxrange=-1)
int Int_t
Definition: External.C:63
Bool_t fFixedSigma2Gaus
switch for fix Sigma of gaussian
Double_t fSecWidth
position of the 2nd peak
Double_t GetMean() const
TString fFitOption
number of sigmas to veto the signal peak
TF1 * fBkRFunc
fit function for reflections
Double_t fFrac2Gaus
initialization for wa yield
void SetInitialSecondGaussianSigma(Double_t sigma)
Int_t fNParsSec
switch off/on second peak (for D+->KKpi in Ds)
TF1 * CreateSignalFitFunction(TString fname, Double_t integral)
void SetFixRatio2GausSigma(Double_t sigmafrac)
Bool_t fFixedMean
signal second gaussian sigma in case of k2Gaus
Double_t GetReducedChiSquare() const
Double_t fMassParticle
help variable
void SetFixSignalYield(Double_t yield)
Double_t FitFunction4Refl(Double_t *x, Double_t *par)
Double_t GetRawYieldBinCounting(Double_t &errRyBC, Double_t nSigma=3., Int_t option=0, Int_t pdgCode=0) const
void SetParticlePdgMass(Double_t mass)
void SetInitialRatio2GausSigma(Double_t fracsigma)
TH1F * SetTemplateReflections(const TH1 *h, TString opt, Double_t minRange, Double_t maxRange)
Double_t nsigma
void SetHistogramFit(const TH1F *histoToFit)
Int_t fTypeOfFit4Bkg
upper mass limit
TH1F * fHistoTemplRfl
switch for fix refl/signal
TF1 * fBkgFunc
background fit function (1st step, side bands only)
Double_t fMassErr
signal gaussian mean value
Double_t fRflOverSig
fit parameters in reflection fit function
Double_t fMinMass
histogram to fit
Double_t GetReflOverSigUncertainty() const
Bool_t fFixRflOverSig
reflection/signal
Double_t FitFunction4Mass(Double_t *x, Double_t *par)
Double_t GetSigmaUncertainty() const
void Significance(Double_t nOfSigma, Double_t &significance, Double_t &errsignificance) const
Double_t BackFitFuncPolHelper(Double_t *x, Double_t *par)
Bool_t draw[nPtBins]
void SetInitialReflOverS(Double_t rovers)
Double_t fMaxMass
lower mass limit
TF1 * CreateBackgroundFitFunction(TString fname, Double_t integral)
TF1 * fRflFunc
internal variable for fit with reflections
Double_t GetRawYieldError() const
Double_t fNSigma4SideBands
kTRUE = only side bands considered
void Background(Double_t nOfSigma, Double_t &background, Double_t &errbackground) const
void SetInitialGaussianSigma(Double_t sigma)
void SetInitialGaussianMean(Double_t mean)
Double_t minMass
Double_t fRatio2GausSigma
switch for fixed fraction of 2nd gaussian in case of k2Gaus or k2GausSigmaRatioPar ...
void SetRangeFit(Double_t minvalue, Double_t maxvalue)
Double_t FitFunction4Sgn(Double_t *x, Double_t *par)
Int_t fPolDegreeBkg
background fit func
void SetSmoothReflectionTemplate(Bool_t opt)
void SetUseLikelihoodWithWeightsFit()
Double_t fSigmaSgn2Gaus
unc on signal gaussian sigma
void SetInitialFrac2Gaus(Double_t frac)
Double_t maxMass
bool Bool_t
Definition: External.C:53
TF1 * fBkgFuncRefit
background fit function (1st step, extended in peak region)
Double_t CheckForSignal(Double_t mean, Double_t sigma)
TF1 * fSigFunc
err on signal gaussian integral
TF1 * fBkgFuncSb
Signal fit function.
void SetNSigma4SideBands(Double_t ns=4.)
Bool_t fSecondPeak
fit function for reflections
AliHFInvMassFitter & operator=(const AliHFInvMassFitter &source)
Bool_t fSmoothRfl
histogram with reflection template
TH1F * GetHistoClone() const
TF1 * CreateBackgroundPlusReflectionFunction(TString fname)
Definition: External.C:196
Double_t FitFunction4BkgAndRefl(Double_t *x, Double_t *par)
Int_t fNParsSig
switch for fixed ratio between two gaussian sigmas in case of k2GausSigmaRatioPar ...
Double_t GetRawYield() const
Bool_t fReflections
background fit function (2nd step)
Bool_t fFixedSigma
switch for fix mean of gaussian