Hi,
I’m fitting a histogram in Root with a gaussian and a polynomial. I was able to deduce the number of events (using integral) for both signal and background. I would like now to get the statistical error on these number of events.
I tried (see full code below) :
Function->IntegralError(a,b);
However the IntegralError is giving me 0. Can anyone let me know what I’m doing wrong ?
Double_t background3(Double_t *x, Double_t *par) {
return par[0] + par[1]*x[0] + par[2]*x[0]*x[0] ;
}
Double_t GAUSS(Double_t *x, Double_t *par){
return par[0]*exp(-0.5*(((x[0]-par[1])/par[2])*((x[0]-par[1])/par[2])));
}
Double_t fitFunction(Double_t *x, Double_t *par) {
return background3(x,par) + GAUSS(x,&par[3]);
}
TF1 *fitFcn = new TF1("fitFcn",fitFunction,3.04,3.17,6);
fitFcn->SetParameters(1,1,1,1,3.095,0.004);
hist4230->GetXaxis()->SetTitle("MM_{(#pi^{+}#pi^{-})} GeV/c^{2}");
hist4230->SetTitle("@4.23 GeV");
hist4230->GetYaxis()->SetTitle("Entries/1.3 MeV/c^{2}");
hist4230->GetYaxis()->SetTitleOffset(1.4);
fitFcn->SetParLimits(5,0.003,0.007);
hist4230->Fit("fitFcn","V+","ep");
hist4230->SetMarkerStyle(20);
TF1 *backFcn = new TF1("backFcn",background3,3.04,3.17,3);
//fitFcn->SetLineColor(kGreen);
backFcn->SetLineColor(kRed);
TF1 *signalFcn = new TF1("signalFcn",GAUSS,3.04,3.17,3);
signalFcn->SetLineColor(kBlue);
signalFcn->SetNpx(500);
Double_t par[6];
fitFcn->GetParameters(par);
backFcn->SetParameters(par);
backFcn->Draw("same");
signalFcn->SetParameters(&par[3]);
signalFcn->Draw("same");
double w=hist4230->GetBinWidth(1);
int integral = backFcn->Integral(3.04,3.17)/w;
int integral2 =signalFcn->Integral(3.04,3.17)/w;
double error_integral2 =signalFcn->IntegralError(3.04,3.17);
cout<<"Integral 1::::::"<<integral<<endl;
cout<<"Integral 2::::::"<<integral2<<endl;
cout<<"Error Integral ::::::"<<error_integral2<<endl;