# Extended Maximum Likelihood Fit - Number of signal Events

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) ;

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();``````

Any ideas ??

Apart from “42” I don’t know what to say. I don’t even know what the question is. All you provided as a fairly small positive integer and a floating point number. Maybe ask Google? google.ch/?q=1

Axel.

I tried your example in ROOT 6. Seems to me it works fine:

``````\$ root
-----------------------------------------------------------------
| Welcome to ROOT 6.09/01                     http://root.cern.ch |
|                                    (c) 1995-2016, The ROOT Team |
| Built for macosx64                                              |
| From heads/master@v6-09-01-1587-gce992d9, Feb 21 2017, 09:29:21 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'      |
-----------------------------------------------------------------

root [0] 1
(int) 1
root [1]
``````