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
BayesianToyMC Class Reference

#include <BayesianToyMC.h>

Inheritance diagram for BayesianToyMC:
LimitAlgo

Public Member Functions

virtual void applyOptions (const boost::program_options::variables_map &vm)
 
 BayesianToyMC ()
 
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)
 
- Public Member Functions inherited from LimitAlgo
virtual void applyDefaultOptions ()
 
 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 float hintSafetyFactor_ = 5.
 Safety factor for hint (integrate up to this number of times the hinted limit) More...
 
static std::string integrationType_ = "toymc"
 numerical integration algorithm More...
 
static int numIters_ = 1000
 number of iterations for each toy mc computation More...
 
static unsigned int tries_ = 1
 number of toy mc computations to run More...
 

Additional Inherited Members

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

Detailed Description

Interface to BayesianCalculator used with toymc algorithms

Author
Giovanni Petrucciani (UCSD)

Definition at line 13 of file BayesianToyMC.h.

Constructor & Destructor Documentation

BayesianToyMC::BayesianToyMC ( )

Definition at line 21 of file BayesianToyMC.cc.

References hintSafetyFactor_, integrationType_, numIters_, LimitAlgo::options_, and tries_.

21  :
22  LimitAlgo("BayesianToyMC specific options")
23 {
24  options_.add_options()
25  ("integrationType", boost::program_options::value<std::string>(&integrationType_)->default_value(integrationType_), "Integration algorithm to use")
26  ("tries", boost::program_options::value<unsigned int>(&tries_)->default_value(tries_), "Number of times to run the ToyMC on the same data")
27  ("numIters,i", boost::program_options::value<int>(&numIters_)->default_value(numIters_), "Number of iterations or calls used within iteration (0=ROOT Default)")
28  ("hintSafetyFactor",
29  boost::program_options::value<float>(&hintSafetyFactor_)->default_value(hintSafetyFactor_),
30  "set range of integration equal to this number of times the hinted limit")
31  ;
32 }
static int numIters_
number of iterations for each toy mc computation
Definition: BayesianToyMC.h:26
static unsigned int tries_
number of toy mc computations to run
Definition: BayesianToyMC.h:28
LimitAlgo()
Definition: LimitAlgo.h:19
static std::string integrationType_
numerical integration algorithm
Definition: BayesianToyMC.h:24
boost::program_options::options_description options_
Definition: LimitAlgo.h:32
static float hintSafetyFactor_
Safety factor for hint (integrate up to this number of times the hinted limit)
Definition: BayesianToyMC.h:30

Member Function Documentation

void BayesianToyMC::applyOptions ( const boost::program_options::variables_map &  vm)
virtual

Reimplemented from LimitAlgo.

Definition at line 34 of file BayesianToyMC.cc.

References gather_cfg::cout, integrationType_, numIters_, tries_, and withSystematics.

34  {
35  if (!withSystematics) {
36  std::cout << "BayesianToyMC: when running with no systematics, BayesianToyMC is identical to BayesianSimple." << std::endl;
37  tries_ = 1;
38  numIters_ = 0;
39  integrationType_ = "";
40  }
41 }
bool withSystematics
Definition: Combine.cc:68
static int numIters_
number of iterations for each toy mc computation
Definition: BayesianToyMC.h:26
static unsigned int tries_
number of toy mc computations to run
Definition: BayesianToyMC.h:28
static std::string integrationType_
numerical integration algorithm
Definition: BayesianToyMC.h:24
tuple cout
Definition: gather_cfg.py:121
virtual const std::string& BayesianToyMC::name ( void  ) const
inlinevirtual

Implements LimitAlgo.

Definition at line 18 of file BayesianToyMC.h.

18  {
19  static const std::string name("BayesianToyMC");
20  return name;
21  }
virtual const std::string & name() const
Definition: BayesianToyMC.h:18
bool BayesianToyMC::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 42 of file BayesianToyMC.cc.

References cl, gather_cfg::cout, hintSafetyFactor_, i, integrationType_, utils::makeNuisancePdf(), numIters_, alignCSCRings::r, mathSSE::sqrt(), tries_, and withSystematics.

42  {
43  RooArgSet poi(*mc_s->GetParametersOfInterest());
44 
45  RooRealVar *r = dynamic_cast<RooRealVar *>(poi.first());
46  if ((hint != 0) && (*hint > r->getMin())) {
47  r->setMax(hintSafetyFactor_*(*hint));
48  }
49  double rMax = r->getMax();
50 
51  std::auto_ptr<RooStats::ModelConfig> mc_noNuis(0);
52  if (!withSystematics && mc_s->GetNuisanceParameters() != 0) {
53  mc_noNuis.reset(new RooStats::ModelConfig(w));
54  mc_noNuis->SetPdf(*mc_s->GetPdf());
55  mc_noNuis->SetObservables(*mc_s->GetObservables());
56  mc_noNuis->SetParametersOfInterest(*mc_s->GetParametersOfInterest());
57  mc_noNuis->SetPriorPdf(*mc_s->GetPriorPdf());
58  mc_s = mc_noNuis.get();
59  }
60  std::auto_ptr<RooAbsPdf> nuisancePdf;
61  for (;;) {
62  limit = 0; limitErr = 0; bool rerun = false;
63  for (unsigned int i = 0; i < tries_; ++i) {
64  BayesianCalculator bcalc(data, *mc_s);
65  bcalc.SetLeftSideTailFraction(0);
66  bcalc.SetConfidenceLevel(cl);
67  if (!integrationType_.empty()) bcalc.SetIntegrationType(integrationType_.c_str());
68  if (numIters_) bcalc.SetNumIters(numIters_);
69  if (integrationType_ == "toymc") {
70  if (nuisancePdf.get() == 0) nuisancePdf.reset(utils::makeNuisancePdf(*mc_s));
71  bcalc.ForceNuisancePdf(*nuisancePdf);
72  }
73  // get the interval
74  std::auto_ptr<SimpleInterval> bcInterval(bcalc.GetInterval());
75  if (bcInterval.get() == 0) return false;
76  double lim = bcInterval->UpperLimit();
77  // check against bound
78  if (lim >= 0.5*r->getMax()) {
79  std::cout << "Limit " << r->GetName() << " < " << lim << "; " << r->GetName() << " max < " << r->getMax() << std::endl;
80  if (r->getMax()/rMax > 20) return false;
81  r->setMax(r->getMax()*2);
82  rerun = true; break;
83  }
84  // add to running sum(x) and sum(x2)
85  limit += lim;
86  limitErr += lim*lim;
87  if (tries_ > 1 && verbose > 1) std::cout << " - limit from try " << i << ": " << lim << std::endl;
88  }
89  if (rerun) continue;
90  limit /= tries_;
91  limitErr = (tries_ > 1 ? std::sqrt((limitErr/tries_ - limit*limit)/((tries_-1)*tries_)) : 0);
92  if (verbose > -1) {
93  std::cout << "\n -- BayesianToyMC -- " << "\n";
94  if (limitErr > 0) {
95  std::cout << "Limit: " << r->GetName() << " < " << limit << " +/- " << limitErr << " @ " << cl * 100 << "% CL" << std::endl;
96  } else {
97  std::cout << "Limit: " << r->GetName() << " < " << limit << " @ " << cl * 100 << "% CL" << std::endl;
98  }
99  }
100  break;
101  }
102  return true;
103 }
int i
Definition: DBlmapReader.cc:9
bool withSystematics
Definition: Combine.cc:68
static int numIters_
number of iterations for each toy mc computation
Definition: BayesianToyMC.h:26
RooAbsPdf * makeNuisancePdf(RooStats::ModelConfig &model, const char *name="nuisancePdf")
Definition: utils.cc:200
static unsigned int tries_
number of toy mc computations to run
Definition: BayesianToyMC.h:28
T sqrt(T t)
Definition: SSEVec.h:46
float cl
Definition: Combine.cc:71
static std::string integrationType_
numerical integration algorithm
Definition: BayesianToyMC.h:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
T w() const
static float hintSafetyFactor_
Safety factor for hint (integrate up to this number of times the hinted limit)
Definition: BayesianToyMC.h:30

Member Data Documentation

float BayesianToyMC::hintSafetyFactor_ = 5.
staticprivate

Safety factor for hint (integrate up to this number of times the hinted limit)

Definition at line 30 of file BayesianToyMC.h.

Referenced by BayesianToyMC(), and run().

std::string BayesianToyMC::integrationType_ = "toymc"
staticprivate

numerical integration algorithm

Definition at line 24 of file BayesianToyMC.h.

Referenced by applyOptions(), BayesianToyMC(), and run().

int BayesianToyMC::numIters_ = 1000
staticprivate

number of iterations for each toy mc computation

Definition at line 26 of file BayesianToyMC.h.

Referenced by applyOptions(), BayesianToyMC(), and run().

unsigned int BayesianToyMC::tries_ = 1
staticprivate

number of toy mc computations to run

Definition at line 28 of file BayesianToyMC.h.

Referenced by applyOptions(), BayesianToyMC(), and run().