CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Private Attributes
AsymptoticNew Class Reference

#include <AsymptoticNew.h>

Inheritance diagram for AsymptoticNew:
LimitAlgo

Public Member Functions

virtual void applyDefaultOptions ()
 
virtual void applyOptions (const boost::program_options::variables_map &vm)
 
 AsymptoticNew ()
 
virtual const std::string & name () const
 
virtual bool run (RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
 
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)
 
- Public Member Functions inherited from LimitAlgo
 LimitAlgo ()
 
 LimitAlgo (const char *desc)
 
const
boost::program_options::options_description & 
options () const
 
virtual void setNToys (const int)
 
virtual void setToyNumber (const int)
 
virtual ~LimitAlgo ()
 

Static Private Attributes

static double maxrscan_ = 20.
 
static double minrscan_ = 0.
 
static int nscanpoints_ = 20
 
static bool qtilde_ = true
 
static double rValue_
 
static std::string what_ = "both"
 

Additional Inherited Members

- Protected Attributes inherited from LimitAlgo
boost::program_options::options_description options_
 

Detailed Description

new CLs asymptotic limits

Author
Nicholas Wardle (mostly taken from Asymptotic class)

Definition at line 16 of file AsymptoticNew.h.

Constructor & Destructor Documentation

AsymptoticNew::AsymptoticNew ( )

Definition at line 21 of file AsymptoticNew.cc.

References maxrscan_, minrscan_, nscanpoints_, LimitAlgo::options_, qtilde_, and what_.

21  :
22 LimitAlgo("AsymptoticNew specific options"){
23  options_.add_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.")
29  ;
30 }
static int nscanpoints_
Definition: AsymptoticNew.h:28
static double minrscan_
Definition: AsymptoticNew.h:30
static bool qtilde_
Definition: AsymptoticNew.h:29
static std::string what_
Definition: AsymptoticNew.h:26
LimitAlgo()
Definition: LimitAlgo.h:19
static double maxrscan_
Definition: AsymptoticNew.h:30
boost::program_options::options_description options_
Definition: LimitAlgo.h:32

Member Function Documentation

void AsymptoticNew::applyDefaultOptions ( )
virtual

Reimplemented from LimitAlgo.

Definition at line 38 of file AsymptoticNew.cc.

References maxrscan_, minrscan_, nscanpoints_, qtilde_, and what_.

38  {
39  what_ = "observed";
40  nscanpoints_ = 20;
41  qtilde_ = true;
42  minrscan_=0.;
43  maxrscan_=20.;
44 }
static int nscanpoints_
Definition: AsymptoticNew.h:28
static double minrscan_
Definition: AsymptoticNew.h:30
static bool qtilde_
Definition: AsymptoticNew.h:29
static std::string what_
Definition: AsymptoticNew.h:26
static double maxrscan_
Definition: AsymptoticNew.h:30
void AsymptoticNew::applyOptions ( const boost::program_options::variables_map &  vm)
virtual

Reimplemented from LimitAlgo.

Definition at line 32 of file AsymptoticNew.cc.

References what_.

32  {
33  if (what_ != "observed" && what_ != "expected" && what_ != "both")
34  throw std::invalid_argument("Asymptotic: option 'run' can only be 'observed', 'expected' or 'both' (the default)");
35 
36 }
static std::string what_
Definition: AsymptoticNew.h:26
virtual const std::string& AsymptoticNew::name ( void  ) const
inlinevirtual

Implements LimitAlgo.

Definition at line 23 of file AsymptoticNew.h.

23 { static std::string name_ = "AsymptoticNew"; return name_; }
bool AsymptoticNew::run ( RooWorkspace *  w,
RooStats::ModelConfig *  mc_s,
RooStats::ModelConfig *  mc_b,
RooAbsData &  data,
double &  limit,
double &  limitErr,
const double *  hint 
)
virtual

Implements LimitAlgo.

Definition at line 46 of file AsymptoticNew.cc.

References gather_cfg::cout, DEBUG, runLimit(), dqm::qstatus::WARNING, and what_.

46  {
48  if (verbose > 0) std::cout << "Will compute " << what_ << " limit(s) " << std::endl;
49 
50  std::vector<std::pair<float,float> > expected;
51  expected = runLimit(w, mc_s, mc_b, data, limit, limitErr, hint);
52 
53  if (verbose >= 0) {
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);
58  }
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);
61  }
62  std::cout << std::endl;
63  }
64 
65  return true;
66 }
#define DEBUG
static const int WARNING
static std::string what_
Definition: AsymptoticNew.h:26
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)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
T w() const
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 
)

Definition at line 68 of file AsymptoticNew.cc.

References Combine::commitPoint(), maxrscan_, minrscan_, nscanpoints_, qtilde_, alignCSCRings::r, and what_.

Referenced by run().

68  {
69 
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);
74  poi->setVal(oldval);
75 
76  // Set up asymptotic calculator
77  AsymptoticCalculator * ac = new RooStats::AsymptoticCalculator(data, *mc_b, *mc_s);
78  AsymptoticCalculator::SetPrintLevel(verbose>2);
79  ac->SetOneSided(true);
80  ac->SetQTilde(qtilde_);
81  HypoTestInverter calc(*ac);
82  calc.SetVerbose(verbose>2);
83  calc.UseCLs(true);
84 
85  calc.SetFixedScan(nscanpoints_,minrscan_,maxrscan_);
86  RooStats::HypoTestInverterResult * r = calc.GetInterval();
87 
88  // Expected Median + bands
89  // bands will be based on Z-values
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 };
93 
94  for (int iq = 0; iq < 5; ++iq) {
95  limit = r->GetExpectedUpperLimit(zvals[iq]);
96  limitErr = 0;
97  Combine::commitPoint(true, quantiles[iq]);
98  expected.push_back(std::pair<float,float>(quantiles[iq], limit));
99  }
100 
101 
102  // Observed Limit
103  if (what_!="expected") {
104  limit = r->UpperLimit();
105  } else {
106  limit = 0 ;
107  }
108 
109  return expected;
110 
111 }
static int nscanpoints_
Definition: AsymptoticNew.h:28
static double minrscan_
Definition: AsymptoticNew.h:30
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 ...
Definition: Combine.cc:557
static bool qtilde_
Definition: AsymptoticNew.h:29
static std::string what_
Definition: AsymptoticNew.h:26
static double maxrscan_
Definition: AsymptoticNew.h:30
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

double AsymptoticNew::maxrscan_ = 20.
staticprivate

Definition at line 30 of file AsymptoticNew.h.

Referenced by applyDefaultOptions(), AsymptoticNew(), and runLimit().

double AsymptoticNew::minrscan_ = 0.
staticprivate

Definition at line 30 of file AsymptoticNew.h.

Referenced by applyDefaultOptions(), AsymptoticNew(), and runLimit().

int AsymptoticNew::nscanpoints_ = 20
staticprivate

Definition at line 28 of file AsymptoticNew.h.

Referenced by applyDefaultOptions(), AsymptoticNew(), and runLimit().

bool AsymptoticNew::qtilde_ = true
staticprivate

Definition at line 29 of file AsymptoticNew.h.

Referenced by applyDefaultOptions(), AsymptoticNew(), and runLimit().

double AsymptoticNew::rValue_
staticprivate

Definition at line 27 of file AsymptoticNew.h.

std::string AsymptoticNew::what_ = "both"
staticprivate

Definition at line 26 of file AsymptoticNew.h.

Referenced by applyDefaultOptions(), applyOptions(), AsymptoticNew(), run(), and runLimit().