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