1 /**************************************************************************
2 * Author: Andrey Ivanov. *
3 * Contributors are mentioned in the code where appropriate. *
5 * Permission to use, copy, modify and distribute this software and its *
6 * documentation strictly for non-commercial purposes is hereby granted *
7 * without fee, provided that the above copyright notice appears in all *
8 * copies and that both the copyright notice and this permission notice *
9 * appear in the supporting documentation. The authors make no claims *
10 * about the suitability of this software for any purpose. It is *
11 * provided "as is" without express or implied warranty. *
12 **************************************************************************/
14 //-------------------------------------------------------------------------
16 // This class include into LRC library for Long-Range Correlation analysis
17 // it makes fit of the 1d histogramm
18 // calculates ax+b coefficients with error and hi square
19 // Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch,
20 // Andrey Ivanov (SPbSU-CERN), Igor Altsebeev (SPbSU-CERN)
21 //-------------------------------------------------------------------------
25 #include "AliLRCFit.h"
34 AliLRCFit::AliLRCFit():TObject(),fN (0), fTrueN(0), fNmin (0), fNmax(0), fS1(.0), fSz(.0), fSfz(.0), fSf(.0), fSf2(.0), fhi2(.0), fw(.0), fz(.0), f(.0), fnum(.0), fdf(.0), fdelta(.0), fa(.0), fb(.0), fda(.0), fdb(.0), fda1(.0), fdb1(.0), fxmin(.0), fxmax(.0){
38 AliLRCFit::AliLRCFit(TH1D * const h,double xShift):TObject(),fN (0), fTrueN(0), fNmin (0), fNmax(0), fS1(.0), fSz(.0), fSfz(.0), fSf(.0), fSf2(.0), fhi2(.0), fw(.0), fz(.0), f(.0), fnum(.0), fdf(.0), fdelta(.0), fa(.0), fb(.0), fda(.0), fdb(.0), fda1(.0), fdb1(.0), fxmin(.0), fxmax(.0){
39 //Constructor make fit of 1d histogramm
40 AliLRCFit(h,h->GetXaxis()->GetXmin(),h->GetXaxis()->GetXmax(),xShift);
43 AliLRCFit::AliLRCFit(TH1D * const h, double xmin, double xmax,double xShift):TObject(),fN (0), fTrueN(0), fNmin (0), fNmax(0), fS1(.0), fSz(.0), fSfz(.0), fSf(.0), fSf2(.0), fhi2(.0), fw(.0), fz(.0), f(.0), fnum(.0), fdf(.0), fdelta(.0), fa(.0), fb(.0), fda(.0), fdb(.0), fda1(.0), fdb1(.0), fxmin(.0), fxmax(.0){
44 //Constructor make fit of 1d histogramm between xmin and xmax
45 fNmin=h->GetXaxis()->FindBin(xmin);
46 fNmax=h->GetXaxis()->FindBin(xmax);
48 for(int i=fNmin; i<=fNmax; i++){
49 fw = h->GetBinError(i);
50 f= h->GetBinCenter(i)-xShift;
51 fz= h->GetBinContent(i);
58 fSf2 += (f*f)/(fw*fw);
62 fdelta = fS1*fSf2 - fSf*fSf;
63 fa = (fSf2*fSz - fSf*fSfz)/fdelta;
64 fb = (fS1*fSfz - fSf*fSz)/fdelta;
65 fda = sqrt(fSf2/fdelta);
66 fdb = sqrt(fS1/fdelta);
70 for(int i=fNmin; i<=fNmax; i++){
71 fw = h->GetBinError(i);
72 f= h->GetBinCenter(i)-xShift;
73 fz= h->GetBinContent(i);
75 double fDletaZ2=fz-fa-fb*f;
77 fhi2 += fDletaZ2/(fw*fw);
78 fda1 += ( fDletaZ2/(fdelta*fdelta) ) * ((fSf2 - fSf*f)/ (fw*fw))*((fSf2 - fSf*f)/ (fw*fw));
79 fdb1 += ( fDletaZ2/(fdelta*fdelta) ) * ((fS1*f - fSf)/ (fw*fw))*((fS1*f - fSf)/ (fw*fw));
84 fhi2 = fTrueN > 2 ? fhi2 / (fTrueN-2) : -1;
87 AliLRCFit::~AliLRCFit() {
90 double AliLRCFit::Geta() const {return fa;}
91 double AliLRCFit::Getb() const {return fb;}
92 double AliLRCFit::Getda() const {return fda;}
93 double AliLRCFit::Getdb() const {return fdb;}
94 double AliLRCFit::Getda1() const {return fda1;}
95 double AliLRCFit::Getdb1() const {return fdb1;}
96 double AliLRCFit::Gethi2() const {return fhi2;}
97 double AliLRCFit::Getf() const {return f;}
98 double AliLRCFit::Getxmin() const {return fxmin;}
99 double AliLRCFit::Getxmax() const {return fxmax;}
100 int AliLRCFit::GetN() const {return fN;}
101 double AliLRCFit::GetFitRange() const
103 //Returns range between xmin and xmax
104 return (fxmax-fxmin);