2 #include <RooStats/ModelConfig.h>
3 #include <RooStats/HypoTestInverter.h>
4 #include <RooStats/HypoTestInverterResult.h>
5 #include "RooStats/AsymptoticCalculator.h"
6 #include "../interface/AsymptoticNew.h"
7 #include "../interface/Combine.h"
8 #include "../interface/CloseCoutSentry.h"
9 #include "../interface/RooFitGlobalKillSentry.h"
10 #include "../interface/ProfiledLikelihoodRatioTestStatExt.h"
11 #include "../interface/utils.h"
13 using namespace RooStats;
22 LimitAlgo(
"AsymptoticNew specific options"){
24 (
"run", boost::program_options::value<std::string>(&
what_)->default_value(
what_),
"What to run: both (default), observed, expected.")
25 (
"nPoints", boost::program_options::value<int>(&
nscanpoints_)->default_value(
nscanpoints_),
"Number of points in scan for CLs")
26 (
"qtilde", boost::program_options::value<bool>(&
qtilde_)->default_value(
qtilde_),
"Allow only non-negative signal strengths (default is true).")
27 (
"scanMin", boost::program_options::value<double>(&
minrscan_)->default_value(
minrscan_),
"Minimum value for scan in r.")
28 (
"scanMax", boost::program_options::value<double>(&
maxrscan_)->default_value(
maxrscan_),
"Maximum value for scan in r.")
34 throw std::invalid_argument(
"Asymptotic: option 'run' can only be 'observed', 'expected' or 'both' (the default)");
46 bool AsymptoticNew::run(RooWorkspace *
w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &
data,
double &
limit,
double &limitErr,
const double *hint) {
50 std::vector<std::pair<float,float> > expected;
51 expected =
runLimit(w, mc_s, mc_b, data, limit, limitErr, hint);
54 const char *rname = mc_s->GetParametersOfInterest()->first()->GetName();
55 std::cout <<
"\n -- AsymptoticNew -- " <<
"\n";
56 if (
what_ !=
"expected") {
57 printf(
"Observed Limit: %s < %6.4f\n", rname, limit);
59 for (std::vector<std::pair<float,float> >::const_iterator it = expected.begin(), ed = expected.end(); it != ed; ++it) {
60 printf(
"Expected %4.1f%%: %s < %6.4f\n", it->first*100, rname, it->second);
68 std::vector<std::pair<float,float> >
AsymptoticNew::runLimit(RooWorkspace *
w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &
data,
double &
limit,
double &limitErr,
const double *hint) {
70 RooRealVar *poi = (RooRealVar*)mc_s->GetParametersOfInterest()->first();
71 mc_s->SetSnapshot(*poi);
72 double oldval = poi->getVal();
73 poi->setVal(0); mc_b->SetSnapshot(*poi);
77 AsymptoticCalculator * ac =
new RooStats::AsymptoticCalculator(data, *mc_b, *mc_s);
78 AsymptoticCalculator::SetPrintLevel(
verbose>2);
79 ac->SetOneSided(
true);
81 HypoTestInverter calc(*ac);
86 RooStats::HypoTestInverterResult *
r = calc.GetInterval();
90 std::vector<std::pair<float,float> > expected;
91 const double quantiles[5] = { 0.025, 0.16, 0.50, 0.84, 0.975 };
92 const double zvals[5] = { -2, -1, 0, 1, 2 };
94 for (
int iq = 0; iq < 5; ++iq) {
95 limit = r->GetExpectedUpperLimit(zvals[iq]);
98 expected.push_back(std::pair<float,float>(quantiles[iq], limit));
103 if (
what_!=
"expected") {
104 limit = r->UpperLimit();
static void commitPoint(bool expected, float quantile)
Save a point into the output tree. Usually if expected = false, quantile should be set to -1 (except ...
virtual void applyOptions(const boost::program_options::variables_map &vm)
std::vector< std::pair< float, float > > runLimit(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
char data[epos_bytes_allocation]
boost::program_options::options_description options_
virtual void applyDefaultOptions()