]>
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 | ||
27de2dfb | 6 | /* $Id$ */ |
7 | ||
fabf4d8e | 8 | ///////////////////////////////////////////////////////////// |
9 | // | |
10 | // AliHFMassFitter for the fit of invariant mass distribution | |
11 | // of charmed mesons | |
12 | // | |
13 | // Author: C.Bianchin, chiara.bianchin@pd.infn.it | |
14 | ///////////////////////////////////////////////////////////// | |
15 | ||
16 | #include <TNamed.h> | |
fabf4d8e | 17 | #include <TString.h> |
18 | ||
dc262918 | 19 | class TF1; |
20 | class TNtuple; | |
21 | class TFile; | |
22 | class TList; | |
23 | class TH1F; | |
a12d80b8 | 24 | class TVirtualPad; |
fabf4d8e | 25 | |
26 | class AliHFMassFitter : public TNamed { | |
27 | ||
28 | public: | |
9fdc4a0c | 29 | |
30 | enum ETypeOfBkg{ kExpo=0, kLin=1, kPol2=2, kNoBk=3, kPow=4, kPowEx=5 }; | |
31 | enum ETypeOfSgn{ kGaus=0, k2Gaus=1 }; | |
32 | ||
fabf4d8e | 33 | AliHFMassFitter(); |
9fdc4a0c | 34 | AliHFMassFitter(const TH1F* histoToFit, Double_t minvalue, Double_t maxvalue, Int_t rebin=1, Int_t fittypeb=kExpo, Int_t fittypes=kGaus); |
2f328d65 | 35 | virtual ~AliHFMassFitter(); |
fabf4d8e | 36 | |
74179930 | 37 | AliHFMassFitter(const AliHFMassFitter &mfit); |
38 | AliHFMassFitter& operator=(const AliHFMassFitter &mfit); | |
fabf4d8e | 39 | |
40 | //setters | |
dc262918 | 41 | void SetHisto(const TH1F *histoToFit); |
d22f0682 | 42 | void SetRangeFit(Double_t minvalue, Double_t maxvalue){fminMass=minvalue; fmaxMass=maxvalue; CheckRangeFit();} |
24e73105 | 43 | void SetMinRangeFit(Double_t minvalue){fminMass=minvalue;printf("CheckRangeFit after SetMaxRangeFit is also set\n");} |
44 | void SetMaxRangeFit(Double_t maxvalue){fmaxMass=maxvalue;printf("CheckRangeFit after SetMinRangeFit is also set\n");} | |
2f328d65 | 45 | void SetBinN(Int_t newbinN){fNbin=newbinN;} |
46 | void SetType(Int_t fittypeb, Int_t fittypes); | |
fabf4d8e | 47 | void SetReflectionSigmaFactor(Int_t constant) {ffactor=constant;} |
6321ee46 | 48 | void SetInitialGaussianMean(Double_t mean) {fMass=mean;} // change the default value of the mean |
49 | void SetInitialGaussianSigma(Double_t sigma) {fSigmaSgn=sigma;} // change the default value of the sigma | |
50 | void SetSideBands(Bool_t onlysidebands=kTRUE) {fSideBands=onlysidebands;} // consider only side bands | |
3c0e7d59 | 51 | void SetFixParam(Bool_t *fixpar){fFixPar=fixpar;} |
4d7b8e51 | 52 | void SetDefaultFixParam(); |
3c0e7d59 | 53 | Bool_t SetFixThisParam(Int_t thispar,Bool_t fixpar); |
24e73105 | 54 | void SetFixGaussianMean(Double_t mean=1.865,Bool_t fixpar=kTRUE){SetInitialGaussianMean(mean); SetFixThisParam(fNFinalPars-2,fixpar);} |
5227afe7 | 55 | void SetFixGaussianSigma(Double_t sigma=0.012, Bool_t fixpar=kTRUE){SetInitialGaussianSigma(sigma); SetFixThisParam(fNFinalPars-1,fixpar);} |
fabf4d8e | 56 | |
57 | //getters | |
6321ee46 | 58 | TH1F* GetHistoClone() const; //return the histogram |
a60f573d | 59 | void GetRangeFit(Double_t &minvalue, Double_t &maxvalue) const {minvalue=fminMass; maxvalue=fmaxMass;} |
2f328d65 | 60 | Double_t GetMinRangeFit()const {return fminMass;} |
61 | Double_t GetMaxRangeFit()const {return fmaxMass;} | |
62 | Int_t GetBinN() const {return fNbin;} | |
dc262918 | 63 | void GetFitPars(Float_t* pars) const; |
4d7b8e51 | 64 | Int_t GetNFinalPars() const {return fNFinalPars;} |
56cbeefb | 65 | void GetTypeOfFit(Bool_t &background, Int_t &typeb) const {background = fWithBkg; typeb = ftypeOfFit4Bkg;} |
fabf4d8e | 66 | Int_t GetReflectionSigmaFactor() const {return ffactor;} |
0566386c | 67 | Double_t GetMean() const {return fMass;} |
2cc87a41 | 68 | Double_t GetMeanUncertainty() const {return fMassErr;} |
0566386c | 69 | Double_t GetSigma()const {return fSigmaSgn;} |
2cc87a41 | 70 | Double_t GetSigmaUncertainty()const { return fSigmaSgnErr;} |
e654a7da | 71 | Double_t GetRawYield()const {return fRawYield;} |
72 | Double_t GetRawYieldError()const {return fRawYieldErr;} | |
34c79b83 | 73 | Double_t GetChiSquare() const; |
b7d4bc49 | 74 | Double_t GetReducedChiSquare() const; |
dc262918 | 75 | void GetSideBandsBounds(Int_t& lb, Int_t& hb) const; |
3c0e7d59 | 76 | Bool_t* GetFixParam()const {return fFixPar;} |
77 | Bool_t GetFixThisParam(Int_t thispar)const; | |
1bbb8940 | 78 | TVirtualPad* GetPad(Double_t nsigma=3,Int_t writeFitInfo=1)const; |
fabf4d8e | 79 | |
ad73ca8f | 80 | void PrintParTitles() const; |
81 | ||
9c8a7bcf | 82 | void InitNtuParam(TString ntuname="ntupar"); // initialize TNtuple to store the parameters |
6321ee46 | 83 | void FillNtuParam(); //Fill the TNtuple with the current parameters |
84 | TNtuple* GetNtuParam() const {return fntuParam;} // return the TNtuple | |
9c8a7bcf | 85 | TNtuple* NtuParamOneShot(TString ntuname="ntupar"); // the three functions above all together |
dc262918 | 86 | void WriteHisto(TString path="./") const; // write the histogram |
6321ee46 | 87 | void WriteNtuple(TString path="./") const; // write the TNtuple |
1bbb8940 | 88 | void WriteCanvas(TString userIDstring="",TString path="./",Double_t nsigma=3,Int_t writeFitInfo=1,Bool_t draw=kFALSE) const; //write the canvas in a root file |
89 | void DrawHere(TVirtualPad* pd,Double_t nsigma=3,Int_t writeFitInfo=1) const; | |
90 | void DrawFit(Double_t nsigma=3) const; | |
56cbeefb | 91 | void Reset(); |
92 | ||
dc262918 | 93 | void IntS(Float_t *valuewitherror) const; // integral of signal given my the fit with error |
94 | Double_t IntTot() const {return fhistoInvMass->Integral("width");} // return total integral of the histogram | |
6321ee46 | 95 | void Signal(Double_t nOfSigma,Double_t &signal,Double_t &errsignal) const; // signal in nsigma with error |
96 | void Signal(Double_t min,Double_t max,Double_t &signal,Double_t &errsignal) const; // signal in (min, max) with error | |
97 | void Background(Double_t nOfSigma,Double_t &background,Double_t &errbackground) const; // backgournd in nsigma with error | |
98 | void Background(Double_t min,Double_t max,Double_t &background,Double_t &errbackground) const; // backgournd in (min, max) with error | |
99 | void Significance(Double_t nOfSigma,Double_t &significance,Double_t &errsignificance) const; // significance in nsigma with error | |
100 | void Significance(Double_t min,Double_t max,Double_t &significance,Double_t &errsignificance) const; // significance in (min, max) with error | |
fabf4d8e | 101 | |
dc262918 | 102 | Double_t FitFunction4MassDistr (Double_t* x, Double_t* par); |
103 | Double_t FitFunction4Sgn (Double_t* x, Double_t* par); | |
104 | Double_t FitFunction4Bkg (Double_t* x, Double_t* par); | |
34c79b83 | 105 | Bool_t MassFitter(Bool_t draw=kTRUE); |
5a8a84f8 | 106 | Bool_t RefitWithBkgOnly(Bool_t draw=kTRUE); |
d22f0682 | 107 | void RebinMass(Int_t bingroup=1); |
6e429dc7 | 108 | TF1* GetBackgroundFullRangeFunc(){ |
109 | return fhistoInvMass->GetFunction("funcbkgFullRange"); | |
110 | } | |
111 | TF1* GetBackgroundRecalcFunc(){ | |
112 | return fhistoInvMass->GetFunction("funcbkgRecalc"); | |
113 | } | |
114 | TF1* GetMassFunc(){ | |
115 | return fhistoInvMass->GetFunction("funcmass"); | |
116 | } | |
6bd53ac7 | 117 | void SetUseLikelihoodFit(){fFitOption="L,";} |
118 | void SetUseLikelihoodWithWeightsFit(){fFitOption="WL,";} | |
119 | void SetUseChi2Fit(){fFitOption="";} | |
fabf4d8e | 120 | |
121 | private: | |
122 | ||
1bbb8940 | 123 | void PlotFit(TVirtualPad* pd,Double_t nsigma=3,Int_t writeFitInfo=1)const; |
a12d80b8 | 124 | |
2f328d65 | 125 | void ComputeParSize(); |
d22f0682 | 126 | void ComputeNFinalPars(); |
b7d4bc49 | 127 | Bool_t SideBandsBounds(); |
d22f0682 | 128 | Bool_t CheckRangeFit(); |
16856d6e | 129 | void AddFunctionsToHisto(); |
2f328d65 | 130 | |
d22f0682 | 131 | TH1F* fhistoInvMass; // histogram to fit |
132 | Double_t fminMass; // lower mass limit | |
133 | Double_t fmaxMass; // upper mass limit | |
1bbb8940 | 134 | Int_t fminBinMass; // bin corresponding to fminMass |
135 | Int_t fmaxBinMass; // bin corresponding to fmaxMass | |
d22f0682 | 136 | Int_t fNbin; // number of bins |
137 | Int_t fParsSize; // size of fFitPars array | |
138 | Int_t fNFinalPars; // number of parameters of the final function | |
139 | Float_t* fFitPars; //[fParsSize] array of fit parameters | |
140 | Bool_t fWithBkg; // signal+background (kTRUE) or signal only (kFALSE) | |
141 | Int_t ftypeOfFit4Bkg; // 0 = exponential; 1 = linear; 2 = pol2 | |
142 | Int_t ftypeOfFit4Sgn; // 0 = gaus; 1 = gaus+gaus broadened | |
143 | Int_t ffactor; // number to multiply to the sigma of the signal to obtain the reflected gaussian | |
144 | TNtuple* fntuParam; // contains fit parameters | |
145 | Double_t fMass; // signal gaussian mean value | |
2cc87a41 | 146 | Double_t fMassErr; // err signal gaussian mean value |
d22f0682 | 147 | Double_t fSigmaSgn; // signal gaussian sigma |
2cc87a41 | 148 | Double_t fSigmaSgnErr; // err signal gaussian sigma |
e654a7da | 149 | Double_t fRawYield; // signal gaussian integral |
150 | Double_t fRawYieldErr; // err on signal gaussian integral | |
d22f0682 | 151 | Bool_t fSideBands; // kTRUE = only side bands considered |
4d7b8e51 | 152 | Bool_t* fFixPar; //[fNFinalPars] for each par if kTRUE it is fixed in fit |
d22f0682 | 153 | Int_t fSideBandl; // left side band limit (bin number) |
154 | Int_t fSideBandr; // right side band limit (bin number) | |
155 | Int_t fcounter; // internal counter | |
6bd53ac7 | 156 | TString fFitOption; // L, LW or Chi2 |
d22f0682 | 157 | TList* fContourGraph; // TList of TGraph containing contour plots |
e654a7da | 158 | |
9fdc4a0c | 159 | ClassDef(AliHFMassFitter,8); // class for invariant mass fit |
fabf4d8e | 160 | }; |
161 | ||
162 | #endif | |
163 | ||
74179930 | 164 |