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