1 #ifndef ALIHFMASSFITTER_H
2 #define ALIHFMASSFITTER_H
3 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 /////////////////////////////////////////////////////////////
8 // AliHFMassFitter for the fit of invariant mass distribution
11 // Author: C.Bianchin, chiara.bianchin@pd.infn.it
12 /////////////////////////////////////////////////////////////
24 class AliHFMassFitter : public TNamed {
28 AliHFMassFitter(const TH1F* histoToFit, Double_t minvalue, Double_t maxvalue, Int_t rebin=1,Int_t fittypeb=0,Int_t fittypes=0);
29 virtual ~AliHFMassFitter();
31 AliHFMassFitter(const AliHFMassFitter &mfit);
32 AliHFMassFitter& operator=(const AliHFMassFitter &mfit);
35 void SetHisto(const TH1F *histoToFit);
36 void SetRangeFit(Double_t minvalue, Double_t maxvalue){fminMass=minvalue; fmaxMass=maxvalue; CheckRangeFit();}
37 void SetMinRangeFit(Double_t minvalue){fminMass=minvalue;printf("CheckRangeFit after SetMaxRangeFit is also set\n");}
38 void SetMaxRangeFit(Double_t maxvalue){fmaxMass=maxvalue;printf("CheckRangeFit after SetMinRangeFit is also set\n");}
39 void SetBinN(Int_t newbinN){fNbin=newbinN;}
40 void SetType(Int_t fittypeb, Int_t fittypes);
41 void SetReflectionSigmaFactor(Int_t constant) {ffactor=constant;}
42 void SetInitialGaussianMean(Double_t mean) {fMass=mean;} // change the default value of the mean
43 void SetInitialGaussianSigma(Double_t sigma) {fSigmaSgn=sigma;} // change the default value of the sigma
44 void SetSideBands(Bool_t onlysidebands=kTRUE) {fSideBands=onlysidebands;} // consider only side bands
45 void SetFixParam(Bool_t *fixpar){fFixPar=fixpar;}
46 void SetDefaultFixParam();
47 Bool_t SetFixThisParam(Int_t thispar,Bool_t fixpar);
48 void SetFixGaussianMean(Double_t mean=1.865,Bool_t fixpar=kTRUE){SetInitialGaussianMean(mean); SetFixThisParam(fNFinalPars-2,fixpar);}
49 void SetFixGaussianSigma(Double_t sigma=0.012, Bool_t fixpar=kTRUE){SetInitialGaussianMean(sigma); SetFixThisParam(fNFinalPars-1,fixpar);}
52 TH1F* GetHistoClone() const; //return the histogram
53 void GetRangeFit(Double_t &minvalue, Double_t &maxvalue) const {minvalue=fminMass; maxvalue=fmaxMass;}
54 Double_t GetMinRangeFit()const {return fminMass;}
55 Double_t GetMaxRangeFit()const {return fmaxMass;}
56 Int_t GetBinN() const {return fNbin;}
57 void GetFitPars(Float_t* pars) const;
58 Int_t GetNFinalPars() const {return fNFinalPars;}
59 void GetTypeOfFit(Bool_t &background, Int_t &typeb) const {background = fWithBkg; typeb = ftypeOfFit4Bkg;}
60 Int_t GetReflectionSigmaFactor() const {return ffactor;}
61 Double_t GetMean() const {return fMass;}
62 Double_t GetSigma()const {return fSigmaSgn;}
63 Double_t GetChiSquare() const;
64 Double_t GetReducedChiSquare() const;
65 void GetSideBandsBounds(Int_t& lb, Int_t& hb) const;
66 Bool_t* GetFixParam()const {return fFixPar;}
67 Bool_t GetFixThisParam(Int_t thispar)const;
68 TVirtualPad* GetPad(Double_t nsigma=2,Int_t writeFitInfo=1)const;
70 void PrintParTitles() const;
72 void InitNtuParam(char *ntuname="ntupar"); // initialize TNtuple to store the parameters
73 void FillNtuParam(); //Fill the TNtuple with the current parameters
74 TNtuple* GetNtuParam() const {return fntuParam;} // return the TNtuple
75 TNtuple* NtuParamOneShot(char *ntuname="ntupar"); // the three functions above all together
76 void WriteHisto(TString path="./") const; // write the histogram
77 void WriteNtuple(TString path="./") const; // write the TNtuple
78 void WriteCanvas(TString userIDstring="",TString path="./",Double_t nsigma=2,Int_t writeFitInfo=1,Bool_t draw=kFALSE) const; //write the canvas in a root file
79 void DrawHere(TVirtualPad* pd,Double_t nsigma=2,Int_t writeFitInfo=1) const;
80 void DrawFit(Double_t nsigma=2) const;
83 void IntS(Float_t *valuewitherror) const; // integral of signal given my the fit with error
84 Double_t IntTot() const {return fhistoInvMass->Integral("width");} // return total integral of the histogram
85 void Signal(Double_t nOfSigma,Double_t &signal,Double_t &errsignal) const; // signal in nsigma with error
86 void Signal(Double_t min,Double_t max,Double_t &signal,Double_t &errsignal) const; // signal in (min, max) with error
87 void Background(Double_t nOfSigma,Double_t &background,Double_t &errbackground) const; // backgournd in nsigma with error
88 void Background(Double_t min,Double_t max,Double_t &background,Double_t &errbackground) const; // backgournd in (min, max) with error
89 void Significance(Double_t nOfSigma,Double_t &significance,Double_t &errsignificance) const; // significance in nsigma with error
90 void Significance(Double_t min,Double_t max,Double_t &significance,Double_t &errsignificance) const; // significance in (min, max) with error
92 Double_t FitFunction4MassDistr (Double_t* x, Double_t* par);
93 Double_t FitFunction4Sgn (Double_t* x, Double_t* par);
94 Double_t FitFunction4Bkg (Double_t* x, Double_t* par);
95 Bool_t MassFitter(Bool_t draw=kTRUE);
96 Bool_t RefitWithBkgOnly(Bool_t draw=kTRUE);
97 void RebinMass(Int_t bingroup=1);
102 void PlotFit(TVirtualPad* pd,Double_t nsigma=2,Int_t writeFitInfo=1)const;
104 void ComputeParSize();
105 void ComputeNFinalPars();
106 Bool_t SideBandsBounds();
107 Bool_t CheckRangeFit();
108 void AddFunctionsToHisto();
110 TH1F* fhistoInvMass; // histogram to fit
111 Double_t fminMass; // lower mass limit
112 Double_t fmaxMass; // upper mass limit
115 Int_t fNbin; // number of bins
116 Int_t fParsSize; // size of fFitPars array
117 Int_t fNFinalPars; // number of parameters of the final function
118 Float_t* fFitPars; //[fParsSize] array of fit parameters
119 Bool_t fWithBkg; // signal+background (kTRUE) or signal only (kFALSE)
120 Int_t ftypeOfFit4Bkg; // 0 = exponential; 1 = linear; 2 = pol2
121 Int_t ftypeOfFit4Sgn; // 0 = gaus; 1 = gaus+gaus broadened
122 Int_t ffactor; // number to multiply to the sigma of the signal to obtain the reflected gaussian
123 TNtuple* fntuParam; // contains fit parameters
124 Double_t fMass; // signal gaussian mean value
125 Double_t fSigmaSgn; // signal gaussian sigma
126 Bool_t fSideBands; // kTRUE = only side bands considered
127 Bool_t* fFixPar; //[fNFinalPars] for each par if kTRUE it is fixed in fit
128 Int_t fSideBandl; // left side band limit (bin number)
129 Int_t fSideBandr; // right side band limit (bin number)
130 Int_t fcounter; // internal counter
131 TList* fContourGraph; // TList of TGraph containing contour plots
132 ClassDef(AliHFMassFitter,4); // class for invariant mass fit