]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/EBYE/LRC/AliLRCFit.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / EBYE / LRC / AliLRCFit.cxx
CommitLineData
d03e5de4 1/**************************************************************************
ec6ab54b 2 * Author: Andrey Ivanov. *
d03e5de4 3 * Contributors are mentioned in the code where appropriate. *
4 * *
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 **************************************************************************/
13
14//-------------------------------------------------------------------------
15// Description:
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
ec6ab54b 19// Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch,
20// Andrey Ivanov (SPbSU-CERN), Igor Altsebeev (SPbSU-CERN)
d03e5de4 21//-------------------------------------------------------------------------
22
23/* $Id$ */
24
25#include "AliLRCFit.h"
adf00ba6 26#include "TH1D.h"
ec6ab54b 27#include "math.h"
d03e5de4 28
adf00ba6 29class TH1D;
d03e5de4 30
31ClassImp(AliLRCFit)
32
33
ec6ab54b 34AliLRCFit::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){
d03e5de4 35//Empty constructor
36}
37
ec6ab54b 38AliLRCFit::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){
d03e5de4 39 //Constructor make fit of 1d histogramm
ec6ab54b 40AliLRCFit(h,h->GetXaxis()->GetXmin(),h->GetXaxis()->GetXmax(),xShift);
d03e5de4 41}
42
ec6ab54b 43AliLRCFit::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){
d03e5de4 44 //Constructor make fit of 1d histogramm between xmin and xmax
ec6ab54b 45 fNmin=h->GetXaxis()->FindBin(xmin);
46 fNmax=h->GetXaxis()->FindBin(xmax);
47 //double xShift=0;
48 for(int i=fNmin; i<=fNmax; i++){
49 fw = h->GetBinError(i);
50 f= h->GetBinCenter(i)-xShift;
51 fz= h->GetBinContent(i);
52 if(fw){
53 fTrueN++;
54 fS1 += 1.0/(fw*fw);
55 fSz += fz/(fw*fw);
56 fSf += f/(fw*fw);
57 fSfz += f*fz/(fw*fw);
58 fSf2 += (f*f)/(fw*fw);
59 }
60 }
61 if(fTrueN<2)return;
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);
67 fdb1 = 0;
68 fda1 = 0;
69 fhi2 = 0;
70 for(int i=fNmin; i<=fNmax; i++){
71 fw = h->GetBinError(i);
72 f= h->GetBinCenter(i)-xShift;
73 fz= h->GetBinContent(i);
74 if(fw){
75 double fDletaZ2=fz-fa-fb*f;
76 fDletaZ2*=fDletaZ2;
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));
80 }
81 }
82 fda1 = sqrt( fda1 );
83 fdb1 = sqrt( fdb1 );
84 fhi2 = fTrueN > 2 ? fhi2 / (fTrueN-2) : -1;
d03e5de4 85}
86
87AliLRCFit::~AliLRCFit() {
88}
89
90double AliLRCFit::Geta() const {return fa;}
91double AliLRCFit::Getb() const {return fb;}
92double AliLRCFit::Getda() const {return fda;}
93double AliLRCFit::Getdb() const {return fdb;}
94double AliLRCFit::Getda1() const {return fda1;}
95double AliLRCFit::Getdb1() const {return fdb1;}
96double AliLRCFit::Gethi2() const {return fhi2;}
97double AliLRCFit::Getf() const {return f;}
d96e5666 98double AliLRCFit::Getxmin() const {return fxmin;}
99double AliLRCFit::Getxmax() const {return fxmax;}
d03e5de4 100int AliLRCFit::GetN() const {return fN;}
ec6ab54b 101double AliLRCFit::GetFitRange() const
102{
103//Returns range between xmin and xmax
104return (fxmax-fxmin);
105}
d03e5de4 106
107
108