RooFit categories and RooSimultaneous

Hello,

I have a root-tree that I use to create a RooDataSet.

The branches I use, let’s say, are called mass and likelihood. I want to do a simultaneous mass fit to two sub-samples of the RooDataSet: one with likelihood > cut and the other with likelihood < cut.

I understand that I can make an intermediate step, re-create a Tree with additional branch that would be a discrete 0 or 1, and read it as a RooCatergory when I create the RooDataSet.

But is there an easier way of doing it? There are many advantages to doing this in one program…

Thanks,
Yuri

Hi Yuri,

You don’t have to recreate a tree, you just need to add a column to your
dataset that stored the decision of your cut in a RooCategory. Given

RooRealVar* mass, likelihood // variables in dataset, assumed to be declared
RooDataSet
d // data with observables ‘mass’ and ‘likelihood’, defined earlier

you do something like this

// Define a real->category mapping splitting sample in “sampleA” and "sampleB"
RooThresholdCategory thresh_func(“tresh”,“thresh”,*likelihood,“SampleA”) ;
thresh_func.addThreshold(cutValue,“SampleB”) ;

// Add category to your data, return value is RooCategory with same states
// defined as input function
RooCategory* thresh = (RooCategory*) data->addColumn(thresh_func) ;

Then proceed to build a RooSimultaneous p.d.f with index category ‘thresh’

Wouter

[quote=“Wouter Verkerke”]
// Add category to your data, return value is RooCategory with same states
// defined as input function
RooCategory* thresh = (RooCategory*) data->addColumn(thresh_func) ;

Then proceed to build a RooSimultaneous p.d.f with index category ‘thresh’

Wouter[/quote]

but that does not work - that was one of the first things I tried. Problem is, Roo Simultaneous asks for RooAbsCategoryLValue&, and RooThresholdCategory does not inherit from it, unlike RooCategory.

Yuri

P.S. Any ideas about my other post? Subject “reading dataset from a tree”

Hi Yuri,

You should give RooSimultaneous the ‘tresh’ object return by addColumn()
rather than the thres_func object.

Wouter

Wouter,

thanks so much, the fit now works very well. Problem is, I’m now having trouble plotting the result. I want to plot m3 distributions passing and failing the cut with fit results overlaid. I get the data to plot correctly, but for the fit result I only get the “fail” component. Snippet of my code is below

RooRealVar efficiency(“efficiency”,“efficiency”,0.9,-1.0,1.0);
RooRealVar nSig(“nSig”,“nSig”,1000.0,-10.0,1000000.0);
RooFormulaVar nSigpass(“nSigpass”,“nSigefficiency", RooArgList(nSig,efficiency) ) ;
RooFormulaVar nSigfail(“nSigfail”,"nSig
(1.0 - efficiency)”, RooArgList(nSig,efficiency) ) ;

RooArgList componentspass(sigShapePdf,bkgShapePdf);
RooArgList yieldspass(nSigpass, nBkgpass);
RooAddPdf sumpass(“sumpass”,“fixed extended sum pdf”, componentspass, yieldspass);

RooArgList componentsfail(sigShapeFPdf,bkgShapePdf );
RooArgList yieldsfail(nSigfail, nBkgfail );
RooAddPdf sumfail(“sumfail”,“fixed extended sum pdf”, componentsfail, yieldsfail);

RooThresholdCategory pf_cut("pf_cut","pf_cut",p_r9,"pass",0);
pf_cut.addThreshold(0.9,"fail",1);

RooCategory *MyfitCat = (RooCategory*) data->addColumn(pf_cut);
RooSimultaneous totalPdf("totalPdf","totalPdf",*MyfitCat);
totalPdf.addPdf(sumpass,"pass");
totalPdf.addPdf(sumfail,"fail");

    TCanvas *cc = new TCanvas();
    cc->Divide(1,2);
    cc->cd(1);
    RooPlot* frame1 = m3.frame(60);
frame1->SetTitle("");
data->plotOn(frame1,Cut("pf_cut==0"));
MyfitCat->setLabel("pass");
totalPdf.plotOn(frame1,Slice(*MyfitCat),ProjWData(m3,*data)) ;
    totalPdf.plotOn(frame1,Slice(*MyfitCat),Components(bkgShapePdf),LineStyle(kDashed),ProjWData(m3,*data)) ;
frame1->Draw("e0");

    cc->cd(2);
    RooPlot* frame2 = m3.frame(60);
frame2->SetTitle("");
data->plotOn(frame2,Cut("pf_cut==1"));
MyfitCat->setLabel("fail");
totalPdf.plotOn(frame2,Slice(*MyfitCat),ProjWData(m3,*data)) ;
    totalPdf.plotOn(frame2,Slice(*MyfitCat),Components(bkgShapePdf),LineStyle(kDashed),ProjWData(m3,*data)) ;
frame2->Draw("e0");
1 Like

Hi Yury,

Sorry for the late reply, I was offline last week.

I see nothing obviously wrong with your macro but I cannot reproduce
your problem as the macro below is incomplete (i.e. I miss data and definition of m3).
If you send me a self-contained example I will have look.

Wouter