CombineHarvester
CMSHistFuncFactory.h
Go to the documentation of this file.
1 #ifndef CMSHistFuncFactory_h
2 #define CMSHistFuncFactory_h
3 #include <algorithm>
4 #include <vector>
5 #include "RooWorkspace.h"
6 #include "RooHistPdf.h"
7 #include "RooBinning.h"
9 #pragma GCC diagnostic push
10 #pragma GCC diagnostic ignored "-Wuninitialized"
11 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
12 #pragma GCC diagnostic ignored "-Wunused-parameter"
13 #include "HiggsAnalysis/CombinedLimit/interface/CMSHistFunc.h"
14 #include "HiggsAnalysis/CombinedLimit/interface/RooSpline1D.h"
15 #include "HiggsAnalysis/CombinedLimit/interface/VerticalInterpHistPdf.h"
16 #include "HiggsAnalysis/CombinedLimit/interface/AsymPow.h"
17 #pragma GCC diagnostic pop
18 
19 namespace ch {
20 
22 public:
23  void Run(CombineHarvester& cb, RooWorkspace& ws, std::map<std::string, std::string> process_vs_norm_postfix_map);
24  void Run(CombineHarvester& cb, RooWorkspace& ws);
25  void SetHorizontalMorphingVariable(std::map<std::string, RooAbsReal*> &hvar) { mass_var = hvar; }
27 private:
28  std::string norm_postfix_ = "norm";
29  unsigned v_;
30  // RooAbsReal *mass_var;
31  std::map<std::string, RooAbsReal*> mass_var;
32  void RunSingleProc(CombineHarvester& cb, RooWorkspace& ws, std::string bin, std::string process);
33  std::map<std::string, RooRealVar> obs_;
34  unsigned hist_mode_;
35  bool rebin_;
36 
37  TH1F AsTH1F(TH1 const* hist) {
38  TH1F res;
39  TH1F const* test_f = dynamic_cast<TH1F const*>(hist);
40  TH1D const* test_d = dynamic_cast<TH1D const*>(hist);
41  if (test_f) {
42  test_f->Copy(res);
43  } else if (test_d) {
44  test_d->Copy(res);
45  } else {
46  throw std::runtime_error("TH1 is not a TH1F or a TH1D");
47  }
48  return res;
49  }
50 
51  RooRealVar VarFromHist(TString name, TString title, TH1 const& hist) {
52  RooBinning * binning;
53  if (hist.GetXaxis()->GetXbins() && hist.GetXaxis()->GetXbins()->GetSize()) {
54  binning = new RooBinning(hist.GetNbinsX(), hist.GetXaxis()->GetXbins()->GetArray());
55  } else {
56  binning = new RooBinning(hist.GetNbinsX(), hist.GetXaxis()->GetXmin(), hist.GetXaxis()->GetXmax());
57  }
58  RooRealVar x(name, title, hist.GetXaxis()->GetXmin(), hist.GetXaxis()->GetXmax());
59  // x.getBinning().Print();
60  x.setBinning(*binning);
61  delete binning;
62  return x;
63  }
64 };
65 
66 }
67 
68 #endif
void Run(CombineHarvester &cb, RooWorkspace &ws, std::map< std::string, std::string > process_vs_norm_postfix_map)
void SetHorizontalMorphingVariable(std::map< std::string, RooAbsReal * > &hvar)
Definition: Algorithm.h:10