2 #include "../interface/BayesianFlatPrior.h"
3 #include "RooRealVar.h"
5 #include "RooUniform.h"
6 #include "RooWorkspace.h"
9 #include "../interface/Combine.h"
10 #include "RooStats/BayesianCalculator.h"
11 #include "RooStats/SimpleInterval.h"
12 #include "RooStats/ModelConfig.h"
17 using namespace RooStats;
22 LimitAlgo(
"BayesianSimple specific options")
25 (
"maxDim", boost::program_options::value<int>(&
maxDim_)->default_value(
maxDim_),
"Maximum number of dimensions to try doing the integration")
29 bool BayesianFlatPrior::run(RooWorkspace *
w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &
data,
double &
limit,
double &limitErr,
const double *hint) {
30 RooArgSet poi(*mc_s->GetParametersOfInterest());
32 int dim = poi.getSize();
35 std::cerr <<
"ERROR: Your model has more parameters than the maximum allowed in the BayesianSimple method. \n" <<
36 " N(params) = " << dim <<
", maxDim = " <<
maxDim_ <<
"\n" <<
37 " Please use MarkovChainMC or BayesianToyMC method to compute Bayesian limits instead of BayesianSimple.\n" <<
38 " If you really want to run BayesianSimple, change the value of the 'maxDim' option, \n"
39 " but note that it's really not supposed to work for N(params) above 5 or so " << std::endl;
40 throw std::logic_error(
"Too many parameters for BayesianSimple method. Use MarkovChainMC or BayesianToyMC method to compute Bayesian limits instead.");
43 RooRealVar *
r =
dynamic_cast<RooRealVar *
>(poi.first());
44 double rMax = r->getMax();
45 std::auto_ptr<RooStats::ModelConfig> mc_noNuis(0);
47 mc_noNuis.reset(
new RooStats::ModelConfig(w));
48 mc_noNuis->SetPdf(*mc_s->GetPdf());
49 mc_noNuis->SetObservables(*mc_s->GetObservables());
50 mc_noNuis->SetParametersOfInterest(*mc_s->GetParametersOfInterest());
51 mc_noNuis->SetPriorPdf(*mc_s->GetPriorPdf());
52 mc_s = mc_noNuis.get();
55 BayesianCalculator bcalc(data, *mc_s);
56 bcalc.SetLeftSideTailFraction(0);
57 bcalc.SetConfidenceLevel(
cl);
58 std::auto_ptr<SimpleInterval> bcInterval(bcalc.GetInterval());
59 if (bcInterval.get() == 0)
return false;
60 limit = bcInterval->UpperLimit();
61 if (limit >= 0.5*r->getMax()) {
62 std::cout <<
"Limit " << r->GetName() <<
" < " << limit <<
"; " << r->GetName() <<
" max < " << r->getMax() << std::endl;
63 if (r->getMax()/rMax > 20)
return false;
64 r->setMax(r->getMax()*2);
68 std::cout <<
"\n -- BayesianSimple -- " <<
"\n";
69 std::cout <<
"Limit: " << r->GetName() <<
" < " << limit <<
" @ " <<
cl * 100 <<
"% CL" << std::endl;
73 TCanvas
c1(
"c1",
"c1");
74 std::auto_ptr<RooPlot> bcPlot(bcalc.GetPosteriorPlot(
true, 0.1));
76 c1.Print(
"plots/bc_plot.png");
char data[epos_bytes_allocation]
boost::program_options::options_description options_
virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)