Dear All,
I’m a roofit/root beginner and I’m having a difficulty extracting the number of Signal of Events after a fit.
I wanted to fit a Mass distribution to get the number of signal events in a certain Gaussian peak and the number of background events under it.
To do so, it was suggested to try a maximum likelihood fit which fits not only the shape but the number of events as well.
By setting initially the number of signal events and background events as follow : [See full code down below ]
RooRealVar nsig("nsig","signal events",0,7000);
RooRealVar nbkg("nbkg","signal background events",0,1600000);
I’m able with these numbers to have a “decent” fit [See Pic attached]
In the end, I get the number of Signal of events as the same number I put initially 7000. I know for sure from another tool that the number of signal events should be around 20800.
So my question is : Am I doing something wrong? Did I misunderstood something?
How can I get the number of signal/background events automatically after the Likelihood fit.?
RooRealVar x("x","MM",3.04,3.19) ;
RooDataHist dh("dh","dataset",x,h);
RooPlot* frame = x.frame(Title("J/#psi")) ;
dh.plotOn(frame) ;
RooRealVar mean1("mean1","mean of gaussians",3.095);
RooRealVar sigma1("sigma1","width of gaussians",0.0047);
RooGaussian sig1("sig1","Signal component 1",x,mean1,sigma1);
RooRealVar a0("a0","a0",0.0005,-2.,1.) ;
RooRealVar a1("a1","a1",-0.0002,-2.,1.) ;
RooRealVar a2("a2","a2",0.0005,-1.,1.) ;
RooRealVar a3("a3","a2",0.0005,-1.,1.) ;
RooChebychev bkg("bkg","background maximum Likelihood fitp.d.f.",x,RooArgList(a0,a1,a2)) ;
RooRealVar nsig("nsig","signal events",0,7000);
RooRealVar nbkg("nbkg","signal background events",0,1600000);
RooExtendPdf esig("esig","esig",sig1,nsig) ;
RooExtendPdf ebkg("ebkg","ebkg",bkg,nbkg) ;
RooAddPdf all("all","all",RooArgList(esig,ebkg)) ;
RooFitResult* r = all.fitTo(dh,Extended(kTRUE),Save());
all.plotOn(frame);
all.plotOn(frame,Components(bkg),LineStyle(kDashed));
frame->SetMinimum(45000);
frame->SetMaximum(70000);
frame->Draw();