]>
Commit | Line | Data |
---|---|---|
fabf4d8e | 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 */ | |
5 | ||
6 | ///////////////////////////////////////////////////////////// | |
7 | // | |
8 | // AliHFMassFitter for the fit of invariant mass distribution | |
9 | // of charmed mesons | |
10 | // | |
11 | // Author: C.Bianchin, chiara.bianchin@pd.infn.it | |
12 | ///////////////////////////////////////////////////////////// | |
13 | ||
14 | #include <TNamed.h> | |
fabf4d8e | 15 | #include <TString.h> |
16 | ||
dc262918 | 17 | class TF1; |
18 | class TNtuple; | |
19 | class TFile; | |
20 | class TList; | |
21 | class TH1F; | |
a12d80b8 | 22 | class TVirtualPad; |
fabf4d8e | 23 | |
24 | class AliHFMassFitter : public TNamed { | |
25 | ||
26 | public: | |
27 | AliHFMassFitter(); | |
dc262918 | 28 | AliHFMassFitter(const TH1F* histoToFit, Double_t minvalue, Double_t maxvalue, Int_t rebin=1,Int_t fittypeb=0,Int_t fittypes=0); |
2f328d65 | 29 | virtual ~AliHFMassFitter(); |
fabf4d8e | 30 | |
74179930 | 31 | AliHFMassFitter(const AliHFMassFitter &mfit); |
32 | AliHFMassFitter& operator=(const AliHFMassFitter &mfit); | |
fabf4d8e | 33 | |
34 | //setters | |
dc262918 | 35 | void SetHisto(const TH1F *histoToFit); |
d22f0682 | 36 | void SetRangeFit(Double_t minvalue, Double_t maxvalue){fminMass=minvalue; fmaxMass=maxvalue; CheckRangeFit();} |
24e73105 | 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");} | |
2f328d65 | 39 | void SetBinN(Int_t newbinN){fNbin=newbinN;} |
40 | void SetType(Int_t fittypeb, Int_t fittypes); | |
fabf4d8e | 41 | void SetReflectionSigmaFactor(Int_t constant) {ffactor=constant;} |
6321ee46 | 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 | |
3c0e7d59 | 45 | void SetFixParam(Bool_t *fixpar){fFixPar=fixpar;} |
4d7b8e51 | 46 | void SetDefaultFixParam(); |
3c0e7d59 | 47 | Bool_t SetFixThisParam(Int_t thispar,Bool_t fixpar); |
24e73105 | 48 | void SetFixGaussianMean(Double_t mean=1.865,Bool_t fixpar=kTRUE){SetInitialGaussianMean(mean); SetFixThisParam(fNFinalPars-2,fixpar);} |
5a8a84f8 | 49 | void SetFixGaussianSigma(Double_t sigma=0.012, Bool_t fixpar=kTRUE){SetInitialGaussianMean(sigma); SetFixThisParam(fNFinalPars-1,fixpar);} |
fabf4d8e | 50 | |
51 | //getters | |
6321ee46 | 52 | TH1F* GetHistoClone() const; //return the histogram |
a60f573d | 53 | void GetRangeFit(Double_t &minvalue, Double_t &maxvalue) const {minvalue=fminMass; maxvalue=fmaxMass;} |
2f328d65 | 54 | Double_t GetMinRangeFit()const {return fminMass;} |
55 | Double_t GetMaxRangeFit()const {return fmaxMass;} | |
56 | Int_t GetBinN() const {return fNbin;} | |
dc262918 | 57 | void GetFitPars(Float_t* pars) const; |
4d7b8e51 | 58 | Int_t GetNFinalPars() const {return fNFinalPars;} |
56cbeefb | 59 | void GetTypeOfFit(Bool_t &background, Int_t &typeb) const {background = fWithBkg; typeb = ftypeOfFit4Bkg;} |
fabf4d8e | 60 | Int_t GetReflectionSigmaFactor() const {return ffactor;} |
0566386c | 61 | Double_t GetMean() const {return fMass;} |
62 | Double_t GetSigma()const {return fSigmaSgn;} | |
34c79b83 | 63 | Double_t GetChiSquare() const; |
b7d4bc49 | 64 | Double_t GetReducedChiSquare() const; |
dc262918 | 65 | void GetSideBandsBounds(Int_t& lb, Int_t& hb) const; |
3c0e7d59 | 66 | Bool_t* GetFixParam()const {return fFixPar;} |
67 | Bool_t GetFixThisParam(Int_t thispar)const; | |
d22f0682 | 68 | TVirtualPad* GetPad(Double_t nsigma=2,Int_t writeFitInfo=1)const; |
fabf4d8e | 69 | |
ad73ca8f | 70 | void PrintParTitles() const; |
71 | ||
6321ee46 | 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 | |
dc262918 | 76 | void WriteHisto(TString path="./") const; // write the histogram |
6321ee46 | 77 | void WriteNtuple(TString path="./") const; // write the TNtuple |
d22f0682 | 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; | |
a12d80b8 | 80 | void DrawFit(Double_t nsigma=2) const; |
56cbeefb | 81 | void Reset(); |
82 | ||
dc262918 | 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 | |
6321ee46 | 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 | |
fabf4d8e | 91 | |
dc262918 | 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); | |
34c79b83 | 95 | Bool_t MassFitter(Bool_t draw=kTRUE); |
5a8a84f8 | 96 | Bool_t RefitWithBkgOnly(Bool_t draw=kTRUE); |
d22f0682 | 97 | void RebinMass(Int_t bingroup=1); |
fabf4d8e | 98 | |
99 | ||
100 | private: | |
101 | ||
d22f0682 | 102 | void PlotFit(TVirtualPad* pd,Double_t nsigma=2,Int_t writeFitInfo=1)const; |
a12d80b8 | 103 | |
2f328d65 | 104 | void ComputeParSize(); |
d22f0682 | 105 | void ComputeNFinalPars(); |
b7d4bc49 | 106 | Bool_t SideBandsBounds(); |
d22f0682 | 107 | Bool_t CheckRangeFit(); |
16856d6e | 108 | void AddFunctionsToHisto(); |
2f328d65 | 109 | |
d22f0682 | 110 | TH1F* fhistoInvMass; // histogram to fit |
111 | Double_t fminMass; // lower mass limit | |
112 | Double_t fmaxMass; // upper mass limit | |
24e73105 | 113 | Int_t fminBinMass; |
114 | Int_t fmaxBinMass; | |
d22f0682 | 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 | |
4d7b8e51 | 127 | Bool_t* fFixPar; //[fNFinalPars] for each par if kTRUE it is fixed in fit |
d22f0682 | 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 | |
24e73105 | 132 | ClassDef(AliHFMassFitter,4); // class for invariant mass fit |
fabf4d8e | 133 | }; |
134 | ||
135 | #endif | |
136 | ||
74179930 | 137 |