{ using namespace RooFit; using namespace RooStats; RooRealVar x("x","dummy obs",0.,1.); RooUniform pdf_x("pdf_x","dummy pdf of x",x); RooRealVar s("s","# of signal",0.,10.); RooRealVar b("b","# of background",3.2,0.,10.); RooAddPdf pdf_splusb("pdf_splusb","total PDF",RooArgList(pdf_x,pdf_x),RooArgList(s,b)); RooUniform prior_s("prior_s","prior for signal",s); RooGaussian prior_b("prior_b","priot for background",b,RooConst(3.2),RooConst(1.4)); RooProdPdf model("model","constrained model",pdf_splusb,prior_b); RooWorkspace wspace("wspace"); ModelConfig cfg(&wspace); cfg.SetPdf(model); cfg.SetParametersOfInterest(s); cfg.SetPriorPdf(prior_s); cfg.SetNuisanceParameters(b); RooPlot *frame = s.frame(); for (int n=0; n<=4; n++) { RooRealVar nevt("nevt","# of observed event",n); RooDataSet data("data","data",RooArgSet(x,nevt),WeightVar("nevt")); data.add(RooArgSet(x),n); BayesianCalculator bcalc(data,cfg); RooAbsPdf *posterior = bcalc.GetPosteriorPdf(); posterior->plotOn(frame, LineColor(kRed+n),LineWidth(3)); } frame->Draw(); }