{ using namespace RooFit; using namespace RooStats; const char* infile = "CombinedModel.root"; const char* workspaceName = "w"; const char* modelConfigName = "ModelConfig"; const char* dataName = "data"; ///////////////////////////////////////////////////////////// // First part is just to access the workspace file //////////////////////////////////////////////////////////// // Check if example input file exists TFile *file = TFile::Open(infile); // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); // get the modelConfig out of the file ModelConfig* mc = (ModelConfig*) w->obj(modelConfigName); // get the modelConfig out of the file RooAbsData* data = w->data(dataName); BayesianCalculator bayesianCalc(*data,*mc); bayesianCalc.SetConfidenceLevel(0.683); // 68% interval // set the type of interval (not really needed for central which is the default) bayesianCalc.SetLeftSideTailFraction(0.5); // for central interval //bayesianCalc.SetLeftSideTailFraction(0.); // for upper limit //bayesianCalc.SetShortestInterval(); // for shortest interval // set the integration type (not really needed for the default ADAPTIVE) // possible alternative values are "VEGAS" , "MISER", or "PLAIN" (MC integration from libMathMore) // "TOYMC" (toy MC integration, work when nuisances exist and they have a constraints pdf) TString integrationType = ""; // this is needed if using TOYMC if (integrationType.Contains("TOYMC") ) { RooAbsPdf * nuisPdf = RooStats::MakeNuisancePdf(*mc, "nuisance_pdf"); if (nuisPdf) bayesianCalc.ForceNuisancePdf(*nuisPdf); } //bayesianCalc.SetIntegrationType(integrationType); // compute interval by scanning the posterior function // it is done by default when computing shortest intervals bayesianCalc.SetScanOfPosterior(100); RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first(); SimpleInterval* interval = bayesianCalc.GetInterval(); if (!interval) { cout << "Error computing Bayesian interval - exit " << endl; return; } double lowerLimit = interval->LowerLimit(); double upperLimit = interval->UpperLimit(); cout << "\n68% interval on " <GetName()<<" is : ["<< lowerLimit << ", "<< upperLimit <<"] "<Draw(); }