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