diff --git a/_a_zh_systematics_8cc_source.html b/_a_zh_systematics_8cc_source.html index f7da8845466..f8bbb4c714b 100644 --- a/_a_zh_systematics_8cc_source.html +++ b/_a_zh_systematics_8cc_source.html @@ -302,7 +302,7 @@
200 }
201 
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::syst::SystMap
Definition: Systematics.h:70
ch::syst::SystMapAsymm
Definition: Systematics.h:135
ch::syst::bin_id
Definition: Systematics.h:41
@@ -314,7 +314,7 @@
ch
Definition: Algorithm.h:10
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
Utilities.h
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::syst::channel
Definition: Systematics.h:26
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
ch::AddSystematics_AZh
void AddSystematics_AZh(CombineHarvester &cb, CombineHarvester src)
Definition: AZhSystematics.cc:20
@@ -322,7 +322,7 @@
ch::syst::era
Definition: Systematics.h:21
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
ch::syst::process
Definition: Systematics.h:36
-
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:638
+
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:652
diff --git a/_auto_rebin_8cc_source.html b/_auto_rebin_8cc_source.html index 97885cac04f..96d8a02a182 100644 --- a/_auto_rebin_8cc_source.html +++ b/_auto_rebin_8cc_source.html @@ -453,8 +453,8 @@
351 
352 }
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
-
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:95
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
+
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:105
ch::CombineHarvester::bin_set
std::set< std::string > bin_set()
Definition: CombineHarvester_Filters.cc:190
ch::AutoRebin::GetMaximumFracUncertBin
int GetMaximumFracUncertBin(TH1F &total_bkg)
Return bin with maximum value of fractional error.
Definition: AutoRebin.cc:336
ch::AutoRebin::AutoRebin
AutoRebin()
Definition: AutoRebin.cc:10
@@ -462,8 +462,8 @@
ch
Definition: Algorithm.h:10
ch::AutoRebin::FindNewBinning
void FindNewBinning(TH1F &total_bkg, std::vector< double > &new_bins, double bin_condition, double bin_uncert_fraction, int mode)
Pass through the total background histogram to find bins failing the required condition ("empty" bins...
Definition: AutoRebin.cc:104
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
-
ch::Process
Definition: Process.h:14
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
+
ch::Process
Definition: Process.h:15
ch::AutoRebin::Rebin
void Rebin(CombineHarvester &src, CombineHarvester &dest)
Work out optimal binning using the total background histogram built from src, and apply the binning t...
Definition: AutoRebin.cc:18
diff --git a/_bin_by_bin_8cc_source.html b/_bin_by_bin_8cc_source.html index 004941f1099..d415091668e 100644 --- a/_bin_by_bin_8cc_source.html +++ b/_bin_by_bin_8cc_source.html @@ -312,7 +312,7 @@
ch::CombineHarvester::CreateParameterIfEmpty
void CreateParameterIfEmpty(std::string const &name)
Definition: CombineHarvester_Creation.cc:228
ch::Systematic::set_name
void set_name(std::string const &name)
Definition: Systematic.h:20
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::Object::bin_id
virtual int bin_id() const
Definition: Object.h:35
ch::CombineHarvester::bin_set
std::set< std::string > bin_set()
Definition: CombineHarvester_Filters.cc:190
ch::CombineHarvester::InsertSystematic
void InsertSystematic(ch::Systematic const &sys)
Definition: CombineHarvester_Creation.cc:253
@@ -326,15 +326,15 @@
ch
Definition: Algorithm.h:10
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
-
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:42
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
+
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:52
ch::Systematic::set_value_u
void set_value_u(double const &value_u)
Definition: Systematic.h:26
-
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:131
+
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:141
ch::BinByBinFactory::MergeAndAdd
void MergeAndAdd(CombineHarvester &src, CombineHarvester &dest)
A convenience function which calls MergeBinErrors and AddBinByBin in turn.
Definition: BinByBin.cc:202
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::Object::era
virtual std::string const & era() const
Definition: Object.h:29
ch::BinByBinFactory::MergeBinErrors
void MergeBinErrors(CombineHarvester &cb)
Merges histogram bin errors between processes.
Definition: BinByBin.cc:22
-
ch::Process
Definition: Process.h:14
+
ch::Process
Definition: Process.h:15
ch::Systematic::name
std::string const & name() const
Definition: Systematic.h:21
ch::BinByBinFactory::AddBinByBin
void AddBinByBin(CombineHarvester &src, CombineHarvester &dest)
Create bin-by-bin shape uncertainties for every process in src, and add these to dest ...
Definition: BinByBin.cc:105
ch::Systematic
Definition: Systematic.h:12
diff --git a/_c_m_s_hist_func_factory_8cc.html b/_c_m_s_hist_func_factory_8cc.html new file mode 100644 index 00000000000..371142d0ea2 --- /dev/null +++ b/_c_m_s_hist_func_factory_8cc.html @@ -0,0 +1,134 @@ + + + + + + + +CombineHarvester: CombinePdfs/src/CMSHistFuncFactory.cc File Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
CombineHarvester +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
CMSHistFuncFactory.cc File Reference
+
+
+
#include "CombineHarvester/CombinePdfs/interface/CMSHistFuncFactory.h"
+#include <iostream>
+#include <set>
+#include <vector>
+#include <string>
+#include "boost/lexical_cast.hpp"
+#include "boost/format.hpp"
+#include "boost/multi_array.hpp"
+#include "TVector.h"
+#include "TGraphErrors.h"
+#include "RooFitResult.h"
+#include "RooRealVar.h"
+#include "RooDataHist.h"
+#include "RooProduct.h"
+#include "RooConstVar.h"
+#include "CombineHarvester/CombineTools/interface/Logging.h"
+
+

Go to the source code of this file.

+ + + + +

+Namespaces

 ch
 
+
+
+ + + + diff --git a/_c_m_s_hist_func_factory_8cc_source.html b/_c_m_s_hist_func_factory_8cc_source.html new file mode 100644 index 00000000000..df4826ae226 --- /dev/null +++ b/_c_m_s_hist_func_factory_8cc_source.html @@ -0,0 +1,861 @@ + + + + + + + +CombineHarvester: CombinePdfs/src/CMSHistFuncFactory.cc Source File + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
CombineHarvester +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
CMSHistFuncFactory.cc
+
+
+Go to the documentation of this file.
+
2 #include <iostream>
+
3 #include <set>
+
4 #include <vector>
+
5 #include <string>
+
6 #include "boost/lexical_cast.hpp"
+
7 #include "boost/format.hpp"
+
8 #include "boost/multi_array.hpp"
+
9 #include "TVector.h"
+
10 #include "TGraphErrors.h"
+
11 #include "RooFitResult.h"
+
12 #include "RooRealVar.h"
+
13 #include "RooDataHist.h"
+
14 #include "RooProduct.h"
+
15 #include "RooConstVar.h"
+ +
17 
+
18 namespace ch {
+
19 
+
20 /*
+
21 TODO:
+
22 2) Morphing options
+
23 3) Remove morphing proc errors
+
24 */
+
25 
+
26 CMSHistFuncFactory::CMSHistFuncFactory() : v_(1), hist_mode_(0), rebin_(true) {}
+
27 
+
28 void CMSHistFuncFactory::Run(ch::CombineHarvester &cb, RooWorkspace &ws) {
+
29  for (auto const& bin : cb.bin_set()) {
+
30  for (auto const& proc : cb.cp().bin({bin}).process_set()) {
+
31  if (v_) {
+
32  std::cout << ">> Processing " << bin << "," << proc << "\n";
+
33  RunSingleProc(cb, ws, bin, proc);
+
34  }
+
35  }
+
36  TH1F data_hist = cb.cp().bin({bin}).GetObservedShape();
+
37  if (rebin_) data_hist = RebinHist(data_hist);
+
38  // data_hist.Print("range");
+
39 
+
40  RooRealVar *xvar = ws.var(TString::Format("CMS_x_%s", bin.c_str()));
+
41  RooDataHist rdh_dat(TString::Format("%s_data_obs", bin.c_str()), "",
+
42  RooArgList(*xvar), &data_hist);
+
43 
+
44  ws.import(rdh_dat);
+
45 
+
46  cb.cp().bin({bin}).ForEachObs([&](ch::Observation * p) {
+
47  p->set_shape(nullptr, false);
+
48  p->set_rate(1.0);
+
49  });
+
50  }
+
51 }
+
52 
+
53 void CMSHistFuncFactory::RunSingleProc(CombineHarvester& cb, RooWorkspace& ws,
+
54  std::string bin, std::string process) {
+
55  using std::vector;
+
56  using std::set;
+
57  using std::string;
+
58  using boost::lexical_cast;
+
59  using boost::multi_array;
+
60  using boost::extents;
+
61 
+
62  TString key = bin + "_" + process;
+
63 
+
64 
+
65  CombineHarvester cbp = cb.cp().bin({bin}).process({process});
+
66  vector<string> m_str_vec = Set2Vec(cbp.SetFromProcs(
+
67  std::mem_fn(&ch::Process::mass)));
+
68  unsigned m = m_str_vec.size();
+
69  vector<double> m_vec;
+
70  if (m_str_vec.size() == 1) {
+
71  } else {
+
72  std::sort(m_str_vec.begin(), m_str_vec.end(),
+
73  [](string const& s1, string const& s2) {
+
74  return lexical_cast<double>(s1) < lexical_cast<double>(s2);
+
75  });
+
76  for (auto const& s : m_str_vec) {
+
77  if (v_) std::cout << ">>>> Mass point: " << s << "\n";
+
78  m_vec.push_back(lexical_cast<double>(s));
+
79  }
+
80  }
+
81 
+
82  // ss = "shape systematic"
+
83  // Make a list of the names of shape systematics affecting this process
+
84  vector<string> ss_vec =
+
85  Set2Vec(cbp.cp().syst_type({"shape", "shapeU"}).syst_name_set());
+
86  // Now check if all shape systematics are present for all mass points
+
87  for (auto const& s : m_str_vec) {
+
88  if (cbp.cp().syst_type({"shape", "shapeU"}).mass({s}).syst_name_set().size() !=
+
89  ss_vec.size()) {
+
90  throw std::runtime_error(FNERROR(
+
91  "Some mass points do not have the full set of shape systematics, "
+
92  "this is currently unsupported"));
+
93  }
+
94  }
+
95  unsigned ss = ss_vec.size(); // number of shape systematics
+
96 
+
97  vector<string> ls_vec =
+
98  Set2Vec(cbp.cp().syst_type({"lnN"}).syst_name_set());
+
99  unsigned ls = ls_vec.size(); // number of lnN systematics
+
100 
+
101  // Store pointers to each ch::Process (one per mass point) in the CH instance
+
102  multi_array<ch::Process *, 1> pr_arr(extents[m]);
+
103  // Store pointers pointers to each ch::Systematic for each mass point (hence
+
104  // an ss * m 2D array)
+
105  multi_array<ch::Systematic *, 2> ss_arr(extents[ss][m]);
+
106  // With shape systematics we have to support cases where the value in the
+
107  // datacard is != 1.0, i.e. we are scaling the parameter that goes into the
+
108  // Gaussian constraint PDF - we have to pass this factor on when we build the
+
109  // normal vertical-interpolation PDF for each mass point. We will store these
+
110  // scale factors in this array, one per shape systematic.
+
111  multi_array<double, 1> ss_scale_arr(extents[ss]);
+
112  // Really just for book-keeping, we'll set this flag to true when the shape
+
113  // systematic scale factor != 1
+
114  multi_array<bool, 1> ss_must_scale_arr(extents[ss]);
+
115  // Similar to the ss_arr above, store the lnN ch::Systematic objects. Note
+
116  // implicit in all this is the assumption that the processes at each mass
+
117  // point have exactly the same list of systematic uncertainties.
+
118  multi_array<ch::Systematic *, 2> ls_arr(extents[ls][m]);
+
119 
+
120  // This array holds pointers to the RooRealVar objects that will become our
+
121  // shape nuisance parameters, e.g. "CMS_scale_t_mutau_8TeV"
+
122  multi_array<std::shared_ptr<RooRealVar>, 1> ss_scale_var_arr(extents[ss]);
+
123  // And this array holds the constant scale factors that we'll build from
+
124  // ss_scale_arr above
+
125  multi_array<std::shared_ptr<RooConstVar>, 1> ss_scale_fac_arr(extents[ss]);
+
126  // Finally this array will contain the scale_var * scale_fac product where we
+
127  // need to provide a scaled value of the nuisance parameter instead of the
+
128  // parameter itself in building the vertical-interp. PDF
+
129  multi_array<std::shared_ptr<RooProduct>, 1> ss_scale_prod_arr(extents[ss]);
+
130 
+
131  // Now let's fill some of these arrays...
+
132  for (unsigned mi = 0; mi < m; ++mi) {
+
133  // The ch::Process pointers
+
134  cbp.cp().mass({m_str_vec[mi]}).ForEachProc([&](ch::Process *p) {
+
135  pr_arr[mi] = p;
+
136  });
+
137  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
138  // The ch::Systematic pointers for shape systematics
+
139  cbp.cp().mass({m_str_vec[mi]}).syst_name({ss_vec[ssi]})
+
140  .ForEachSyst([&](ch::Systematic *n) {
+
141  ss_arr[ssi][mi] = n;
+
142  });
+
143  }
+
144  for (unsigned lsi = 0; lsi < ls; ++lsi) {
+
145  // The ch::Systematic pointers for lnN systematics
+
146  cbp.cp().mass({m_str_vec[mi]}).syst_name({ls_vec[lsi]})
+
147  .ForEachSyst([&](ch::Systematic *n) {
+
148  ls_arr[lsi][mi] = n;
+
149  });
+
150  }
+
151  }
+
152 
+
154  // We need to build a RooArgList of the vertical morphing parameters for the
+
155  // vertical-interpolation pdf - this will be the same for each mass point so
+
156  // we only build it once
+
157  RooArgList ss_list;
+
158  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
159  // Make the nuisance parameter var. We use shared_ptrs here as a convenience
+
160  // because they will take care of automatically cleaning up the memory at
+
161  // the end
+
162  ss_scale_var_arr[ssi] =
+
163  std::make_shared<RooRealVar>(ss_vec[ssi].c_str(), "", 0);
+
164  // We'll make a quick check that the scale factor for this systematic is the
+
165  // same for all mass points. We could do a separate scaling at each mass
+
166  // point but this would create a lot of complications
+
167  set<double> scales;
+
168  // Insert the scale from each mass point into the set, if it has a size
+
169  // larger than one at the end then we have a problem!
+
170  for (unsigned mi = 0; mi < m; ++mi) {
+
171  scales.insert(ss_arr[ssi][mi]->scale());
+
172  }
+
173  if (scales.size() > 1) {
+
174  // Don't let the user proceed, we can't build the model they want
+
175  std::runtime_error(FNERROR(
+
176  "Shape morphing parameters that vary with mass are not allowed"));
+
177  } else {
+
178  // Everything ok, set the scale value in its array
+
179  ss_scale_arr[ssi] = *(scales.begin());
+
180  // Handle the case where the scale factor is != 1
+
181  if (std::fabs(ss_scale_arr[ssi] - 1.0) > 1E-6) {
+
182  ss_must_scale_arr[ssi] = true;
+
183  // Build the RooConstVar with the value of the scale factor
+
184  ss_scale_fac_arr[ssi] = std::make_shared<RooConstVar>(
+
185  TString::Format("%g", ss_scale_arr[ssi]), "",
+
186  ss_scale_arr[ssi]);
+
187  // Create the product of the floating nuisance parameter and the
+
188  // constant scale factor
+
189  ss_scale_prod_arr[ssi] = std::make_shared<RooProduct>(
+
190  ss_vec[ssi] + "_scaled_" + key, "",
+
191  RooArgList(*(ss_scale_var_arr[ssi]), *(ss_scale_fac_arr[ssi])));
+
192  // Add this to the list
+
193  ss_list.add(*(ss_scale_prod_arr[ssi]));
+
194  } else {
+
195  // If the scale factor is 1.0 then we just add the nuisance parameter
+
196  // directly to our list
+
197  ss_list.add(*(ss_scale_var_arr[ssi]));
+
198  }
+
199  }
+
200  }
+
202  // Summarise the info on the shape systematics and scale factors
+
203  if (v_) {
+
204  std::cout << ">> Shape systematics: " << ss << "\n";
+
205  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
206  std::cout << boost::format("%-50s %-5i %-8.3g\n")
+
207  % ss_vec[ssi] % ss_must_scale_arr[ssi] % ss_scale_arr[ssi];
+
208  }
+
209  }
+
210 
+
211  // lms = "lnN morphing systematic"
+
212  // Now we have some work to do with the lnN systematics. We can consider two cases:
+
213  // a) The uncertainty is the same for each mass point => we can leave it in
+
214  // the datacard as is and let text2workspace do its normal thing
+
215  // b) The uncertainty varies between mass points => we can't capture this
+
216  // information in the text datacard in the usual way, so we'll build a RooFit
+
217  // object that effectively makes the lnN uncertainty a function of the mass
+
218  // variable
+
219  // We'll use "lms" to refer to case b), which we'll try to figure out now...
+
220  vector<string> lms_vec; // vec of systematic names
+
221  set<string> lms_set; // set of systematic names
+
222  // index positions in our full ls_arr array for the lms systematics
+
223  vector<unsigned > lms_vec_idx;
+
224  for (unsigned lsi = 0; lsi < ls; ++lsi) {
+
225  // Extra complication is that the user might have been evil and mixed
+
226  // symmetric and asymmetric lnN values, we'll try and detect changes in
+
227  // either
+
228  set<double> k_hi;
+
229  set<double> k_lo;
+
230  // Go through each mass point for this systematic and add the uncertainty
+
231  // values (so-called "kappa" values)
+
232  for (unsigned mi = 0; mi < m; ++mi) {
+
233  Systematic *n = ls_arr[lsi][mi];
+
234  k_hi.insert(n->value_u());
+
235  if (n->asymm()) {
+
236  k_lo.insert(n->value_d());
+
237  }
+
238  }
+
239  // If either of these sets has more than one entry then this is a lms case
+
240  if (k_hi.size() > 1 || k_lo.size() > 1) {
+
241  lms_vec.push_back(ls_vec[lsi]);
+
242  lms_set.insert(ls_vec[lsi]);
+
243  lms_vec_idx.push_back(lsi);
+
244  }
+
245  }
+
246  unsigned lms = lms_vec.size();
+
247  // New array for the pointers to the lms Systematic objects
+
248  multi_array<ch::Systematic *, 2> lms_arr(extents[lms][m]);
+
249  for (unsigned lmsi = 0; lmsi < lms; ++lmsi) {
+
250  for (unsigned mi = 0; mi < m; ++mi) {
+
251  lms_arr[lmsi][mi] = ls_arr[lms_vec_idx[lmsi]][mi];
+
252  }
+
253  }
+
254 
+
255  // We will need to create the nuisance parameters for these now
+
256  multi_array<std::shared_ptr<RooRealVar>, 1> lms_var_arr(extents[lms]);
+
257  for (unsigned lmsi = 0; lmsi < lms; ++lmsi) {
+
258  lms_var_arr[lmsi] =
+
259  std::make_shared<RooRealVar>(lms_vec[lmsi].c_str(), "", 0);
+
260  }
+
261 
+
262  // Give a summary of the lms systematics to the user
+
263  if (v_) {
+
264  std::cout << ">> lnN morphing systematics: " << lms << "\n";
+
265  for (unsigned lmsi = 0; lmsi < lms; ++lmsi) {
+
266  std::cout << ">>>> " << lms_vec[lmsi] << "\n";
+
267  }
+
268  }
+
269 
+
270  // 2D array of all input histograms, size is (mass points * (nominal +
+
271  // 2*shape-systs)). The factor of 2 needed for the Up and Down shapes
+
272  multi_array<std::shared_ptr<TH1F>, 2> hist_arr(extents[m][1+ss*2]);
+
273  // We also need the array of process yields vs mass, because this will have to
+
274  // be interpolated too
+
275  multi_array<double, 1> rate_arr(extents[m]);
+
276  // Also store the yield uncertainty - we don't actually need this for the signal
+
277  // model, but will include it in the debug TGraph
+
278  multi_array<double, 1> rate_unc_arr(extents[m]);
+
279  // The vertical-interpolation PDF needs the TH1 inputs in the format of a TList
+
280  multi_array<std::shared_ptr<TList>, 1> list_arr(extents[m]);
+
281  // Combine always treats the normalisation part of shape systematics as
+
282  // distinct from the actual shape morphing. Essentially the norm part is
+
283  // treated as an asymmetric lnN. We have to make the kappa_hi and kappa_lo a
+
284  // function of the mass parameter too, so we need two more arrays in (ss * m)
+
285  multi_array<double, 2> ss_k_hi_arr(extents[ss][m]);
+
286  multi_array<double, 2> ss_k_lo_arr(extents[ss][m]);
+
287  // For each shape systematic we will build a RooSpline1D, configured to
+
288  // interpolate linearly between the kappa values
+
289  multi_array<std::shared_ptr<RooAbsReal>, 1> ss_spl_hi_arr(extents[ss]);
+
290  multi_array<std::shared_ptr<RooAbsReal>, 1> ss_spl_lo_arr(extents[ss]);
+
291  // To define the actually process scaling as a function of these kappa values,
+
292  // we need an AsymPow object per mass point
+
293  multi_array<std::shared_ptr<AsymPow>, 1> ss_asy_arr(extents[ss]);
+
294 
+
295  // Similar set of objects needed for the lms normalisation systematics
+
296  multi_array<double, 2> lms_k_hi_arr(extents[lms][m]);
+
297  multi_array<double, 2> lms_k_lo_arr(extents[lms][m]);
+
298  multi_array<std::shared_ptr<RooSpline1D>, 1> lms_spl_hi_arr(extents[lms]);
+
299  multi_array<std::shared_ptr<RooSpline1D>, 1> lms_spl_lo_arr(extents[lms]);
+
300  multi_array<std::shared_ptr<AsymPow>, 1> lms_asy_arr(extents[lms]);
+
301 
+
302  for (unsigned mi = 0; mi < m; ++mi) {
+
303  // Grab the nominal process histograms. We also have to convert every
+
304  // histogram to a uniform integer binning, because this is what
+
305  // text2workspace will do for all the non-morphed processes in our datacard,
+
306  // and we need the binning of these to be in sync.
+
307  hist_arr[mi][0] =
+
308  std::make_shared<TH1F>(AsTH1F(pr_arr[mi]->ClonedScaledShape().get()));
+
309  if (rebin_) *hist_arr[mi][0] = RebinHist(*hist_arr[mi][0]);
+
310  if (m > 1) {
+
311  for (int b = 1; b < hist_arr[mi][0]->GetNbinsX() + 1; ++b) {
+
312  hist_arr[mi][0]->SetBinError(b, 0.);
+
313  }
+
314  }
+
315  // If the user supplied a TFile pointer we'll dump a bunch of info into it
+
316  // for debugging
+
317  // if (file) {
+
318  // file->WriteTObject(pr_arr[mi]->shape(), key + "_" + m_str_vec[mi]);
+
319  // }
+
320  // Store the process rate
+
321  rate_arr[mi] = 1.;
+
322  // auto proc_hist = pr_arr[mi]->ClonedScaledShape();
+
323  // proc_hist->IntegralAndError(1, proc_hist->GetNbinsX(), rate_unc_arr[mi]);
+
324  // Do the same for the Up and Down shapes
+
325  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
326  hist_arr[mi][1 + 2 * ssi] =
+
327  std::make_shared<TH1F>(AsTH1F(ss_arr[ssi][mi]->shape_u()));
+
328  hist_arr[mi][2 + 2 * ssi] =
+
329  std::make_shared<TH1F>(AsTH1F(ss_arr[ssi][mi]->shape_d()));
+
330  if (rebin_) *hist_arr[mi][1 + 2 * ssi] = RebinHist(*hist_arr[mi][1 + 2 * ssi]);
+
331  if (rebin_) *hist_arr[mi][2 + 2 * ssi] = RebinHist(*hist_arr[mi][2 + 2 * ssi]);
+
332  TH1F* h_hi = hist_arr[mi][1 + 2 * ssi].get();
+
333  TH1F* h_lo = hist_arr[mi][2 + 2 * ssi].get();
+
334  if (h_hi->Integral() > 0.) {
+
335  h_hi->Scale(hist_arr[mi][0]->Integral() / h_hi->Integral());
+
336  }
+
337  if (h_lo->Integral() > 0.) {
+
338  h_lo->Scale(hist_arr[mi][0]->Integral() / h_lo->Integral());
+
339  }
+
340 
+
341  // TODO: Need to implement the logic of normalising shape variations here
+
342 
+
343  // if (file) {
+
344  // file->WriteTObject(ss_arr[ssi][mi]->shape_u(),
+
345  // key + "_" + m_str_vec[mi] + "_" + ss_vec[ssi] + "Up");
+
346  // file->WriteTObject(ss_arr[ssi][mi]->shape_d(),
+
347  // key + "_" + m_str_vec[mi] + "_" + ss_vec[ssi] + "Down");
+
348  // }
+
349  // Store the uncertainty ("kappa") values for the shape systematics
+
350  ss_k_hi_arr[ssi][mi] = ss_arr[ssi][mi]->value_u();
+
351  ss_k_lo_arr[ssi][mi] = ss_arr[ssi][mi]->value_d();
+
352  // For the normalisation we scale the kappa instead of putting the scaling
+
353  // parameter as the variable
+
354  if (std::fabs(ss_scale_arr[ssi] - 1.0) > 1E-6) {
+
355  ss_k_hi_arr[ssi][mi] = std::pow(ss_arr[ssi][mi]->value_u(), ss_scale_arr[ssi]);
+
356  ss_k_lo_arr[ssi][mi] = std::pow(ss_arr[ssi][mi]->value_d(), ss_scale_arr[ssi]);
+
357  }
+
358  }
+
359  // And now the uncertainty values for the lnN systematics that vary with mass
+
360  // We'll force these to be asymmetric even if they're not
+
361  for (unsigned lmsi = 0; lmsi < lms; ++lmsi) {
+
362  lms_k_hi_arr[lmsi][mi] = lms_arr[lmsi][mi]->value_u();
+
363  if (lms_arr[lmsi][mi]->asymm()) {
+
364  lms_k_lo_arr[lmsi][mi] = lms_arr[lmsi][mi]->value_d();
+
365  } else {
+
366  lms_k_lo_arr[lmsi][mi] = 1. / lms_arr[lmsi][mi]->value_u();
+
367  }
+
368  }
+
369  }
+
370  // Now we'll fill these objects..
+
371 
+
372 
+
373  // Now we've made all our histograms, we'll put them in the TList format
+
374  // of [nominal, syst_1_Up, syst_1_Down, ... , syst_N_Up, syst_N_Down]
+
375  // for (unsigned mi = 0; mi < m; ++mi) {
+
376  // list_arr[mi] = std::make_shared<TList>();
+
377  // for (unsigned xi = 0; xi < (1 + ss * 2); ++xi) {
+
378  // list_arr[mi]->Add(hist_arr[mi][xi].get());
+
379  // }
+
380  // }
+
381 
+
382  // Print the values of the yields and kappa factors that will be inputs
+
383  // to our spline interpolation objects
+
384  if (v_) {
+
385  for (unsigned mi = 0; mi < m; ++mi) {
+
386  std::cout << boost::format("%-10s") % m_str_vec[mi];
+
387  }
+
388  std::cout << "\n";
+
389  for (unsigned mi = 0; mi < m; ++mi) {
+
390  std::cout << boost::format("%-10.5g") % rate_arr[mi];
+
391  }
+
392  std::cout << "\n";
+
393  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
394  std::cout << ss_vec[ssi] << " Up" << std::endl;
+
395  for (unsigned mi = 0; mi < m; ++mi) {
+
396  std::cout << boost::format("%-10.5g") % ss_k_hi_arr[ssi][mi];
+
397  }
+
398  std::cout << "\n";
+
399  std::cout << ss_vec[ssi] << " Down" << std::endl;
+
400  for (unsigned mi = 0; mi < m; ++mi) {
+
401  std::cout << boost::format("%-10.5g") % ss_k_lo_arr[ssi][mi];
+
402  }
+
403  std::cout << "\n";
+
404  }
+
405  for (unsigned lmsi = 0; lmsi < lms; ++lmsi) {
+
406  std::cout << lms_vec[lmsi] << " Up" << std::endl;
+
407  for (unsigned mi = 0; mi < m; ++mi) {
+
408  std::cout << boost::format("%-10.5g") % lms_k_hi_arr[lmsi][mi];
+
409  }
+
410  std::cout << "\n";
+
411  std::cout << lms_vec[lmsi] << " Down" << std::endl;
+
412  for (unsigned mi = 0; mi < m; ++mi) {
+
413  std::cout << boost::format("%-10.5g") % lms_k_lo_arr[lmsi][mi];
+
414  }
+
415  std::cout << "\n";
+
416  }
+
417  }
+
418 
+
419  // Can do more sophistical spline interpolation if we want, but let's use
+
420  // simple LINEAR interpolation for now
+
421  TString interp = "LINEAR";
+
422 
+
423  // Here when the force_template_limit option is requested
+
424  // we have to add some extra terms to the vector of masses to ensure that
+
425  // the signal pdf goes to 0 outside of the MC template range.
+
426 
+
427  vector<double> new_m_vec(m_vec);
+
428  // Insert an entry at either end of the vector for a mass just slightly
+
429  // outside of the range
+
430  if (m > 1) {
+
431  new_m_vec.insert(new_m_vec.begin(),m_vec[0]-1E-6);
+
432  new_m_vec.push_back(m_vec[m-1]+1E-6);
+
433  }
+
434  // Create a corresponding rate array with 0 entries for these new masses
+
435  multi_array<double, 1> new_rate_arr(extents[m+2]);
+
436  new_rate_arr[0] = 0.0;
+
437  // for(unsigned i = 0; i < m; ++i) new_rate_arr[i+1] = rate_arr[i] ;
+
438 
+
439  // With CMSHistFunc the normalisation is handled internally
+
440  for(unsigned i = 0; i < m; ++i) new_rate_arr[i+1] = 1.0;
+
441  new_rate_arr[m+1] = 0.0;
+
442 
+
443  bool force_template_limit = false;
+
444 
+
445  // if (v_ && force_template_limit) {
+
446  // std::cout << ">>>> Forcing rate to 0 outside of template range:" << "\n";
+
447  // for(unsigned mi = 0; mi < m+2; ++mi) {
+
448  // std::cout << boost::format("%-10.5g") % new_m_vec[mi];
+
449  // }
+
450  // std::cout << "\n";
+
451  // for(unsigned mi = 0; mi < m+2; ++mi) {
+
452  // std::cout << boost::format("%-10.5g") % new_rate_arr[mi];
+
453  // }
+
454  // std::cout << "\n";
+
455  // }
+
456  // Create the 1D spline directly from the rate array
+
458  std::shared_ptr<RooSpline1D> rate_spline;
+
459  if (m > 1) rate_spline = std::make_shared<RooSpline1D>("interp_rate_"+key, "", *mass_var[process],
+
460  force_template_limit ? m+2 : m,
+
461  force_template_limit ? new_m_vec.data() : m_vec.data(),
+
462  force_template_limit ? new_rate_arr.data() : rate_arr.data(),
+
463  interp);
+
464  // if (file) {
+
465  // TGraphErrors tmp(m, m_vec.data(), rate_arr.data(), nullptr, rate_unc_arr.data());
+
466  // file->WriteTObject(&tmp, "interp_rate_"+key);
+
467  // }
+
468  // Collect all terms that will go into the total normalisation:
+
469  // nominal * systeff_1 * systeff_2 * ... * systeff_N
+
470  RooArgList rate_prod;
+
471  if (m > 1) {
+
472  rate_prod.add(*rate_spline);
+
473  }
+
474  // For each shape systematic build a 1D spline for kappa_hi and kappa_lo
+
475  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
476  if (m > 1) {
+
477  ss_spl_hi_arr[ssi] = std::make_shared<RooSpline1D>("spline_hi_" +
+
478  key + "_" + ss_vec[ssi], "", *mass_var[process], m, m_vec.data(),
+
479  ss_k_hi_arr[ssi].origin(), interp);
+
480  ss_spl_lo_arr[ssi] = std::make_shared<RooSpline1D>("spline_lo_" +
+
481  key + "_" + ss_vec[ssi], "", *mass_var[process], m, m_vec.data(),
+
482  ss_k_lo_arr[ssi].origin(), interp);
+
483  } else {
+
484  ss_spl_hi_arr[ssi] = std::make_shared<RooConstVar>(TString::Format("%g", ss_k_hi_arr[ssi][0]), "", ss_k_hi_arr[ssi][0]);
+
485  ss_spl_lo_arr[ssi] = std::make_shared<RooConstVar>(TString::Format("%g", ss_k_lo_arr[ssi][0]), "", ss_k_lo_arr[ssi][0]);
+
486  }
+
487  ss_asy_arr[ssi] = std::make_shared<AsymPow>("systeff_" +
+
488  key + "_" + ss_vec[ssi], "",
+
489  *(ss_spl_lo_arr[ssi]), *(ss_spl_hi_arr[ssi]),
+
490  *(ss_scale_var_arr[ssi]));
+
491  // if (file) {
+
492  // TGraph tmp_hi(m, m_vec.data(), ss_k_hi_arr[ssi].origin());
+
493  // file->WriteTObject(&tmp_hi, "spline_hi_" + key + "_" + ss_vec[ssi]);
+
494  // TGraph tmp_lo(m, m_vec.data(), ss_k_lo_arr[ssi].origin());
+
495  // file->WriteTObject(&tmp_lo, "spline_lo_" + key + "_" + ss_vec[ssi]);
+
496  // }
+
497  // Then build the AsymPow object for each systematic as a function of the
+
498  // kappas and the nuisance parameter
+
499  rate_prod.add(*(ss_asy_arr[ssi]));
+
500  }
+
501  // Same procedure for the lms normalisation systematics: build the splines
+
502  // then the AsymPows and add to the rate_prod list
+
503  for (unsigned lmsi = 0; lmsi < lms; ++lmsi) {
+
504  lms_spl_hi_arr[lmsi] = std::make_shared<RooSpline1D>("spline_hi_" +
+
505  key + "_" + lms_vec[lmsi], "", *mass_var[process], m, m_vec.data(),
+
506  lms_k_hi_arr[lmsi].origin(), interp);
+
507  lms_spl_lo_arr[lmsi] = std::make_shared<RooSpline1D>("spline_lo_" +
+
508  key + "_" + lms_vec[lmsi], "", *mass_var[process], m, m_vec.data(),
+
509  lms_k_lo_arr[lmsi].origin(), interp);
+
510  lms_asy_arr[lmsi] = std::make_shared<AsymPow>("systeff_" +
+
511  key + "_" + lms_vec[lmsi], "", *(lms_spl_lo_arr[lmsi]),
+
512  *(lms_spl_hi_arr[lmsi]), *(lms_var_arr[lmsi]));
+
513  rate_prod.add(*(lms_asy_arr[lmsi]));
+
514  }
+
515  // We'll come back to this rate_prod a bit later.
+
516 
+
517  // Now some fun with binning. We anticipate that the process histograms we
+
518  // have been supplied could have a finer binning than is actually wanted for
+
519  // the analysis (and the fit), in order to avoid known problems with the RMS
+
520  // of a peaking distribution not being morphed smoothly from mass point to
+
521  // mass point if the binning is too wide. The RooMorphingPdf will handle
+
522  // re-binning on the fly, but we have to tell it how to rebin. To do this we
+
523  // assume the observed data histogram has the target binning.
+
524  TH1F data_hist = cbp.GetObservedShape();
+
525  TH1F proc_hist = cbp.GetShape();
+
526  // The x-axis variable has to be called "CMS_th1x", as this is what
+
527  // text2workspace will use for all the normal processes
+
528  // data_hist.Print("range");
+
529  TString xvar_name = TString::Format("CMS_x_%s", bin.c_str());
+
530  RooRealVar xvar = VarFromHist(xvar_name, xvar_name, data_hist);
+
531  // RooRealVar xvar("CMS_th1x", "CMS_th1x", 0,
+
532  // static_cast<float>(data_hist.GetNbinsX()));
+
533  // xvar.setBins(data_hist.GetNbinsX());
+
534 
+
535  // Create a second x-axis variable, named specific to the bin, that will be
+
536  // for the finer-binned input
+
537  // RooRealVar morph_xvar(("CMS_th1x_"+bin).c_str(), "", 0,
+
538  // static_cast<float>(proc_hist.GetNbinsX()));
+
539  // We're not going to need roofit to evaluate anything as a function of this
+
540  // morphing x-axis variable, so we set it constant
+
541  // morph_xvar.setConstant();
+
542  // morph_xvar.setBins(proc_hist.GetNbinsX());
+
543  if (v_) {
+
544  xvar.Print();
+
545  // morph_xvar.Print();
+
546  }
+
547 
+
548  // Follow what ShapeTools.py does and set the smoothing region
+
549  // to the minimum of all of the shape scales
+
550  double qrange = 1.;
+
551  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
552  if (ss_scale_arr[ssi] < qrange) qrange = ss_scale_arr[ssi];
+
553  }
+
554 
+
555 
+
556  TString morph_name = key + "_morph";
+
557  // At long last, we can build our pdf, giving it:
+
558  // xvar : the fixed "CMS_th1x" x-axis variable with uniform integer binning
+
559  // mass_var: the floating mass value for the interpolation
+
560  // vpdf_list: the list of vertical-interpolation pdfs
+
561  // m_vec: the corresponding list of mass points
+
562  // allow_morph: if false will just evaluate to the closest pdf in mass
+
563  // data_hist.GetXaxis(): The original (non-uniform) target binning
+
564  // proc_hist.GetXaxis(): The original (non-uniform) morphing binning
+
566  CMSHistFunc morph_func(morph_name, "", xvar, *hist_arr[0][0]);
+
567  morph_func.setVerticalSmoothRegion(qrange);
+
568  morph_func.setHorizontalType(CMSHistFunc::HorizontalType::Integral);
+
569  morph_func.setVerticalMorphs(ss_list);
+
570  if (m > 1) {
+
571  morph_func.addHorizontalMorph(*mass_var[process], TVectorD(m, m_vec.data()));
+
572  }
+
573  morph_func.prepareStorage();
+
574 
+
575  for (unsigned mi = 0; mi < m; ++mi) {
+
576  morph_func.setShape(0, mi, 0, 0, *hist_arr[mi][0]);
+
577  for (unsigned ssi = 0; ssi < ss; ++ssi) {
+
578  morph_func.setShape(0, mi, ssi + 1, 0, *hist_arr[mi][2 + 2 * ssi]);
+
579  morph_func.setShape(0, mi, ssi + 1, 1, *hist_arr[mi][1 + 2 * ssi]);
+
580  }
+
581  }
+
582  // And we can make the final normalisation product
+
583  // The value of norm_postfix is very important. text2workspace will only look
+
584  // for for a term with the pdf name + "_norm". But it might be the user wants
+
585  // to add even more terms to this total normalisation, so we give them the option
+
586  // of using some other suffix.
+
588  TString norm_postfix = "norm";
+
589  RooProduct morph_rate(morph_name + "_" + TString(norm_postfix), "",
+
590  rate_prod);
+
592 
+
593  // Dump even more plots
+
594  // if (file) MakeMorphDebugPlots(&morph_pdf, &mass_var, m_vec, file, &data_hist);
+
595 
+
596  // Load our pdf and norm objects into the workspace
+
597  ws.import(morph_func, RooFit::RecycleConflictNodes());
+
598  if (rate_prod.getSize() > 0) {
+
599  ws.import(morph_rate, RooFit::RecycleConflictNodes());
+
600  } else {
+
601  std::cout << "No normalisation term to import!\n";
+
602  }
+
603 
+
604  // if (!verbose) RooMsgService::instance().setGlobalKillBelow(backup_msg_level);
+
605 //
+
606  // Now we can clean up the CH instance a bit
+
607  // We only need one entry for each Process or Systematic now, not one per mass point
+
608  // We'll modify the first mass point to house our new pdf and norm, and drop
+
609  // the rest.
+
610  std::string mass_min = m_str_vec.at(0);
+
611 
+
612  // Dump Process entries for other mass points
+
613  cb.FilterProcs([&](ch::Process const* p) {
+
614  return p->bin() == bin && p->process() == process && p->mass() != mass_min;
+
615  });
+
616  // Dump Systematic entries for other mass points, but only if the type is shape
+
617  // or a lnN that we found varied as a function of the mass. We've already built
+
618  // these uncertainties into our normalisation term. Constant lnN systematics can
+
619  // remain in the datacard and be added by text2workspace
+
620  cb.FilterSysts([&](ch::Systematic const* n) {
+
621  return (n->bin() == bin && n->process() == process) &&
+
622  ((n->mass() != mass_min) || (n->type() == "shape" || n->type() == "shapeU") ||
+
623  (lms_set.count(n->name())));
+
624  });
+
625  // With the remaining Process entry (should only be one if we did this right),
+
626  // Make the mass generic ("*"), drop the TH1 and set the rate to 1.0, as this
+
627  // will now be read from our norm object
+
628  cb.ForEachProc([&](ch::Process * p) {
+
629  if (p->bin() == bin && p->process() == process) {
+
630  if (m > 1) {
+
631  p->set_mass("*");
+
632  }
+
633  p->set_shape(nullptr, false);
+
634  p->set_rate(1.0);
+
635  }
+
636  });
+
637  // Just declare the mass to be generic for the remaining systematics
+
638  if (m > 1) {
+
639  cb.ForEachSyst([&](ch::Systematic * n) {
+
640  if (n->bin() == bin && n->process() == process) {
+
641  n->set_mass("*");
+
642  }
+
643  });
+
644  }
+
645 
+
646  // And we're done, but note that we haven't populated the Process entry with
+
647  // the PDF or norm objects we created, as we assume the user has more work to
+
648  // do on their RooWorkspace before copying into the CH instance. Once they've
+
649  // imported the workspace:
+
650  //
+
651  // cb.AddWorkspace(ws);
+
652  //
+
653  // They can populate the Process entries, e.g. if all signals were replaced
+
654  // with Morphing PDFs:
+
655  //
+
656  // cb.cp().signals().ExtractPdfs(cb, "htt", "$BIN_$PROCESS_morph");
+
658 }
+
659 
+
660 
+
661 
+
662 
+
663 
+
664 // }
+
665 
+
666 // void MakeMorphDebugPlots(RooMorphingPdf* pdf, RooAbsReal* mass,
+
667 // std::vector<double> const& masses, TFile* f, TH1 *ref_bins) {
+
668 // RooRealVar *rrv = dynamic_cast<RooRealVar*>(mass);
+
669 // if (!rrv) return;
+
670 // f->cd();
+
671 // f->mkdir(pdf->GetName());
+
672 // gDirectory->cd(pdf->GetName());
+
673 // for (unsigned i = 0; i < masses.size(); ++i) {
+
674 // rrv->setVal(masses[i]);
+
675 // TH1 * h = pdf->createHistogram("CMS_th1x");
+
676 // h->AddDirectory(false);
+
677 // TH1 * h2 = nullptr;
+
678 // if (ref_bins) {
+
679 // h2 = (TH1*)ref_bins->Clone();
+
680 // h2->Reset();
+
681 // for (int x = 1; x <= h2->GetNbinsX(); ++x) {
+
682 // h2->SetBinContent(x, h->GetBinContent(x));
+
683 // }
+
684 // } else {
+
685 // h2 = h;
+
686 // h = nullptr;
+
687 // }
+
688 // h2->AddDirectory(false);
+
689 // h2->SetName(TString::Format("actual_point_%g", masses[i]));
+
690 // gDirectory->WriteTObject(h2);
+
691 // if (h) delete h;
+
692 // if (h2) delete h2;
+
693 // }
+
694 // double m = masses.front();
+
695 // double step = 1;
+
696 // if (((masses.back() - masses.front()) / step) > 100.) step = step * 10.;
+
697 // if (((masses.back() - masses.front()) / step) > 100.) step = step * 10.;
+
698 // if (((masses.back() - masses.front()) / step) < 10.) step = step/10.;
+
699 // while (m <= masses.back()) {
+
700 // rrv->setVal(m);
+
701 // TH1* hm = pdf->createHistogram("CMS_th1x");
+
702 // hm->AddDirectory(false);
+
703 // TH1 * hm2 = nullptr;
+
704 // if (ref_bins) {
+
705 // hm2 = (TH1*)ref_bins->Clone();
+
706 // hm2->Reset();
+
707 // for (int x = 1; x <= hm2->GetNbinsX(); ++x) {
+
708 // hm2->SetBinContent(x, hm->GetBinContent(x));
+
709 // }
+
710 // } else {
+
711 // hm2 = hm;
+
712 // hm = nullptr;
+
713 // }
+
714 // hm2->AddDirectory(false);
+
715 // hm2->SetName(TString::Format("morph_point_%g", m));
+
716 // //It struggles with m=0, instead adds really small number close to 0
+
717 // if(fabs(m) < 1E-5) hm2->SetName(TString::Format("morph_point_0"));
+
718 // gDirectory->WriteTObject(hm2);
+
719 // if (hm) delete hm;
+
720 // if (hm2) delete hm2;
+
721 // m += step;
+
722 // }
+
723 // f->cd();
+
724 // }
+
725 }
+ + +
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
+
virtual void set_mass(std::string const &mass)
Definition: Object.h:37
+
CombineHarvester & syst_type(std::vector< std::string > const &vec, bool cond=true)
+
void Run(CombineHarvester &cb, RooWorkspace &ws)
+
std::string const & type() const
Definition: Systematic.h:24
+
std::set< std::string > bin_set()
+ + +
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Observation.cc:51
+
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
+
void set_rate(double const &rate)
Definition: Process.h:24
+
CombineHarvester & FilterProcs(Function func)
+
#define FNERROR(x)
Definition: Logging.h:9
+
virtual std::string const & process() const
Definition: Object.h:20
+
void set_rate(double const &rate)
Definition: Observation.h:20
+
Definition: Algorithm.h:10
+
virtual std::string const & mass() const
Definition: Object.h:38
+
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
+ +
TH1F RebinHist(TH1F const &hist)
Definition: Utilities.cc:170
+
void ForEachProc(Function func)
+ +
CombineHarvester & mass(std::vector< std::string > const &vec, bool cond=true)
+
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
+
virtual std::string const & bin() const
Definition: Object.h:17
+
void ForEachSyst(Function func)
+
CombineHarvester & FilterSysts(Function func)
+ + +
std::string const & name() const
Definition: Systematic.h:21
+ + +
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:69
+
+
+ + + + diff --git a/_c_m_s_hist_func_factory_8h.html b/_c_m_s_hist_func_factory_8h.html new file mode 100644 index 00000000000..286e3a9ab4e --- /dev/null +++ b/_c_m_s_hist_func_factory_8h.html @@ -0,0 +1,134 @@ + + + + + + + +CombineHarvester: CombinePdfs/interface/CMSHistFuncFactory.h File Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
CombineHarvester +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
CMSHistFuncFactory.h File Reference
+
+
+
#include <algorithm>
+#include <vector>
+#include "RooWorkspace.h"
+#include "RooHistPdf.h"
+#include "RooBinning.h"
+#include "CombineHarvester/CombineTools/interface/CombineHarvester.h"
+#include "HiggsAnalysis/CombinedLimit/interface/CMSHistFunc.h"
+#include "HiggsAnalysis/CombinedLimit/interface/RooSpline1D.h"
+#include "HiggsAnalysis/CombinedLimit/interface/VerticalInterpHistPdf.h"
+#include "HiggsAnalysis/CombinedLimit/interface/AsymPow.h"
+
+

Go to the source code of this file.

+ + + + +

+Data Structures

class  ch::CMSHistFuncFactory
 
+ + + +

+Namespaces

 ch
 
+
+
+ + + + diff --git a/_c_m_s_hist_func_factory_8h_source.html b/_c_m_s_hist_func_factory_8h_source.html new file mode 100644 index 00000000000..ddca3df436b --- /dev/null +++ b/_c_m_s_hist_func_factory_8h_source.html @@ -0,0 +1,182 @@ + + + + + + + +CombineHarvester: CombinePdfs/interface/CMSHistFuncFactory.h Source File + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
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);
+
24  void SetHorizontalMorphingVariable(std::map<std::string, RooAbsReal*> &hvar) { mass_var = hvar; }
+ +
26 private:
+
27  unsigned v_;
+
28  // RooAbsReal *mass_var;
+
29  std::map<std::string, RooAbsReal*> mass_var;
+
30  void RunSingleProc(CombineHarvester& cb, RooWorkspace& ws, std::string bin, std::string process);
+
31  std::map<std::string, RooRealVar> obs_;
+
32  unsigned hist_mode_;
+
33  bool rebin_;
+
34 
+
35  TH1F AsTH1F(TH1 const* hist) {
+
36  TH1F res;
+
37  TH1F const* test_f = dynamic_cast<TH1F const*>(hist);
+
38  TH1D const* test_d = dynamic_cast<TH1D const*>(hist);
+
39  if (test_f) {
+
40  test_f->Copy(res);
+
41  } else if (test_d) {
+
42  test_d->Copy(res);
+
43  } else {
+
44  throw std::runtime_error("TH1 is not a TH1F or a TH1D");
+
45  }
+
46  return res;
+
47  }
+
48 
+
49  RooRealVar VarFromHist(TString name, TString title, TH1 const& hist) {
+
50  RooBinning * binning;
+
51  if (hist.GetXaxis()->GetXbins() && hist.GetXaxis()->GetXbins()->GetSize()) {
+
52  binning = new RooBinning(hist.GetNbinsX(), hist.GetXaxis()->GetXbins()->GetArray());
+
53  } else {
+
54  binning = new RooBinning(hist.GetNbinsX(), hist.GetXaxis()->GetXmin(), hist.GetXaxis()->GetXmax());
+
55  }
+
56  RooRealVar x(name, title, hist.GetXaxis()->GetXmin(), hist.GetXaxis()->GetXmax());
+
57  // x.getBinning().Print();
+
58  x.setBinning(*binning);
+
59  delete binning;
+
60  return x;
+
61  }
+
62 };
+
63 
+
64 }
+
65 
+
66 #endif
+
void SetHorizontalMorphingVariable(std::map< std::string, RooAbsReal * > &hvar)
+ + +
void Run(CombineHarvester &cb, RooWorkspace &ws)
+ +
Definition: Algorithm.h:10
+ + +
+
+ + + + diff --git a/_card_writer_8cc_source.html b/_card_writer_8cc_source.html index d664a9c4610..70ff5e18f85 100644 --- a/_card_writer_8cc_source.html +++ b/_card_writer_8cc_source.html @@ -158,112 +158,134 @@
56  }
57  f_map[key] = mappings;
58  });
-
59  return f_map;
-
60 }
-
61 
-
62 void CardWriter::MakeDirs(PatternMap const& map) const {
-
63  std::set<boost::filesystem::path> mk_dirs;
-
64  for (auto const& f : map) {
-
65  mk_dirs.insert(boost::filesystem::path(f.first).parent_path());
-
66  }
-
67  for (auto & dir : mk_dirs) {
-
68  FNLOGC(std::cout, v_ > 0) << "Creating dir " << dir.string() << "\n";
-
69 
-
70  boost::filesystem::create_directories(dir);
-
71  }
-
72 }
-
73 
-
74 std::map<std::string, CombineHarvester> CardWriter::WriteCards(std::string const& tag,
-
75  ch::CombineHarvester& cmb) const {
-
76  #ifdef TIME_FUNCTIONS
-
77  LAUNCH_FUNCTION_TIMER(__timer__, __token__)
-
78  #endif
-
79 
-
80  // Update the current "$TAG" value
-
81  tag_ = tag;
-
82 
-
83  // Build the set of files we need to create (the map keys), and associate a
-
84  // set of compiled Object patterns that are associated to each file (the map
-
85  // values). One entry will typically look like:
-
86  //
-
87  // ["htt_mt_125.root"] = {"htt_mt_125.root", "htt_mt_*.root"}
-
88  //
-
89  // i.e. in addition to getting a pattern identical to the filename, we also
-
90  // get a pattern where each $MASS placeholder has been replaced by a wildcard
-
91  // expression.
-
92  auto f_map = BuildMap(root_pattern_, cmb);
-
93 
-
94  if (create_dirs_) MakeDirs(f_map);
+
59  auto masses = cmb.cp().mass(wildcard_masses_, false).mass_set();
+
60  cmb.cp().mass(wildcard_masses_, true)
+
61  .ForEachObj([&](ch::Object const* obj) {
+
62  // Build the fully-compiled key
+
63  std::string key = Compile(pattern, obj, true);
+
64  for (auto m : masses) {
+
65  std::string full_key = key;
+
66  boost::replace_all(full_key, "$MASS", m);
+
67  if (f_map.count(full_key)) continue;
+
68  std::set<std::string> mappings;
+
69  // The fully-compiled pattern always goes in
+
70  std::string wildcard_key = key;
+
71  boost::replace_all(wildcard_key, "$MASS", obj->mass());
+
72  mappings.insert(wildcard_key);
+
73  f_map[full_key] = mappings;
+
74  }
+
75  });
+
76  for (auto const& it : f_map) {
+
77  std::cout << it.first << ": ";
+
78  for (auto const& it2 : it.second) std::cout << it2 << " ";
+
79  std::cout << "\n";
+
80  }
+
81  return f_map;
+
82 }
+
83 
+
84 void CardWriter::MakeDirs(PatternMap const& map) const {
+
85  std::set<boost::filesystem::path> mk_dirs;
+
86  for (auto const& f : map) {
+
87  mk_dirs.insert(boost::filesystem::path(f.first).parent_path());
+
88  }
+
89  for (auto & dir : mk_dirs) {
+
90  FNLOGC(std::cout, v_ > 0) << "Creating dir " << dir.string() << "\n";
+
91 
+
92  boost::filesystem::create_directories(dir);
+
93  }
+
94 }
95 
-
96  // It turns out that the Compile method takes a small but appreciable amount
-
97  // of CPU time. To evaluate it every time it's needed could be O(10^7) calls,
-
98  // equivalent to tens of seconds for a complex model. To avoid this we just
-
99  // calculate once for each ch::Object and store the result in a map, which we
-
100  // use as a look-up later.
-
101  std::map<Object const*, std::string> root_map;
-
102  cmb.ForEachObj([&](ch::Object const* obj) {
-
103  root_map[obj] = Compile(root_pattern_, obj);
-
104  });
-
105  std::map<Object const*, std::string> text_map;
-
106  cmb.ForEachObj([&](ch::Object const* obj) {
-
107  text_map[obj] = Compile(text_pattern_, obj);
-
108  });
-
109 
-
110  std::map<std::string, CombineHarvester> datacards;
-
111  for (auto const& f : f_map) {
-
112  // Create each ROOT file (overwrite pre-existing)
-
113  FNLOGC(std::cout, v_ > 0) << "Creating file " << f.first << "\n";
-
114  TFile file(f.first.c_str(), "RECREATE");
+
96 std::map<std::string, CombineHarvester> CardWriter::WriteCards(std::string const& tag,
+
97  ch::CombineHarvester& cmb) const {
+
98  #ifdef TIME_FUNCTIONS
+
99  LAUNCH_FUNCTION_TIMER(__timer__, __token__)
+
100  #endif
+
101 
+
102  // Update the current "$TAG" value
+
103  tag_ = tag;
+
104 
+
105  // Build the set of files we need to create (the map keys), and associate a
+
106  // set of compiled Object patterns that are associated to each file (the map
+
107  // values). One entry will typically look like:
+
108  //
+
109  // ["htt_mt_125.root"] = {"htt_mt_125.root", "htt_mt_*.root"}
+
110  //
+
111  // i.e. in addition to getting a pattern identical to the filename, we also
+
112  // get a pattern where each $MASS placeholder has been replaced by a wildcard
+
113  // expression.
+
114  auto f_map = BuildMap(root_pattern_, cmb);
115 
-
116  // Filter CH instance to leave only the objects that will be written into
-
117  // this file
-
118  CombineHarvester f_cmb = cmb.cp().FilterAll([&](ch::Object const* obj) {
-
119  return !ch::contains(f.second, root_map.at(obj));
-
120  });
-
121 
-
122  // Call BuildMap again - this time to figure out which text datacards to
-
123  // create
-
124  auto d_map = BuildMap(text_pattern_, f_cmb);
-
125 
-
126  // Create dirs if we're allowed to
-
127  if (create_dirs_) MakeDirs(d_map);
-
128 
-
129  // Loop through each datacard
-
130  for (auto const& d : d_map) {
-
131  // Filter CH instance to leave only the objects that will be written into
-
132  // this text datacard
-
133  CombineHarvester d_cmb = f_cmb.cp().FilterAll([&](ch::Object const* obj) {
-
134  return !ch::contains(d.second, text_map.at(obj));
-
135  });
-
136  FNLOGC(std::cout, v_ > 0) << "Creating datacard " << d.first << "\n";
-
137  d_cmb.WriteDatacard(d.first, file);
-
138  datacards[d.first] = d_cmb;
-
139  }
-
140  };
-
141  return datacards;
-
142 }
+
116  if (create_dirs_) MakeDirs(f_map);
+
117 
+
118  // It turns out that the Compile method takes a small but appreciable amount
+
119  // of CPU time. To evaluate it every time it's needed could be O(10^7) calls,
+
120  // equivalent to tens of seconds for a complex model. To avoid this we just
+
121  // calculate once for each ch::Object and store the result in a map, which we
+
122  // use as a look-up later.
+
123  std::map<Object const*, std::string> root_map;
+
124  cmb.ForEachObj([&](ch::Object const* obj) {
+
125  root_map[obj] = Compile(root_pattern_, obj);
+
126  });
+
127  std::map<Object const*, std::string> text_map;
+
128  cmb.ForEachObj([&](ch::Object const* obj) {
+
129  text_map[obj] = Compile(text_pattern_, obj);
+
130  });
+
131 
+
132  std::map<std::string, CombineHarvester> datacards;
+
133  for (auto const& f : f_map) {
+
134  // Create each ROOT file (overwrite pre-existing)
+
135  FNLOGC(std::cout, v_ > 0) << "Creating file " << f.first << "\n";
+
136  TFile file(f.first.c_str(), "RECREATE");
+
137 
+
138  // Filter CH instance to leave only the objects that will be written into
+
139  // this file
+
140  CombineHarvester f_cmb = cmb.cp().FilterAll([&](ch::Object const* obj) {
+
141  return !ch::contains(f.second, root_map.at(obj));
+
142  });
143 
-
144 std::string CardWriter::Compile(std::string pattern, ch::Object const* obj,
-
145  bool skip_mass) const {
-
146  #ifdef TIME_FUNCTIONS
-
147  LAUNCH_FUNCTION_TIMER(__timer__, __token__)
-
148  #endif
-
149  boost::replace_all(pattern, "$TAG", tag_);
-
150  boost::replace_all(pattern, "$BINID",
-
151  boost::lexical_cast<std::string>(obj->bin_id()));
-
152  boost::replace_all(pattern, "$BIN", obj->bin());
-
153  boost::replace_all(pattern, "$PROCESS", obj->process());
-
154  if (!skip_mass) boost::replace_all(pattern, "$MASS", obj->mass());
-
155  boost::replace_all(pattern, "$ERA", obj->era());
-
156  boost::replace_all(pattern, "$CHANNEL", obj->channel());
-
157  boost::replace_all(pattern, "$ANALYSIS", obj->analysis());
-
158  return pattern;
-
159 }
-
160 }
+
144  // Call BuildMap again - this time to figure out which text datacards to
+
145  // create
+
146  auto d_map = BuildMap(text_pattern_, f_cmb);
+
147 
+
148  // Create dirs if we're allowed to
+
149  if (create_dirs_) MakeDirs(d_map);
+
150 
+
151  // Loop through each datacard
+
152  for (auto const& d : d_map) {
+
153  // Filter CH instance to leave only the objects that will be written into
+
154  // this text datacard
+
155  CombineHarvester d_cmb = f_cmb.cp().FilterAll([&](ch::Object const* obj) {
+
156  return !ch::contains(d.second, text_map.at(obj));
+
157  });
+
158  FNLOGC(std::cout, v_ > 0) << "Creating datacard " << d.first << "\n";
+
159  d_cmb.WriteDatacard(d.first, file);
+
160  datacards[d.first] = d_cmb;
+
161  }
+
162  };
+
163  return datacards;
+
164 }
+
165 
+
166 std::string CardWriter::Compile(std::string pattern, ch::Object const* obj,
+
167  bool skip_mass) const {
+
168  #ifdef TIME_FUNCTIONS
+
169  LAUNCH_FUNCTION_TIMER(__timer__, __token__)
+
170  #endif
+
171  boost::replace_all(pattern, "$TAG", tag_);
+
172  boost::replace_all(pattern, "$BINID",
+
173  boost::lexical_cast<std::string>(obj->bin_id()));
+
174  boost::replace_all(pattern, "$BIN", obj->bin());
+
175  boost::replace_all(pattern, "$PROCESS", obj->process());
+
176  if (!skip_mass) boost::replace_all(pattern, "$MASS", obj->mass());
+
177  boost::replace_all(pattern, "$ERA", obj->era());
+
178  boost::replace_all(pattern, "$CHANNEL", obj->channel());
+
179  boost::replace_all(pattern, "$ANALYSIS", obj->analysis());
+
180  return pattern;
+
181 }
+
182 }
ch::Object::analysis
virtual std::string const & analysis() const
Definition: Object.h:26
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::WriteDatacard
void WriteDatacard(std::string const &name, std::string const &root_file)
Definition: CombineHarvester_Datacards.cc:454
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::WriteDatacard
void WriteDatacard(std::string const &name, std::string const &root_file)
Definition: CombineHarvester_Datacards.cc:455
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::Object::bin_id
virtual int bin_id() const
Definition: Object.h:35
ch::CardWriter::SetWildcardMasses
CardWriter & SetWildcardMasses(std::vector< std::string > const &masses)
Redefine the mass values that should be treated as wildcards.
Definition: CardWriter.cc:31
ch::CardWriter
Automates the writing of datacards into directory structures.
Definition: CardWriter.h:50
@@ -273,15 +295,15 @@
Algorithm.h
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
ch::CardWriter::CardWriter
CardWriter(std::string const &text_pattern, std::string const &root_pattern)
Must be constructed with text and ROOT file patterns.
Definition: CardWriter.cc:12
-
ch::CombineHarvester::FilterAll
CombineHarvester & FilterAll(Function func)
Definition: CombineHarvester.h:607
+
ch::CombineHarvester::FilterAll
CombineHarvester & FilterAll(Function func)
Definition: CombineHarvester.h:621
LAUNCH_FUNCTION_TIMER
#define LAUNCH_FUNCTION_TIMER(x, y)
Conveniently initialise a ch::FnTimer instance.
Definition: Logging.h:67
FNLOGC
#define FNLOGC(x, y)
Definition: Logging.h:14
ch::contains
bool contains(const Range &r, T p)
Definition: Algorithm.h:22
ch::CardWriter::CreateDirectories
CardWriter & CreateDirectories(bool flag)
Control whether directories can be created if missing.
Definition: CardWriter.cc:25
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::Object::era
virtual std::string const & era() const
Definition: Object.h:29
-
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:585
-
ch::CardWriter::WriteCards
std::map< std::string, CombineHarvester > WriteCards(std::string const &tag, ch::CombineHarvester &cmb) const
Write datacards according to patterns, substituting $TAG for tag
Definition: CardWriter.cc:74
+
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:599
+
ch::CardWriter::WriteCards
std::map< std::string, CombineHarvester > WriteCards(std::string const &tag, ch::CombineHarvester &cmb) const
Write datacards according to patterns, substituting $TAG for tag
Definition: CardWriter.cc:96
ch::Object
Definition: Object.h:8
Logging.h
CardWriter.h
diff --git a/_card_writer_8h_source.html b/_card_writer_8h_source.html index 237abb896e7..91939307c61 100644 --- a/_card_writer_8h_source.html +++ b/_card_writer_8h_source.html @@ -145,7 +145,7 @@
ch::CardWriter::CardWriter
CardWriter(std::string const &text_pattern, std::string const &root_pattern)
Must be constructed with text and ROOT file patterns.
Definition: CardWriter.cc:12
Object.h
ch::CardWriter::CreateDirectories
CardWriter & CreateDirectories(bool flag)
Control whether directories can be created if missing.
Definition: CardWriter.cc:25
-
ch::CardWriter::WriteCards
std::map< std::string, CombineHarvester > WriteCards(std::string const &tag, ch::CombineHarvester &cmb) const
Write datacards according to patterns, substituting $TAG for tag
Definition: CardWriter.cc:74
+
ch::CardWriter::WriteCards
std::map< std::string, CombineHarvester > WriteCards(std::string const &tag, ch::CombineHarvester &cmb) const
Write datacards according to patterns, substituting $TAG for tag
Definition: CardWriter.cc:96
ch::Object
Definition: Object.h:8
ch::CardWriter::SetVerbosity
CardWriter & SetVerbosity(unsigned v)
Set >= 1 for verbose output, otherwise silent.
Definition: CardWriter.cc:20
diff --git a/_combine_harvester_8cc_source.html b/_combine_harvester_8cc_source.html index eab7c2f5294..1be8db04058 100644 --- a/_combine_harvester_8cc_source.html +++ b/_combine_harvester_8cc_source.html @@ -143,770 +143,781 @@
41  swap(first.wspaces_, second.wspaces_);
42  swap(first.verbosity_, second.verbosity_);
43  swap(first.flags_, second.flags_);
-
44  swap(first.log_, second.log_);
-
45 }
-
46 
-
47 CombineHarvester::CombineHarvester(CombineHarvester const& other)
-
48  : obs_(other.obs_),
-
49  procs_(other.procs_),
-
50  systs_(other.systs_),
-
51  params_(other.params_),
-
52  wspaces_(other.wspaces_),
-
53  flags_(other.flags_),
-
54  verbosity_(other.verbosity_),
-
55  log_(other.log_) {
-
56  // std::cout << "[CombineHarvester] Copy-constructor called " << &other
-
57  // << " -> " << this << "\n";
-
58 }
-
59 
-
60 
-
61 void CombineHarvester::SetFlag(std::string const& flag, bool const& value) {
-
62  auto it = flags_.find(flag);
-
63  if (it != flags_.end()) {
-
64  FNLOG(std::cout) << "Changing value of flag \"" << it->first << "\" from " << it->second << " to " << value << "\n";
-
65  it->second = value;
-
66  } else {
-
67  FNLOG(std::cout) << "Created new flag \"" << flag << "\" with value " << value << "\n";
-
68  flags_[flag] = value;
-
69  }
-
70 }
-
71 
-
72 bool CombineHarvester::GetFlag(std::string const& flag) const {
-
73  auto it = flags_.find(flag);
-
74  if (it != flags_.end()) {
-
75  return it->second;
-
76  } else {
-
77  throw std::runtime_error(FNERROR("Flag " + flag + " is not defined"));
-
78  }
-
79 }
-
80 
-
81 CombineHarvester CombineHarvester::deep() {
-
82  CombineHarvester cpy;
-
83  // std::cout << "[CombineHarvester] Deep copy called " << this
-
84  // << " -> " << &cpy << "\n";
-
85  cpy.obs_.resize(obs_.size());
-
86  cpy.procs_.resize(procs_.size());
-
87  cpy.systs_.resize(systs_.size());
-
88  cpy.flags_ = flags_;
-
89  cpy.verbosity_ = verbosity_;
-
90  cpy.log_ = log_;
-
91 
-
92  // Build a map of workspace object pointers
-
93  std::map<RooAbsData const*, RooAbsData *> dat_map;
-
94  std::map<RooAbsPdf const*, RooAbsPdf *> pdf_map;
-
95  std::map<RooRealVar const*, RooRealVar *> var_map;
-
96  std::map<RooAbsReal const*, RooAbsReal *> fun_map;
-
97 
-
98  // Loop through each workspace and make a full copy
-
99  for (auto const& it : wspaces_) {
-
100  std::string ws_name = it.first;
-
101  RooWorkspace const& o_wsp = *(it.second.get());
-
102  cpy.wspaces_.insert({ws_name, std::make_shared<RooWorkspace>(o_wsp)});
-
103  RooWorkspace & n_wsp = *(cpy.wspaces_.at(ws_name).get());
-
104 
-
105  std::list<RooAbsData *> o_dat = o_wsp.allData();
-
106  RooArgSet const& o_pdf = o_wsp.allPdfs();
-
107  RooArgSet const& o_var = o_wsp.allVars();
-
108  RooArgSet const& o_fun = o_wsp.allFunctions();
-
109 
-
110  std::list<RooAbsData *> n_dat = n_wsp.allData();
-
111  RooArgSet const& n_pdf = n_wsp.allPdfs();
-
112  RooArgSet const& n_var = n_wsp.allVars();
-
113  RooArgSet const& n_fun = n_wsp.allFunctions();
-
114 
-
115  auto o_dat_it = o_dat.begin();
-
116  auto n_dat_it = n_dat.begin();
-
117  for (; o_dat_it != o_dat.end(); ++o_dat_it, ++n_dat_it) {
-
118  dat_map[*o_dat_it] = *n_dat_it;
-
119  }
-
120 
-
121  auto o_pdf_it = o_pdf.createIterator();
-
122  auto n_pdf_it = n_pdf.createIterator();
-
123  do {
-
124  RooAbsPdf *o_pdf_ptr = static_cast<RooAbsPdf*>(**o_pdf_it);
-
125  RooAbsPdf *n_pdf_ptr = static_cast<RooAbsPdf*>(**n_pdf_it);
-
126  if (o_pdf_ptr && n_pdf_ptr) pdf_map[o_pdf_ptr] = n_pdf_ptr;
-
127  n_pdf_it->Next();
-
128  } while (o_pdf_it->Next());
-
129 
-
130  auto o_var_it = o_var.createIterator();
-
131  auto n_var_it = n_var.createIterator();
-
132  do {
-
133  RooRealVar *o_var_ptr = static_cast<RooRealVar*>(**o_var_it);
-
134  RooRealVar *n_var_ptr = static_cast<RooRealVar*>(**n_var_it);
-
135  if (o_var_ptr && n_var_ptr) var_map[o_var_ptr] = n_var_ptr;
-
136  n_var_it->Next();
-
137  } while (o_var_it->Next());
-
138 
-
139  auto o_fun_it = o_fun.createIterator();
-
140  auto n_fun_it = n_fun.createIterator();
-
141  do {
-
142  RooAbsReal *o_fun_ptr = static_cast<RooAbsReal*>(**o_fun_it);
-
143  RooAbsReal *n_fun_ptr = static_cast<RooAbsReal*>(**n_fun_it);
-
144  if (o_fun_ptr && n_fun_ptr) fun_map[o_fun_ptr] = n_fun_ptr;
-
145  n_fun_it->Next();
-
146  } while (o_fun_it->Next());
-
147  }
-
148 
-
149 
-
150  for (std::size_t i = 0; i < cpy.obs_.size(); ++i) {
-
151  if (obs_[i]) {
-
152  cpy.obs_[i] = std::make_shared<Observation>(*(obs_[i]));
-
153  if (obs_[i]->data())
-
154  cpy.obs_[i]->set_data(dat_map.at(obs_[i]->data()));
-
155  }
-
156  }
-
157 
-
158  for (std::size_t i = 0; i < cpy.procs_.size(); ++i) {
-
159  if (procs_[i]) {
-
160  cpy.procs_[i] = std::make_shared<Process>(*(procs_[i]));
-
161  if (procs_[i]->pdf())
-
162  cpy.procs_[i]->set_pdf(pdf_map.at(procs_[i]->pdf()));
-
163  if (procs_[i]->data())
-
164  cpy.procs_[i]->set_data(dat_map.at(procs_[i]->data()));
-
165  if (procs_[i]->norm())
-
166  cpy.procs_[i]->set_norm(fun_map.at(procs_[i]->norm()));
-
167  }
-
168  }
-
169 
-
170  for (std::size_t i = 0; i < cpy.systs_.size(); ++i) {
-
171  if (systs_[i]) {
-
172  cpy.systs_[i] = std::make_shared<Systematic>(*(systs_[i]));
-
173  if (systs_[i]->data_u() || systs_[i]->data_d()) {
-
174  cpy.systs_[i]->set_data(
-
175  static_cast<RooDataHist*>(dat_map.at(systs_[i]->data_u())),
-
176  static_cast<RooDataHist*>(dat_map.at(systs_[i]->data_d())),
-
177  nullptr);
-
178  }
-
179  }
-
180  }
-
181 
-
182  for (auto const& it : params_) {
-
183  if (it.second) {
-
184  cpy.params_.insert({it.first, std::make_shared<Parameter>(*(it.second))});
-
185  } else {
-
186  params_.insert({it.first, nullptr});
-
187  }
-
188  }
-
189 
-
190  for (auto it : cpy.params_) {
-
191  for (unsigned i = 0; i < it.second->vars().size(); ++i) {
-
192  it.second->vars()[i] = var_map.at(it.second->vars()[i]);
-
193  }
-
194  }
-
195  return cpy;
-
196 }
-
197 
-
198 CombineHarvester::CombineHarvester(CombineHarvester&& other) {
-
199  // std::cout << "[CombineHarvester] Move-constructor called " <<
-
200  // &other << " -> " << this << "\n";
-
201  swap(*this, other);
-
202 }
-
203 
-
204 CombineHarvester& CombineHarvester::operator=(CombineHarvester other) {
-
205  // std::cout << "[CombineHarvester] Assignment operator called " << &other <<
-
206  // " -> " << this << "\n";
-
207  swap(*this, other);
-
208  return (*this);
-
209 }
-
210 
-
211 CombineHarvester CombineHarvester::cp() {
-
212  // std::cout << "[CombineHarvester] Shallow copy method cp() called from " <<
-
213  // this << "\n";
-
214  return CombineHarvester(*this);
-
215 }
-
216 
-
217 CombineHarvester & CombineHarvester::PrintAll() {
-
218  return PrintObs().PrintProcs().PrintSysts().PrintParams();
-
219 }
-
220 
-
221 CombineHarvester & CombineHarvester::PrintObs() {
-
222  std::cout << Observation::PrintHeader;
-
223  for (unsigned i = 0; i < obs_.size(); ++i)
-
224  std::cout << *(obs_[i]) << "\n";
-
225  return *this;
-
226 }
-
227 
-
228 CombineHarvester & CombineHarvester::PrintProcs() {
-
229  std::cout << Process::PrintHeader;
-
230  for (unsigned i = 0; i < procs_.size(); ++i)
-
231  std::cout << *(procs_[i]) << "\n";
-
232  return *this;
-
233 }
-
234 
-
235 CombineHarvester & CombineHarvester::PrintSysts() {
-
236  std::cout << Systematic::PrintHeader;
-
237  for (unsigned i = 0; i < systs_.size(); ++i)
-
238  std::cout << *(systs_[i]) << "\n";
-
239  return *this;
-
240 }
-
241 
-
242 CombineHarvester & CombineHarvester::PrintParams() {
-
243  std::cout << Parameter::PrintHeader;
-
244  for (auto const& it : params_) std::cout << *(it.second) << "\n";
-
245  return *this;
-
246 }
-
247 
-
248 
-
272 void CombineHarvester::LoadShapes(Observation* entry,
-
273  std::vector<HistMapping> const& mappings) {
-
274  // Pre-condition #1
-
275  if (entry->shape() || entry->data()) {
-
276  throw std::runtime_error(FNERROR("Observation already contains a shape"));
-
277  }
-
278 
-
279  if (verbosity_ >= 2) {
-
280  LOGLINE(log(), "Extracting shapes for Observation:");
-
281  log() << Observation::PrintHeader << *entry << "\n";
-
282  LOGLINE(log(), "Mappings:");
-
283  for (HistMapping const& m : mappings) log() << m << "\n";
-
284  }
-
285 
-
286  // Pre-condition #2
-
287  // ResolveMapping will throw if this fails
-
288  if (mappings.size() == 0) {
-
289  if (verbosity_ >= 2) LOGLINE(log(), "No mappings in this card, assuming FAKE");
-
290  return;
-
291  }
-
292  HistMapping mapping =
-
293  ResolveMapping(entry->process(), entry->bin(), mappings);
-
294  boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
-
295  boost::replace_all(mapping.pattern, "$BIN", entry->bin());
-
296  boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
-
297  boost::replace_all(mapping.pattern, "$MASS", entry->mass());
-
298 
-
299  if (verbosity_ >= 2) {
-
300  LOGLINE(log(), "Resolved Mapping:");
-
301  log() << mapping << "\n";
-
302  }
+
44  swap(first.post_lines_, second.post_lines_);
+
45  swap(first.log_, second.log_);
+
46 }
+
47 
+
48 CombineHarvester::CombineHarvester(CombineHarvester const& other)
+
49  : obs_(other.obs_),
+
50  procs_(other.procs_),
+
51  systs_(other.systs_),
+
52  params_(other.params_),
+
53  wspaces_(other.wspaces_),
+
54  flags_(other.flags_),
+
55  post_lines_(other.post_lines_),
+
56  verbosity_(other.verbosity_),
+
57  log_(other.log_) {
+
58  // std::cout << "[CombineHarvester] Copy-constructor called " << &other
+
59  // << " -> " << this << "\n";
+
60 }
+
61 
+
62 
+
63 void CombineHarvester::SetFlag(std::string const& flag, bool const& value) {
+
64  auto it = flags_.find(flag);
+
65  if (it != flags_.end()) {
+
66  FNLOG(std::cout) << "Changing value of flag \"" << it->first << "\" from " << it->second << " to " << value << "\n";
+
67  it->second = value;
+
68  } else {
+
69  FNLOG(std::cout) << "Created new flag \"" << flag << "\" with value " << value << "\n";
+
70  flags_[flag] = value;
+
71  }
+
72 }
+
73 
+
74 bool CombineHarvester::GetFlag(std::string const& flag) const {
+
75  auto it = flags_.find(flag);
+
76  if (it != flags_.end()) {
+
77  return it->second;
+
78  } else {
+
79  throw std::runtime_error(FNERROR("Flag " + flag + " is not defined"));
+
80  }
+
81 }
+
82 
+
83 CombineHarvester CombineHarvester::deep() {
+
84  CombineHarvester cpy;
+
85  // std::cout << "[CombineHarvester] Deep copy called " << this
+
86  // << " -> " << &cpy << "\n";
+
87  cpy.obs_.resize(obs_.size());
+
88  cpy.procs_.resize(procs_.size());
+
89  cpy.systs_.resize(systs_.size());
+
90  cpy.flags_ = flags_;
+
91  cpy.verbosity_ = verbosity_;
+
92  cpy.post_lines_ = post_lines_;
+
93  cpy.log_ = log_;
+
94 
+
95  // Build a map of workspace object pointers
+
96  std::map<RooAbsData const*, RooAbsData *> dat_map;
+
97  std::map<RooAbsReal const*, RooAbsReal *> pdf_map;
+
98  std::map<RooRealVar const*, RooRealVar *> var_map;
+
99  std::map<RooAbsReal const*, RooAbsReal *> fun_map;
+
100 
+
101  // Loop through each workspace and make a full copy
+
102  for (auto const& it : wspaces_) {
+
103  std::string ws_name = it.first;
+
104  RooWorkspace const& o_wsp = *(it.second.get());
+
105  cpy.wspaces_.insert({ws_name, std::make_shared<RooWorkspace>(o_wsp)});
+
106  RooWorkspace & n_wsp = *(cpy.wspaces_.at(ws_name).get());
+
107 
+
108  std::list<RooAbsData *> o_dat = o_wsp.allData();
+
109  RooArgSet const& o_pdf = o_wsp.allPdfs();
+
110  RooArgSet const& o_var = o_wsp.allVars();
+
111  RooArgSet const& o_fun = o_wsp.allFunctions();
+
112 
+
113  std::list<RooAbsData *> n_dat = n_wsp.allData();
+
114  RooArgSet const& n_pdf = n_wsp.allPdfs();
+
115  RooArgSet const& n_var = n_wsp.allVars();
+
116  RooArgSet const& n_fun = n_wsp.allFunctions();
+
117 
+
118  auto o_dat_it = o_dat.begin();
+
119  auto n_dat_it = n_dat.begin();
+
120  for (; o_dat_it != o_dat.end(); ++o_dat_it, ++n_dat_it) {
+
121  dat_map[*o_dat_it] = *n_dat_it;
+
122  }
+
123 
+
124  auto o_pdf_it = o_pdf.createIterator();
+
125  auto n_pdf_it = n_pdf.createIterator();
+
126  do {
+
127  RooAbsPdf *o_pdf_ptr = static_cast<RooAbsPdf*>(**o_pdf_it);
+
128  RooAbsPdf *n_pdf_ptr = static_cast<RooAbsPdf*>(**n_pdf_it);
+
129  if (o_pdf_ptr && n_pdf_ptr) pdf_map[o_pdf_ptr] = n_pdf_ptr;
+
130  n_pdf_it->Next();
+
131  } while (o_pdf_it->Next());
+
132 
+
133  auto o_var_it = o_var.createIterator();
+
134  auto n_var_it = n_var.createIterator();
+
135  do {
+
136  RooRealVar *o_var_ptr = static_cast<RooRealVar*>(**o_var_it);
+
137  RooRealVar *n_var_ptr = static_cast<RooRealVar*>(**n_var_it);
+
138  if (o_var_ptr && n_var_ptr) var_map[o_var_ptr] = n_var_ptr;
+
139  n_var_it->Next();
+
140  } while (o_var_it->Next());
+
141 
+
142  auto o_fun_it = o_fun.createIterator();
+
143  auto n_fun_it = n_fun.createIterator();
+
144  do {
+
145  RooAbsReal *o_fun_ptr = static_cast<RooAbsReal*>(**o_fun_it);
+
146  RooAbsReal *n_fun_ptr = static_cast<RooAbsReal*>(**n_fun_it);
+
147  if (o_fun_ptr && n_fun_ptr) fun_map[o_fun_ptr] = n_fun_ptr;
+
148  n_fun_it->Next();
+
149  } while (o_fun_it->Next());
+
150  }
+
151 
+
152 
+
153  for (std::size_t i = 0; i < cpy.obs_.size(); ++i) {
+
154  if (obs_[i]) {
+
155  cpy.obs_[i] = std::make_shared<Observation>(*(obs_[i]));
+
156  if (obs_[i]->data())
+
157  cpy.obs_[i]->set_data(dat_map.at(obs_[i]->data()));
+
158  }
+
159  }
+
160 
+
161  for (std::size_t i = 0; i < cpy.procs_.size(); ++i) {
+
162  if (procs_[i]) {
+
163  cpy.procs_[i] = std::make_shared<Process>(*(procs_[i]));
+
164  if (procs_[i]->pdf())
+
165  cpy.procs_[i]->set_pdf(pdf_map.at(procs_[i]->pdf()));
+
166  if (procs_[i]->observable())
+
167  cpy.procs_[i]->set_observable(var_map.at(procs_[i]->observable()));
+
168  if (procs_[i]->data())
+
169  cpy.procs_[i]->set_data(dat_map.at(procs_[i]->data()));
+
170  if (procs_[i]->norm())
+
171  cpy.procs_[i]->set_norm(fun_map.at(procs_[i]->norm()));
+
172  }
+
173  }
+
174 
+
175  for (std::size_t i = 0; i < cpy.systs_.size(); ++i) {
+
176  if (systs_[i]) {
+
177  cpy.systs_[i] = std::make_shared<Systematic>(*(systs_[i]));
+
178  if (systs_[i]->data_u() || systs_[i]->data_d()) {
+
179  cpy.systs_[i]->set_data(
+
180  static_cast<RooDataHist*>(dat_map.at(systs_[i]->data_u())),
+
181  static_cast<RooDataHist*>(dat_map.at(systs_[i]->data_d())),
+
182  nullptr);
+
183  }
+
184  }
+
185  }
+
186 
+
187  for (auto const& it : params_) {
+
188  if (it.second) {
+
189  cpy.params_.insert({it.first, std::make_shared<Parameter>(*(it.second))});
+
190  } else {
+
191  params_.insert({it.first, nullptr});
+
192  }
+
193  }
+
194 
+
195  for (auto it : cpy.params_) {
+
196  for (unsigned i = 0; i < it.second->vars().size(); ++i) {
+
197  it.second->vars()[i] = var_map.at(it.second->vars()[i]);
+
198  }
+
199  }
+
200  return cpy;
+
201 }
+
202 
+
203 CombineHarvester::CombineHarvester(CombineHarvester&& other) {
+
204  // std::cout << "[CombineHarvester] Move-constructor called " <<
+
205  // &other << " -> " << this << "\n";
+
206  swap(*this, other);
+
207 }
+
208 
+
209 CombineHarvester& CombineHarvester::operator=(CombineHarvester other) {
+
210  // std::cout << "[CombineHarvester] Assignment operator called " << &other <<
+
211  // " -> " << this << "\n";
+
212  swap(*this, other);
+
213  return (*this);
+
214 }
+
215 
+
216 CombineHarvester CombineHarvester::cp() {
+
217  // std::cout << "[CombineHarvester] Shallow copy method cp() called from " <<
+
218  // this << "\n";
+
219  return CombineHarvester(*this);
+
220 }
+
221 
+
222 CombineHarvester & CombineHarvester::PrintAll() {
+
223  return PrintObs().PrintProcs().PrintSysts().PrintParams();
+
224 }
+
225 
+
226 CombineHarvester & CombineHarvester::PrintObs() {
+
227  std::cout << Observation::PrintHeader;
+
228  for (unsigned i = 0; i < obs_.size(); ++i)
+
229  std::cout << *(obs_[i]) << "\n";
+
230  return *this;
+
231 }
+
232 
+
233 CombineHarvester & CombineHarvester::PrintProcs() {
+
234  std::cout << Process::PrintHeader;
+
235  for (unsigned i = 0; i < procs_.size(); ++i)
+
236  std::cout << *(procs_[i]) << "\n";
+
237  return *this;
+
238 }
+
239 
+
240 CombineHarvester & CombineHarvester::PrintSysts() {
+
241  std::cout << Systematic::PrintHeader;
+
242  for (unsigned i = 0; i < systs_.size(); ++i)
+
243  std::cout << *(systs_[i]) << "\n";
+
244  return *this;
+
245 }
+
246 
+
247 CombineHarvester & CombineHarvester::PrintParams() {
+
248  std::cout << Parameter::PrintHeader;
+
249  for (auto const& it : params_) std::cout << *(it.second) << "\n";
+
250  return *this;
+
251 }
+
252 
+
253 
+
277 void CombineHarvester::LoadShapes(Observation* entry,
+
278  std::vector<HistMapping> const& mappings) {
+
279  // Pre-condition #1
+
280  if (entry->shape() || entry->data()) {
+
281  throw std::runtime_error(FNERROR("Observation already contains a shape"));
+
282  }
+
283 
+
284  if (verbosity_ >= 2) {
+
285  LOGLINE(log(), "Extracting shapes for Observation:");
+
286  log() << Observation::PrintHeader << *entry << "\n";
+
287  LOGLINE(log(), "Mappings:");
+
288  for (HistMapping const& m : mappings) log() << m << "\n";
+
289  }
+
290 
+
291  // Pre-condition #2
+
292  // ResolveMapping will throw if this fails
+
293  if (mappings.size() == 0) {
+
294  if (verbosity_ >= 2) LOGLINE(log(), "No mappings in this card, assuming FAKE");
+
295  return;
+
296  }
+
297  HistMapping mapping =
+
298  ResolveMapping(entry->process(), entry->bin(), mappings);
+
299  boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
+
300  boost::replace_all(mapping.pattern, "$BIN", entry->bin());
+
301  boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
+
302  boost::replace_all(mapping.pattern, "$MASS", entry->mass());
303 
-
304  if (mapping.is_fake) {
-
305  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is FAKE");
-
306  } else if (mapping.IsHist()) {
-
307  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type in TH1");
-
308  // Pre-condition #3
-
309  // GetClonedTH1 will throw if this fails
-
310  std::unique_ptr<TH1> h = GetClonedTH1(mapping.file.get(), mapping.pattern);
-
311  // Post-conditions #1 and #2
-
312  entry->set_shape(std::move(h), true);
-
313  } else if (mapping.IsData()) {
-
314  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is RooAbsData");
-
315  // Pre-condition #3
-
316  // SetupWorkspace will throw if workspace not found
-
317  RooAbsData* dat = mapping.ws->data(mapping.WorkspaceObj().c_str());
-
318  if (!dat) {
-
319  throw std::runtime_error(FNERROR("RooAbsData not found in workspace"));
-
320  }
-
321  // Post-condition #1
-
322  entry->set_data(dat);
-
323  entry->set_rate(dat->sumEntries());
-
324  }
-
325 }
-
326 
-
356 void CombineHarvester::LoadShapes(Process* entry,
-
357  std::vector<HistMapping> const& mappings) {
-
358  // Pre-condition #1
-
359  if (entry->shape() || entry->pdf()) {
-
360  throw std::runtime_error(FNERROR("Process already contains a shape"));
-
361  }
-
362 
-
363  if (verbosity_ >= 2) {
-
364  LOGLINE(log(), "Extracting shapes for Process:");
-
365  log() << Process::PrintHeader << *entry << "\n";
-
366  LOGLINE(log(), "Mappings:");
-
367  for (HistMapping const& m : mappings) log() << m << "\n";
-
368  }
-
369 
-
370  // Pre-condition #2
-
371  // ResolveMapping will throw if this fails
-
372  if (mappings.size() == 0) {
-
373  if (verbosity_ >= 2) LOGLINE(log(), "No mappings in this card, assuming FAKE");
-
374  return;
-
375  }
-
376  HistMapping mapping =
-
377  ResolveMapping(entry->process(), entry->bin(), mappings);
-
378  boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
-
379  boost::replace_all(mapping.pattern, "$BIN", entry->bin());
-
380  boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
-
381  boost::replace_all(mapping.pattern, "$MASS", entry->mass());
-
382 
-
383  if (verbosity_ >= 2) {
-
384  LOGLINE(log(), "Resolved Mapping:");
-
385  log() << mapping << "\n";
-
386  }
+
304  if (verbosity_ >= 2) {
+
305  LOGLINE(log(), "Resolved Mapping:");
+
306  log() << mapping << "\n";
+
307  }
+
308 
+
309  if (mapping.is_fake) {
+
310  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is FAKE");
+
311  } else if (mapping.IsHist()) {
+
312  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type in TH1");
+
313  // Pre-condition #3
+
314  // GetClonedTH1 will throw if this fails
+
315  std::unique_ptr<TH1> h = GetClonedTH1(mapping.file.get(), mapping.pattern);
+
316  // Post-conditions #1 and #2
+
317  entry->set_shape(std::move(h), true);
+
318  } else if (mapping.IsData()) {
+
319  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is RooAbsData");
+
320  // Pre-condition #3
+
321  // SetupWorkspace will throw if workspace not found
+
322  RooAbsData* dat = mapping.ws->data(mapping.WorkspaceObj().c_str());
+
323  if (!dat) {
+
324  throw std::runtime_error(FNERROR("RooAbsData not found in workspace"));
+
325  }
+
326  // Post-condition #1
+
327  entry->set_data(dat);
+
328  entry->set_rate(dat->sumEntries());
+
329  }
+
330 }
+
331 
+
361 void CombineHarvester::LoadShapes(Process* entry,
+
362  std::vector<HistMapping> const& mappings) {
+
363  // Pre-condition #1
+
364  if (entry->shape() || entry->pdf()) {
+
365  throw std::runtime_error(FNERROR("Process already contains a shape"));
+
366  }
+
367 
+
368  if (verbosity_ >= 2) {
+
369  LOGLINE(log(), "Extracting shapes for Process:");
+
370  log() << Process::PrintHeader << *entry << "\n";
+
371  LOGLINE(log(), "Mappings:");
+
372  for (HistMapping const& m : mappings) log() << m << "\n";
+
373  }
+
374 
+
375  // Pre-condition #2
+
376  // ResolveMapping will throw if this fails
+
377  if (mappings.size() == 0) {
+
378  if (verbosity_ >= 2) LOGLINE(log(), "No mappings in this card, assuming FAKE");
+
379  return;
+
380  }
+
381  HistMapping mapping =
+
382  ResolveMapping(entry->process(), entry->bin(), mappings);
+
383  boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
+
384  boost::replace_all(mapping.pattern, "$BIN", entry->bin());
+
385  boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
+
386  boost::replace_all(mapping.pattern, "$MASS", entry->mass());
387 
-
388  if (mapping.is_fake) {
-
389  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is FAKE");
-
390  } else if (mapping.IsHist()) {
-
391  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is TH1");
-
392  // Pre-condition #3
-
393  // GetClonedTH1 will throw if this fails
-
394  std::unique_ptr<TH1> h = GetClonedTH1(mapping.file.get(), mapping.pattern);
-
395 
-
396  if (HasNegativeBins(h.get())) {
-
397  LOGLINE(log(), "Warning: process shape has negative bins");
-
398  log() << Process::PrintHeader << *entry << "\n";
-
399  if (flags_.at("zero-negative-bins-on-import")) {
-
400  ZeroNegativeBins(h.get());
-
401  }
-
402  }
-
403  // Post-conditions #1 and #2
-
404  entry->set_shape(std::move(h), true);
-
405  } else if (mapping.IsPdf()) {
-
406  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is RooAbsPdf/RooAbsData");
-
407  // Pre-condition #3
-
408  // Try and get this as RooAbsData first. If this doesn't work try pdf
-
409  RooAbsData* data = mapping.ws->data(mapping.WorkspaceObj().c_str());
-
410  RooAbsPdf* pdf = mapping.ws->pdf(mapping.WorkspaceObj().c_str());
-
411  if (data) {
-
412  if (verbosity_ >= 2) {
-
413  data->printStream(log(), data->defaultPrintContents(0),
-
414  data->defaultPrintStyle(0), "[LoadShapes] ");
-
415  }
-
416  entry->set_data(data);
-
417  entry->set_rate(data->sumEntries());
-
418  } else if (pdf) {
-
419  if (verbosity_ >= 2) {
-
420  pdf->printStream(log(), pdf->defaultPrintContents(0),
-
421  pdf->defaultPrintStyle(0), "[LoadShapes] ");
-
422  }
-
423  // Post-condition #1
-
424  entry->set_pdf(pdf);
-
425  } else { // Pre-condition #3
-
426  if (flags_.at("allow-missing-shapes")) {
-
427  LOGLINE(log(), "Warning, shape missing:");
-
428  log() << Process::PrintHeader << *entry << "\n";
-
429  } else {
-
430  throw std::runtime_error(FNERROR("RooAbsPdf not found in workspace"));
-
431  }
-
432  }
-
433 
-
434  HistMapping norm_mapping = mapping;
-
435  if (!data && norm_mapping.syst_pattern != "") {
-
436  // For when we're not parsing a datacard, syst_pattern is being using to
-
437  // note a different mapping for the normalisation term
-
438  norm_mapping.pattern = norm_mapping.syst_pattern;
-
439  boost::replace_all(norm_mapping.pattern, "$CHANNEL", entry->bin());
-
440  boost::replace_all(norm_mapping.pattern, "$BIN", entry->bin());
-
441  boost::replace_all(norm_mapping.pattern, "$PROCESS", entry->process());
-
442  boost::replace_all(norm_mapping.pattern, "$MASS", entry->mass());
-
443  } else {
-
444  norm_mapping.pattern += "_norm";
-
445  }
-
446  RooAbsReal* norm =
-
447  norm_mapping.ws->function(norm_mapping.WorkspaceObj().c_str());
-
448  if (norm) {
-
449  // Post-condition #3
-
450  entry->set_norm(norm);
-
451  if (verbosity_ >= 2) {
-
452  LOGLINE(log(), "Normalisation RooAbsReal found");
-
453  norm->printStream(log(), norm->defaultPrintContents(0),
-
454  norm->defaultPrintStyle(0), "[LoadShapes] ");
-
455  }
-
456  // If we can upcast norm to a RooRealVar then we can interpret
-
457  // it as a free parameter that should be added to the list
-
458  RooRealVar* norm_var = dynamic_cast<RooRealVar*>(norm);
-
459  if (norm_var) {
-
460  RooArgSet tmp_set(*norm_var);
-
461  ImportParameters(&tmp_set);
-
462  }
-
463  }
-
464 
-
465  // Post-condition #4
-
466  // Import any paramters of the RooAbsPdf and the RooRealVar
-
467  RooAbsData const* data_obj = FindMatchingData(entry);
-
468  if (data_obj) {
-
469  if (verbosity_ >= 2) LOGLINE(log(), "Matching RooAbsData has been found");
-
470  if (pdf) {
-
471  RooArgSet argset = ParametersByName(pdf, data_obj->get());
-
472  ImportParameters(&argset);
-
473  }
-
474  if (norm) {
-
475  RooArgSet argset = ParametersByName(norm, data_obj->get());
-
476  ImportParameters(&argset);
-
477  }
-
478  } else {
-
479  if (verbosity_ >= 2)
-
480  LOGLINE(log(), "No RooAbsData found, assume observable CMS_th1x");
-
481  RooRealVar mx("CMS_th1x" , "CMS_th1x", 0, 1);
-
482  RooArgSet tmp_set(mx);
-
483  if (pdf) {
-
484  RooArgSet argset = ParametersByName(pdf, &tmp_set);
-
485  ImportParameters(&argset);
-
486  }
-
487  if (norm) {
-
488  RooArgSet argset = ParametersByName(norm, &tmp_set);
-
489  ImportParameters(&argset);
-
490  }
-
491  }
-
492  }
-
493 }
-
494 
-
495 void CombineHarvester::LoadShapes(Systematic* entry,
-
496  std::vector<HistMapping> const& mappings) {
-
497  if (entry->shape_u() || entry->shape_d() ||
-
498  entry->data_u() || entry->data_d()) {
-
499  throw std::runtime_error(FNERROR("Systematic already contains a shape"));
-
500  }
-
501 
-
502  if (verbosity_ >= 2) {
-
503  LOGLINE(log(), "Extracting shapes for Systematic:");
-
504  log() << Systematic::PrintHeader << *entry << "\n";
-
505  LOGLINE(log(), "Mappings:");
-
506  for (HistMapping const& m : mappings) log() << m << "\n";
-
507  }
-
508 
-
509  // Pre-condition #2
-
510  // ResolveMapping will throw if this fails
-
511  HistMapping mapping =
-
512  ResolveMapping(entry->process(), entry->bin(), mappings);
-
513  boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
-
514  boost::replace_all(mapping.pattern, "$BIN", entry->bin());
-
515  boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
-
516  boost::replace_all(mapping.pattern, "$MASS", entry->mass());
-
517  std::string p_s =
-
518  mapping.IsPdf() ? mapping.SystWorkspaceObj() : mapping.syst_pattern;
-
519  boost::replace_all(p_s, "$CHANNEL", entry->bin());
-
520  boost::replace_all(p_s, "$BIN", entry->bin());
-
521  boost::replace_all(p_s, "$PROCESS", entry->process());
-
522  boost::replace_all(p_s, "$MASS", entry->mass());
-
523  std::string p_s_hi = p_s;
-
524  std::string p_s_lo = p_s;
-
525  boost::replace_all(p_s_hi, "$SYSTEMATIC", entry->name() + "Up");
-
526  boost::replace_all(p_s_lo, "$SYSTEMATIC", entry->name() + "Down");
-
527  if (mapping.IsHist()) {
-
528  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is TH1");
-
529  std::unique_ptr<TH1> h = GetClonedTH1(mapping.file.get(), mapping.pattern);
-
530  std::unique_ptr<TH1> h_u = GetClonedTH1(mapping.file.get(), p_s_hi);
-
531  std::unique_ptr<TH1> h_d = GetClonedTH1(mapping.file.get(), p_s_lo);
-
532 
-
533  if (HasNegativeBins(h.get())) {
-
534  LOGLINE(log(), "Warning: Systematic shape has negative bins");
-
535  log() << Systematic::PrintHeader << *entry << "\n";
-
536  if (flags_.at("zero-negative-bins-on-import")) {
-
537  ZeroNegativeBins(h.get());
-
538  }
-
539  }
-
540 
-
541  if (HasNegativeBins(h_u.get())) {
-
542  LOGLINE(log(), "Warning: Systematic shape_u has negative bins");
-
543  log() << Systematic::PrintHeader << *entry << "\n";
-
544  if (flags_.at("zero-negative-bins-on-import")) {
-
545  ZeroNegativeBins(h_u.get());
-
546  }
-
547  }
-
548 
-
549  if (HasNegativeBins(h_d.get())) {
-
550  LOGLINE(log(), "Warning: Systematic shape_d has negative bins");
-
551  log() << Systematic::PrintHeader << *entry << "\n";
-
552  if (flags_.at("zero-negative-bins-on-import")) {
-
553  ZeroNegativeBins(h_d.get());
-
554  }
-
555  }
-
556  entry->set_shapes(std::move(h_u), std::move(h_d), h.get());
-
557  } else if (mapping.IsPdf()) {
-
558  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is RooDataHist");
-
559  // Try and get this as RooAbsData first. If this doesn't work try pdf
-
560  RooDataHist* h =
-
561  dynamic_cast<RooDataHist*>(mapping.sys_ws->data(mapping.WorkspaceObj().c_str()));
-
562  RooDataHist* h_u =
-
563  dynamic_cast<RooDataHist*>(mapping.sys_ws->data(p_s_hi.c_str()));
-
564  RooDataHist* h_d =
-
565  dynamic_cast<RooDataHist*>(mapping.sys_ws->data(p_s_lo.c_str()));
-
566  if (!h || !h_u || !h_d) {
-
567  if (flags_.at("allow-missing-shapes")) {
-
568  LOGLINE(log(), "Warning, shape missing:");
-
569  log() << Systematic::PrintHeader << *entry << "\n";
-
570  } else {
-
571  throw std::runtime_error(
-
572  FNERROR("All shapes must be of type RooDataHist"));
-
573  }
-
574  } else {
-
575  entry->set_data(h_u, h_d, h);
-
576  }
-
577  } else {
-
578  throw std::runtime_error(
-
579  FNERROR("Resolved mapping is not of TH1 / RooAbsData type"));
-
580  }
-
581 }
-
582 
-
602 HistMapping const& CombineHarvester::ResolveMapping(
-
603  std::string const& process, std::string const& bin,
-
604  std::vector<HistMapping> const& mappings) {
-
605  StrPairVec attempts = GenerateShapeMapAttempts(process, bin);
-
606  for (unsigned a = 0; a < attempts.size(); ++a) {
-
607  for (unsigned m = 0; m < mappings.size(); ++m) {
-
608  if ((attempts[a].first == mappings[m].process) &&
-
609  (attempts[a].second == mappings[m].category)) {
-
610  return mappings[m];
-
611  }
-
612  }
-
613  }
-
614  // If we get this far then we didn't find a valid mapping
-
615  FNLOG(log()) << "Searching for mapping for (" << bin << "," << process << ")\n";
-
616  FNLOG(log()) << "Avaiable mappings:\n";
-
617  for (auto const& m : mappings) {
-
618  FNLOG(log()) << m << "\n";
-
619  }
-
620  throw std::runtime_error(FNERROR("Valid mapping not found"));
-
621 }
-
622 
-
623 CombineHarvester::StrPairVec CombineHarvester::GenerateShapeMapAttempts(
-
624  std::string process, std::string category) {
-
625  CombineHarvester::StrPairVec result;
-
626  result.push_back(std::make_pair(process , category));
-
627  result.push_back(std::make_pair("*" , category));
-
628  result.push_back(std::make_pair(process , "*"));
-
629  result.push_back(std::make_pair("*" , "*"));
-
630  return result;
-
631 }
-
632 
-
633 std::shared_ptr<RooWorkspace> CombineHarvester::SetupWorkspace(
-
634  RooWorkspace const& ws, bool can_rename) {
-
635  bool name_in_use = false;
-
636 
-
637  // 1) Does the UUID of this ws match any other ws in the map?
-
638  for (auto const& it : wspaces_) {
-
639  // - Yes: just return a ptr to the matched ws
-
640  if (it.second->uuid() == ws.uuid() && flags_["workspace-uuid-recycle"]) {
-
641  FNLOGC(log(), verbosity_ >= 1)
-
642  << "Workspace with name " << it.second->GetName()
-
643  << " has the same UUID, will use this one\n";
-
644  return it.second;
-
645  }
-
646  if (!name_in_use && strcmp(it.second->GetName(), ws.GetName()) == 0) {
-
647  name_in_use = true;
-
648  }
-
649  }
-
650 
-
651  // 2) No: Ok will clone it in. Is the ws name already in use?
-
652  if (!name_in_use) {
-
653  // - No: clone with same name and return
-
654  // IMPORTANT: Don't used RooWorkspace::Clone(), it seems to introduce
-
655  // bugs
-
656  if (GetFlag("workspaces-use-clone")) {
-
657  wspaces_[std::string(ws.GetName())] = std::shared_ptr<RooWorkspace>(
-
658  reinterpret_cast<RooWorkspace*>(ws.Clone()));
-
659  } else {
-
660  wspaces_[std::string(ws.GetName())] =
-
661  std::make_shared<RooWorkspace>(RooWorkspace(ws));
-
662  }
-
663  return wspaces_.at(ws.GetName());
-
664  }
-
665 
-
666  // 3) Am I allowed to rename (default no)?
-
667  if (!can_rename) {
-
668  // - No: throw runtime error
-
669  throw std::runtime_error(FNERROR("A different workspace with name " +
-
670  std::string(ws.GetName()) +
-
671  " already exists"));
-
672  }
-
673 
-
674  // 4) Yes: determine first available nameX, clone, return
-
675  std::set<int> used_ints = {0};
-
676  std::string src_name(ws.GetName());
-
677  for (auto const& it : wspaces_) {
-
678  std::string test_name(it.second->GetName());
-
679  if (test_name.find(src_name) == 0) {
-
680  std::string postfix = test_name.substr(src_name.size());
-
681  try {
-
682  int number = boost::lexical_cast<int>(postfix);
-
683  used_ints.insert(number);
-
684  } catch (boost::bad_lexical_cast & e) {
-
685  }
-
686  }
-
687  }
-
688  std::string new_name =
-
689  src_name + boost::lexical_cast<std::string>(*(used_ints.rbegin()) + 1);
-
690  FNLOGC(log(), verbosity_ >= 1) << "Workspace with name " << src_name
-
691  << " already defined, renaming to " << new_name
-
692  << "\n";
-
693 
-
694  std::shared_ptr<RooWorkspace> new_wsp;
-
695  if (GetFlag("workspaces-use-clone")) {
-
696  new_wsp = std::shared_ptr<RooWorkspace>(
-
697  reinterpret_cast<RooWorkspace*>(ws.Clone(new_name.c_str())));
-
698  } else {
-
699  new_wsp = std::make_shared<RooWorkspace>(RooWorkspace(ws));
-
700  }
-
701  new_wsp->SetName(new_name.c_str());
-
702  wspaces_[new_name] = new_wsp;
-
703  return wspaces_.at(new_name);
-
704 }
-
705 
-
706 void CombineHarvester::ImportParameters(RooArgSet *vars) {
-
707  auto x = vars->createIterator();
-
708  do {
-
709  RooRealVar *y = dynamic_cast<RooRealVar*>(**x);
-
710  if (y) {
-
711  if (!params_.count(y->GetName())) {
-
712  if (verbosity_ >= 1) {
-
713  log() << "[ImportParameters] Creating parameter from RooRealVar:\n";
-
714  y->printStream(log(), y->defaultPrintContents(0),
-
715  y->defaultPrintStyle(0), "[ImportParameters] ");
-
716  }
-
717  Parameter par;
-
718  par.set_name(y->GetName());
-
719  par.set_val(y->getVal());
-
720  if ((y->hasError() || y->hasAsymError()) &&
-
721  flags_["import-parameter-err"]) {
-
722  par.set_err_d(y->getErrorLo());
-
723  par.set_err_u(y->getErrorHi());
-
724  } else {
-
725  par.set_err_d(0.);
-
726  par.set_err_u(0.);
+
388  if (verbosity_ >= 2) {
+
389  LOGLINE(log(), "Resolved Mapping:");
+
390  log() << mapping << "\n";
+
391  }
+
392 
+
393  if (mapping.is_fake) {
+
394  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is FAKE");
+
395  } else if (mapping.IsHist()) {
+
396  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is TH1");
+
397  // Pre-condition #3
+
398  // GetClonedTH1 will throw if this fails
+
399  std::unique_ptr<TH1> h = GetClonedTH1(mapping.file.get(), mapping.pattern);
+
400 
+
401  if (HasNegativeBins(h.get())) {
+
402  LOGLINE(log(), "Warning: process shape has negative bins");
+
403  log() << Process::PrintHeader << *entry << "\n";
+
404  if (flags_.at("zero-negative-bins-on-import")) {
+
405  ZeroNegativeBins(h.get());
+
406  }
+
407  }
+
408  // Post-conditions #1 and #2
+
409  entry->set_shape(std::move(h), true);
+
410  } else if (mapping.IsPdf()) {
+
411  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is RooAbsPdf/RooAbsData");
+
412  // Pre-condition #3
+
413  // Try and get this as RooAbsData first. If this doesn't work try pdf
+
414  RooAbsData* data = mapping.ws->data(mapping.WorkspaceObj().c_str());
+
415  RooAbsReal* pdf = mapping.ws->function(mapping.WorkspaceObj().c_str());
+
416  if (data) {
+
417  if (verbosity_ >= 2) {
+
418  data->printStream(log(), data->defaultPrintContents(0),
+
419  data->defaultPrintStyle(0), "[LoadShapes] ");
+
420  }
+
421  entry->set_data(data);
+
422  entry->set_rate(data->sumEntries());
+
423  } else if (pdf) {
+
424  if (verbosity_ >= 2) {
+
425  pdf->printStream(log(), pdf->defaultPrintContents(0),
+
426  pdf->defaultPrintStyle(0), "[LoadShapes] ");
+
427  }
+
428  // Post-condition #1
+
429  entry->set_pdf(pdf);
+
430  } else { // Pre-condition #3
+
431  if (flags_.at("allow-missing-shapes")) {
+
432  LOGLINE(log(), "Warning, shape missing:");
+
433  log() << Process::PrintHeader << *entry << "\n";
+
434  } else {
+
435  throw std::runtime_error(FNERROR("RooAbsPdf not found in workspace"));
+
436  }
+
437  }
+
438 
+
439  HistMapping norm_mapping = mapping;
+
440  if (!data && norm_mapping.syst_pattern != "") {
+
441  // For when we're not parsing a datacard, syst_pattern is being using to
+
442  // note a different mapping for the normalisation term
+
443  norm_mapping.pattern = norm_mapping.syst_pattern;
+
444  boost::replace_all(norm_mapping.pattern, "$CHANNEL", entry->bin());
+
445  boost::replace_all(norm_mapping.pattern, "$BIN", entry->bin());
+
446  boost::replace_all(norm_mapping.pattern, "$PROCESS", entry->process());
+
447  boost::replace_all(norm_mapping.pattern, "$MASS", entry->mass());
+
448  } else {
+
449  norm_mapping.pattern += "_norm";
+
450  }
+
451  RooAbsReal* norm =
+
452  norm_mapping.ws->function(norm_mapping.WorkspaceObj().c_str());
+
453  if (norm) {
+
454  // Post-condition #3
+
455  entry->set_norm(norm);
+
456  if (verbosity_ >= 2) {
+
457  LOGLINE(log(), "Normalisation RooAbsReal found");
+
458  norm->printStream(log(), norm->defaultPrintContents(0),
+
459  norm->defaultPrintStyle(0), "[LoadShapes] ");
+
460  }
+
461  // If we can upcast norm to a RooRealVar then we can interpret
+
462  // it as a free parameter that should be added to the list
+
463  RooRealVar* norm_var = dynamic_cast<RooRealVar*>(norm);
+
464  if (norm_var) {
+
465  RooArgSet tmp_set(*norm_var);
+
466  ImportParameters(&tmp_set);
+
467  }
+
468  }
+
469 
+
470  // Post-condition #4
+
471  // Import any paramters of the RooAbsPdf and the RooRealVar
+
472  RooAbsData const* data_obj = FindMatchingData(entry);
+
473  if (data_obj) {
+
474  if (verbosity_ >= 2) LOGLINE(log(), "Matching RooAbsData has been found");
+
475  if (pdf) {
+
476  RooArgSet argset = ParametersByName(pdf, data_obj->get());
+
477  ImportParameters(&argset);
+
478  if (!entry->observable()) {
+
479  std::string var_name;
+
480  if (data_obj) var_name = data_obj->get()->first()->GetName();
+
481  entry->set_observable(
+
482  (RooRealVar*)entry->pdf()->findServer(var_name.c_str()));
+
483  }
+
484  }
+
485  if (norm) {
+
486  RooArgSet argset = ParametersByName(norm, data_obj->get());
+
487  ImportParameters(&argset);
+
488  }
+
489  } else {
+
490  if (verbosity_ >= 2)
+
491  LOGLINE(log(), "No RooAbsData found, assume observable CMS_th1x");
+
492  RooRealVar mx("CMS_th1x" , "CMS_th1x", 0, 1);
+
493  RooArgSet tmp_set(mx);
+
494  if (pdf) {
+
495  RooArgSet argset = ParametersByName(pdf, &tmp_set);
+
496  ImportParameters(&argset);
+
497  }
+
498  if (norm) {
+
499  RooArgSet argset = ParametersByName(norm, &tmp_set);
+
500  ImportParameters(&argset);
+
501  }
+
502  }
+
503  }
+
504 }
+
505 
+
506 void CombineHarvester::LoadShapes(Systematic* entry,
+
507  std::vector<HistMapping> const& mappings) {
+
508  if (entry->shape_u() || entry->shape_d() ||
+
509  entry->data_u() || entry->data_d()) {
+
510  throw std::runtime_error(FNERROR("Systematic already contains a shape"));
+
511  }
+
512 
+
513  if (verbosity_ >= 2) {
+
514  LOGLINE(log(), "Extracting shapes for Systematic:");
+
515  log() << Systematic::PrintHeader << *entry << "\n";
+
516  LOGLINE(log(), "Mappings:");
+
517  for (HistMapping const& m : mappings) log() << m << "\n";
+
518  }
+
519 
+
520  // Pre-condition #2
+
521  // ResolveMapping will throw if this fails
+
522  HistMapping mapping =
+
523  ResolveMapping(entry->process(), entry->bin(), mappings);
+
524  boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
+
525  boost::replace_all(mapping.pattern, "$BIN", entry->bin());
+
526  boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
+
527  boost::replace_all(mapping.pattern, "$MASS", entry->mass());
+
528  std::string p_s =
+
529  mapping.IsPdf() ? mapping.SystWorkspaceObj() : mapping.syst_pattern;
+
530  boost::replace_all(p_s, "$CHANNEL", entry->bin());
+
531  boost::replace_all(p_s, "$BIN", entry->bin());
+
532  boost::replace_all(p_s, "$PROCESS", entry->process());
+
533  boost::replace_all(p_s, "$MASS", entry->mass());
+
534  std::string p_s_hi = p_s;
+
535  std::string p_s_lo = p_s;
+
536  boost::replace_all(p_s_hi, "$SYSTEMATIC", entry->name() + "Up");
+
537  boost::replace_all(p_s_lo, "$SYSTEMATIC", entry->name() + "Down");
+
538  if (mapping.IsHist()) {
+
539  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is TH1");
+
540  std::unique_ptr<TH1> h = GetClonedTH1(mapping.file.get(), mapping.pattern);
+
541  std::unique_ptr<TH1> h_u = GetClonedTH1(mapping.file.get(), p_s_hi);
+
542  std::unique_ptr<TH1> h_d = GetClonedTH1(mapping.file.get(), p_s_lo);
+
543 
+
544  if (HasNegativeBins(h.get())) {
+
545  LOGLINE(log(), "Warning: Systematic shape has negative bins");
+
546  log() << Systematic::PrintHeader << *entry << "\n";
+
547  if (flags_.at("zero-negative-bins-on-import")) {
+
548  ZeroNegativeBins(h.get());
+
549  }
+
550  }
+
551 
+
552  if (HasNegativeBins(h_u.get())) {
+
553  LOGLINE(log(), "Warning: Systematic shape_u has negative bins");
+
554  log() << Systematic::PrintHeader << *entry << "\n";
+
555  if (flags_.at("zero-negative-bins-on-import")) {
+
556  ZeroNegativeBins(h_u.get());
+
557  }
+
558  }
+
559 
+
560  if (HasNegativeBins(h_d.get())) {
+
561  LOGLINE(log(), "Warning: Systematic shape_d has negative bins");
+
562  log() << Systematic::PrintHeader << *entry << "\n";
+
563  if (flags_.at("zero-negative-bins-on-import")) {
+
564  ZeroNegativeBins(h_d.get());
+
565  }
+
566  }
+
567  entry->set_shapes(std::move(h_u), std::move(h_d), h.get());
+
568  } else if (mapping.IsPdf()) {
+
569  if (verbosity_ >= 2) LOGLINE(log(), "Mapping type is RooDataHist");
+
570  // Try and get this as RooAbsData first. If this doesn't work try pdf
+
571  RooDataHist* h =
+
572  dynamic_cast<RooDataHist*>(mapping.sys_ws->data(mapping.WorkspaceObj().c_str()));
+
573  RooDataHist* h_u =
+
574  dynamic_cast<RooDataHist*>(mapping.sys_ws->data(p_s_hi.c_str()));
+
575  RooDataHist* h_d =
+
576  dynamic_cast<RooDataHist*>(mapping.sys_ws->data(p_s_lo.c_str()));
+
577  if (!h || !h_u || !h_d) {
+
578  if (flags_.at("allow-missing-shapes")) {
+
579  LOGLINE(log(), "Warning, shape missing:");
+
580  log() << Systematic::PrintHeader << *entry << "\n";
+
581  } else {
+
582  throw std::runtime_error(
+
583  FNERROR("All shapes must be of type RooDataHist"));
+
584  }
+
585  } else {
+
586  entry->set_data(h_u, h_d, h);
+
587  }
+
588  } else {
+
589  throw std::runtime_error(
+
590  FNERROR("Resolved mapping is not of TH1 / RooAbsData type"));
+
591  }
+
592 }
+
593 
+
613 HistMapping const& CombineHarvester::ResolveMapping(
+
614  std::string const& process, std::string const& bin,
+
615  std::vector<HistMapping> const& mappings) {
+
616  StrPairVec attempts = GenerateShapeMapAttempts(process, bin);
+
617  for (unsigned a = 0; a < attempts.size(); ++a) {
+
618  for (unsigned m = 0; m < mappings.size(); ++m) {
+
619  if ((attempts[a].first == mappings[m].process) &&
+
620  (attempts[a].second == mappings[m].category)) {
+
621  return mappings[m];
+
622  }
+
623  }
+
624  }
+
625  // If we get this far then we didn't find a valid mapping
+
626  FNLOG(log()) << "Searching for mapping for (" << bin << "," << process << ")\n";
+
627  FNLOG(log()) << "Avaiable mappings:\n";
+
628  for (auto const& m : mappings) {
+
629  FNLOG(log()) << m << "\n";
+
630  }
+
631  throw std::runtime_error(FNERROR("Valid mapping not found"));
+
632 }
+
633 
+
634 CombineHarvester::StrPairVec CombineHarvester::GenerateShapeMapAttempts(
+
635  std::string process, std::string category) {
+
636  CombineHarvester::StrPairVec result;
+
637  result.push_back(std::make_pair(process , category));
+
638  result.push_back(std::make_pair("*" , category));
+
639  result.push_back(std::make_pair(process , "*"));
+
640  result.push_back(std::make_pair("*" , "*"));
+
641  return result;
+
642 }
+
643 
+
644 std::shared_ptr<RooWorkspace> CombineHarvester::SetupWorkspace(
+
645  RooWorkspace const& ws, bool can_rename) {
+
646  bool name_in_use = false;
+
647 
+
648  // 1) Does the UUID of this ws match any other ws in the map?
+
649  for (auto const& it : wspaces_) {
+
650  // - Yes: just return a ptr to the matched ws
+
651  if (it.second->uuid() == ws.uuid() && flags_["workspace-uuid-recycle"]) {
+
652  FNLOGC(log(), verbosity_ >= 1)
+
653  << "Workspace with name " << it.second->GetName()
+
654  << " has the same UUID, will use this one\n";
+
655  return it.second;
+
656  }
+
657  if (!name_in_use && strcmp(it.second->GetName(), ws.GetName()) == 0) {
+
658  name_in_use = true;
+
659  }
+
660  }
+
661 
+
662  // 2) No: Ok will clone it in. Is the ws name already in use?
+
663  if (!name_in_use) {
+
664  // - No: clone with same name and return
+
665  // IMPORTANT: Don't used RooWorkspace::Clone(), it seems to introduce
+
666  // bugs
+
667  if (GetFlag("workspaces-use-clone")) {
+
668  wspaces_[std::string(ws.GetName())] = std::shared_ptr<RooWorkspace>(
+
669  reinterpret_cast<RooWorkspace*>(ws.Clone()));
+
670  } else {
+
671  wspaces_[std::string(ws.GetName())] =
+
672  std::make_shared<RooWorkspace>(RooWorkspace(ws));
+
673  }
+
674  return wspaces_.at(ws.GetName());
+
675  }
+
676 
+
677  // 3) Am I allowed to rename (default no)?
+
678  if (!can_rename) {
+
679  // - No: throw runtime error
+
680  throw std::runtime_error(FNERROR("A different workspace with name " +
+
681  std::string(ws.GetName()) +
+
682  " already exists"));
+
683  }
+
684 
+
685  // 4) Yes: determine first available nameX, clone, return
+
686  std::set<int> used_ints = {0};
+
687  std::string src_name(ws.GetName());
+
688  for (auto const& it : wspaces_) {
+
689  std::string test_name(it.second->GetName());
+
690  if (test_name.find(src_name) == 0) {
+
691  std::string postfix = test_name.substr(src_name.size());
+
692  try {
+
693  int number = boost::lexical_cast<int>(postfix);
+
694  used_ints.insert(number);
+
695  } catch (boost::bad_lexical_cast & e) {
+
696  }
+
697  }
+
698  }
+
699  std::string new_name =
+
700  src_name + boost::lexical_cast<std::string>(*(used_ints.rbegin()) + 1);
+
701  FNLOGC(log(), verbosity_ >= 1) << "Workspace with name " << src_name
+
702  << " already defined, renaming to " << new_name
+
703  << "\n";
+
704 
+
705  std::shared_ptr<RooWorkspace> new_wsp;
+
706  if (GetFlag("workspaces-use-clone")) {
+
707  new_wsp = std::shared_ptr<RooWorkspace>(
+
708  reinterpret_cast<RooWorkspace*>(ws.Clone(new_name.c_str())));
+
709  } else {
+
710  new_wsp = std::make_shared<RooWorkspace>(RooWorkspace(ws));
+
711  }
+
712  new_wsp->SetName(new_name.c_str());
+
713  wspaces_[new_name] = new_wsp;
+
714  return wspaces_.at(new_name);
+
715 }
+
716 
+
717 void CombineHarvester::ImportParameters(RooArgSet *vars) {
+
718  auto x = vars->createIterator();
+
719  do {
+
720  RooRealVar *y = dynamic_cast<RooRealVar*>(**x);
+
721  if (y) {
+
722  if (!params_.count(y->GetName())) {
+
723  if (verbosity_ >= 1) {
+
724  log() << "[ImportParameters] Creating parameter from RooRealVar:\n";
+
725  y->printStream(log(), y->defaultPrintContents(0),
+
726  y->defaultPrintStyle(0), "[ImportParameters] ");
727  }
-
728  params_[y->GetName()] = std::make_shared<Parameter>(par);
-
729  } else {
-
730  if (verbosity_ >= 1)
-
731  log() << "[ImportParameters] Parameter \"" << y->GetName()
-
732  << "\" already exists\n";
-
733  }
-
734  Parameter *param = params_[y->GetName()].get();
-
735  std::vector<RooRealVar *> & p_vars = param->vars();
-
736  if (std::find(p_vars.begin(), p_vars.end(), y) == p_vars.end()) {
-
737  p_vars.push_back(y);
-
738  if (verbosity_ >= 1)
-
739  log() << "[ImportParameters] Parameter now stores " << p_vars.size()
-
740  << " link(s) to RooRealVar objects\n";
-
741  } else {
-
742  if (verbosity_ >= 1)
-
743  log() << "[ImportParameters] Parameter already stores link to "
-
744  "RooRealVar object\n";
-
745  }
-
746  }
-
747  } while (x->Next());
-
748 }
-
749 
-
750 RooAbsData const* CombineHarvester::FindMatchingData(Process const* proc) {
-
751  RooAbsData const* data_obj = nullptr;
-
752  for (unsigned i = 0; i < obs_.size(); ++i) {
-
753  if (proc->bin() == obs_[i]->bin() &&
-
754  proc->bin_id() == obs_[i]->bin_id()) {
-
755  data_obj = obs_[i]->data();
-
756  }
-
757  }
-
758  return data_obj;
+
728  Parameter par;
+
729  par.set_name(y->GetName());
+
730  par.set_val(y->getVal());
+
731  if ((y->hasError() || y->hasAsymError()) &&
+
732  flags_["import-parameter-err"]) {
+
733  par.set_err_d(y->getErrorLo());
+
734  par.set_err_u(y->getErrorHi());
+
735  } else {
+
736  par.set_err_d(0.);
+
737  par.set_err_u(0.);
+
738  }
+
739  params_[y->GetName()] = std::make_shared<Parameter>(par);
+
740  } else {
+
741  if (verbosity_ >= 1)
+
742  log() << "[ImportParameters] Parameter \"" << y->GetName()
+
743  << "\" already exists\n";
+
744  }
+
745  Parameter *param = params_[y->GetName()].get();
+
746  std::vector<RooRealVar *> & p_vars = param->vars();
+
747  if (std::find(p_vars.begin(), p_vars.end(), y) == p_vars.end()) {
+
748  p_vars.push_back(y);
+
749  if (verbosity_ >= 1)
+
750  log() << "[ImportParameters] Parameter now stores " << p_vars.size()
+
751  << " link(s) to RooRealVar objects\n";
+
752  } else {
+
753  if (verbosity_ >= 1)
+
754  log() << "[ImportParameters] Parameter already stores link to "
+
755  "RooRealVar object\n";
+
756  }
+
757  }
+
758  } while (x->Next());
759 }
760 
-
761 ch::Parameter* CombineHarvester::SetupRateParamVar(std::string const& name,
-
762  double val) {
-
763  RooWorkspace *ws = nullptr;
-
764  if (!wspaces_.count("_rateParams")) {
-
765  ws = this->SetupWorkspace(RooWorkspace("_rateParams","_rateParams")).get();
-
766  } else {
-
767  ws = wspaces_.at("_rateParams").get();
+
761 RooAbsData const* CombineHarvester::FindMatchingData(Process const* proc) {
+
762  RooAbsData const* data_obj = nullptr;
+
763  for (unsigned i = 0; i < obs_.size(); ++i) {
+
764  if (proc->bin() == obs_[i]->bin() &&
+
765  proc->bin_id() == obs_[i]->bin_id()) {
+
766  data_obj = obs_[i]->data();
+
767  }
768  }
-
769  // Parameter doesn't exist in the workspace - let's create it
-
770  RooRealVar *var = ws->var(name.c_str());
-
771  if (!var) {
-
772  // The value doesn't matter, our Parameter object will set it later
-
773  RooRealVar tmp_var(name.c_str(), name.c_str(), 0);
-
774  ws->import(tmp_var);
-
775  var = ws->var(name.c_str());
-
776  FNLOGC(log(), verbosity_ > 1)
-
777  << "Created new RooRealVar for rateParam: " << name << "\n";
-
778  if (verbosity_ > 1) var->Print();
-
779  } else {
-
780  FNLOGC(log(), verbosity_ > 1)
-
781  << "Reusing existing RooRealVar for rateParam: " << name << "\n";
-
782  }
-
783  Parameter * param = nullptr;
-
784  if (!params_.count(name)) {
-
785  params_[name] = std::make_shared<Parameter>(Parameter());
-
786  param = params_.at(name).get();
-
787  param->set_name(name);
-
788  param->set_err_u(0.);
-
789  param->set_err_d(0.);
+
769  return data_obj;
+
770 }
+
771 
+
772 ch::Parameter* CombineHarvester::SetupRateParamVar(std::string const& name,
+
773  double val) {
+
774  RooWorkspace *ws = nullptr;
+
775  if (!wspaces_.count("_rateParams")) {
+
776  ws = this->SetupWorkspace(RooWorkspace("_rateParams","_rateParams")).get();
+
777  } else {
+
778  ws = wspaces_.at("_rateParams").get();
+
779  }
+
780  // Parameter doesn't exist in the workspace - let's create it
+
781  RooRealVar *var = ws->var(name.c_str());
+
782  if (!var) {
+
783  // The value doesn't matter, our Parameter object will set it later
+
784  RooRealVar tmp_var(name.c_str(), name.c_str(), 0);
+
785  ws->import(tmp_var);
+
786  var = ws->var(name.c_str());
+
787  FNLOGC(log(), verbosity_ > 1)
+
788  << "Created new RooRealVar for rateParam: " << name << "\n";
+
789  if (verbosity_ > 1) var->Print();
790  } else {
-
791  param = params_.at(name).get();
-
792  }
-
793  // If the RooRealVar in the workpsace isn't in the list, add it
-
794  bool var_in_par = false;
-
795  for (auto const& ptr : param->vars()) {
-
796  if (ptr == var) {
-
797  var_in_par = true;
-
798  break;
-
799  }
-
800  }
-
801  if (!var_in_par) {
-
802  param->vars().push_back(var);
+
791  FNLOGC(log(), verbosity_ > 1)
+
792  << "Reusing existing RooRealVar for rateParam: " << name << "\n";
+
793  }
+
794  Parameter * param = nullptr;
+
795  if (!params_.count(name)) {
+
796  params_[name] = std::make_shared<Parameter>(Parameter());
+
797  param = params_.at(name).get();
+
798  param->set_name(name);
+
799  param->set_err_u(0.);
+
800  param->set_err_d(0.);
+
801  } else {
+
802  param = params_.at(name).get();
803  }
-
804  // Then this propagates the value to the RooRealVar
-
805  FNLOGC(log(), verbosity_ > 1) << "Updating parameter value from "
-
806  << param->val();
-
807  param->set_val(val);
-
808  if (verbosity_ > 1) log() << " to " << param->val() << "\n";
-
809  return param;
-
810 }
-
811 
-
812 void CombineHarvester::SetupRateParamFunc(std::string const& name,
-
813  std::string const& formula,
-
814  std::string const& pars) {
-
815  RooWorkspace *ws = nullptr;
-
816  if (!wspaces_.count("_rateParams")) {
-
817  ws = this->SetupWorkspace(RooWorkspace("_rateParams","_rateParams")).get();
-
818  } else {
-
819  ws = wspaces_.at("_rateParams").get();
-
820  }
-
821  RooAbsReal *form = ws->function(name.c_str());
-
822  // No parameter to make, this is a formula
-
823  if (!form) {
-
824  RooFormulaVar formularvar(name.c_str(), name.c_str(),
-
825  formula.c_str(),
-
826  RooArgList(ws->argSet(pars.c_str())));
-
827  ws->import(formularvar);
-
828  form = ws->function(name.c_str());
-
829  FNLOGC(log(), verbosity_ > 1)
-
830  << "Created new RooFormulaVar for rateParam: " << name << "\n";
-
831  if (verbosity_ > 1) form->Print();
-
832  }
-
833 }
-
834 }
+
804  // If the RooRealVar in the workpsace isn't in the list, add it
+
805  bool var_in_par = false;
+
806  for (auto const& ptr : param->vars()) {
+
807  if (ptr == var) {
+
808  var_in_par = true;
+
809  break;
+
810  }
+
811  }
+
812  if (!var_in_par) {
+
813  param->vars().push_back(var);
+
814  }
+
815  // Then this propagates the value to the RooRealVar
+
816  FNLOGC(log(), verbosity_ > 1) << "Updating parameter value from "
+
817  << param->val();
+
818  param->set_val(val);
+
819  if (verbosity_ > 1) log() << " to " << param->val() << "\n";
+
820  return param;
+
821 }
+
822 
+
823 void CombineHarvester::SetupRateParamFunc(std::string const& name,
+
824  std::string const& formula,
+
825  std::string const& pars) {
+
826  RooWorkspace *ws = nullptr;
+
827  if (!wspaces_.count("_rateParams")) {
+
828  ws = this->SetupWorkspace(RooWorkspace("_rateParams","_rateParams")).get();
+
829  } else {
+
830  ws = wspaces_.at("_rateParams").get();
+
831  }
+
832  RooAbsReal *form = ws->function(name.c_str());
+
833  // No parameter to make, this is a formula
+
834  if (!form) {
+
835  RooFormulaVar formularvar(name.c_str(), name.c_str(),
+
836  formula.c_str(),
+
837  RooArgList(ws->argSet(pars.c_str())));
+
838  ws->import(formularvar);
+
839  form = ws->function(name.c_str());
+
840  FNLOGC(log(), verbosity_ > 1)
+
841  << "Created new RooFormulaVar for rateParam: " << name << "\n";
+
842  if (verbosity_ > 1) form->Print();
+
843  }
+
844 }
+
845 }
ch::CombineHarvester::swap
friend void swap(CombineHarvester &first, CombineHarvester &second)
Definition: CombineHarvester.cc:33
ch::CombineHarvester::data
CombineHarvester & data()
Definition: CombineHarvester_Filters.cc:183
ch::Observation::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Observation.cc:113
ch::Parameter::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Parameter.cc:62
ch::HistMapping::IsPdf
bool IsPdf() const
Definition: HistMapping.cc:21
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::Observation::shape
TH1 const * shape() const
Definition: Observation.h:27
LOGLINE
#define LOGLINE(x, y)
Definition: Logging.h:11
std
ch::swap
void swap(CombineHarvester &first, CombineHarvester &second)
Definition: CombineHarvester.cc:33
Process.h
-
ch::CombineHarvester::PrintObs
CombineHarvester & PrintObs()
Definition: CombineHarvester.cc:221
-
ch::ZeroNegativeBins
void ZeroNegativeBins(TH1 *h)
Definition: Utilities.cc:348
+
ch::CombineHarvester::PrintObs
CombineHarvester & PrintObs()
Definition: CombineHarvester.cc:226
+
ch::ZeroNegativeBins
void ZeroNegativeBins(TH1 *h)
Definition: Utilities.cc:349
CombineHarvester.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
FNLOG
#define FNLOG(x)
Definition: Logging.h:13
ch::CombineHarvester::~CombineHarvester
~CombineHarvester()
Definition: CombineHarvester.cc:29
-
ch::CombineHarvester::PrintParams
CombineHarvester & PrintParams()
Definition: CombineHarvester.cc:242
+
ch::CombineHarvester::PrintParams
CombineHarvester & PrintParams()
Definition: CombineHarvester.cc:247
FNERROR
#define FNERROR(x)
Definition: Logging.h:9
Systematic.h
ch::GetClonedTH1
std::unique_ptr< TH1 > GetClonedTH1(TFile *file, std::string const &path)
Definition: TFileIO.cc:12
ch
Definition: Algorithm.h:10
-
ch::HasNegativeBins
bool HasNegativeBins(TH1 const *h)
Definition: Utilities.cc:338
+
ch::HasNegativeBins
bool HasNegativeBins(TH1 const *h)
Definition: Utilities.cc:339
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
-
ch::CombineHarvester::SetFlag
void SetFlag(std::string const &flag, bool const &value)
Set a named flag value.
Definition: CombineHarvester.cc:61
+
ch::CombineHarvester::SetFlag
void SetFlag(std::string const &flag, bool const &value)
Set a named flag value.
Definition: CombineHarvester.cc:63
Parameter.h
ch::Observation
Definition: Observation.h:12
ch::Observation::data
RooAbsData const * data() const
Definition: Observation.h:35
FNLOGC
#define FNLOGC(x, y)
Definition: Logging.h:14
-
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:131
-
ch::CombineHarvester::PrintProcs
CombineHarvester & PrintProcs()
Definition: CombineHarvester.cc:228
-
ch::CombineHarvester::PrintAll
CombineHarvester & PrintAll()
Definition: CombineHarvester.cc:217
+
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:141
+
ch::CombineHarvester::PrintProcs
CombineHarvester & PrintProcs()
Definition: CombineHarvester.cc:233
+
ch::CombineHarvester::PrintAll
CombineHarvester & PrintAll()
Definition: CombineHarvester.cc:222
Observation.h
ch::Parameter
Definition: Parameter.h:12
ch::Systematic::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Systematic.cc:164
TFileIO.h
-
ch::CombineHarvester::GetFlag
bool GetFlag(std::string const &flag) const
Definition: CombineHarvester.cc:72
-
ch::CombineHarvester::PrintSysts
CombineHarvester & PrintSysts()
Definition: CombineHarvester.cc:235
+
ch::CombineHarvester::GetFlag
bool GetFlag(std::string const &flag) const
Definition: CombineHarvester.cc:74
+
ch::CombineHarvester::PrintSysts
CombineHarvester & PrintSysts()
Definition: CombineHarvester.cc:240
ch::ParametersByName
RooArgSet ParametersByName(RooAbsReal const *pdf, RooArgSet const *dat_vars)
Definition: Utilities.cc:18
Logging.h
ch::CombineHarvester::CombineHarvester
CombineHarvester()
Definition: CombineHarvester.cc:16
-
ch::CombineHarvester::operator=
CombineHarvester & operator=(CombineHarvester other)
Definition: CombineHarvester.cc:204
-
ch::CombineHarvester::deep
CombineHarvester deep()
Creates and retunrs a deep copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:81
+
ch::CombineHarvester::operator=
CombineHarvester & operator=(CombineHarvester other)
Definition: CombineHarvester.cc:209
+
ch::CombineHarvester::deep
CombineHarvester deep()
Creates and retunrs a deep copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:83
diff --git a/_combine_harvester_8h_source.html b/_combine_harvester_8h_source.html index afc3161c537..444bbeb4fb5 100644 --- a/_combine_harvester_8h_source.html +++ b/_combine_harvester_8h_source.html @@ -251,316 +251,323 @@
300  void RemoveGroup(std::string const& name, std::vector<std::string> const& patterns);
301 
308  void RenameGroup(std::string const& oldname, std::string const& newname);
-
322  double GetRate();
-
323  double GetObservedRate();
-
324  double GetUncertainty();
-
325 
-
334  double GetUncertainty(RooFitResult const* fit, unsigned n_samples);
-
335  double GetUncertainty(RooFitResult const& fit, unsigned n_samples);
-
336  TH1F GetShape();
-
337  TH1F GetShapeWithUncertainty();
-
338 
-
348  TH1F GetShapeWithUncertainty(RooFitResult const* fit, unsigned n_samples);
-
349  TH1F GetShapeWithUncertainty(RooFitResult const& fit, unsigned n_samples);
-
350  TH1F GetObservedShape();
-
351 
-
352  TH2F GetRateCovariance(RooFitResult const& fit, unsigned n_samples);
-
353  TH2F GetRateCorrelation(RooFitResult const& fit, unsigned n_samples);
-
379  void AddObservations(std::vector<std::string> mass,
-
380  std::vector<std::string> analysis,
-
381  std::vector<std::string> era,
-
382  std::vector<std::string> channel,
-
383  ch::Categories bin);
-
384 
-
385  void AddProcesses(std::vector<std::string> mass,
-
386  std::vector<std::string> analysis,
-
387  std::vector<std::string> era,
-
388  std::vector<std::string> channel,
-
389  std::vector<std::string> procs,
-
390  ch::Categories bin, bool signal);
-
391 
-
392  void AddSystFromProc(Process const& proc, std::string const& name,
-
393  std::string const& type, bool asymm, double val_u,
-
394  double val_d, std::string const& formula,
-
395  std::string const& args);
+
309 
+
315  void AddDatacardLineAtEnd(std::string const& line);
+
316 
+
320  void ClearDatacardLinesAtEnd();
+
334  double GetRate();
+
335  double GetObservedRate();
+
336  double GetUncertainty();
+
337 
+
346  double GetUncertainty(RooFitResult const* fit, unsigned n_samples);
+
347  double GetUncertainty(RooFitResult const& fit, unsigned n_samples);
+
348  TH1F GetShape();
+
349  TH1F GetShapeWithUncertainty();
+
350 
+
360  TH1F GetShapeWithUncertainty(RooFitResult const* fit, unsigned n_samples);
+
361  TH1F GetShapeWithUncertainty(RooFitResult const& fit, unsigned n_samples);
+
362  TH1F GetObservedShape();
+
363 
+
364  TH2F GetRateCovariance(RooFitResult const& fit, unsigned n_samples);
+
365  TH2F GetRateCorrelation(RooFitResult const& fit, unsigned n_samples);
+
391  void AddObservations(std::vector<std::string> mass,
+
392  std::vector<std::string> analysis,
+
393  std::vector<std::string> era,
+
394  std::vector<std::string> channel,
+
395  ch::Categories bin);
396 
-
397  template <class Map>
-
398  void AddSyst(CombineHarvester & target, std::string const& name,
-
399  std::string const& type, Map const& valmap);
-
400 
-
401  void ExtractShapes(std::string const& file, std::string const& rule,
-
402  std::string const& syst_rule);
-
403  void ExtractPdfs(CombineHarvester& target, std::string const& ws_name,
-
404  std::string const& rule, std::string norm_rule = "");
-
405  void ExtractData(std::string const& ws_name, std::string const& rule);
-
406 
-
407  void AddWorkspace(RooWorkspace const& ws, bool can_rename = false);
+
397  void AddProcesses(std::vector<std::string> mass,
+
398  std::vector<std::string> analysis,
+
399  std::vector<std::string> era,
+
400  std::vector<std::string> channel,
+
401  std::vector<std::string> procs,
+
402  ch::Categories bin, bool signal);
+
403 
+
404  void AddSystFromProc(Process const& proc, std::string const& name,
+
405  std::string const& type, bool asymm, double val_u,
+
406  double val_d, std::string const& formula,
+
407  std::string const& args);
408 
-
409  void InsertObservation(ch::Observation const& obs);
-
410  void InsertProcess(ch::Process const& proc);
-
411  void InsertSystematic(ch::Systematic const& sys);
+
409  template <class Map>
+
410  void AddSyst(CombineHarvester & target, std::string const& name,
+
411  std::string const& type, Map const& valmap);
412 
-
418  void RenameSystematic(CombineHarvester& target, std::string const& old_name, std::string const& new_name);
-
419 
-
420  void CreateParameterIfEmpty(std::string const& name);
-
421 
-
428  void AddBinByBin(double threshold, bool fixed_norm, CombineHarvester* other);
-
429 
-
430 
-
437  void AddBinByBin(double threshold, bool fixed_norm, CombineHarvester & other);
-
438 
-
439 
-
446  void MergeBinErrors(double bbb_threshold, double merge_threshold);
-
449  private:
-
450  friend void swap(CombineHarvester& first, CombineHarvester& second);
+
413  void ExtractShapes(std::string const& file, std::string const& rule,
+
414  std::string const& syst_rule);
+
415  void ExtractPdfs(CombineHarvester& target, std::string const& ws_name,
+
416  std::string const& rule, std::string norm_rule = "");
+
417  void ExtractData(std::string const& ws_name, std::string const& rule);
+
418 
+
419  void AddWorkspace(RooWorkspace const& ws, bool can_rename = false);
+
420 
+
421  void InsertObservation(ch::Observation const& obs);
+
422  void InsertProcess(ch::Process const& proc);
+
423  void InsertSystematic(ch::Systematic const& sys);
+
424 
+
430  void RenameSystematic(CombineHarvester& target, std::string const& old_name, std::string const& new_name);
+
431 
+
432  void CreateParameterIfEmpty(std::string const& name);
+
433 
+
440  void AddBinByBin(double threshold, bool fixed_norm, CombineHarvester* other);
+
441 
+
442 
+
449  void AddBinByBin(double threshold, bool fixed_norm, CombineHarvester & other);
+
450 
451 
-
452  // ---------------------------------------------------------------
-
453  // Main data members
-
454  // ---------------------------------------------------------------
-
455  std::vector<std::shared_ptr<Observation>> obs_;
-
456  std::vector<std::shared_ptr<Process>> procs_;
-
457  std::vector<std::shared_ptr<Systematic>> systs_;
-
458  std::map<std::string, std::shared_ptr<Parameter>> params_;
-
459  std::map<std::string, std::shared_ptr<RooWorkspace>> wspaces_;
-
460 
-
461  std::unordered_map<std::string, bool> flags_;
-
462 
-
463  // ---------------------------------------------------------------
-
464  // typedefs
-
465  // ---------------------------------------------------------------
-
466  typedef std::pair<std::string, std::string> StrPair;
-
467  typedef std::vector<StrPair> StrPairVec;
-
468  typedef std::vector<std::string> StrVec;
-
469 
-
470 
-
471  // ---------------------------------------------------------------
-
472  // Logging
-
473  // ---------------------------------------------------------------
-
474  unsigned verbosity_;
-
475  std::ostream * log_;
-
476  std::ostream& log() const { return *log_; }
-
477 
-
478  // ---------------------------------------------------------------
-
479  // Private methods for the shape extraction routines
-
480  // --> implementation in src/CombineHarvester.cc
-
481  // ---------------------------------------------------------------
-
482  void LoadShapes(Observation* entry,
-
483  std::vector<HistMapping> const& mappings);
-
484  void LoadShapes(Process* entry,
-
485  std::vector<HistMapping> const& mappings);
-
486  void LoadShapes(Systematic* entry,
-
487  std::vector<HistMapping> const& mappings);
-
488 
-
489  HistMapping const& ResolveMapping(std::string const& process,
-
490  std::string const& bin,
-
491  std::vector<HistMapping> const& mappings);
-
492 
-
493  StrPairVec GenerateShapeMapAttempts(std::string process,
-
494  std::string category);
-
495 
-
496  std::shared_ptr<RooWorkspace> SetupWorkspace(RooWorkspace const& ws,
-
497  bool can_rename = false);
-
498 
-
499  void ImportParameters(RooArgSet *vars);
-
500 
-
501  RooAbsData const* FindMatchingData(Process const* proc);
+
458  void MergeBinErrors(double bbb_threshold, double merge_threshold);
+
461  private:
+
462  friend void swap(CombineHarvester& first, CombineHarvester& second);
+
463 
+
464  // ---------------------------------------------------------------
+
465  // Main data members
+
466  // ---------------------------------------------------------------
+
467  std::vector<std::shared_ptr<Observation>> obs_;
+
468  std::vector<std::shared_ptr<Process>> procs_;
+
469  std::vector<std::shared_ptr<Systematic>> systs_;
+
470  std::map<std::string, std::shared_ptr<Parameter>> params_;
+
471  std::map<std::string, std::shared_ptr<RooWorkspace>> wspaces_;
+
472 
+
473  std::unordered_map<std::string, bool> flags_;
+
474 
+
475  std::vector<std::string> post_lines_;
+
476 
+
477  // ---------------------------------------------------------------
+
478  // typedefs
+
479  // ---------------------------------------------------------------
+
480  typedef std::pair<std::string, std::string> StrPair;
+
481  typedef std::vector<StrPair> StrPairVec;
+
482  typedef std::vector<std::string> StrVec;
+
483 
+
484 
+
485  // ---------------------------------------------------------------
+
486  // Logging
+
487  // ---------------------------------------------------------------
+
488  unsigned verbosity_;
+
489  std::ostream * log_;
+
490  std::ostream& log() const { return *log_; }
+
491 
+
492  // ---------------------------------------------------------------
+
493  // Private methods for the shape extraction routines
+
494  // --> implementation in src/CombineHarvester.cc
+
495  // ---------------------------------------------------------------
+
496  void LoadShapes(Observation* entry,
+
497  std::vector<HistMapping> const& mappings);
+
498  void LoadShapes(Process* entry,
+
499  std::vector<HistMapping> const& mappings);
+
500  void LoadShapes(Systematic* entry,
+
501  std::vector<HistMapping> const& mappings);
502 
-
503  ch::Parameter * SetupRateParamVar(std::string const& name, double val);
-
504  void SetupRateParamFunc(std::string const& name, std::string const& formula,
-
505  std::string const& pars);
+
503  HistMapping const& ResolveMapping(std::string const& process,
+
504  std::string const& bin,
+
505  std::vector<HistMapping> const& mappings);
506 
-
507  // ---------------------------------------------------------------
-
508  // Private methods for the shape writing routines
-
509  // ---------------------------------------------------------------
-
510  void WriteHistToFile(
-
511  TH1 * hist,
-
512  TFile * file,
-
513  std::vector<HistMapping> const& mappings,
-
514  std::string const& bin,
-
515  std::string const& process,
-
516  std::string const& mass,
-
517  std::string const& nuisance,
-
518  unsigned type);
-
519 
-
520 void FillHistMappings(std::vector<HistMapping> & mappings);
-
521 
-
522  // ---------------------------------------------------------------
-
523  // Private methods for shape/yield evaluation
-
524  // --> implementation in src/CombineHarvester_Evaluate.cc
-
525  // ---------------------------------------------------------------
-
526  typedef std::vector<std::vector<Systematic const*>> ProcSystMap;
-
527  ProcSystMap GenerateProcSystMap();
-
528 
-
529  double GetRateInternal(ProcSystMap const& lookup,
-
530  std::string const& single_sys = "");
-
531 
-
532  TH1F GetShapeInternal(ProcSystMap const& lookup,
-
533  std::string const& single_sys = "");
-
534 
-
535  inline double smoothStepFunc(double x) const {
-
536  if (std::fabs(x) >= 1.0/*_smoothRegion*/) return x > 0 ? +1 : -1;
-
537  double xnorm = x/1.0;/*_smoothRegion*/
-
538  double xnorm2 = xnorm*xnorm;
-
539  return 0.125 * xnorm * (xnorm2 * (3.*xnorm2 - 10.) + 15);
-
540  }
-
541 
-
542  double logKappaForX(double x, double k_low, double k_high) const;
-
543 
-
544  void ShapeDiff(double x, TH1F* target, TH1 const* nom, TH1 const* low,
-
545  TH1 const* high, bool linear);
-
546  void ShapeDiff(double x, TH1F* target, RooDataHist const* nom,
-
547  RooDataHist const* low, RooDataHist const* high);
-
548 };
-
549 
-
550 
-
551 // ---------------------------------------------------------------
-
552 // Template method implementation
-
553 // ---------------------------------------------------------------
-
554 template <typename T, typename R>
-
555 std::set<R> CombineHarvester::SetFromAll(T func) {
-
556  std::set<R> ret;
-
557  for (auto const& item : obs_) ret.insert(func(item.get()));
-
558  for (auto const& item : procs_) ret.insert(func(item.get()));
-
559  for (auto const& item : systs_) ret.insert(func(item.get()));
-
560  return ret;
-
561 };
-
562 
-
563 template <typename T, typename R>
-
564 std::set<R> CombineHarvester::SetFromObs(T func) {
-
565  std::set<R> ret;
-
566  for (auto const& item : obs_) ret.insert(func(item.get()));
-
567  return ret;
-
568 };
-
569 
-
570 template <typename T, typename R>
-
571 std::set<R> CombineHarvester::SetFromProcs(T func) {
-
572  std::set<R> ret;
-
573  for (auto const& item : procs_) ret.insert(func(item.get()));
+
507  StrPairVec GenerateShapeMapAttempts(std::string process,
+
508  std::string category);
+
509 
+
510  std::shared_ptr<RooWorkspace> SetupWorkspace(RooWorkspace const& ws,
+
511  bool can_rename = false);
+
512 
+
513  void ImportParameters(RooArgSet *vars);
+
514 
+
515  RooAbsData const* FindMatchingData(Process const* proc);
+
516 
+
517  ch::Parameter * SetupRateParamVar(std::string const& name, double val);
+
518  void SetupRateParamFunc(std::string const& name, std::string const& formula,
+
519  std::string const& pars);
+
520 
+
521  // ---------------------------------------------------------------
+
522  // Private methods for the shape writing routines
+
523  // ---------------------------------------------------------------
+
524  void WriteHistToFile(
+
525  TH1 * hist,
+
526  TFile * file,
+
527  std::vector<HistMapping> const& mappings,
+
528  std::string const& bin,
+
529  std::string const& process,
+
530  std::string const& mass,
+
531  std::string const& nuisance,
+
532  unsigned type);
+
533 
+
534 void FillHistMappings(std::vector<HistMapping> & mappings);
+
535 
+
536  // ---------------------------------------------------------------
+
537  // Private methods for shape/yield evaluation
+
538  // --> implementation in src/CombineHarvester_Evaluate.cc
+
539  // ---------------------------------------------------------------
+
540  typedef std::vector<std::vector<Systematic const*>> ProcSystMap;
+
541  ProcSystMap GenerateProcSystMap();
+
542 
+
543  double GetRateInternal(ProcSystMap const& lookup,
+
544  std::string const& single_sys = "");
+
545 
+
546  TH1F GetShapeInternal(ProcSystMap const& lookup,
+
547  std::string const& single_sys = "");
+
548 
+
549  inline double smoothStepFunc(double x) const {
+
550  if (std::fabs(x) >= 1.0/*_smoothRegion*/) return x > 0 ? +1 : -1;
+
551  double xnorm = x/1.0;/*_smoothRegion*/
+
552  double xnorm2 = xnorm*xnorm;
+
553  return 0.125 * xnorm * (xnorm2 * (3.*xnorm2 - 10.) + 15);
+
554  }
+
555 
+
556  double logKappaForX(double x, double k_low, double k_high) const;
+
557 
+
558  void ShapeDiff(double x, TH1F* target, TH1 const* nom, TH1 const* low,
+
559  TH1 const* high, bool linear);
+
560  void ShapeDiff(double x, TH1F* target, RooDataHist const* nom,
+
561  RooDataHist const* low, RooDataHist const* high);
+
562 };
+
563 
+
564 
+
565 // ---------------------------------------------------------------
+
566 // Template method implementation
+
567 // ---------------------------------------------------------------
+
568 template <typename T, typename R>
+
569 std::set<R> CombineHarvester::SetFromAll(T func) {
+
570  std::set<R> ret;
+
571  for (auto const& item : obs_) ret.insert(func(item.get()));
+
572  for (auto const& item : procs_) ret.insert(func(item.get()));
+
573  for (auto const& item : systs_) ret.insert(func(item.get()));
574  return ret;
575 };
576 
577 template <typename T, typename R>
-
578 std::set<R> CombineHarvester::SetFromSysts(T func) {
+
578 std::set<R> CombineHarvester::SetFromObs(T func) {
579  std::set<R> ret;
-
580  for (auto const& item : systs_) ret.insert(func(item.get()));
+
580  for (auto const& item : obs_) ret.insert(func(item.get()));
581  return ret;
582 };
583 
-
584 template<typename Function>
-
585 void CombineHarvester::ForEachObj(Function func) {
-
586  ForEachObs(func);
-
587  ForEachProc(func);
-
588  ForEachSyst(func);
-
589 }
+
584 template <typename T, typename R>
+
585 std::set<R> CombineHarvester::SetFromProcs(T func) {
+
586  std::set<R> ret;
+
587  for (auto const& item : procs_) ret.insert(func(item.get()));
+
588  return ret;
+
589 };
590 
-
591 template<typename Function>
-
592 void CombineHarvester::ForEachProc(Function func) {
-
593  for (auto & item: procs_) func(item.get());
-
594 }
-
595 
-
596 template<typename Function>
-
597 void CombineHarvester::ForEachObs(Function func) {
-
598  for (auto & item: obs_) func(item.get());
-
599 }
-
600 
-
601 template<typename Function>
-
602 void CombineHarvester::ForEachSyst(Function func) {
-
603  for (auto & item: systs_) func(item.get());
-
604 }
-
605 
-
606 template<typename Function>
-
607 CombineHarvester& CombineHarvester::FilterAll(Function func) {
-
608  FilterObs(func);
-
609  FilterProcs(func);
-
610  FilterSysts(func);
-
611  return *this;
-
612 }
-
613 
-
614 template<typename Function>
-
615 CombineHarvester& CombineHarvester::FilterObs(Function func) {
-
616  boost::remove_erase_if(
-
617  obs_, [&](std::shared_ptr<Observation> ptr) { return func(ptr.get());
-
618  });
-
619  return *this;
-
620 }
-
621 
-
622 template<typename Function>
-
623 CombineHarvester& CombineHarvester::FilterProcs(Function func) {
-
624  boost::remove_erase_if(
-
625  procs_, [&](std::shared_ptr<Process> ptr) { return func(ptr.get());
-
626  });
-
627  return *this;
-
628 }
-
629 template<typename Function>
-
630 CombineHarvester& CombineHarvester::FilterSysts(Function func) {
-
631  boost::remove_erase_if(
-
632  systs_, [&](std::shared_ptr<Systematic> ptr) { return func(ptr.get());
-
633  });
-
634  return *this;
-
635 }
-
636 
-
637 template <class Map>
-
638 void CombineHarvester::AddSyst(CombineHarvester& target,
-
639  std::string const& name, std::string const& type,
-
640  Map const& valmap) {
-
641  // Keep track of which Process entries get a Systematic assigned and which
-
642  // don't. If verbosity is on we'll print lists of these processes at the end.
-
643  std::vector<ch::Process *> not_added_procs;
-
644  std::vector<ch::Process *> added_procs;
-
645  // Also track which tuples in the map did not get used. Do this by getting the
-
646  // full map here and then removing elements as they are used to create a
-
647  // Systematic.
-
648  auto tuples = valmap.GetTupleSet();
-
649  if (verbosity_ >= 1) {
-
650  LOGLINE(log(), name + ":" + type);
-
651  }
-
652  for (unsigned i = 0; i < procs_.size(); ++i) {
-
653  if (!valmap.Contains(procs_[i].get())) {
-
654  not_added_procs.push_back(procs_[i].get());
-
655  continue;
-
656  }
-
657  tuples.erase(valmap.GetTuple(procs_[i].get()));
-
658  added_procs.push_back(procs_[i].get());
-
659  double val_u = valmap.ValU(procs_[i].get());
-
660  double val_d = valmap.ValD(procs_[i].get());
-
661  std::string formula = valmap.Formula(procs_[i].get());
-
662  std::string args = valmap.Args(procs_[i].get());
-
663  target.AddSystFromProc(*(procs_[i]), name, type, valmap.IsAsymm(),
-
664  val_u, val_d, formula, args);
+
591 template <typename T, typename R>
+
592 std::set<R> CombineHarvester::SetFromSysts(T func) {
+
593  std::set<R> ret;
+
594  for (auto const& item : systs_) ret.insert(func(item.get()));
+
595  return ret;
+
596 };
+
597 
+
598 template<typename Function>
+
599 void CombineHarvester::ForEachObj(Function func) {
+
600  ForEachObs(func);
+
601  ForEachProc(func);
+
602  ForEachSyst(func);
+
603 }
+
604 
+
605 template<typename Function>
+
606 void CombineHarvester::ForEachProc(Function func) {
+
607  for (auto & item: procs_) func(item.get());
+
608 }
+
609 
+
610 template<typename Function>
+
611 void CombineHarvester::ForEachObs(Function func) {
+
612  for (auto & item: obs_) func(item.get());
+
613 }
+
614 
+
615 template<typename Function>
+
616 void CombineHarvester::ForEachSyst(Function func) {
+
617  for (auto & item: systs_) func(item.get());
+
618 }
+
619 
+
620 template<typename Function>
+
621 CombineHarvester& CombineHarvester::FilterAll(Function func) {
+
622  FilterObs(func);
+
623  FilterProcs(func);
+
624  FilterSysts(func);
+
625  return *this;
+
626 }
+
627 
+
628 template<typename Function>
+
629 CombineHarvester& CombineHarvester::FilterObs(Function func) {
+
630  boost::remove_erase_if(
+
631  obs_, [&](std::shared_ptr<Observation> ptr) { return func(ptr.get());
+
632  });
+
633  return *this;
+
634 }
+
635 
+
636 template<typename Function>
+
637 CombineHarvester& CombineHarvester::FilterProcs(Function func) {
+
638  boost::remove_erase_if(
+
639  procs_, [&](std::shared_ptr<Process> ptr) { return func(ptr.get());
+
640  });
+
641  return *this;
+
642 }
+
643 template<typename Function>
+
644 CombineHarvester& CombineHarvester::FilterSysts(Function func) {
+
645  boost::remove_erase_if(
+
646  systs_, [&](std::shared_ptr<Systematic> ptr) { return func(ptr.get());
+
647  });
+
648  return *this;
+
649 }
+
650 
+
651 template <class Map>
+
652 void CombineHarvester::AddSyst(CombineHarvester& target,
+
653  std::string const& name, std::string const& type,
+
654  Map const& valmap) {
+
655  // Keep track of which Process entries get a Systematic assigned and which
+
656  // don't. If verbosity is on we'll print lists of these processes at the end.
+
657  std::vector<ch::Process *> not_added_procs;
+
658  std::vector<ch::Process *> added_procs;
+
659  // Also track which tuples in the map did not get used. Do this by getting the
+
660  // full map here and then removing elements as they are used to create a
+
661  // Systematic.
+
662  auto tuples = valmap.GetTupleSet();
+
663  if (verbosity_ >= 1) {
+
664  LOGLINE(log(), name + ":" + type);
665  }
-
666  if (tuples.size() && verbosity_ >= 1) {
-
667  log() << ">> Map keys that were not used to create a Systematic:\n";
-
668  for (auto s : tuples) {
-
669  log() << ch::Tuple2String(s) << "\n";
+
666  for (unsigned i = 0; i < procs_.size(); ++i) {
+
667  if (!valmap.Contains(procs_[i].get())) {
+
668  not_added_procs.push_back(procs_[i].get());
+
669  continue;
670  }
-
671  }
-
672  if (verbosity_ >= 2) {
-
673  Process::PrintHeader(log());
-
674  log() << ">> Process entries that did not get a Systematic:\n";
-
675  for (auto p : not_added_procs) {
-
676  log() << *p << "\n";
-
677  }
-
678  log() << ">> Process entries that did get a Systematic:\n";
-
679  for (auto p : added_procs) {
-
680  log() << *p << "\n";
-
681  }
-
682  }
-
683 }
-
684 }
-
685 
-
686 #endif
+
671  tuples.erase(valmap.GetTuple(procs_[i].get()));
+
672  added_procs.push_back(procs_[i].get());
+
673  double val_u = valmap.ValU(procs_[i].get());
+
674  double val_d = valmap.ValD(procs_[i].get());
+
675  std::string formula = valmap.Formula(procs_[i].get());
+
676  std::string args = valmap.Args(procs_[i].get());
+
677  target.AddSystFromProc(*(procs_[i]), name, type, valmap.IsAsymm(),
+
678  val_u, val_d, formula, args);
+
679  }
+
680  if (tuples.size() && verbosity_ >= 1) {
+
681  log() << ">> Map keys that were not used to create a Systematic:\n";
+
682  for (auto s : tuples) {
+
683  log() << ch::Tuple2String(s) << "\n";
+
684  }
+
685  }
+
686  if (verbosity_ >= 2) {
+
687  Process::PrintHeader(log());
+
688  log() << ">> Process entries that did not get a Systematic:\n";
+
689  for (auto p : not_added_procs) {
+
690  log() << *p << "\n";
+
691  }
+
692  log() << ">> Process entries that did get a Systematic:\n";
+
693  for (auto p : added_procs) {
+
694  log() << *p << "\n";
+
695  }
+
696  }
+
697 }
+
698 }
+
699 
+
700 #endif
ch::CombineHarvester::swap
friend void swap(CombineHarvester &first, CombineHarvester &second)
Definition: CombineHarvester.cc:33
-
ch::CombineHarvester::SetFromAll
std::set< R > SetFromAll(T func)
Fill an std::set with the return values from an arbitrary function.
Definition: CombineHarvester.h:555
+
ch::CombineHarvester::ClearDatacardLinesAtEnd
void ClearDatacardLinesAtEnd()
Clear all added datacard lines.
Definition: CombineHarvester_Evaluate.cc:743
+
ch::CombineHarvester::SetFromAll
std::set< R > SetFromAll(T func)
Fill an std::set with the return values from an arbitrary function.
Definition: CombineHarvester.h:569
ch::CombineHarvester::data
CombineHarvester & data()
Definition: CombineHarvester_Filters.cc:183
ch::CombineHarvester::CreateParameterIfEmpty
void CreateParameterIfEmpty(std::string const &name)
Definition: CombineHarvester_Creation.cc:228
ch::CombineHarvester::ExtractData
void ExtractData(std::string const &ws_name, std::string const &rule)
Definition: CombineHarvester_Creation.cc:199
ch::CombineHarvester::GetShape
TH1F GetShape()
Definition: CombineHarvester_Evaluate.cc:277
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::WriteDatacard
void WriteDatacard(std::string const &name, std::string const &root_file)
Definition: CombineHarvester_Datacards.cc:454
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::WriteDatacard
void WriteDatacard(std::string const &name, std::string const &root_file)
Definition: CombineHarvester_Datacards.cc:455
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::CombineHarvester::GetRate
double GetRate()
Definition: CombineHarvester_Evaluate.cc:272
ch::CombineHarvester::GetRateCovariance
TH2F GetRateCovariance(RooFitResult const &fit, unsigned n_samples)
Definition: CombineHarvester_Evaluate.cc:179
-
ch::CombineHarvester::RenameGroup
void RenameGroup(std::string const &oldname, std::string const &newname)
Rename a nuisance parameter group.
Definition: CombineHarvester_Evaluate.cc:722
+
ch::CombineHarvester::RenameGroup
void RenameGroup(std::string const &oldname, std::string const &newname)
Rename a nuisance parameter group.
Definition: CombineHarvester_Evaluate.cc:728
ch::CombineHarvester::ExtractPdfs
void ExtractPdfs(CombineHarvester &target, std::string const &ws_name, std::string const &rule, std::string norm_rule="")
Definition: CombineHarvester_Creation.cc:181
ch::CombineHarvester::syst_type
CombineHarvester & syst_type(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:136
ch::CombineHarvester::analysis_set
std::set< std::string > analysis_set()
Definition: CombineHarvester_Filters.cc:223
@@ -575,85 +582,86 @@
ch::CombineHarvester::syst_name_set
std::set< std::string > syst_name_set()
Definition: CombineHarvester_Filters.cc:271
ch::CombineHarvester::era
CombineHarvester & era(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:69
Process.h
-
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:426
-
ch::CombineHarvester::PrintObs
CombineHarvester & PrintObs()
Definition: CombineHarvester.cc:221
+
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:433
+
ch::CombineHarvester::PrintObs
CombineHarvester & PrintObs()
Definition: CombineHarvester.cc:226
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
ch::CombineHarvester::InsertProcess
void InsertProcess(ch::Process const &proc)
Definition: CombineHarvester_Creation.cc:249
ch::CombineHarvester::SetVerbosity
void SetVerbosity(unsigned verbosity)
Definition: CombineHarvester.h:95
ch::CombineHarvester::channel_set
std::set< std::string > channel_set()
Definition: CombineHarvester_Filters.cc:247
HistMapping.h
ch::CombineHarvester::~CombineHarvester
~CombineHarvester()
Definition: CombineHarvester.cc:29
-
ch::CombineHarvester::PrintParams
CombineHarvester & PrintParams()
Definition: CombineHarvester.cc:242
-
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:571
+
ch::CombineHarvester::PrintParams
CombineHarvester & PrintParams()
Definition: CombineHarvester.cc:247
+
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:585
ch::CombineHarvester::bin_id
CombineHarvester & bin_id(std::vector< int > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:27
ch::CombineHarvester::bin_id_set
std::set< int > bin_id_set()
Definition: CombineHarvester_Filters.cc:202
-
ch::CombineHarvester::RemoveGroup
void RemoveGroup(std::string const &name, std::vector< std::string > const &patterns)
Remove parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:708
-
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:623
+
ch::CombineHarvester::RemoveGroup
void RemoveGroup(std::string const &name, std::vector< std::string > const &patterns)
Remove parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:714
+
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:637
ch::CombineHarvester::AddProcesses
void AddProcesses(std::vector< std::string > mass, std::vector< std::string > analysis, std::vector< std::string > era, std::vector< std::string > channel, std::vector< std::string > procs, ch::Categories bin, bool signal)
Definition: CombineHarvester_Creation.cc:45
ch::CombineHarvester::AddWorkspace
void AddWorkspace(RooWorkspace const &ws, bool can_rename=false)
Definition: CombineHarvester_Creation.cc:176
Systematic.h
ch::CombineHarvester::AddBinByBin
void AddBinByBin(double threshold, bool fixed_norm, CombineHarvester *other)
Create bin-by-bin uncertainties.
Definition: CombineHarvester_Creation.cc:219
-
ch::Tuple2String
std::string Tuple2String(const std::tuple< Args... > &t)
Format any std::tuple as a string.
Definition: Utilities.h:213
+
ch::Tuple2String
std::string Tuple2String(const std::tuple< Args... > &t)
Format any std::tuple as a string.
Definition: Utilities.h:214
ch
Definition: Algorithm.h:10
ch::CombineHarvester::mass_set
std::set< std::string > mass_set()
Definition: CombineHarvester_Filters.cc:259
-
ch::CombineHarvester::GetParameter
ch::Parameter const * GetParameter(std::string const &name) const
Definition: CombineHarvester_Evaluate.cc:517
+
ch::CombineHarvester::GetParameter
ch::Parameter const * GetParameter(std::string const &name) const
Definition: CombineHarvester_Evaluate.cc:523
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
ch::CombineHarvester::syst_name
CombineHarvester & syst_name(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:126
-
ch::CombineHarvester::GetObservedRate
double GetObservedRate()
Definition: CombineHarvester_Evaluate.cc:418
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
+
ch::CombineHarvester::GetObservedRate
double GetObservedRate()
Definition: CombineHarvester_Evaluate.cc:425
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
ch::CombineHarvester::InsertObservation
void InsertObservation(ch::Observation const &obs)
Definition: CombineHarvester_Creation.cc:245
ch::CombineHarvester::MergeBinErrors
void MergeBinErrors(double bbb_threshold, double merge_threshold)
Merge bin errors within a bin.
Definition: CombineHarvester_Creation.cc:236
ch::CombineHarvester::GetShapeWithUncertainty
TH1F GetShapeWithUncertainty()
Definition: CombineHarvester_Evaluate.cc:103
-
ch::CombineHarvester::FilterAll
CombineHarvester & FilterAll(Function func)
Definition: CombineHarvester.h:607
+
ch::CombineHarvester::FilterAll
CombineHarvester & FilterAll(Function func)
Definition: CombineHarvester.h:621
ch::CombineHarvester::RenameSystematic
void RenameSystematic(CombineHarvester &target, std::string const &old_name, std::string const &new_name)
Rename a systematic from 'old_name' to 'new_name' and add a parameter 'new_name' to CH instance 'targ...
Definition: CombineHarvester_Creation.cc:137
ch::CombineHarvester::Verbosity
unsigned Verbosity()
Definition: CombineHarvester.h:96
Utilities.h
-
ch::CombineHarvester::RenameParameter
void RenameParameter(std::string const &oldname, std::string const &newname)
Definition: CombineHarvester_Evaluate.cc:507
-
ch::CombineHarvester::SetFlag
void SetFlag(std::string const &flag, bool const &value)
Set a named flag value.
Definition: CombineHarvester.cc:61
+
ch::CombineHarvester::RenameParameter
void RenameParameter(std::string const &oldname, std::string const &newname)
Definition: CombineHarvester_Evaluate.cc:513
+
ch::CombineHarvester::SetFlag
void SetFlag(std::string const &flag, bool const &value)
Set a named flag value.
Definition: CombineHarvester.cc:63
Parameter.h
ch::Observation
Definition: Observation.h:12
ch::CombineHarvester::mass
CombineHarvester & mass(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:97
-
ch::CombineHarvester::FilterObs
CombineHarvester & FilterObs(Function func)
Definition: CombineHarvester.h:615
-
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:131
+
ch::CombineHarvester::FilterObs
CombineHarvester & FilterObs(Function func)
Definition: CombineHarvester.h:629
+
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:141
ch::CombineHarvester::attr
CombineHarvester & attr(std::vector< std::string > const &vec, std::string attr_label, bool cond=true)
Definition: CombineHarvester_Filters.cc:111
-
ch::CombineHarvester::VariableRebin
void VariableRebin(std::vector< double > bins)
Definition: CombineHarvester_Evaluate.cc:583
+
ch::CombineHarvester::VariableRebin
void VariableRebin(std::vector< double > bins)
Definition: CombineHarvester_Evaluate.cc:589
ch::CombineHarvester::histograms
CombineHarvester & histograms()
Definition: CombineHarvester_Filters.cc:166
-
ch::CombineHarvester::PrintProcs
CombineHarvester & PrintProcs()
Definition: CombineHarvester.cc:228
-
ch::CombineHarvester::PrintAll
CombineHarvester & PrintAll()
Definition: CombineHarvester.cc:217
+
ch::CombineHarvester::PrintProcs
CombineHarvester & PrintProcs()
Definition: CombineHarvester.cc:233
+
ch::CombineHarvester::PrintAll
CombineHarvester & PrintAll()
Definition: CombineHarvester.cc:222
ch::CombineHarvester::era_set
std::set< std::string > era_set()
Definition: CombineHarvester_Filters.cc:235
-
ch::CombineHarvester::SetFromObs
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
Definition: CombineHarvester.h:564
+
ch::CombineHarvester::AddDatacardLineAtEnd
void AddDatacardLineAtEnd(std::string const &line)
Add a line of text at the end of all datacards.
Definition: CombineHarvester_Evaluate.cc:739
+
ch::CombineHarvester::SetFromObs
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
Definition: CombineHarvester.h:578
Observation.h
ch::CombineHarvester::syst_type_set
std::set< std::string > syst_type_set()
Definition: CombineHarvester_Filters.cc:277
-
ch::CombineHarvester::SetPdfBins
void SetPdfBins(unsigned nbins)
Definition: CombineHarvester_Evaluate.cc:646
+
ch::CombineHarvester::SetPdfBins
void SetPdfBins(unsigned nbins)
Definition: CombineHarvester_Evaluate.cc:652
ch::CombineHarvester::process_rgx
CombineHarvester & process_rgx(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:48
ch::Parameter
Definition: Parameter.h:12
-
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:585
+
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:599
ch::syst::channel
Definition: Systematics.h:26
-
ch::CombineHarvester::GetFlag
bool GetFlag(std::string const &flag) const
Definition: CombineHarvester.cc:72
-
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:602
-
ch::CombineHarvester::SetGroup
void SetGroup(std::string const &name, std::vector< std::string > const &patterns)
Add parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:694
-
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:536
+
ch::CombineHarvester::GetFlag
bool GetFlag(std::string const &flag) const
Definition: CombineHarvester.cc:74
+
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:616
+
ch::CombineHarvester::SetGroup
void SetGroup(std::string const &name, std::vector< std::string > const &patterns)
Add parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:700
+
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:542
ch::CombineHarvester::GetRateCorrelation
TH2F GetRateCorrelation(RooFitResult const &fit, unsigned n_samples)
Definition: CombineHarvester_Evaluate.cc:252
-
ch::CombineHarvester::GetParameters
std::vector< ch::Parameter > GetParameters() const
Definition: CombineHarvester_Evaluate.cc:575
-
ch::CombineHarvester::PrintSysts
CombineHarvester & PrintSysts()
Definition: CombineHarvester.cc:235
-
ch::CombineHarvester::FilterSysts
CombineHarvester & FilterSysts(Function func)
Definition: CombineHarvester.h:630
-
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:597
+
ch::CombineHarvester::GetParameters
std::vector< ch::Parameter > GetParameters() const
Definition: CombineHarvester_Evaluate.cc:581
+
ch::CombineHarvester::PrintSysts
CombineHarvester & PrintSysts()
Definition: CombineHarvester.cc:240
+
ch::CombineHarvester::FilterSysts
CombineHarvester & FilterSysts(Function func)
Definition: CombineHarvester.h:644
+
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:611
ch::CombineHarvester::pdfs
CombineHarvester & pdfs()
Definition: CombineHarvester_Filters.cc:176
-
ch::Process
Definition: Process.h:14
+
ch::Process
Definition: Process.h:15
ch::CombineHarvester::analysis
CombineHarvester & analysis(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:55
ch::CombineHarvester::CombineHarvester
CombineHarvester()
Definition: CombineHarvester.cc:16
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
ch::Categories
std::vector< std::pair< int, std::string > > Categories
Definition: CombineHarvester.h:28
-
ch::CombineHarvester::SetFromSysts
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
Definition: CombineHarvester.h:578
+
ch::CombineHarvester::SetFromSysts
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
Definition: CombineHarvester.h:592
ch::syst::era
Definition: Systematics.h:21
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
-
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:638
+
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:652
ch::CombineHarvester::ExtractShapes
void ExtractShapes(std::string const &file, std::string const &rule, std::string const &syst_rule)
Definition: CombineHarvester_Creation.cc:147
ch::Systematic
Definition: Systematic.h:12
ch::CombineHarvester::AddObservations
void AddObservations(std::vector< std::string > mass, std::vector< std::string > analysis, std::vector< std::string > era, std::vector< std::string > channel, ch::Categories bin)
Definition: CombineHarvester_Creation.cc:20
ch::CombineHarvester::GetUncertainty
double GetUncertainty()
Definition: CombineHarvester_Evaluate.cc:44
-
ch::CombineHarvester::operator=
CombineHarvester & operator=(CombineHarvester other)
Definition: CombineHarvester.cc:204
-
ch::CombineHarvester::deep
CombineHarvester deep()
Creates and retunrs a deep copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:81
+
ch::CombineHarvester::operator=
CombineHarvester & operator=(CombineHarvester other)
Definition: CombineHarvester.cc:209
+
ch::CombineHarvester::deep
CombineHarvester deep()
Creates and retunrs a deep copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:83
diff --git a/_combine_harvester___creation_8cc_source.html b/_combine_harvester___creation_8cc_source.html index 8fb6d25348d..e1d68d0d2fd 100644 --- a/_combine_harvester___creation_8cc_source.html +++ b/_combine_harvester___creation_8cc_source.html @@ -357,7 +357,7 @@
255 }
256 }
ch::Object::analysis
virtual std::string const & analysis() const
Definition: Object.h:26
-
ch::GenerateCombinations
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
Definition: Utilities.cc:190
+
ch::GenerateCombinations
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
Definition: Utilities.cc:191
ch::CombineHarvester::data
CombineHarvester & data()
Definition: CombineHarvester_Filters.cc:183
ch::CombineHarvester::CreateParameterIfEmpty
void CreateParameterIfEmpty(std::string const &name)
Definition: CombineHarvester_Creation.cc:228
ch::CombineHarvester::ExtractData
void ExtractData(std::string const &ws_name, std::string const &rule)
Definition: CombineHarvester_Creation.cc:199
@@ -384,7 +384,7 @@
ch::CombineHarvester::InsertObservation
void InsertObservation(ch::Observation const &obs)
Definition: CombineHarvester_Creation.cc:245
ch::CombineHarvester::MergeBinErrors
void MergeBinErrors(double bbb_threshold, double merge_threshold)
Merge bin errors within a bin.
Definition: CombineHarvester_Creation.cc:236
ch::CombineHarvester::RenameSystematic
void RenameSystematic(CombineHarvester &target, std::string const &old_name, std::string const &new_name)
Rename a systematic from 'old_name' to 'new_name' and add a parameter 'new_name' to CH instance 'targ...
Definition: CombineHarvester_Creation.cc:137
-
ch::Object::attribute
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:43
+
ch::Object::attribute
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:44
Utilities.h
Parameter.h
ch::Observation
Definition: Observation.h:12
@@ -395,10 +395,10 @@
ch::Parameter
Definition: Parameter.h:12
ch::syst::channel
Definition: Systematics.h:26
ch::BinByBinFactory::MergeBinErrors
void MergeBinErrors(CombineHarvester &cb)
Merges histogram bin errors between processes.
Definition: BinByBin.cc:22
-
ch::Process
Definition: Process.h:14
+
ch::Process
Definition: Process.h:15
Logging.h
ch::Categories
std::vector< std::pair< int, std::string > > Categories
Definition: CombineHarvester.h:28
-
ch::Object::all_attributes
virtual std::map< std::string, std::string > const & all_attributes() const
Definition: Object.h:42
+
ch::Object::all_attributes
virtual std::map< std::string, std::string > const & all_attributes() const
Definition: Object.h:43
ch::BinByBinFactory::AddBinByBin
void AddBinByBin(CombineHarvester &src, CombineHarvester &dest)
Create bin-by-bin shape uncertainties for every process in src, and add these to dest ...
Definition: BinByBin.cc:105
ch::syst::era
Definition: Systematics.h:21
ch::CombineHarvester::ExtractShapes
void ExtractShapes(std::string const &file, std::string const &rule, std::string const &syst_rule)
Definition: CombineHarvester_Creation.cc:147
diff --git a/_combine_harvester___datacards_8cc_source.html b/_combine_harvester___datacards_8cc_source.html index 7d52ca9edbf..7570a814874 100644 --- a/_combine_harvester___datacards_8cc_source.html +++ b/_combine_harvester___datacards_8cc_source.html @@ -159,1093 +159,1104 @@
57  std::string const& channel,
58  int bin_id,
59  std::string const& mass) {
-
60  // Load the entire datacard into memory as a vector of strings
-
61  std::vector<std::string> lines = ch::ParseFileLines(filename);
-
62  // Loop through lines, trimming whitespace at the beginning or end
-
63  // then splitting each line into a vector of words (using any amount
-
64  // of whitespace as the separator). We skip any line of zero length
-
65  // or which starts with a "#" or "-" character.
-
66  std::vector<std::vector<std::string>> words;
-
67  for (unsigned i = 0; i < lines.size(); ++i) {
-
68  boost::trim(lines[i]);
-
69  if (lines[i].size() == 0) continue;
-
70  if (lines[i].at(0) == '#' || lines[i].at(0) == '-') continue;
-
71  words.push_back(std::vector<std::string>());
-
72  boost::split(words.back(), lines[i], boost::is_any_of("\t "),
-
73  boost::token_compress_on);
-
74  }
-
75 
-
76  std::vector<HistMapping> hist_mapping;
-
77  // std::map<std::string, RooAbsData*> data_map;
-
78  std::map<std::string, std::shared_ptr<TFile>> file_store;
-
79  std::map<std::string, std::shared_ptr<RooWorkspace>> ws_store;
-
80 
-
81  bool start_nuisance_scan = false;
-
82  unsigned r = 0;
-
83 
-
84  // We will allow cards that describe a single bin to have an "observation"
-
85  // line without a "bin" line above it. We probably won't know the bin name
-
86  // when we parse this line, so we'll store it here and fix it later
-
87  std::shared_ptr<ch::Observation> single_obs = nullptr;
-
88  std::set<std::string> bin_names;
-
89 
-
90  // Store the groups that we encounter
-
91  std::map<std::string, std::set<std::string>> groups;
-
92 
-
93  // Do a first pass just for shapes, as some cards
-
94  // declare observations / processes before the shapes lines
-
95  for (unsigned i = 0; i < words.size(); ++i) {
-
96  // Ignore line if it only has one word
-
97  if (words[i].size() <= 1) continue;
-
98 
-
99  // If the line begins "shapes" then we've
-
100  // found process --> TH1 mapping information
-
101  if (boost::iequals(words[i][0], "shapes") && words[i].size() >= 5) {
-
102  hist_mapping.push_back(HistMapping());
-
103  HistMapping &mapping = hist_mapping.back();
-
104  mapping.process = words[i][1];
-
105  mapping.category = words[i][2];
-
106  // The root file path given in the datacard is relative to the datacard
-
107  // path, so we join the path to the datacard with the path to the file
-
108  std::string dc_path;
-
109  std::size_t slash = filename.find_last_of('/');
-
110  if (slash != filename.npos) {
-
111  dc_path = filename.substr(0, slash) + "/" + words[i][3];
-
112  } else {
-
113  dc_path = words[i][3];
-
114  }
-
115  if (!file_store.count(dc_path))
-
116  file_store[dc_path] = std::make_shared<TFile>(dc_path.c_str());
-
117  mapping.file = file_store.at(dc_path);
-
118  mapping.pattern = words[i][4];
-
119  if (words[i].size() > 5) mapping.syst_pattern = words[i][5];
-
120 
-
121  if (mapping.IsPdf()) {
-
122  std::string store_key =
-
123  mapping.file->GetName() + mapping.WorkspaceName();
-
124  if (!ws_store.count(store_key)) {
-
125  mapping.file->cd();
-
126  std::shared_ptr<RooWorkspace> ptr(dynamic_cast<RooWorkspace*>(
-
127  gDirectory->Get(mapping.WorkspaceName().c_str())));
-
128  if (!ptr) {
-
129  throw std::runtime_error(FNERROR("Workspace not found in file"));
-
130  }
-
131  ws_store[store_key] = ptr;
-
132  }
-
133  mapping.ws = SetupWorkspace(*(ws_store[store_key]), true);
-
134  }
-
135  if (mapping.IsPdf() && mapping.syst_pattern != "") {
-
136  std::string store_key =
-
137  mapping.file->GetName() + mapping.SystWorkspaceName();
-
138  if (!ws_store.count(store_key)) {
-
139  mapping.file->cd();
-
140  std::shared_ptr<RooWorkspace> ptr(dynamic_cast<RooWorkspace*>(
-
141  gDirectory->Get(mapping.SystWorkspaceName().c_str())));
-
142  if (!ptr) {
-
143  throw std::runtime_error(FNERROR("Workspace not found in file"));
-
144  }
-
145  ws_store[store_key] = ptr;
-
146  }
-
147  mapping.sys_ws = SetupWorkspace(*(ws_store[store_key]), true);
-
148  }
-
149  }
-
150 
-
151  // We can also have a "FAKE" shape directive
-
152  // Must be four words long: shapes * * FAKE
-
153  if (boost::iequals(words[i][0], "shapes") && words[i].size() == 4 &&
-
154  boost::iequals(words[i][3], "FAKE")) {
-
155  hist_mapping.push_back(HistMapping());
-
156  HistMapping &mapping = hist_mapping.back();
-
157  mapping.process = words[i][1];
-
158  mapping.category = words[i][2];
-
159  mapping.is_fake = true;
-
160  }
-
161  }
-
162 
-
163  // Loop through the vector of word vectors
-
164  for (unsigned i = 0; i < words.size(); ++i) {
-
165  // Ignore line if it only has one word
-
166  if (words[i].size() <= 1) continue;
-
167 
-
168  // Want to check this line and the previous one, so need i >= 1.
-
169  // If the first word on this line is "observation" and "bin" on
-
170  // the previous line then we've found the entries for data, and
-
171  // can add Observation objects
-
172  if (i >= 1) {
-
173  if ( boost::iequals(words[i][0], "observation") &&
-
174  boost::iequals(words[i-1][0], "bin") &&
-
175  words[i].size() == words[i-1].size()) {
-
176  for (unsigned p = 1; p < words[i].size(); ++p) {
-
177  auto obs = std::make_shared<Observation>();
-
178  obs->set_bin(words[i-1][p]);
-
179  obs->set_rate(boost::lexical_cast<double>(words[i][p]));
-
180  obs->set_analysis(analysis);
-
181  obs->set_era(era);
-
182  obs->set_channel(channel);
-
183  obs->set_bin_id(bin_id);
-
184  obs->set_mass(mass);
-
185 
-
186  LoadShapes(obs.get(), hist_mapping);
-
187 
-
188  obs_.push_back(obs);
-
189  }
-
190  }
-
191  }
-
192 
-
193  if (boost::iequals(words[i][0], "observation") &&
-
194  !boost::iequals(words[i-1][0], "bin") &&
-
195  words[i].size() == 2 &&
-
196  single_obs.get() == nullptr) {
-
197  for (unsigned p = 1; p < words[i].size(); ++p) {
-
198  single_obs = std::make_shared<Observation>();
-
199  single_obs->set_bin("");
-
200  single_obs->set_rate(boost::lexical_cast<double>(words[i][p]));
-
201  single_obs->set_analysis(analysis);
-
202  single_obs->set_era(era);
-
203  single_obs->set_channel(channel);
-
204  single_obs->set_bin_id(bin_id);
-
205  single_obs->set_mass(mass);
-
206  }
-
207  }
-
208 
-
209  // Similarly look for the lines indicating the different signal
-
210  // and background processes
-
211  // Once these are found save in line index for the rate line as r
-
212  // to we can refer back to these later, then assume that every
-
213  // line that follows is a nuisance parameter
-
214 
-
215  if (i >= 3) {
-
216  if ( boost::iequals(words[i][0], "rate") &&
-
217  boost::iequals(words[i-1][0], "process") &&
-
218  boost::iequals(words[i-2][0], "process") &&
-
219  boost::iequals(words[i-3][0], "bin") &&
-
220  words[i].size() == words[i-1].size() &&
-
221  words[i].size() == words[i-2].size() &&
-
222  words[i].size() == words[i-3].size()) {
-
223  for (unsigned p = 1; p < words[i].size(); ++p) {
-
224  auto proc = std::make_shared<Process>();
-
225  proc->set_bin(words[i-3][p]);
-
226  bin_names.insert(words[i-3][p]);
-
227  try {
-
228  int process_id = boost::lexical_cast<int>(words[i-2][p]);
-
229  proc->set_signal(process_id <= 0);
-
230  proc->set_process(words[i-1][p]);
-
231  } catch(boost::bad_lexical_cast &) {
-
232  int process_id = boost::lexical_cast<int>(words[i-1][p]);
-
233  proc->set_signal(process_id <= 0);
-
234  proc->set_process(words[i-2][p]);
-
235  }
-
236  proc->set_rate(boost::lexical_cast<double>(words[i][p]));
-
237  proc->set_analysis(analysis);
-
238  proc->set_era(era);
-
239  proc->set_channel(channel);
-
240  proc->set_bin_id(bin_id);
-
241  proc->set_mass(mass);
-
242 
-
243  LoadShapes(proc.get(), hist_mapping);
-
244 
-
245  procs_.push_back(proc);
-
246  }
-
247  r = i;
-
248  start_nuisance_scan = true;
-
249  }
-
250  }
-
251 
-
252  if (start_nuisance_scan && words[i].size() >= 4) {
-
253  if (boost::iequals(words[i][1], "param")) {
-
254  std::string param_name = words[i][0];
-
255  if (!params_.count(param_name))
-
256  params_[param_name] = std::make_shared<Parameter>(Parameter());
-
257  Parameter * param = params_.at(param_name).get();
-
258  param->set_name(param_name);
-
259  param->set_val(boost::lexical_cast<double>(words[i][2]));
-
260  std::size_t slash_pos = words[i][3].find("/");
-
261  if (slash_pos != words[i][3].npos) {
-
262  param->set_err_d(
-
263  boost::lexical_cast<double>(words[i][3].substr(0, slash_pos)));
-
264  param->set_err_u(
-
265  boost::lexical_cast<double>(words[i][3].substr(slash_pos+1)));
-
266  } else {
-
267  param->set_err_u(+1.0 * boost::lexical_cast<double>(words[i][3]));
-
268  param->set_err_d(-1.0 * boost::lexical_cast<double>(words[i][3]));
-
269  }
-
270  if (words[i].size() >= 5) {
-
271  // We have a range
-
272  std::vector<std::string> tokens;
-
273  boost::split(tokens, words[i][4], boost::is_any_of("[],"));
-
274  if (tokens.size() == 4) {
-
275  param->set_range_d(boost::lexical_cast<double>(tokens[1]));
-
276  param->set_range_u(boost::lexical_cast<double>(tokens[2]));
-
277  }
-
278  }
-
279  continue; // skip the rest of this now
-
280  }
-
281  }
-
282 
-
283  if (start_nuisance_scan && words[i].size() >= 5 &&
-
284  boost::iequals(words[i][1], "rateParam")) {
-
285  if (verbosity_ > 1) {
-
286  FNLOG(log()) << "Processing rateParam line:\n";
-
287  for (auto const& str : words[i]) {
-
288  log() << str << "\t";
-
289  }
-
290  log() << "\n";
-
291  }
-
292 
-
293  bool has_range = words[i].size() == 6 && words[i][5][0] == '[';
-
294  std::string param_name = words[i][0];
-
295  // If this is a free param may need to create a Parameter object
-
296  // If the line has 5 words this must be a floating param, otherwise
-
297  // if it has 6 then it's a floating param
-
298  if (words[i].size() == 5 || has_range) {
-
299  ch::Parameter* param = SetupRateParamVar(
-
300  param_name, boost::lexical_cast<double>(words[i][4]));
-
301  param->set_err_u(0.);
-
302  param->set_err_d(0.);
-
303  if (has_range) {
-
304  std::vector<std::string> tokens;
-
305  boost::split(tokens, words[i][5], boost::is_any_of("[],"));
-
306  if (tokens.size() == 4) {
-
307  param->set_range_d(boost::lexical_cast<double>(tokens[1]));
-
308  param->set_range_u(boost::lexical_cast<double>(tokens[2]));
-
309  FNLOGC(log(), verbosity_ > 1) << "Setting parameter range to " << words[i][5];
-
310  }
-
311  }
-
312  } else if (words[i].size() == 6 && !has_range) {
-
313  SetupRateParamFunc(param_name, words[i][4], words[i][5]);
-
314  }
-
315  for (unsigned p = 1; p < words[r].size(); ++p) {
-
316  bool matches_bin = false;
-
317  bool matches_proc = false;
-
318  int process_id;
-
319  std::string process;
-
320  std::string bin = words[r-3][p];
-
321  // Not great that we repeat this below
-
322  try {
-
323  process_id = boost::lexical_cast<int>(words[r-2][p]);
-
324  process = words[r-1][p];
-
325  } catch(boost::bad_lexical_cast &) {
-
326  process_id = boost::lexical_cast<int>(words[r-1][p]);
-
327  process = words[r-2][p];
-
328  }
-
329  if (words[i][2] == "*" || words[i][2] == bin) {
-
330  matches_bin = true;
-
331  }
-
332  if (words[i][3] == "*" || words[i][3] == process) {
-
333  matches_proc = true;
-
334  }
-
335  if (!matches_bin || !matches_proc) continue;
-
336  auto sys = std::make_shared<Systematic>();
-
337  sys->set_bin(bin);
-
338  sys->set_signal(process_id <= 0);
-
339  sys->set_process(process);
-
340  sys->set_name(param_name);
-
341  sys->set_type("rateParam");
-
342  sys->set_analysis(analysis);
-
343  sys->set_era(era);
-
344  sys->set_channel(channel);
-
345  sys->set_bin_id(bin_id);
-
346  sys->set_mass(mass);
-
347  systs_.push_back(sys);
-
348  }
-
349  continue;
-
350  }
-
351 
-
352  if (start_nuisance_scan && words[i].size() >= 4 &&
-
353  boost::iequals(words[i][1], "group")) {
-
354  if (!groups.count(words[i][0])) {
-
355  groups[words[i][0]] = std::set<std::string>();
-
356  }
-
357  for (unsigned ig = 3; ig < words[i].size(); ++ig) {
-
358  groups[words[i][0]].insert(words[i][ig]);
-
359  }
-
360  continue;
-
361  }
-
362 
-
363  if (start_nuisance_scan && words[i].size()-1 == words[r].size()) {
-
364  for (unsigned p = 2; p < words[i].size(); ++p) {
-
365  if (words[i][p] == "-") continue;
-
366  auto sys = std::make_shared<Systematic>();
-
367  sys->set_bin(words[r-3][p-1]);
-
368  try {
-
369  int process_id = boost::lexical_cast<int>(words[r-2][p-1]);
-
370  sys->set_signal(process_id <= 0);
-
371  sys->set_process(words[r-1][p-1]);
-
372  } catch(boost::bad_lexical_cast &) {
-
373  int process_id = boost::lexical_cast<int>(words[r-1][p-1]);
-
374  sys->set_signal(process_id <= 0);
-
375  sys->set_process(words[r-2][p-1]);
-
376  }
-
377  sys->set_name(words[i][0]);
-
378  std::string type = words[i][1];
-
379  if (!contains(std::vector<std::string>{"shape", "shape?", "shapeN2", "shapeU", "lnN", "lnU"},
-
380  type)) {
-
381  throw std::runtime_error(
-
382  FNERROR("Systematic type " + type + " not supported"));
-
383  }
-
384  sys->set_type(words[i][1]);
-
385  sys->set_analysis(analysis);
-
386  sys->set_era(era);
-
387  sys->set_channel(channel);
-
388  sys->set_bin_id(bin_id);
-
389  sys->set_mass(mass);
-
390  sys->set_scale(1.0);
-
391  std::size_t slash_pos = words[i][p].find("/");
-
392  if (slash_pos != words[i][p].npos) {
-
393  // Assume asymmetric of form kDown/kUp
-
394  sys->set_value_d(
-
395  boost::lexical_cast<double>(words[i][p].substr(0, slash_pos)));
-
396  sys->set_value_u(
-
397  boost::lexical_cast<double>(words[i][p].substr(slash_pos+1)));
-
398  sys->set_asymm(true);
-
399  } else {
-
400  sys->set_value_u(boost::lexical_cast<double>(words[i][p]));
-
401  sys->set_asymm(false);
-
402  }
-
403  if (sys->type() == "shape" || sys->type() == "shapeN2" ||
-
404  sys->type() == "shapeU") {
-
405  sys->set_scale(boost::lexical_cast<double>(words[i][p]));
-
406  LoadShapes(sys.get(), hist_mapping);
-
407  } else if (sys->type() == "shape?") {
-
408  // This might fail, so we have to "try"
-
409  try {
-
410  LoadShapes(sys.get(), hist_mapping);
-
411  } catch (std::exception & e) {
-
412  LOGLINE(log(), "Systematic with shape? did not resolve to a shape");
-
413  if (verbosity_ > 0) log() << e.what();
-
414  }
-
415  if (!sys->shape_u() || !sys->shape_d()) {
-
416  sys->set_type("lnN");
-
417  } else {
-
418  sys->set_type("shape");
-
419  sys->set_scale(boost::lexical_cast<double>(words[i][p]));
-
420  }
-
421  }
-
422  if (sys->type() == "shape" || sys->type() == "shapeN2" ||
-
423  sys->type() == "shapeU")
-
424  sys->set_asymm(true);
-
425 
-
426  CombineHarvester::CreateParameterIfEmpty(sys->name());
-
427  if (sys->type() == "lnU" || sys->type() == "shapeU") {
-
428  params_.at(sys->name())->set_err_d(0.);
-
429  params_.at(sys->name())->set_err_u(0.);
-
430  }
-
431  systs_.push_back(sys);
-
432  }
-
433  }
-
434  }
-
435  if (single_obs) {
-
436  if (bin_names.size() == 1) {
-
437  single_obs->set_bin(*(bin_names.begin()));
-
438  LoadShapes(single_obs.get(), hist_mapping);
-
439  obs_.push_back(single_obs);
-
440  } else {
-
441  throw std::runtime_error(FNERROR(
-
442  "Input card specifies a single observation entry without a bin, but "
-
443  "multiple bins defined elsewhere"));
-
444  }
-
445  }
-
446 
-
447  // Finally populate the groups
-
448  for (auto const& grp : groups) {
-
449  this->SetGroup(grp.first, ch::Set2Vec(grp.second));
-
450  }
-
451  return 0;
-
452 }
-
453 
-
454 void CombineHarvester::WriteDatacard(std::string const& name,
-
455  std::string const& root_file) {
-
456  TFile file(root_file.c_str(), "RECREATE");
-
457  CombineHarvester::WriteDatacard(name, file);
-
458  file.Close();
-
459 }
-
460 
-
461 void CombineHarvester::WriteDatacard(std::string const& name) {
-
462  TFile dummy;
-
463  CombineHarvester::WriteDatacard(name, dummy);
-
464  dummy.Close();
-
465 }
-
466 
-
467 void CombineHarvester::FillHistMappings(std::vector<HistMapping> & mappings) {
-
468  // Build maps of
-
469  // RooAbsData --> RooWorkspace
-
470  // RooAbsPdf --> RooWorkspace
-
471  std::map<RooAbsData const*, RooWorkspace*> data_ws_map;
-
472  std::map<RooAbsPdf const*, RooWorkspace*> pdf_ws_map;
-
473  for (auto const& iter : wspaces_) {
-
474  auto dat = iter.second->allData();
-
475  for (auto d : dat) {
-
476  data_ws_map[d] = iter.second.get();
-
477  }
-
478  RooArgSet vars = iter.second->allPdfs();
-
479  auto v = vars.createIterator();
-
480  do {
-
481  RooAbsPdf *y = dynamic_cast<RooAbsPdf*>(**v);
-
482  if (y) pdf_ws_map[iter.second->pdf(y->GetName())] = iter.second.get();
-
483  } while (v->Next());
-
484  }
-
485 
-
486  // For writing TH1s we will hard code a set of patterns for each bin
-
487  // This assumes that the backgrounds will not depend on "mass" but the
-
488  // signal will. Will probably want to change this in the future
-
489  std::set<std::string> hist_bins;
-
490  auto bins = this->bin_set();
-
491  for (auto bin : bins) {
-
492  unsigned shape_count = std::count_if(procs_.begin(), procs_.end(),
-
493  [&](std::shared_ptr<ch::Process> p) {
-
494  return (p->bin() == bin && p->shape() && (!p->signal()));
-
495  });
-
496  shape_count += std::count_if(obs_.begin(), obs_.end(),
-
497  [&](std::shared_ptr<ch::Observation> p) {
-
498  return (p->bin() == bin && p->shape());
-
499  });
-
500  unsigned counting = std::count_if(
-
501  procs_.begin(), procs_.end(), [&](std::shared_ptr<ch::Process> p) {
-
502  return (p->bin() == bin && p->shape() == nullptr &&
-
503  p->pdf() == nullptr && p->data() == nullptr);
-
504  });
-
505  counting += std::count_if(
-
506  obs_.begin(), obs_.end(), [&](std::shared_ptr<ch::Observation> p) {
-
507  return (p->bin() == bin && p->shape() == nullptr &&
-
508  p->data() == nullptr);
-
509  });
-
510 
-
511  if (shape_count > 0) {
-
512  mappings.emplace_back("*", bin, bin + "/$PROCESS",
-
513  bin + "/$PROCESS_$SYSTEMATIC");
-
514  hist_bins.insert(bin);
-
515  } else if (counting > 0) {
-
516  mappings.emplace_back("*", bin, "", "");
-
517  mappings.back().is_fake = true;
-
518  }
-
519 
-
520  CombineHarvester ch_signals =
-
521  std::move(this->cp().bin({bin}).signals().histograms());
-
522  auto sig_proc_set =
-
523  ch_signals.SetFromProcs(std::mem_fn(&ch::Process::process));
-
524  for (auto sig_proc : sig_proc_set) {
-
525  // should only add this mapping if the signal process has a numeric mass
-
526  // value, otherwise we will write it using the background rule above
-
527  auto masses = Set2Vec(ch_signals.cp()
-
528  .process({sig_proc})
-
529  .SetFromProcs(std::mem_fn(&ch::Process::mass)));
-
530  if (masses.size() != 1) {
-
531  throw std::runtime_error(FNERROR("Process " + sig_proc + " in bin " +
-
532  bin +
-
533  " has multiple entries with multiple "
-
534  "mass values, this is not supported"));
-
535 
-
536  }
-
537  if (is_float(masses[0])) {
-
538  mappings.emplace_back(sig_proc, bin, bin + "/" + sig_proc + "$MASS",
-
539  bin + "/" + sig_proc + "$MASS_$SYSTEMATIC");
-
540  }
-
541  }
-
542  }
-
543 
-
544  // Generate mappings for RooFit objects
-
545  for (auto bin : bins) {
-
546  CombineHarvester ch_bin = std::move(this->cp().bin({bin}));
-
547  for (auto obs : ch_bin.obs_) {
-
548  if (!obs->data()) continue;
-
549  std::string obj_name = std::string(data_ws_map[obs->data()]->GetName()) +
-
550  ":" + std::string(obs->data()->GetName());
-
551  mappings.emplace_back("data_obs", obs->bin(), obj_name, "");
-
552  }
-
553 
-
554  bool prototype_ok = false;
-
555  HistMapping prototype;
-
556  std::vector<HistMapping> full_list;
-
557  auto pmap = ch_bin.GenerateProcSystMap();
-
558  for (unsigned i = 0; i < ch_bin.procs_.size(); ++i) {
-
559  ch::Process * proc = ch_bin.procs_[i].get();
-
560  if (!proc->data() && !proc->pdf()) continue;
-
561  std::string obj_name;
-
562  std::string obj_sys_name;
-
563  if (proc->data()) {
-
564  obj_name = std::string(data_ws_map[proc->data()]->GetName()) + ":" +
-
565  std::string(proc->data()->GetName());
-
566  }
-
567  if (proc->pdf()) {
-
568  obj_name = std::string(pdf_ws_map[proc->pdf()]->GetName()) +
-
569  ":" + std::string(proc->pdf()->GetName());
-
570  }
-
571  for (unsigned j = 0; j < pmap[i].size(); ++j) {
-
572  ch::Systematic const* sys = pmap[i][j];
-
573  if (sys->data_u()) {
-
574  obj_sys_name = std::string(data_ws_map[sys->data_u()]->GetName()) +
-
575  ":" + std::string(sys->data_u()->GetName());
-
576  boost::replace_all(obj_sys_name, sys->name() + "Up", "$SYSTEMATIC");
-
577  boost::replace_all(obj_sys_name, sys->process(), "$PROCESS");
-
578  break;
-
579  }
-
580  }
-
581  boost::replace_all(obj_name, proc->process(), "$PROCESS");
-
582 
-
583  // If the prototype pattern is already filled, but doesn't equal this
-
584  // new pattern - then we can't use the prototype
-
585  if (prototype.pattern.size() && prototype.pattern != obj_name) {
-
586  prototype_ok = false;
+
60  TH1::AddDirectory(kFALSE);
+
61  // Load the entire datacard into memory as a vector of strings
+
62  std::vector<std::string> lines = ch::ParseFileLines(filename);
+
63  // Loop through lines, trimming whitespace at the beginning or end
+
64  // then splitting each line into a vector of words (using any amount
+
65  // of whitespace as the separator). We skip any line of zero length
+
66  // or which starts with a "#" or "-" character.
+
67  std::vector<std::vector<std::string>> words;
+
68  for (unsigned i = 0; i < lines.size(); ++i) {
+
69  boost::trim(lines[i]);
+
70  if (lines[i].size() == 0) continue;
+
71  if (lines[i].at(0) == '#' || lines[i].at(0) == '-') continue;
+
72  words.push_back(std::vector<std::string>());
+
73  boost::split(words.back(), lines[i], boost::is_any_of("\t "),
+
74  boost::token_compress_on);
+
75  }
+
76 
+
77  std::vector<HistMapping> hist_mapping;
+
78  // std::map<std::string, RooAbsData*> data_map;
+
79  std::map<std::string, std::shared_ptr<TFile>> file_store;
+
80  std::map<std::string, std::shared_ptr<RooWorkspace>> ws_store;
+
81 
+
82  bool start_nuisance_scan = false;
+
83  unsigned r = 0;
+
84 
+
85  // We will allow cards that describe a single bin to have an "observation"
+
86  // line without a "bin" line above it. We probably won't know the bin name
+
87  // when we parse this line, so we'll store it here and fix it later
+
88  std::shared_ptr<ch::Observation> single_obs = nullptr;
+
89  std::set<std::string> bin_names;
+
90 
+
91  // Store the groups that we encounter
+
92  std::map<std::string, std::set<std::string>> groups;
+
93 
+
94  // Do a first pass just for shapes, as some cards
+
95  // declare observations / processes before the shapes lines
+
96  for (unsigned i = 0; i < words.size(); ++i) {
+
97  // Ignore line if it only has one word
+
98  if (words[i].size() <= 1) continue;
+
99 
+
100  // If the line begins "shapes" then we've
+
101  // found process --> TH1 mapping information
+
102  if (boost::iequals(words[i][0], "shapes") && words[i].size() >= 5) {
+
103  hist_mapping.push_back(HistMapping());
+
104  HistMapping &mapping = hist_mapping.back();
+
105  mapping.process = words[i][1];
+
106  mapping.category = words[i][2];
+
107  // The root file path given in the datacard is relative to the datacard
+
108  // path, so we join the path to the datacard with the path to the file
+
109  std::string dc_path;
+
110  std::size_t slash = filename.find_last_of('/');
+
111  if (slash != filename.npos) {
+
112  dc_path = filename.substr(0, slash) + "/" + words[i][3];
+
113  } else {
+
114  dc_path = words[i][3];
+
115  }
+
116  if (!file_store.count(dc_path))
+
117  file_store[dc_path] = std::make_shared<TFile>(dc_path.c_str());
+
118  mapping.file = file_store.at(dc_path);
+
119  mapping.pattern = words[i][4];
+
120  if (words[i].size() > 5) mapping.syst_pattern = words[i][5];
+
121 
+
122  if (mapping.IsPdf()) {
+
123  std::string store_key =
+
124  mapping.file->GetName() + mapping.WorkspaceName();
+
125  if (!ws_store.count(store_key)) {
+
126  mapping.file->cd();
+
127  std::shared_ptr<RooWorkspace> ptr(dynamic_cast<RooWorkspace*>(
+
128  gDirectory->Get(mapping.WorkspaceName().c_str())));
+
129  if (!ptr) {
+
130  throw std::runtime_error(FNERROR("Workspace not found in file"));
+
131  }
+
132  ws_store[store_key] = ptr;
+
133  }
+
134  mapping.ws = SetupWorkspace(*(ws_store[store_key]), true);
+
135  }
+
136  if (mapping.IsPdf() && mapping.syst_pattern != "") {
+
137  std::string store_key =
+
138  mapping.file->GetName() + mapping.SystWorkspaceName();
+
139  if (!ws_store.count(store_key)) {
+
140  mapping.file->cd();
+
141  std::shared_ptr<RooWorkspace> ptr(dynamic_cast<RooWorkspace*>(
+
142  gDirectory->Get(mapping.SystWorkspaceName().c_str())));
+
143  if (!ptr) {
+
144  throw std::runtime_error(FNERROR("Workspace not found in file"));
+
145  }
+
146  ws_store[store_key] = ptr;
+
147  }
+
148  mapping.sys_ws = SetupWorkspace(*(ws_store[store_key]), true);
+
149  }
+
150  }
+
151 
+
152  // We can also have a "FAKE" shape directive
+
153  // Must be four words long: shapes * * FAKE
+
154  if (boost::iequals(words[i][0], "shapes") && words[i].size() == 4 &&
+
155  boost::iequals(words[i][3], "FAKE")) {
+
156  hist_mapping.push_back(HistMapping());
+
157  HistMapping &mapping = hist_mapping.back();
+
158  mapping.process = words[i][1];
+
159  mapping.category = words[i][2];
+
160  mapping.is_fake = true;
+
161  }
+
162  }
+
163 
+
164  // Loop through the vector of word vectors
+
165  for (unsigned i = 0; i < words.size(); ++i) {
+
166  // Ignore line if it only has one word
+
167  if (words[i].size() <= 1) continue;
+
168 
+
169  // Want to check this line and the previous one, so need i >= 1.
+
170  // If the first word on this line is "observation" and "bin" on
+
171  // the previous line then we've found the entries for data, and
+
172  // can add Observation objects
+
173  if (i >= 1) {
+
174  if ( boost::iequals(words[i][0], "observation") &&
+
175  boost::iequals(words[i-1][0], "bin") &&
+
176  words[i].size() == words[i-1].size()) {
+
177  for (unsigned p = 1; p < words[i].size(); ++p) {
+
178  auto obs = std::make_shared<Observation>();
+
179  obs->set_bin(words[i-1][p]);
+
180  obs->set_rate(boost::lexical_cast<double>(words[i][p]));
+
181  obs->set_analysis(analysis);
+
182  obs->set_era(era);
+
183  obs->set_channel(channel);
+
184  obs->set_bin_id(bin_id);
+
185  obs->set_mass(mass);
+
186 
+
187  LoadShapes(obs.get(), hist_mapping);
+
188 
+
189  obs_.push_back(obs);
+
190  }
+
191  }
+
192  }
+
193 
+
194  if (boost::iequals(words[i][0], "observation") &&
+
195  !boost::iequals(words[i-1][0], "bin") &&
+
196  words[i].size() == 2 &&
+
197  single_obs.get() == nullptr) {
+
198  for (unsigned p = 1; p < words[i].size(); ++p) {
+
199  single_obs = std::make_shared<Observation>();
+
200  single_obs->set_bin("");
+
201  single_obs->set_rate(boost::lexical_cast<double>(words[i][p]));
+
202  single_obs->set_analysis(analysis);
+
203  single_obs->set_era(era);
+
204  single_obs->set_channel(channel);
+
205  single_obs->set_bin_id(bin_id);
+
206  single_obs->set_mass(mass);
+
207  }
+
208  }
+
209 
+
210  // Similarly look for the lines indicating the different signal
+
211  // and background processes
+
212  // Once these are found save in line index for the rate line as r
+
213  // to we can refer back to these later, then assume that every
+
214  // line that follows is a nuisance parameter
+
215 
+
216  if (i >= 3) {
+
217  if ( boost::iequals(words[i][0], "rate") &&
+
218  boost::iequals(words[i-1][0], "process") &&
+
219  boost::iequals(words[i-2][0], "process") &&
+
220  boost::iequals(words[i-3][0], "bin") &&
+
221  words[i].size() == words[i-1].size() &&
+
222  words[i].size() == words[i-2].size() &&
+
223  words[i].size() == words[i-3].size()) {
+
224  for (unsigned p = 1; p < words[i].size(); ++p) {
+
225  auto proc = std::make_shared<Process>();
+
226  proc->set_bin(words[i-3][p]);
+
227  bin_names.insert(words[i-3][p]);
+
228  try {
+
229  int process_id = boost::lexical_cast<int>(words[i-2][p]);
+
230  proc->set_signal(process_id <= 0);
+
231  proc->set_process(words[i-1][p]);
+
232  } catch(boost::bad_lexical_cast &) {
+
233  int process_id = boost::lexical_cast<int>(words[i-1][p]);
+
234  proc->set_signal(process_id <= 0);
+
235  proc->set_process(words[i-2][p]);
+
236  }
+
237  proc->set_rate(boost::lexical_cast<double>(words[i][p]));
+
238  proc->set_analysis(analysis);
+
239  proc->set_era(era);
+
240  proc->set_channel(channel);
+
241  proc->set_bin_id(bin_id);
+
242  proc->set_mass(mass);
+
243 
+
244  LoadShapes(proc.get(), hist_mapping);
+
245 
+
246  procs_.push_back(proc);
+
247  }
+
248  r = i;
+
249  start_nuisance_scan = true;
+
250  }
+
251  }
+
252 
+
253  if (start_nuisance_scan && words[i].size() >= 4) {
+
254  if (boost::iequals(words[i][1], "param")) {
+
255  std::string param_name = words[i][0];
+
256  if (!params_.count(param_name))
+
257  params_[param_name] = std::make_shared<Parameter>(Parameter());
+
258  Parameter * param = params_.at(param_name).get();
+
259  param->set_name(param_name);
+
260  param->set_val(boost::lexical_cast<double>(words[i][2]));
+
261  std::size_t slash_pos = words[i][3].find("/");
+
262  if (slash_pos != words[i][3].npos) {
+
263  param->set_err_d(
+
264  boost::lexical_cast<double>(words[i][3].substr(0, slash_pos)));
+
265  param->set_err_u(
+
266  boost::lexical_cast<double>(words[i][3].substr(slash_pos+1)));
+
267  } else {
+
268  param->set_err_u(+1.0 * boost::lexical_cast<double>(words[i][3]));
+
269  param->set_err_d(-1.0 * boost::lexical_cast<double>(words[i][3]));
+
270  }
+
271  if (words[i].size() >= 5) {
+
272  // We have a range
+
273  std::vector<std::string> tokens;
+
274  boost::split(tokens, words[i][4], boost::is_any_of("[],"));
+
275  if (tokens.size() == 4) {
+
276  param->set_range_d(boost::lexical_cast<double>(tokens[1]));
+
277  param->set_range_u(boost::lexical_cast<double>(tokens[2]));
+
278  }
+
279  }
+
280  continue; // skip the rest of this now
+
281  }
+
282  }
+
283 
+
284  if (start_nuisance_scan && words[i].size() >= 5 &&
+
285  boost::iequals(words[i][1], "rateParam")) {
+
286  if (verbosity_ > 1) {
+
287  FNLOG(log()) << "Processing rateParam line:\n";
+
288  for (auto const& str : words[i]) {
+
289  log() << str << "\t";
+
290  }
+
291  log() << "\n";
+
292  }
+
293 
+
294  bool has_range = words[i].size() == 6 && words[i][5][0] == '[';
+
295  std::string param_name = words[i][0];
+
296  // If this is a free param may need to create a Parameter object
+
297  // If the line has 5 words this must be a floating param, otherwise
+
298  // if it has 6 then it's a floating param
+
299  if (words[i].size() == 5 || has_range) {
+
300  ch::Parameter* param = SetupRateParamVar(
+
301  param_name, boost::lexical_cast<double>(words[i][4]));
+
302  param->set_err_u(0.);
+
303  param->set_err_d(0.);
+
304  if (has_range) {
+
305  std::vector<std::string> tokens;
+
306  boost::split(tokens, words[i][5], boost::is_any_of("[],"));
+
307  if (tokens.size() == 4) {
+
308  param->set_range_d(boost::lexical_cast<double>(tokens[1]));
+
309  param->set_range_u(boost::lexical_cast<double>(tokens[2]));
+
310  FNLOGC(log(), verbosity_ > 1) << "Setting parameter range to " << words[i][5];
+
311  }
+
312  }
+
313  } else if (words[i].size() == 6 && !has_range) {
+
314  SetupRateParamFunc(param_name, words[i][4], words[i][5]);
+
315  }
+
316  for (unsigned p = 1; p < words[r].size(); ++p) {
+
317  bool matches_bin = false;
+
318  bool matches_proc = false;
+
319  int process_id;
+
320  std::string process;
+
321  std::string bin = words[r-3][p];
+
322  // Not great that we repeat this below
+
323  try {
+
324  process_id = boost::lexical_cast<int>(words[r-2][p]);
+
325  process = words[r-1][p];
+
326  } catch(boost::bad_lexical_cast &) {
+
327  process_id = boost::lexical_cast<int>(words[r-1][p]);
+
328  process = words[r-2][p];
+
329  }
+
330  if (words[i][2] == "*" || words[i][2] == bin) {
+
331  matches_bin = true;
+
332  }
+
333  if (words[i][3] == "*" || words[i][3] == process) {
+
334  matches_proc = true;
+
335  }
+
336  if (!matches_bin || !matches_proc) continue;
+
337  auto sys = std::make_shared<Systematic>();
+
338  sys->set_bin(bin);
+
339  sys->set_signal(process_id <= 0);
+
340  sys->set_process(process);
+
341  sys->set_name(param_name);
+
342  sys->set_type("rateParam");
+
343  sys->set_analysis(analysis);
+
344  sys->set_era(era);
+
345  sys->set_channel(channel);
+
346  sys->set_bin_id(bin_id);
+
347  sys->set_mass(mass);
+
348  systs_.push_back(sys);
+
349  }
+
350  continue;
+
351  }
+
352 
+
353  if (start_nuisance_scan && words[i].size() >= 4 &&
+
354  boost::iequals(words[i][1], "group")) {
+
355  if (!groups.count(words[i][0])) {
+
356  groups[words[i][0]] = std::set<std::string>();
+
357  }
+
358  for (unsigned ig = 3; ig < words[i].size(); ++ig) {
+
359  groups[words[i][0]].insert(words[i][ig]);
+
360  }
+
361  continue;
+
362  }
+
363 
+
364  if (start_nuisance_scan && words[i].size()-1 == words[r].size()) {
+
365  for (unsigned p = 2; p < words[i].size(); ++p) {
+
366  if (words[i][p] == "-") continue;
+
367  auto sys = std::make_shared<Systematic>();
+
368  sys->set_bin(words[r-3][p-1]);
+
369  try {
+
370  int process_id = boost::lexical_cast<int>(words[r-2][p-1]);
+
371  sys->set_signal(process_id <= 0);
+
372  sys->set_process(words[r-1][p-1]);
+
373  } catch(boost::bad_lexical_cast &) {
+
374  int process_id = boost::lexical_cast<int>(words[r-1][p-1]);
+
375  sys->set_signal(process_id <= 0);
+
376  sys->set_process(words[r-2][p-1]);
+
377  }
+
378  sys->set_name(words[i][0]);
+
379  std::string type = words[i][1];
+
380  if (!contains(std::vector<std::string>{"shape", "shape?", "shapeN2", "shapeU", "lnN", "lnU"},
+
381  type)) {
+
382  throw std::runtime_error(
+
383  FNERROR("Systematic type " + type + " not supported"));
+
384  }
+
385  sys->set_type(words[i][1]);
+
386  sys->set_analysis(analysis);
+
387  sys->set_era(era);
+
388  sys->set_channel(channel);
+
389  sys->set_bin_id(bin_id);
+
390  sys->set_mass(mass);
+
391  sys->set_scale(1.0);
+
392  std::size_t slash_pos = words[i][p].find("/");
+
393  if (slash_pos != words[i][p].npos) {
+
394  // Assume asymmetric of form kDown/kUp
+
395  sys->set_value_d(
+
396  boost::lexical_cast<double>(words[i][p].substr(0, slash_pos)));
+
397  sys->set_value_u(
+
398  boost::lexical_cast<double>(words[i][p].substr(slash_pos+1)));
+
399  sys->set_asymm(true);
+
400  } else {
+
401  sys->set_value_u(boost::lexical_cast<double>(words[i][p]));
+
402  sys->set_asymm(false);
+
403  }
+
404  if (sys->type() == "shape" || sys->type() == "shapeN2" ||
+
405  sys->type() == "shapeU") {
+
406  sys->set_scale(boost::lexical_cast<double>(words[i][p]));
+
407  LoadShapes(sys.get(), hist_mapping);
+
408  } else if (sys->type() == "shape?") {
+
409  // This might fail, so we have to "try"
+
410  try {
+
411  LoadShapes(sys.get(), hist_mapping);
+
412  } catch (std::exception & e) {
+
413  LOGLINE(log(), "Systematic with shape? did not resolve to a shape");
+
414  if (verbosity_ > 0) log() << e.what();
+
415  }
+
416  if (!sys->shape_u() || !sys->shape_d()) {
+
417  sys->set_type("lnN");
+
418  } else {
+
419  sys->set_type("shape");
+
420  sys->set_scale(boost::lexical_cast<double>(words[i][p]));
+
421  }
+
422  }
+
423  if (sys->type() == "shape" || sys->type() == "shapeN2" ||
+
424  sys->type() == "shapeU")
+
425  sys->set_asymm(true);
+
426 
+
427  CombineHarvester::CreateParameterIfEmpty(sys->name());
+
428  if (sys->type() == "lnU" || sys->type() == "shapeU") {
+
429  params_.at(sys->name())->set_err_d(0.);
+
430  params_.at(sys->name())->set_err_u(0.);
+
431  }
+
432  systs_.push_back(sys);
+
433  }
+
434  }
+
435  }
+
436  if (single_obs) {
+
437  if (bin_names.size() == 1) {
+
438  single_obs->set_bin(*(bin_names.begin()));
+
439  LoadShapes(single_obs.get(), hist_mapping);
+
440  obs_.push_back(single_obs);
+
441  } else {
+
442  throw std::runtime_error(FNERROR(
+
443  "Input card specifies a single observation entry without a bin, but "
+
444  "multiple bins defined elsewhere"));
+
445  }
+
446  }
+
447 
+
448  // Finally populate the groups
+
449  for (auto const& grp : groups) {
+
450  this->SetGroup(grp.first, ch::Set2Vec(grp.second));
+
451  }
+
452  return 0;
+
453 }
+
454 
+
455 void CombineHarvester::WriteDatacard(std::string const& name,
+
456  std::string const& root_file) {
+
457  TFile file(root_file.c_str(), "RECREATE");
+
458  CombineHarvester::WriteDatacard(name, file);
+
459  file.Close();
+
460 }
+
461 
+
462 void CombineHarvester::WriteDatacard(std::string const& name) {
+
463  TFile dummy;
+
464  CombineHarvester::WriteDatacard(name, dummy);
+
465  dummy.Close();
+
466 }
+
467 
+
468 void CombineHarvester::FillHistMappings(std::vector<HistMapping> & mappings) {
+
469  // Build maps of
+
470  // RooAbsData --> RooWorkspace
+
471  // RooAbsPdf --> RooWorkspace
+
472  std::map<RooAbsData const*, RooWorkspace*> data_ws_map;
+
473  std::map<RooAbsReal const*, RooWorkspace*> pdf_ws_map;
+
474  for (auto const& iter : wspaces_) {
+
475  auto dat = iter.second->allData();
+
476  for (auto d : dat) {
+
477  data_ws_map[d] = iter.second.get();
+
478  }
+
479  RooArgSet vars = iter.second->allPdfs();
+
480  auto v = vars.createIterator();
+
481  do {
+
482  RooAbsReal *y = dynamic_cast<RooAbsReal*>(**v);
+
483  if (y) pdf_ws_map[iter.second->pdf(y->GetName())] = iter.second.get();
+
484  } while (v->Next());
+
485  RooArgSet fvars = iter.second->allFunctions();
+
486  auto fv = fvars.createIterator();
+
487  do {
+
488  RooAbsReal *y = dynamic_cast<RooAbsReal*>(**fv);
+
489  if (y) pdf_ws_map[iter.second->function(y->GetName())] = iter.second.get();
+
490  } while (fv->Next());
+
491  }
+
492 
+
493  // For writing TH1s we will hard code a set of patterns for each bin
+
494  // This assumes that the backgrounds will not depend on "mass" but the
+
495  // signal will. Will probably want to change this in the future
+
496  std::set<std::string> hist_bins;
+
497  auto bins = this->bin_set();
+
498  for (auto bin : bins) {
+
499  unsigned shape_count = std::count_if(procs_.begin(), procs_.end(),
+
500  [&](std::shared_ptr<ch::Process> p) {
+
501  return (p->bin() == bin && p->shape() && (!p->signal()));
+
502  });
+
503  shape_count += std::count_if(obs_.begin(), obs_.end(),
+
504  [&](std::shared_ptr<ch::Observation> p) {
+
505  return (p->bin() == bin && p->shape());
+
506  });
+
507  unsigned counting = std::count_if(
+
508  procs_.begin(), procs_.end(), [&](std::shared_ptr<ch::Process> p) {
+
509  return (p->bin() == bin && p->shape() == nullptr &&
+
510  p->pdf() == nullptr && p->data() == nullptr);
+
511  });
+
512  counting += std::count_if(
+
513  obs_.begin(), obs_.end(), [&](std::shared_ptr<ch::Observation> p) {
+
514  return (p->bin() == bin && p->shape() == nullptr &&
+
515  p->data() == nullptr);
+
516  });
+
517 
+
518  if (shape_count > 0) {
+
519  mappings.emplace_back("*", bin, bin + "/$PROCESS",
+
520  bin + "/$PROCESS_$SYSTEMATIC");
+
521  hist_bins.insert(bin);
+
522  } else if (counting > 0) {
+
523  mappings.emplace_back("*", bin, "", "");
+
524  mappings.back().is_fake = true;
+
525  }
+
526 
+
527  CombineHarvester ch_signals =
+
528  std::move(this->cp().bin({bin}).signals().histograms());
+
529  auto sig_proc_set =
+
530  ch_signals.SetFromProcs(std::mem_fn(&ch::Process::process));
+
531  for (auto sig_proc : sig_proc_set) {
+
532  // should only add this mapping if the signal process has a numeric mass
+
533  // value, otherwise we will write it using the background rule above
+
534  auto masses = Set2Vec(ch_signals.cp()
+
535  .process({sig_proc})
+
536  .SetFromProcs(std::mem_fn(&ch::Process::mass)));
+
537  if (masses.size() != 1) {
+
538  throw std::runtime_error(FNERROR("Process " + sig_proc + " in bin " +
+
539  bin +
+
540  " has multiple entries with multiple "
+
541  "mass values, this is not supported"));
+
542 
+
543  }
+
544  if (is_float(masses[0])) {
+
545  mappings.emplace_back(sig_proc, bin, bin + "/" + sig_proc + "$MASS",
+
546  bin + "/" + sig_proc + "$MASS_$SYSTEMATIC");
+
547  }
+
548  }
+
549  }
+
550 
+
551  // Generate mappings for RooFit objects
+
552  for (auto bin : bins) {
+
553  CombineHarvester ch_bin = std::move(this->cp().bin({bin}));
+
554  for (auto obs : ch_bin.obs_) {
+
555  if (!obs->data()) continue;
+
556  std::string obj_name = std::string(data_ws_map[obs->data()]->GetName()) +
+
557  ":" + std::string(obs->data()->GetName());
+
558  mappings.emplace_back("data_obs", obs->bin(), obj_name, "");
+
559  }
+
560 
+
561  bool prototype_ok = false;
+
562  HistMapping prototype;
+
563  std::vector<HistMapping> full_list;
+
564  auto pmap = ch_bin.GenerateProcSystMap();
+
565  for (unsigned i = 0; i < ch_bin.procs_.size(); ++i) {
+
566  ch::Process * proc = ch_bin.procs_[i].get();
+
567  if (!proc->data() && !proc->pdf()) continue;
+
568  std::string obj_name;
+
569  std::string obj_sys_name;
+
570  if (proc->data()) {
+
571  obj_name = std::string(data_ws_map[proc->data()]->GetName()) + ":" +
+
572  std::string(proc->data()->GetName());
+
573  }
+
574  if (proc->pdf()) {
+
575  obj_name = std::string(pdf_ws_map[proc->pdf()]->GetName()) +
+
576  ":" + std::string(proc->pdf()->GetName());
+
577  }
+
578  for (unsigned j = 0; j < pmap[i].size(); ++j) {
+
579  ch::Systematic const* sys = pmap[i][j];
+
580  if (sys->data_u()) {
+
581  obj_sys_name = std::string(data_ws_map[sys->data_u()]->GetName()) +
+
582  ":" + std::string(sys->data_u()->GetName());
+
583  boost::replace_all(obj_sys_name, sys->name() + "Up", "$SYSTEMATIC");
+
584  boost::replace_all(obj_sys_name, sys->process(), "$PROCESS");
+
585  break;
+
586  }
587  }
-
588 
-
589  if (prototype.syst_pattern.size() && obj_sys_name.size() &&
-
590  prototype.syst_pattern != obj_sys_name) {
-
591  prototype_ok = false;
-
592  }
-
593 
-
594  if (!prototype.pattern.size()) {
-
595  prototype_ok = true;
-
596  prototype.process = "*";
-
597  prototype.category = bin;
-
598  prototype.pattern = obj_name;
+
588  boost::replace_all(obj_name, proc->process(), "$PROCESS");
+
589 
+
590  // If the prototype pattern is already filled, but doesn't equal this
+
591  // new pattern - then we can't use the prototype
+
592  if (prototype.pattern.size() && prototype.pattern != obj_name) {
+
593  prototype_ok = false;
+
594  }
+
595 
+
596  if (prototype.syst_pattern.size() && obj_sys_name.size() &&
+
597  prototype.syst_pattern != obj_sys_name) {
+
598  prototype_ok = false;
599  }
-
600  if (!prototype.syst_pattern.size()) {
-
601  prototype.syst_pattern = obj_sys_name;
-
602  }
-
603 
-
604  full_list.emplace_back(proc->process(), proc->bin(), obj_name,
-
605  obj_sys_name);
-
606  }
-
607  // There are two reasons we won't want to write a generic mapping
-
608  // for the processes in this bin:
-
609  // 1) One or more processes is not described by the prototype mapping
-
610  // 2) We also have a generic histogram mapping for this bin
-
611  if (!prototype_ok || hist_bins.count(bin)) {
-
612  for (auto m : full_list) {
-
613  mappings.push_back(m);
-
614  }
-
615  } else {
-
616  mappings.push_back(prototype);
-
617  }
-
618  }
-
619 }
-
620 
-
621 
-
622 void CombineHarvester::WriteDatacard(std::string const& name,
-
623  TFile& root_file) {
-
624  using boost::format;
-
625 
-
626  // First figure out if this is a counting-experiment only
-
627  bool is_counting = true;
-
628  this->ForEachObs([&](ch::Observation *obs) {
-
629  if (obs->shape() != nullptr || obs->data() != nullptr) {
-
630  is_counting = false;
-
631  }
-
632  });
-
633  if (is_counting) {
-
634  this->ForEachProc([&](ch::Process *proc) {
-
635  if (proc->shape() != nullptr || proc->data() != nullptr ||
-
636  proc->pdf() != nullptr) {
-
637  is_counting = false;
-
638  }
-
639  });
-
640  }
-
641 
-
642  // Allow a non-open ROOT file if this is purely a counting experiment
-
643  if (!root_file.IsOpen() && !is_counting) {
-
644  throw std::runtime_error(FNERROR(
-
645  std::string("Output ROOT file is not open: ") + root_file.GetName()));
-
646  }
-
647  std::ofstream txt_file;
-
648  txt_file.open(name);
-
649  if (!txt_file.is_open()) {
-
650  throw std::runtime_error(FNERROR("Unable to create file: " + name));
-
651  }
-
652 
-
653  txt_file << "# Datacard produced by CombineHarvester with git status: "
-
654  << ch::GitVersion() << "\n";
-
655 
-
656  std::string dashes(80, '-');
-
657 
-
658  auto bin_set = this->SetFromProcs(std::mem_fn(&ch::Process::bin));
-
659  auto proc_set = this->SetFromProcs(std::mem_fn(&ch::Process::process));
-
660  std::set<std::string> sys_set;
-
661  std::set<std::string> rateparam_set;
-
662  this->ForEachSyst([&](ch::Systematic const* sys) {
-
663  if (sys->type() == "rateParam") {
-
664  rateparam_set.insert(sys->name());
-
665  } else {
-
666  sys_set.insert(sys->name());
-
667  }
-
668  });
-
669  txt_file << "imax " << bin_set.size()
-
670  << " number of bins\n";
-
671  txt_file << "jmax " << proc_set.size() - 1
-
672  << " number of processes minus 1\n";
-
673  txt_file << "kmax " << "*" << " number of nuisance parameters\n";
-
674  txt_file << dashes << "\n";
-
675 
-
676 
-
677  std::vector<HistMapping> mappings;
-
678  FillHistMappings(mappings);
-
679 
-
680  auto bins = this->SetFromObs(std::mem_fn(&ch::Observation::bin));
-
681 
-
682  auto proc_sys_map = this->GenerateProcSystMap();
+
600 
+
601  if (!prototype.pattern.size()) {
+
602  prototype_ok = true;
+
603  prototype.process = "*";
+
604  prototype.category = bin;
+
605  prototype.pattern = obj_name;
+
606  }
+
607  if (!prototype.syst_pattern.size()) {
+
608  prototype.syst_pattern = obj_sys_name;
+
609  }
+
610 
+
611  full_list.emplace_back(proc->process(), proc->bin(), obj_name,
+
612  obj_sys_name);
+
613  }
+
614  // There are two reasons we won't want to write a generic mapping
+
615  // for the processes in this bin:
+
616  // 1) One or more processes is not described by the prototype mapping
+
617  // 2) We also have a generic histogram mapping for this bin
+
618  if (!prototype_ok || hist_bins.count(bin)) {
+
619  for (auto m : full_list) {
+
620  mappings.push_back(m);
+
621  }
+
622  } else {
+
623  mappings.push_back(prototype);
+
624  }
+
625  }
+
626 }
+
627 
+
628 
+
629 void CombineHarvester::WriteDatacard(std::string const& name,
+
630  TFile& root_file) {
+
631  using boost::format;
+
632 
+
633  // First figure out if this is a counting-experiment only
+
634  bool is_counting = true;
+
635  this->ForEachObs([&](ch::Observation *obs) {
+
636  if (obs->shape() != nullptr || obs->data() != nullptr) {
+
637  is_counting = false;
+
638  }
+
639  });
+
640  if (is_counting) {
+
641  this->ForEachProc([&](ch::Process *proc) {
+
642  if (proc->shape() != nullptr || proc->data() != nullptr ||
+
643  proc->pdf() != nullptr) {
+
644  is_counting = false;
+
645  }
+
646  });
+
647  }
+
648 
+
649  // Allow a non-open ROOT file if this is purely a counting experiment
+
650  if (!root_file.IsOpen() && !is_counting) {
+
651  throw std::runtime_error(FNERROR(
+
652  std::string("Output ROOT file is not open: ") + root_file.GetName()));
+
653  }
+
654  std::ofstream txt_file;
+
655  txt_file.open(name);
+
656  if (!txt_file.is_open()) {
+
657  throw std::runtime_error(FNERROR("Unable to create file: " + name));
+
658  }
+
659 
+
660  txt_file << "# Datacard produced by CombineHarvester with git status: "
+
661  << ch::GitVersion() << "\n";
+
662 
+
663  std::string dashes(80, '-');
+
664 
+
665  auto bin_set = this->SetFromProcs(std::mem_fn(&ch::Process::bin));
+
666  auto proc_set = this->SetFromProcs(std::mem_fn(&ch::Process::process));
+
667  std::set<std::string> sys_set;
+
668  std::set<std::string> rateparam_set;
+
669  this->ForEachSyst([&](ch::Systematic const* sys) {
+
670  if (sys->type() == "rateParam") {
+
671  rateparam_set.insert(sys->name());
+
672  } else {
+
673  sys_set.insert(sys->name());
+
674  }
+
675  });
+
676  txt_file << "imax " << bin_set.size()
+
677  << " number of bins\n";
+
678  txt_file << "jmax " << proc_set.size() - 1
+
679  << " number of processes minus 1\n";
+
680  txt_file << "kmax " << "*" << " number of nuisance parameters\n";
+
681  txt_file << dashes << "\n";
+
682 
683 
-
684  std::set<std::string> all_dependents_pars;
-
685  std::set<std::string> multipdf_cats;
-
686  for (auto proc : procs_) {
-
687  if (!proc->pdf()) continue;
-
688  // The rest of this is building the list of dependents
-
692  RooAbsData const* data_obj = FindMatchingData(proc.get());
-
693  RooArgSet par_list;
-
694  RooArgSet norm_par_list;
-
695 
-
696  if (data_obj) {
-
697  par_list.add(ParametersByName(proc->pdf(), data_obj->get()));
-
698  if (proc->norm()) {
-
699  norm_par_list.add(ParametersByName(proc->norm(), data_obj->get()));
-
700  }
-
701  } else {
-
702  RooRealVar mx("CMS_th1x" , "CMS_th1x", 0, 1);
-
703  RooArgSet tmp_set(mx);
-
704  par_list.add(ParametersByName(proc->pdf(), &tmp_set));
+
684  std::vector<HistMapping> mappings;
+
685  FillHistMappings(mappings);
+
686 
+
687  auto bins = this->SetFromObs(std::mem_fn(&ch::Observation::bin));
+
688 
+
689  auto proc_sys_map = this->GenerateProcSystMap();
+
690 
+
691  std::set<std::string> all_dependents_pars;
+
692  std::set<std::string> multipdf_cats;
+
693  for (auto proc : procs_) {
+
694  if (!proc->pdf()) continue;
+
695  // The rest of this is building the list of dependents
+
699  RooAbsData const* data_obj = FindMatchingData(proc.get());
+
700  RooArgSet par_list;
+
701  RooArgSet norm_par_list;
+
702 
+
703  if (data_obj) {
+
704  par_list.add(ParametersByName(proc->pdf(), data_obj->get()));
705  if (proc->norm()) {
-
706  norm_par_list.add(ParametersByName(proc->norm(), &tmp_set));
+
706  norm_par_list.add(ParametersByName(proc->norm(), data_obj->get()));
707  }
-
708  }
-
709  RooFIter par_list_it = par_list.fwdIterator();
-
710  RooAbsArg *par_list_var = nullptr;
-
711  while ((par_list_var = par_list_it.next())) {
-
712  if (dynamic_cast<RooRealVar*>(par_list_var)) {
-
713  all_dependents_pars.insert(par_list_var->GetName());
+
708  } else {
+
709  RooRealVar mx("CMS_th1x" , "CMS_th1x", 0, 1);
+
710  RooArgSet tmp_set(mx);
+
711  par_list.add(ParametersByName(proc->pdf(), &tmp_set));
+
712  if (proc->norm()) {
+
713  norm_par_list.add(ParametersByName(proc->norm(), &tmp_set));
714  }
-
715  // If this pdf has a RooCategory parameter then it's probably a
-
716  // RooMultiPdf. We'll need to write a special line in the datacard to
-
717  // indicate that this is a discrete pdf index. However it's best to be
-
718  // sure, so we'll use ROOT's string-based RTTI to check the type without
-
719  // having to link against HiggsAnalysis/CombinedLimit
-
720  if (dynamic_cast<RooCategory*>(par_list_var) &&
-
721  proc->pdf()->InheritsFrom("RooMultiPdf")) {
-
722  multipdf_cats.insert(par_list_var->GetName());
-
723  }
-
724  }
-
725  if (proc->norm()) {
-
726  RooFIter nm_list_it = norm_par_list.fwdIterator();
-
727  RooAbsArg *nm_list_var = nullptr;
-
728  while ((nm_list_var = nm_list_it.next())) {
-
729  if (dynamic_cast<RooRealVar*>(nm_list_var)) {
-
730  all_dependents_pars.insert(nm_list_var->GetName());
-
731  }
-
732  }
-
733  }
-
734  }
-
735 
-
736  // The ROOT file mapping should be given as a relative path
-
737  std::string file_name = root_file.GetName();
-
738  // Get the full path to the output root file
-
739  // NOTE: was using canonical here instead of absolute, but not
-
740  // supported in boost 1.47
-
741  boost::filesystem::path root_file_path =
-
742  boost::filesystem::absolute(file_name);
-
743  // Get the full path to the directory containing the txt file
-
744  boost::filesystem::path txt_file_path =
-
745  boost::filesystem::absolute(name).parent_path();
-
746  // Compute the relative path from the txt file to the root file
-
747  file_name = make_relative(txt_file_path, root_file_path).string();
-
748 
-
749  // Keep track of the workspaces we actually need to write into the
-
750  // output file
-
751  std::set<std::string> used_wsps;
-
752 
-
753  for (auto const& mapping : mappings) {
-
754  if (!mapping.is_fake) {
-
755  txt_file << format("shapes %s %s %s %s %s\n")
-
756  % mapping.process
-
757  % mapping.category
-
758  % file_name
-
759  % mapping.pattern
-
760  % mapping.syst_pattern;
-
761  if (mapping.IsPdf() || mapping.IsData()) {
-
762  used_wsps.insert(mapping.WorkspaceName());
-
763  }
-
764  } else {
-
765  txt_file << format("shapes %s %s %s\n")
-
766  % mapping.process
-
767  % mapping.category
-
768  % "FAKE";
-
769  }
-
770  }
-
771  txt_file << dashes << "\n";
-
772 
-
773  if (!is_counting) {
-
774  for (auto ws_it : wspaces_) {
-
775  if (ws_it.first == "_rateParams") continue; // don't write this one
-
776  // Also skip any workspace that isn't needed for this card
-
777  if (!used_wsps.count(ws_it.second->GetName())) continue;
-
778  ch::WriteToTFile(ws_it.second.get(), &root_file, ws_it.second->GetName());
-
779  }
-
780  }
-
781 
-
782  // Writing observations
-
783  if (obs_.size() > 0) {
-
784  txt_file << "bin ";
-
785  for (auto const& obs : obs_) {
-
786  txt_file << format("%-15s ") % obs->bin();
-
787  if (obs->shape()) {
-
788  bool add_dir = TH1::AddDirectoryStatus();
-
789  TH1::AddDirectory(false);
-
790  std::unique_ptr<TH1> h((TH1*)(obs->shape()->Clone()));
-
791  h->Scale(obs->rate());
-
792  WriteHistToFile(h.get(), &root_file, mappings, obs->bin(), "data_obs",
-
793  obs->mass(), "", 0);
-
794  TH1::AddDirectory(add_dir);
-
795  }
-
796  }
-
797  txt_file << "\n";
-
798  txt_file << "observation ";
-
799  // On the precision of the observation yields: .1f is not sufficient for
-
800  // combine to be happy if we have some asimov dataset with non-integer values.
-
801  // We could just always give .4f but this doesn't look nice for the majority
-
802  // of cards that have real data. Instead we'll check...
-
803  std::string obs_fmt_int = "%-15.1f ";
-
804  std::string obs_fmt_flt = "%-15.4f ";
-
805  for (auto const& obs : obs_) {
-
806  bool is_float =
-
807  std::fabs(obs->rate() - std::round(obs->rate())) > 1E-4;
-
808  txt_file << format(is_float ? obs_fmt_flt : obs_fmt_int)
-
809  % obs->rate();
-
810  }
-
811  txt_file << "\n";
-
812  txt_file << dashes << "\n";
-
813  }
-
814 
-
815  unsigned sys_str_len = 14;
-
816  for (auto const& sys : sys_set) {
-
817  if (sys.length() > sys_str_len) sys_str_len = sys.length();
-
818  }
-
819  for (auto const& sys : all_dependents_pars) {
-
820  if (sys.length() > sys_str_len) sys_str_len = sys.length();
-
821  }
-
822  std::string sys_str_short = boost::lexical_cast<std::string>(sys_str_len);
-
823  std::string sys_str_long = boost::lexical_cast<std::string>(sys_str_len+9);
-
824 
-
825  txt_file << format("%-"+sys_str_long+"s") % "bin";
-
826  for (auto const& proc : procs_) {
-
827  if (proc->shape()) {
-
828  bool add_dir = TH1::AddDirectoryStatus();
-
829  TH1::AddDirectory(false);
-
830  std::unique_ptr<TH1> h = proc->ClonedScaledShape();
-
831  WriteHistToFile(h.get(), &root_file, mappings, proc->bin(),
-
832  proc->process(), proc->mass(), "", 0);
-
833  TH1::AddDirectory(add_dir);
-
834  }
-
835  txt_file << format("%-15s ") % proc->bin();
-
836  }
-
837  txt_file << "\n";
-
838 
-
839  txt_file << format("%-"+sys_str_long+"s") % "process";
-
840 
-
841  for (auto const& proc : procs_) {
-
842  txt_file << format("%-15s ") % proc->process();
+
715  }
+
716  RooFIter par_list_it = par_list.fwdIterator();
+
717  RooAbsArg *par_list_var = nullptr;
+
718  while ((par_list_var = par_list_it.next())) {
+
719  if (dynamic_cast<RooRealVar*>(par_list_var)) {
+
720  all_dependents_pars.insert(par_list_var->GetName());
+
721  }
+
722  // If this pdf has a RooCategory parameter then it's probably a
+
723  // RooMultiPdf. We'll need to write a special line in the datacard to
+
724  // indicate that this is a discrete pdf index. However it's best to be
+
725  // sure, so we'll use ROOT's string-based RTTI to check the type without
+
726  // having to link against HiggsAnalysis/CombinedLimit
+
727  if (dynamic_cast<RooCategory*>(par_list_var) &&
+
728  proc->pdf()->InheritsFrom("RooMultiPdf")) {
+
729  multipdf_cats.insert(par_list_var->GetName());
+
730  }
+
731  }
+
732  if (proc->norm()) {
+
733  RooFIter nm_list_it = norm_par_list.fwdIterator();
+
734  RooAbsArg *nm_list_var = nullptr;
+
735  while ((nm_list_var = nm_list_it.next())) {
+
736  if (dynamic_cast<RooRealVar*>(nm_list_var)) {
+
737  all_dependents_pars.insert(nm_list_var->GetName());
+
738  }
+
739  }
+
740  }
+
741  }
+
742 
+
743  // The ROOT file mapping should be given as a relative path
+
744  std::string file_name = root_file.GetName();
+
745  // Get the full path to the output root file
+
746  // NOTE: was using canonical here instead of absolute, but not
+
747  // supported in boost 1.47
+
748  boost::filesystem::path root_file_path =
+
749  boost::filesystem::absolute(file_name);
+
750  // Get the full path to the directory containing the txt file
+
751  boost::filesystem::path txt_file_path =
+
752  boost::filesystem::absolute(name).parent_path();
+
753  // Compute the relative path from the txt file to the root file
+
754  file_name = make_relative(txt_file_path, root_file_path).string();
+
755 
+
756  // Keep track of the workspaces we actually need to write into the
+
757  // output file
+
758  std::set<std::string> used_wsps;
+
759 
+
760  for (auto const& mapping : mappings) {
+
761  if (!mapping.is_fake) {
+
762  txt_file << format("shapes %s %s %s %s %s\n")
+
763  % mapping.process
+
764  % mapping.category
+
765  % file_name
+
766  % mapping.pattern
+
767  % mapping.syst_pattern;
+
768  if (mapping.IsPdf() || mapping.IsData()) {
+
769  used_wsps.insert(mapping.WorkspaceName());
+
770  }
+
771  } else {
+
772  txt_file << format("shapes %s %s %s\n")
+
773  % mapping.process
+
774  % mapping.category
+
775  % "FAKE";
+
776  }
+
777  }
+
778  txt_file << dashes << "\n";
+
779 
+
780  if (!is_counting) {
+
781  for (auto ws_it : wspaces_) {
+
782  if (ws_it.first == "_rateParams") continue; // don't write this one
+
783  // Also skip any workspace that isn't needed for this card
+
784  if (!used_wsps.count(ws_it.second->GetName())) continue;
+
785  ch::WriteToTFile(ws_it.second.get(), &root_file, ws_it.second->GetName());
+
786  }
+
787  }
+
788 
+
789  // Writing observations
+
790  if (obs_.size() > 0) {
+
791  txt_file << "bin ";
+
792  for (auto const& obs : obs_) {
+
793  txt_file << format("%-15s ") % obs->bin();
+
794  if (obs->shape()) {
+
795  bool add_dir = TH1::AddDirectoryStatus();
+
796  TH1::AddDirectory(false);
+
797  std::unique_ptr<TH1> h((TH1*)(obs->shape()->Clone()));
+
798  h->Scale(obs->rate());
+
799  WriteHistToFile(h.get(), &root_file, mappings, obs->bin(), "data_obs",
+
800  obs->mass(), "", 0);
+
801  TH1::AddDirectory(add_dir);
+
802  }
+
803  }
+
804  txt_file << "\n";
+
805  txt_file << "observation ";
+
806  // On the precision of the observation yields: .1f is not sufficient for
+
807  // combine to be happy if we have some asimov dataset with non-integer values.
+
808  // We could just always give .4f but this doesn't look nice for the majority
+
809  // of cards that have real data. Instead we'll check...
+
810  std::string obs_fmt_int = "%-15.1f ";
+
811  std::string obs_fmt_flt = "%-15.4f ";
+
812  for (auto const& obs : obs_) {
+
813  bool is_float =
+
814  std::fabs(obs->rate() - std::round(obs->rate())) > 1E-4;
+
815  txt_file << format(is_float ? obs_fmt_flt : obs_fmt_int)
+
816  % obs->rate();
+
817  }
+
818  txt_file << "\n";
+
819  txt_file << dashes << "\n";
+
820  }
+
821 
+
822  unsigned sys_str_len = 14;
+
823  for (auto const& sys : sys_set) {
+
824  if (sys.length() > sys_str_len) sys_str_len = sys.length();
+
825  }
+
826  for (auto const& sys : all_dependents_pars) {
+
827  if (sys.length() > sys_str_len) sys_str_len = sys.length();
+
828  }
+
829  std::string sys_str_short = boost::lexical_cast<std::string>(sys_str_len);
+
830  std::string sys_str_long = boost::lexical_cast<std::string>(sys_str_len+9);
+
831 
+
832  txt_file << format("%-"+sys_str_long+"s") % "bin";
+
833  for (auto const& proc : procs_) {
+
834  if (proc->shape()) {
+
835  bool add_dir = TH1::AddDirectoryStatus();
+
836  TH1::AddDirectory(false);
+
837  std::unique_ptr<TH1> h = proc->ClonedScaledShape();
+
838  WriteHistToFile(h.get(), &root_file, mappings, proc->bin(),
+
839  proc->process(), proc->mass(), "", 0);
+
840  TH1::AddDirectory(add_dir);
+
841  }
+
842  txt_file << format("%-15s ") % proc->bin();
843  }
844  txt_file << "\n";
845 
846  txt_file << format("%-"+sys_str_long+"s") % "process";
847 
-
848  // Setup process_ids first
-
849  std::map<std::string, int> p_ids;
-
850  unsigned sig_id = 0;
-
851  unsigned bkg_id = 1;
-
852  for (unsigned p = 0; p < procs_.size(); ++p) {
-
853  if (!procs_[p]->signal()) {
-
854  if (p_ids.count(procs_[p]->process()) == 0) {
-
855  p_ids[procs_[p]->process()] = bkg_id;
-
856  ++bkg_id;
-
857  }
-
858  else {
-
859  // check if process was already picked up as signal
-
860  if (p_ids[procs_[p]->process()] <= 0) throw std::runtime_error(FNERROR("Ambiguous definition of process (" + procs_[p]->process() + ") as both signal and background"));
-
861  }
-
862  }
-
863  unsigned q = procs_.size() - (p + 1);
-
864  if (procs_[q]->signal()) {
-
865  if (p_ids.count(procs_[q]->process()) == 0) {
-
866  p_ids[procs_[q]->process()] = sig_id;
-
867  --sig_id;
+
848  for (auto const& proc : procs_) {
+
849  txt_file << format("%-15s ") % proc->process();
+
850  }
+
851  txt_file << "\n";
+
852 
+
853  txt_file << format("%-"+sys_str_long+"s") % "process";
+
854 
+
855  // Setup process_ids first
+
856  std::map<std::string, int> p_ids;
+
857  unsigned sig_id = 0;
+
858  unsigned bkg_id = 1;
+
859  for (unsigned p = 0; p < procs_.size(); ++p) {
+
860  if (!procs_[p]->signal()) {
+
861  if (p_ids.count(procs_[p]->process()) == 0) {
+
862  p_ids[procs_[p]->process()] = bkg_id;
+
863  ++bkg_id;
+
864  }
+
865  else {
+
866  // check if process was already picked up as signal
+
867  if (p_ids[procs_[p]->process()] <= 0) throw std::runtime_error(FNERROR("Ambiguous definition of process (" + procs_[p]->process() + ") as both signal and background"));
868  }
-
869  else {
-
870  // check if process was already picked up as background
-
871  if (p_ids[procs_[q]->process()] > 0) throw std::runtime_error(FNERROR("Ambiguous definition of process (" + procs_[q]->process() + ") as both signal and background"));
-
872  }
-
873  }
-
874  }
-
875  for (auto const& proc : procs_) {
-
876  txt_file << format("%-15s ") % p_ids[proc->process()];
-
877  }
-
878  txt_file << "\n";
-
879 
-
880 
-
881  txt_file << format("%-"+sys_str_long+"s") % "rate";
+
869  }
+
870  unsigned q = procs_.size() - (p + 1);
+
871  if (procs_[q]->signal()) {
+
872  if (p_ids.count(procs_[q]->process()) == 0) {
+
873  p_ids[procs_[q]->process()] = sig_id;
+
874  --sig_id;
+
875  }
+
876  else {
+
877  // check if process was already picked up as background
+
878  if (p_ids[procs_[q]->process()] > 0) throw std::runtime_error(FNERROR("Ambiguous definition of process (" + procs_[q]->process() + ") as both signal and background"));
+
879  }
+
880  }
+
881  }
882  for (auto const& proc : procs_) {
-
883  txt_file << format("%-15.6g ") % proc->no_norm_rate();
+
883  txt_file << format("%-15s ") % p_ids[proc->process()];
884  }
885  txt_file << "\n";
-
886  txt_file << dashes << "\n";
+
886 
887 
-
888  // Need to write parameters here that feature both in the list of pdf
-
889  // dependents and sys_set.
-
890  for (auto par : params_) {
-
891  Parameter const* p = par.second.get();
-
892  if (p->err_d() != 0.0 && p->err_u() != 0.0 &&
-
893  all_dependents_pars.count(p->name()) && sys_set.count(p->name())) {
-
894  txt_file << format((format("%%-%is param %%g %%g") % sys_str_len).str()) %
-
895  p->name() % p->val() % ((p->err_u() - p->err_d()) / 2.0);
-
896  if (p->range_d() != std::numeric_limits<double>::lowest() &&
-
897  p->range_u() != std::numeric_limits<double>::max()) {
-
898  txt_file << format(" [%.4g,%.4g]") % p->range_d() % p->range_u();
-
899  }
-
900  txt_file << "\n";
-
901  }
-
902  }
-
903 
-
904  for (auto const& sys : sys_set) {
-
905  std::vector<std::string> line(procs_.size() + 2);
-
906  line[0] = sys;
-
907  bool seen_lnN = false;
-
908  bool seen_lnU = false;
-
909  bool seen_shape = false;
-
910  bool seen_shapeN2 = false;
-
911  bool seen_shapeU = false;
-
912  for (unsigned p = 0; p < procs_.size(); ++p) {
-
913  line[p + 2] = "-";
-
914  for (unsigned n = 0; n < proc_sys_map[p].size(); ++n) {
-
915  ch::Systematic const* ptr = proc_sys_map[p][n];
-
916  // Only interested into Systematics with name "sys"
-
917  if (ptr->name() != sys) continue;
-
918  std::string tp = ptr->type();
-
919  if (tp == "lnN" || tp == "lnU") {
-
920  if (tp == "lnN") seen_lnN = true;
-
921  if (tp == "lnU") seen_lnU = true;
-
922  line[p + 2] =
-
923  ptr->asymm()
-
924  ? (format("%g/%g") % ptr->value_d() % ptr->value_u()).str()
-
925  : (format("%g") % ptr->value_u()).str();
-
926  break;
-
927  }
-
928  if (tp == "shape" || tp == "shapeN2" || tp == "shapeU") {
-
929  if (tp == "shape") seen_shape = true;
-
930  if (tp == "shapeN2") seen_shapeN2 = true;
-
931  if (tp == "shapeU") seen_shapeU = true;
-
932  line[p + 2] = (format("%g") % ptr->scale()).str();
-
933  if (ptr->shape_u() && ptr->shape_d()) {
-
934  bool add_dir = TH1::AddDirectoryStatus();
-
935  TH1::AddDirectory(false);
-
936  std::unique_ptr<TH1> h_d = ptr->ClonedShapeD();
-
937  h_d->Scale(procs_[p]->rate() * ptr->value_d());
-
938  WriteHistToFile(h_d.get(), &root_file, mappings, ptr->bin(),
-
939  ptr->process(), ptr->mass(), ptr->name(), 1);
-
940  std::unique_ptr<TH1> h_u = ptr->ClonedShapeU();
-
941  h_u->Scale(procs_[p]->rate() * ptr->value_u());
-
942  WriteHistToFile(h_u.get(), &root_file, mappings, ptr->bin(),
-
943  ptr->process(), ptr->mass(), ptr->name(), 2);
-
944  TH1::AddDirectory(add_dir);
-
945  break;
-
946  } else if (ptr->data_u() && ptr->data_d()) {
-
947  } else {
-
948  if (!flags_.at("allow-missing-shapes")) {
-
949  std::stringstream err;
-
950  err << "Trying to write shape uncertainty with missing "
-
951  "shapes:\n";
-
952  err << Systematic::PrintHeader << *ptr;
-
953  throw std::runtime_error(FNERROR(err.str()));
-
954  }
-
955  }
-
956  }
-
957  }
-
958  }
-
959  if (seen_shapeN2) {
-
960  line[1] = "shapeN2";
-
961  } else if (seen_shapeU) {
-
962  line[1] = "shapeU";
-
963  } else if (seen_lnU) {
-
964  line[1] = "lnU";
-
965  } else if (seen_lnN && !seen_shape) {
-
966  line[1] = "lnN";
-
967  } else if (!seen_lnN && seen_shape) {
-
968  line[1] = "shape";
-
969  } else if (seen_lnN && seen_shape) {
-
970  line[1] = "shape?";
-
971  } else {
-
972  throw std::runtime_error(FNERROR("Systematic type could not be deduced"));
-
973  }
-
974  txt_file << format("%-" + sys_str_short + "s %-7s ") % line[0] % line[1];
-
975  for (unsigned p = 0; p < procs_.size(); ++p) {
-
976  txt_file << format("%-15s ") % line[p + 2];
-
977  }
-
978  txt_file << "\n";
-
979  }
-
980  // write param line for any parameter which has a non-zero error
-
981  // and which doesn't appear in list of nuisances
-
982  CombineHarvester ch_rp = this->cp().syst_type({"rateParam"});
-
983  // These are all the processes with a rateParam. We'll look at each one and
-
984  // see if every bin with this process also has this rateParam.
-
985  std::vector<std::vector<std::string> > floating_params;
-
986  for (auto const& sys : rateparam_set) {
-
987  FNLOGC(log(), verbosity_ > 1) << "Doing rateParam: " << sys << "\n";
-
988  auto procs_rp = ch_rp.cp().syst_name({sys}).SetFromSysts(
-
989  std::mem_fn(&ch::Systematic::process));
-
990  FNLOGC(log(), verbosity_ > 1) << "Procs for this rateParam: \n";
-
991  for (auto const& proc : procs_rp) {
-
992  FNLOGC(log(), verbosity_ > 1) << " - " << proc << "\n";
-
993  // Get the set of bins
-
994  auto bins_rp = ch_rp.cp().process({proc}).syst_name({sys}).SetFromSysts(
-
995  std::mem_fn(&ch::Systematic::bin));
-
996  auto bins_all = this->cp().process({proc}).bin_set();
-
997  if (bins_rp.size() > 0 && bins_rp.size() == bins_all.size()) {
-
998  floating_params.push_back({sys, "*", proc});
-
999  } else {
-
1000  for (auto const& bin : bins_rp) {
-
1001  floating_params.push_back({sys, bin, proc});
-
1002  }
-
1003  }
-
1004  FNLOGC(log(), verbosity_ > 1)
-
1005  << bins_rp.size() << "/" << bins_all.size()
-
1006  << " bins with this process have a rateParam\n";
-
1007  }
-
1008  }
-
1009  for (auto const& rp : floating_params) {
-
1010  if (params_.count(rp[0])) {
-
1011  ch::Parameter const* par = params_.at(rp[0]).get();
-
1012  txt_file << format("%-" + sys_str_short + "s %-10s %-10s %-10s %g") %
-
1013  rp[0] % "rateParam" % rp[1] % rp[2] % par->val();
-
1014  // Check if we have to set the range too
-
1015  // TODO: should package this into some function in ch::Parameter
-
1016  if (par->range_d() != std::numeric_limits<double>::lowest() &&
-
1017  par->range_u() != std::numeric_limits<double>::max()) {
-
1018  txt_file << format(" [%.4g,%.4g]") % par->range_d() % par->range_u();
-
1019  }
-
1020  txt_file << "\n";
-
1021  }
-
1022  }
-
1023  for (auto const& rp : floating_params) {
-
1024  if (!params_.count(rp[0])) {
-
1025  // If we don't have a ch::Parameter with this name, then we'll assume
-
1026  // this is a function
-
1027  RooWorkspace *rp_ws = wspaces_.at("_rateParams").get();
-
1028  RooFormulaVar* form =
-
1029  dynamic_cast<RooFormulaVar*>(rp_ws->function(rp[0].c_str()));
-
1030  // Want to extract the formula string, apparently "printMetaArgs" is the
-
1031  // only way to do it
-
1032  std::stringstream ss;
-
1033  form->printMetaArgs(ss);
-
1034  std::string form_str = ss.str();
-
1035  // The string will be like 'formula="blah"', strip everything on either
-
1036  // side of the double quotes (including the quotes themselves)
-
1037  std::size_t first = form_str.find_first_of('"');
-
1038  std::size_t last = form_str.find_last_of('"');
-
1039  form_str = form_str.substr(first + 1, last - first - 1);
-
1040  // unique_ptr because we own the RooArgSet that is generated
-
1041  unsigned npars =
-
1042  std::unique_ptr<RooArgSet>(form->getParameters(RooArgList()))->getSize();
-
1043  std::string args = "";
-
1044  for (unsigned i = 0; i < npars; ++i) {
-
1045  args += std::string(form->getParameter(i)->GetName());
-
1046  if (i < (npars-1)) {
-
1047  args += ",";
-
1048  }
-
1049  }
-
1050  txt_file << format("%-" + sys_str_short +
-
1051  "s %-10s %-10s %-10s %-20s %s\n") %
-
1052  rp[0] % "rateParam" % rp[1] % rp[2] % form_str % args;
-
1053  }
-
1054  }
-
1055 
-
1056  std::set<std::string> ws_vars;
-
1057  for (auto iter : wspaces_) {
-
1058  RooArgSet vars = iter.second->allVars();
-
1059  auto v = vars.createIterator();
-
1060  do {
-
1061  RooRealVar *y = dynamic_cast<RooRealVar*>(**v);
-
1062  if (y) {
-
1063  ws_vars.insert(y->GetName());
-
1064  }
-
1065  } while (v->Next());
-
1066  }
-
1067 
-
1068  // How to check for params we need to write:
-
1069  // Get a list of all pdf dependents for the processes we've just written
-
1070  // Also need a list of all Systematic entries we've just written
-
1071  // Then we write param if:
-
1072  // - it has non-zero errors
-
1073  // - it appears in the first list
-
1074  // - it doesn't appear in the second list
-
1075  for (auto par : params_) {
-
1076  Parameter const* p = par.second.get();
-
1077  if (p->err_d() != 0.0 && p->err_u() != 0.0 &&
-
1078  all_dependents_pars.count(p->name()) && !sys_set.count(p->name())) {
-
1079  txt_file << format((format("%%-%is param %%g %%g") % sys_str_len).str()) %
-
1080  p->name() % p->val() % ((p->err_u() - p->err_d()) / 2.0);
-
1081  if (p->range_d() != std::numeric_limits<double>::lowest() &&
-
1082  p->range_u() != std::numeric_limits<double>::max()) {
-
1083  txt_file << format(" [%.4g,%.4g]") % p->range_d() % p->range_u();
-
1084  }
-
1085  txt_file << "\n";
-
1086  }
-
1087  }
-
1088 
-
1089  for (auto par : multipdf_cats) {
-
1090  txt_file << format((format("%%-%is discrete\n") % sys_str_len).str()) % par;
-
1091  }
-
1092 
-
1093  // Finally write the NP groups
-
1094  // We should only consider parameters are either:
-
1095  // - in the list of pdf dependents
-
1096  // - in the list of systematics
-
1097  std::map<std::string, std::set<std::string>> groups;
-
1098  for (auto const& par : params_) {
-
1099  Parameter * p = par.second.get();
-
1100  if (!all_dependents_pars.count(p->name()) && !sys_set.count(p->name())) {
-
1101  continue;
-
1102  }
-
1103  if (p->err_d() == 0.0 && p->err_u() == 0.0) continue;
-
1104  for (auto const& str : p->groups()) {
-
1105  if (!groups.count(str)) {
-
1106  groups[str] = std::set<std::string>();
-
1107  }
-
1108  groups[str].insert(p->name());
+
888  txt_file << format("%-"+sys_str_long+"s") % "rate";
+
889  for (auto const& proc : procs_) {
+
890  txt_file << format("%-15.6g ") % proc->no_norm_rate();
+
891  }
+
892  txt_file << "\n";
+
893  txt_file << dashes << "\n";
+
894 
+
895  // Need to write parameters here that feature both in the list of pdf
+
896  // dependents and sys_set.
+
897  for (auto par : params_) {
+
898  Parameter const* p = par.second.get();
+
899  if (p->err_d() != 0.0 && p->err_u() != 0.0 &&
+
900  all_dependents_pars.count(p->name()) && sys_set.count(p->name())) {
+
901  txt_file << format((format("%%-%is param %%g %%g") % sys_str_len).str()) %
+
902  p->name() % p->val() % ((p->err_u() - p->err_d()) / 2.0);
+
903  if (p->range_d() != std::numeric_limits<double>::lowest() &&
+
904  p->range_u() != std::numeric_limits<double>::max()) {
+
905  txt_file << format(" [%.4g,%.4g]") % p->range_d() % p->range_u();
+
906  }
+
907  txt_file << "\n";
+
908  }
+
909  }
+
910 
+
911  for (auto const& sys : sys_set) {
+
912  std::vector<std::string> line(procs_.size() + 2);
+
913  line[0] = sys;
+
914  bool seen_lnN = false;
+
915  bool seen_lnU = false;
+
916  bool seen_shape = false;
+
917  bool seen_shapeN2 = false;
+
918  bool seen_shapeU = false;
+
919  for (unsigned p = 0; p < procs_.size(); ++p) {
+
920  line[p + 2] = "-";
+
921  for (unsigned n = 0; n < proc_sys_map[p].size(); ++n) {
+
922  ch::Systematic const* ptr = proc_sys_map[p][n];
+
923  // Only interested into Systematics with name "sys"
+
924  if (ptr->name() != sys) continue;
+
925  std::string tp = ptr->type();
+
926  if (tp == "lnN" || tp == "lnU") {
+
927  if (tp == "lnN") seen_lnN = true;
+
928  if (tp == "lnU") seen_lnU = true;
+
929  line[p + 2] =
+
930  ptr->asymm()
+
931  ? (format("%g/%g") % ptr->value_d() % ptr->value_u()).str()
+
932  : (format("%g") % ptr->value_u()).str();
+
933  break;
+
934  }
+
935  if (tp == "shape" || tp == "shapeN2" || tp == "shapeU") {
+
936  if (tp == "shape") seen_shape = true;
+
937  if (tp == "shapeN2") seen_shapeN2 = true;
+
938  if (tp == "shapeU") seen_shapeU = true;
+
939  line[p + 2] = (format("%g") % ptr->scale()).str();
+
940  if (ptr->shape_u() && ptr->shape_d()) {
+
941  bool add_dir = TH1::AddDirectoryStatus();
+
942  TH1::AddDirectory(false);
+
943  std::unique_ptr<TH1> h_d = ptr->ClonedShapeD();
+
944  h_d->Scale(procs_[p]->rate() * ptr->value_d());
+
945  WriteHistToFile(h_d.get(), &root_file, mappings, ptr->bin(),
+
946  ptr->process(), ptr->mass(), ptr->name(), 1);
+
947  std::unique_ptr<TH1> h_u = ptr->ClonedShapeU();
+
948  h_u->Scale(procs_[p]->rate() * ptr->value_u());
+
949  WriteHistToFile(h_u.get(), &root_file, mappings, ptr->bin(),
+
950  ptr->process(), ptr->mass(), ptr->name(), 2);
+
951  TH1::AddDirectory(add_dir);
+
952  break;
+
953  } else if (ptr->data_u() && ptr->data_d()) {
+
954  } else {
+
955  if (!flags_.at("allow-missing-shapes")) {
+
956  std::stringstream err;
+
957  err << "Trying to write shape uncertainty with missing "
+
958  "shapes:\n";
+
959  err << Systematic::PrintHeader << *ptr;
+
960  throw std::runtime_error(FNERROR(err.str()));
+
961  }
+
962  }
+
963  }
+
964  }
+
965  }
+
966  if (seen_shapeN2) {
+
967  line[1] = "shapeN2";
+
968  } else if (seen_shapeU) {
+
969  line[1] = "shapeU";
+
970  } else if (seen_lnU) {
+
971  line[1] = "lnU";
+
972  } else if (seen_lnN && !seen_shape) {
+
973  line[1] = "lnN";
+
974  } else if (!seen_lnN && seen_shape) {
+
975  line[1] = "shape";
+
976  } else if (seen_lnN && seen_shape) {
+
977  line[1] = "shape?";
+
978  } else {
+
979  throw std::runtime_error(FNERROR("Systematic type could not be deduced"));
+
980  }
+
981  txt_file << format("%-" + sys_str_short + "s %-7s ") % line[0] % line[1];
+
982  for (unsigned p = 0; p < procs_.size(); ++p) {
+
983  txt_file << format("%-15s ") % line[p + 2];
+
984  }
+
985  txt_file << "\n";
+
986  }
+
987  // write param line for any parameter which has a non-zero error
+
988  // and which doesn't appear in list of nuisances
+
989  CombineHarvester ch_rp = this->cp().syst_type({"rateParam"});
+
990  // These are all the processes with a rateParam. We'll look at each one and
+
991  // see if every bin with this process also has this rateParam.
+
992  std::vector<std::vector<std::string> > floating_params;
+
993  for (auto const& sys : rateparam_set) {
+
994  FNLOGC(log(), verbosity_ > 1) << "Doing rateParam: " << sys << "\n";
+
995  auto procs_rp = ch_rp.cp().syst_name({sys}).SetFromSysts(
+
996  std::mem_fn(&ch::Systematic::process));
+
997  FNLOGC(log(), verbosity_ > 1) << "Procs for this rateParam: \n";
+
998  for (auto const& proc : procs_rp) {
+
999  FNLOGC(log(), verbosity_ > 1) << " - " << proc << "\n";
+
1000  // Get the set of bins
+
1001  auto bins_rp = ch_rp.cp().process({proc}).syst_name({sys}).SetFromSysts(
+
1002  std::mem_fn(&ch::Systematic::bin));
+
1003  auto bins_all = this->cp().process({proc}).bin_set();
+
1004  if (bins_rp.size() > 0 && bins_rp.size() == bins_all.size()) {
+
1005  floating_params.push_back({sys, "*", proc});
+
1006  } else {
+
1007  for (auto const& bin : bins_rp) {
+
1008  floating_params.push_back({sys, bin, proc});
+
1009  }
+
1010  }
+
1011  FNLOGC(log(), verbosity_ > 1)
+
1012  << bins_rp.size() << "/" << bins_all.size()
+
1013  << " bins with this process have a rateParam\n";
+
1014  }
+
1015  }
+
1016  for (auto const& rp : floating_params) {
+
1017  if (params_.count(rp[0])) {
+
1018  ch::Parameter const* par = params_.at(rp[0]).get();
+
1019  txt_file << format("%-" + sys_str_short + "s %-10s %-10s %-10s %g") %
+
1020  rp[0] % "rateParam" % rp[1] % rp[2] % par->val();
+
1021  // Check if we have to set the range too
+
1022  // TODO: should package this into some function in ch::Parameter
+
1023  if (par->range_d() != std::numeric_limits<double>::lowest() &&
+
1024  par->range_u() != std::numeric_limits<double>::max()) {
+
1025  txt_file << format(" [%.4g,%.4g]") % par->range_d() % par->range_u();
+
1026  }
+
1027  txt_file << "\n";
+
1028  }
+
1029  }
+
1030  for (auto const& rp : floating_params) {
+
1031  if (!params_.count(rp[0])) {
+
1032  // If we don't have a ch::Parameter with this name, then we'll assume
+
1033  // this is a function
+
1034  RooWorkspace *rp_ws = wspaces_.at("_rateParams").get();
+
1035  RooFormulaVar* form =
+
1036  dynamic_cast<RooFormulaVar*>(rp_ws->function(rp[0].c_str()));
+
1037  // Want to extract the formula string, apparently "printMetaArgs" is the
+
1038  // only way to do it
+
1039  std::stringstream ss;
+
1040  form->printMetaArgs(ss);
+
1041  std::string form_str = ss.str();
+
1042  // The string will be like 'formula="blah"', strip everything on either
+
1043  // side of the double quotes (including the quotes themselves)
+
1044  std::size_t first = form_str.find_first_of('"');
+
1045  std::size_t last = form_str.find_last_of('"');
+
1046  form_str = form_str.substr(first + 1, last - first - 1);
+
1047  // unique_ptr because we own the RooArgSet that is generated
+
1048  unsigned npars =
+
1049  std::unique_ptr<RooArgSet>(form->getParameters(RooArgList()))->getSize();
+
1050  std::string args = "";
+
1051  for (unsigned i = 0; i < npars; ++i) {
+
1052  args += std::string(form->getParameter(i)->GetName());
+
1053  if (i < (npars-1)) {
+
1054  args += ",";
+
1055  }
+
1056  }
+
1057  txt_file << format("%-" + sys_str_short +
+
1058  "s %-10s %-10s %-10s %-20s %s\n") %
+
1059  rp[0] % "rateParam" % rp[1] % rp[2] % form_str % args;
+
1060  }
+
1061  }
+
1062 
+
1063  std::set<std::string> ws_vars;
+
1064  for (auto iter : wspaces_) {
+
1065  RooArgSet vars = iter.second->allVars();
+
1066  auto v = vars.createIterator();
+
1067  do {
+
1068  RooRealVar *y = dynamic_cast<RooRealVar*>(**v);
+
1069  if (y) {
+
1070  ws_vars.insert(y->GetName());
+
1071  }
+
1072  } while (v->Next());
+
1073  }
+
1074 
+
1075  // How to check for params we need to write:
+
1076  // Get a list of all pdf dependents for the processes we've just written
+
1077  // Also need a list of all Systematic entries we've just written
+
1078  // Then we write param if:
+
1079  // - it has non-zero errors
+
1080  // - it appears in the first list
+
1081  // - it doesn't appear in the second list
+
1082  for (auto par : params_) {
+
1083  Parameter const* p = par.second.get();
+
1084  if (p->err_d() != 0.0 && p->err_u() != 0.0 &&
+
1085  all_dependents_pars.count(p->name()) && !sys_set.count(p->name())) {
+
1086  txt_file << format((format("%%-%is param %%g %%g") % sys_str_len).str()) %
+
1087  p->name() % p->val() % ((p->err_u() - p->err_d()) / 2.0);
+
1088  if (p->range_d() != std::numeric_limits<double>::lowest() &&
+
1089  p->range_u() != std::numeric_limits<double>::max()) {
+
1090  txt_file << format(" [%.4g,%.4g]") % p->range_d() % p->range_u();
+
1091  }
+
1092  txt_file << "\n";
+
1093  }
+
1094  }
+
1095 
+
1096  for (auto par : multipdf_cats) {
+
1097  txt_file << format((format("%%-%is discrete\n") % sys_str_len).str()) % par;
+
1098  }
+
1099 
+
1100  // Finally write the NP groups
+
1101  // We should only consider parameters are either:
+
1102  // - in the list of pdf dependents
+
1103  // - in the list of systematics
+
1104  std::map<std::string, std::set<std::string>> groups;
+
1105  for (auto const& par : params_) {
+
1106  Parameter * p = par.second.get();
+
1107  if (!all_dependents_pars.count(p->name()) && !sys_set.count(p->name())) {
+
1108  continue;
1109  }
-
1110  }
-
1111  for (auto const& gr : groups) {
-
1112  txt_file << format("%s group =") % gr.first;
-
1113  for (auto const& np : gr.second) {
-
1114  txt_file << " " << np;
-
1115  }
-
1116  txt_file << "\n";
+
1110  if (p->err_d() == 0.0 && p->err_u() == 0.0) continue;
+
1111  for (auto const& str : p->groups()) {
+
1112  if (!groups.count(str)) {
+
1113  groups[str] = std::set<std::string>();
+
1114  }
+
1115  groups[str].insert(p->name());
+
1116  }
1117  }
-
1118 
-
1119  txt_file.close();
-
1120 }
-
1121 
-
1122 void CombineHarvester::WriteHistToFile(
-
1123  TH1 * hist,
-
1124  TFile * file,
-
1125  std::vector<HistMapping> const& mappings,
-
1126  std::string const& bin,
-
1127  std::string const& process,
-
1128  std::string const& mass,
-
1129  std::string const& nuisance,
-
1130  unsigned type) {
-
1131  StrPairVec attempts = this->GenerateShapeMapAttempts(process, bin);
-
1132  for (unsigned a = 0; a < attempts.size(); ++a) {
-
1133  for (unsigned m = 0; m < mappings.size(); ++m) {
-
1134  if ((attempts[a].first == mappings[m].process) &&
-
1135  (attempts[a].second == mappings[m].category)) {
-
1136  std::string p = (type == 0 ?
-
1137  mappings[m].pattern : mappings[m].syst_pattern);
-
1138  boost::replace_all(p, "$CHANNEL", bin);
-
1139  boost::replace_all(p, "$PROCESS", process);
-
1140  boost::replace_all(p, "$MASS", mass);
-
1141  if (type == 1) boost::replace_all(p, "$SYSTEMATIC", nuisance+"Down");
-
1142  if (type == 2) boost::replace_all(p, "$SYSTEMATIC", nuisance+"Up");
-
1143  WriteToTFile(hist, file, p);
-
1144  return;
-
1145  }
-
1146  }
-
1147  }
-
1148 }
-
1149 }
+
1118  for (auto const& gr : groups) {
+
1119  txt_file << format("%s group =") % gr.first;
+
1120  for (auto const& np : gr.second) {
+
1121  txt_file << " " << np;
+
1122  }
+
1123  txt_file << "\n";
+
1124  }
+
1125 
+
1126  for (auto const& postl : post_lines_) {
+
1127  txt_file << postl << "\n";
+
1128  }
+
1129 
+
1130  txt_file.close();
+
1131 }
+
1132 
+
1133 void CombineHarvester::WriteHistToFile(
+
1134  TH1 * hist,
+
1135  TFile * file,
+
1136  std::vector<HistMapping> const& mappings,
+
1137  std::string const& bin,
+
1138  std::string const& process,
+
1139  std::string const& mass,
+
1140  std::string const& nuisance,
+
1141  unsigned type) {
+
1142  StrPairVec attempts = this->GenerateShapeMapAttempts(process, bin);
+
1143  for (unsigned a = 0; a < attempts.size(); ++a) {
+
1144  for (unsigned m = 0; m < mappings.size(); ++m) {
+
1145  if ((attempts[a].first == mappings[m].process) &&
+
1146  (attempts[a].second == mappings[m].category)) {
+
1147  std::string p = (type == 0 ?
+
1148  mappings[m].pattern : mappings[m].syst_pattern);
+
1149  boost::replace_all(p, "$CHANNEL", bin);
+
1150  boost::replace_all(p, "$PROCESS", process);
+
1151  boost::replace_all(p, "$MASS", mass);
+
1152  if (type == 1) boost::replace_all(p, "$SYSTEMATIC", nuisance+"Down");
+
1153  if (type == 2) boost::replace_all(p, "$SYSTEMATIC", nuisance+"Up");
+
1154  WriteToTFile(hist, file, p);
+
1155  return;
+
1156  }
+
1157  }
+
1158  }
+
1159 }
+
1160 }
ch::Systematic::ClonedShapeU
std::unique_ptr< TH1 > ClonedShapeU() const
Definition: Systematic.cc:150
ch::CombineHarvester::data
CombineHarvester & data()
Definition: CombineHarvester_Filters.cc:183
ch::CombineHarvester::CreateParameterIfEmpty
void CreateParameterIfEmpty(std::string const &name)
Definition: CombineHarvester_Creation.cc:228
@@ -1254,25 +1265,26 @@
ch::CombineHarvester
Definition: CombineHarvester.h:30
ch::Systematic::data_u
RooDataHist const * data_u() const
Definition: Systematic.h:45
ch::Systematic::data_d
RooDataHist const * data_d() const
Definition: Systematic.h:47
-
ch::CombineHarvester::WriteDatacard
void WriteDatacard(std::string const &name, std::string const &root_file)
Definition: CombineHarvester_Datacards.cc:454
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::WriteDatacard
void WriteDatacard(std::string const &name, std::string const &root_file)
Definition: CombineHarvester_Datacards.cc:455
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::Observation::shape
TH1 const * shape() const
Definition: Observation.h:27
ch::HistMapping::WorkspaceName
std::string WorkspaceName() const
Definition: HistMapping.cc:37
-
ch::Process::norm
RooAbsReal const * norm() const
Definition: Process.h:56
+
ch::Process::norm
RooAbsReal const * norm() const
Definition: Process.h:66
ch::HistMapping::process
std::string process
Definition: HistMapping.h:11
-
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:53
+
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:63
ch::CombineHarvester::syst_type
CombineHarvester & syst_type(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:136
ch::Parameter::set_val
void set_val(double const &val)
Definition: Parameter.h:23
ch::Systematic::type
std::string const & type() const
Definition: Systematic.h:24
ch::CombineHarvester::ParseDatacard
int ParseDatacard(std::string const &filename, std::string const &analysis, std::string const &era, std::string const &channel, int bin_id, std::string const &mass)
Definition: CombineHarvester_Datacards.cc:54
LOGLINE
#define LOGLINE(x, y)
Definition: Logging.h:11
-
ch::Process::no_norm_rate
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:36
-
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:95
+
ch::Process::no_norm_rate
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:46
+
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:105
ch::CombineHarvester::bin_set
std::set< std::string > bin_set()
Definition: CombineHarvester_Filters.cc:190
ch::Parameter::set_name
void set_name(std::string const &name)
Definition: Parameter.h:20
ch::syst::bin_id
Definition: Systematics.h:41
ch::HistMapping::SystWorkspaceName
std::string SystWorkspaceName() const
Definition: HistMapping.cc:53
ch::Parameter::val
double val() const
Definition: Parameter.h:31
+
ch::Process::pdf
RooAbsReal const * pdf() const
Definition: Process.h:60
Process.h
CombineHarvester.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
@@ -1281,7 +1293,7 @@
FNLOG
#define FNLOG(x)
Definition: Logging.h:13
ch::Systematic::asymm
bool asymm() const
Definition: Systematic.h:36
ch::HistMapping::pattern
std::string pattern
Definition: HistMapping.h:13
-
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:571
+
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:585
FNERROR
#define FNERROR(x)
Definition: Logging.h:9
Systematic.h
ch::Object::process
virtual std::string const & process() const
Definition: Object.h:20
@@ -1291,20 +1303,20 @@
ch::Parameter::err_d
double err_d() const
Definition: Parameter.h:37
Algorithm.h
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
-
ch::is_float
bool is_float(std::string const &str)
Definition: Utilities.cc:240
-
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:223
+
ch::is_float
bool is_float(std::string const &str)
Definition: Utilities.cc:241
+
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:224
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
ch::CombineHarvester::syst_name
CombineHarvester & syst_name(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:126
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
ch::Parameter::range_d
double range_d() const
Definition: Parameter.h:43
-
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:42
+
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:52
Utilities.h
Parameter.h
ch::Parameter::name
std::string const & name() const
Definition: Parameter.h:21
ch::Observation
Definition: Observation.h:12
ch::Observation::data
RooAbsData const * data() const
Definition: Observation.h:35
FNLOGC
#define FNLOGC(x, y)
Definition: Logging.h:14
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::contains
bool contains(const Range &r, T p)
Definition: Algorithm.h:22
ch::Parameter::groups
std::set< std::string > & groups()
Definition: Parameter.h:54
ch::Systematic::value_d
double value_d() const
Definition: Systematic.h:30
@@ -1313,9 +1325,8 @@
ch::Parameter::set_range_d
void set_range_d(double const &range_d)
Definition: Parameter.h:42
ch::Systematic::value_u
double value_u() const
Definition: Systematic.h:27
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
-
ch::CombineHarvester::SetFromObs
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
Definition: CombineHarvester.h:564
+
ch::CombineHarvester::SetFromObs
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
Definition: CombineHarvester.h:578
Observation.h
-
ch::Process::pdf
RooAbsPdf const * pdf() const
Definition: Process.h:50
ch::Systematic::ClonedShapeD
std::unique_ptr< TH1 > ClonedShapeD() const
Definition: Systematic.cc:157
ch::Parameter::err_u
double err_u() const
Definition: Parameter.h:34
MakeUnique.h
@@ -1323,17 +1334,17 @@
ch::Systematic::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Systematic.cc:164
ch::syst::channel
Definition: Systematics.h:26
TFileIO.h
-
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:602
-
ch::CombineHarvester::SetGroup
void SetGroup(std::string const &name, std::vector< std::string > const &patterns)
Add parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:694
+
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:616
+
ch::CombineHarvester::SetGroup
void SetGroup(std::string const &name, std::vector< std::string > const &patterns)
Add parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:700
ch::HistMapping::sys_ws
std::shared_ptr< RooWorkspace > sys_ws
Definition: HistMapping.h:17
ch::HistMapping
Definition: HistMapping.h:10
-
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:597
-
ch::Process
Definition: Process.h:14
+
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:611
+
ch::Process
Definition: Process.h:15
ch::ParametersByName
RooArgSet ParametersByName(RooAbsReal const *pdf, RooArgSet const *dat_vars)
Definition: Utilities.cc:18
ch::CombineHarvester::CombineHarvester
CombineHarvester()
Definition: CombineHarvester.cc:16
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
-
ch::CombineHarvester::SetFromSysts
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
Definition: CombineHarvester.h:578
-
ch::make_relative
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
Definition: Utilities.cc:312
+
ch::CombineHarvester::SetFromSysts
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
Definition: CombineHarvester.h:592
+
ch::make_relative
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
Definition: Utilities.cc:313
ch::Systematic::name
std::string const & name() const
Definition: Systematic.h:21
ch::syst::era
Definition: Systematics.h:21
ch::syst::process
Definition: Systematics.h:36
diff --git a/_combine_harvester___evaluate_8cc_source.html b/_combine_harvester___evaluate_8cc_source.html index e14566626da..5d9f7e391ae 100644 --- a/_combine_harvester___evaluate_8cc_source.html +++ b/_combine_harvester___evaluate_8cc_source.html @@ -478,395 +478,411 @@
376  }
377  shape.Add(&proc_shape);
378  } else if (procs_[i]->pdf()) {
-
379  RooAbsData const* data_obj = FindMatchingData(procs_[i].get());
-
380  std::string var_name = "CMS_th1x";
-
381  if (data_obj) var_name = data_obj->get()->first()->GetName();
-
382  TH1::AddDirectory(false);
-
383  TH1F *tmp = dynamic_cast<TH1F*>(
-
384  procs_[i]->pdf()->createHistogram(var_name.c_str()));
-
385  TH1F proc_shape = *tmp;
-
386  delete tmp;
-
387  if (!procs_[i]->pdf()->selfNormalized()) {
-
388  // LOGLINE(log(), "Have a pdf that is not selfNormalized");
-
389  // std::cout << "Integral: " << proc_shape.Integral() << "\n";
-
390  if (proc_shape.Integral() > 0.) {
-
391  proc_shape.Scale(1. / proc_shape.Integral());
-
392  }
-
393  }
-
394  for (auto sys_it : lookup[i]) {
-
395  if (sys_it->type() == "rateParam") {
-
396  continue; // don't evaluate this for now
-
397  }
-
398  double x = params_[sys_it->name()]->val();
-
399  if (sys_it->asymm()) {
-
400  p_rate *= logKappaForX(x * sys_it->scale(), sys_it->value_d(),
-
401  sys_it->value_u());
-
402  } else {
-
403  p_rate *= std::pow(sys_it->value_u(), x * sys_it->scale());
+
379  if (!procs_[i]->observable()) {
+
380  RooAbsData const* data_obj = FindMatchingData(procs_[i].get());
+
381  std::string var_name = "CMS_th1x";
+
382  if (data_obj) var_name = data_obj->get()->first()->GetName();
+
383  procs_[i]->set_observable((RooRealVar *)procs_[i]->pdf()->findServer(var_name.c_str()));
+
384  }
+
385  TH1::AddDirectory(false);
+
386  TH1F* tmp = (TH1F*)procs_[i]->observable()->createHistogram("");
+
387  for (int b = 1; b <= tmp->GetNbinsX(); ++b) {
+
388  procs_[i]->observable()->setVal(tmp->GetBinCenter(b));
+
389  tmp->SetBinContent(b, tmp->GetBinWidth(b) * procs_[i]->pdf()->getVal());
+
390  }
+
391  TH1F proc_shape = *tmp;
+
392  delete tmp;
+
393  RooAbsPdf const* aspdf = dynamic_cast<RooAbsPdf const*>(procs_[i]->pdf());
+
394  if ((aspdf && !aspdf->selfNormalized()) || (!aspdf)) {
+
395  // LOGLINE(log(), "Have a pdf that is not selfNormalized");
+
396  // std::cout << "Integral: " << proc_shape.Integral() << "\n";
+
397  if (proc_shape.Integral() > 0.) {
+
398  proc_shape.Scale(1. / proc_shape.Integral());
+
399  }
+
400  }
+
401  for (auto sys_it : lookup[i]) {
+
402  if (sys_it->type() == "rateParam") {
+
403  continue; // don't evaluate this for now
404  }
-
405  }
-
406  proc_shape.Scale(p_rate);
-
407  if (!shape_init) {
-
408  proc_shape.Copy(shape);
-
409  shape.Reset();
-
410  shape_init = true;
-
411  }
-
412  shape.Add(&proc_shape);
-
413  }
-
414  }
-
415  return shape;
-
416 }
-
417 
-
418 double CombineHarvester::GetObservedRate() {
-
419  double rate = 0.0;
-
420  for (unsigned i = 0; i < obs_.size(); ++i) {
-
421  rate += obs_[i]->rate();
-
422  }
-
423  return rate;
-
424 }
-
425 
-
426 TH1F CombineHarvester::GetObservedShape() {
-
427  TH1F shape;
-
428  bool shape_init = false;
-
429 
-
430  for (unsigned i = 0; i < obs_.size(); ++i) {
-
431  TH1F proc_shape;
-
432  double p_rate = obs_[i]->rate();
-
433  if (obs_[i]->shape()) {
-
434  proc_shape = obs_[i]->ShapeAsTH1F();
-
435  } else if (obs_[i]->data()) {
-
436  std::string var_name = obs_[i]->data()->get()->first()->GetName();
-
437  TH1F *tmp = dynamic_cast<TH1F*>(obs_[i]->data()->createHistogram(
-
438  var_name.c_str()));
-
439  proc_shape = *tmp;
-
440  delete tmp;
-
441  proc_shape.Scale(1. / proc_shape.Integral());
-
442  }
-
443  proc_shape.Scale(p_rate);
-
444  if (!shape_init) {
-
445  proc_shape.Copy(shape);
-
446  shape.Reset();
-
447  shape_init = true;
+
405  double x = params_[sys_it->name()]->val();
+
406  if (sys_it->asymm()) {
+
407  p_rate *= logKappaForX(x * sys_it->scale(), sys_it->value_d(),
+
408  sys_it->value_u());
+
409  } else {
+
410  p_rate *= std::pow(sys_it->value_u(), x * sys_it->scale());
+
411  }
+
412  }
+
413  proc_shape.Scale(p_rate);
+
414  if (!shape_init) {
+
415  proc_shape.Copy(shape);
+
416  shape.Reset();
+
417  shape_init = true;
+
418  }
+
419  shape.Add(&proc_shape);
+
420  }
+
421  }
+
422  return shape;
+
423 }
+
424 
+
425 double CombineHarvester::GetObservedRate() {
+
426  double rate = 0.0;
+
427  for (unsigned i = 0; i < obs_.size(); ++i) {
+
428  rate += obs_[i]->rate();
+
429  }
+
430  return rate;
+
431 }
+
432 
+
433 TH1F CombineHarvester::GetObservedShape() {
+
434  TH1F shape;
+
435  bool shape_init = false;
+
436 
+
437  for (unsigned i = 0; i < obs_.size(); ++i) {
+
438  TH1F proc_shape;
+
439  double p_rate = obs_[i]->rate();
+
440  if (obs_[i]->shape()) {
+
441  proc_shape = obs_[i]->ShapeAsTH1F();
+
442  } else if (obs_[i]->data()) {
+
443  TH1F* tmp = dynamic_cast<TH1F*>(obs_[i]->data()->createHistogram(
+
444  "", *(RooRealVar*)obs_[i]->data()->get()->first()));
+
445  proc_shape = *tmp;
+
446  delete tmp;
+
447  proc_shape.Scale(1. / proc_shape.Integral());
448  }
-
449  shape.Add(&proc_shape);
-
450  }
-
451  return shape;
-
452 }
-
453 
-
454 void CombineHarvester::ShapeDiff(double x,
-
455  TH1F * target,
-
456  TH1 const* nom,
-
457  TH1 const* low,
-
458  TH1 const* high,
-
459  bool linear) {
-
460  double fx = smoothStepFunc(x);
-
461  for (int i = 1; i <= target->GetNbinsX(); ++i) {
-
462  float h = high->GetBinContent(i);
-
463  float l = low->GetBinContent(i);
-
464  float n = nom->GetBinContent(i);
-
465  if (!linear) {
-
466  float t = target->GetBinContent(i);
-
467  target->SetBinContent(i, t > 0. ? std::log(t) : -999.);
-
468  h = (h > 0. && n > 0.) ? std::log(h/n) : 0.;
-
469  l = (l > 0. && n > 0.) ? std::log(l/n) : 0.;
-
470  target->SetBinContent(i, target->GetBinContent(i) +
-
471  0.5 * x * ((h - l) + (h + l) * fx));
-
472  target->SetBinContent(i, std::exp(target->GetBinContent(i)));
-
473  } else {
-
474  target->SetBinContent(i, target->GetBinContent(i) +
-
475  0.5 * x * ((h - l) + (h + l - 2. * n) * fx));
-
476  }
-
477  }
-
478 }
-
479 
-
480 void CombineHarvester::ShapeDiff(double x,
-
481  TH1F * target,
-
482  RooDataHist const* nom,
-
483  RooDataHist const* low,
-
484  RooDataHist const* high) {
-
485  double fx = smoothStepFunc(x);
-
486  for (int i = 1; i <= target->GetNbinsX(); ++i) {
-
487  high->get(i-1);
-
488  low->get(i-1);
-
489  nom->get(i-1);
-
490  // The RooDataHists are not scaled to unity (unlike in the TH1 case above)
-
491  // so we have to normalise the bin contents on the fly
-
492  float h = high->weight() / high->sumEntries();
-
493  float l = low->weight() / low->sumEntries();
-
494  float n = nom->weight() / nom->sumEntries();
-
495  target->SetBinContent(i, target->GetBinContent(i) +
-
496  0.5 * x * ((h - l) + (h + l - 2. * n) * fx));
-
497  }
-
498 }
-
499 
-
500 // void CombineHarvester::SetParameters(std::vector<ch::Parameter> params) {
-
501 // params_.clear();
-
502 // for (unsigned i = 0; i < params.size(); ++i) {
-
503 // params_[params[i].name()] = std::make_shared<ch::Parameter>(params[i]);
-
504 // }
-
505 // }
-
506 
-
507 void CombineHarvester::RenameParameter(std::string const& oldname,
-
508  std::string const& newname) {
-
509  auto it = params_.find(oldname);
-
510  if (it != params_.end()) {
-
511  params_[newname] = it->second;
-
512  params_[newname]->set_name(newname);
-
513  params_.erase(it);
-
514  }
-
515 }
-
516 
-
517 ch::Parameter const* CombineHarvester::GetParameter(
-
518  std::string const& name) const {
-
519  auto it = params_.find(name);
-
520  if (it != params_.end()) {
-
521  return it->second.get();
-
522  } else {
-
523  return nullptr;
-
524  }
-
525 }
-
526 
-
527 ch::Parameter* CombineHarvester::GetParameter(std::string const& name) {
-
528  auto it = params_.find(name);
-
529  if (it != params_.end()) {
-
530  return it->second.get();
-
531  } else {
-
532  return nullptr;
-
533  }
-
534 }
-
535 
-
536 void CombineHarvester::UpdateParameters(
-
537  std::vector<ch::Parameter> const& params) {
-
538  for (unsigned i = 0; i < params.size(); ++i) {
-
539  auto it = params_.find(params[i].name());
-
540  if (it != params_.end()) {
-
541  it->second->set_val(params[i].val());
-
542  it->second->set_err_d(params[i].err_d());
-
543  it->second->set_err_u(params[i].err_u());
-
544  } else {
-
545  if (verbosity_ >= 1) {
-
546  LOGLINE(log(), "Parameter " + params[i].name() + " is not defined");
-
547  }
-
548  }
-
549  }
-
550 }
-
551 
-
552 void CombineHarvester::UpdateParameters(RooFitResult const& fit) {
-
553  for (int i = 0; i < fit.floatParsFinal().getSize(); ++i) {
-
554  RooRealVar const* var =
-
555  dynamic_cast<RooRealVar const*>(fit.floatParsFinal().at(i));
-
556  // check for failed cast here
-
557  auto it = params_.find(std::string(var->GetName()));
-
558  if (it != params_.end()) {
-
559  it->second->set_val(var->getVal());
-
560  it->second->set_err_d(var->getErrorLo());
-
561  it->second->set_err_u(var->getErrorHi());
-
562  } else {
-
563  if (verbosity_ >= 1) {
-
564  LOGLINE(log(),
-
565  "Parameter " + std::string(var->GetName()) + " is not defined");
-
566  }
-
567  }
-
568  }
-
569 }
-
570 
-
571 void CombineHarvester::UpdateParameters(RooFitResult const* fit) {
-
572  UpdateParameters(*fit);
-
573 }
-
574 
-
575 std::vector<ch::Parameter> CombineHarvester::GetParameters() const {
-
576  std::vector<ch::Parameter> params;
-
577  for (auto const& it : params_) {
-
578  params.push_back(*(it.second));
-
579  }
-
580  return params;
-
581 }
-
582 
-
583 void CombineHarvester::VariableRebin(std::vector<double> bins) {
-
584  // We need to keep a record of the Process rates before we rebin. The
-
585  // reasoning comes from the following scenario: the user might choose a new
-
586  // binning which excludes some of the existing bins - thus changing the
-
587  // process normalisation. This is fine, but we also need to adjust the shape
-
588  // Systematic entries - both the rebinning and the adjustment of the value_u
-
589  // and value_d shifts.
-
590  std::vector<double> prev_proc_rates(procs_.size());
-
591 
-
592  // Also hold on the scaled Process hists *after* the rebinning is done - these
-
593  // are needed to update the associated Systematic entries
-
594  std::vector<std::unique_ptr<TH1>> scaled_procs(procs_.size());
-
595 
-
596  for (unsigned i = 0; i < procs_.size(); ++i) {
-
597  if (procs_[i]->shape()) {
-
598  // Get the scaled shape here
-
599  std::unique_ptr<TH1> copy(procs_[i]->ClonedScaledShape());
-
600  // shape norm should only be "no_norm_rate"
-
601  prev_proc_rates[i] = procs_[i]->no_norm_rate();
-
602  std::unique_ptr<TH1> copy2(copy->Rebin(bins.size()-1, "", &(bins[0])));
-
603  // The process shape & rate will be reset here
-
604  procs_[i]->set_shape(std::move(copy2), true);
-
605  scaled_procs[i] = procs_[i]->ClonedScaledShape();
-
606  }
-
607  }
-
608  for (unsigned i = 0; i < obs_.size(); ++i) {
-
609  if (obs_[i]->shape()) {
-
610  std::unique_ptr<TH1> copy(obs_[i]->ClonedScaledShape());
-
611  std::unique_ptr<TH1> copy2(copy->Rebin(bins.size()-1, "", &(bins[0])));
-
612  obs_[i]->set_shape(std::move(copy2), true);
-
613  }
-
614  }
-
615  for (unsigned i = 0; i < systs_.size(); ++i) {
-
616  TH1 const* proc_hist = nullptr;
-
617  double prev_rate = 0.;
-
618  for (unsigned j = 0; j < procs_.size(); ++j) {
-
619  if (MatchingProcess(*(procs_[j]), *(systs_[i].get()))) {
-
620  proc_hist = scaled_procs[j].get();
-
621  prev_rate = prev_proc_rates[j];
-
622  }
-
623  }
-
624  if (systs_[i]->shape_u() && systs_[i]->shape_d()) {
-
625  // These hists will be normalised to unity
-
626  std::unique_ptr<TH1> copy_u(systs_[i]->ClonedShapeU());
-
627  std::unique_ptr<TH1> copy_d(systs_[i]->ClonedShapeD());
-
628 
-
629  // If we found a matching Process we will scale this back up to their
-
630  // initial rates
-
631  if (proc_hist) {
-
632  copy_u->Scale(systs_[i]->value_u() * prev_rate);
-
633  copy_d->Scale(systs_[i]->value_d() * prev_rate);
-
634  }
-
635  std::unique_ptr<TH1> copy2_u(
-
636  copy_u->Rebin(bins.size() - 1, "", &(bins[0])));
-
637  std::unique_ptr<TH1> copy2_d(
-
638  copy_d->Rebin(bins.size() - 1, "", &(bins[0])));
-
639  // If we have proc_hist != nullptr, set_shapes will re-calculate value_u
-
640  // and value_d for us, before scaling the new hists back to unity
-
641  systs_[i]->set_shapes(std::move(copy2_u), std::move(copy2_d), proc_hist);
-
642  }
-
643  }
-
644 }
-
645 
-
646 void CombineHarvester::SetPdfBins(unsigned nbins) {
-
647  for (unsigned i = 0; i < procs_.size(); ++i) {
-
648  std::set<std::string> binning_vars;
-
649  if (procs_[i]->pdf()) {
-
650  RooAbsData const* data_obj = FindMatchingData(procs_[i].get());
-
651  std::string var_name = "CMS_th1x";
-
652  if (data_obj) var_name = data_obj->get()->first()->GetName();
-
653  binning_vars.insert(var_name);
-
654  }
-
655  for (auto & it : wspaces_) {
-
656  for (auto & var : binning_vars) {
-
657  RooRealVar* avar =
-
658  dynamic_cast<RooRealVar*>(it.second->var(var.c_str()));
-
659  if (avar) avar->setBins(nbins);
-
660  }
-
661  }
-
662  }
-
663 }
-
664 
-
665 // This implementation "borowed" from
-
666 // HiggsAnalysis/CombinedLimit/src/ProcessNormalization.cc
-
667 double CombineHarvester::logKappaForX(double x, double k_low,
-
668  double k_high) const {
-
669  if (k_high == 0. || k_low == 0.) {
-
670  if (verbosity_ >= 1) {
-
671  LOGLINE(log(), "Have kappa=0.0 (scaling ill-defined), returning 1.0");
-
672  }
-
673  return 1.;
-
674  }
-
675  if (fabs(x) >= 0.5)
-
676  return (x >= 0 ? std::pow(k_high, x) : std::pow(k_low, -1.0 * x));
-
677  // interpolate between log(kappaHigh) and -log(kappaLow)
-
678  // logKappa(x) = avg + halfdiff * h(2x)
-
679  // where h(x) is the 3th order polynomial
-
680  // h(x) = (3 x^5 - 10 x^3 + 15 x)/8;
-
681  // chosen so that h(x) satisfies the following:
-
682  // h (+/-1) = +/-1
-
683  // h'(+/-1) = 0
-
684  // h"(+/-1) = 0
-
685  double logKhi = std::log(k_high);
-
686  double logKlo = -std::log(k_low);
-
687  double avg = 0.5 * (logKhi + logKlo), halfdiff = 0.5 * (logKhi - logKlo);
-
688  double twox = x + x, twox2 = twox * twox;
-
689  double alpha = 0.125 * twox * (twox2 * (3 * twox2 - 10.) + 15.);
-
690  double ret = avg + alpha * halfdiff;
-
691  return std::exp(ret * x);
-
692 }
-
693 
-
694 void CombineHarvester::SetGroup(std::string const& name,
-
695  std::vector<std::string> const& patterns) {
-
696  std::vector<boost::regex> rgx;
-
697  for (auto const& pt : patterns) rgx.emplace_back(pt);
-
698  for (auto it = params_.begin(); it != params_.end(); ++it) {
-
699  std::string par = it->first;
-
700  auto & groups = it->second->groups();
-
701  if (groups.count(name)) continue;
-
702  if (ch::contains_rgx(rgx, par)) {
-
703  groups.insert(name);
-
704  };
-
705  }
-
706 }
-
707 
-
708 void CombineHarvester::RemoveGroup(std::string const& name,
-
709  std::vector<std::string> const& patterns) {
-
710  std::vector<boost::regex> rgx;
-
711  for (auto const& pt : patterns) rgx.emplace_back(pt);
-
712  for (auto it = params_.begin(); it != params_.end(); ++it) {
-
713  std::string par = it->first;
-
714  auto & groups = it->second->groups();
-
715  if (!groups.count(name)) continue;
-
716  if (ch::contains_rgx(rgx, par)) {
-
717  groups.erase(name);
-
718  };
-
719  }
-
720 }
-
721 
-
722 void CombineHarvester::RenameGroup(std::string const& oldname,
-
723  std::string const& newname) {
-
724  for (auto it = params_.begin(); it != params_.end(); ++it) {
-
725  auto & groups = it->second->groups();
-
726  if (groups.count(oldname)) {
-
727  groups.erase(oldname);
-
728  groups.insert(newname);
-
729  }
-
730  }
-
731 }
-
732 }
+
449  proc_shape.Scale(p_rate);
+
450  if (!shape_init) {
+
451  proc_shape.Copy(shape);
+
452  shape.Reset();
+
453  shape_init = true;
+
454  }
+
455  shape.Add(&proc_shape);
+
456  }
+
457  return shape;
+
458 }
+
459 
+
460 void CombineHarvester::ShapeDiff(double x,
+
461  TH1F * target,
+
462  TH1 const* nom,
+
463  TH1 const* low,
+
464  TH1 const* high,
+
465  bool linear) {
+
466  double fx = smoothStepFunc(x);
+
467  for (int i = 1; i <= target->GetNbinsX(); ++i) {
+
468  float h = high->GetBinContent(i);
+
469  float l = low->GetBinContent(i);
+
470  float n = nom->GetBinContent(i);
+
471  if (!linear) {
+
472  float t = target->GetBinContent(i);
+
473  target->SetBinContent(i, t > 0. ? std::log(t) : -999.);
+
474  h = (h > 0. && n > 0.) ? std::log(h/n) : 0.;
+
475  l = (l > 0. && n > 0.) ? std::log(l/n) : 0.;
+
476  target->SetBinContent(i, target->GetBinContent(i) +
+
477  0.5 * x * ((h - l) + (h + l) * fx));
+
478  target->SetBinContent(i, std::exp(target->GetBinContent(i)));
+
479  } else {
+
480  target->SetBinContent(i, target->GetBinContent(i) +
+
481  0.5 * x * ((h - l) + (h + l - 2. * n) * fx));
+
482  }
+
483  }
+
484 }
+
485 
+
486 void CombineHarvester::ShapeDiff(double x,
+
487  TH1F * target,
+
488  RooDataHist const* nom,
+
489  RooDataHist const* low,
+
490  RooDataHist const* high) {
+
491  double fx = smoothStepFunc(x);
+
492  for (int i = 1; i <= target->GetNbinsX(); ++i) {
+
493  high->get(i-1);
+
494  low->get(i-1);
+
495  nom->get(i-1);
+
496  // The RooDataHists are not scaled to unity (unlike in the TH1 case above)
+
497  // so we have to normalise the bin contents on the fly
+
498  float h = high->weight() / high->sumEntries();
+
499  float l = low->weight() / low->sumEntries();
+
500  float n = nom->weight() / nom->sumEntries();
+
501  target->SetBinContent(i, target->GetBinContent(i) +
+
502  0.5 * x * ((h - l) + (h + l - 2. * n) * fx));
+
503  }
+
504 }
+
505 
+
506 // void CombineHarvester::SetParameters(std::vector<ch::Parameter> params) {
+
507 // params_.clear();
+
508 // for (unsigned i = 0; i < params.size(); ++i) {
+
509 // params_[params[i].name()] = std::make_shared<ch::Parameter>(params[i]);
+
510 // }
+
511 // }
+
512 
+
513 void CombineHarvester::RenameParameter(std::string const& oldname,
+
514  std::string const& newname) {
+
515  auto it = params_.find(oldname);
+
516  if (it != params_.end()) {
+
517  params_[newname] = it->second;
+
518  params_[newname]->set_name(newname);
+
519  params_.erase(it);
+
520  }
+
521 }
+
522 
+
523 ch::Parameter const* CombineHarvester::GetParameter(
+
524  std::string const& name) const {
+
525  auto it = params_.find(name);
+
526  if (it != params_.end()) {
+
527  return it->second.get();
+
528  } else {
+
529  return nullptr;
+
530  }
+
531 }
+
532 
+
533 ch::Parameter* CombineHarvester::GetParameter(std::string const& name) {
+
534  auto it = params_.find(name);
+
535  if (it != params_.end()) {
+
536  return it->second.get();
+
537  } else {
+
538  return nullptr;
+
539  }
+
540 }
+
541 
+
542 void CombineHarvester::UpdateParameters(
+
543  std::vector<ch::Parameter> const& params) {
+
544  for (unsigned i = 0; i < params.size(); ++i) {
+
545  auto it = params_.find(params[i].name());
+
546  if (it != params_.end()) {
+
547  it->second->set_val(params[i].val());
+
548  it->second->set_err_d(params[i].err_d());
+
549  it->second->set_err_u(params[i].err_u());
+
550  } else {
+
551  if (verbosity_ >= 1) {
+
552  LOGLINE(log(), "Parameter " + params[i].name() + " is not defined");
+
553  }
+
554  }
+
555  }
+
556 }
+
557 
+
558 void CombineHarvester::UpdateParameters(RooFitResult const& fit) {
+
559  for (int i = 0; i < fit.floatParsFinal().getSize(); ++i) {
+
560  RooRealVar const* var =
+
561  dynamic_cast<RooRealVar const*>(fit.floatParsFinal().at(i));
+
562  // check for failed cast here
+
563  auto it = params_.find(std::string(var->GetName()));
+
564  if (it != params_.end()) {
+
565  it->second->set_val(var->getVal());
+
566  it->second->set_err_d(var->getErrorLo());
+
567  it->second->set_err_u(var->getErrorHi());
+
568  } else {
+
569  if (verbosity_ >= 1) {
+
570  LOGLINE(log(),
+
571  "Parameter " + std::string(var->GetName()) + " is not defined");
+
572  }
+
573  }
+
574  }
+
575 }
+
576 
+
577 void CombineHarvester::UpdateParameters(RooFitResult const* fit) {
+
578  UpdateParameters(*fit);
+
579 }
+
580 
+
581 std::vector<ch::Parameter> CombineHarvester::GetParameters() const {
+
582  std::vector<ch::Parameter> params;
+
583  for (auto const& it : params_) {
+
584  params.push_back(*(it.second));
+
585  }
+
586  return params;
+
587 }
+
588 
+
589 void CombineHarvester::VariableRebin(std::vector<double> bins) {
+
590  // We need to keep a record of the Process rates before we rebin. The
+
591  // reasoning comes from the following scenario: the user might choose a new
+
592  // binning which excludes some of the existing bins - thus changing the
+
593  // process normalisation. This is fine, but we also need to adjust the shape
+
594  // Systematic entries - both the rebinning and the adjustment of the value_u
+
595  // and value_d shifts.
+
596  std::vector<double> prev_proc_rates(procs_.size());
+
597 
+
598  // Also hold on the scaled Process hists *after* the rebinning is done - these
+
599  // are needed to update the associated Systematic entries
+
600  std::vector<std::unique_ptr<TH1>> scaled_procs(procs_.size());
+
601 
+
602  for (unsigned i = 0; i < procs_.size(); ++i) {
+
603  if (procs_[i]->shape()) {
+
604  // Get the scaled shape here
+
605  std::unique_ptr<TH1> copy(procs_[i]->ClonedScaledShape());
+
606  // shape norm should only be "no_norm_rate"
+
607  prev_proc_rates[i] = procs_[i]->no_norm_rate();
+
608  std::unique_ptr<TH1> copy2(copy->Rebin(bins.size()-1, "", &(bins[0])));
+
609  // The process shape & rate will be reset here
+
610  procs_[i]->set_shape(std::move(copy2), true);
+
611  scaled_procs[i] = procs_[i]->ClonedScaledShape();
+
612  }
+
613  }
+
614  for (unsigned i = 0; i < obs_.size(); ++i) {
+
615  if (obs_[i]->shape()) {
+
616  std::unique_ptr<TH1> copy(obs_[i]->ClonedScaledShape());
+
617  std::unique_ptr<TH1> copy2(copy->Rebin(bins.size()-1, "", &(bins[0])));
+
618  obs_[i]->set_shape(std::move(copy2), true);
+
619  }
+
620  }
+
621  for (unsigned i = 0; i < systs_.size(); ++i) {
+
622  TH1 const* proc_hist = nullptr;
+
623  double prev_rate = 0.;
+
624  for (unsigned j = 0; j < procs_.size(); ++j) {
+
625  if (MatchingProcess(*(procs_[j]), *(systs_[i].get()))) {
+
626  proc_hist = scaled_procs[j].get();
+
627  prev_rate = prev_proc_rates[j];
+
628  }
+
629  }
+
630  if (systs_[i]->shape_u() && systs_[i]->shape_d()) {
+
631  // These hists will be normalised to unity
+
632  std::unique_ptr<TH1> copy_u(systs_[i]->ClonedShapeU());
+
633  std::unique_ptr<TH1> copy_d(systs_[i]->ClonedShapeD());
+
634 
+
635  // If we found a matching Process we will scale this back up to their
+
636  // initial rates
+
637  if (proc_hist) {
+
638  copy_u->Scale(systs_[i]->value_u() * prev_rate);
+
639  copy_d->Scale(systs_[i]->value_d() * prev_rate);
+
640  }
+
641  std::unique_ptr<TH1> copy2_u(
+
642  copy_u->Rebin(bins.size() - 1, "", &(bins[0])));
+
643  std::unique_ptr<TH1> copy2_d(
+
644  copy_d->Rebin(bins.size() - 1, "", &(bins[0])));
+
645  // If we have proc_hist != nullptr, set_shapes will re-calculate value_u
+
646  // and value_d for us, before scaling the new hists back to unity
+
647  systs_[i]->set_shapes(std::move(copy2_u), std::move(copy2_d), proc_hist);
+
648  }
+
649  }
+
650 }
+
651 
+
652 void CombineHarvester::SetPdfBins(unsigned nbins) {
+
653  for (unsigned i = 0; i < procs_.size(); ++i) {
+
654  std::set<std::string> binning_vars;
+
655  if (procs_[i]->pdf()) {
+
656  RooAbsData const* data_obj = FindMatchingData(procs_[i].get());
+
657  std::string var_name = "CMS_th1x";
+
658  if (data_obj) var_name = data_obj->get()->first()->GetName();
+
659  binning_vars.insert(var_name);
+
660  }
+
661  for (auto & it : wspaces_) {
+
662  for (auto & var : binning_vars) {
+
663  RooRealVar* avar =
+
664  dynamic_cast<RooRealVar*>(it.second->var(var.c_str()));
+
665  if (avar) avar->setBins(nbins);
+
666  }
+
667  }
+
668  }
+
669 }
+
670 
+
671 // This implementation "borowed" from
+
672 // HiggsAnalysis/CombinedLimit/src/ProcessNormalization.cc
+
673 double CombineHarvester::logKappaForX(double x, double k_low,
+
674  double k_high) const {
+
675  if (k_high == 0. || k_low == 0.) {
+
676  if (verbosity_ >= 1) {
+
677  LOGLINE(log(), "Have kappa=0.0 (scaling ill-defined), returning 1.0");
+
678  }
+
679  return 1.;
+
680  }
+
681  if (fabs(x) >= 0.5)
+
682  return (x >= 0 ? std::pow(k_high, x) : std::pow(k_low, -1.0 * x));
+
683  // interpolate between log(kappaHigh) and -log(kappaLow)
+
684  // logKappa(x) = avg + halfdiff * h(2x)
+
685  // where h(x) is the 3th order polynomial
+
686  // h(x) = (3 x^5 - 10 x^3 + 15 x)/8;
+
687  // chosen so that h(x) satisfies the following:
+
688  // h (+/-1) = +/-1
+
689  // h'(+/-1) = 0
+
690  // h"(+/-1) = 0
+
691  double logKhi = std::log(k_high);
+
692  double logKlo = -std::log(k_low);
+
693  double avg = 0.5 * (logKhi + logKlo), halfdiff = 0.5 * (logKhi - logKlo);
+
694  double twox = x + x, twox2 = twox * twox;
+
695  double alpha = 0.125 * twox * (twox2 * (3 * twox2 - 10.) + 15.);
+
696  double ret = avg + alpha * halfdiff;
+
697  return std::exp(ret * x);
+
698 }
+
699 
+
700 void CombineHarvester::SetGroup(std::string const& name,
+
701  std::vector<std::string> const& patterns) {
+
702  std::vector<boost::regex> rgx;
+
703  for (auto const& pt : patterns) rgx.emplace_back(pt);
+
704  for (auto it = params_.begin(); it != params_.end(); ++it) {
+
705  std::string par = it->first;
+
706  auto & groups = it->second->groups();
+
707  if (groups.count(name)) continue;
+
708  if (ch::contains_rgx(rgx, par)) {
+
709  groups.insert(name);
+
710  };
+
711  }
+
712 }
+
713 
+
714 void CombineHarvester::RemoveGroup(std::string const& name,
+
715  std::vector<std::string> const& patterns) {
+
716  std::vector<boost::regex> rgx;
+
717  for (auto const& pt : patterns) rgx.emplace_back(pt);
+
718  for (auto it = params_.begin(); it != params_.end(); ++it) {
+
719  std::string par = it->first;
+
720  auto & groups = it->second->groups();
+
721  if (!groups.count(name)) continue;
+
722  if (ch::contains_rgx(rgx, par)) {
+
723  groups.erase(name);
+
724  };
+
725  }
+
726 }
+
727 
+
728 void CombineHarvester::RenameGroup(std::string const& oldname,
+
729  std::string const& newname) {
+
730  for (auto it = params_.begin(); it != params_.end(); ++it) {
+
731  auto & groups = it->second->groups();
+
732  if (groups.count(oldname)) {
+
733  groups.erase(oldname);
+
734  groups.insert(newname);
+
735  }
+
736  }
+
737 }
+
738 
+
739 void CombineHarvester::AddDatacardLineAtEnd(std::string const& line) {
+
740  post_lines_.push_back(line);
+
741 }
+
742 
+
743 void CombineHarvester::ClearDatacardLinesAtEnd() {
+
744  post_lines_.clear();
+
745 }
+
746 }
+
ch::CombineHarvester::ClearDatacardLinesAtEnd
void ClearDatacardLinesAtEnd()
Clear all added datacard lines.
Definition: CombineHarvester_Evaluate.cc:743
ch::CombineHarvester::data
CombineHarvester & data()
Definition: CombineHarvester_Filters.cc:183
ch::contains_rgx
bool contains_rgx(const std::vector< boost::regex > &r, T p)
Definition: Algorithm.h:34
ch::CombineHarvester::GetShape
TH1F GetShape()
Definition: CombineHarvester_Evaluate.cc:277
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::CombineHarvester::GetRate
double GetRate()
Definition: CombineHarvester_Evaluate.cc:272
ch::CombineHarvester::GetRateCovariance
TH2F GetRateCovariance(RooFitResult const &fit, unsigned n_samples)
Definition: CombineHarvester_Evaluate.cc:179
-
ch::CombineHarvester::RenameGroup
void RenameGroup(std::string const &oldname, std::string const &newname)
Rename a nuisance parameter group.
Definition: CombineHarvester_Evaluate.cc:722
+
ch::CombineHarvester::RenameGroup
void RenameGroup(std::string const &oldname, std::string const &newname)
Rename a nuisance parameter group.
Definition: CombineHarvester_Evaluate.cc:728
LOGLINE
#define LOGLINE(x, y)
Definition: Logging.h:11
ch::CombineHarvester::bin_set
std::set< std::string > bin_set()
Definition: CombineHarvester_Filters.cc:190
Process.h
-
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:426
+
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:433
CombineHarvester.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
-
ch::CombineHarvester::RemoveGroup
void RemoveGroup(std::string const &name, std::vector< std::string > const &patterns)
Remove parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:708
+
ch::CombineHarvester::RemoveGroup
void RemoveGroup(std::string const &name, std::vector< std::string > const &patterns)
Remove parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:714
FNERROR
#define FNERROR(x)
Definition: Logging.h:9
Systematic.h
ch::MatchingProcess
bool MatchingProcess(T const &first, U const &second)
Definition: Utilities.h:43
ch
Definition: Algorithm.h:10
Algorithm.h
-
ch::CombineHarvester::GetParameter
ch::Parameter const * GetParameter(std::string const &name) const
Definition: CombineHarvester_Evaluate.cc:517
+
ch::CombineHarvester::GetParameter
ch::Parameter const * GetParameter(std::string const &name) const
Definition: CombineHarvester_Evaluate.cc:523
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
-
ch::CombineHarvester::GetObservedRate
double GetObservedRate()
Definition: CombineHarvester_Evaluate.cc:418
+
ch::CombineHarvester::GetObservedRate
double GetObservedRate()
Definition: CombineHarvester_Evaluate.cc:425
ch::CombineHarvester::GetShapeWithUncertainty
TH1F GetShapeWithUncertainty()
Definition: CombineHarvester_Evaluate.cc:103
Utilities.h
-
ch::CombineHarvester::RenameParameter
void RenameParameter(std::string const &oldname, std::string const &newname)
Definition: CombineHarvester_Evaluate.cc:507
+
ch::CombineHarvester::RenameParameter
void RenameParameter(std::string const &oldname, std::string const &newname)
Definition: CombineHarvester_Evaluate.cc:513
Parameter.h
-
ch::CombineHarvester::VariableRebin
void VariableRebin(std::vector< double > bins)
Definition: CombineHarvester_Evaluate.cc:583
+
ch::CombineHarvester::VariableRebin
void VariableRebin(std::vector< double > bins)
Definition: CombineHarvester_Evaluate.cc:589
+
ch::CombineHarvester::AddDatacardLineAtEnd
void AddDatacardLineAtEnd(std::string const &line)
Add a line of text at the end of all datacards.
Definition: CombineHarvester_Evaluate.cc:739
Observation.h
MakeUnique.h
-
ch::CombineHarvester::SetPdfBins
void SetPdfBins(unsigned nbins)
Definition: CombineHarvester_Evaluate.cc:646
+
ch::CombineHarvester::SetPdfBins
void SetPdfBins(unsigned nbins)
Definition: CombineHarvester_Evaluate.cc:652
ch::Parameter
Definition: Parameter.h:12
-
ch::CombineHarvester::SetGroup
void SetGroup(std::string const &name, std::vector< std::string > const &patterns)
Add parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:694
-
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:536
+
ch::CombineHarvester::SetGroup
void SetGroup(std::string const &name, std::vector< std::string > const &patterns)
Add parameters to a given group.
Definition: CombineHarvester_Evaluate.cc:700
+
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:542
ch::CombineHarvester::GetRateCorrelation
TH2F GetRateCorrelation(RooFitResult const &fit, unsigned n_samples)
Definition: CombineHarvester_Evaluate.cc:252
-
ch::CombineHarvester::GetParameters
std::vector< ch::Parameter > GetParameters() const
Definition: CombineHarvester_Evaluate.cc:575
+
ch::CombineHarvester::GetParameters
std::vector< ch::Parameter > GetParameters() const
Definition: CombineHarvester_Evaluate.cc:581
ch::any_of
bool any_of(const Range &r, Predicate p)
Definition: Algorithm.h:17
ch::Systematic::name
std::string const & name() const
Definition: Systematic.h:21
ch::Systematic
Definition: Systematic.h:12
diff --git a/_combine_harvester___filters_8cc_source.html b/_combine_harvester___filters_8cc_source.html index bf33c364b08..c7bbc75cf33 100644 --- a/_combine_harvester___filters_8cc_source.html +++ b/_combine_harvester___filters_8cc_source.html @@ -399,7 +399,7 @@
CombineHarvester.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
ch::CombineHarvester::channel_set
std::set< std::string > channel_set()
Definition: CombineHarvester_Filters.cc:247
-
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:571
+
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:585
ch::CombineHarvester::bin_id
CombineHarvester & bin_id(std::vector< int > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:27
ch::CombineHarvester::bin_id_set
std::set< int > bin_id_set()
Definition: CombineHarvester_Filters.cc:202
Systematic.h
@@ -412,22 +412,22 @@
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
ch::FilterContainingRgx
void FilterContainingRgx(Input &in, Filter const &filter, Converter fn, bool cond)
Definition: Algorithm.h:49
ch::CombineHarvester::syst_name
CombineHarvester & syst_name(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:126
-
ch::Object::attribute
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:43
+
ch::Object::attribute
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:44
ch::CombineHarvester::mass
CombineHarvester & mass(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:97
ch::CombineHarvester::attr
CombineHarvester & attr(std::vector< std::string > const &vec, std::string attr_label, bool cond=true)
Definition: CombineHarvester_Filters.cc:111
ch::CombineHarvester::histograms
CombineHarvester & histograms()
Definition: CombineHarvester_Filters.cc:166
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::CombineHarvester::era_set
std::set< std::string > era_set()
Definition: CombineHarvester_Filters.cc:235
ch::Object::era
virtual std::string const & era() const
Definition: Object.h:29
-
ch::CombineHarvester::SetFromObs
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
Definition: CombineHarvester.h:564
+
ch::CombineHarvester::SetFromObs
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
Definition: CombineHarvester.h:578
Observation.h
ch::CombineHarvester::syst_type_set
std::set< std::string > syst_type_set()
Definition: CombineHarvester_Filters.cc:277
ch::CombineHarvester::process_rgx
CombineHarvester & process_rgx(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:48
-
ch::CombineHarvester::GetFlag
bool GetFlag(std::string const &flag) const
Definition: CombineHarvester.cc:72
+
ch::CombineHarvester::GetFlag
bool GetFlag(std::string const &flag) const
Definition: CombineHarvester.cc:74
ch::CombineHarvester::pdfs
CombineHarvester & pdfs()
Definition: CombineHarvester_Filters.cc:176
ch::CombineHarvester::analysis
CombineHarvester & analysis(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:55
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
-
ch::CombineHarvester::SetFromSysts
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
Definition: CombineHarvester.h:578
+
ch::CombineHarvester::SetFromSysts
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
Definition: CombineHarvester.h:592
ch::Systematic::name
std::string const & name() const
Definition: Systematic.h:21
ch::erase_if
void erase_if(Range &r, Predicate p)
Definition: Algorithm.h:12
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
diff --git a/_combine_harvester___python_8cc_source.html b/_combine_harvester___python_8cc_source.html index cef06897d30..95580dcb74d 100644 --- a/_combine_harvester___python_8cc_source.html +++ b/_combine_harvester___python_8cc_source.html @@ -404,168 +404,169 @@
302  .def("SetPdfBins", &CombineHarvester::SetPdfBins)
303  .def("SetGroup", &CombineHarvester::SetGroup)
304  .def("RemoveGroup", &CombineHarvester::RemoveGroup)
-
305  .def("RenameGroup", &CombineHarvester::RenameGroup)
-
306  // Evaluation
-
307  .def("GetRate", &CombineHarvester::GetRate)
-
308  .def("GetObservedRate", &CombineHarvester::GetObservedRate)
-
309  .def("GetUncertainty", Overload1_GetUncertainty)
-
310  .def("GetUncertainty", Overload2_GetUncertainty)
-
311  .def("GetShape", &CombineHarvester::GetShape)
-
312  .def("GetShapeWithUncertainty", Overload1_GetShapeWithUncertainty)
-
313  .def("GetShapeWithUncertainty", Overload2_GetShapeWithUncertainty)
-
314  .def("GetRateCovariance", &CombineHarvester::GetRateCovariance)
-
315  .def("GetRateCorrelation", &CombineHarvester::GetRateCorrelation)
-
316  .def("GetObservedShape", &CombineHarvester::GetObservedShape)
-
317  // Creation
-
318  .def("__AddObservations__", &CombineHarvester::AddObservations)
-
319  .def("__AddProcesses__", &CombineHarvester::AddProcesses)
-
320  .def("AddSystFromProc", &CombineHarvester::AddSystFromProc)
-
321  .def("ExtractShapes", &CombineHarvester::ExtractShapes)
-
322  .def("AddBinByBin", Overload_AddBinByBin)
-
323  .def("MergeBinErrors", &CombineHarvester::MergeBinErrors)
-
324  .def("InsertObservation", &CombineHarvester::InsertObservation)
-
325  .def("InsertProcess", &CombineHarvester::InsertProcess)
-
326  .def("InsertSystematic", &CombineHarvester::InsertSystematic)
-
327  .def("AddWorkspace", &CombineHarvester::AddWorkspace)
-
328  .def("ExtractPdfs", &CombineHarvester::ExtractPdfs)
-
329  ;
-
330 
-
331  py::class_<Object>("Object")
-
332  .def("set_bin", &Object::set_bin)
-
333  .def("bin", &Object::bin,
-
334  py::return_value_policy<py::copy_const_reference>())
-
335  .def("set_process", &Object::set_process)
-
336  .def("process",&Object::process,
-
337  py::return_value_policy<py::copy_const_reference>())
-
338  .def("set_analysis", &Object::set_analysis)
-
339  .def("analysis", &Object::analysis,
-
340  py::return_value_policy<py::copy_const_reference>())
-
341  .def("set_era", &Object::set_era)
-
342  .def("era", &Object::era,
-
343  py::return_value_policy<py::copy_const_reference>())
-
344  .def("set_channel", &Object::set_channel)
-
345  .def("channel", &Object::channel,
-
346  py::return_value_policy<py::copy_const_reference>())
-
347  .def("set_bin_id", &Object::set_bin_id)
-
348  .def("bin_id", &Object::bin_id)
-
349  .def("set_mass", &Object::set_mass)
-
350  .def("mass", &Object::mass,
-
351  py::return_value_policy<py::copy_const_reference>())
-
352  ;
-
353 
-
354  py::class_<Observation, py::bases<Object>>("Observation")
-
355  .def("set_rate", &Observation::set_rate)
-
356  .def("rate", &Observation::rate)
-
357  .def("set_shape", Overload_Obs_set_shape)
-
358  .def("ShapeAsTH1F", &Observation::ShapeAsTH1F)
-
359  .def(py::self_ns::str(py::self_ns::self))
-
360  ;
-
361 
-
362  py::class_<Process, py::bases<Object>>("Process")
-
363  .def("set_rate", &Process::set_rate)
-
364  .def("rate", &Process::rate)
-
365  .def("no_norm_rate", &Process::no_norm_rate)
-
366  .def("set_shape", Overload_Proc_set_shape)
-
367  .def("set_signal", &Process::set_signal)
-
368  .def("signal", &Process::signal)
-
369  .def("ShapeAsTH1F", &Process::ShapeAsTH1F)
-
370  .def(py::self_ns::str(py::self_ns::self))
-
371  ;
-
372 
-
373  py::class_<Systematic, py::bases<Object>>("Systematic")
-
374  .def("set_signal", &Systematic::set_signal)
-
375  .def("signal", &Systematic::signal)
-
376  .def("set_name", &Systematic::set_name)
-
377  .def("name", &Systematic::name,
-
378  py::return_value_policy<py::copy_const_reference>())
-
379  .def("set_type", &Systematic::set_type)
-
380  .def("type", &Systematic::type,
-
381  py::return_value_policy<py::copy_const_reference>())
-
382  .def("set_value_u", &Systematic::set_value_u)
-
383  .def("value_u", &Systematic::value_u)
-
384  .def("set_value_d", &Systematic::set_value_d)
-
385  .def("value_d", &Systematic::value_d)
-
386  .def("set_scale", &Systematic::set_scale)
-
387  .def("scale", &Systematic::scale)
-
388  .def("set_asymm", &Systematic::set_asymm)
-
389  .def("asymm", &Systematic::asymm)
-
390  .def("set_shapes", Overload_Syst_set_shapes)
-
391  .def(py::self_ns::str(py::self_ns::self))
-
392  ;
-
393 
-
394  py::class_<Parameter>("Parameter")
-
395  // .def("set_name", &Systematic::set_name)
-
396  .def("name", &Parameter::name,
-
397  py::return_value_policy<py::copy_const_reference>())
-
398  .def("set_val", &Parameter::set_val)
-
399  .def("val", &Parameter::val)
-
400  .def("set_err_u", &Parameter::set_err_u)
-
401  .def("err_u", &Parameter::err_u)
-
402  .def("set_err_d", &Parameter::set_err_d)
-
403  .def("err_d", &Parameter::err_d)
-
404  .def("set_range_u", &Parameter::set_range_u)
-
405  .def("range_u", &Parameter::range_u)
-
406  .def("set_range_d", &Parameter::set_range_d)
-
407  .def("set_range", &Parameter::set_range)
-
408  .def("range_d", &Parameter::range_d)
-
409  .def("set_frozen", &Parameter::set_frozen)
-
410  .def("frozen", &Parameter::frozen)
-
411  ;
-
412 
-
413  py::class_<CardWriter>("CardWriter", py::init<std::string, std::string>())
-
414  .def("WriteCards", &CardWriter::WriteCards)
-
415  .def("SetVerbosity", &CardWriter::SetVerbosity,
-
416  py::return_internal_reference<>())
-
417  .def("CreateDirectories", &CardWriter::CreateDirectories,
-
418  py::return_internal_reference<>())
-
419  .def("SetWildcardMasses", &CardWriter::SetWildcardMasses,
-
420  py::return_internal_reference<>())
-
421  ;
-
422 
-
423  py::def("CloneObs", CloneObsPy);
-
424  py::def("CloneProcs", CloneProcsPy);
-
425  py::def("CloneSysts", CloneSystsPy);
-
426  py::def("CloneProcsAndSysts", CloneProcsAndSystsPy);
-
427  py::def("SplitSyst", ch::SplitSyst);
-
428 
-
429  py::class_<BinByBinFactory>("BinByBinFactory")
-
430  .def("MergeBinErrors", &BinByBinFactory::MergeBinErrors)
-
431  .def("AddBinByBin", &BinByBinFactory::AddBinByBin)
-
432  .def("MergeAndAdd", &BinByBinFactory::MergeAndAdd)
-
433  .def("SetVerbosity", &BinByBinFactory::SetVerbosity,
-
434  py::return_internal_reference<>())
-
435  .def("SetAddThreshold", &BinByBinFactory::SetAddThreshold,
-
436  py::return_internal_reference<>())
-
437  .def("SetMergeThreshold", &BinByBinFactory::SetMergeThreshold,
-
438  py::return_internal_reference<>())
-
439  .def("SetPattern", &BinByBinFactory::SetPattern,
-
440  py::return_internal_reference<>())
-
441  .def("SetFixNorm", &BinByBinFactory::SetFixNorm,
-
442  py::return_internal_reference<>())
-
443  .def("SetPoissonErrors", &BinByBinFactory::SetPoissonErrors,
-
444  py::return_internal_reference<>())
-
445  ;
-
446 
-
447  py::class_<AutoRebin>("AutoRebin")
-
448  .def("Rebin", &AutoRebin::Rebin)
-
449  .def("SetVerbosity", &AutoRebin::SetVerbosity,
-
450  py::return_internal_reference<>())
-
451  .def("SetBinThreshold", &AutoRebin::SetBinThreshold,
-
452  py::return_internal_reference<>())
-
453  .def("SetBinUncertFraction", &AutoRebin::SetBinUncertFraction,
-
454  py::return_internal_reference<>())
-
455  .def("SetPerformRebin", &AutoRebin::SetPerformRebin,
-
456  py::return_internal_reference<>())
-
457  .def("SetRebinMode", &AutoRebin::SetRebinMode,
-
458  py::return_internal_reference<>())
-
459  ;
-
460 
-
461  py::def("TGraphFromTable", ch::TGraphFromTable);
-
462  py::def("MassesFromRange", ch::MassesFromRange, defaults_MassesFromRange());
-
463  py::def("ValsFromRange", ch::ValsFromRange, defaults_ValsFromRange());
-
464  py::def("SetStandardBinNames", ch::SetStandardBinNames, defaults_SetStandardBinNames());
-
465  py::def("ParseCombineWorkspace", ch::ParseCombineWorkspacePy);
-
466 }
+
305  .def("AddDatacardLineAtEnd", &CombineHarvester::AddDatacardLineAtEnd)
+
306  .def("ClearDatacardLinesAtEnd", &CombineHarvester::ClearDatacardLinesAtEnd)
+
307  // Evaluation
+
308  .def("GetRate", &CombineHarvester::GetRate)
+
309  .def("GetObservedRate", &CombineHarvester::GetObservedRate)
+
310  .def("GetUncertainty", Overload1_GetUncertainty)
+
311  .def("GetUncertainty", Overload2_GetUncertainty)
+
312  .def("GetShape", &CombineHarvester::GetShape)
+
313  .def("GetShapeWithUncertainty", Overload1_GetShapeWithUncertainty)
+
314  .def("GetShapeWithUncertainty", Overload2_GetShapeWithUncertainty)
+
315  .def("GetRateCovariance", &CombineHarvester::GetRateCovariance)
+
316  .def("GetRateCorrelation", &CombineHarvester::GetRateCorrelation)
+
317  .def("GetObservedShape", &CombineHarvester::GetObservedShape)
+
318  // Creation
+
319  .def("__AddObservations__", &CombineHarvester::AddObservations)
+
320  .def("__AddProcesses__", &CombineHarvester::AddProcesses)
+
321  .def("AddSystFromProc", &CombineHarvester::AddSystFromProc)
+
322  .def("ExtractShapes", &CombineHarvester::ExtractShapes)
+
323  .def("AddBinByBin", Overload_AddBinByBin)
+
324  .def("MergeBinErrors", &CombineHarvester::MergeBinErrors)
+
325  .def("InsertObservation", &CombineHarvester::InsertObservation)
+
326  .def("InsertProcess", &CombineHarvester::InsertProcess)
+
327  .def("InsertSystematic", &CombineHarvester::InsertSystematic)
+
328  .def("AddWorkspace", &CombineHarvester::AddWorkspace)
+
329  .def("ExtractPdfs", &CombineHarvester::ExtractPdfs)
+
330  ;
+
331 
+
332  py::class_<Object>("Object")
+
333  .def("set_bin", &Object::set_bin)
+
334  .def("bin", &Object::bin,
+
335  py::return_value_policy<py::copy_const_reference>())
+
336  .def("set_process", &Object::set_process)
+
337  .def("process",&Object::process,
+
338  py::return_value_policy<py::copy_const_reference>())
+
339  .def("set_analysis", &Object::set_analysis)
+
340  .def("analysis", &Object::analysis,
+
341  py::return_value_policy<py::copy_const_reference>())
+
342  .def("set_era", &Object::set_era)
+
343  .def("era", &Object::era,
+
344  py::return_value_policy<py::copy_const_reference>())
+
345  .def("set_channel", &Object::set_channel)
+
346  .def("channel", &Object::channel,
+
347  py::return_value_policy<py::copy_const_reference>())
+
348  .def("set_bin_id", &Object::set_bin_id)
+
349  .def("bin_id", &Object::bin_id)
+
350  .def("set_mass", &Object::set_mass)
+
351  .def("mass", &Object::mass,
+
352  py::return_value_policy<py::copy_const_reference>())
+
353  ;
+
354 
+
355  py::class_<Observation, py::bases<Object>>("Observation")
+
356  .def("set_rate", &Observation::set_rate)
+
357  .def("rate", &Observation::rate)
+
358  .def("set_shape", Overload_Obs_set_shape)
+
359  .def("ShapeAsTH1F", &Observation::ShapeAsTH1F)
+
360  .def(py::self_ns::str(py::self_ns::self))
+
361  ;
+
362 
+
363  py::class_<Process, py::bases<Object>>("Process")
+
364  .def("set_rate", &Process::set_rate)
+
365  .def("rate", &Process::rate)
+
366  .def("no_norm_rate", &Process::no_norm_rate)
+
367  .def("set_shape", Overload_Proc_set_shape)
+
368  .def("set_signal", &Process::set_signal)
+
369  .def("signal", &Process::signal)
+
370  .def("ShapeAsTH1F", &Process::ShapeAsTH1F)
+
371  .def(py::self_ns::str(py::self_ns::self))
+
372  ;
+
373 
+
374  py::class_<Systematic, py::bases<Object>>("Systematic")
+
375  .def("set_signal", &Systematic::set_signal)
+
376  .def("signal", &Systematic::signal)
+
377  .def("set_name", &Systematic::set_name)
+
378  .def("name", &Systematic::name,
+
379  py::return_value_policy<py::copy_const_reference>())
+
380  .def("set_type", &Systematic::set_type)
+
381  .def("type", &Systematic::type,
+
382  py::return_value_policy<py::copy_const_reference>())
+
383  .def("set_value_u", &Systematic::set_value_u)
+
384  .def("value_u", &Systematic::value_u)
+
385  .def("set_value_d", &Systematic::set_value_d)
+
386  .def("value_d", &Systematic::value_d)
+
387  .def("set_scale", &Systematic::set_scale)
+
388  .def("scale", &Systematic::scale)
+
389  .def("set_asymm", &Systematic::set_asymm)
+
390  .def("asymm", &Systematic::asymm)
+
391  .def("set_shapes", Overload_Syst_set_shapes)
+
392  .def(py::self_ns::str(py::self_ns::self))
+
393  ;
+
394 
+
395  py::class_<Parameter>("Parameter")
+
396  // .def("set_name", &Systematic::set_name)
+
397  .def("name", &Parameter::name,
+
398  py::return_value_policy<py::copy_const_reference>())
+
399  .def("set_val", &Parameter::set_val)
+
400  .def("val", &Parameter::val)
+
401  .def("set_err_u", &Parameter::set_err_u)
+
402  .def("err_u", &Parameter::err_u)
+
403  .def("set_err_d", &Parameter::set_err_d)
+
404  .def("err_d", &Parameter::err_d)
+
405  .def("set_range_u", &Parameter::set_range_u)
+
406  .def("range_u", &Parameter::range_u)
+
407  .def("set_range_d", &Parameter::set_range_d)
+
408  .def("set_range", &Parameter::set_range)
+
409  .def("range_d", &Parameter::range_d)
+
410  .def("set_frozen", &Parameter::set_frozen)
+
411  .def("frozen", &Parameter::frozen)
+
412  ;
+
413 
+
414  py::class_<CardWriter>("CardWriter", py::init<std::string, std::string>())
+
415  .def("WriteCards", &CardWriter::WriteCards)
+
416  .def("SetVerbosity", &CardWriter::SetVerbosity,
+
417  py::return_internal_reference<>())
+
418  .def("CreateDirectories", &CardWriter::CreateDirectories,
+
419  py::return_internal_reference<>())
+
420  .def("SetWildcardMasses", &CardWriter::SetWildcardMasses,
+
421  py::return_internal_reference<>())
+
422  ;
+
423 
+
424  py::def("CloneObs", CloneObsPy);
+
425  py::def("CloneProcs", CloneProcsPy);
+
426  py::def("CloneSysts", CloneSystsPy);
+
427  py::def("CloneProcsAndSysts", CloneProcsAndSystsPy);
+
428  py::def("SplitSyst", ch::SplitSyst);
+
429 
+
430  py::class_<BinByBinFactory>("BinByBinFactory")
+
431  .def("MergeBinErrors", &BinByBinFactory::MergeBinErrors)
+
432  .def("AddBinByBin", &BinByBinFactory::AddBinByBin)
+
433  .def("MergeAndAdd", &BinByBinFactory::MergeAndAdd)
+
434  .def("SetVerbosity", &BinByBinFactory::SetVerbosity,
+
435  py::return_internal_reference<>())
+
436  .def("SetAddThreshold", &BinByBinFactory::SetAddThreshold,
+
437  py::return_internal_reference<>())
+
438  .def("SetMergeThreshold", &BinByBinFactory::SetMergeThreshold,
+
439  py::return_internal_reference<>())
+
440  .def("SetPattern", &BinByBinFactory::SetPattern,
+
441  py::return_internal_reference<>())
+
442  .def("SetFixNorm", &BinByBinFactory::SetFixNorm,
+
443  py::return_internal_reference<>())
+
444  .def("SetPoissonErrors", &BinByBinFactory::SetPoissonErrors,
+
445  py::return_internal_reference<>())
+
446  ;
+
447 
+
448  py::class_<AutoRebin>("AutoRebin")
+
449  .def("Rebin", &AutoRebin::Rebin)
+
450  .def("SetVerbosity", &AutoRebin::SetVerbosity,
+
451  py::return_internal_reference<>())
+
452  .def("SetBinThreshold", &AutoRebin::SetBinThreshold,
+
453  py::return_internal_reference<>())
+
454  .def("SetBinUncertFraction", &AutoRebin::SetBinUncertFraction,
+
455  py::return_internal_reference<>())
+
456  .def("SetPerformRebin", &AutoRebin::SetPerformRebin,
+
457  py::return_internal_reference<>())
+
458  .def("SetRebinMode", &AutoRebin::SetRebinMode,
+
459  py::return_internal_reference<>())
+
460  ;
+
461 
+
462  py::def("TGraphFromTable", ch::TGraphFromTable);
+
463  py::def("MassesFromRange", ch::MassesFromRange, defaults_MassesFromRange());
+
464  py::def("ValsFromRange", ch::ValsFromRange, defaults_ValsFromRange());
+
465  py::def("SetStandardBinNames", ch::SetStandardBinNames, defaults_SetStandardBinNames());
+
466  py::def("ParseCombineWorkspace", ch::ParseCombineWorkspacePy);
+
467 }
FilterObsPy
void FilterObsPy(ch::CombineHarvester &cb, boost::python::object func)
Definition: CombineHarvester_Python.cc:35
Overload_Syst_set_shapes
void(Systematic::* Overload_Syst_set_shapes)(TH1 const &, TH1 const &, TH1 const &)
Definition: CombineHarvester_Python.cc:158
CloneProcsAndSystsPy
void CloneProcsAndSystsPy(ch::CombineHarvester &src, ch::CombineHarvester &dest, boost::python::object func)
Definition: CombineHarvester_Python.cc:108
@@ -579,7 +580,7 @@
ch::SplitSyst
void SplitSyst(ch::CombineHarvester &cb, std::string const &syst_in, std::string const &split1, std::string const &split2, double val1, double val2)
Replace all instances of an existing systematic with two copies having modified values.
Definition: CopyTools.cc:9
ForEachSystPy
void ForEachSystPy(ch::CombineHarvester &cb, boost::python::object func)
Definition: CombineHarvester_Python.cc:70
ch::CloneSysts
void CloneSysts(ch::CombineHarvester &src, ch::CombineHarvester &dest, Function func)
Duplicate Systematic objects in one instance, which are then modified by a user-supplied function...
Definition: CopyTools.h:60
-
ch::ParseCombineWorkspacePy
void ParseCombineWorkspacePy(CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
Definition: ParseCombineWorkspace.cc:14
+
ch::ParseCombineWorkspacePy
void ParseCombineWorkspacePy(CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
Definition: ParseCombineWorkspace.cc:16
Overload1_GetShapeWithUncertainty
TH1F(CombineHarvester::* Overload1_GetShapeWithUncertainty)(void)
Definition: CombineHarvester_Python.cc:137
convert_cpp_map_to_py_dict
Convert a C++ map to a python dict.
Definition: CombineHarvester_Python.h:71
convert_cpp_set_to_py_list
Convert a C++ set to a python list.
Definition: CombineHarvester_Python.h:59
@@ -589,9 +590,9 @@
convert_cpp_root_to_py_root
Covert a C++ ROOT type to a PyROOT type.
Definition: CombineHarvester_Python.h:34
CombineHarvester.h
CopyTools.h
-
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:623
+
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:637
ch::CardWriter
Automates the writing of datacards into directory structures.
Definition: CardWriter.h:50
-
ch::MassesFromRange
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
Definition: Utilities.cc:248
+
ch::MassesFromRange
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
Definition: Utilities.cc:249
AutoRebin.h
BinByBin.h
ch::TGraphFromTable
TGraph TGraphFromTable(std::string filename, std::string const &x_column, std::string const &y_column)
Definition: Utilities.cc:121
@@ -603,16 +604,16 @@
FilterAllPy
void FilterAllPy(ch::CombineHarvester &cb, boost::python::object func)
Definition: CombineHarvester_Python.cc:28
Overload_Proc_set_shape
void(Process::* Overload_Proc_set_shape)(TH1 const &, bool)
Definition: CombineHarvester_Python.cc:155
ForEachObsPy
void ForEachObsPy(ch::CombineHarvester &cb, boost::python::object func)
Definition: CombineHarvester_Python.cc:56
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
Overload2_WriteDatacard
void(CombineHarvester::* Overload2_WriteDatacard)(std::string const &)
Definition: CombineHarvester_Python.cc:128
-
ch::CombineHarvester::FilterAll
CombineHarvester & FilterAll(Function func)
Definition: CombineHarvester.h:607
+
ch::CombineHarvester::FilterAll
CombineHarvester & FilterAll(Function func)
Definition: CombineHarvester.h:621
ParseCombineWorkspace.h
Utilities.h
Parameter.h
ch::Observation
Definition: Observation.h:12
-
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:280
+
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:281
ch::CloneProcsAndSysts
void CloneProcsAndSysts(ch::CombineHarvester &src, ch::CombineHarvester &dest, Function func)
Duplicate the Process and Systematic objects in one instance, which are then modified by a user-suppl...
Definition: CopyTools.h:93
-
ch::CombineHarvester::FilterObs
CombineHarvester & FilterObs(Function func)
Definition: CombineHarvester.h:615
+
ch::CombineHarvester::FilterObs
CombineHarvester & FilterObs(Function func)
Definition: CombineHarvester.h:629
Overload2_GetShapeWithUncertainty
TH1F(CombineHarvester::* Overload2_GetShapeWithUncertainty)(RooFitResult const &, unsigned)
Definition: CombineHarvester_Python.cc:140
ForEachProcPy
void ForEachProcPy(ch::CombineHarvester &cb, boost::python::object func)
Definition: CombineHarvester_Python.cc:63
Overload2_ParseDatacard
int(CombineHarvester::* Overload2_ParseDatacard)(std::string const &, std::string)
Definition: CombineHarvester_Python.cc:122
@@ -624,15 +625,15 @@
ch::BinByBinFactory
Merges bin uncertainties and creates bin-by-bin statistical uncertainties.
Definition: BinByBin.h:21
Overload2_GetUncertainty
double(CombineHarvester::* Overload2_GetUncertainty)(RooFitResult const &, unsigned)
Definition: CombineHarvester_Python.cc:134
ch::Parameter
Definition: Parameter.h:12
-
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:585
-
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:602
+
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:599
+
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:616
CloneObsPy
void CloneObsPy(ch::CombineHarvester &src, ch::CombineHarvester &dest, boost::python::object func)
Definition: CombineHarvester_Python.cc:84
ForEachObjPy
void ForEachObjPy(ch::CombineHarvester &cb, boost::python::object func)
Definition: CombineHarvester_Python.cc:77
ch::Object
Definition: Object.h:8
-
ch::CombineHarvester::FilterSysts
CombineHarvester & FilterSysts(Function func)
Definition: CombineHarvester.h:630
-
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:597
+
ch::CombineHarvester::FilterSysts
CombineHarvester & FilterSysts(Function func)
Definition: CombineHarvester.h:644
+
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:611
Overload1_GetParameter
ch::Parameter *(CombineHarvester::* Overload1_GetParameter)(std::string const &name)
Definition: CombineHarvester_Python.cc:146
-
ch::Process
Definition: Process.h:14
+
ch::Process
Definition: Process.h:15
Overload_Obs_set_shape
void(Observation::* Overload_Obs_set_shape)(TH1 const &, bool)
Definition: CombineHarvester_Python.cc:152
CardWriter.h
Overload1_UpdateParameters
void(CombineHarvester::* Overload1_UpdateParameters)(RooFitResult const &)
Definition: CombineHarvester_Python.cc:143
diff --git a/_copy_tools_8cc_source.html b/_copy_tools_8cc_source.html index 36dcb285230..3d15abd6fa3 100644 --- a/_copy_tools_8cc_source.html +++ b/_copy_tools_8cc_source.html @@ -124,7 +124,7 @@
22 }
ch::Systematic::set_name
void set_name(std::string const &name)
Definition: Systematic.h:20
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::SplitSyst
void SplitSyst(ch::CombineHarvester &cb, std::string const &syst_in, std::string const &split1, std::string const &split2, double val1, double val2)
Replace all instances of an existing systematic with two copies having modified values.
Definition: CopyTools.cc:9
ch::CloneSysts
void CloneSysts(ch::CombineHarvester &src, ch::CombineHarvester &dest, Function func)
Duplicate Systematic objects in one instance, which are then modified by a user-supplied function...
Definition: CopyTools.h:60
CombineHarvester.h
diff --git a/_copy_tools_8h_source.html b/_copy_tools_8h_source.html index 92ce4b54483..d8652c08138 100644 --- a/_copy_tools_8h_source.html +++ b/_copy_tools_8h_source.html @@ -162,15 +162,15 @@
CombineHarvester.h
ch::CombineHarvester::InsertProcess
void InsertProcess(ch::Process const &proc)
Definition: CombineHarvester_Creation.cc:249
ch
Definition: Algorithm.h:10
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
ch::CombineHarvester::InsertObservation
void InsertObservation(ch::Observation const &obs)
Definition: CombineHarvester_Creation.cc:245
Object.h
ch::Observation
Definition: Observation.h:12
ch::CloneProcsAndSysts
void CloneProcsAndSysts(ch::CombineHarvester &src, ch::CombineHarvester &dest, Function func)
Duplicate the Process and Systematic objects in one instance, which are then modified by a user-suppl...
Definition: CopyTools.h:93
ch::CloneProcs
void CloneProcs(ch::CombineHarvester &src, ch::CombineHarvester &dest, Function func)
Duplicate Process objects in one instance, which are then modified by a user-supplied function...
Definition: CopyTools.h:41
-
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:602
-
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:597
-
ch::Process
Definition: Process.h:14
+
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:616
+
ch::CombineHarvester::ForEachObs
void ForEachObs(Function func)
Definition: CombineHarvester.h:611
+
ch::Process
Definition: Process.h:15
ch::Systematic
Definition: Systematic.h:12
diff --git a/_hhh_systematics_8cc_source.html b/_hhh_systematics_8cc_source.html index 5cce725b663..6524229bf0d 100644 --- a/_hhh_systematics_8cc_source.html +++ b/_hhh_systematics_8cc_source.html @@ -412,7 +412,7 @@
310  }
311 }
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::syst::SystMap
Definition: Systematics.h:70
ch::syst::SystMapAsymm
Definition: Systematics.h:135
ch::syst::bin_id
Definition: Systematics.h:41
@@ -423,7 +423,7 @@
ch
Definition: Algorithm.h:10
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
Utilities.h
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::syst::channel
Definition: Systematics.h:26
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
ch::AddSystematics_hhh_tt
void AddSystematics_hhh_tt(CombineHarvester &cb, CombineHarvester src)
Definition: HhhSystematics.cc:235
@@ -431,7 +431,7 @@
ch::syst::era
Definition: Systematics.h:21
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
ch::syst::process
Definition: Systematics.h:36
-
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:638
+
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:652
ch::AddSystematics_hhh_et_mt
void AddSystematics_hhh_et_mt(CombineHarvester &cb, CombineHarvester src)
Definition: HhhSystematics.cc:19
diff --git a/_htt_systematics___m_s_s_m_legacy_8cc_source.html b/_htt_systematics___m_s_s_m_legacy_8cc_source.html index 91b1c029a75..e8e05328e91 100644 --- a/_htt_systematics___m_s_s_m_legacy_8cc_source.html +++ b/_htt_systematics___m_s_s_m_legacy_8cc_source.html @@ -267,25 +267,25 @@
165 }
ch::AddMSSMSystematics
void AddMSSMSystematics(CombineHarvester &cb, CombineHarvester src)
Definition: HttSystematics_MSSMLegacy.cc:18
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::syst::SystMap
Definition: Systematics.h:70
ch::syst::SystMapAsymm
Definition: Systematics.h:135
ch::syst::bin_id
Definition: Systematics.h:41
Process.h
HttSystematics.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
-
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:571
+
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:585
ch::Object::process
virtual std::string const & process() const
Definition: Object.h:20
ch
Definition: Algorithm.h:10
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
Utilities.h
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::syst::channel
Definition: Systematics.h:26
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
Systematics.h
ch::syst::era
Definition: Systematics.h:21
ch::syst::process
Definition: Systematics.h:36
-
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:638
+
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:652
diff --git a/_htt_systematics___m_s_s_m_update_8cc_source.html b/_htt_systematics___m_s_s_m_update_8cc_source.html index ec99f88b5d3..f55511317e0 100644 --- a/_htt_systematics___m_s_s_m_update_8cc_source.html +++ b/_htt_systematics___m_s_s_m_update_8cc_source.html @@ -835,7 +835,7 @@
735 
736 }
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::syst::SystMap
Definition: Systematics.h:70
ch::syst::SystMapAsymm
Definition: Systematics.h:135
ch::syst::bin_id
Definition: Systematics.h:41
@@ -843,21 +843,21 @@
HttSystematics.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
ch::AddMSSMUpdateSystematics_mm
void AddMSSMUpdateSystematics_mm(CombineHarvester &cb, CombineHarvester src)
Definition: HttSystematics_MSSMUpdate.cc:475
-
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:571
+
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:585
ch::AddMSSMUpdateSystematics_et_mt
void AddMSSMUpdateSystematics_et_mt(CombineHarvester &cb, CombineHarvester src)
Definition: HttSystematics_MSSMUpdate.cc:18
ch::Object::process
virtual std::string const & process() const
Definition: Object.h:20
ch
Definition: Algorithm.h:10
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
Utilities.h
ch::AddMSSMUpdateSystematics_tt
void AddMSSMUpdateSystematics_tt(CombineHarvester &cb, CombineHarvester src)
Definition: HttSystematics_MSSMUpdate.cc:589
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::syst::channel
Definition: Systematics.h:26
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
Systematics.h
ch::syst::era
Definition: Systematics.h:21
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
ch::syst::process
Definition: Systematics.h:36
-
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:638
+
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:652
ch::AddMSSMUpdateSystematics_em
void AddMSSMUpdateSystematics_em(CombineHarvester &cb, CombineHarvester src)
Definition: HttSystematics_MSSMUpdate.cc:342
diff --git a/_htt_systematics___s_m_legacy_8cc_source.html b/_htt_systematics___s_m_legacy_8cc_source.html index 7fe169207dc..6cdcac8e0ef 100644 --- a/_htt_systematics___s_m_legacy_8cc_source.html +++ b/_htt_systematics___s_m_legacy_8cc_source.html @@ -1091,7 +1091,7 @@
989 }
990 }
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::syst::SystMap
Definition: Systematics.h:70
ch::syst::SystMapAsymm
Definition: Systematics.h:135
ch::AddSystematics_tt
void AddSystematics_tt(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:860
@@ -1107,7 +1107,7 @@
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
ch::AddSystematics_ee_mm
void AddSystematics_ee_mm(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:18
Utilities.h
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::AddSystematics_em
void AddSystematics_em(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:222
ch::CombineHarvester::process_rgx
CombineHarvester & process_rgx(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:48
ch::syst::channel
Definition: Systematics.h:26
@@ -1116,7 +1116,7 @@
ch::syst::era
Definition: Systematics.h:21
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
ch::syst::process
Definition: Systematics.h:36
-
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:638
+
ch::CombineHarvester::AddSyst
void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)
Definition: CombineHarvester.h:652
diff --git a/_m_s_s_m_yield_table_8cpp_source.html b/_m_s_s_m_yield_table_8cpp_source.html index 62bc1c15b6b..2e560375db7 100644 --- a/_m_s_s_m_yield_table_8cpp_source.html +++ b/_m_s_s_m_yield_table_8cpp_source.html @@ -411,7 +411,7 @@
main
int main(int argc, char *argv[])
Definition: MSSMYieldTable.cpp:33
ch::CombineHarvester
Definition: CombineHarvester.h:30
BkgInfo::BkgInfo
BkgInfo(string const &l, vector< string > const &p)
Definition: MSSMYieldTable.cpp:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::CombineHarvester::GetRate
double GetRate()
Definition: CombineHarvester_Evaluate.cc:272
ColInfo::label
string label
Definition: MSSMYieldTable.cpp:19
ch::CombineHarvester::ParseDatacard
int ParseDatacard(std::string const &filename, std::string const &analysis, std::string const &era, std::string const &channel, int bin_id, std::string const &mass)
Definition: CombineHarvester_Datacards.cc:54
@@ -422,19 +422,19 @@
ColInfo::cats_str
vector< string > cats_str
Definition: MSSMYieldTable.cpp:20
CombineHarvester.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
-
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:23
+
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:24
BkgInfo::label
string label
Definition: MSSMYieldTable.cpp:28
-
ch::CombineHarvester::GetObservedRate
double GetObservedRate()
Definition: CombineHarvester_Evaluate.cc:418
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
+
ch::CombineHarvester::GetObservedRate
double GetObservedRate()
Definition: CombineHarvester_Evaluate.cc:425
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
BkgInfo
Definition: MSSMYieldTable.cpp:27
Utilities.h
ColInfo::cats_int
vector< int > cats_int
Definition: MSSMYieldTable.cpp:21
-
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:585
+
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:599
TFileIO.h
-
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:536
-
ch::Process
Definition: Process.h:14
+
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:542
+
ch::Process
Definition: Process.h:15
ColInfo
Definition: MSSMYieldTable.cpp:18
-
ch::Process::rate
double rate() const
Definition: Process.h:24
+
ch::Process::rate
double rate() const
Definition: Process.h:25
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
ch::CombineHarvester::channel
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:83
ColInfo::era
string era
Definition: MSSMYieldTable.cpp:22
diff --git a/_morph_functions_8cc_source.html b/_morph_functions_8cc_source.html index cd483cdc280..21dc53d25d1 100644 --- a/_morph_functions_8cc_source.html +++ b/_morph_functions_8cc_source.html @@ -776,16 +776,16 @@
ch::CombineHarvester::GetShape
TH1F GetShape()
Definition: CombineHarvester_Evaluate.cc:277
ch::BuildRooMorphing
void BuildRooMorphing(RooWorkspace &ws, CombineHarvester &cb, std::string const &bin, std::string const &process, RooAbsReal &mass_var, std::string norm_postfix, bool allow_morph, bool verbose, bool force_template_limit=false, TFile *file=nullptr)
[part1]
Definition: MorphFunctions.cc:20
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::MakeMorphDebugPlots
void MakeMorphDebugPlots(RooMorphingPdf *pdf, RooAbsReal *mass, std::vector< double > const &masses, TFile *f, TH1 *ref_bins=nullptr)
Definition: MorphFunctions.cc:626
ch::Object::set_mass
virtual void set_mass(std::string const &mass)
Definition: Object.h:37
ch::CombineHarvester::syst_type
CombineHarvester & syst_type(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:136
ch::Systematic::type
std::string const & type() const
Definition: Systematic.h:24
-
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:426
+
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:433
ch::Systematic::asymm
bool asymm() const
Definition: Systematic.h:36
-
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:571
-
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:23
-
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:623
+
ch::CombineHarvester::SetFromProcs
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
Definition: CombineHarvester.h:585
+
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:24
+
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:637
FNERROR
#define FNERROR(x)
Definition: Logging.h:9
ch::Object::process
virtual std::string const & process() const
Definition: Object.h:20
ch
Definition: Algorithm.h:10
@@ -794,20 +794,20 @@
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
MorphFunctions.h
ch::RebinHist
TH1F RebinHist(TH1F const &hist)
Definition: Utilities.cc:170
-
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:592
+
ch::CombineHarvester::ForEachProc
void ForEachProc(Function func)
Definition: CombineHarvester.h:606
ch::CombineHarvester::mass
CombineHarvester & mass(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:97
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::Systematic::value_d
double value_d() const
Definition: Systematic.h:30
ch::Systematic::value_u
double value_u() const
Definition: Systematic.h:27
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
-
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:602
-
ch::CombineHarvester::FilterSysts
CombineHarvester & FilterSysts(Function func)
Definition: CombineHarvester.h:630
-
ch::Process
Definition: Process.h:14
+
ch::CombineHarvester::ForEachSyst
void ForEachSyst(Function func)
Definition: CombineHarvester.h:616
+
ch::CombineHarvester::FilterSysts
CombineHarvester & FilterSysts(Function func)
Definition: CombineHarvester.h:644
+
ch::Process
Definition: Process.h:15
Logging.h
ch::Systematic::name
std::string const & name() const
Definition: Systematic.h:21
ch::syst::process
Definition: Systematics.h:36
ch::Systematic
Definition: Systematic.h:12
-
ch::Process::set_shape
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:59
+
ch::Process::set_shape
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:69
diff --git a/_object_8h_source.html b/_object_8h_source.html index 56af09e0f71..127991e8c2f 100644 --- a/_object_8h_source.html +++ b/_object_8h_source.html @@ -141,26 +141,28 @@
39 
40  virtual void set_attribute(std::string const& attr_label, std::string const& attr_value);
41  virtual void delete_attribute(std::string const& attr_label) { attributes_.erase(attr_label); }
-
42  virtual std::map<std::string,std::string> const& all_attributes() const { return attributes_;}
-
43  virtual std::string const attribute(std::string const& attr_label) const { return attributes_.count(attr_label) >0 ? attributes_.at(attr_label) : "" ; }
-
44 
-
45  private:
-
46  std::string bin_;
-
47  std::string process_;
-
48  bool signal_;
-
49  std::string analysis_;
-
50  std::string era_;
-
51  std::string channel_;
-
52  int bin_id_;
-
53  std::string mass_;
-
54  std::map<std::string,std::string> attributes_;
-
55  friend void swap(Object& first, Object& second);
-
56 };
-
57 }
-
58 
-
59 #endif
+
42  virtual void set_all_attributes(std::map<std::string,std::string> const& attrs_) { attributes_ = attrs_;}
+
43  virtual std::map<std::string,std::string> const& all_attributes() const { return attributes_;}
+
44  virtual std::string const attribute(std::string const& attr_label) const { return attributes_.count(attr_label) >0 ? attributes_.at(attr_label) : "" ; }
+
45 
+
46  private:
+
47  std::string bin_;
+
48  std::string process_;
+
49  bool signal_;
+
50  std::string analysis_;
+
51  std::string era_;
+
52  std::string channel_;
+
53  int bin_id_;
+
54  std::string mass_;
+
55  std::map<std::string,std::string> attributes_;
+
56  friend void swap(Object& first, Object& second);
+
57 };
+
58 }
+
59 
+
60 #endif
ch::Object::analysis
virtual std::string const & analysis() const
Definition: Object.h:26
ch::Object::swap
friend void swap(Object &first, Object &second)
Definition: Object.cc:18
+
ch::Object::set_all_attributes
virtual void set_all_attributes(std::map< std::string, std::string > const &attrs_)
Definition: Object.h:42
ch::Object::set_signal
void set_signal(bool const &signal)
Definition: Object.h:22
ch::Object::set_bin_id
virtual void set_bin_id(int const &bin_id)
Definition: Object.h:34
ch::Object::set_process
virtual void set_process(std::string const &process)
Definition: Object.h:19
@@ -175,14 +177,14 @@
ch::Object::operator=
Object & operator=(Object other)
Definition: Object.cc:63
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
ch::Object::set_bin
virtual void set_bin(std::string const &bin)
Definition: Object.h:16
-
ch::Object::attribute
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:43
+
ch::Object::attribute
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:44
ch::Object::signal
bool signal() const
Definition: Object.h:23
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::Object::era
virtual std::string const & era() const
Definition: Object.h:29
ch::syst::channel
Definition: Systematics.h:26
ch::Object::delete_attribute
virtual void delete_attribute(std::string const &attr_label)
Definition: Object.h:41
ch::Object
Definition: Object.h:8
-
ch::Object::all_attributes
virtual std::map< std::string, std::string > const & all_attributes() const
Definition: Object.h:42
+
ch::Object::all_attributes
virtual std::map< std::string, std::string > const & all_attributes() const
Definition: Object.h:43
ch::Object::set_era
virtual void set_era(std::string const &era)
Definition: Object.h:28
ch::syst::era
Definition: Systematics.h:21
ch::syst::process
Definition: Systematics.h:36
diff --git a/_parse_combine_workspace_8cc.html b/_parse_combine_workspace_8cc.html index 1185ea1779d..d0d57af2f90 100644 --- a/_parse_combine_workspace_8cc.html +++ b/_parse_combine_workspace_8cc.html @@ -104,6 +104,7 @@
#include "CombineHarvester/CombineTools/interface/ParseCombineWorkspace.h"
+#include "HiggsAnalysis/CombinedLimit/interface/CMSHistErrorPropagator.h"
#include <iostream>
#include <string>
#include <vector>
@@ -112,6 +113,7 @@ #include "RooCategory.h"
#include "RooAddPdf.h"
#include "RooProdPdf.h"
+#include "RooRealSumPdf.h"
#include "RooStats/ModelConfig.h"
#include "CombineHarvester/CombineTools/interface/Logging.h"
@@ -128,8 +130,8 @@   void ch::ParseCombineWorkspace (CombineHarvester &cb, RooWorkspace &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)   -RooAddPdf * ch::FindAddPdf (RooAbsPdf *input) -  +RooAbsReal * ch::FindAddPdf (RooAbsReal *input) + 
diff --git a/_parse_combine_workspace_8cc.js b/_parse_combine_workspace_8cc.js index d1941a2c7f9..de62b68c6f1 100644 --- a/_parse_combine_workspace_8cc.js +++ b/_parse_combine_workspace_8cc.js @@ -2,5 +2,5 @@ var _parse_combine_workspace_8cc = [ [ "ParseCombineWorkspacePy", "_parse_combine_workspace_8cc.html#af7bcceb32c2f4a82fe1de32a93d0dfa3", null ], [ "ParseCombineWorkspace", "_parse_combine_workspace_8cc.html#a5ae8a88e9e0d2120deec06e553a525f6", null ], - [ "FindAddPdf", "_parse_combine_workspace_8cc.html#a0d8871a3c13b62ac6fefeb9a87b5e44a", null ] + [ "FindAddPdf", "_parse_combine_workspace_8cc.html#a5a4aae941cd175bf6764ad6789b4df8c", null ] ]; \ No newline at end of file diff --git a/_parse_combine_workspace_8cc_source.html b/_parse_combine_workspace_8cc_source.html index fc992c93ada..bf7739e811e 100644 --- a/_parse_combine_workspace_8cc_source.html +++ b/_parse_combine_workspace_8cc_source.html @@ -101,131 +101,163 @@
Go to the documentation of this file.
-
2 #include <iostream>
-
3 #include <string>
-
4 #include <vector>
-
5 #include "RooWorkspace.h"
-
6 #include "RooSimultaneous.h"
-
7 #include "RooCategory.h"
-
8 #include "RooAddPdf.h"
-
9 #include "RooProdPdf.h"
-
10 #include "RooStats/ModelConfig.h"
- -
12 
-
13 namespace ch {
-
14 void ParseCombineWorkspacePy(CombineHarvester& cb, RooWorkspace const& ws,
-
15  std::string const& modelcfg,
-
16  std::string const& data, bool verbose) {
-
17  ParseCombineWorkspace(cb, const_cast<RooWorkspace&>(ws), modelcfg, data, verbose);
-
18 }
-
19 
-
20 void ParseCombineWorkspace(CombineHarvester& cb, RooWorkspace& ws,
-
21  std::string const& modelcfg_name,
-
22  std::string const& data_name, bool verbose) {
-
23  bool v = verbose;
-
24 
-
25  RooStats::ModelConfig* cfg =
-
26  dynamic_cast<RooStats::ModelConfig*>(ws.genobj(modelcfg_name.c_str()));
-
27  if (!cfg) {
-
28  throw std::runtime_error(
-
29  FNERROR("Could not get ModelConfig from workspace"));
-
30  }
-
31  RooSimultaneous* pdf = dynamic_cast<RooSimultaneous*>(cfg->GetPdf());
-
32  if (!pdf) {
-
33  throw std::runtime_error(FNERROR("PDF is not a RooSimultaneous"));
-
34  }
-
35 
-
36  std::vector<std::string> cats;
+
2 #include "HiggsAnalysis/CombinedLimit/interface/CMSHistErrorPropagator.h"
+
3 #include <iostream>
+
4 #include <string>
+
5 #include <vector>
+
6 #include "RooWorkspace.h"
+
7 #include "RooSimultaneous.h"
+
8 #include "RooCategory.h"
+
9 #include "RooAddPdf.h"
+
10 #include "RooProdPdf.h"
+
11 #include "RooRealSumPdf.h"
+
12 #include "RooStats/ModelConfig.h"
+ +
14 
+
15 namespace ch {
+
16 void ParseCombineWorkspacePy(CombineHarvester& cb, RooWorkspace const& ws,
+
17  std::string const& modelcfg,
+
18  std::string const& data, bool verbose) {
+
19  ParseCombineWorkspace(cb, const_cast<RooWorkspace&>(ws), modelcfg, data, verbose);
+
20 }
+
21 
+
22 void ParseCombineWorkspace(CombineHarvester& cb, RooWorkspace& ws,
+
23  std::string const& modelcfg_name,
+
24  std::string const& data_name, bool verbose) {
+
25  bool v = verbose;
+
26 
+
27  RooStats::ModelConfig* cfg =
+
28  dynamic_cast<RooStats::ModelConfig*>(ws.genobj(modelcfg_name.c_str()));
+
29  if (!cfg) {
+
30  throw std::runtime_error(
+
31  FNERROR("Could not get ModelConfig from workspace"));
+
32  }
+
33  RooSimultaneous* pdf = dynamic_cast<RooSimultaneous*>(cfg->GetPdf());
+
34  if (!pdf) {
+
35  throw std::runtime_error(FNERROR("PDF is not a RooSimultaneous"));
+
36  }
37 
-
38  struct ProcInfo {
-
39  std::string bin;
-
40  std::string proc;
-
41  std::string pdf;
-
42  std::string norm;
-
43  };
-
44  std::map<std::string, std::vector<ProcInfo>> proc_infos;
-
45 
-
46  RooAbsData *data = ws.data(data_name.c_str());
-
47  // Hard-coded the category as "CMS_channel". Could deduce instead...
-
48  std::unique_ptr<TList> split(data->split(RooCategory("CMS_channel", "")));
-
49  for (int i = 0; i < split->GetSize(); ++i) {
-
50  RooAbsData *idat = dynamic_cast<RooAbsData*>(split->At(i));
-
51  cats.push_back(idat->GetName());
-
52  FNLOGC(std::cout, v) << "Found data for category: " << cats.back() << "\n";
-
53  ws.import(*idat);
-
54 
-
55  ch::Observation obs;
-
56  obs.set_bin(cats.back());
-
57  cb.InsertObservation(obs);
-
58 
-
59  RooAddPdf *ipdf = FindAddPdf(pdf->getPdf(cats.back().c_str()));
-
60  if (ipdf) {
-
61  FNLOGC(std::cout, v) << "Found RooAddPdf: " << ipdf->GetName() << "\n";
-
62  RooArgList const& coeffs = ipdf->coefList();
-
63  RooArgList const& pdfs = ipdf->pdfList();
-
64  if (coeffs.getSize() != pdfs.getSize()) {
-
65  throw std::runtime_error(FNERROR("This RooAddPdf is not extended!"));
-
66  }
-
67  for (int j = 0; j < coeffs.getSize(); ++j) {
-
68  RooAbsReal *jcoeff = dynamic_cast<RooAbsReal*>(coeffs.at(j));
-
69  RooAbsPdf *jpdf = dynamic_cast<RooAbsPdf*>(pdfs.at(j));
-
70  FNLOGC(std::cout, v) << "Component " << j << "\t" << jcoeff->GetName()
-
71  << "\t" << jpdf->GetName() << "\n";
-
72  ch::Process proc;
-
73  proc.set_bin(cats.back());
-
74  // Get the process name & signal flag from the pdf attributes that are
-
75  // set by text2workspace. Should really check they exist first...
-
76  proc.set_process(jpdf->getStringAttribute("combine.process"));
-
77  proc.set_rate(1.);
-
78  proc.set_signal(jpdf->getAttribute("combine.signal"));
-
79  proc_infos[proc.bin()].push_back(
-
80  {proc.bin(), proc.process(), jpdf->GetName(), jcoeff->GetName()});
-
81  cb.InsertProcess(proc);
-
82  }
-
83  }
-
84  }
-
85  cb.AddWorkspace(ws);
-
86  cb.ExtractData(ws.GetName(), "$BIN");
-
87  // This loop is slow if we have have a lot of procs
-
88  // Better way would be to filter to each bin, then do all the procs for that
-
89  // bin
-
90  for (auto b : cb.bin_set()) {
-
91  auto cb_bin = cb.cp().bin({b});
-
92  for (auto const& pinfo: proc_infos[b]) {
-
93  cb_bin.cp().process({pinfo.proc}).ExtractPdfs(
-
94  cb, ws.GetName(), pinfo.pdf, pinfo.norm);
-
95  }
-
96  }
-
97 }
-
98 
-
99 RooAddPdf* FindAddPdf(RooAbsPdf* input) {
-
100  RooAddPdf *as_add = dynamic_cast<RooAddPdf*>(input);
-
101  if (as_add) return as_add;
-
102  RooProdPdf *as_prod = dynamic_cast<RooProdPdf*>(input);
-
103  if (as_prod) {
-
104  RooArgList const& comps = as_prod->pdfList();
-
105  for (int i = 0; i < comps.getSize(); ++i) {
-
106  RooAddPdf* try_add = FindAddPdf(dynamic_cast<RooAbsPdf*>(comps.at(i)));
-
107  if (try_add) return try_add;
-
108  }
-
109  }
-
110  return nullptr;
-
111 }
-
112 }
+
38  std::vector<std::string> cats;
+
39 
+
40  struct ProcInfo {
+
41  std::string bin;
+
42  std::string proc;
+
43  std::string pdf;
+
44  std::string norm;
+
45  };
+
46  std::map<std::string, std::vector<ProcInfo>> proc_infos;
+
47 
+
48  RooAbsData *data = ws.data(data_name.c_str());
+
49  // Hard-coded the category as "CMS_channel". Could deduce instead...
+
50  std::unique_ptr<TList> split(data->split(RooCategory("CMS_channel", "")));
+
51  for (int i = 0; i < split->GetSize(); ++i) {
+
52  RooAbsData *idat = dynamic_cast<RooAbsData*>(split->At(i));
+
53  cats.push_back(idat->GetName());
+
54  FNLOGC(std::cout, v) << "Found data for category: " << cats.back() << "\n";
+
55 
+
56  ch::Observation obs;
+
57  obs.set_bin(cats.back());
+
58  cb.InsertObservation(obs);
+
59 
+
60  bool delete_pdfs = false;
+
61 
+
62  RooAbsReal *ipdf = FindAddPdf(pdf->getPdf(cats.back().c_str()));
+
63  if (ipdf) {
+
64  std::unique_ptr<RooArgSet> pdf_obs(ipdf->getObservables(data->get()));
+
65  idat = idat->reduce(*pdf_obs);
+
66  ws.import(*idat);
+
67  RooAddPdf *ipdf_add = dynamic_cast<RooAddPdf*>(ipdf);
+
68  RooRealSumPdf *ipdf_sum = dynamic_cast<RooRealSumPdf*>(ipdf);
+
69  RooArgList const* coeffs = nullptr;
+
70  RooArgList const* pdfs = nullptr;
+
71  if (ipdf_add) {
+
72  FNLOGC(std::cout, v) << "Found RooAddPdf: " << ipdf_add->GetName() << "\n";
+
73  coeffs = &(ipdf_add->coefList());
+
74  pdfs = &(ipdf_add->pdfList());
+
75  if (coeffs->getSize() != pdfs->getSize()) {
+
76  throw std::runtime_error(FNERROR("This RooAddPdf is not extended!"));
+
77  }
+
78  }
+
79  if (ipdf_sum) {
+
80  FNLOGC(std::cout, v) << "Found RooRealSumPdf: " << ipdf_sum->GetName() << "\n";
+
81  coeffs = &(ipdf_sum->coefList());
+
82  pdfs = &(ipdf_sum->funcList());
+
83  if (coeffs->getSize() != pdfs->getSize()) {
+
84  throw std::runtime_error(FNERROR("This RooRealSumPdf is not extended!"));
+
85  }
+
86  if (pdfs->getSize() == 1) {
+
87  CMSHistErrorPropagator *err = dynamic_cast<CMSHistErrorPropagator*>(pdfs->at(0));
+
88  if (err) {
+
89  coeffs = &(err->coefList());
+
90  pdfs = new RooArgList(err->wrapperList());
+
91  delete_pdfs = true;
+
92  }
+
93  }
+
94  }
+
95  for (int j = 0; j < coeffs->getSize(); ++j) {
+
96  RooAbsReal *jcoeff = dynamic_cast<RooAbsReal*>(coeffs->at(j));
+
97  RooAbsReal *jpdf = dynamic_cast<RooAbsReal*>(pdfs->at(j));
+
98  FNLOGC(std::cout, v) << "Component " << j << "\t" << jcoeff->GetName()
+
99  << "\t" << jpdf->GetName() << "\n";
+
100  ch::Process proc;
+
101  proc.set_bin(cats.back());
+
102  // Get the process name & signal flag from the pdf attributes that are
+
103  // set by text2workspace. Should really check they exist first...
+
104  proc.set_process(jpdf->getStringAttribute("combine.process"));
+
105  proc.set_rate(1.);
+
106  proc.set_signal(jpdf->getAttribute("combine.signal"));
+
107  proc_infos[proc.bin()].push_back(
+
108  {proc.bin(), proc.process(), jpdf->GetName(), jcoeff->GetName()});
+
109  cb.InsertProcess(proc);
+
110  }
+
111  if (delete_pdfs) delete pdfs;
+
112  }
+
113  }
+
114  cb.AddWorkspace(ws);
+
115  cb.ExtractData(ws.GetName(), "$BIN");
+
116  // This loop is slow if we have have a lot of procs
+
117  // Better way would be to filter to each bin, then do all the procs for that
+
118  // bin
+
119  for (auto b : cb.bin_set()) {
+
120  auto cb_bin = cb.cp().bin({b});
+
121  for (auto const& pinfo: proc_infos[b]) {
+
122  cb_bin.cp().process({pinfo.proc}).ExtractPdfs(
+
123  cb, ws.GetName(), pinfo.pdf, pinfo.norm);
+
124  }
+
125  }
+
126 }
+
127 
+
128 RooAbsReal* FindAddPdf(RooAbsReal* input) {
+
129  RooAddPdf *as_add = dynamic_cast<RooAddPdf*>(input);
+
130  RooRealSumPdf *as_sum = dynamic_cast<RooRealSumPdf*>(input);
+
131  if (as_add) return as_add;
+
132  if (as_sum) return as_sum;
+
133  RooProdPdf *as_prod = dynamic_cast<RooProdPdf*>(input);
+
134  if (as_prod) {
+
135  RooArgList const& comps = as_prod->pdfList();
+
136  for (int i = 0; i < comps.getSize(); ++i) {
+
137  RooAbsReal* try_add = FindAddPdf(dynamic_cast<RooAbsReal*>(comps.at(i)));
+
138  if (try_add) return try_add;
+
139  }
+
140  }
+
141  return nullptr;
+
142 }
+
143 }
void ExtractData(std::string const &ws_name, std::string const &rule)
void set_signal(bool const &signal)
Definition: Object.h:22
virtual void set_process(std::string const &process)
Definition: Object.h:19
-
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
-
void ParseCombineWorkspacePy(CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
+
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
+
void ParseCombineWorkspacePy(CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
std::set< std::string > bin_set()
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
void InsertProcess(ch::Process const &proc)
-
void ParseCombineWorkspace(CombineHarvester &cb, RooWorkspace &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
-
void set_rate(double const &rate)
Definition: Process.h:23
+
void ParseCombineWorkspace(CombineHarvester &cb, RooWorkspace &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
+
void set_rate(double const &rate)
Definition: Process.h:24
void AddWorkspace(RooWorkspace const &ws, bool can_rename=false)
#define FNERROR(x)
Definition: Logging.h:9
virtual std::string const & process() const
Definition: Object.h:20
+
RooAbsReal * FindAddPdf(RooAbsReal *input)
Definition: Algorithm.h:10
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
void InsertObservation(ch::Observation const &obs)
@@ -234,8 +266,7 @@
#define FNLOGC(x, y)
Definition: Logging.h:14
virtual std::string const & bin() const
Definition: Object.h:17
-
RooAddPdf * FindAddPdf(RooAbsPdf *input)
- +
diff --git a/_parse_combine_workspace_8h.html b/_parse_combine_workspace_8h.html index 102c49a88ac..d90bb482458 100644 --- a/_parse_combine_workspace_8h.html +++ b/_parse_combine_workspace_8h.html @@ -120,8 +120,8 @@   void ch::ParseCombineWorkspacePy (CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)   -RooAddPdf * ch::FindAddPdf (RooAbsPdf *input) -  +RooAbsReal * ch::FindAddPdf (RooAbsReal *input) +  diff --git a/_parse_combine_workspace_8h.js b/_parse_combine_workspace_8h.js index 6fbae6c3971..fd4b33742ab 100644 --- a/_parse_combine_workspace_8h.js +++ b/_parse_combine_workspace_8h.js @@ -2,5 +2,5 @@ var _parse_combine_workspace_8h = [ [ "ParseCombineWorkspace", "_parse_combine_workspace_8h.html#a5ae8a88e9e0d2120deec06e553a525f6", null ], [ "ParseCombineWorkspacePy", "_parse_combine_workspace_8h.html#af7bcceb32c2f4a82fe1de32a93d0dfa3", null ], - [ "FindAddPdf", "_parse_combine_workspace_8h.html#a0d8871a3c13b62ac6fefeb9a87b5e44a", null ] + [ "FindAddPdf", "_parse_combine_workspace_8h.html#a5a4aae941cd175bf6764ad6789b4df8c", null ] ]; \ No newline at end of file diff --git a/_parse_combine_workspace_8h_source.html b/_parse_combine_workspace_8h_source.html index 4637d4ef8eb..8a49a1b4777 100644 --- a/_parse_combine_workspace_8h_source.html +++ b/_parse_combine_workspace_8h_source.html @@ -118,14 +118,14 @@
16  std::string const& modelcfg,
17  std::string const& data, bool verbose = false);
18 
-
19 RooAddPdf* FindAddPdf(RooAbsPdf* input);
+
19 RooAbsReal* FindAddPdf(RooAbsReal* input);
20 }
21 #endif
-
ch::ParseCombineWorkspacePy
void ParseCombineWorkspacePy(CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
Definition: ParseCombineWorkspace.cc:14
+
ch::ParseCombineWorkspacePy
void ParseCombineWorkspacePy(CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
Definition: ParseCombineWorkspace.cc:16
CombineHarvester.h
-
ch::ParseCombineWorkspace
void ParseCombineWorkspace(CombineHarvester &cb, RooWorkspace &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
Definition: ParseCombineWorkspace.cc:20
+
ch::ParseCombineWorkspace
void ParseCombineWorkspace(CombineHarvester &cb, RooWorkspace &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)
Definition: ParseCombineWorkspace.cc:22
+
ch::FindAddPdf
RooAbsReal * FindAddPdf(RooAbsReal *input)
Definition: ParseCombineWorkspace.cc:128
ch
Definition: Algorithm.h:10
-
ch::FindAddPdf
RooAddPdf * FindAddPdf(RooAbsPdf *input)
Definition: ParseCombineWorkspace.cc:99
diff --git a/_post_fit_shapes_8cpp_source.html b/_post_fit_shapes_8cpp_source.html index 41bf4b2922f..7f876852738 100644 --- a/_post_fit_shapes_8cpp_source.html +++ b/_post_fit_shapes_8cpp_source.html @@ -202,7 +202,7 @@
100 
101  // Drop any process that has no hist/data/pdf
102  cmb.FilterProcs([&](ch::Process * proc) {
-
103  bool no_shape = !proc->shape() && !proc->data() && !proc->pdf();
+
103  bool no_shape = !proc->shape() && !proc->data() && !proc->pdf();
104  if (no_shape) {
105  cout << "Filtering process with no shape:\n";
106  cout << ch::Process::PrintHeader << *proc << "\n";
@@ -334,27 +334,27 @@
232 
main
int main(int argc, char *argv[])
Definition: PostFitShapes.cpp:11
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::CombineHarvester::GetRate
double GetRate()
Definition: CombineHarvester_Evaluate.cc:272
-
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:53
+
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:63
ch::CombineHarvester::ParseDatacard
int ParseDatacard(std::string const &filename, std::string const &analysis, std::string const &era, std::string const &channel, int bin_id, std::string const &mass)
Definition: CombineHarvester_Datacards.cc:54
ch::CombineHarvester::backgrounds
CombineHarvester & backgrounds()
Definition: CombineHarvester_Filters.cc:156
ch::CombineHarvester::bin_set
std::set< std::string > bin_set()
Definition: CombineHarvester_Filters.cc:190
std
ch::CombineHarvester::process_set
std::set< std::string > process_set()
Definition: CombineHarvester_Filters.cc:214
-
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:426
+
ch::Process::pdf
RooAbsReal const * pdf() const
Definition: Process.h:60
+
ch::CombineHarvester::GetObservedShape
TH1F GetObservedShape()
Definition: CombineHarvester_Evaluate.cc:433
CombineHarvester.h
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
-
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:623
+
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:637
ch::CombineHarvester::bin
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:13
-
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:42
+
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:52
ch::CombineHarvester::GetShapeWithUncertainty
TH1F GetShapeWithUncertainty()
Definition: CombineHarvester_Evaluate.cc:103
-
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:131
-
ch::Process::pdf
RooAbsPdf const * pdf() const
Definition: Process.h:50
-
ch::CombineHarvester::SetPdfBins
void SetPdfBins(unsigned nbins)
Definition: CombineHarvester_Evaluate.cc:646
+
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:141
+
ch::CombineHarvester::SetPdfBins
void SetPdfBins(unsigned nbins)
Definition: CombineHarvester_Evaluate.cc:652
TFileIO.h
-
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:536
-
ch::Process
Definition: Process.h:14
+
ch::CombineHarvester::UpdateParameters
void UpdateParameters(std::vector< ch::Parameter > const &params)
Definition: CombineHarvester_Evaluate.cc:542
+
ch::Process
Definition: Process.h:15
ch::CombineHarvester::signals
CombineHarvester & signals()
Definition: CombineHarvester_Filters.cc:146
ch::WriteToTFile
void WriteToTFile(T *ptr, TFile *file, std::string const &path)
Definition: TFileIO.h:31
ch::CombineHarvester::GetUncertainty
double GetUncertainty()
Definition: CombineHarvester_Evaluate.cc:44
diff --git a/_process_8cc_source.html b/_process_8cc_source.html index 664b3d2952a..520356a220a 100644 --- a/_process_8cc_source.html +++ b/_process_8cc_source.html @@ -114,177 +114,187 @@
12  shape_(),
13  pdf_(nullptr),
14  data_(nullptr),
-
15  norm_(nullptr) {
-
16  }
-
17 
-
18 Process::~Process() { }
+
15  norm_(nullptr),
+
16  cached_obs_(nullptr),
+
17  cached_int_(nullptr) {
+
18  }
19 
-
20 void swap(Process& first, Process& second) {
-
21  using std::swap;
-
22  swap(static_cast<Object&>(first), static_cast<Object&>(second));
-
23  swap(first.rate_, second.rate_);
-
24  swap(first.shape_, second.shape_);
-
25  swap(first.pdf_, second.pdf_);
-
26  swap(first.data_, second.data_);
-
27  swap(first.norm_, second.norm_);
-
28 }
-
29 
-
30 Process::Process(Process const& other)
-
31  : Object(other),
-
32  rate_(other.rate_),
-
33  pdf_(other.pdf_),
-
34  data_(other.data_),
-
35  norm_(other.norm_) {
-
36  TH1 *h = nullptr;
-
37  if (other.shape_) {
-
38  h = static_cast<TH1*>(other.shape_->Clone());
-
39  h->SetDirectory(0);
-
40  }
-
41  shape_ = std::unique_ptr<TH1>(h);
-
42 }
-
43 
-
44 Process::Process(Process&& other)
-
45  : Object(),
-
46  rate_(0.0),
-
47  shape_(),
-
48  pdf_(nullptr),
-
49  data_(nullptr),
-
50  norm_(nullptr) {
-
51  swap(*this, other);
-
52 }
-
53 
-
54 Process& Process::operator=(Process other) {
-
55  swap(*this, other);
-
56  return (*this);
-
57 }
-
58 
-
59 void Process::set_shape(std::unique_ptr<TH1> shape, bool set_rate) {
-
60  // We were given a nullptr - this is fine, and so we're done
-
61  if (!shape) {
-
62  // This will safely release any existing TH1 held by shape_
-
63  shape_ = nullptr;
-
64  return;
-
65  }
-
66  // Otherwise we validate this new hist. First is to check that all bins have
-
67  // +ve values, otherwise the interpretation as a pdf is tricky
-
68  // for (int i = 1; i <= shape->GetNbinsX(); ++i) {
-
69  // if (shape->GetBinContent(i) < 0.) {
-
70  // throw std::runtime_error(FNERROR("TH1 has a bin with content < 0"));
-
71  // }
-
72  // }
-
73  // At this point we can safely move the shape in and take ownership
-
74  shape_ = std::move(shape);
-
75  // Ensure that root will not try and clean this up
-
76  shape_->SetDirectory(0);
-
77  if (set_rate) {
-
78  this->set_rate(shape_->Integral());
-
79  }
-
80  if (shape_->Integral() > 0.) shape_->Scale(1. / shape_->Integral());
-
81 }
-
82 
-
83 void Process::set_shape(TH1 const& shape, bool set_rate) {
-
84  set_shape(std::unique_ptr<TH1>(static_cast<TH1*>(shape.Clone())), set_rate);
-
85 }
-
86 
-
87 
-
88 std::unique_ptr<TH1> Process::ClonedShape() const {
-
89  if (!shape_) return std::unique_ptr<TH1>();
-
90  std::unique_ptr<TH1> res(static_cast<TH1 *>(shape_->Clone()));
-
91  res->SetDirectory(0);
-
92  return res;
-
93 }
-
94 
-
95 std::unique_ptr<TH1> Process::ClonedScaledShape() const {
-
96  if (!shape_) return std::unique_ptr<TH1>();
-
97  std::unique_ptr<TH1> res(ClonedShape());
-
98  res->Scale(this->no_norm_rate());
-
99  return res;
-
100 }
-
101 
-
102 TH1F Process::ShapeAsTH1F() const {
-
103  if (!shape_ && !data_) {
-
104  throw std::runtime_error(
-
105  FNERROR("Process object does not contain a shape"));
-
106  }
-
107  TH1F res;
-
108  if (this->shape()) {
-
109  // Need to get the shape as a concrete type (TH1F or TH1D)
-
110  // A nice way to do this is just to use TH1D::Copy into a fresh TH1F
-
111  TH1F const* test_f = dynamic_cast<TH1F const*>(this->shape());
-
112  TH1D const* test_d = dynamic_cast<TH1D const*>(this->shape());
-
113  if (test_f) {
-
114  test_f->Copy(res);
-
115  } else if (test_d) {
-
116  test_d->Copy(res);
-
117  } else {
-
118  throw std::runtime_error(FNERROR("TH1 shape is not a TH1F or a TH1D"));
-
119  }
-
120  } else if (this->data()) {
-
121  std::string var_name = this->data()->get()->first()->GetName();
-
122  TH1F *tmp = dynamic_cast<TH1F*>(this->data()->createHistogram(
-
123  var_name.c_str()));
-
124  res = *tmp;
-
125  delete tmp;
-
126  if (res.Integral() > 0.) res.Scale(1. / res.Integral());
-
127  }
-
128  return res;
-
129 }
-
130 
-
131 std::ostream& Process::PrintHeader(std::ostream& out) {
-
132  std::string line =
-
133  (boost::format(
-
134  "%-6s %-9s %-6s %-8s %-28s %-3i %-16s %-4i %-10.5g %-5i") %
-
135  "mass" % "analysis" % "era" % "channel" % "bin" % "id" % "process" %
-
136  "sig" % "rate" % "shape").str();
-
137  std::string div(line.length(), '-');
-
138  out << div << std::endl;
-
139  out << line << std::endl;
-
140  out << div << std::endl;
-
141  return out;
-
142 }
-
143 
-
144 std::ostream& operator<< (std::ostream &out, Process const& val) {
-
145  out << boost::format(
-
146  "%-6s %-9s %-6s %-8s %-28s %-3i %-16s %-4i %-10.5g %-5i") %
-
147  val.mass() % val.analysis() % val.era() % val.channel() %
-
148  val.bin() % val.bin_id() % val.process() % val.signal() %
-
149  val.rate() %
-
150  (bool(val.shape()) || bool(val.pdf()) || bool(val.data()));
+
20 Process::~Process() {
+
21  if (cached_int_) delete cached_int_;
+
22 }
+
23 
+
24 void swap(Process& first, Process& second) {
+
25  using std::swap;
+
26  swap(static_cast<Object&>(first), static_cast<Object&>(second));
+
27  swap(first.rate_, second.rate_);
+
28  swap(first.shape_, second.shape_);
+
29  swap(first.pdf_, second.pdf_);
+
30  swap(first.data_, second.data_);
+
31  swap(first.norm_, second.norm_);
+
32  swap(first.cached_obs_, second.cached_obs_);
+
33  swap(first.cached_int_, second.cached_int_);
+
34 }
+
35 
+
36 Process::Process(Process const& other)
+
37  : Object(other),
+
38  rate_(other.rate_),
+
39  pdf_(other.pdf_),
+
40  data_(other.data_),
+
41  norm_(other.norm_),
+
42  cached_obs_(other.cached_obs_),
+
43  cached_int_(nullptr) {
+
44  TH1 *h = nullptr;
+
45  if (other.shape_) {
+
46  h = static_cast<TH1*>(other.shape_->Clone());
+
47  h->SetDirectory(0);
+
48  }
+
49  shape_ = std::unique_ptr<TH1>(h);
+
50 }
+
51 
+
52 Process::Process(Process&& other)
+
53  : Object(),
+
54  rate_(0.0),
+
55  shape_(),
+
56  pdf_(nullptr),
+
57  data_(nullptr),
+
58  norm_(nullptr),
+
59  cached_obs_(nullptr),
+
60  cached_int_(nullptr) {
+
61  swap(*this, other);
+
62 }
+
63 
+
64 Process& Process::operator=(Process other) {
+
65  swap(*this, other);
+
66  return (*this);
+
67 }
+
68 
+
69 void Process::set_shape(std::unique_ptr<TH1> shape, bool set_rate) {
+
70  // We were given a nullptr - this is fine, and so we're done
+
71  if (!shape) {
+
72  // This will safely release any existing TH1 held by shape_
+
73  shape_ = nullptr;
+
74  return;
+
75  }
+
76  // Otherwise we validate this new hist. First is to check that all bins have
+
77  // +ve values, otherwise the interpretation as a pdf is tricky
+
78  // for (int i = 1; i <= shape->GetNbinsX(); ++i) {
+
79  // if (shape->GetBinContent(i) < 0.) {
+
80  // throw std::runtime_error(FNERROR("TH1 has a bin with content < 0"));
+
81  // }
+
82  // }
+
83  // At this point we can safely move the shape in and take ownership
+
84  shape_ = std::move(shape);
+
85  // Ensure that root will not try and clean this up
+
86  shape_->SetDirectory(0);
+
87  if (set_rate) {
+
88  this->set_rate(shape_->Integral());
+
89  }
+
90  if (shape_->Integral() > 0.) shape_->Scale(1. / shape_->Integral());
+
91 }
+
92 
+
93 void Process::set_shape(TH1 const& shape, bool set_rate) {
+
94  set_shape(std::unique_ptr<TH1>(static_cast<TH1*>(shape.Clone())), set_rate);
+
95 }
+
96 
+
97 
+
98 std::unique_ptr<TH1> Process::ClonedShape() const {
+
99  if (!shape_) return std::unique_ptr<TH1>();
+
100  std::unique_ptr<TH1> res(static_cast<TH1 *>(shape_->Clone()));
+
101  res->SetDirectory(0);
+
102  return res;
+
103 }
+
104 
+
105 std::unique_ptr<TH1> Process::ClonedScaledShape() const {
+
106  if (!shape_) return std::unique_ptr<TH1>();
+
107  std::unique_ptr<TH1> res(ClonedShape());
+
108  res->Scale(this->no_norm_rate());
+
109  return res;
+
110 }
+
111 
+
112 TH1F Process::ShapeAsTH1F() const {
+
113  if (!shape_ && !data_) {
+
114  throw std::runtime_error(
+
115  FNERROR("Process object does not contain a shape"));
+
116  }
+
117  TH1F res;
+
118  if (this->shape()) {
+
119  // Need to get the shape as a concrete type (TH1F or TH1D)
+
120  // A nice way to do this is just to use TH1D::Copy into a fresh TH1F
+
121  TH1F const* test_f = dynamic_cast<TH1F const*>(this->shape());
+
122  TH1D const* test_d = dynamic_cast<TH1D const*>(this->shape());
+
123  if (test_f) {
+
124  test_f->Copy(res);
+
125  } else if (test_d) {
+
126  test_d->Copy(res);
+
127  } else {
+
128  throw std::runtime_error(FNERROR("TH1 shape is not a TH1F or a TH1D"));
+
129  }
+
130  } else if (this->data()) {
+
131  std::string var_name = this->data()->get()->first()->GetName();
+
132  TH1F *tmp = dynamic_cast<TH1F*>(this->data()->createHistogram(
+
133  var_name.c_str()));
+
134  res = *tmp;
+
135  delete tmp;
+
136  if (res.Integral() > 0.) res.Scale(1. / res.Integral());
+
137  }
+
138  return res;
+
139 }
+
140 
+
141 std::ostream& Process::PrintHeader(std::ostream& out) {
+
142  std::string line =
+
143  (boost::format(
+
144  "%-6s %-9s %-6s %-8s %-28s %-3i %-16s %-4i %-10.5g %-5i") %
+
145  "mass" % "analysis" % "era" % "channel" % "bin" % "id" % "process" %
+
146  "sig" % "rate" % "shape").str();
+
147  std::string div(line.length(), '-');
+
148  out << div << std::endl;
+
149  out << line << std::endl;
+
150  out << div << std::endl;
151  return out;
152 }
-
153 }
+
153 
+
154 std::ostream& operator<< (std::ostream &out, Process const& val) {
+
155  out << boost::format(
+
156  "%-6s %-9s %-6s %-8s %-28s %-3i %-16s %-4i %-10.5g %-5i") %
+
157  val.mass() % val.analysis() % val.era() % val.channel() %
+
158  val.bin() % val.bin_id() % val.process() % val.signal() %
+
159  val.rate() %
+
160  (bool(val.shape()) || bool(val.pdf()) || bool(val.data()));
+
161  return out;
+
162 }
+
163 }
ch::Object::analysis
virtual std::string const & analysis() const
Definition: Object.h:26
-
ch::Process::ClonedShape
std::unique_ptr< TH1 > ClonedShape() const
Definition: Process.cc:88
-
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:53
+
ch::Process::ClonedShape
std::unique_ptr< TH1 > ClonedShape() const
Definition: Process.cc:98
+
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:63
ch::Object::bin_id
virtual int bin_id() const
Definition: Object.h:35
-
ch::Process::no_norm_rate
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:36
-
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:95
+
ch::Process::no_norm_rate
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:46
+
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:105
ch::swap
void swap(CombineHarvester &first, CombineHarvester &second)
Definition: CombineHarvester.cc:33
+
ch::Process::pdf
RooAbsReal const * pdf() const
Definition: Process.h:60
Process.h
-
ch::swap
void swap(Process &first, Process &second)
Definition: Process.cc:20
-
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:23
-
ch::Process::~Process
~Process()
Definition: Process.cc:18
+
ch::swap
void swap(Process &first, Process &second)
Definition: Process.cc:24
+
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:24
+
ch::Process::~Process
~Process()
Definition: Process.cc:20
FNERROR
#define FNERROR(x)
Definition: Logging.h:9
ch::Object::channel
virtual std::string const & channel() const
Definition: Object.h:32
ch::Object::process
virtual std::string const & process() const
Definition: Object.h:20
ch
Definition: Algorithm.h:10
-
ch::Process::ShapeAsTH1F
TH1F ShapeAsTH1F() const
Definition: Process.cc:102
+
ch::Process::ShapeAsTH1F
TH1F ShapeAsTH1F() const
Definition: Process.cc:112
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
-
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:42
+
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:52
ch::Process::Process
Process()
Definition: Process.cc:9
ch::Object::signal
bool signal() const
Definition: Object.h:23
-
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:131
-
ch::Process::swap
friend void swap(Process &first, Process &second)
Definition: Process.cc:20
+
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:141
+
ch::Process::swap
friend void swap(Process &first, Process &second)
Definition: Process.cc:24
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::Object::era
virtual std::string const & era() const
Definition: Object.h:29
-
ch::Process::pdf
RooAbsPdf const * pdf() const
Definition: Process.h:50
-
ch::Process::operator=
Process & operator=(Process other)
Definition: Process.cc:54
+
ch::Process::operator=
Process & operator=(Process other)
Definition: Process.cc:64
ch::Object
Definition: Object.h:8
-
ch::Process
Definition: Process.h:14
-
ch::Process::rate
double rate() const
Definition: Process.h:24
+
ch::Process
Definition: Process.h:15
+
ch::Process::rate
double rate() const
Definition: Process.h:25
Logging.h
ch::operator<<
std::ostream & operator<<(std::ostream &out, HistMapping const &val)
Definition: HistMapping.cc:70
-
ch::Process::set_shape
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:59
+
ch::Process::set_shape
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:69
diff --git a/_process_8h.html b/_process_8h.html index acc024fd971..c4ba7652eb1 100644 --- a/_process_8h.html +++ b/_process_8h.html @@ -109,6 +109,7 @@ #include "RooAbsPdf.h"
#include "RooAbsReal.h"
#include "RooAbsData.h"
+#include "RooRealVar.h"
#include "CombineHarvester/CombineTools/interface/MakeUnique.h"
#include "CombineHarvester/CombineTools/interface/Object.h"
diff --git a/_process_8h_source.html b/_process_8h_source.html index 1ee98ff702f..289c4f4798b 100644 --- a/_process_8h_source.html +++ b/_process_8h_source.html @@ -108,85 +108,102 @@
6 #include "RooAbsPdf.h"
7 #include "RooAbsReal.h"
8 #include "RooAbsData.h"
-
9 #include "CombineHarvester/CombineTools/interface/MakeUnique.h"
-
10 #include "CombineHarvester/CombineTools/interface/Object.h"
-
11 
-
12 namespace ch {
-
13 
-
14 class Process : public Object {
-
15  public:
-
16  Process();
-
17  ~Process();
-
18  Process(Process const& other);
-
19  Process(Process&& other);
-
20  Process& operator=(Process other);
-
21 
+
9 #include "RooRealVar.h"
+
10 #include "CombineHarvester/CombineTools/interface/MakeUnique.h"
+
11 #include "CombineHarvester/CombineTools/interface/Object.h"
+
12 
+
13 namespace ch {
+
14 
+
15 class Process : public Object {
+
16  public:
+
17  Process();
+
18  ~Process();
+
19  Process(Process const& other);
+
20  Process(Process&& other);
+
21  Process& operator=(Process other);
22 
-
23  void set_rate(double const& rate) { rate_ = rate; }
-
24  double rate() const { return norm_ ? norm_->getVal() * rate_ : rate_; }
-
25 
-
36  double no_norm_rate() const { return rate_; }
-
37 
-
38  void set_shape(std::unique_ptr<TH1> shape, bool set_rate);
-
39 
-
40  void set_shape(TH1 const& shape, bool set_rate);
-
41 
-
42  TH1 const* shape() const { return shape_.get(); }
-
43 
-
44  std::unique_ptr<TH1> ClonedShape() const;
-
45  std::unique_ptr<TH1> ClonedScaledShape() const;
-
46 
-
47  TH1F ShapeAsTH1F() const;
-
48 
-
49  void set_pdf(RooAbsPdf* pdf) { pdf_ = pdf; }
-
50  RooAbsPdf const* pdf() const { return pdf_; }
+
23 
+
24  void set_rate(double const& rate) { rate_ = rate; }
+
25  double rate() const {
+
26  double base = 1.;
+
27  if (pdf_ && !dynamic_cast<RooAbsPdf*>(pdf_) && cached_obs_) {
+
28  if (!cached_int_) {
+
29  cached_int_ = pdf_->createIntegral(RooArgSet(*cached_obs_));
+
30  }
+
31  base = cached_int_->getVal();
+
32  }
+
33  return norm_ ? base * norm_->getVal() * rate_ : base * rate_;
+
34  }
+
35 
+
46  double no_norm_rate() const { return rate_; }
+
47 
+
48  void set_shape(std::unique_ptr<TH1> shape, bool set_rate);
+
49 
+
50  void set_shape(TH1 const& shape, bool set_rate);
51 
-
52  void set_data(RooAbsData* data) { data_ = data; }
-
53  RooAbsData const* data() const { return data_; }
-
54 
-
55  void set_norm(RooAbsReal* norm) { norm_ = norm; }
-
56  RooAbsReal const* norm() const { return norm_; }
-
57 
-
58  friend std::ostream& operator<< (std::ostream &out, Process const& val);
-
59  static std::ostream& PrintHeader(std::ostream &out);
-
60 
-
61  private:
-
62  double rate_;
-
63  std::unique_ptr<TH1> shape_;
-
64  RooAbsPdf* pdf_;
-
65  RooAbsData* data_;
-
66  RooAbsReal* norm_;
+
52  TH1 const* shape() const { return shape_.get(); }
+
53 
+
54  std::unique_ptr<TH1> ClonedShape() const;
+
55  std::unique_ptr<TH1> ClonedScaledShape() const;
+
56 
+
57  TH1F ShapeAsTH1F() const;
+
58 
+
59  void set_pdf(RooAbsReal* pdf) { pdf_ = pdf; }
+
60  RooAbsReal const* pdf() const { return pdf_; }
+
61 
+
62  void set_data(RooAbsData* data) { data_ = data; }
+
63  RooAbsData const* data() const { return data_; }
+
64 
+
65  void set_norm(RooAbsReal* norm) { norm_ = norm; }
+
66  RooAbsReal const* norm() const { return norm_; }
67 
-
68  friend void swap(Process& first, Process& second);
-
69 };
-
70 }
-
71 
-
72 #endif
-
ch::Process::operator<<
friend std::ostream & operator<<(std::ostream &out, Process const &val)
Definition: Process.cc:144
-
ch::Process::ClonedShape
std::unique_ptr< TH1 > ClonedShape() const
Definition: Process.cc:88
-
ch::Process::norm
RooAbsReal const * norm() const
Definition: Process.h:56
-
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:53
-
ch::Process::set_data
void set_data(RooAbsData *data)
Definition: Process.h:52
-
ch::Process::no_norm_rate
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:36
-
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:95
-
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:23
-
ch::Process::~Process
~Process()
Definition: Process.cc:18
-
ch::Process::set_pdf
void set_pdf(RooAbsPdf *pdf)
Definition: Process.h:49
+
68  void set_observable(RooRealVar* obs) { cached_obs_ = obs; }
+
69  RooRealVar * observable() const { return cached_obs_; }
+
70 
+
71  friend std::ostream& operator<< (std::ostream &out, Process const& val);
+
72  static std::ostream& PrintHeader(std::ostream &out);
+
73 
+
74  private:
+
75  double rate_;
+
76  std::unique_ptr<TH1> shape_;
+
77  RooAbsReal* pdf_;
+
78  RooAbsData* data_;
+
79  RooAbsReal* norm_;
+
80  RooRealVar* cached_obs_;
+
81  mutable RooAbsReal* cached_int_;
+
82 
+
83  friend void swap(Process& first, Process& second);
+
84 };
+
85 }
+
86 
+
87 #endif
+
ch::Process::operator<<
friend std::ostream & operator<<(std::ostream &out, Process const &val)
Definition: Process.cc:154
+
ch::Process::ClonedShape
std::unique_ptr< TH1 > ClonedShape() const
Definition: Process.cc:98
+
ch::Process::set_observable
void set_observable(RooRealVar *obs)
Definition: Process.h:68
+
ch::Process::norm
RooAbsReal const * norm() const
Definition: Process.h:66
+
ch::Process::data
RooAbsData const * data() const
Definition: Process.h:63
+
ch::Process::set_data
void set_data(RooAbsData *data)
Definition: Process.h:62
+
ch::Process::no_norm_rate
double no_norm_rate() const
Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's pres...
Definition: Process.h:46
+
ch::Process::ClonedScaledShape
std::unique_ptr< TH1 > ClonedScaledShape() const
Definition: Process.cc:105
+
ch::Process::set_pdf
void set_pdf(RooAbsReal *pdf)
Definition: Process.h:59
+
ch::Process::pdf
RooAbsReal const * pdf() const
Definition: Process.h:60
+
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:24
+
ch::Process::~Process
~Process()
Definition: Process.cc:20
ch
Definition: Algorithm.h:10
-
ch::Process::ShapeAsTH1F
TH1F ShapeAsTH1F() const
Definition: Process.cc:102
-
ch::Process::set_norm
void set_norm(RooAbsReal *norm)
Definition: Process.h:55
-
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:42
+
ch::Process::ShapeAsTH1F
TH1F ShapeAsTH1F() const
Definition: Process.cc:112
+
ch::Process::set_norm
void set_norm(RooAbsReal *norm)
Definition: Process.h:65
+
ch::Process::observable
RooRealVar * observable() const
Definition: Process.h:69
+
ch::Process::shape
TH1 const * shape() const
Definition: Process.h:52
ch::Process::Process
Process()
Definition: Process.cc:9
Object.h
-
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:131
-
ch::Process::swap
friend void swap(Process &first, Process &second)
Definition: Process.cc:20
-
ch::Process::pdf
RooAbsPdf const * pdf() const
Definition: Process.h:50
+
ch::Process::PrintHeader
static std::ostream & PrintHeader(std::ostream &out)
Definition: Process.cc:141
+
ch::Process::swap
friend void swap(Process &first, Process &second)
Definition: Process.cc:24
MakeUnique.h
-
ch::Process::operator=
Process & operator=(Process other)
Definition: Process.cc:54
+
ch::Process::operator=
Process & operator=(Process other)
Definition: Process.cc:64
ch::Object
Definition: Object.h:8
-
ch::Process
Definition: Process.h:14
-
ch::Process::rate
double rate() const
Definition: Process.h:24
-
ch::Process::set_shape
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:59
+
ch::Process
Definition: Process.h:15
+
ch::Process::rate
double rate() const
Definition: Process.h:25
+
ch::Process::set_shape
void set_shape(std::unique_ptr< TH1 > shape, bool set_rate)
Definition: Process.cc:69
diff --git a/_s_m_legacy_example_8cpp_source.html b/_s_m_legacy_example_8cpp_source.html index c3b0655b4a6..61649cde91b 100644 --- a/_s_m_legacy_example_8cpp_source.html +++ b/_s_m_legacy_example_8cpp_source.html @@ -368,7 +368,7 @@
274  cout << "\n>> Done!\n";
275 }
ch::CombineHarvester
Definition: CombineHarvester.h:30
-
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:211
+
ch::CombineHarvester::cp
CombineHarvester cp()
Creates and returns a shallow copy of the CombineHarvester instance.
Definition: CombineHarvester.cc:216
ch::BinByBinFactory::SetMergeThreshold
BinByBinFactory & SetMergeThreshold(double val)
The threshold for the merging algorithm.
Definition: BinByBin.h:107
ch::AddSystematics_tt
void AddSystematics_tt(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:860
std
@@ -380,8 +380,8 @@
ch::CombineHarvester::process
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:35
CopyTools.h
ch::CombineHarvester::channel_set
std::set< std::string > channel_set()
Definition: CombineHarvester_Filters.cc:247
-
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:23
-
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:623
+
ch::Process::set_rate
void set_rate(double const &rate)
Definition: Process.h:24
+
ch::CombineHarvester::FilterProcs
CombineHarvester & FilterProcs(Function func)
Definition: CombineHarvester.h:637
ch::CombineHarvester::AddProcesses
void AddProcesses(std::vector< std::string > mass, std::vector< std::string > analysis, std::vector< std::string > era, std::vector< std::string > channel, std::vector< std::string > procs, ch::Categories bin, bool signal)
Definition: CombineHarvester_Creation.cc:45
ch::CardWriter
Automates the writing of datacards into directory structures.
Definition: CardWriter.h:50
ch::BinByBinFactory::SetFixNorm
BinByBinFactory & SetFixNorm(bool fix)
Whether or not the bin-by-bin systematics are allowed to vary the process normalisation.
Definition: BinByBin.h:124
@@ -389,18 +389,18 @@
BinByBin.h
ch::TGraphFromTable
TGraph TGraphFromTable(std::string filename, std::string const &x_column, std::string const &y_column)
Definition: Utilities.cc:121
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
-
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:223
+
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:224
ch::AddSystematics_et_mt
void AddSystematics_et_mt(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:416
ch::CombineHarvester::syst_name
CombineHarvester & syst_name(std::vector< std::string > const &vec, bool cond=true)
Definition: CombineHarvester_Filters.cc:126
ch::AddSystematics_ee_mm
void AddSystematics_ee_mm(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:18
Utilities.h
-
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:280
+
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:281
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::BinByBinFactory
Merges bin uncertainties and creates bin-by-bin statistical uncertainties.
Definition: BinByBin.h:21
ch::AddSystematics_em
void AddSystematics_em(CombineHarvester &cb)
Definition: HttSystematics_SMLegacy.cc:222
-
ch::CardWriter::WriteCards
std::map< std::string, CombineHarvester > WriteCards(std::string const &tag, ch::CombineHarvester &cmb) const
Write datacards according to patterns, substituting $TAG for tag
Definition: CardWriter.cc:74
-
ch::Process
Definition: Process.h:14
-
ch::Process::rate
double rate() const
Definition: Process.h:24
+
ch::CardWriter::WriteCards
std::map< std::string, CombineHarvester > WriteCards(std::string const &tag, ch::CombineHarvester &cmb) const
Write datacards according to patterns, substituting $TAG for tag
Definition: CardWriter.cc:96
+
ch::Process
Definition: Process.h:15
+
ch::Process::rate
double rate() const
Definition: Process.h:25
main
int main()
Definition: SMLegacyExample.cpp:18
ch::Categories
std::vector< std::pair< int, std::string > > Categories
Definition: CombineHarvester.h:28
CardWriter.h
diff --git a/_systematics_8h_source.html b/_systematics_8h_source.html index f327cb72ef0..23fbbe91312 100644 --- a/_systematics_8h_source.html +++ b/_systematics_8h_source.html @@ -412,7 +412,7 @@
ch::syst::SystMap::Formula
std::string Formula(ch::Process *) const
Definition: Systematics.h:103
ch::syst::channel
Definition: Systematics.h:26
ch::syst::SystMapFunc
Definition: Systematics.h:203
-
ch::Process
Definition: Process.h:14
+
ch::Process
Definition: Process.h:15
Logging.h
ch::syst::SystMap::GetTuple
auto GetTuple(ch::Process *p) const -> decltype(std::make_tuple(T::get(p)...))
Definition: Systematics.h:125
ch::syst::SystMapAsymm::GetTuple
auto GetTuple(ch::Process *p) const -> decltype(std::make_tuple(T::get(p)...))
Definition: Systematics.h:193
diff --git a/_utilities_8cc_source.html b/_utilities_8cc_source.html index 004aed53064..e7f983263bf 100644 --- a/_utilities_8cc_source.html +++ b/_utilities_8cc_source.html @@ -275,191 +275,192 @@
173  static_cast<float>(hist.GetNbinsX()));
174  for (int i = 1; i <= hist.GetNbinsX(); ++i) {
175  shape.SetBinContent(i, hist.GetBinContent(i));
-
176  }
-
177  return shape;
-
178 }
-
179 
-
180 TH1F RestoreBinning(TH1F const& src, TH1F const& ref) {
-
181  TH1F res = ref;
-
182  res.Reset();
-
183  for (int x = 1; x <= res.GetNbinsX(); ++x) {
-
184  res.SetBinContent(x, src.GetBinContent(x));
-
185  res.SetBinError(x, src.GetBinError(x));
-
186  }
-
187  return res;
-
188 }
-
189 
-
190 std::vector<std::vector<unsigned>> GenerateCombinations(
-
191  std::vector<unsigned> vec) {
-
192  unsigned n = vec.size();
-
193  std::vector<unsigned> idx(n, 0);
-
194  std::vector<std::vector<unsigned>> result;
-
195  // if any one of the elements is zero there are no
-
196  // combinations to build
-
197  if (std::find(vec.begin(), vec.end(), 0) != vec.end()) {
-
198  return result;
-
199  }
-
200  result.push_back(idx);
-
201  bool exit_loop = false;
-
202  while (exit_loop == false) {
-
203  // Find the first index we can increment (if possible)
-
204  for (unsigned i = 0; i < n; ++i) {
-
205  if ((idx[i] + 1) == vec[i]) {
-
206  if (i != n - 1) {
-
207  idx[i] = 0;
-
208  } else {
-
209  // we're done
-
210  exit_loop = true;
-
211  break;
-
212  }
-
213  } else {
-
214  ++(idx[i]);
-
215  result.push_back(idx);
-
216  break;
-
217  }
-
218  }
-
219  }
-
220  return result;
-
221 }
-
222 
-
223 std::vector<std::string> ParseFileLines(std::string const& file_name) {
-
224  // Build a vector of input files
-
225  std::vector<std::string> files;
-
226  std::ifstream file;
-
227  file.open(file_name.c_str());
-
228  if (!file.is_open()) {
-
229  throw std::runtime_error(
-
230  FNERROR("File " + file_name + " could not be opened"));
-
231  }
-
232  std::string line = "";
-
233  while (std::getline(file, line)) { // while loop through lines
-
234  files.push_back(line);
-
235  }
-
236  file.close();
-
237  return files;
-
238 }
-
239 
-
240 bool is_float(std::string const& str) {
-
241  std::istringstream iss(str);
-
242  float f;
-
243  iss >> std::noskipws >> f; // noskipws considers leading whitespace invalid
-
244  // Check the entire string was consumed and if either failbit or badbit is set
-
245  return iss.eof() && !iss.fail();
-
246 }
-
247 
-
248 std::vector<std::string> MassesFromRange(std::string const& input,
-
249  std::string const& fmt) {
-
250  std::set<double> mass_set;
-
251  std::vector<std::string> tokens;
-
252  boost::split(tokens, input, boost::is_any_of(","));
-
253  for (auto const& t : tokens) {
-
254  std::vector<std::string> sub_tokens;
-
255  boost::split(sub_tokens, t, boost::is_any_of("-:"));
-
256  if (sub_tokens.size() == 1) {
-
257  double mass_val = boost::lexical_cast<double>(sub_tokens[0]);
-
258  mass_set.insert(mass_val);
-
259  } else if (sub_tokens.size() == 3) {
-
260  double lo = boost::lexical_cast<double>(sub_tokens[0]);
-
261  double hi = boost::lexical_cast<double>(sub_tokens[1]);
-
262  double step = boost::lexical_cast<double>(sub_tokens[2]);
-
263  if (hi <= lo)
-
264  throw std::runtime_error(
-
265  "[MassesFromRange] High mass is smaller than low mass!");
-
266  double start = lo;
-
267  while (start < hi + 0.001) {
-
268  mass_set.insert(start);
-
269  start += step;
-
270  }
-
271  }
-
272  }
-
273  std::vector<std::string> result;
-
274  for (auto const& m : mass_set) {
-
275  result.push_back((boost::format(fmt) % m).str());
-
276  }
-
277  return result;
-
278 }
-
279 
-
280 std::vector<std::string> ValsFromRange(std::string const& input,
-
281  std::string const& fmt) {
-
282  std::set<double> mass_set;
-
283  std::vector<std::string> tokens;
-
284  boost::split(tokens, input, boost::is_any_of(","));
-
285  for (auto const& t : tokens) {
-
286  std::vector<std::string> sub_tokens;
-
287  boost::split(sub_tokens, t, boost::is_any_of(":|"));
-
288  if (sub_tokens.size() == 1) {
-
289  double mass_val = boost::lexical_cast<double>(sub_tokens[0]);
-
290  mass_set.insert(mass_val);
-
291  } else if (sub_tokens.size() == 3) {
-
292  double lo = boost::lexical_cast<double>(sub_tokens[0]);
-
293  double hi = boost::lexical_cast<double>(sub_tokens[1]);
-
294  double step = boost::lexical_cast<double>(sub_tokens[2]);
-
295  if (hi <= lo)
-
296  throw std::runtime_error(
-
297  "[ValsFromRange] High mass is smaller than low mass!");
-
298  double start = lo;
-
299  while (start < hi + 1E-4) {
-
300  mass_set.insert(start);
-
301  start += step;
-
302  }
-
303  }
-
304  }
-
305  std::vector<std::string> result;
-
306  for (auto const& m : mass_set) {
-
307  result.push_back((boost::format(fmt) % m).str());
-
308  }
-
309  return result;
-
310 }
-
311 
-
312 boost::filesystem::path make_relative(boost::filesystem::path p_from,
-
313  boost::filesystem::path p_to) {
-
314  p_from = boost::filesystem::absolute(p_from);
-
315  p_to = boost::filesystem::absolute(p_to);
-
316  boost::filesystem::path ret;
-
317  boost::filesystem::path::const_iterator itrFrom(p_from.begin()),
-
318  itrTo(p_to.begin());
-
319  // Find common base
-
320  for (boost::filesystem::path::const_iterator toEnd(p_to.end()),
-
321  fromEnd(p_from.end());
-
322  itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo;
-
323  ++itrFrom, ++itrTo);
-
324  // Navigate backwards in directory to reach previously found base
-
325  for (boost::filesystem::path::const_iterator fromEnd(p_from.end());
-
326  itrFrom != fromEnd; ++itrFrom) {
-
327  if ((*itrFrom) != ".") ret /= "..";
-
328  }
-
329  // Now navigate down the directory branch
-
330  // ret.append(itrTo, p_to.end());
-
331  for (boost::filesystem::path::const_iterator toEnd(p_to.end());
-
332  itrTo != toEnd; ++itrTo) {
-
333  ret /= *itrTo;
-
334  }
-
335  return ret;
-
336 }
-
337 
-
338 bool HasNegativeBins(TH1 const* h) {
-
339  bool has_negative = false;
-
340  for (int i = 1; i <= h->GetNbinsX(); ++i) {
-
341  if (h->GetBinContent(i) < 0.) {
-
342  has_negative = true;
-
343  }
-
344  }
-
345  return has_negative;
-
346 }
-
347 
-
348 void ZeroNegativeBins(TH1 *h) {
-
349  for (int i = 1; i <= h->GetNbinsX(); ++i) {
-
350  if (h->GetBinContent(i) < 0.) {
-
351  h->SetBinContent(i, 0.);
-
352  }
-
353  }
-
354 }
+
176  shape.SetBinError(i, hist.GetBinError(i));
+
177  }
+
178  return shape;
+
179 }
+
180 
+
181 TH1F RestoreBinning(TH1F const& src, TH1F const& ref) {
+
182  TH1F res = ref;
+
183  res.Reset();
+
184  for (int x = 1; x <= res.GetNbinsX(); ++x) {
+
185  res.SetBinContent(x, src.GetBinContent(x));
+
186  res.SetBinError(x, src.GetBinError(x));
+
187  }
+
188  return res;
+
189 }
+
190 
+
191 std::vector<std::vector<unsigned>> GenerateCombinations(
+
192  std::vector<unsigned> vec) {
+
193  unsigned n = vec.size();
+
194  std::vector<unsigned> idx(n, 0);
+
195  std::vector<std::vector<unsigned>> result;
+
196  // if any one of the elements is zero there are no
+
197  // combinations to build
+
198  if (std::find(vec.begin(), vec.end(), 0) != vec.end()) {
+
199  return result;
+
200  }
+
201  result.push_back(idx);
+
202  bool exit_loop = false;
+
203  while (exit_loop == false) {
+
204  // Find the first index we can increment (if possible)
+
205  for (unsigned i = 0; i < n; ++i) {
+
206  if ((idx[i] + 1) == vec[i]) {
+
207  if (i != n - 1) {
+
208  idx[i] = 0;
+
209  } else {
+
210  // we're done
+
211  exit_loop = true;
+
212  break;
+
213  }
+
214  } else {
+
215  ++(idx[i]);
+
216  result.push_back(idx);
+
217  break;
+
218  }
+
219  }
+
220  }
+
221  return result;
+
222 }
+
223 
+
224 std::vector<std::string> ParseFileLines(std::string const& file_name) {
+
225  // Build a vector of input files
+
226  std::vector<std::string> files;
+
227  std::ifstream file;
+
228  file.open(file_name.c_str());
+
229  if (!file.is_open()) {
+
230  throw std::runtime_error(
+
231  FNERROR("File " + file_name + " could not be opened"));
+
232  }
+
233  std::string line = "";
+
234  while (std::getline(file, line)) { // while loop through lines
+
235  files.push_back(line);
+
236  }
+
237  file.close();
+
238  return files;
+
239 }
+
240 
+
241 bool is_float(std::string const& str) {
+
242  std::istringstream iss(str);
+
243  float f;
+
244  iss >> std::noskipws >> f; // noskipws considers leading whitespace invalid
+
245  // Check the entire string was consumed and if either failbit or badbit is set
+
246  return iss.eof() && !iss.fail();
+
247 }
+
248 
+
249 std::vector<std::string> MassesFromRange(std::string const& input,
+
250  std::string const& fmt) {
+
251  std::set<double> mass_set;
+
252  std::vector<std::string> tokens;
+
253  boost::split(tokens, input, boost::is_any_of(","));
+
254  for (auto const& t : tokens) {
+
255  std::vector<std::string> sub_tokens;
+
256  boost::split(sub_tokens, t, boost::is_any_of("-:"));
+
257  if (sub_tokens.size() == 1) {
+
258  double mass_val = boost::lexical_cast<double>(sub_tokens[0]);
+
259  mass_set.insert(mass_val);
+
260  } else if (sub_tokens.size() == 3) {
+
261  double lo = boost::lexical_cast<double>(sub_tokens[0]);
+
262  double hi = boost::lexical_cast<double>(sub_tokens[1]);
+
263  double step = boost::lexical_cast<double>(sub_tokens[2]);
+
264  if (hi <= lo)
+
265  throw std::runtime_error(
+
266  "[MassesFromRange] High mass is smaller than low mass!");
+
267  double start = lo;
+
268  while (start < hi + 0.001) {
+
269  mass_set.insert(start);
+
270  start += step;
+
271  }
+
272  }
+
273  }
+
274  std::vector<std::string> result;
+
275  for (auto const& m : mass_set) {
+
276  result.push_back((boost::format(fmt) % m).str());
+
277  }
+
278  return result;
+
279 }
+
280 
+
281 std::vector<std::string> ValsFromRange(std::string const& input,
+
282  std::string const& fmt) {
+
283  std::set<double> mass_set;
+
284  std::vector<std::string> tokens;
+
285  boost::split(tokens, input, boost::is_any_of(","));
+
286  for (auto const& t : tokens) {
+
287  std::vector<std::string> sub_tokens;
+
288  boost::split(sub_tokens, t, boost::is_any_of(":|"));
+
289  if (sub_tokens.size() == 1) {
+
290  double mass_val = boost::lexical_cast<double>(sub_tokens[0]);
+
291  mass_set.insert(mass_val);
+
292  } else if (sub_tokens.size() == 3) {
+
293  double lo = boost::lexical_cast<double>(sub_tokens[0]);
+
294  double hi = boost::lexical_cast<double>(sub_tokens[1]);
+
295  double step = boost::lexical_cast<double>(sub_tokens[2]);
+
296  if (hi <= lo)
+
297  throw std::runtime_error(
+
298  "[ValsFromRange] High mass is smaller than low mass!");
+
299  double start = lo;
+
300  while (start < hi + 1E-4) {
+
301  mass_set.insert(start);
+
302  start += step;
+
303  }
+
304  }
+
305  }
+
306  std::vector<std::string> result;
+
307  for (auto const& m : mass_set) {
+
308  result.push_back((boost::format(fmt) % m).str());
+
309  }
+
310  return result;
+
311 }
+
312 
+
313 boost::filesystem::path make_relative(boost::filesystem::path p_from,
+
314  boost::filesystem::path p_to) {
+
315  p_from = boost::filesystem::absolute(p_from);
+
316  p_to = boost::filesystem::absolute(p_to);
+
317  boost::filesystem::path ret;
+
318  boost::filesystem::path::const_iterator itrFrom(p_from.begin()),
+
319  itrTo(p_to.begin());
+
320  // Find common base
+
321  for (boost::filesystem::path::const_iterator toEnd(p_to.end()),
+
322  fromEnd(p_from.end());
+
323  itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo;
+
324  ++itrFrom, ++itrTo);
+
325  // Navigate backwards in directory to reach previously found base
+
326  for (boost::filesystem::path::const_iterator fromEnd(p_from.end());
+
327  itrFrom != fromEnd; ++itrFrom) {
+
328  if ((*itrFrom) != ".") ret /= "..";
+
329  }
+
330  // Now navigate down the directory branch
+
331  // ret.append(itrTo, p_to.end());
+
332  for (boost::filesystem::path::const_iterator toEnd(p_to.end());
+
333  itrTo != toEnd; ++itrTo) {
+
334  ret /= *itrTo;
+
335  }
+
336  return ret;
+
337 }
+
338 
+
339 bool HasNegativeBins(TH1 const* h) {
+
340  bool has_negative = false;
+
341  for (int i = 1; i <= h->GetNbinsX(); ++i) {
+
342  if (h->GetBinContent(i) < 0.) {
+
343  has_negative = true;
+
344  }
+
345  }
+
346  return has_negative;
+
347 }
+
348 
+
349 void ZeroNegativeBins(TH1 *h) {
+
350  for (int i = 1; i <= h->GetNbinsX(); ++i) {
+
351  if (h->GetBinContent(i) < 0.) {
+
352  h->SetBinContent(i, 0.);
+
353  }
+
354  }
355 }
+
356 }
ch::Object::analysis
virtual std::string const & analysis() const
Definition: Object.h:26
ch::SetFromBinName
void SetFromBinName(ch::Object *input, std::string parse_rules)
Definition: Utilities.cc:96
-
ch::GenerateCombinations
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
Definition: Utilities.cc:190
+
ch::GenerateCombinations
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
Definition: Utilities.cc:191
ch::ExtractSampledFitParameters
std::vector< ch::Parameter > ExtractSampledFitParameters(RooFitResult const &res)
Definition: Utilities.cc:60
-
ch::RestoreBinning
TH1F RestoreBinning(TH1F const &src, TH1F const &ref)
Definition: Utilities.cc:180
+
ch::RestoreBinning
TH1F RestoreBinning(TH1F const &src, TH1F const &ref)
Definition: Utilities.cc:181
ch::Object::set_bin_id
virtual void set_bin_id(int const &bin_id)
Definition: Object.h:34
ch::CombineHarvester
Definition: CombineHarvester.h:30
ch::Object::set_mass
virtual void set_mass(std::string const &mass)
Definition: Object.h:37
@@ -467,32 +468,32 @@
ch::Object::bin_id
virtual int bin_id() const
Definition: Object.h:35
ch::TH1F2Data
RooDataHist TH1F2Data(TH1F const &hist, RooRealVar const &x, std::string const &name)
Definition: Utilities.cc:158
ch::SetStandardBinNames
void SetStandardBinNames(CombineHarvester &cb, std::string const &pattern="$ANALYSIS_$CHANNEL_$BINID_$ERA")
Definition: Utilities.cc:78
-
ch::ZeroNegativeBins
void ZeroNegativeBins(TH1 *h)
Definition: Utilities.cc:348
+
ch::ZeroNegativeBins
void ZeroNegativeBins(TH1 *h)
Definition: Utilities.cc:349
CombineHarvester.h
FNLOG
#define FNLOG(x)
Definition: Logging.h:13
ch::Object::set_analysis
virtual void set_analysis(std::string const &analysis)
Definition: Object.h:25
FNERROR
#define FNERROR(x)
Definition: Logging.h:9
-
ch::MassesFromRange
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
Definition: Utilities.cc:248
+
ch::MassesFromRange
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
Definition: Utilities.cc:249
ch::Object::channel
virtual std::string const & channel() const
Definition: Object.h:32
ch::Object::process
virtual std::string const & process() const
Definition: Object.h:20
ch::TGraphFromTable
TGraph TGraphFromTable(std::string filename, std::string const &x_column, std::string const &y_column)
Definition: Utilities.cc:121
ch
Definition: Algorithm.h:10
-
ch::HasNegativeBins
bool HasNegativeBins(TH1 const *h)
Definition: Utilities.cc:338
+
ch::HasNegativeBins
bool HasNegativeBins(TH1 const *h)
Definition: Utilities.cc:339
ch::Object::mass
virtual std::string const & mass() const
Definition: Object.h:38
-
ch::is_float
bool is_float(std::string const &str)
Definition: Utilities.cc:240
-
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:223
+
ch::is_float
bool is_float(std::string const &str)
Definition: Utilities.cc:241
+
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:224
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
ch::RebinHist
TH1F RebinHist(TH1F const &hist)
Definition: Utilities.cc:170
ch::Object::set_bin
virtual void set_bin(std::string const &bin)
Definition: Object.h:16
ch::SetStandardBinName
void SetStandardBinName(ch::Object *obj, std::string pattern)
Definition: Utilities.cc:84
Utilities.h
-
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:280
+
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:281
ch::Object::bin
virtual std::string const & bin() const
Definition: Object.h:17
ch::Object::era
virtual std::string const & era() const
Definition: Object.h:29
-
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:585
+
ch::CombineHarvester::ForEachObj
void ForEachObj(Function func)
Definition: CombineHarvester.h:599
ch::Object
Definition: Object.h:8
ch::ParametersByName
RooArgSet ParametersByName(RooAbsReal const *pdf, RooArgSet const *dat_vars)
Definition: Utilities.cc:18
-
ch::make_relative
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
Definition: Utilities.cc:312
+
ch::make_relative
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
Definition: Utilities.cc:313
ch::Object::set_era
virtual void set_era(std::string const &era)
Definition: Object.h:28
ch::Object::set_channel
virtual void set_channel(std::string const &channel)
Definition: Object.h:31
diff --git a/_utilities_8h_source.html b/_utilities_8h_source.html index 8c0eb4962f2..5fd794e180e 100644 --- a/_utilities_8h_source.html +++ b/_utilities_8h_source.html @@ -167,150 +167,151 @@
65  first->set_channel(second->channel());
66  first->set_bin_id(second->bin_id());
67  first->set_mass(second->mass());
-
68 }
-
69 
-
70 void SetFromBinName(ch::Object *input, std::string parse_rules);
-
71 
-
72 // ---------------------------------------------------------------------------
-
73 // Rate scaling
-
74 // ---------------------------------------------------------------------------
-
75 TGraph TGraphFromTable(std::string filename, std::string const& x_column,
-
76  std::string const& y_column);
-
77 
-
78 // ---------------------------------------------------------------------------
-
79 // Misc
-
80 // ---------------------------------------------------------------------------
-
81 template<class T>
-
82 std::vector<T> Join(std::vector<std::vector<T>> const& in) {
-
83  unsigned size = 0;
-
84  for (auto const& x : in) size += x.size();
-
85  std::vector<T> res(size);
-
86  unsigned i = 0;
-
87  for (auto const& x : in) {
-
88  for (auto const& y : x) {
-
89  res[i] = y;
-
90  ++i;
-
91  }
-
92  }
-
93  return res;
-
94 }
-
95 
-
96 std::vector<std::string> JoinStr(
-
97  std::vector<std::vector<std::string>> const& in);
-
98 
-
99 template<class T>
-
100 std::vector<T> Set2Vec(std::set<T> const& in) {
-
101  return std::vector<T>(in.begin(), in.end());
-
102 }
-
103 
-
104 RooDataHist TH1F2Data(TH1F const& hist, RooRealVar const& x,
-
105  std::string const& name);
-
106 
-
107 TH1F RebinHist(TH1F const& hist);
-
108 
-
109 TH1F RestoreBinning(TH1F const& src, TH1F const& ref);
-
110 
+
68  first->set_all_attributes(second->all_attributes());
+
69 }
+
70 
+
71 void SetFromBinName(ch::Object *input, std::string parse_rules);
+
72 
+
73 // ---------------------------------------------------------------------------
+
74 // Rate scaling
+
75 // ---------------------------------------------------------------------------
+
76 TGraph TGraphFromTable(std::string filename, std::string const& x_column,
+
77  std::string const& y_column);
+
78 
+
79 // ---------------------------------------------------------------------------
+
80 // Misc
+
81 // ---------------------------------------------------------------------------
+
82 template<class T>
+
83 std::vector<T> Join(std::vector<std::vector<T>> const& in) {
+
84  unsigned size = 0;
+
85  for (auto const& x : in) size += x.size();
+
86  std::vector<T> res(size);
+
87  unsigned i = 0;
+
88  for (auto const& x : in) {
+
89  for (auto const& y : x) {
+
90  res[i] = y;
+
91  ++i;
+
92  }
+
93  }
+
94  return res;
+
95 }
+
96 
+
97 std::vector<std::string> JoinStr(
+
98  std::vector<std::vector<std::string>> const& in);
+
99 
+
100 template<class T>
+
101 std::vector<T> Set2Vec(std::set<T> const& in) {
+
102  return std::vector<T>(in.begin(), in.end());
+
103 }
+
104 
+
105 RooDataHist TH1F2Data(TH1F const& hist, RooRealVar const& x,
+
106  std::string const& name);
+
107 
+
108 TH1F RebinHist(TH1F const& hist);
+
109 
+
110 TH1F RestoreBinning(TH1F const& src, TH1F const& ref);
111 
-
112 std::vector<std::vector<unsigned>> GenerateCombinations(
-
113  std::vector<unsigned> vec);
-
114 
-
115 std::vector<std::string> ParseFileLines(std::string const& file_name);
-
116 
+
112 
+
113 std::vector<std::vector<unsigned>> GenerateCombinations(
+
114  std::vector<unsigned> vec);
+
115 
+
116 std::vector<std::string> ParseFileLines(std::string const& file_name);
117 
-
118 bool is_float(std::string const& str);
-
119 
-
142 std::vector<std::string> MassesFromRange(std::string const& input,
-
143  std::string const& fmt = "%.0f");
-
144 
-
163 std::vector<std::string> ValsFromRange(std::string const& input,
-
164  std::string const& fmt = "%.0f");
-
165 
-
166 bool HasNegativeBins(TH1 const* h);
-
167 
-
168 void ZeroNegativeBins(TH1 *h);
-
169 
-
170 // ---------------------------------------------------------------------------
-
171 // Tuple Printing
-
172 // ---------------------------------------------------------------------------
-
173 // Most of this is just implementation detail, so we'll hide it away in a
-
174 // namespace:
-
175 namespace tupleprint {
-
176 // Have stolen tuple printing routines from here:
-
177 // http://en.cppreference.com/w/cpp/utility/tuple/tuple_cat
-
178 template <class Tuple, std::size_t N>
-
179 struct TuplePrinter {
-
180  static void print(const Tuple &t, std::stringstream & str) {
-
181  TuplePrinter<Tuple, N - 1>::print(t, str);
-
182  str << ", " << std::get<N - 1>(t);
-
183  }
-
184 };
-
185 
-
186 template <class Tuple>
-
187 struct TuplePrinter<Tuple, 1> {
-
188  static void print(const Tuple & t, std::stringstream & str) {
-
189  str << std::get<0>(t);
-
190  }
-
191 };
-
192 
-
193 // Have to add this because we do make use of empty tuples
-
194 // Would lead to infinite recursion otherwise
-
195 template <class Tuple>
-
196 struct TuplePrinter<Tuple, 0> {
-
197  static void print(const Tuple & /*t*/, std::stringstream & /*str*/) { }
-
198 };
-
199 }
-
200 
-
212 template <class... Args>
-
213 std::string Tuple2String(const std::tuple<Args...> &t) {
-
214  std::stringstream str;
-
215  str << "(";
-
216  tupleprint::TuplePrinter<decltype(t), sizeof...(Args)>::print(t, str);
-
217  str << ")";
-
218  return str.str();
-
219 }
-
220 
-
221 // ---------------------------------------------------------------------------
-
222 // Filesystem Additions
-
223 // ---------------------------------------------------------------------------
-
239 boost::filesystem::path make_relative(boost::filesystem::path p_from,
-
240  boost::filesystem::path p_to);
-
241 }
-
242 
-
243 #endif
+
118 
+
119 bool is_float(std::string const& str);
+
120 
+
143 std::vector<std::string> MassesFromRange(std::string const& input,
+
144  std::string const& fmt = "%.0f");
+
145 
+
164 std::vector<std::string> ValsFromRange(std::string const& input,
+
165  std::string const& fmt = "%.0f");
+
166 
+
167 bool HasNegativeBins(TH1 const* h);
+
168 
+
169 void ZeroNegativeBins(TH1 *h);
+
170 
+
171 // ---------------------------------------------------------------------------
+
172 // Tuple Printing
+
173 // ---------------------------------------------------------------------------
+
174 // Most of this is just implementation detail, so we'll hide it away in a
+
175 // namespace:
+
176 namespace tupleprint {
+
177 // Have stolen tuple printing routines from here:
+
178 // http://en.cppreference.com/w/cpp/utility/tuple/tuple_cat
+
179 template <class Tuple, std::size_t N>
+
180 struct TuplePrinter {
+
181  static void print(const Tuple &t, std::stringstream & str) {
+
182  TuplePrinter<Tuple, N - 1>::print(t, str);
+
183  str << ", " << std::get<N - 1>(t);
+
184  }
+
185 };
+
186 
+
187 template <class Tuple>
+
188 struct TuplePrinter<Tuple, 1> {
+
189  static void print(const Tuple & t, std::stringstream & str) {
+
190  str << std::get<0>(t);
+
191  }
+
192 };
+
193 
+
194 // Have to add this because we do make use of empty tuples
+
195 // Would lead to infinite recursion otherwise
+
196 template <class Tuple>
+
197 struct TuplePrinter<Tuple, 0> {
+
198  static void print(const Tuple & /*t*/, std::stringstream & /*str*/) { }
+
199 };
+
200 }
+
201 
+
213 template <class... Args>
+
214 std::string Tuple2String(const std::tuple<Args...> &t) {
+
215  std::stringstream str;
+
216  str << "(";
+
217  tupleprint::TuplePrinter<decltype(t), sizeof...(Args)>::print(t, str);
+
218  str << ")";
+
219  return str.str();
+
220 }
+
221 
+
222 // ---------------------------------------------------------------------------
+
223 // Filesystem Additions
+
224 // ---------------------------------------------------------------------------
+
240 boost::filesystem::path make_relative(boost::filesystem::path p_from,
+
241  boost::filesystem::path p_to);
+
242 }
+
243 
+
244 #endif
ch::SetFromBinName
void SetFromBinName(ch::Object *input, std::string parse_rules)
Definition: Utilities.cc:96
-
ch::GenerateCombinations
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
Definition: Utilities.cc:190
+
ch::GenerateCombinations
std::vector< std::vector< unsigned > > GenerateCombinations(std::vector< unsigned > vec)
Definition: Utilities.cc:191
ch::ExtractSampledFitParameters
std::vector< ch::Parameter > ExtractSampledFitParameters(RooFitResult const &res)
Definition: Utilities.cc:60
-
ch::RestoreBinning
TH1F RestoreBinning(TH1F const &src, TH1F const &ref)
Definition: Utilities.cc:180
+
ch::RestoreBinning
TH1F RestoreBinning(TH1F const &src, TH1F const &ref)
Definition: Utilities.cc:181
ch::ExtractFitParameters
std::vector< ch::Parameter > ExtractFitParameters(RooFitResult const &res)
Definition: Utilities.cc:46
ch::TH1F2Data
RooDataHist TH1F2Data(TH1F const &hist, RooRealVar const &x, std::string const &name)
Definition: Utilities.cc:158
-
ch::tupleprint::TuplePrinter::print
static void print(const Tuple &t, std::stringstream &str)
Definition: Utilities.h:180
-
ch::tupleprint::TuplePrinter< Tuple, 1 >::print
static void print(const Tuple &t, std::stringstream &str)
Definition: Utilities.h:188
+
ch::tupleprint::TuplePrinter::print
static void print(const Tuple &t, std::stringstream &str)
Definition: Utilities.h:181
+
ch::tupleprint::TuplePrinter< Tuple, 1 >::print
static void print(const Tuple &t, std::stringstream &str)
Definition: Utilities.h:189
ch::SetStandardBinNames
void SetStandardBinNames(CombineHarvester &cb, std::string const &pattern="$ANALYSIS_$CHANNEL_$BINID_$ERA")
Definition: Utilities.cc:78
Process.h
-
ch::tupleprint::TuplePrinter
Definition: Utilities.h:179
-
ch::ZeroNegativeBins
void ZeroNegativeBins(TH1 *h)
Definition: Utilities.cc:348
+
ch::tupleprint::TuplePrinter
Definition: Utilities.h:180
+
ch::ZeroNegativeBins
void ZeroNegativeBins(TH1 *h)
Definition: Utilities.cc:349
ch::SetProperties
void SetProperties(T *first, U const *second)
Definition: Utilities.h:59
Systematic.h
-
ch::MassesFromRange
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
Definition: Utilities.cc:248
+
ch::MassesFromRange
std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of mass values using ranges and intervals specified in a string.
Definition: Utilities.cc:249
ch::MatchingProcess
bool MatchingProcess(T const &first, U const &second)
Definition: Utilities.h:43
-
ch::Join
std::vector< T > Join(std::vector< std::vector< T >> const &in)
Definition: Utilities.h:82
+
ch::Join
std::vector< T > Join(std::vector< std::vector< T >> const &in)
Definition: Utilities.h:83
ch::TGraphFromTable
TGraph TGraphFromTable(std::string filename, std::string const &x_column, std::string const &y_column)
Definition: Utilities.cc:121
-
ch::Tuple2String
std::string Tuple2String(const std::tuple< Args... > &t)
Format any std::tuple as a string.
Definition: Utilities.h:213
+
ch::Tuple2String
std::string Tuple2String(const std::tuple< Args... > &t)
Format any std::tuple as a string.
Definition: Utilities.h:214
ch
Definition: Algorithm.h:10
-
ch::HasNegativeBins
bool HasNegativeBins(TH1 const *h)
Definition: Utilities.cc:338
-
ch::is_float
bool is_float(std::string const &str)
Definition: Utilities.cc:240
-
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:223
+
ch::HasNegativeBins
bool HasNegativeBins(TH1 const *h)
Definition: Utilities.cc:339
+
ch::is_float
bool is_float(std::string const &str)
Definition: Utilities.cc:241
+
ch::ParseFileLines
std::vector< std::string > ParseFileLines(std::string const &file_name)
Definition: Utilities.cc:224
ch::JoinStr
std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)
Definition: Utilities.cc:153
ch::RebinHist
TH1F RebinHist(TH1F const &hist)
Definition: Utilities.cc:170
ch::SetStandardBinName
void SetStandardBinName(ch::Object *obj, std::string pattern)
Definition: Utilities.cc:84
Parameter.h
-
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:280
-
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:100
+
ch::ValsFromRange
std::vector< std::string > ValsFromRange(std::string const &input, std::string const &fmt="%.0f")
Generate a vector of values using ranges and intervals specified in a string.
Definition: Utilities.cc:281
+
ch::Set2Vec
std::vector< T > Set2Vec(std::set< T > const &in)
Definition: Utilities.h:101
ch::Object
Definition: Object.h:8
ch::ParametersByName
RooArgSet ParametersByName(RooAbsReal const *pdf, RooArgSet const *dat_vars)
Definition: Utilities.cc:18
Logging.h
-
ch::make_relative
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
Definition: Utilities.cc:312
-
ch::tupleprint::TuplePrinter< Tuple, 0 >::print
static void print(const Tuple &, std::stringstream &)
Definition: Utilities.h:197
+
ch::make_relative
boost::filesystem::path make_relative(boost::filesystem::path p_from, boost::filesystem::path p_to)
Determine the relative path from one file to another.
Definition: Utilities.cc:313
+
ch::tupleprint::TuplePrinter< Tuple, 0 >::print
static void print(const Tuple &, std::stringstream &)
Definition: Utilities.h:198
diff --git a/annotated.html b/annotated.html index 3d9082b580e..f3c184ccf46 100644 --- a/annotated.html +++ b/annotated.html @@ -121,25 +121,26 @@  CAutoRebinTests for any bins below a certain threshold and if they exist merges them with neighborouring bins  CBinByBinFactoryMerges bin uncertainties and creates bin-by-bin statistical uncertainties  CCardWriterAutomates the writing of datacards into directory structures - CCombineHarvester - CFnTimerDetermine the total amount of time spent in a function - CToken - CHistMapping - CObject - CObservation - CParameter - CProcess - CSOverBInfo - CSystematic - CBkgInfo - CColInfo - Cconvert_cpp_map_to_py_dictConvert a C++ map to a python dict - Cconvert_cpp_root_to_py_rootCovert a C++ ROOT type to a PyROOT type - Cconvert_cpp_set_to_py_listConvert a C++ set to a python list - Cconvert_cpp_vector_to_py_listConvert a C++ vector to a python list - Cconvert_py_root_to_cpp_root - Cconvert_py_seq_to_cpp_vector - Cconvert_py_tup_to_cpp_pair + CCMSHistFuncFactory + CCombineHarvester + CFnTimerDetermine the total amount of time spent in a function + CToken + CHistMapping + CObject + CObservation + CParameter + CProcess + CSOverBInfo + CSystematic + CBkgInfo + CColInfo + Cconvert_cpp_map_to_py_dictConvert a C++ map to a python dict + Cconvert_cpp_root_to_py_rootCovert a C++ ROOT type to a PyROOT type + Cconvert_cpp_set_to_py_listConvert a C++ set to a python list + Cconvert_cpp_vector_to_py_listConvert a C++ vector to a python list + Cconvert_py_root_to_cpp_root + Cconvert_py_seq_to_cpp_vector + Cconvert_py_tup_to_cpp_pair diff --git a/classch_1_1_c_m_s_hist_func_factory.html b/classch_1_1_c_m_s_hist_func_factory.html new file mode 100644 index 00000000000..a8c02104493 --- /dev/null +++ b/classch_1_1_c_m_s_hist_func_factory.html @@ -0,0 +1,202 @@ + + + + + + + +CombineHarvester: ch::CMSHistFuncFactory Class Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
CombineHarvester +
+
+ + + + + + +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
ch::CMSHistFuncFactory Class Reference
+
+
+ +

#include "CombineHarvester/CombinePdfs/interface/CMSHistFuncFactory.h"

+ + + + + + + + +

+Public Member Functions

void Run (CombineHarvester &cb, RooWorkspace &ws)
 
void SetHorizontalMorphingVariable (std::map< std::string, RooAbsReal * > &hvar)
 
 CMSHistFuncFactory ()
 
+

Detailed Description

+
+

Definition at line 21 of file CMSHistFuncFactory.h.

+

Constructor & Destructor Documentation

+ +
+
+ + + + + + + +
ch::CMSHistFuncFactory::CMSHistFuncFactory ()
+
+ +

Definition at line 26 of file CMSHistFuncFactory.cc.

+ +
+
+

Member Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
void ch::CMSHistFuncFactory::Run (ch::CombineHarvestercb,
RooWorkspace & ws 
)
+
+ +

Definition at line 28 of file CMSHistFuncFactory.cc.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + +
void ch::CMSHistFuncFactory::SetHorizontalMorphingVariable (std::map< std::string, RooAbsReal * > & hvar)
+
+inline
+
+ +

Definition at line 24 of file CMSHistFuncFactory.h.

+ +
+
+
The documentation for this class was generated from the following files: +
+
+ + + + diff --git a/classch_1_1_c_m_s_hist_func_factory.js b/classch_1_1_c_m_s_hist_func_factory.js new file mode 100644 index 00000000000..aadd2540e26 --- /dev/null +++ b/classch_1_1_c_m_s_hist_func_factory.js @@ -0,0 +1,6 @@ +var classch_1_1_c_m_s_hist_func_factory = +[ + [ "CMSHistFuncFactory", "classch_1_1_c_m_s_hist_func_factory.html#aab342dafc3932662c321d48c33b393c7", null ], + [ "Run", "classch_1_1_c_m_s_hist_func_factory.html#a76a006851773756a05ca67e577b32c60", null ], + [ "SetHorizontalMorphingVariable", "classch_1_1_c_m_s_hist_func_factory.html#a73f46125c448b221340e3573565645a3", null ] +]; \ No newline at end of file diff --git a/classch_1_1_card_writer.html b/classch_1_1_card_writer.html index 12f97e01c1f..4ce104187c5 100644 --- a/classch_1_1_card_writer.html +++ b/classch_1_1_card_writer.html @@ -195,7 +195,7 @@

Member Function Documentation

Write datacards according to patterns, substituting $TAG for tag

-

Definition at line 74 of file CardWriter.cc.

+

Definition at line 96 of file CardWriter.cc.

diff --git a/classch_1_1_combine_harvester.html b/classch_1_1_combine_harvester.html index 46be8ef509b..337456b5fb5 100644 --- a/classch_1_1_combine_harvester.html +++ b/classch_1_1_combine_harvester.html @@ -298,6 +298,12 @@ void RenameGroup (std::string const &oldname, std::string const &newname)  Rename a nuisance parameter group. More...
  +void AddDatacardLineAtEnd (std::string const &line) + Add a line of text at the end of all datacards. More...
+  +void ClearDatacardLinesAtEnd () + Clear all added datacard lines. More...
Rate, shape and uncertainty evaluation

Methods to calculate total yields and shapes

All of these methods are greedy, meaning they will sum over all available objects and evaluate the effect of all uncertainties. They should be used at the end of a chain of filter methods to give the desired yield, shape or uncertainty.

@@ -436,7 +442,7 @@

Copy constructor (makes a shallow copy)

When copying a CombineHarvester instance it is important to remember that the stored Observation, Process, Systematic and Parameter objects themselves are not duplicated, rather their pointers are simply copied. This is called making a shallow-copy, and means modifying the contents of one of these objects in the copied CombineHarvester also modifies it for the original. However, filtering methods only affect the instance they are called from. For example, if all the signal Process entries are filtered from a copied CombineHarvester instance they will remain in the original instance.

-

Definition at line 47 of file CombineHarvester.cc.

+

Definition at line 48 of file CombineHarvester.cc.

@@ -454,7 +460,7 @@
-

Definition at line 198 of file CombineHarvester.cc.

+

Definition at line 203 of file CombineHarvester.cc.

@@ -473,7 +479,7 @@

Member Function Documentation

-

Definition at line 204 of file CombineHarvester.cc.

+

Definition at line 209 of file CombineHarvester.cc.

@@ -504,7 +510,7 @@

Member Function Documentation

Set a named flag value.

Creates the flag if it doesn't already

-

Definition at line 61 of file CombineHarvester.cc.

+

Definition at line 63 of file CombineHarvester.cc.

@@ -522,7 +528,7 @@

Member Function Documentation

-

Definition at line 72 of file CombineHarvester.cc.

+

Definition at line 74 of file CombineHarvester.cc.

@@ -541,7 +547,7 @@

Member Function Documentation

Creates and returns a shallow copy of the CombineHarvester instance.

-

Definition at line 211 of file CombineHarvester.cc.

+

Definition at line 216 of file CombineHarvester.cc.

@@ -561,7 +567,7 @@

Member Function Documentation

Creates and retunrs a deep copy of the CombineHarvester instance.

Unlike the shallow copy, a deep copy will duplicate every internal object, including any attached RooWorkspaces. This makes it completely independent of the original instance.

-

Definition at line 81 of file CombineHarvester.cc.

+

Definition at line 83 of file CombineHarvester.cc.

@@ -578,7 +584,7 @@

Member Function Documentation

-

Definition at line 217 of file CombineHarvester.cc.

+

Definition at line 222 of file CombineHarvester.cc.

@@ -595,7 +601,7 @@

Member Function Documentation

-

Definition at line 221 of file CombineHarvester.cc.

+

Definition at line 226 of file CombineHarvester.cc.

@@ -612,7 +618,7 @@

Member Function Documentation

-

Definition at line 228 of file CombineHarvester.cc.

+

Definition at line 233 of file CombineHarvester.cc.

@@ -629,7 +635,7 @@

Member Function Documentation

-

Definition at line 235 of file CombineHarvester.cc.

+

Definition at line 240 of file CombineHarvester.cc.

@@ -646,7 +652,7 @@

Member Function Documentation

-

Definition at line 242 of file CombineHarvester.cc.

+

Definition at line 247 of file CombineHarvester.cc.

@@ -805,7 +811,7 @@

Member Function Documentation

-

Definition at line 454 of file CombineHarvester_Datacards.cc.

+

Definition at line 455 of file CombineHarvester_Datacards.cc.

@@ -833,7 +839,7 @@

Member Function Documentation

-

Definition at line 622 of file CombineHarvester_Datacards.cc.

+

Definition at line 629 of file CombineHarvester_Datacards.cc.

@@ -851,7 +857,7 @@

Member Function Documentation

-

Definition at line 461 of file CombineHarvester_Datacards.cc.

+

Definition at line 462 of file CombineHarvester_Datacards.cc.

@@ -1270,7 +1276,7 @@

Member Function Documentation

-

Definition at line 607 of file CombineHarvester.h.

+

Definition at line 621 of file CombineHarvester.h.

@@ -1290,7 +1296,7 @@

Member Function Documentation

-

Definition at line 615 of file CombineHarvester.h.

+

Definition at line 629 of file CombineHarvester.h.

@@ -1310,7 +1316,7 @@

Member Function Documentation

-

Definition at line 623 of file CombineHarvester.h.

+

Definition at line 637 of file CombineHarvester.h.

@@ -1330,7 +1336,7 @@

Member Function Documentation

-

Definition at line 630 of file CombineHarvester.h.

+

Definition at line 644 of file CombineHarvester.h.

@@ -1513,7 +1519,7 @@

Member Function Documentation

-

Definition at line 555 of file CombineHarvester.h.

+

Definition at line 569 of file CombineHarvester.h.

@@ -1536,7 +1542,7 @@

Member Function Documentation

Fill an std::set using only the Observation entries.

See also
SetFromAll
-

Definition at line 564 of file CombineHarvester.h.

+

Definition at line 578 of file CombineHarvester.h.

@@ -1559,7 +1565,7 @@

Member Function Documentation

Fill an std::set using only the Process entries.

See also
SetFromAll
-

Definition at line 571 of file CombineHarvester.h.

+

Definition at line 585 of file CombineHarvester.h.

@@ -1582,7 +1588,7 @@

Member Function Documentation

Fill an std::set using only the Systematic entries.

See also
SetFromAll
-

Definition at line 578 of file CombineHarvester.h.

+

Definition at line 592 of file CombineHarvester.h.

@@ -1600,7 +1606,7 @@

Member Function Documentation

-

Definition at line 517 of file CombineHarvester_Evaluate.cc.

+

Definition at line 523 of file CombineHarvester_Evaluate.cc.

@@ -1618,7 +1624,7 @@

Member Function Documentation

-

Definition at line 527 of file CombineHarvester_Evaluate.cc.

+

Definition at line 533 of file CombineHarvester_Evaluate.cc.

@@ -1636,7 +1642,7 @@

Member Function Documentation

-

Definition at line 536 of file CombineHarvester_Evaluate.cc.

+

Definition at line 542 of file CombineHarvester_Evaluate.cc.

@@ -1657,7 +1663,7 @@

Member Function Documentation

Update the parameters to the post-fit values in a RooFitResult.

Deprecated:
For consistency and compatibility with the python interface, please use the UpdateParameters(RooFitResult const&) version of this method instead - this method will be removed in an upcoming release
-

Definition at line 571 of file CombineHarvester_Evaluate.cc.

+

Definition at line 577 of file CombineHarvester_Evaluate.cc.

@@ -1675,7 +1681,7 @@

Member Function Documentation

-

Definition at line 552 of file CombineHarvester_Evaluate.cc.

+

Definition at line 558 of file CombineHarvester_Evaluate.cc.

@@ -1692,7 +1698,7 @@

Member Function Documentation

-

Definition at line 575 of file CombineHarvester_Evaluate.cc.

+

Definition at line 581 of file CombineHarvester_Evaluate.cc.

@@ -1720,7 +1726,7 @@

Member Function Documentation

-

Definition at line 507 of file CombineHarvester_Evaluate.cc.

+

Definition at line 513 of file CombineHarvester_Evaluate.cc.

@@ -1740,7 +1746,7 @@

Member Function Documentation

-

Definition at line 585 of file CombineHarvester.h.

+

Definition at line 599 of file CombineHarvester.h.

@@ -1760,7 +1766,7 @@

Member Function Documentation

-

Definition at line 592 of file CombineHarvester.h.

+

Definition at line 606 of file CombineHarvester.h.

@@ -1780,7 +1786,7 @@

Member Function Documentation

-

Definition at line 597 of file CombineHarvester.h.

+

Definition at line 611 of file CombineHarvester.h.

@@ -1800,7 +1806,7 @@

Member Function Documentation

-

Definition at line 602 of file CombineHarvester.h.

+

Definition at line 616 of file CombineHarvester.h.

@@ -1818,7 +1824,7 @@

Member Function Documentation

-

Definition at line 583 of file CombineHarvester_Evaluate.cc.

+

Definition at line 589 of file CombineHarvester_Evaluate.cc.

@@ -1836,7 +1842,7 @@

Member Function Documentation

-

Definition at line 646 of file CombineHarvester_Evaluate.cc.

+

Definition at line 652 of file CombineHarvester_Evaluate.cc.

@@ -1874,7 +1880,7 @@

Member Function Documentation

-

Definition at line 694 of file CombineHarvester_Evaluate.cc.

+

Definition at line 700 of file CombineHarvester_Evaluate.cc.

@@ -1912,7 +1918,7 @@

Member Function Documentation

-

Definition at line 708 of file CombineHarvester_Evaluate.cc.

+

Definition at line 714 of file CombineHarvester_Evaluate.cc.

@@ -1949,7 +1955,52 @@

Member Function Documentation

-

Definition at line 722 of file CombineHarvester_Evaluate.cc.

+

Definition at line 728 of file CombineHarvester_Evaluate.cc.

+ + + + +
+
+ + + + + + + + +
void ch::CombineHarvester::AddDatacardLineAtEnd (std::string const & line)
+
+ +

Add a line of text at the end of all datacards.

+
Parameters
+ + +
lineLine of text to add
+
+
+ +

Definition at line 739 of file CombineHarvester_Evaluate.cc.

+ +
+
+ +
+
+ + + + + + + +
void ch::CombineHarvester::ClearDatacardLinesAtEnd ()
+
+ +

Clear all added datacard lines.

+ +

Definition at line 743 of file CombineHarvester_Evaluate.cc.

@@ -1983,7 +2034,7 @@

Member Function Documentation

-

Definition at line 418 of file CombineHarvester_Evaluate.cc.

+

Definition at line 425 of file CombineHarvester_Evaluate.cc.

@@ -2169,7 +2220,7 @@

Member Function Documentation

-

Definition at line 426 of file CombineHarvester_Evaluate.cc.

+

Definition at line 433 of file CombineHarvester_Evaluate.cc.

@@ -2435,7 +2486,7 @@

Member Function Documentation

-

Definition at line 638 of file CombineHarvester.h.

+

Definition at line 652 of file CombineHarvester.h.

diff --git a/classch_1_1_combine_harvester.js b/classch_1_1_combine_harvester.js index a4c426776ab..1ea9a793da3 100644 --- a/classch_1_1_combine_harvester.js +++ b/classch_1_1_combine_harvester.js @@ -70,6 +70,8 @@ var classch_1_1_combine_harvester = [ "SetGroup", "classch_1_1_combine_harvester.html#a5d75e03de3d628f7281a2e6914722bc5", null ], [ "RemoveGroup", "classch_1_1_combine_harvester.html#ac3e906d415a6d68713f08a0c3f885810", null ], [ "RenameGroup", "classch_1_1_combine_harvester.html#a750a78b28b4ae6ca2d27a34b4ac32cc9", null ], + [ "AddDatacardLineAtEnd", "classch_1_1_combine_harvester.html#a59b5a637f7f11c2ee77a9b07bc1deb02", null ], + [ "ClearDatacardLinesAtEnd", "classch_1_1_combine_harvester.html#ac431bdfafad282e891915f7488f43bce", null ], [ "GetRate", "classch_1_1_combine_harvester.html#aff4165661f9f137607d6c3c881172689", null ], [ "GetObservedRate", "classch_1_1_combine_harvester.html#a0b5444f9dcfa6fdace5fa2d8dc2ca11f", null ], [ "GetUncertainty", "classch_1_1_combine_harvester.html#a9c0e44635dc637746222f67e9be518e5", null ], diff --git a/classch_1_1_object.html b/classch_1_1_object.html index 64538220008..5ea9c2af9c8 100644 --- a/classch_1_1_object.html +++ b/classch_1_1_object.html @@ -167,6 +167,8 @@   virtual void delete_attribute (std::string const &attr_label)   +virtual void set_all_attributes (std::map< std::string, std::string > const &attrs_) +  virtual std::map< std::string, std::string > const & all_attributes () const   virtual std::string const attribute (std::string const &attr_label) const @@ -746,6 +748,32 @@

Member Function Documentation

Definition at line 41 of file Object.h.

+ + + +
+
+ + + + + +
+ + + + + + + + +
virtual void ch::Object::set_all_attributes (std::map< std::string, std::string > const & attrs_)
+
+inlinevirtual
+
+ +

Definition at line 42 of file Object.h.

+
@@ -769,7 +797,7 @@

Member Function Documentation

-

Definition at line 42 of file Object.h.

+

Definition at line 43 of file Object.h.

@@ -795,7 +823,7 @@

Member Function Documentation

-

Definition at line 43 of file Object.h.

+

Definition at line 44 of file Object.h.

diff --git a/classch_1_1_object.js b/classch_1_1_object.js index 563c7f96556..73c75fc6447 100644 --- a/classch_1_1_object.js +++ b/classch_1_1_object.js @@ -23,6 +23,7 @@ var classch_1_1_object = [ "mass", "classch_1_1_object.html#a88dfb8797821405ddc943dd9b4a0b4ce", null ], [ "set_attribute", "classch_1_1_object.html#a7fdcd9b776c2fa52ad292ef857dd285b", null ], [ "delete_attribute", "classch_1_1_object.html#afe324e1fe370f7804a30e84da0a67556", null ], + [ "set_all_attributes", "classch_1_1_object.html#a8c779be0d578124a56a17031abd86c9f", null ], [ "all_attributes", "classch_1_1_object.html#ac67ae0228db7343bdb8d408e11e19318", null ], [ "attribute", "classch_1_1_object.html#a4c0ab9bc1a210c618008faa8dd72f65d", null ], [ "swap", "classch_1_1_object.html#a9ea9cb8427d79a8fccee9409eae3f603", null ] diff --git a/classch_1_1_observation.html b/classch_1_1_observation.html index d0a5f539243..15f3db846bc 100644 --- a/classch_1_1_observation.html +++ b/classch_1_1_observation.html @@ -197,6 +197,8 @@   virtual void delete_attribute (std::string const &attr_label)   +virtual void set_all_attributes (std::map< std::string, std::string > const &attrs_) +  virtual std::map< std::string, std::string > const & all_attributes () const   virtual std::string const attribute (std::string const &attr_label) const diff --git a/classch_1_1_process.html b/classch_1_1_process.html index 43a07f3c290..473eab79c2b 100644 --- a/classch_1_1_process.html +++ b/classch_1_1_process.html @@ -149,10 +149,10 @@   TH1F ShapeAsTH1F () const   -void set_pdf (RooAbsPdf *pdf) -  -RooAbsPdf const * pdf () const -  +void set_pdf (RooAbsReal *pdf) +  +RooAbsReal const * pdf () const +  void set_data (RooAbsData *data)   RooAbsData const * data () const @@ -161,6 +161,10 @@   RooAbsReal const * norm () const   +void set_observable (RooRealVar *obs) +  +RooRealVar * observable () const +  - Public Member Functions inherited from ch::Object  Object ()   @@ -208,6 +212,8 @@   virtual void delete_attribute (std::string const &attr_label)   +virtual void set_all_attributes (std::map< std::string, std::string > const &attrs_) +  virtual std::map< std::string, std::string > const & all_attributes () const   virtual std::string const attribute (std::string const &attr_label) const @@ -227,7 +233,7 @@

Detailed Description

-

Definition at line 14 of file Process.h.

+

Definition at line 15 of file Process.h.

Constructor & Destructor Documentation

@@ -259,7 +265,7 @@
-

Definition at line 18 of file Process.cc.

+

Definition at line 20 of file Process.cc.

@@ -277,7 +283,7 @@
-

Definition at line 30 of file Process.cc.

+

Definition at line 36 of file Process.cc.

@@ -295,7 +301,7 @@
-

Definition at line 44 of file Process.cc.

+

Definition at line 52 of file Process.cc.

@@ -314,7 +320,7 @@

Member Function Documentation

-

Definition at line 54 of file Process.cc.

+

Definition at line 64 of file Process.cc.

@@ -340,7 +346,7 @@

Member Function Documentation

-

Definition at line 23 of file Process.h.

+

Definition at line 24 of file Process.h.

@@ -365,7 +371,7 @@

Member Function Documentation

-

Definition at line 24 of file Process.h.

+

Definition at line 25 of file Process.h.

@@ -393,7 +399,7 @@

Member Function Documentation

Get the process normalisation without multiplying by the RooAbsReal value (in the case that it's present)

Generally this isn't a very useful method, it just returns the value of the rate class member without multipling by the RooAbsReal term. If the process has a RooAbsReal attached then this is often an (or the) important part of determining the total process normalisation. One place this is useful is writing the rate into the text datacard.

-

Definition at line 36 of file Process.h.

+

Definition at line 46 of file Process.h.

@@ -421,7 +427,7 @@

Member Function Documentation

-

Definition at line 59 of file Process.cc.

+

Definition at line 69 of file Process.cc.

@@ -449,7 +455,7 @@

Member Function Documentation

-

Definition at line 83 of file Process.cc.

+

Definition at line 93 of file Process.cc.

@@ -474,7 +480,7 @@

Member Function Documentation

-

Definition at line 42 of file Process.h.

+

Definition at line 52 of file Process.h.

@@ -491,7 +497,7 @@

Member Function Documentation

-

Definition at line 88 of file Process.cc.

+

Definition at line 98 of file Process.cc.

@@ -508,7 +514,7 @@

Member Function Documentation

-

Definition at line 95 of file Process.cc.

+

Definition at line 105 of file Process.cc.

@@ -525,11 +531,11 @@

Member Function Documentation

-

Definition at line 102 of file Process.cc.

+

Definition at line 112 of file Process.cc.

- +
@@ -539,7 +545,7 @@

Member Function Documentation

- + @@ -551,11 +557,11 @@

Member Function Documentation

void ch::Process::set_pdf (RooAbsPdf * RooAbsReal *  pdf)
-

Definition at line 49 of file Process.h.

+

Definition at line 59 of file Process.h.

- +
@@ -563,7 +569,7 @@

Member Function Documentation

- + @@ -576,7 +582,7 @@

Member Function Documentation

RooAbsPdf const* ch::Process::pdf RooAbsReal const* ch::Process::pdf ( ) const
-

Definition at line 50 of file Process.h.

+

Definition at line 60 of file Process.h.

@@ -602,7 +608,7 @@

Member Function Documentation

-

Definition at line 52 of file Process.h.

+

Definition at line 62 of file Process.h.

@@ -627,7 +633,7 @@

Member Function Documentation

-

Definition at line 53 of file Process.h.

+

Definition at line 63 of file Process.h.

@@ -653,7 +659,7 @@

Member Function Documentation

-

Definition at line 55 of file Process.h.

+

Definition at line 65 of file Process.h.

@@ -678,7 +684,58 @@

Member Function Documentation

-

Definition at line 56 of file Process.h.

+

Definition at line 66 of file Process.h.

+ +
+ + +
+
+ + + + + +
+ + + + + + + + +
void ch::Process::set_observable (RooRealVar * obs)
+
+inline
+
+ +

Definition at line 68 of file Process.h.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + +
RooRealVar* ch::Process::observable () const
+
+inline
+
+ +

Definition at line 69 of file Process.h.

@@ -704,7 +761,7 @@

Member Function Documentation

-

Definition at line 131 of file Process.cc.

+

Definition at line 141 of file Process.cc.

@@ -741,7 +798,7 @@

Friends And Related Function Documentation

-

Definition at line 144 of file Process.cc.

+

Definition at line 154 of file Process.cc.

@@ -777,7 +834,7 @@

Friends And Related Function Documentation

-

Definition at line 20 of file Process.cc.

+

Definition at line 24 of file Process.cc.

diff --git a/classch_1_1_process.js b/classch_1_1_process.js index 6fce0a90c59..c65c760d005 100644 --- a/classch_1_1_process.js +++ b/classch_1_1_process.js @@ -14,12 +14,14 @@ var classch_1_1_process = [ "ClonedShape", "classch_1_1_process.html#abd6b57dd2665b2e4edfb9d648e09b6f8", null ], [ "ClonedScaledShape", "classch_1_1_process.html#a95f8396972318625650d3c8a773bb561", null ], [ "ShapeAsTH1F", "classch_1_1_process.html#a75dddf259aac5a30b652a7f838fccc5d", null ], - [ "set_pdf", "classch_1_1_process.html#a29daf76545fd7b93af93aa0b42af1790", null ], - [ "pdf", "classch_1_1_process.html#afbce7b1c6d9fc6cfcebdf4b3c54e6bd3", null ], + [ "set_pdf", "classch_1_1_process.html#ad7adabf3df5395b10b80c77af00648ae", null ], + [ "pdf", "classch_1_1_process.html#a40aab277133c48b1852d33e6fdb35ecf", null ], [ "set_data", "classch_1_1_process.html#a97283db14e35e64eef1f0231c8cdd64c", null ], [ "data", "classch_1_1_process.html#a2e2e290f4c554cf76456180913188b7b", null ], [ "set_norm", "classch_1_1_process.html#a0d192379f39205b78311bd0d8cb13f20", null ], [ "norm", "classch_1_1_process.html#ab41c6e3bf638dbb480404166185ed0a1", null ], + [ "set_observable", "classch_1_1_process.html#af8158fc6ada12e951a6c84504d05444f", null ], + [ "observable", "classch_1_1_process.html#a25e01410aada0818fa20a95a30a96025", null ], [ "operator<<", "classch_1_1_process.html#ad2d1aa710013a7a2eac899ed820a8f29", null ], [ "swap", "classch_1_1_process.html#acdd8a9af1254395822e5c250053397aa", null ] ]; \ No newline at end of file diff --git a/classch_1_1_systematic.html b/classch_1_1_systematic.html index 43e543ea3df..454218d8d76 100644 --- a/classch_1_1_systematic.html +++ b/classch_1_1_systematic.html @@ -219,6 +219,8 @@   virtual void delete_attribute (std::string const &attr_label)   +virtual void set_all_attributes (std::map< std::string, std::string > const &attrs_) +  virtual std::map< std::string, std::string > const & all_attributes () const   virtual std::string const attribute (std::string const &attr_label) const diff --git a/classes.html b/classes.html index 978eba71fe9..ad284aa71c4 100644 --- a/classes.html +++ b/classes.html @@ -103,32 +103,33 @@
A | B | C | E | F | H | M | O | P | S | T
- + - - - + + - + - - - - - + + +
  A  
-
  F  
-
Process (ch)   TuplePrinter< Tuple, 0 > (ch::tupleprint)   convert_cpp_map_to_py_dict   
  S  
+
CombineHarvester (ch)   Process (ch)   TuplePrinter< Tuple, 0 > (ch::tupleprint)   convert_cpp_map_to_py_dict   
  F  
+
  S  
TuplePrinter< Tuple, 1 > (ch::tupleprint)   convert_cpp_root_to_py_root   
AutoRebin (ch)   FnTimer (ch)   
  a  
+
AutoRebin (ch)   
  a  
convert_cpp_set_to_py_list   
  B  
-
  H  
-
SOverBInfo (ch)   convert_cpp_vector_to_py_list   
Systematic (ch)   analysis (ch::syst)   convert_py_root_to_cpp_root   
BinByBinFactory (ch)   HistMapping (ch)   SystMap (ch::syst)   
  b  
+
FnTimer (ch)   SOverBInfo (ch)   convert_cpp_vector_to_py_list   
  H  
+
Systematic (ch)   analysis (ch::syst)   convert_py_root_to_cpp_root   
BinByBinFactory (ch)   SystMap (ch::syst)   
  b  
convert_py_seq_to_cpp_vector   
BkgInfo   
  O  
-
SystMapAsymm (ch::syst)   convert_py_tup_to_cpp_pair   
BkgInfo   HistMapping (ch)   SystMapAsymm (ch::syst)   convert_py_tup_to_cpp_pair   
  C  
+
  O  
SystMapFunc (ch::syst)   bin (ch::syst)   
  e  
Object (ch)   
  T  
+
  T  
bin_id (ch::syst)   
CardWriter (ch)   Observation (ch)   
  c  
+
CardWriter (ch)   Object (ch)   
  c  
era (ch::syst)   
ColInfo   
  P  
-
FnTimer::Token (ch)   
  m  
+
CMSHistFuncFactory (ch)   Observation (ch)   FnTimer::Token (ch)   
  m  
CombineHarvester (ch)   TuplePrinter (ch::tupleprint)   channel (ch::syst)   
Parameter (ch)   mass (ch::syst)   
ColInfo   
  P  
+
TuplePrinter (ch::tupleprint)   channel (ch::syst)   
mass (ch::syst)   
Parameter (ch)   
A | B | C | E | F | H | M | O | P | S | T
diff --git a/dir_67357b0f7d17e3dc186f37df5b958e70.html b/dir_67357b0f7d17e3dc186f37df5b958e70.html index fcd57d4b9ec..1e758701b01 100644 --- a/dir_67357b0f7d17e3dc186f37df5b958e70.html +++ b/dir_67357b0f7d17e3dc186f37df5b958e70.html @@ -103,6 +103,8 @@ + + diff --git a/dir_67357b0f7d17e3dc186f37df5b958e70.js b/dir_67357b0f7d17e3dc186f37df5b958e70.js index a890c000640..1c601842a04 100644 --- a/dir_67357b0f7d17e3dc186f37df5b958e70.js +++ b/dir_67357b0f7d17e3dc186f37df5b958e70.js @@ -1,5 +1,8 @@ var dir_67357b0f7d17e3dc186f37df5b958e70 = [ + [ "CMSHistFuncFactory.h", "_c_m_s_hist_func_factory_8h.html", [ + [ "CMSHistFuncFactory", "classch_1_1_c_m_s_hist_func_factory.html", "classch_1_1_c_m_s_hist_func_factory" ] + ] ], [ "MorphFunctions.h", "_morph_functions_8h.html", "_morph_functions_8h" ], [ "Python.h", "_python_8h.html", "_python_8h" ] ]; \ No newline at end of file diff --git a/dir_a11d860a120a6ee231a0ac3c6fec920f.html b/dir_a11d860a120a6ee231a0ac3c6fec920f.html index 87040324d3f..ac17d5aa086 100644 --- a/dir_a11d860a120a6ee231a0ac3c6fec920f.html +++ b/dir_a11d860a120a6ee231a0ac3c6fec920f.html @@ -103,6 +103,8 @@

Files

file  CMSHistFuncFactory.h [code]
 
file  MorphFunctions.h [code]
 
file  Python.h [code]
+ + diff --git a/dir_a11d860a120a6ee231a0ac3c6fec920f.js b/dir_a11d860a120a6ee231a0ac3c6fec920f.js index 1f4f1e614a0..eab960e431c 100644 --- a/dir_a11d860a120a6ee231a0ac3c6fec920f.js +++ b/dir_a11d860a120a6ee231a0ac3c6fec920f.js @@ -1,5 +1,6 @@ var dir_a11d860a120a6ee231a0ac3c6fec920f = [ + [ "CMSHistFuncFactory.cc", "_c_m_s_hist_func_factory_8cc.html", null ], [ "MorphFunctions.cc", "_morph_functions_8cc.html", "_morph_functions_8cc" ], [ "Python.cc", "_python_8cc.html", "_python_8cc" ] ]; \ No newline at end of file diff --git a/files.html b/files.html index e9cc8495259..f979d83a997 100644 --- a/files.html +++ b/files.html @@ -104,11 +104,13 @@
[detail level 123]

Files

file  CMSHistFuncFactory.cc [code]
 
file  MorphFunctions.cc [code]
 
file  Python.cc [code]
- - - - - + + + + + + + diff --git a/functions.html b/functions.html index b37fd05cf19..5522369dbd7 100644 --- a/functions.html +++ b/functions.html @@ -103,6 +103,9 @@

- a -

- - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  CombinePdfs
  interface
 MorphFunctions.h
 Python.h
  src
 MorphFunctions.cc
 Python.cc
 CMSHistFuncFactory.h
 MorphFunctions.h
 Python.h
  src
 CMSHistFuncFactory.cc
 MorphFunctions.cc
 Python.cc
  CombineTools
  bin
 MSSMYieldTable.cpp
 CBkgInfo
 Cch::CardWriterAutomates the writing of datacards into directory structures
 Cch::syst::channel
 CColInfo
 Cch::CombineHarvester
 Cconvert_cpp_map_to_py_dict< TKey, TValue >Convert a C++ map to a python dict
 Cconvert_cpp_root_to_py_root< T >Covert a C++ ROOT type to a PyROOT type
 Cconvert_cpp_set_to_py_list< T >Convert a C++ set to a python list
 Cconvert_cpp_vector_to_py_list< T >Convert a C++ vector to a python list
 Cconvert_py_root_to_cpp_root< T >
 Cconvert_py_seq_to_cpp_vector< T >
 Cconvert_py_tup_to_cpp_pair< T, U >
 Cch::syst::era
 Cch::FnTimerDetermine the total amount of time spent in a function
 Cch::HistMapping
 Cch::syst::mass
 Cch::Object
 Cch::Observation
 Cch::Process
 Cch::Systematic
 Cch::Parameter
 Cch::syst::process
 Cch::SOverBInfo
 Cch::syst::SystMap< T >
 Cch::syst::SystMapAsymm< T >
 Cch::syst::SystMapFunc< T >
 Cch::FnTimer::Token
 Cch::tupleprint::TuplePrinter< Tuple, N >
 Cch::tupleprint::TuplePrinter< Tuple, 0 >
 Cch::tupleprint::TuplePrinter< Tuple, 1 >
 Cch::CMSHistFuncFactory
 CColInfo
 Cch::CombineHarvester
 Cconvert_cpp_map_to_py_dict< TKey, TValue >Convert a C++ map to a python dict
 Cconvert_cpp_root_to_py_root< T >Covert a C++ ROOT type to a PyROOT type
 Cconvert_cpp_set_to_py_list< T >Convert a C++ set to a python list
 Cconvert_cpp_vector_to_py_list< T >Convert a C++ vector to a python list
 Cconvert_py_root_to_cpp_root< T >
 Cconvert_py_seq_to_cpp_vector< T >
 Cconvert_py_tup_to_cpp_pair< T, U >
 Cch::syst::era
 Cch::FnTimerDetermine the total amount of time spent in a function
 Cch::HistMapping
 Cch::syst::mass
 Cch::Object
 Cch::Observation
 Cch::Process
 Cch::Systematic
 Cch::Parameter
 Cch::syst::process
 Cch::SOverBInfo
 Cch::syst::SystMap< T >
 Cch::syst::SystMapAsymm< T >
 Cch::syst::SystMapFunc< T >
 Cch::FnTimer::Token
 Cch::tupleprint::TuplePrinter< Tuple, N >
 Cch::tupleprint::TuplePrinter< Tuple, 0 >
 Cch::tupleprint::TuplePrinter< Tuple, 1 >
diff --git a/hierarchy.js b/hierarchy.js index 726c63dad63..f9545925788 100644 --- a/hierarchy.js +++ b/hierarchy.js @@ -8,6 +8,7 @@ var hierarchy = [ "BkgInfo", "struct_bkg_info.html", null ], [ "ch::CardWriter", "classch_1_1_card_writer.html", null ], [ "ch::syst::channel", "structch_1_1syst_1_1channel.html", null ], + [ "ch::CMSHistFuncFactory", "classch_1_1_c_m_s_hist_func_factory.html", null ], [ "ColInfo", "struct_col_info.html", null ], [ "ch::CombineHarvester", "classch_1_1_combine_harvester.html", null ], [ "convert_cpp_map_to_py_dict< TKey, TValue >", "structconvert__cpp__map__to__py__dict.html", null ], diff --git a/namespacech.html b/namespacech.html index e821bcf467c..6dfcf259f24 100644 --- a/namespacech.html +++ b/namespacech.html @@ -124,6 +124,8 @@ class  CardWriter  Automates the writing of datacards into directory structures. More...
  +class  CMSHistFuncFactory +  class  CombineHarvester   class  FnTimer @@ -268,8 +270,8 @@   void ParseCombineWorkspacePy (CombineHarvester &cb, RooWorkspace const &ws, std::string const &modelcfg, std::string const &data, bool verbose=false)   -RooAddPdf * FindAddPdf (RooAbsPdf *input) -  +RooAbsReal * FindAddPdf (RooAbsReal *input) +  double IntegrateFloatRange (TH1F const *hist, double xmin, double xmax)   std::unique_ptr< TH1 > GetClonedTH1 (TFile *file, std::string const &path) @@ -1710,7 +1712,7 @@

Function Documentation

-

Definition at line 20 of file ParseCombineWorkspace.cc.

+

Definition at line 22 of file ParseCombineWorkspace.cc.

@@ -1756,25 +1758,25 @@

Function Documentation

-

Definition at line 14 of file ParseCombineWorkspace.cc.

+

Definition at line 16 of file ParseCombineWorkspace.cc.

- +
- + - +
RooAddPdf * ch::FindAddPdf RooAbsReal * ch::FindAddPdf (RooAbsPdf * RooAbsReal *  input)
-

Definition at line 99 of file ParseCombineWorkspace.cc.

+

Definition at line 128 of file ParseCombineWorkspace.cc.

@@ -2184,7 +2186,7 @@

Function Documentation

-

Definition at line 82 of file Utilities.h.

+

Definition at line 83 of file Utilities.h.

@@ -2222,7 +2224,7 @@

Function Documentation

-

Definition at line 100 of file Utilities.h.

+

Definition at line 101 of file Utilities.h.

@@ -2302,7 +2304,7 @@

Function Documentation

-

Definition at line 180 of file Utilities.cc.

+

Definition at line 181 of file Utilities.cc.

@@ -2320,7 +2322,7 @@

Function Documentation

-

Definition at line 190 of file Utilities.cc.

+

Definition at line 191 of file Utilities.cc.

@@ -2338,7 +2340,7 @@

Function Documentation

-

Definition at line 223 of file Utilities.cc.

+

Definition at line 224 of file Utilities.cc.

@@ -2356,7 +2358,7 @@

Function Documentation

-

Definition at line 240 of file Utilities.cc.

+

Definition at line 241 of file Utilities.cc.

@@ -2397,7 +2399,7 @@

Function Documentation

-

Definition at line 248 of file Utilities.cc.

+

Definition at line 249 of file Utilities.cc.

@@ -2437,7 +2439,7 @@

Function Documentation

-

Definition at line 280 of file Utilities.cc.

+

Definition at line 281 of file Utilities.cc.

@@ -2455,7 +2457,7 @@

Function Documentation

-

Definition at line 338 of file Utilities.cc.

+

Definition at line 339 of file Utilities.cc.

@@ -2473,7 +2475,7 @@

Function Documentation

-

Definition at line 348 of file Utilities.cc.

+

Definition at line 349 of file Utilities.cc.

@@ -2503,7 +2505,7 @@

Function Documentation

Returns
A formatted string of the tuple elements
-

Definition at line 213 of file Utilities.h.

+

Definition at line 214 of file Utilities.h.

@@ -2543,7 +2545,7 @@

Function Documentation

Returns
Relative path from p_from to p_to
-

Definition at line 312 of file Utilities.cc.

+

Definition at line 313 of file Utilities.cc.

@@ -2767,7 +2769,7 @@

Function Documentation

-

Definition at line 20 of file Process.cc.

+

Definition at line 24 of file Process.cc.

@@ -2795,7 +2797,7 @@

Function Documentation

-

Definition at line 144 of file Process.cc.

+

Definition at line 154 of file Process.cc.

diff --git a/namespacech.js b/namespacech.js index ef7778d95a7..6ce25490152 100644 --- a/namespacech.js +++ b/namespacech.js @@ -5,6 +5,7 @@ var namespacech = [ "AutoRebin", "classch_1_1_auto_rebin.html", "classch_1_1_auto_rebin" ], [ "BinByBinFactory", "classch_1_1_bin_by_bin_factory.html", "classch_1_1_bin_by_bin_factory" ], [ "CardWriter", "classch_1_1_card_writer.html", "classch_1_1_card_writer" ], + [ "CMSHistFuncFactory", "classch_1_1_c_m_s_hist_func_factory.html", "classch_1_1_c_m_s_hist_func_factory" ], [ "CombineHarvester", "classch_1_1_combine_harvester.html", "classch_1_1_combine_harvester" ], [ "FnTimer", "classch_1_1_fn_timer.html", "classch_1_1_fn_timer" ], [ "HistMapping", "structch_1_1_hist_mapping.html", "structch_1_1_hist_mapping" ], diff --git a/namespacemembers.html b/namespacemembers.html index 38251833a35..9d2bc1602f4 100644 --- a/namespacemembers.html +++ b/namespacemembers.html @@ -255,7 +255,7 @@

- f -