help ~ the fitting results~why the square of the error is less than the number of signal?
nsig 89.1349±9.42376
the fitting status is ok .
using namespace std;
gSystem->Load(“libRooFit”);
#include"/workfs/bes/songqq/plotstyle/bes3plotstyle.c"
using namespace RooFit;
void fit3pi(){
SetPrelimStyle();
SetStyle();
gStyle->SetOptStat(0);
gStyle->SetPalette(1);
gStyle->SetFrameBorderMode(0);
gStyle->SetCanvasBorderMode(0);
gStyle->SetPadBorderMode(0);
gStyle->SetPadColor(0);
gStyle->SetCanvasColor(0);
gStyle->SetStatColor(0);
gStyle->SetTitleFillColor(0);
gStyle->SetNdivisions(509,"x");
//// define the different variables
TFile* f_data = new TFile("/scratchfs/bes/songqq/DATA/4230@664/etajpsi/eta3pi/eta3pi.root");
TTree *t_d = (TTree*)gDirectory->Get("tree");
gROOT->cd();
TTree *t_data = t_d->CopyTree("abs(m2mu-3.097)<0.03 && chi1<80");
RooRealVar val("m3pi","m3p",0.45,0.65) ;
RooDataSet data("data","dat",t_data,val);
TFile* f_mc = new TFile("/scratchfs/bes/songqq/MC/ANA/4230@664/etajpsi/eta3pi/mu/in_e3pimu_01.root");
TTree* t_mc1 = (TTree*)gDirectory->Get("tree");
gROOT->cd();
TTree* t_mc = t_mc1->CopyTree("abs(m2mu-3.097)<0.03&&chi1<80");
RooDataSet sigset("sigset", "sigset", t_mc, val);
RooKeysPdf sigPdf("sigPdf", "sigpdf", val, sigset, RooKeysPdf::MirrorBoth, 1);
RooRealVar mean("mean","Mean of Gaussian",0.0001,-0.02,0.02) ;
RooRealVar sigma("sigma","Width of Gaussian",0.0001,0.00,0.03) ;
RooGaussian gauss("gauss","gauss",val,mean,sigma);
val.setBins(10000,"cache");
RooFFTConvPdf sig("sig", "MC (X) gauss", val, sigPdf, gauss, 2) ;
sig.setBufferFraction(0.2);
sig.setBufferStrategy(2);
RooRealVar co1("co1","coefficienct #1",59,-100, 100);
RooRealVar co2("co2","coefficienct #2",14,-50, 50);
RooPolynomial bkg("bkg", "background p.d.f.", val, RooArgList(co1));
RooRealVar nsig("nsig", " ", 80 , 0, 120);
RooRealVar nbkg("nbkg", " ", 2, 0, 20);
RooAddPdf sum("sum", "sum", RooArgList(sig,bkg), RooArgList(nsig,nbkg));
sum.fitTo(data,Extended(kTRUE));
RooPlot *xframe=val.frame();
data.plotOn(xframe,Binning(50),MarkerStyle(20));
sum.plotOn(xframe,LineColor(1));
sum.plotOn(xframe,Components(bkg),LineStyle(4),LineColor(4), LineWidth(3));
sum.plotOn(xframe,Components(sig),LineStyle(2), LineColor(2), LineWidth(3));
xframe->Draw();
xframe->SetXTitle("M(#pi^{+}#pi^{-}#gamma#gamma)");
// calculate chisq for check the fit quality
RooCurve curve = (RooCurve)xframe->getObject(1);
//*****************************************************************
RooHist histo = (RooHist)xframe->getHist(“h_data”); //**
//*****************************************************************
cout <<"histo = "<< histo->GetN() << endl;
cout << “chisquare==” << curve->chiSquare(*histo, 5) <<endl;
TPaveText *pt = new TPaveText(0.12,0.55,0.52,0.95,"BRNDC");
pt->SetBorderSize(1);
pt->SetFillColor(10);
pt->SetTextAlign(12);
pt->SetTextSize(0.05);
TString Par1V = Form("%5.0f", nbkg.getVal() );
TString Par1E = Form("%3.0f", nbkg.getError() );
TString Par1 = "N_{bkg} =" + Par1V + "#pm" + Par1E;
TString Par2V = Form("%5.0f", nsig.getVal() );
TString Par2E = Form("%3.0f", nsig.getError() );
TString Par2 = "N_{sig} =" + Par2V + "#pm" + Par2E;
TString Par6 = Form("#chi^{2}/ndf = %.0f/%.0d", curve->chiSquare(*histo, 5)*(histo->GetN()-5),histo->GetN()-5);
TString Par3V = Form("%4.2f", mean.getVal()*1000.00 );
TString Par3E = Form("%3.2f", mean.getError()*1000.00 );
TString Par3 = "#mu =" + Par3V + "#pm" + Par3E + " MeV" ;
TString Par4V = Form("%4.2f", sigma.getVal()*1000.00 );
TString Par4E = Form("%4.2f", sigma.getError()*1000.00 );
TString Par4 = "#sigma =" + Par4V + "#pm" + Par4E + " MeV" ;
TText *text;
text = pt->AddText(Par1);
text = pt->AddText(Par2);
text = pt->AddText(Par3);
text = pt->AddText(Par4);
pt->Draw();
}