CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HybridNew.h
Go to the documentation of this file.
1 #ifndef HiggsAnalysis_CombinedLimit_HybridNew_h
2 #define HiggsAnalysis_CombinedLimit_HybridNew_h
3 
11 #include "../interface/LimitAlgo.h"
12 #include <algorithm>
13 #include <RooStats/ModelConfig.h>
14 #include <RooStats/HybridCalculator.h>
15 #include <RooStats/ToyMCSampler.h>
16 
17 class RooRealVar;
18 class TGraphErrors;
19 class TDirectory;
20 
21 class HybridNew : public LimitAlgo {
22 public:
23  HybridNew() ;
24  virtual void applyOptions(const boost::program_options::variables_map &vm) ;
25  virtual void applyDefaultOptions() ;
26 
27  virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
28  virtual bool runLimit(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
29  virtual bool runSignificance(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
30  virtual bool runSinglePoint(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
31  virtual bool runTestStatistics(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint);
32  virtual const std::string & name() const {
33  static const std::string name("HybridNew");
34  return name;
35  }
36 
37  // I don't understand why if it's declared private it gcc does not like it
39 private:
41  static unsigned int nToys_;
43  static bool CLs_;
44  static std::string rule_, testStat_;
45  static bool reportPVal_;
47  static std::string rValue_; // name=value,name=value,... or just value for a 1D model
48  static RooArgSet rValues_; // values of the parameters
49  static unsigned int iterations_;
51  static std::string gridFile_;
54  static bool fullBToys_;
55  static bool fullGrid_;
56  static bool saveGrid_;
57  static bool noUpdateGrid_;
58  static unsigned int nCpu_, fork_;
60  static std::string algo_;
61  static std::string plot_;
62  static std::string minimizerAlgo_;
63  static float minimizerTolerance_;
64 
65  static bool optimizeProductPdf_;
67  static bool newToyMCSampler_;
68  static bool rMinSet_;
69  static bool rMaxSet_;
70  float mass_;
71 
72  // graph, used to compute the limit, not just for plotting!
73  std::auto_ptr<TGraphErrors> limitPlot_;
74 
75  // performance counter: remember how many toys have been thrown
76  unsigned int perf_totalToysRun_;
77 
78  //----- extra variables used for cross-checking the implementation of frequentist toy tossing in RooStats
79  // mutable RooAbsData *realData_;
80  // std::auto_ptr<RooAbsCollection> snapGlobalObs_;
81 
82  struct Setup {
83  RooStats::ModelConfig modelConfig, modelConfig_bonly;
84  std::auto_ptr<RooStats::TestStatistic> qvar;
85  std::auto_ptr<RooStats::ToyMCSampler> toymcsampler;
86  std::auto_ptr<RooStats::ProofConfig> pc;
87  RooArgSet cleanupList;
88  };
89 
90  void validateOptions() ;
91 
92  // make sure our rValues_ is contains all pois in the model, and does not contain anything else
93  void setupPOI(RooStats::ModelConfig *mc_s) ;
94 
96  std::pair<double,double> eval(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, const RooAbsCollection & rVals, bool adaptive=false, double clsTarget=-1) ;
98  std::pair<double,double> eval(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double rVal, bool adaptive=false, double clsTarget=-1) ;
99 
101  std::auto_ptr<RooStats::HybridCalculator> create(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, const RooAbsCollection & rVals, Setup &setup);
103  std::auto_ptr<RooStats::HybridCalculator> create(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double rVal, Setup &setup);
104 
105  std::pair<double,double> eval(RooStats::HybridCalculator &hc, const RooAbsCollection & rVals, bool adaptive=false, double clsTarget=-1) ;
106 
107  // Compute CLs or CLsb from a HypoTestResult. In the case of the LHCFC test statistics, do the proper transformation to LHC or Profile (which needs to know the POI)
108  std::pair<double,double> eval(const RooStats::HypoTestResult &hcres, const RooAbsCollection & rVals) ;
109  std::pair<double,double> eval(const RooStats::HypoTestResult &hcres, double rVal) ;
110 
111  void applyExpectedQuantile(RooStats::HypoTestResult &hcres);
112  void applyClsQuantile(RooStats::HypoTestResult &hcres);
113  void applySignalQuantile(RooStats::HypoTestResult &hcres);
114  RooStats::HypoTestResult *evalGeneric(RooStats::HybridCalculator &hc, bool forceNoFork=false);
115  RooStats::HypoTestResult *evalWithFork(RooStats::HybridCalculator &hc);
116  // RooStats::HypoTestResult *evalFrequentist(RooStats::HybridCalculator &hc); // cross-check implementation,
117  RooStats::HypoTestResult *readToysFromFile(const RooAbsCollection & rVals);
118 
119  std::map<double, RooStats::HypoTestResult *> grid_;
120 
121  void clearGrid();
122  void readGrid(TDirectory *directory, double rMin, double rMax);
123  void updateGridData(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, bool smart, double clsTarget);
124  void updateGridDataFC(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, bool smart, double clsTarget);
125  std::pair<double,double> updateGridPoint(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, std::map<double, RooStats::HypoTestResult *>::iterator point);
126  void useGrid();
127 
128 
129 };
130 
131 #endif
static std::string rule_
Definition: HybridNew.h:44
std::auto_ptr< RooStats::ProofConfig > pc
Definition: HybridNew.h:86
static unsigned int iterations_
Definition: HybridNew.h:49
static bool importanceSamplingNull_
Definition: HybridNew.h:59
static unsigned int fork_
Definition: HybridNew.h:58
std::auto_ptr< RooStats::ToyMCSampler > toymcsampler
Definition: HybridNew.h:85
RooStats::ModelConfig modelConfig
Definition: HybridNew.h:83
RooStats::HypoTestResult * evalGeneric(RooStats::HybridCalculator &hc, bool forceNoFork=false)
Definition: HybridNew.cc:1170
virtual bool runSignificance(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
Definition: HybridNew.cc:267
void updateGridDataFC(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, bool smart, double clsTarget)
Definition: HybridNew.cc:1441
void validateOptions()
Definition: HybridNew.cc:185
virtual bool runLimit(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
Definition: HybridNew.cc:318
float mass_
Definition: HybridNew.h:70
static std::string rValue_
Definition: HybridNew.h:47
RooArgSet cleanupList
Definition: HybridNew.h:87
static std::string algo_
Definition: HybridNew.h:60
static float minimizerTolerance_
Definition: HybridNew.h:63
static double interpAccuracy_
Definition: HybridNew.h:42
static std::string minimizerAlgo_
Definition: HybridNew.h:62
static WorkingMode workingMode_
Definition: HybridNew.h:40
void applySignalQuantile(RooStats::HypoTestResult &hcres)
Definition: HybridNew.cc:1162
static bool saveHybridResult_
Definition: HybridNew.h:50
virtual const std::string & name() const
Definition: HybridNew.h:32
static double rAbsAccuracy_
Definition: HybridNew.h:42
void clearGrid()
Definition: HybridNew.cc:1509
static float quantileForExpectedFromGrid_
Definition: HybridNew.h:53
void updateGridData(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, bool smart, double clsTarget)
Definition: HybridNew.cc:1379
virtual void applyOptions(const boost::program_options::variables_map &vm)
Definition: HybridNew.cc:135
void applyExpectedQuantile(RooStats::HypoTestResult &hcres)
Definition: HybridNew.cc:1068
std::auto_ptr< RooStats::TestStatistic > qvar
Definition: HybridNew.h:84
static bool reportPVal_
Definition: HybridNew.h:45
static bool CLs_
Definition: HybridNew.h:43
virtual bool run(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
Definition: HybridNew.cc:251
std::pair< double, double > eval(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, const RooAbsCollection &rVals, bool adaptive=false, double clsTarget=-1)
generic version
Definition: HybridNew.cc:587
static bool saveGrid_
Definition: HybridNew.h:56
std::map< double, RooStats::HypoTestResult * > grid_
Definition: HybridNew.h:119
static unsigned int nCpu_
Definition: HybridNew.h:58
static bool fullGrid_
Definition: HybridNew.h:55
virtual bool runTestStatistics(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
Definition: HybridNew.cc:556
static bool rMaxSet_
Definition: HybridNew.h:69
static unsigned int nToys_
Definition: HybridNew.h:41
static bool genGlobalObs_
Definition: HybridNew.h:46
static std::string testStat_
Definition: HybridNew.h:44
static bool optimizeProductPdf_
Definition: HybridNew.h:65
static bool noUpdateGrid_
Definition: HybridNew.h:57
void setupPOI(RooStats::ModelConfig *mc_s)
Definition: HybridNew.cc:220
RooStats::HypoTestResult * readToysFromFile(const RooAbsCollection &rVals)
Definition: HybridNew.cc:1293
void useGrid()
Definition: HybridNew.cc:1489
static std::string gridFile_
Definition: HybridNew.h:51
unsigned int perf_totalToysRun_
Definition: HybridNew.h:76
std::auto_ptr< TGraphErrors > limitPlot_
Definition: HybridNew.h:73
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static bool optimizeTestStatistics_
Definition: HybridNew.h:66
std::pair< double, double > updateGridPoint(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, std::map< double, RooStats::HypoTestResult * >::iterator point)
Definition: HybridNew.cc:1462
static bool genNuisances_
Definition: HybridNew.h:46
static std::string plot_
Definition: HybridNew.h:61
static double rRelAccuracy_
Definition: HybridNew.h:42
RooStats::ModelConfig modelConfig_bonly
Definition: HybridNew.h:83
static bool rMinSet_
Definition: HybridNew.h:68
static bool expectedFromGrid_
Definition: HybridNew.h:52
static bool newToyMCSampler_
Definition: HybridNew.h:67
void applyClsQuantile(RooStats::HypoTestResult &hcres)
Definition: HybridNew.cc:1084
void readGrid(TDirectory *directory, double rMin, double rMax)
Definition: HybridNew.cc:1345
virtual void applyDefaultOptions()
Definition: HybridNew.cc:180
static bool clsQuantiles_
Definition: HybridNew.h:52
virtual bool runSinglePoint(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, double &limit, double &limitErr, const double *hint)
Definition: HybridNew.cc:546
static bool importanceSamplingAlt_
Definition: HybridNew.h:59
RooStats::HypoTestResult * evalWithFork(RooStats::HybridCalculator &hc)
Definition: HybridNew.cc:1180
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
static bool fitNuisances_
Definition: HybridNew.h:46
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
static bool readHybridResults_
Definition: HybridNew.h:50
static bool fullBToys_
Definition: HybridNew.h:54
static RooArgSet rValues_
Definition: HybridNew.h:48
static double clsAccuracy_
Definition: HybridNew.h:42
T w() const
std::auto_ptr< RooStats::HybridCalculator > create(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStats::ModelConfig *mc_b, RooAbsData &data, const RooAbsCollection &rVals, Setup &setup)
generic version
Definition: HybridNew.cc:639