{ using namespace RooStats; double credLevel= .68; double size = 1.-credLevel; RooWorkspace *w = new RooWorkspace("CMGWs","CMG workspace"); w.factory("Gaussian::signal(imass[110,120],sigmean[115],sigwidth[1])"); w.factory("Exponential::background(imass,exppar[-.1])"); w.factory("SUM::model(nsig[50,0.1,120]*signal,nbkg[1000,0,10000]*background)"); w.factory("Uniform::priorPOI(nsig)"); //prior1 w.factory("GenericPdf::priorPOI2('1/sqrt(@0)',nsig)"); //prior2 // Get the interesting objects RooAbsPdf* model = w.pdf("model"); RooRealVar* nsig = w.var("nsig"); // Create an example dataset (binned is fast..) RooDataHist* data = model->generateBinned(*w.var("imass")); // Model Config 1 ModelConfig modelConfig(new RooWorkspace()); modelConfig.SetPdf(*model); modelConfig.SetParametersOfInterest(RooArgSet(*nsig)); modelConfig.SetPriorPdf(*w.pdf("priorPOI")); // example use of MCMCInterval MCMCCalculator mccalc(*data, modelConfig); mccalc.SetTestSize(size); // special options mccalc.SetNumBins(40); // bins used internally for representing posterior mccalc.SetNumBurnInSteps(500); // first N steps to be ignored as burn-in mccalc.SetNumIters(500000); // how long to run chain mccalc.SetLeftSideTailFraction(0.5); // for central interval MCMCInterval* interval = mccalc.GetInterval(); double cl = mccalc.ConfidenceLevel(); cout << "* " << cl <<" CL central interval: [ " << interval->LowerLimit(*nsig) << " - " << interval->UpperLimit(*nsig) << " ]" << endl; MCMCIntervalPlot plot(*interval);plot.SetLineColor(kBlue);plot->SetLineWidth(2); modelConfig.SetPriorPdf(*w.pdf("priorPOI2")); MCMCCalculator mccalcsqrt(*data, modelConfig); mccalcsqrt.SetTestSize(size); // special options mccalcsqrt.SetNumBins(40); // bins used internally for representing posterior mccalcsqrt.SetNumBurnInSteps(500); // first N steps to be ignored as burn-in mccalcsqrt.SetNumIters(500000); // how long to run chain mccalcsqrt.SetLeftSideTailFraction(0.5); // for central interval interval = mccalcsqrt.GetInterval(); double cl = mccalcsqrt.ConfidenceLevel(); cout << "* " << cl <<" CL central interval: [ " << interval->LowerLimit(*nsig) << " - " << interval->UpperLimit(*nsig) << " ]" << endl; MCMCIntervalPlot plotsqrt(*interval);plotsqrt.SetLineColor(kBlue);plotsqrt->SetLineWidth(2); TCanvas c1("MCMCCR","MCMC Calculator Result",800,400); c1.Divide(2,1); c1.cd(1);plot->Draw(); c1.cd(2);plotsqrt->Draw(); }