%%cpp -d #include "RooRealVar.h" #include "RooProdPdf.h" #include "RooWorkspace.h" #include "RooDataSet.h" #include "TCanvas.h" #include "TH1.h" using namespace RooFit; using namespace RooStats; RooWorkspace *w1 = new RooWorkspace("w"); w1->factory("Poisson::px(x[150,0,500],sum::splusb(s[0,0,100],b[100,0,300]))"); w1->factory("Poisson::py(y[100,0,500],prod::taub(tau[1.],b))"); w1->factory("Uniform::prior_b(b)"); w1->factory("PROJ::averagedModel(PROD::foo(px|b,py,prior_b),b)"); RooPlot *frame = w1->var("x")->frame(); w1->pdf("averagedModel")->plotOn(frame); w1->pdf("px")->plotOn(frame, LineColor(kRed)); frame->Draw(); w1->var("y")->setVal(100); w1->var("x")->setVal(150); std::unique_ptr cdf{w1->pdf("averagedModel")->createCdf(*w1->var("x"))}; cdf->getVal(); // get ugly print messages out of the way cout << "Hybrid p-value = " << cdf->getVal() << endl; cout << "Z_Gamma Significance = " << PValueToSignificance(1 - cdf->getVal()) << endl; double Z_Bi = NumberCountingUtils::BinomialWithTauObsZ(150, 100, 1); std::cout << "Z_Bi significance estimation: " << Z_Bi << std::endl; %jsroot on gROOT->GetListOfCanvases()->Draw()