// Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch
//-------------------------------------------------------------------------
+#include "Riostream.h"
#include "AliLRCAnalysis.h"
+#include "TFile.h"
+#include "AliLRCFit.h"
+#include "TProfile.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include "TPaveText.h"
+#include "TF1.h"
+//#include "math.h"
+#include "TStyle.h"
+
+class gStyle;
+class math;
ClassImp(AliLRCAnalysis)
* AliLRCAnalysis class
******************************************************/
-AliLRCAnalysis::AliLRCAnalysis(): fPrAbs(new TH1D()), fPrRel(new TH1D()), fPrf(new TH1D()), fPrb(new TH1D()), fileHist(new TFile()), fdptb(.0), fEntries(0), fSx((char*)" "), fSy((char*)" "), fxFitMin(.0), fxFitMax(.0), fa_rel(.0), fb_rel(.0), fXi2_rel(.0), fa_abs(.0), fb_abs(.0), fXi2_abs(.0){
+AliLRCAnalysis::AliLRCAnalysis(): TObject(), fPrAbs(new TH1D()), fPrRel(new TH1D()), fPrf(new TH1D()), fPrb(new TH1D()), fileHist(new TFile()), fdptb(.0), fEntries(0), fSx((char*)" "), fSy((char*)" "), fxFitMin(.0), fxFitMax(.0), farel(.0), fbrel(.0), farelError(0.), fbrelError(0.), fXi2rel(.0), faabs(.0), fbabs(.0), faabsError(0.), fbabsError(0.), fXi2abs(.0){
//Empty constructor
}
-AliLRCAnalysis::AliLRCAnalysis(const AliLRCAnalysis& a):fPrAbs(a.fPrAbs), fPrRel(a.fPrRel), fPrf(a.fPrf), fPrb(a.fPrb), fileHist(a.fileHist), fdptb(a.fdptb), fEntries(a.fEntries), fSx(a.fSx), fSy(a.fSy), fxFitMin(a.fxFitMin), fxFitMax(a.fxFitMax), fa_rel(a.fa_rel), fb_rel(a.fb_rel), fXi2_rel(a.fXi2_rel), fa_abs(a.fa_abs), fb_abs(a.fb_abs), fXi2_abs(a.fXi2_abs){
+AliLRCAnalysis::AliLRCAnalysis(const AliLRCAnalysis& a): TObject(), fPrAbs(a.fPrAbs), fPrRel(a.fPrRel), fPrf(a.fPrf), fPrb(a.fPrb), fileHist(a.fileHist), fdptb(a.fdptb), fEntries(a.fEntries), fSx(a.fSx), fSy(a.fSy), fxFitMin(a.fxFitMin), fxFitMax(a.fxFitMax), farel(a.farel), fbrel(a.fbrel), farelError(a.farelError), fbrelError(a.fbrelError), fXi2rel(a.fXi2rel), faabs(a.faabs), fbabs(a.fbabs), faabsError(a.faabsError), fbabsError(a.fbabsError), fXi2abs(a.fXi2abs){
//Constructor
}
fEntries = a.fEntries;
fxFitMin = a.fxFitMin;
fxFitMax = a.fxFitMax;
- fa_rel = a.fa_rel;
- fb_rel = a.fb_rel;
- fXi2_rel = a.fXi2_rel;
- fa_abs = a.fa_abs;
- fb_abs = a.fb_abs;
- fXi2_abs = a.fXi2_abs;
+ farel = a.farel;
+ fbrel = a.fbrel;
+ fXi2rel = a.fXi2rel;
+ faabs = a.faabs;
+ fbabs = a.fbabs;
+ fXi2abs = a.fXi2abs;
}
return *this;
}
delete fPrAbs;
delete fPrRel;
delete fileHist;
+ delete fPrf;
+ delete fPrb;
}
-double AliLRCAnalysis::HI2(TH1D *h, double a, double b, double xmin, double xmax) const {
+double AliLRCAnalysis::HI2(TH1D * const h, double a, double b, double xmin, double xmax) const {
//hi square calculation of approximation 1d hist with ax+b between xmin and xmax
- double trueN = 0;
+ int trueN = 0;
double fhi2=0;
double num;
double fN=h->GetNbinsX();
int fNmax = int((xmax-f)/fdf)+1;
for(int i=fNmin; i<=fNmax; i++) {
double fw = h->GetBinError(i);
- if(fw!=0){
+ if(fw){
num = b*(i*fdf-fdf/2+f)+a-h->GetBinContent(i);
fhi2 = fhi2 + (num*num) / (fw*fw);
trueN++;
}
}
- return fhi2/(trueN-2);
+ //cout << "trueN " << trueN << endl;
+ return trueN > 2 ? fhi2/(trueN-2.) : -1;
}
-double AliLRCAnalysis::HI2(TH1D *h, double a, double b) const {
+double AliLRCAnalysis::HI2(TH1D * const h, double a, double b) const {
//hi square calculation of approximation 1d hist with ax+b
- double trueN = 0;
+ int trueN = 0;
double fhi2=0;
double num;
int fN=h->GetNbinsX();
int fNmax = fN;
for(int i=fNmin; i<=fNmax; i++) {
double fw = h->GetBinError(i);
- if(fw!=0){
+ if(fw){
num = b*(i*fdf-fdf/2+f)+a-h->GetBinContent(i);
fhi2 = fhi2 + (num*num) / (fw*fw);
trueN++;
}
}
- return fhi2/(trueN-2);
+ //cout << "trueN2 " << trueN << endl;
+ return trueN > 2 ? fhi2/(trueN-2.) : -1;
}
double mnf = fPrf->GetMean();
fxFitMin = mnf-2*sqrt(mnf);
fxFitMax = mnf+2*sqrt(mnf);
+ //delete profX;
}
void AliLRCAnalysis::SetBinsRange(int binMin, int binMax){
+//Set the bin range
TH1D* h=fPrf;
- double N=h->GetNbinsX();
+ double n=h->GetNbinsX();
fxFitMin = h->GetXaxis()->GetXmin();
fxFitMax = h->GetXaxis()->GetXmax();
- double df = (fxFitMax-fxFitMin)/N;
- for(int i=1; i<=N; i++)
+ double df = (fxFitMax-fxFitMin)/n;
+ for(int i=1; i<=n; i++)
if(h->GetBinContent(i) != 0){
fxFitMin += (i + binMin) * df;
break;
}
- for(int i=1; i<=N; i++)
- if(h->GetBinContent(N-i) != 0){
+ for(int i=1; i<=n; i++)
+ if(h->GetBinContent(n-i) != 0){
fxFitMax -= (i + binMax) * df;
break;
}
}
bool AliLRCAnalysis::SetFitRange(double xMin, double xMax){
-//������������� ������� �������������. ���������� false, ���� xMin ������ xMax. ��������� �� ���������� �� ����, � ���� � ���� ��� �����.((
+//Set the fit range
if(xMax < xMin){
return false;
}
this->fxFitMax = xMax;
return true;
}
+void AliLRCAnalysis::SetFullFitRange(){
+//Set fitting on full range
+ TH1D* h=fPrf;
+ fxFitMin = h->GetXaxis()->GetXmin();
+ //fxFitMax = h->GetXaxis()->GetXmax();
+
+ for ( int binI = h->GetNbinsX(); binI > 0; binI-- )
+ {
+ if ( h->GetBinContent(binI) != 0 )
+ {
+ fxFitMax = h->GetBinLowEdge(binI+1) ;
+ break;
+ }
+ }
+}
+
void AliLRCAnalysis::SetXmin(double xMin){
fxFitMin = xMin;
fxFitMax = xMax;
}
-double AliLRCAnalysis::GetArel(){
- return fa_rel;
+double AliLRCAnalysis::GetArel() const {
+ return farel;
}
-double AliLRCAnalysis::GetBrel(){
- return fb_rel;
+double AliLRCAnalysis::GetBrel() const {
+ return fbrel;
}
-double AliLRCAnalysis::GetXi2rel(){
- return fXi2_rel;
+double AliLRCAnalysis::GetArelError() const {
+ return farelError;
}
-double AliLRCAnalysis::GetAabs(){
- return fa_abs;
+double AliLRCAnalysis::GetBrelError() const {
+ return fbrelError;
}
-double AliLRCAnalysis::GetBabs(){
- return fb_abs;
+double AliLRCAnalysis::GetXi2rel() const {
+ return fXi2rel;
}
-double AliLRCAnalysis::GetXi2abs(){
- return fXi2_abs;
+double AliLRCAnalysis::GetAabs() const {
+ return faabs;
+}
+
+double AliLRCAnalysis::GetBabs() const {
+ return fbabs;
+}
+
+double AliLRCAnalysis::GetAabsError() const {
+ return faabsError;
+}
+
+double AliLRCAnalysis::GetBabsError() const {
+ return fbabsError;
+}
+double AliLRCAnalysis::GetXi2abs() const {
+ return fXi2abs;
}
void AliLRCAnalysis::Calculate(){
+//Calculate all
double mnf;
fPrAbs->SetStats(0);
fPrAbs->Fit("pol1", "0", "", fxFitMin, fxFitMax);
TF1 *fitt1 = fPrAbs->GetFunction("pol1");
- fa_abs = fitt1->GetParameter(0);
- fb_abs = fitt1->GetParameter(1);
- fXi2_abs = HI2(fPrAbs, fitt1->GetParameter(0), fitt1->GetParameter(1), fxFitMin, fxFitMax);
+ faabs = fitt1->GetParameter(0);
+ fbabs = fitt1->GetParameter(1);
+ faabsError = fitt1->GetParError(0);
+ fbabsError = fitt1->GetParError(1);
+ fXi2abs = HI2(fPrAbs, fitt1->GetParameter(0), fitt1->GetParameter(1), fxFitMin, fxFitMax);
mnf = fPrf->GetMean();
fPrRel->SetStats(0);
f1->SetParameter(0,fit1->Geta());
f1->SetParameter(1,fit1->Getb());
fPrRel->Fit("f1", "0", "", fxFitMin/mnf, fxFitMax/mnf);
- fa_rel = fit1->Geta();
- fb_rel = fit1->Getb();
- fXi2_rel = fit1->Gethi2();
+ farel = fit1->Geta();
+ fbrel = fit1->Getb();
+ farelError = fit1->Getda();
+ fbrelError = fit1->Getdb();
+ fXi2rel = fit1->Gethi2();
}
void AliLRCAnalysis::DrawAbs() {
-// Draw abs var histrogramm
+ //Draw abs var hist with ALL info
+ int * mas = new int[N_PL_FLAGS];
+ for ( int i = 0; i < N_PL_FLAGS; i++ )
+ mas[i] = 1;
+ DrawAbsPure( mas, 1 );
+ delete [] mas;
+ mas = NULL;
+}
+
+void AliLRCAnalysis::DrawAbs( int * mas ) {
+//Draw abs var hist with REQUESTED BY ARRAY info
+ DrawAbsPure( mas, 1 );
+}
+
+void AliLRCAnalysis::DrawAbsPure( const int * const mDrawArray, bool drawPaveLabel ) {
+// Draw abs var histrogram
//double mnf;
double y1, y2, x1, x2;
Int_t i, n;
if(fPrAbs->GetBinContent(i)+fPrAbs->GetBinError(i)>y2)
y2=fPrAbs->GetBinContent(i)+fPrAbs->GetBinError(i);
}
- x1 = fPrAbs->GetXaxis()->GetXmin();
+ fPrAbs->DrawCopy();
+
+ x1 = fPrAbs->GetXaxis()->GetXmin();
x2 = fPrAbs->GetXaxis()->GetXmax();
- TPaveText *pt1 = new TPaveText(x1+(x2-x1)/4, y1+(y2-y1)/2, x2-(x2-x1)/4, y2);
- pt1->SetTextSize(0.03);
- sprintf(str, "Entries = %i", fEntries);
- pt1->AddText(str);
- sprintf(str, "a = %f #pm %f", fit1->GetParameter(0), fit1->GetParError(0));
- pt1->AddText(str);
- sprintf(str, "b = %f #pm %f", fit1->GetParameter(1), fit1->GetParError(1));
- pt1->AddText(str);
- sprintf(str, "#hat{#chi}^{2} = #chi^{2}/(n-2) = %f", HI2(fPrAbs, fit1->GetParameter(0), fit1->GetParameter(1), fxFitMin, fxFitMax));
- pt1->AddText(str);
- sprintf(str, "<%s> = %f " , fSx, fPrf->GetMean());
- pt1->AddText(str);
- sprintf(str, "<%s> = %f", fSy, fPrb->GetMean());
- pt1->AddText(str);
-
- sprintf(str, "<<%s>> = %f " , fSx, fPrf->GetRMS());
- pt1->AddText(str);
- sprintf(str, "<<%s>> = %f", fSy, fPrb->GetRMS());
- pt1->AddText(str);
- if(fdptb){
- sprintf(str, "d%s = %f", fSy, fdptb);
- pt1->AddText(str);
- }
-
-
- pt1->SetTextAlign(12);
- pt1->SetTextFont(42);
- pt1->SetFillColor(0);
- fPrAbs->DrawCopy();
- pt1->DrawClone();
+
+ if ( drawPaveLabel )
+ {
+ int nDatas = 0;
+ for ( int j = 0; j < 9; j++)
+ if ( mDrawArray[j] ) nDatas++;
+ double aXshift = (x2-x1)/7;
+ double aYshift = (y2-y1)/20;
+
+ TPaveText *pt1 = new TPaveText(x1+(x2-x1)/2 + aXshift, y1+aYshift, x2-(x2-x1)/6 + aXshift, y1+(y2-y1)/3*2/9*nDatas + aYshift);
+
+ sprintf(str, "Entries = %i", fEntries);
+ if ( mDrawArray[0] ) pt1->AddText(str);
+ sprintf(str, "a = %g #pm %g", GetRoundWithError(fit1->GetParameter(0), fit1->GetParError(0)), GetRoundWithPrecision(fit1->GetParError(0), 2)); //fit1->GetParameter(0), fit1->GetParError(0));
+ if ( mDrawArray[1] ) pt1->AddText(str);
+ sprintf(str, "b = %g #pm %g", GetRoundWithError(fit1->GetParameter(1), fit1->GetParError(1)), GetRoundWithPrecision(fit1->GetParError(1), 2)); //fit1->GetParameter(1), fit1->GetParError(1));
+ if ( mDrawArray[2] ) pt1->AddText(str);
+ sprintf(str, "#hat{#chi}^{2} = #chi^{2}/(n-2) = %g", GetRoundWithPrecision(HI2(fPrAbs, fit1->GetParameter(0), fit1->GetParameter(1), fxFitMin, fxFitMax), 3));
+ if ( mDrawArray[3] ) pt1->AddText(str);
+ sprintf(str, "<%s> = %g " , fSx, GetRoundWithPrecision(fPrf->GetMean(), 3));
+ if ( mDrawArray[4] ) pt1->AddText(str);
+
+ sprintf(str, "<%s> = %g", fSy, GetRoundWithPrecision(fPrb->GetMean(),3));
+ if ( mDrawArray[5] ) pt1->AddText(str);
+
+ sprintf(str, "<<%s>> = %g " , fSx, GetRoundWithPrecision(fPrf->GetRMS(), 3));
+ if ( mDrawArray[6] ) pt1->AddText(str);
+ sprintf(str, "<<%s>> = %g", fSy, GetRoundWithPrecision(fPrb->GetRMS(), 3));
+ if ( mDrawArray[7] ) pt1->AddText(str);
+
+ if ( fdptb ) {
+ sprintf(str, "d%s = %g", fSy, GetRoundWithPrecision(fdptb, 3));
+ if ( mDrawArray[8] ) pt1->AddText(str);
+ }
+
+ pt1->SetTextAlign(12);
+ pt1->SetTextFont(42);
+ pt1->SetFillColor(4000);
+ //pt1->SetFillStyle(4100);
+ pt1->SetShadowColor(4000);
+ pt1->SetBorderSize(0);
+
+ pt1->DrawClone("same");
+ }
}
void AliLRCAnalysis::DrawRel() {
-// Draw rel var histogramm
-double mnf;
-double y1, y2, x1, x2;
-Int_t i, n;
-char str[50];
-
-mnf = fPrf->GetMean();
-
-fPrRel->SetStats(0);
-AliLRCFit *fit1 = new AliLRCFit(fPrRel, fxFitMin/mnf, fxFitMax/mnf);
-TF1 *f1 = new TF1("f1", "[0] + [1]*x", 0, fPrRel->GetXaxis()->GetXmax());
-f1->SetParameter(0,fit1->Geta());
-f1->SetParameter(1,fit1->Getb());
-fPrRel->Fit("f1", "", "", fxFitMin/mnf, fxFitMax/mnf);
+ //Draw rel var hist with ALL info
+ int * mas = new int[N_PL_FLAGS];
+ for ( int i = 0; i < N_PL_FLAGS; i++ )
+ mas[i] = 1;
+ DrawRelPure( mas, 1 );
+ delete [] mas;
+ mas = NULL;
+}
+
+void AliLRCAnalysis::DrawRel( int * mas ) {
+//Draw rel var hist with REQUESTED BY ARRAY info
+ DrawRelPure( mas, 1 );
+}
+
+void AliLRCAnalysis::DrawRelPure( const int * const mDrawArray, bool drawPaveLabel ) {
+// Draw rel var histogram
+ double mnf;
+ double y1, y2, x1, x2;
+ Int_t i, n;
+ char str[50];
+
+ mnf = fPrf->GetMean();
+
+ fPrRel->SetStats(0);
+ AliLRCFit *fit1 = new AliLRCFit(fPrRel, fxFitMin/mnf, fxFitMax/mnf);
+ TF1 *f1 = new TF1("f1", "[0] + [1]*x", 0, fPrRel->GetXaxis()->GetXmax());
+ f1->SetParameter(0,fit1->Geta());
+ f1->SetParameter(1,fit1->Getb());
+ fPrRel->Fit("f1", "", "", fxFitMin/mnf, fxFitMax/mnf);
y1=fPrRel->GetBinContent(1)-fPrRel->GetBinError(1);
y2=fPrRel->GetBinContent(1)+fPrRel->GetBinError(1);
n=fPrRel->GetNbinsX();
if(fPrRel->GetBinContent(i)+fPrRel->GetBinError(i)>y2)
y2=fPrRel->GetBinContent(i)+fPrRel->GetBinError(i);
}
+ fPrRel->DrawCopy();
+
x1 = fPrRel->GetXaxis()->GetXmin();
x2 = fPrRel->GetXaxis()->GetXmax();
- TPaveText *pt1 = new TPaveText(x1+(x2-x1)/4, y1+(y2-y1)/2, x2-(x2-x1)/4, y2);
- pt1->SetTextSize(0.03);
- sprintf(str, "Entries = %i", fEntries);
- pt1->AddText(str);
- sprintf(str, "a = %f #pm %f", fit1->Geta(), fit1->Getda());
- pt1->AddText(str);
- sprintf(str, "b = %f #pm %f", fit1->Getb(), fit1->Getdb());
- pt1->AddText(str);
- sprintf(str, "#hat{#chi}^{2} = #chi^{2}/(n-2) = %f", fit1->Gethi2());
- pt1->AddText(str);
- sprintf(str, "<%s> = %f " , fSx, fPrf->GetMean());
- pt1->AddText(str);
- sprintf(str, "<%s> = %f", fSy, fPrb->GetMean());
- pt1->AddText(str);
- sprintf(str, "<<%s>> = %f " , fSx, fPrf->GetRMS());
- pt1->AddText(str);
- sprintf(str, "<<%s>> = %f", fSy, fPrb->GetRMS());
- pt1->AddText(str);
- if(fdptb){
- sprintf(str, "d%s = %f", fSy, fdptb);
- pt1->AddText(str);
- }
- pt1->SetTextAlign(12);
- pt1->SetTextFont(42);
- pt1->SetFillColor(0);
- fPrRel->DrawCopy();
- pt1->DrawClone();
+
+ if ( drawPaveLabel )
+ {
+ int nDatas = 0;
+ for ( int j = 0; j < 9; j++)
+ if ( mDrawArray[j] ) nDatas++;
+ double aXshift = (x2-x1)/7;
+ double aYshift = (y2-y1)/20;
+
+ TPaveText *pt1 = new TPaveText(x1+(x2-x1)/2 + aXshift, y1+aYshift, x2-(x2-x1)/6 + aXshift, y1+(y2-y1)/3*2/9*nDatas + aYshift);
+ sprintf(str, "Entries = %i", fEntries);
+ if ( mDrawArray[0] ) pt1->AddText(str);
+ sprintf(str, "a = %g #pm %g", GetRoundWithError(fit1->Geta(), fit1->Getda()), GetRoundWithPrecision(fit1->Getda(), 2)); //fit1->GetParameter(0), fit1->GetParError(0));
+ if ( mDrawArray[1] ) pt1->AddText(str);
+ sprintf(str, "b = %g #pm %g", GetRoundWithError(fit1->Getb(), fit1->Getdb()), GetRoundWithPrecision(fit1->Getdb(), 2)); //fit1->GetParameter(1), fit1->GetParError(1));
+ if ( mDrawArray[2] ) pt1->AddText(str);
+ sprintf(str, "#hat{#chi}^{2} = #chi^{2}/(n-2) = %g", GetRoundWithPrecision(fit1->Gethi2(), 3));
+ if ( mDrawArray[3] ) pt1->AddText(str);
+ sprintf(str, "<%s> = %g " , fSx, GetRoundWithPrecision(fPrf->GetMean(), 3));
+ if ( mDrawArray[4] ) pt1->AddText(str);
+
+ sprintf(str, "<%s> = %g", fSy, GetRoundWithPrecision(fPrb->GetMean(),3));
+ if ( mDrawArray[5] ) pt1->AddText(str);
+
+ sprintf(str, "<<%s>> = %g " , fSx, GetRoundWithPrecision(fPrf->GetRMS(), 3));
+ if ( mDrawArray[6] ) pt1->AddText(str);
+ sprintf(str, "<<%s>> = %g", fSy, GetRoundWithPrecision(fPrb->GetRMS(), 3));
+ if ( mDrawArray[7] ) pt1->AddText(str);
+
+ if ( fdptb ) {
+ sprintf(str, "d%s = %g", fSy, GetRoundWithPrecision(fdptb, 3));
+ if ( mDrawArray[8] ) pt1->AddText(str);
+ }
+
+ pt1->SetTextAlign(12);
+ pt1->SetTextFont(42);
+ pt1->SetFillColor(4000);
+ //pt1->SetFillStyle(4100);
+ pt1->SetShadowColor(4000);
+ pt1->SetBorderSize(0);
+
+ pt1->DrawClone();//"s(0,0)");
+ }
}
void AliLRCAnalysis::SetGraphics() const {
// Set root graph style
+ TStyle tempSt;
gStyle->SetCanvasColor(10);
gStyle->SetFrameFillColor(10);
gStyle->SetStatColor(0);
gStyle->SetPadColor(0);
}
-double AliLRCAnalysis::Integral(TH2D* source, Int_t nbin) const {
+double AliLRCAnalysis::Integral(TH2D* const source, Int_t nbin) const {
// calculate the integrall for x bin and y bins of 2d histogramm
double sum = 0;
for(Int_t i = 1; i<=source->GetNbinsY(); i++) {
}
+double AliLRCAnalysis::GetRoundWithError( double value, double error ){
+//Rounding error and value with DEFAULT precision
+ return GetRoundValueErrorPrecision( value, error, 2 );
+}
+double AliLRCAnalysis::GetRoundWithError( double value, double error, int pres ){
+//Rounding error and value with REQUESTED precision
+ return GetRoundValueErrorPrecision( value, error, pres );
+}
+double AliLRCAnalysis::GetRoundWithPrecision( double value, int pres ){
+//Rounding error and value with requested precision
+ return GetRoundValueErrorPrecision( value, 0, pres );
+}
+
+double AliLRCAnalysis::GetRoundValueErrorPrecision( double value, double error, int pres ) const {
+ //Rounding error and value with requested precision
+ //value == value, error == error
+ //if single argument(value=0) - calculate without errors:
+
+ int i = 0;
+ double order = 1;
+ bool noError = false;
+ pres -= 1;
+
+ cout << "Before rounding: " << value << " " << error << endl;
+
+ if ( !error)
+ {
+ error = value;
+ noError = true;
+ }
+ while ( ((int)error)%10 == 0 || i == 10 )
+ {
+ i++;
+ error*=10;
+ order*=10;
+ }
+
+ for ( int j = 0; j < pres; j++ )
+ {
+ error*=10;
+ order*=10;
+ i++;
+ }
+ int adding = 0;
+ if ( ((int)(error*10))%10 > 4 && ((int)(error*10))%10 != 9 ) //trouble: if we round 19 to 20 - zero disappeares!
+ adding = 1;
+ error = (double)((int)error + adding)/order;
+
+ if ( noError )
+ {
+ cout << "After rounding: " << error << endl;
+ return error;
+ }
+ else
+ {
+ for ( int j = 0; j < i; j++ )
+ value*=10;
+
+ adding = 0;
+ if ( ((int)(value*10))%10 > 4 && ((int)(value*10))%10 != 9 )
+ adding = 1;
+ value = (double)((int)value + adding)/order;
+
+ cout << "After rounding: " << value << " " << error << endl;
+ return value; //taking into account ERROR
+ }
+}
-//-------------------------------------------------------------------------\r
-// Description: \r
-// This class include into LRC library for Long-Range Correlation analysis\r
-// it is base class for NN, PtN, PtPt\r
-// implements base methods for thees classes\r
-// Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch\r
-//-------------------------------------------------------------------------\r
-\r
-#ifndef ALILRCANALYSIS_H\r
-#define ALILRCANALYSIS_H\r
-\r
-/* See cxx source for full Copyright notice */\r
-\r
-\r
-/* $Id$ */\r
-\r
-//-------------------------------------------------------------------------\r
-// LRC library for Long-Range Correlation analysis\r
-//\r
-// Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch\r
-//-------------------------------------------------------------------------\r
-\r
-#include "TFile.h"\r
-#include "AliLRCFit.h"\r
-#include "TProfile.h"\r
-#include "TH1D.h"\r
-#include "TH2D.h"\r
-#include "TPaveText.h"\r
-#include "TF1.h"\r
-#include "math.h"\r
-#include "TStyle.h"\r
-\r
-\r
-class TH1D;\r
-class TH2D;\r
-class TFile;\r
-\r
-class AliLRCAnalysis{\r
- public:\r
- void DrawAbs();\r
- void DrawRel();
- void SetXmin(double xMin);
- void SetXmax(double xMax);
- void SetBinsRange(int binMin, int binMax);
- double GetArel();
- double GetBrel();
- double GetXi2rel();
- double GetAabs();
- double GetBabs();
- double GetXi2abs();
- void Calculate();\r
- bool SetFitRange(double xMin, double xMax);\r
- AliLRCAnalysis();\r
- AliLRCAnalysis(const AliLRCAnalysis& a);\r
- AliLRCAnalysis& operator= (const AliLRCAnalysis& a);\r
- virtual ~AliLRCAnalysis();\r
-\r
- protected:\r
- TH1D* fPrAbs; //Work 1d histogramm in absolute var\r
- TH1D* fPrRel; //Work 1d histogramm in rellation var\r
- TH1D* fPrf; //Forward distribution\r
- TH1D* fPrb; //Backward distribution\r
- TFile* fileHist; // File with histrogramms\r
- double fdptb; //Work var for error calculation\r
- int fEntries; //Number of bins\r
- double HI2(TH1D *h, double a, double b, double xmin, double xmax) const;\r
- double HI2(TH1D *h, double a, double b) const;\r
- double Integral(TH2D* source, int nbin) const;\r
- //Creating profile from histogramm\r
- void CreateHist(char *name, char *nameAbs, char *nameRel, char *atitleF, char *atitleB,char *rtitleF, char *rtitleB,TH2D* sourceHist);\r
- void SetGraphics() const;\r
- void SetErrors(TH2D* source, const char *name);\r
- void SetErrors(TH2D* source, const char *name, double ptd, TH2D* nb);\r
- void SetErrors(TH2D* source, const char *name, double ptd, TProfile* nb);
- \r
-\r
- private:\r
- char* fSx; //Title of x axis\r
- char* fSy; //Title of y axis\r
- double fxFitMin;\r
- double fxFitMax;
- double fa_rel;
- double fb_rel;
- double fXi2_rel;
- double fa_abs;
- double fb_abs;
- double fXi2_abs;
-\r
-\r
- ClassDef(AliLRCAnalysis,0) // macro for rootcint\r
-};\r
-\r
-#endif\r
-\r
+//-------------------------------------------------------------------------
+// Description:
+// This class is included into LRC library for Long-Range Correlation analysis
+// it is base class for NN, PtN, PtPt
+// implements base methods for thees classes
+// Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch
+//-------------------------------------------------------------------------
+
+#ifndef ALILRCANALYSIS_H
+#define ALILRCANALYSIS_H
+
+/* See cxx source for full Copyright notice */
+
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+// LRC library for Long-Range Correlation analysis
+//
+// Origin: Petr Naumenko, SPbSU-CERN, Petr.Naoumenko@cern.ch
+//-------------------------------------------------------------------------
+
+#include <TObject.h>
+
+#define N_PL_FLAGS 10
+
+class TFile;
+class AliLRCFit;
+class TProfile;
+class TH1D;
+class TH2D;
+class TPaveText;
+class TF1;
+class math;
+class TStyle;
+
+class AliLRCAnalysis : public TObject{
+ public:
+ void DrawAbs();
+ void DrawAbs( int * mas );
+ void DrawAbsPure( const int * const mas, bool drawPaveLabel );
+ void DrawRel();
+ void DrawRel( int * mas );
+ void DrawRelPure( const int * const mas, bool drawPaveLabel );
+
+ void SetXmin(double xMin);
+ void SetXmax(double xMax);
+ void SetBinsRange(int binMin, int binMax);
+ double GetArel() const;
+ double GetBrel() const;
+ double GetArelError() const;
+ double GetBrelError() const;
+ double GetXi2rel() const;
+ double GetAabs() const;
+ double GetBabs() const;
+ double GetAabsError() const;
+ double GetBabsError() const;
+ double GetXi2abs() const;
+ void Calculate();
+ bool SetFitRange(double xMin, double xMax);
+ void SetFullFitRange();
+
+ double GetRoundWithError( double value, double error );
+ double GetRoundWithError( double value, double error, int pres );
+ double GetRoundWithPrecision( double value, int pres );
+
+ double GetRoundValueErrorPrecision( double value, double error, int pres ) const;
+
+
+ AliLRCAnalysis();
+ AliLRCAnalysis(const AliLRCAnalysis& a);
+ AliLRCAnalysis& operator= (const AliLRCAnalysis& a);
+ virtual ~AliLRCAnalysis();
+
+ protected:
+ TH1D* fPrAbs; //Work 1d histogramm in absolute var
+ TH1D* fPrRel; //Work 1d histogramm in rellation var
+ TH1D* fPrf; //Forward distribution
+ TH1D* fPrb; //Backward distribution
+ TFile* fileHist; // File with histrogramms
+ double fdptb; //Work var for error calculation
+ int fEntries; //Number of bins
+ double HI2(TH1D * const h, double a, double b, double xmin, double xmax) const;
+ double HI2(TH1D * const h, double a, double b) const;
+ double Integral(TH2D* source, int nbin) const;
+
+ //Creating profile from histogramm
+ void CreateHist(char *name, char *nameAbs, char *nameRel, char *atitleF, char *atitleB,char *rtitleF, char *rtitleB,TH2D* sourceHist);
+ void SetGraphics() const;
+ void SetErrors(TH2D* source, const char *name);
+ void SetErrors(TH2D* source, const char *name, double ptd, TH2D* nb);
+ void SetErrors(TH2D* source, const char *name, double ptd, TProfile* nb);
+
+ private:
+ char* fSx; // Title of x axis
+ char* fSy; // Title of y axis
+ double fxFitMin; // FitMin minimum of fit baundary
+ double fxFitMax; // FitMax maximum of fit baundary
+ double farel; // ax = b the a relative
+ double fbrel; // ax = b the b reletive
+ double farelError; // a relative error
+ double fbrelError; // b reletive error
+ double fXi2rel; // chi square reletive
+ double faabs; // ax = b the a absolut
+ double fbabs; // ax = b the b absolut
+ double faabsError; // a absolut error
+ double fbabsError; // b absolut error
+ double fXi2abs; // chi square absolut
+
+ ClassDef(AliLRCAnalysis,0); // macro for rootcint
+};
+
+#endif
+