ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_2016-07-19_isr_susy_talk.cxx
Go to the documentation of this file.
1 #include "plot_dilep_angles.hpp"
2 
3 #include <cmath>
4 #include <algorithm>
5 
6 #include "TError.h"
7 #include "TVector2.h"
8 #include "TString.h"
9 
10 #include "plot_maker.hpp"
11 #include "plot_opt.hpp"
12 #include "palette.hpp"
13 #include "histo_stack.hpp"
14 #include "event_scan.hpp"
15 #include "utilities.hpp"
16 
17 using namespace std;
18 using namespace PlotOptTypes;
19 
20 namespace {
21  const string isrtype = "ttisr";
22  bool do_tt1l = false;
23  double lumi = 4.34;
24  bool single_thread = false;
25 
26  double CSVMedium = 0.800;
27 }
28 
29 void addSlices(PlotMaker &pm, const vector<double> slices, NamedFunc svar,
30  const vector<double> xbins, NamedFunc xvar, string xlabel,
31  const NamedFunc &baseline, const NamedFunc &weight,
32  const vector<shared_ptr<Process> > &proc,
33  const vector<PlotOpt> &plot_types, int tag_digits=0);
34 
35 bool isRelIsoEl(const Baby &b, size_t iel);
38 
39 bool isRelIsoMu(const Baby &b, size_t imu);
42 
43 bool isGoodJet(const Baby &b, size_t ijet);
44 NamedFunc::VectorType isrJetsPt(const Baby &b, float ptThresh=30.);
46 
47 NamedFunc::ScalarType nJetsWeights_ttisr(const Baby &b, bool use_baby_nisr);
49 
50 
51 int main(){
52  gErrorIgnoreLevel = 6000;
53 
54 
55  string bfolder("");
56  string hostname = execute("echo $HOSTNAME");
57  if(Contains(hostname, "cms") || Contains(hostname, "compute-"))
58  bfolder = "/net/cms2"; // In laptops, you can't create a /net folder
59 
60  Palette colors("txt/colors.txt", "default");
61 
63  string dir_mc_isr = bfolder+"/cms2r0/babymaker/babies/2016_06_14/mc/merged_"+isrtype+"/";
64  auto tt1l = Proc<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
65  {dir_mc_isr+"*_TTJets*SingleLept*.root"}, "ntruleps<=1");
66  auto tt2l = Proc<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
67  {dir_mc_isr+"*_TTJets*DiLept*.root"}, "ntruleps>=2");
68  auto single_t = Proc<Baby_full>("Single t", Process::Type::background, colors("single_t"),
69  {dir_mc_isr+"*_ST_*.root"});
70  auto dyjets = Proc<Baby_full>("DY+jets", Process::Type::background, kOrange-3,
71  //{dir_mc_isr+"*DYJetsToLL_M-50_Tu*.root"});
72  {dir_mc_isr+"*DYJetsToLL_M-50_*.root"},"stitch"); // Inclusive + HT-binned DY
73  auto ttv = Proc<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
74  {dir_mc_isr+"*_TTWJets*.root", dir_mc_isr+"*_TTZTo*.root", dir_mc_isr+"*_TTGJets*.root"});
75  auto other = Proc<Baby_full>("Other", Process::Type::background, colors("other"),
76  {dir_mc_isr+"*_WJetsToLNu*.root",
77  // dir_mc_isr+"*QCD_HT*.root", // Has some ugly high-weight events
78  dir_mc_isr+"*_ZJet*.root", dir_mc_isr+"*_WWTo*.root",
79  dir_mc_isr+"*ggZH_HToBB*.root", dir_mc_isr+"*ttHJetTobb*.root",
80  dir_mc_isr+"*_TTTT_*.root",
81  dir_mc_isr+"*_WH_HToBB*.root", dir_mc_isr+"*_WZTo*.root",
82  dir_mc_isr+"*_ZH_HToBB*.root", dir_mc_isr+"_ZZ_*.root"});
83 
85  string dir_mc_isr_alg = bfolder+"/cms2r0/babymaker/babies/2016_07_18/mc/merged_"+isrtype+"/";
86  auto tt1l_alg = Proc<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
87  {dir_mc_isr_alg+"*_TTJets*SingleLept*.root"}, "ntruleps<=1");
88  auto tt2l_alg = Proc<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
89  {dir_mc_isr_alg+"*_TTJets*DiLept*.root"}, "ntruleps>=2");
90 
92  auto wjets = Proc<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
93  {dir_mc_isr+"*_WJetsToLNu*.root"},
94  "stitch");
95  auto other_w = Proc<Baby_full>("Other", Process::Type::background, colors("other"),
96  {dir_mc_isr+"*DYJetsToLL_M-50_Tu*.root",dir_mc_isr+"*QCD_HT*.root",
97  dir_mc_isr+"*_ZJet*.root", dir_mc_isr+"*_WWTo*.root",
98  dir_mc_isr+"*ggZH_HToBB*.root", dir_mc_isr+"*ttHJetTobb*.root",
99  dir_mc_isr+"*_TTTT_*.root",
100  dir_mc_isr+"*_WH_HToBB*.root", dir_mc_isr+"*_WZTo*.root",
101  dir_mc_isr+"*_ZH_HToBB*.root", dir_mc_isr+"_ZZ_*.root"});
102 
103  string dir_data_isr = bfolder+"/cms2r0/babymaker/babies/2016_06_26/data/skim_"+isrtype+"/";
104  string lumi_label = RoundNumber(lumi,1).Data();
105  auto data = Proc<Baby_full>("Data "+lumi_label+" fb^{-1}", Process::Type::data, kBlack,
106  {dir_data_isr+"*.root"},
107  "pass && (trig[19]||trig[23])");
108 
109  vector<shared_ptr<Process> > procs;
110  if (isrtype=="zisr") procs = {data, dyjets, tt2l, tt1l, single_t, ttv, other};
111  else if (isrtype=="ttisr") procs = {data, tt2l, tt1l, dyjets, single_t, ttv, other};
112  else if (isrtype=="wisr") procs = {data, wjets, tt1l, tt2l, single_t, ttv, other_w};
113  else {cout<<isrtype<<" not supported, exiting"<<endl<<endl; return 0;}
114 
115  vector<shared_ptr<Process> > procs_alg = {data, tt2l_alg, tt1l_alg, dyjets, single_t, ttv, other};
116 
117 
119  string dir_mc_std(bfolder+"/cms2r0/babymaker/babies/2016_06_14/mc/merged_standard/");
120  string dir_data_std(bfolder+"/cms2r0/babymaker/babies/2016_06_26/data/merged_standard/");
121 
122  auto std_data = Proc<Baby_full>("Data", Process::Type::data, kBlack,
123  {dir_data_std+"/*.root"},
124  "(trig[4]||trig[8]||trig[13]||trig[33])");
125 
126  auto std_tt1l = Proc<Baby_full>("tt 1lep", Process::Type::background, colors("tt_1l"),
127  {dir_mc_std+"*_TTJets*SingleLept*.root"},
128  "ntruleps==1");
129  auto std_tt2l = Proc<Baby_full>("tt 2lep", Process::Type::background, colors("tt_2l"),
130  {dir_mc_std+"*_TTJets*DiLept*.root"},
131  "ntruleps==2");
132  auto std_wjets = Proc<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
133  {dir_mc_std+"*_WJetsToLNu*.root"},
134  "stitch");
135  auto std_singlet = Proc<Baby_full>("Single t", Process::Type::background, colors("single_t"),
136  {dir_mc_std+"*_ST_*.root"});
137  auto std_ttv = Proc<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
138  {dir_mc_std+"*_TTWJets*.root", dir_mc_std+"*_TTZTo*.root"});
139  auto std_other = Proc<Baby_full>("Other", Process::Type::background, colors("other"),
140  {dir_mc_std+"*DYJetsToLL*.root",dir_mc_std+"*QCD_HT*.root",
141  dir_mc_std+"*_ZJet*.root",dir_mc_std+"*_ttHJetTobb*.root",
142  dir_mc_std+"*_TTGJets*.root",dir_mc_std+"*_TTTT*.root",
143  dir_mc_std+"*_WH_HToBB*.root",dir_mc_std+"*_ZH_HToBB*.root",
144  dir_mc_std+"*_WWTo*.root",dir_mc_std+"*_WZ*.root",dir_mc_std+"*_ZZ_*.root"},
145  "stitch");
146 
147  string dir_mc_std_alg = bfolder+"/cms2r0/babymaker/babies/2016_07_18/mc/merged_standard/";
148  auto std_tt1l_alg = Proc<Baby_full>("tt 1lep", Process::Type::background, colors("tt_1l"),
149  {dir_mc_std_alg+"*_TTJets*SingleLept*.root"},
150  "ntruleps==1");
151  auto std_tt2l_alg = Proc<Baby_full>("tt 2lep", Process::Type::background, colors("tt_2l"),
152  {dir_mc_std_alg+"*_TTJets*DiLept*.root"},
153  "ntruleps==2");
154 
155  vector<shared_ptr<Process> > procs_1l = {std_data, std_tt1l, std_tt2l, std_wjets, std_singlet, std_ttv, std_other};
156  vector<shared_ptr<Process> > procs_1l_alg = {std_data, std_tt1l_alg, std_tt2l_alg, std_wjets, std_singlet, std_ttv, std_other};
157 
158  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
159  log_lumi.Title(TitleType::info)
160  .Bottom(BottomType::ratio)
161  .YAxis(YAxisType::log)
162  .Stack(StackType::data_norm);
163  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
164  PlotOpt log_shapes = log_lumi().Stack(StackType::shapes)
165  .Bottom(BottomType::off)
166  .ShowBackgroundError(false);
167  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
168  vector<PlotOpt> plot_types = {log_lumi, lin_lumi};
169  vector<PlotOpt> plot_vals = {lin_lumi().PrintVals(true)};
170  PlotMaker pm;
171 
172  // tt_isr skim def:
173  // "nvleps==2 && nleps>=1 && nbm==2 &&
174  // max(Max$(mus_pt*(mus_tight&&mus_reliso<.1)),Max$(els_pt*(els_tight&&els_reliso<.1)))>30"
175  NamedFunc nreliso_els("nreliso_els",nRelIsoEls);
176  NamedFunc nreliso_mus("nreliso_mus",nRelIsoMus);
177  NamedFunc baseline = "nleps==2" && nreliso_els+nreliso_mus>=1;
178  NamedFunc baseline_w = nreliso_els+nreliso_mus==1 && "ht>200&&met>100&&nbl==0";
179  NamedFunc baseline_1l = "nleps==1 && ht>500 && met>200 && nbm>=1 && pass";
180  if(isrtype=="wisr") baseline = baseline_w;
181 
182  NamedFunc max_reliso_elspt("max_reliso_elspt",maxRelIsoElsPt);
183  NamedFunc max_reliso_muspt("max_reliso_muspt",maxRelIsoMusPt);
184  NamedFunc isr_jetspt("isr_jetspt",[&](const Baby &b){
185  return isrJetsPt(b, 30.);
186  });
187  NamedFunc nisrjets("nisrjets", [&](const Baby &b){
188  return isrJetsPt(b, 30.).size();
189  });
190  NamedFunc isr_ht("isr_ht", [&](const Baby &b){
191  vector<double> jets_pt = isrJetsPt(b, 30.);
192  double ht = 0;
193  for (auto &jpt: jets_pt) ht += jpt;
194  return ht;
195  });
196  NamedFunc isr_jetspt20("isr_jetspt20",[&](const Baby &b){
197  return isrJetsPt(b, 20);
198  });
199  NamedFunc nisrjets20("nisrjets20", [&](const Baby &b){
200  return isrJetsPt(b, 20).size();
201  });
202  NamedFunc nisrjets50("nisrjets50", [&](const Baby &b){
203  return isrJetsPt(b, 50).size();
204  });
205  NamedFunc nisrjets75("nisrjets75", [&](const Baby &b){
206  return isrJetsPt(b, 75).size();
207  });
208  NamedFunc isr_syspt("isr_syspt", isrSystemPt);
209 
210  // definitions for njets in slices of ISR pT
211  const vector<double> isr_syspt_slices = {0, 100, 200, 300};
212  const vector<double> nisrjet_bins = {-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5};
213  vector<double> nisrjet_bins_vals = {-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5};
214  if(isrtype!="ttisr") nisrjet_bins_vals = nisrjet_bins;
215 
216  // definitions for ISR pT in slices of njets
217  vector<double> nisrjet_slices = {0,1,2,3,4,5};
218  const vector<double> isr_syspt_bins = {0, 50, 100, 150, 200, 300, 400, 600, 800};
219 
220  const vector<double> isr_ht_slices = {0,100, 200, 300, 400, 500, 2000};
221  const vector<double> isr_ht_bins = {0,100, 200, 300};
222 
223  vector<double> ptbins = {30,40,50,75,100,150,200,300,400,600};
224  vector<double> ptbins_zoom = {20,25,30,35,40,50,75,100,150,200};
225 
226  vector<NamedFunc> weight_opts;
227  weight_opts.push_back(NamedFunc("default", [](const Baby &b) -> NamedFunc::ScalarType{return b.weight()/b.eff_trig()/b.w_toppt();}));
228  if (isrtype=="ttisr"){
229  //reweight TTJets only according to nisr = b.njets()-2 --> perfect closure
230  weight_opts.push_back(NamedFunc("w_ttisr_njets", [](const Baby &b) -> NamedFunc::ScalarType{return nJetsWeights_ttisr(b, false);}));
231  //reweight TTJets only according to nisr = b.nisr() --> honest closure
232  weight_opts.push_back(NamedFunc("w_ttisr_alg", [](const Baby &b) -> NamedFunc::ScalarType{return nJetsWeights_ttisr(b, true);}));
233  } else if (isrtype=="zisr"){
234  weight_opts.push_back(NamedFunc("w_visr", nJetsWeights_visr));
235  }
236  for (const auto &iweight: weight_opts){
237  vector<shared_ptr<Process> > *iprocs = &procs;
238  if(iweight.PlainName()=="w_ttisr_alg") iprocs = &procs_alg;
239  if(do_tt1l) {
240  if(iweight.PlainName()=="w_ttisr_alg")
241  pm.Push<HistoStack>(HistoDef("tt1l", 13, -0.5, 12.5, "njets", "Number of jets", baseline_1l, iweight), procs_1l_alg, plot_types);
242  else
243  pm.Push<HistoStack>(HistoDef("tt1l", 13, -0.5, 12.5, "njets", "Number of jets", baseline_1l, iweight), procs_1l, plot_types);
244  } else {
245  addSlices(pm, isr_syspt_slices, isr_syspt, nisrjet_bins, nisrjets, "ISR jet multiplicity", baseline, iweight, *iprocs, plot_types);
246  addSlices(pm, nisrjet_slices, nisrjets, isr_syspt_bins, isr_syspt, "ISR p_{T} [GeV]", baseline, iweight, *iprocs, {log_lumi});
247  addSlices(pm, isr_ht_slices, isr_ht, isr_syspt_bins, isr_syspt, "ISR p_{T} [GeV]", baseline, iweight, *iprocs, {log_lumi});
248  addSlices(pm, isr_ht_slices, isr_ht, nisrjet_bins, nisrjets, "ISR jet multiplicity", baseline, iweight, *iprocs, {log_lumi});
249  addSlices(pm, nisrjet_slices, nisrjets, isr_syspt_bins, isr_ht, "ISR H_{T} [GeV]", baseline, iweight, *iprocs, {log_lumi});
250 
251  pm.Push<HistoStack>(HistoDef(isrtype, isr_syspt_bins, isr_syspt, "ISR p_{T} [GeV]", baseline && "ht>300", iweight), *iprocs, vector<PlotOpt>({log_lumi}));
252  pm.Push<HistoStack>(HistoDef(isrtype, ptbins, isr_jetspt[0.], "Leading ISR jet p_{T} [GeV]", baseline && nisrjets>0., iweight), *iprocs, plot_types);
253  pm.Push<HistoStack>(HistoDef(isrtype, ptbins, isr_jetspt[1], "2^{nd} ISR jet p_{T} [GeV]", baseline && nisrjets>1, iweight), *iprocs, plot_types);
254  pm.Push<HistoStack>(HistoDef(isrtype, ptbins, isr_jetspt[2], "3^{rd} ISR jet p_{T} [GeV]", baseline && nisrjets>2, iweight), *iprocs, plot_types);
255  pm.Push<HistoStack>(HistoDef(isrtype, ptbins, isr_jetspt[3], "4^{th} ISR jet p_{T} [GeV]", baseline && nisrjets>3, iweight), *iprocs, plot_types);
256 
257  pm.Push<HistoStack>(HistoDef(isrtype, ptbins_zoom, isr_jetspt20[0.], "Leading ISR jet p_{T} [GeV]", baseline && nisrjets20>0., iweight), *iprocs, plot_types);
258  pm.Push<HistoStack>(HistoDef(isrtype, ptbins_zoom, isr_jetspt20[1], "2^{nd} ISR jet p_{T} [GeV]", baseline && nisrjets20>1, iweight), *iprocs, plot_types);
259  pm.Push<HistoStack>(HistoDef(isrtype, ptbins_zoom, isr_jetspt20[2], "3^{rd} ISR jet p_{T} [GeV]", baseline && nisrjets20>2, iweight), *iprocs, plot_types);
260  pm.Push<HistoStack>(HistoDef(isrtype, ptbins_zoom, isr_jetspt20[3], "4^{th} ISR jet p_{T} [GeV]", baseline && nisrjets20>3, iweight), *iprocs, plot_types);
261 
262  pm.Push<HistoStack>(HistoDef(isrtype, ptbins, max_reliso_elspt, "Leading electron p_{T} [GeV]", baseline && nreliso_els>0., iweight), *iprocs, plot_types);
263  pm.Push<HistoStack>(HistoDef(isrtype, ptbins, max_reliso_muspt, "Leading muon p_{T} [GeV]", baseline && nreliso_mus>0., iweight), *iprocs, plot_types);
264 
265  pm.Push<HistoStack>(HistoDef(isrtype,20,0.,500., "met", "MET [GeV]", baseline, iweight), *iprocs, plot_types);
266  pm.Push<HistoStack>(HistoDef(isrtype,15,0.,1500., "ht", "H_{T} [GeV]", baseline, iweight), *iprocs, plot_types);
267  pm.Push<HistoStack>(HistoDef(isrtype,15,0.,1500., "mj14", "M_{J} [GeV]", baseline, iweight), *iprocs, plot_types);
268  pm.Push<HistoStack>(HistoDef(isrtype+"_vals",nisrjet_bins_vals, nisrjets, "ISR jet multiplicity", baseline, iweight), *iprocs, plot_vals);
269  pm.Push<HistoStack>(HistoDef(isrtype,nisrjet_bins, nisrjets50, "Number of 50 GeV ISR jets", baseline, iweight), *iprocs, plot_types);
270  pm.Push<HistoStack>(HistoDef(isrtype,nisrjet_bins, nisrjets75, "Number of 75 GeV ISR jets", baseline, iweight), *iprocs, plot_types);
271  if(isrtype=="zisr"){
272  pm.Push<HistoStack>(HistoDef(isrtype,nisrjet_bins, nisrjets, "ISR jet multiplicity", baseline && "ht>200", iweight), *iprocs, plot_types);
273  pm.Push<HistoStack>(HistoDef(isrtype,isr_syspt_bins, isr_syspt, "ISR p_{T} [GeV]", baseline && "ht>200", iweight), *iprocs, plot_types);
274  }
275  } // if not wjets_tt1l
276  } // Loop over weights
277 
278 
279 
280  if (single_thread) pm.multithreaded_ = false;
281  pm.MakePlots(lumi);
282 }
283 
284 void addSlices(PlotMaker &pm, const vector<double> slices, NamedFunc svar,
285  const vector<double> xbins, NamedFunc xvar, string xlabel,
286  const NamedFunc &baseline, const NamedFunc &weight,
287  const vector<shared_ptr<Process> > &proc,
288  const vector<PlotOpt> &plot_types, int tag_digits){
289 
290  //add the inclusive version first
291  pm.Push<HistoStack>(HistoDef(isrtype+"_incl", xbins, xvar, xlabel, baseline, weight), proc, plot_types);
292  for(unsigned i(0); i<slices.size(); i++){
293  NamedFunc cut = baseline && svar>=slices[i];
294  if (i<(slices.size()-1)) cut = cut && svar<slices[i+1];
295 
296  string tag = isrtype+"_"+svar.PrettyName()+RoundNumber(slices[i],tag_digits).Data();
297  pm.Push<HistoStack>(HistoDef(tag, xbins, xvar, xlabel, cut, weight), proc, plot_types);
298  }
299 }
300 
301 bool isRelIsoEl(const Baby &b, size_t iel){
302  return iel<b.els_pt()->size()
303  && b.els_pt()->at(iel)>30.
304  && fabs(b.els_sceta()->at(iel))<2.
305  && b.els_tight()->at(iel)
306  && b.els_reliso()->at(iel) < 0.1;
307 }
308 
310  int nels = 0;
311  for (size_t iel(0); iel<b.els_pt()->size(); iel++){
312  if (isRelIsoEl(b,iel)) nels++;
313  }
314  return nels;
315 }
316 
318  double max_pt = 0;
319  for (size_t iel(0); iel<b.els_pt()->size(); iel++){
320  if (isRelIsoEl(b,iel) && b.els_pt()->at(iel)>max_pt) max_pt = b.els_pt()->at(iel);
321  }
322  return max_pt;
323 }
324 
325 bool isRelIsoMu(const Baby &b, size_t imu){
326  return imu<b.mus_pt()->size()
327  && b.mus_pt()->at(imu)>30.
328  && fabs(b.mus_eta()->at(imu))<2.
329  && b.mus_tight()->at(imu)
330  && b.mus_reliso()->at(imu) < 0.1;
331 }
332 
334  int nmus = 0;
335  for (size_t imu(0); imu<b.mus_pt()->size(); imu++){
336  if (isRelIsoMu(b,imu)) nmus++;
337  }
338  return nmus;
339 }
340 
342  double max_pt = 0;
343  for (size_t imu(0); imu<b.mus_pt()->size(); imu++){
344  if (isRelIsoMu(b,imu) && b.mus_pt()->at(imu)>max_pt) max_pt = b.mus_pt()->at(imu);
345  }
346  return max_pt;
347 }
348 
349 bool isGoodJet(const Baby &b, size_t ijet){
350  return ijet<b.jets_pt()->size()
351  && fabs(b.jets_eta()->at(ijet))<2.4
352  && !b.jets_islep()->at(ijet);
353 }
354 
355 NamedFunc::VectorType isrJetsPt(const Baby &b, float ptThresh){
356  vector<double> isr_jetspt;
357  for (size_t ijet(0); ijet<b.jets_pt()->size(); ijet++){
358  if (!isGoodJet(b, ijet) || b.jets_pt()->at(ijet)<ptThresh) continue;
359  if (isrtype=="ttisr" && b.jets_csv()->at(ijet)>CSVMedium) continue;
360  isr_jetspt.push_back(b.jets_pt()->at(ijet));
361  }
362  std::sort(isr_jetspt.begin(), isr_jetspt.end(), std::greater<double>());
363  return isr_jetspt;
364 }
365 
367  if (isrtype=="ttisr") return b.jetsys_nob_pt();
368  else return b.jetsys_pt();
369 }
370 
371 NamedFunc::ScalarType nJetsWeights_ttisr(const Baby &b, bool use_baby_nisr){
372  if (b.ntrupv()<0) return 1.; // Do not reweight Data
373 
374  float wgt = b.weight()/b.eff_trig()/b.w_toppt();
375 
376  int nisrjets = b.njets();
377  if (b.SampleType()==20) {
378  if (use_baby_nisr) nisrjets = b.nisr();
379  else nisrjets = b.njets() - 2;
380  }
381  // weights derived in TTJets and applied using the nisr calculation algorithm
382  if (nisrjets==0) return 1.099*wgt; // +- 0.012
383  else if (nisrjets==1) return 0.969*wgt; // +- 0.014
384  else if (nisrjets==2) return 0.870*wgt; // +- 0.020
385  else if (nisrjets==3) return 0.772*wgt; // +- 0.031
386  else if (nisrjets==4) return 0.712*wgt; // +- 0.051
387  else if (nisrjets==5) return 0.661*wgt; // +- 0.088
388  else if (nisrjets>=6) return 0.566*wgt; // +- 0.133
389  else return wgt;
390 }
391 
393  if (b.ntrupv()<0) return 1.; // Do not reweight Data
394 
395  float wgt = b.weight()/b.eff_trig()/b.w_toppt();
396  if(b.SampleType()<30 && b.SampleType()>=60) return wgt;
397 
398  int nisrjets(b.njets());
399  // weights derived in DY+jets
400  if (nisrjets==0) return 0.981*wgt; // +- 0.001
401  else if (nisrjets==1) return 1.071*wgt; // +- 0.001
402  else if (nisrjets==2) return 1.169*wgt; // +- 0.003
403  else if (nisrjets==3) return 1.157*wgt; // +- 0.007
404  else if (nisrjets==4) return 1.014*wgt; // +- 0.013
405  else if (nisrjets==5) return 0.920*wgt; // +- 0.025
406  else if (nisrjets==6) return 0.867*wgt; // +- 0.048
407  else if (nisrjets>=7) return 0.935*wgt; // +- 0.088
408  else return wgt;
409 }
std::vector< float > *const & els_reliso() const
Get els_reliso for current event and cache it.
Definition: baby.cpp:3473
std::vector< float > *const & mus_eta() const
Get mus_eta for current event and cache it.
Definition: baby.cpp:5525
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
std::vector< float > *const & jets_csv() const
Get jets_csv for current event and cache it.
Definition: baby.cpp:4109
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
std::vector< ScalarType > VectorType
Definition: named_func.hpp:16
void addSlices(PlotMaker &pm, const vector< double > slices, NamedFunc svar, const vector< double > xbins, NamedFunc xvar, string xlabel, const NamedFunc &baseline, const NamedFunc &weight, const vector< shared_ptr< Process > > &proc, const vector< PlotOpt > &plot_types, int tag_digits=0)
float const & eff_trig() const
Get eff_trig for current event and cache it.
Definition: baby.cpp:2981
int const & njets() const
Get njets for current event and cache it.
Definition: baby.cpp:5981
std::vector< float > *const & els_pt() const
Get els_pt for current event and cache it.
Definition: baby.cpp:3461
NamedFunc::ScalarType nJetsWeights_ttisr(const Baby &b, bool use_baby_nisr)
Abstract base class for access to ntuple variables.
Definition: baby.hpp:16
STL namespace.
NamedFunc::ScalarType maxRelIsoMusPt(const Baby &b)
std::vector< float > *const & mus_pt() const
Get mus_pt for current event and cache it.
Definition: baby.cpp:5633
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
Definition: named_func.hpp:13
bool Contains(const std::string &str, const std::string &pat)
Definition: utilities.cpp:44
NamedFunc::ScalarType nRelIsoEls(const Baby &b)
float const & w_toppt() const
Get w_toppt for current event and cache it.
Definition: baby.cpp:7505
bool multithreaded_
Definition: plot_maker.hpp:43
float const & jetsys_nob_pt() const
Get jetsys_nob_pt for current event and cache it.
Definition: baby.cpp:4373
std::string execute(const std::string &cmd)
Definition: utilities.cpp:65
double ScalarType
Definition: named_func.hpp:15
float const & jetsys_pt() const
Get jetsys_pt for current event and cache it.
Definition: baby.cpp:4397
NamedFunc::ScalarType isrSystemPt(const Baby &b)
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
bool isRelIsoEl(const Baby &b, size_t iel)
NamedFunc::ScalarType nRelIsoMus(const Baby &b)
std::vector< float > *const & jets_eta() const
Get jets_eta for current event and cache it.
Definition: baby.cpp:4121
std::vector< bool > *const & els_tight() const
Get els_tight for current event and cache it.
Definition: baby.cpp:3521
std::vector< float > *const & mus_reliso() const
Get mus_reliso for current event and cache it.
Definition: baby.cpp:5657
TString RoundNumber(double num, int decimals, double denom=1.)
Definition: utilities.cpp:361
Organizes efficient production of plots with single loop over each process.
Definition: plot_maker.hpp:14
PlotOpt & Bottom(PlotOptTypes::BottomType bottom_type)
Definition: plot_opt.cpp:93
NamedFunc::VectorType isrJetsPt(const Baby &b, float ptThresh=30.)
bool isRelIsoMu(const Baby &b, size_t imu)
float const & weight() const
Get weight for current event and cache it.
Definition: baby.cpp:7517
std::vector< float > *const & els_sceta() const
Get els_sceta for current event and cache it.
Definition: baby.cpp:3485
PlotOpt & ShowBackgroundError(bool show_background_error)
Definition: plot_opt.cpp:386
float const & nisr() const
Get nisr for current event and cache it.
Definition: baby.cpp:5957
std::vector< float > *const & jets_pt() const
Get jets_pt for current event and cache it.
Definition: baby.cpp:4289
NamedFunc::ScalarType nJetsWeights_visr(const Baby &b)
PlotOpt & PrintVals(bool print_vals)
Definition: plot_opt.cpp:404
int const & ntrupv() const
Get ntrupv for current event and cache it.
Definition: baby.cpp:6197
bool isGoodJet(const Baby &b, size_t ijet)
std::vector< bool > *const & jets_islep() const
Get jets_islep for current event and cache it.
Definition: baby.cpp:4253
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
Definition: plot_maker.cpp:54
PlotOpt & Title(PlotOptTypes::TitleType title_type)
Definition: plot_opt.cpp:111
int SampleType() const
Definition: baby.cpp:1681
NamedFunc::ScalarType maxRelIsoElsPt(const Baby &b)
std::vector< bool > *const & mus_tight() const
Get mus_tight for current event and cache it.
Definition: baby.cpp:5693
Loads colors from a text configuration file.
Definition: palette.hpp:8