ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_mismeasure.cxx
Go to the documentation of this file.
1 #include <set>
2 #include <string>
3 #include <iostream>
4 #include <memory>
5 #include <limits>
6 
7 #include "TStyle.h"
8 #include "TColor.h"
9 #include "TCanvas.h"
10 #include "TChain.h"
11 #include "TH1D.h"
12 #include "TH2D.h"
13 #include "TError.h"
14 #include "TGraphAsymmErrors.h"
15 
16 #include "core/timer.hpp"
17 #include "core/baby_full.hpp"
18 #include "core/utilities.hpp"
19 #include "core/process.hpp"
20 #include "core/plot_maker.hpp"
21 #include "core/event_scan.hpp"
22 #include "core/hist1d.hpp"
23 #include "core/palette.hpp"
24 
25 using namespace std;
26 using namespace PlotOptTypes;
27 
28 namespace{
29  float bignum = numeric_limits<float>::max();
30 }
31 
32 TH2D RowNorm(const TH2D &hin){
33  TH2D hout = hin;
34  hout.SetName((hout.GetName()+string("_rownorm")).c_str());
35  for(int irow = 1; irow <= hout.GetNbinsY(); ++irow){
36  double y = 0.;
37  for(int icol = 1; icol <= hout.GetNbinsX(); ++icol){
38  y += hout.GetBinContent(icol, irow);
39  }
40  y = 100./y;
41  for(int icol = 1; icol <= hout.GetNbinsY(); ++icol){
42  hout.SetBinContent(icol, irow, hout.GetBinContent(icol, irow)*y);
43  hout.SetBinError(icol, irow, hout.GetBinError(icol, irow)*y);
44  }
45  }
46  hout.SetMinimum(0.);
47  hout.SetMaximum(100.);
48  return hout;
49 }
50 
51 TH2D ColNorm(const TH2D &hin){
52  TH2D hout = hin;
53  hout.SetName((hout.GetName()+string("_colnorm")).c_str());
54  for(int icol = 1; icol <= hout.GetNbinsY(); ++icol){
55  double y = 0.;
56  for(int irow = 1; irow <= hout.GetNbinsX(); ++irow){
57  y += hout.GetBinContent(icol, irow);
58  }
59  y = 100./y;
60  for(int irow = 1; irow <= hout.GetNbinsY(); ++irow){
61  hout.SetBinContent(icol, irow, hout.GetBinContent(icol, irow)*y);
62  hout.SetBinError(icol, irow, hout.GetBinError(icol, irow)*y);
63  }
64  }
65  hout.SetMinimum(0.);
66  hout.SetMaximum(100.);
67  return hout;
68 }
69 
70 int RegionIndex(const Baby &b, size_t i,
71  double low_nj, double high_nj,
72  double low_met, double high_met,
73  bool cluster_leps){
74  double low_nb = 0.5;
75  if(b.mm_nleps()->at(i)==2){
76  low_nb = -0.5;
77  }
78  if(cluster_leps){
79  low_nj += 1.-b.mm_nleps()->at(i);
80  high_nj += 1.-b.mm_nleps()->at(i);
81  }
82  bool pass_baseline =
83  b.mm_ht()->at(i)>500
84  && b.mm_met()->at(i)>low_met && b.mm_met()->at(i)<=high_met
85  && b.mm_njets()->at(i)>low_nj && b.mm_njets()->at(i)<=high_nj
86  && b.mm_nbm()->at(i)>low_nb;
87 
88  if(!pass_baseline) return -1;
89  double mj = cluster_leps ? b.mm_mj14_lep()->at(i) : b.mm_mj14_nolep()->at(i);
90  if(mj<=250.) return 0;
91  double mt = b.mm_mt()->at(i);
92  switch(b.mm_nleps()->at(i)){
93  case 0:
94  if(mj<=400.) return 1;
95  else return 2;
96  case 1:
97  if(mj<=400.){
98  if(mt<=140.) return 3;
99  else return 5;
100  }else{
101  if(mt<=140.) return 4;
102  else return 6;
103  }
104  case 2:
105  if(mj<=400.) return 7;
106  else return 8;
107  default: return -1;
108  }
109 }
110 
111 bool IsTransferNoLep(const Baby &b){
112  return RegionIndex(b, 0, 6, bignum, 200., bignum, false) == -1
113  && (RegionIndex(b, 2, 6, bignum, 200., bignum, false) == 5
114  || RegionIndex(b, 2, 6, bignum, 200., bignum, false) == 6);
115 }
116 
117 bool IsTransferLep(const Baby &b){
118  return RegionIndex(b, 0, 6, bignum, 200., bignum, true) == -1
119  && (RegionIndex(b, 2, 6, bignum, 200., bignum, true) == 5
120  || RegionIndex(b, 2, 6, bignum, 200., bignum, true) == 6);
121 }
122 
123 void Fill(bool pass, TH1D &h_pass, TH1D &h_total, double x, double w){
124  if(pass) h_pass.Fill(x, w);
125  h_total.Fill(x, w);
126 }
127 
128 void Format(TH1D &h, bool no_stats = false){
129  h.SetLineColor(kBlack);
130  h.SetLineStyle(1);
131  h.SetLineWidth(5);
132  if(no_stats) h.SetStats(false);
133 }
134 
135 void Format(TH2D &h, bool no_stats = false){
136  //h.SetMarkerStyle(20);
137  //h.SetMarkerSize(0.5);
138  h.SetMarkerColor(kBlack);
139  h.SetMinimum(0.);
140  if(no_stats) h.SetStats(false);
141 }
142 
143 void Print(TH1D &h, bool no_stats = false){
144  Format(h, no_stats);
145  TCanvas c;
146  h.Draw("e1p");
147  c.Print((string("plots/")+h.GetName()+".pdf").c_str());
148 }
149 
150 void MakePositive(TH1D &h){
151  for(int i=0; i < h.GetNbinsX(); ++i){
152  double y = h.GetBinContent(i);
153  if(y >= 0.) continue;
154  double e = h.GetBinError(i);
155  e=hypot(e,y);
156  y=0.;
157  h.SetBinContent(i, y);
158  h.SetBinError(i, e);
159  }
160 }
161 
162 void SetAxisLabels(TAxis &a, bool use_total){
163  if(use_total){
164  a.SetBinLabel(1, "Total");
165  a.SetBinLabel(2, "Other");
166  a.SetBinLabel(3, "Very Low MJ");
167  a.SetBinLabel(4, "0l, Low MJ");
168  a.SetBinLabel(5, "0l, High MJ");
169  a.SetBinLabel(6, "R1");
170  a.SetBinLabel(7, "R2");
171  a.SetBinLabel(8, "R3");
172  a.SetBinLabel(9, "R4");
173  a.SetBinLabel(10, "D3");
174  a.SetBinLabel(11, "D4");
175  }else{
176  a.SetBinLabel(1, "Other");
177  a.SetBinLabel(2, "Very Low MJ");
178  a.SetBinLabel(3, "0l, Low MJ");
179  a.SetBinLabel(4, "0l, High MJ");
180  a.SetBinLabel(5, "R1");
181  a.SetBinLabel(6, "R2");
182  a.SetBinLabel(7, "R3");
183  a.SetBinLabel(8, "R4");
184  a.SetBinLabel(9, "D3");
185  a.SetBinLabel(10, "D4");
186  }
187 }
188 
189 TH2D Expand(const TH2D &h){
190  TH2D g("", FullTitle(h).c_str(),
191  h.GetNbinsX()+1, -2.5, h.GetNbinsX()-1.5,
192  h.GetNbinsY()+1, -2.5, h.GetNbinsY()-1.5);
193 
194  for(int ix = 0; ix <= h.GetNbinsX()+1; ++ix){
195  for(int iy = 0; iy <= h.GetNbinsY()+1; ++iy){
196  g.SetBinContent(ix+1, iy+1, h.GetBinContent(ix, iy));
197  g.SetBinError(ix+1, iy+1, h.GetBinError(ix, iy));
198  }
199  }
200 
201  for(int ix = g.GetNbinsX(); ix > 1; --ix){
202  double sumw = 0., sumw2 = 0.;
203  for(int iy = g.GetNbinsY(); iy > 1; --iy){
204  sumw += g.GetBinContent(ix, iy);
205  double e = g.GetBinError(ix, iy);
206  sumw2 += e*e;
207  }
208  g.SetBinContent(ix, 1, sumw);
209  g.SetBinError(ix, 1, sqrt(sumw2));
210  }
211 
212  for(int iy = g.GetNbinsY(); iy > 0; --iy){
213  double sumw = 0., sumw2 = 0.;
214  for(int ix = g.GetNbinsX(); ix > 1; --ix){
215  sumw += g.GetBinContent(ix, iy);
216  double e = g.GetBinError(ix, iy);
217  sumw2 += e*e;
218  }
219  g.SetBinContent(1, iy, sumw);
220  g.SetBinError(1, iy, sqrt(sumw2));
221  }
222 
223  return g;
224 }
225 
226 void PrintTransfer(TH2D &h){
227  Format(h, true);
228  SetAxisLabels(*h.GetXaxis(), false);
229  SetAxisLabels(*h.GetYaxis(), false);
230  TH2D g = Expand(h);
231  Format(g, true);
232  SetAxisLabels(*g.GetXaxis(), true);
233  SetAxisLabels(*g.GetYaxis(), true);
234  TH2D gg = g;
235  for(int ix = 1; ix <= gg.GetNbinsX(); ++ix){
236  gg.SetBinContent(ix, 1, 0.);
237  gg.SetBinError(ix, 1, 0.);
238  }
239  for(int iy = 1; iy <= gg.GetNbinsY(); ++iy){
240  gg.SetBinContent(1, iy, 0.);
241  gg.SetBinError(1, iy, 0.);
242  }
243  Format(gg, true);
244  SetAxisLabels(*gg.GetXaxis(), true);
245  SetAxisLabels(*gg.GetYaxis(), true);
246 
247  TCanvas c;
248  gg.Draw("col");
249  g.Draw("text same");
250  c.Print((string("plots/")+h.GetName()+".pdf").c_str());
251  TH2D rn = RowNorm(h);
252  rn.Draw("col");
253  rn.Draw("text same");
254  c.Print((string("plots/")+h.GetName()+"_rownorm.pdf").c_str());
255  TH2D cn = ColNorm(h);
256  cn.Draw("col");
257  cn.Draw("text same");
258  c.Print((string("plots/")+h.GetName()+"_colnorm.pdf").c_str());
259 }
260 
261 void Print(TH2D &h, bool no_stats = false){
262  Format(h, no_stats);
263  h.SetTitle(("#rho="+to_string(h.GetCorrelationFactor())).c_str());
264  TCanvas c;
265  h.Draw("col");
266  h.Draw("scat same");
267  c.Print((string("plots/")+h.GetName()+".pdf").c_str());
268 }
269 
270 void Print(TH1D &pass, TH1D &total){
271  MakePositive(pass);
272  MakePositive(total);
273  Print(pass);
274  Print(total);
275  TCanvas c;
276  TGraphAsymmErrors g(&pass, &total);
277  g.SetTitle((string(";")+pass.GetXaxis()->GetTitle()+";Fraction Mismeasured").c_str());
278  g.SetMinimum(0.);
279  g.SetMaximum(1.);
280  g.Draw("ap0");
281  c.Print((string("plots/")+g.GetName()+".pdf").c_str());
282 }
283 
284 int main(){
285  gErrorIgnoreLevel = 6000;
286  gStyle->SetOptStat("iouMRen");
287  double stops[2] = {0., 1.};
288  double red[2] = {1., 1.};
289  double green[2] = {1., 0.};
290  double blue[2] = {1., 0.};
291  gStyle->SetNumberContours(256);
292  gStyle->SetPaintTextFormat("4.2f");
293  TColor::CreateGradientColorTable(2, stops, red, green, blue, 256);
294 
295  double lumi = 2.6;
296  int igood = 0;
297  int ibad = 2;
298 
299  string folder_mc="/net/cms29/cms29r0/babymaker/babies/mismeasured_v2/2016_06_14/mc/merged_mm_std_nj5mj250/";
300  auto baby_nontt = make_shared<Baby_full>(set<string>{
301  folder_mc+"*_DYJetsToLL*.root",
302  folder_mc+"*_QCD_HT*.root",
303  folder_mc+"*_ST*channel*.root",
304  folder_mc+"*_TTGJets*.root",
305  folder_mc+"*_TTTT*.root",
306  folder_mc+"*_TTWJetsTo*.root",
307  folder_mc+"*_TTZTo*.root",
308  folder_mc+"*_WH_HToBB*.root",
309  folder_mc+"*_WJetsToLNu_HT-*.root",
310  folder_mc+"*_WWTo*.root",
311  folder_mc+"*_WZTo*.root",
312  folder_mc+"*_ZH*.root",
313  folder_mc+"*_ZZ*.root",
314  folder_mc+"*_ttHJetTobb*.root"
315  });
316  auto baby_tt = make_shared<Baby_full>(set<string>{
317  folder_mc+"*_TTJets*Lept*.root", folder_mc+"*_TTJets_HT*.root"
318  });
319 
320  TH1D h_1l_mm_lep_pt("h_1l_mm_lep_pt", ";Mismeasured Lepton p_{T} [GeV];Entries", 20, 0., 2000.);
321  TH2D h_1l_mt_mj_lep("h_1l_mt_mj_lep", ";M_{J} (with lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
322  TH2D h_1l_mt_mj_nolep("h_1l_mt_mj_nolep", ";M_{J} (no lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
323  TH2D h_1l_mm_mt_mm_mj_lep("h_1l_mm_mt_mm_mj_lep", ";M_{J} (with lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
324  TH2D h_1l_mm_mt_mm_mj_nolep("h_1l_mm_mt_mm_mj_nolep", ";M_{J} (no lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
325  TH2D h_1l_mj_nolep_mj_lep("h_1l_mj_nolep_mj_lep", ";M_{J} (with lep) [GeV];M_{J} (no lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
326  TH2D h_1l_mm_mj_nolep_mm_mj_lep("h_1l_mm_mj_nolep_mm_mj_lep", ";M_{J} (with lep) [GeV];M_{J} (no lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
327  TH2D h_1l_mm_mt_mt("h_1l_mm_mt_mt", ";Correct m_{T} [GeV];Mismeasured m_{T} [GeV]", 100, -1000., 1000., 100, 0., 2000.);
328  TH2D h_1l_mm_mj_nolep_mj_nolep("h_1l_mm_mj_nolep_mj_nolep", ";Correct M_{J} (no lep) [GeV];Mismeasured M_{J} (no lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
329  TH2D h_1l_mm_mj_lep_mj_lep("h_1l_mm_mj_lep_mj_lep", ";Correct M_{J} (with lep) [GeV];Mismeasured M_{J} (with lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
330  TH1D h_2l_mm_lep_pt("h_2l_mm_lep_pt", ";Mismeasured Lepton p_{T} [GeV];Entries", 20, 0., 2000.);
331  TH2D h_2l_mt_mj_lep("h_2l_mt_mj_lep", ";M_{J} (with lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
332  TH2D h_2l_mt_mj_nolep("h_2l_mt_mj_nolep", ";M_{J} (no lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
333  TH2D h_2l_mm_mt_mm_mj_lep("h_2l_mm_mt_mm_mj_lep", ";M_{J} (with lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
334  TH2D h_2l_mm_mt_mm_mj_nolep("h_2l_mm_mt_mm_mj_nolep", ";M_{J} (no lep) [GeV];m_{T} [GeV]", 100, 0., 1000., 100, 0., 1000.);
335  TH2D h_2l_mj_nolep_mj_lep("h_2l_mj_nolep_mj_lep", ";M_{J} (with lep) [GeV];M_{J} (no lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
336  TH2D h_2l_mm_mj_nolep_mm_mj_lep("h_2l_mm_mj_nolep_mm_mj_lep", ";M_{J} (with lep) [GeV];M_{J} (no lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
337  TH2D h_2l_mm_mt_mt("h_2l_mm_mt_mt", ";Correct m_{T} [GeV];Mismeasured m_{T} [GeV]", 100, -1000., 1000., 100, 0., 2000.);
338  TH2D h_2l_mm_mj_nolep_mj_nolep("h_2l_mm_mj_nolep_mj_nolep", ";Correct M_{J} (no lep) [GeV];Mismeasured M_{J} (no lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
339  TH2D h_2l_mm_mj_lep_mj_lep("h_2l_mm_mj_lep_mj_lep", ";Correct M_{J} (with lep) [GeV];Mismeasured M_{J} (with lep) [GeV]", 100, 0., 1000., 100, 0., 1000.);
340 
341  TH2D h_1l_dmt_dmjlep("h_1l_dmt_dmjlep", ";#Delta M_{J} (with lep) [GeV];#Delta m_{T} [GeV]", 60, -100., 500., 110, -100., 1000.);
342  TH2D h_1l_dmt_dmjnolep("h_1l_dmt_dmjnolep", ";#Delta M_{J} (no lep) [GeV];#Delta m_{T} [GeV]", 60, -300., 300., 110, -100., 1000.);
343  TH2D h_1l_dmt_dmjlep_highmet("h_1l_dmt_dmjlep_highmet", ";#Delta M_{J} (with lep) [GeV];#Delta m_{T} [GeV]", 60, -100., 500., 110, -100., 1000.);
344  TH2D h_1l_dmt_dmjnolep_highmet("h_1l_dmt_dmjnolep_highmet", ";#Delta M_{J} (no lep) [GeV];#Delta m_{T} [GeV]", 60, -300., 300., 110, -100., 1000.);
345  TH2D h_1l_dmt_dmjlep_highnj("h_1l_dmt_dmjlep_highnj", ";#Delta M_{J} (with lep) [GeV];#Delta m_{T} [GeV]", 60, -100., 500., 110, -100., 1000.);
346  TH2D h_1l_dmt_dmjnolep_highnj("h_1l_dmt_dmjnolep_highnj", ";#Delta M_{J} (no lep) [GeV];#Delta m_{T} [GeV]", 60, -300., 300., 110, -100., 1000.);
347 
348  TH2D h_transfer_mm_lep("h_transfer_mm_lep", "Baseline;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
349  TH2D h_transfer_all_lep("h_transfer_all_lep", "Baseline;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
350  TH2D h_transfer_mm_nolep("h_transfer_mm_nolep", "Baseline;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
351  TH2D h_transfer_all_nolep("h_transfer_all_nolep", "Baseline;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
352  TH2D h_transfer_lowmet_mm_lep("h_transfer_lowmet_mm_lep", "Low MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
353  TH2D h_transfer_lowmet_all_lep("h_transfer_lowmet_all_lep", "Low MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
354  TH2D h_transfer_lowmet_mm_nolep("h_transfer_lowmet_mm_nolep", "Low MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
355  TH2D h_transfer_lowmet_all_nolep("h_transfer_lowmet_all_nolep", "Low MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
356  TH2D h_transfer_medmet_mm_lep("h_transfer_medmet_mm_lep", "Med MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
357  TH2D h_transfer_medmet_all_lep("h_transfer_medmet_all_lep", "Med MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
358  TH2D h_transfer_medmet_mm_nolep("h_transfer_medmet_mm_nolep", "Med MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
359  TH2D h_transfer_medmet_all_nolep("h_transfer_medmet_all_nolep", "Med MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
360  TH2D h_transfer_highmet_mm_lep("h_transfer_highmet_mm_lep", "High MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
361  TH2D h_transfer_highmet_all_lep("h_transfer_highmet_all_lep", "High MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
362  TH2D h_transfer_highmet_mm_nolep("h_transfer_highmet_mm_nolep", "High MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
363  TH2D h_transfer_highmet_all_nolep("h_transfer_highmet_all_nolep", "High MET;Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
364  TH2D h_transfer_lownj_mm_lep("h_transfer_lownj_mm_lep", "Low N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
365  TH2D h_transfer_lownj_all_lep("h_transfer_lownj_all_lep", "Low N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
366  TH2D h_transfer_lownj_mm_nolep("h_transfer_lownj_mm_nolep", "Low N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
367  TH2D h_transfer_lownj_all_nolep("h_transfer_lownj_all_nolep", "Low N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
368  TH2D h_transfer_highnj_mm_lep("h_transfer_highnj_mm_lep", "High N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
369  TH2D h_transfer_highnj_all_lep("h_transfer_highnj_all_lep", "High N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
370  TH2D h_transfer_highnj_mm_nolep("h_transfer_highnj_mm_nolep", "High N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
371  TH2D h_transfer_highnj_all_nolep("h_transfer_highnj_all_nolep", "High N_{jets};Correct Region;Mismeasured Region", 10, -1.5, 8.5, 10, -1.5, 8.5);
372 
373  TH1D h_num_1l_mt("h_num_1l_mt", "Numerator;m_{T} [GeV];Entries", 20, 0., 1000.);
374  TH1D h_den_1l_mt("h_den_1l_mt", "Denominator;m_{T} [GeV];Entries", 20, 0., 1000.);
375  TH1D h_num_1l_mj_lep("h_num_1l_mj_lep", "Numerator;M_{J} (with lep) [GeV];Entries", 20, 0., 1000.);
376  TH1D h_den_1l_mj_lep("h_den_1l_mj_lep", "Denominator;M_{J} (with lep) [GeV];Entries", 20, 0., 1000.);
377  TH1D h_num_1l_mj_nolep("h_num_1l_mj_nolep", "Numerator;M_{J} (no lep) [GeV];Entries", 20, 0., 1000.);
378  TH1D h_den_1l_mj_nolep("h_den_1l_mj_nolep", "Denominator;M_{J} (no lep) [GeV];Entries", 20, 0., 1000.);
379  TH1D h_num_1l_met("h_num_1l_met", "Numerator;MET [GeV];Entries", 20, 0., 1000.);
380  TH1D h_den_1l_met("h_den_1l_met", "Denominator;MET [GeV];Entries", 20, 0., 1000.);
381  TH1D h_num_1l_njets("h_num_1l_njets", "Numerator;N_{jets};Entries", 7, 4.5, 11.5);
382  TH1D h_den_1l_njets("h_den_1l_njets", "Denominator;N_{jets};Entries", 7, 4.5, 11.5);
383  TH1D h_num_1l_nbm("h_num_1l_nbm", "Numerator;N_{b};Entries", 5, -0.5, 4.5);
384  TH1D h_den_1l_nbm("h_den_1l_nbm", "Denominator;N_{b};Entries", 5, -0.5, 4.5);
385  TH1D h_num_2l_mt("h_num_2l_mt", "Numerator;m_{T} [GeV];Entries", 20, 0., 1000.);
386  TH1D h_den_2l_mt("h_den_2l_mt", "Denominator;m_{T} [GeV];Entries", 20, 0., 1000.);
387  TH1D h_num_2l_mj_lep("h_num_2l_mj_lep", "Numerator;M_{J} (with lep) [GeV];Entries", 20, 0., 1000.);
388  TH1D h_den_2l_mj_lep("h_den_2l_mj_lep", "Denominator;M_{J} (with lep) [GeV];Entries", 20, 0., 1000.);
389  TH1D h_num_2l_mj_nolep("h_num_2l_mj_nolep", "Numerator;M_{J} (no lep) [GeV];Entries", 20, 0., 1000.);
390  TH1D h_den_2l_mj_nolep("h_den_2l_mj_nolep", "Denominator;M_{J} (no lep) [GeV];Entries", 20, 0., 1000.);
391  TH1D h_num_2l_met("h_num_2l_met", "Numerator;MET [GeV];Entries", 20, 0., 1000.);
392  TH1D h_den_2l_met("h_den_2l_met", "Denominator;MET [GeV];Entries", 20, 0., 1000.);
393  TH1D h_num_2l_njets("h_num_2l_njets", "Numerator;N_{jets};Entries", 7, 4.5, 11.5);
394  TH1D h_den_2l_njets("h_den_2l_njets", "Denominator;N_{jets};Entries", 7, 4.5, 11.5);
395  TH1D h_num_2l_nbm("h_num_2l_nbm", "Numerator;N_{b};Entries", 5, -0.5, 4.5);
396  TH1D h_den_2l_nbm("h_den_2l_nbm", "Denominator;N_{b};Entries", 5, -0.5, 4.5);
397 
398  for(auto &b: {baby_nontt, baby_tt}){
399  auto activator = b->Activate();
400  cout << "Getting entries..." << endl;
401  long num_entries = b->GetEntries();
402  cout << num_entries << " entries found." << endl;
403  Timer timer(num_entries, 1.);
404  for(long event = 0; event < num_entries; ++event){
405  timer.Iterate();
406  b->GetEntry(event);
407 
408  if(!b->stitch()) continue;
409  double w = lumi*b->weight();
410 
411  bool mm = b->mm()->at(ibad);
412 
413  if(mm){
414  h_transfer_mm_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., bignum, true),
415  RegionIndex(*b, ibad, 5.5, bignum, 200., bignum, true),
416  w);
417  h_transfer_mm_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., bignum, false),
418  RegionIndex(*b, ibad, 5.5, bignum, 200., bignum, false),
419  w);
420  h_transfer_lowmet_mm_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., 350., true),
421  RegionIndex(*b, ibad, 5.5, bignum, 200., 350., true),
422  w);
423  h_transfer_lowmet_mm_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., 350., false),
424  RegionIndex(*b, ibad, 5.5, bignum, 200., 350., false),
425  w);
426  h_transfer_medmet_mm_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 350., 500., true),
427  RegionIndex(*b, ibad, 5.5, bignum, 350., 500., true),
428  w);
429  h_transfer_medmet_mm_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 350., 500., false),
430  RegionIndex(*b, ibad, 5.5, bignum, 350., 500., false),
431  w);
432  h_transfer_highmet_mm_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 500., bignum, true),
433  RegionIndex(*b, ibad, 5.5, bignum, 500., bignum, true),
434  w);
435  h_transfer_highmet_mm_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 500., bignum, false),
436  RegionIndex(*b, ibad, 5.5, bignum, 500., bignum, false),
437  w);
438  h_transfer_lownj_mm_lep.Fill(RegionIndex(*b, igood, 5.5, 8.5, 200., bignum, true),
439  RegionIndex(*b, ibad, 5.5, 8.5, 200., bignum, true),
440  w);
441  h_transfer_lownj_mm_nolep.Fill(RegionIndex(*b, igood, 5.5, 8.5, 200., bignum, false),
442  RegionIndex(*b, ibad, 5.5, 8.5, 200., bignum, false),
443  w);
444  h_transfer_highnj_mm_lep.Fill(RegionIndex(*b, igood, 8.5, bignum, 200., bignum, true),
445  RegionIndex(*b, ibad, 8.5, bignum, 200., bignum, true),
446  w);
447  h_transfer_highnj_mm_nolep.Fill(RegionIndex(*b, igood, 8.5, bignum, 200., bignum, false),
448  RegionIndex(*b, ibad, 8.5, bignum, 200., bignum, false),
449  w);
450  }
451  h_transfer_all_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., bignum, true),
452  RegionIndex(*b, ibad, 5.5, bignum, 200., bignum, true),
453  w);
454  h_transfer_all_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., bignum, false),
455  RegionIndex(*b, ibad, 5.5, bignum, 200., bignum, false),
456  w);
457  h_transfer_lowmet_all_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., 350., true),
458  RegionIndex(*b, ibad, 5.5, bignum, 200., 350., true),
459  w);
460  h_transfer_lowmet_all_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 200., 350., false),
461  RegionIndex(*b, ibad, 5.5, bignum, 200., 350., false),
462  w);
463  h_transfer_medmet_all_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 350., 500., true),
464  RegionIndex(*b, ibad, 5.5, bignum, 350., 500., true),
465  w);
466  h_transfer_medmet_all_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 350., 500., false),
467  RegionIndex(*b, ibad, 5.5, bignum, 350., 500., false),
468  w);
469  h_transfer_highmet_all_lep.Fill(RegionIndex(*b, igood, 5.5, bignum, 500., bignum, true),
470  RegionIndex(*b, ibad, 5.5, bignum, 500., bignum, true),
471  w);
472  h_transfer_highmet_all_nolep.Fill(RegionIndex(*b, igood, 5.5, bignum, 500., bignum, false),
473  RegionIndex(*b, ibad, 5.5, bignum, 500., bignum, false),
474  w);
475  h_transfer_lownj_all_lep.Fill(RegionIndex(*b, igood, 5.5, 8.5, 200., bignum, true),
476  RegionIndex(*b, ibad, 5.5, 8.5, 200., bignum, true),
477  w);
478  h_transfer_lownj_all_nolep.Fill(RegionIndex(*b, igood, 5.5, 8.5, 200., bignum, false),
479  RegionIndex(*b, ibad, 5.5, 8.5, 200., bignum, false),
480  w);
481  h_transfer_highnj_all_lep.Fill(RegionIndex(*b, igood, 8.5, bignum, 200., bignum, true),
482  RegionIndex(*b, ibad, 8.5, bignum, 200., bignum, true),
483  w);
484  h_transfer_highnj_all_nolep.Fill(RegionIndex(*b, igood, 8.5, bignum, 200., bignum, false),
485  RegionIndex(*b, ibad, 8.5, bignum, 200., bignum, false),
486  w);
487 
488  if(mm
489  && (b->mm_nleps()->at(igood)>0 || b->mm_nleps()->at(ibad)>0)
490  && (b->mm_ht()->at(igood)>500 || b->mm_ht()->at(ibad)>500)
491  && (b->mm_met()->at(igood)>200 || b->mm_met()->at(ibad)>200)
492  && (b->mm_njets()->at(igood)>=5 || b->mm_njets()->at(ibad)>=5)){
493 
494  if(b->mm_nleps()->at(ibad)==1){
495  h_1l_dmt_dmjlep.Fill(b->mm_mj14_lep()->at(ibad)-b->mm_mj14_lep()->at(igood),
496  b->mm_mt()->at(ibad)-b->mm_mt()->at(igood),
497  10.*w);
498  h_1l_dmt_dmjnolep.Fill(b->mm_mj14_nolep()->at(ibad)-b->mm_mj14_nolep()->at(igood),
499  b->mm_mt()->at(ibad)-b->mm_mt()->at(igood),
500  10.*w);
501  if(b->mm_met()->at(ibad)>500.){
502  h_1l_dmt_dmjlep_highmet.Fill(b->mm_mj14_lep()->at(ibad)-b->mm_mj14_lep()->at(igood),
503  b->mm_mt()->at(ibad)-b->mm_mt()->at(igood),
504  10.*w);
505  h_1l_dmt_dmjnolep_highmet.Fill(b->mm_mj14_nolep()->at(ibad)-b->mm_mj14_nolep()->at(igood),
506  b->mm_mt()->at(ibad)-b->mm_mt()->at(igood),
507  10.*w);
508  }
509  if(b->mm_njets()->at(ibad)>8.5){
510  h_1l_dmt_dmjlep_highnj.Fill(b->mm_mj14_lep()->at(ibad)-b->mm_mj14_lep()->at(igood),
511  b->mm_mt()->at(ibad)-b->mm_mt()->at(igood),
512  10.*w);
513  h_1l_dmt_dmjnolep_highnj.Fill(b->mm_mj14_nolep()->at(ibad)-b->mm_mj14_nolep()->at(igood),
514  b->mm_mt()->at(ibad)-b->mm_mt()->at(igood),
515  10.*w);
516  }
517  h_1l_mm_lep_pt.Fill(b->mm_lep_pt()->at(ibad), w);
518  h_1l_mt_mj_lep.Fill(b->mm_mj14_lep()->at(igood), b->mm_mt()->at(igood), w);
519  h_1l_mt_mj_nolep.Fill(b->mm_mj14_nolep()->at(igood), b->mm_mt()->at(igood), w);
520  h_1l_mm_mt_mm_mj_lep.Fill(b->mm_mj14_lep()->at(ibad), b->mm_mt()->at(ibad), w);
521  h_1l_mm_mt_mm_mj_nolep.Fill(b->mm_mj14_nolep()->at(ibad), b->mm_mt()->at(ibad), w);
522  h_1l_mj_nolep_mj_lep.Fill(b->mm_mj14_lep()->at(igood), b->mm_mj14_nolep()->at(igood), w);
523  h_1l_mm_mj_nolep_mm_mj_lep.Fill(b->mm_mj14_lep()->at(ibad), b->mm_mj14_nolep()->at(ibad), w);
524  h_1l_mm_mt_mt.Fill(b->mm_mt()->at(igood), b->mm_mt()->at(ibad), w);
525  h_1l_mm_mj_nolep_mj_nolep.Fill(b->mm_mj14_nolep()->at(igood), b->mm_mj14_nolep()->at(ibad), w);
526  h_1l_mm_mj_lep_mj_lep.Fill(b->mm_mj14_lep()->at(igood), b->mm_mj14_lep()->at(ibad), w);
527  }else if(b->mm_nleps()->at(ibad)==2){
528  h_2l_mm_lep_pt.Fill(b->mm_lep_pt()->at(ibad), w);
529  h_2l_mt_mj_lep.Fill(b->mm_mj14_lep()->at(igood), b->mm_mt()->at(igood), w);
530  h_2l_mt_mj_nolep.Fill(b->mm_mj14_nolep()->at(igood), b->mm_mt()->at(igood), w);
531  h_2l_mm_mt_mm_mj_lep.Fill(b->mm_mj14_lep()->at(ibad), b->mm_mt()->at(ibad), w);
532  h_2l_mm_mt_mm_mj_nolep.Fill(b->mm_mj14_nolep()->at(ibad), b->mm_mt()->at(ibad), w);
533  h_2l_mj_nolep_mj_lep.Fill(b->mm_mj14_lep()->at(igood), b->mm_mj14_nolep()->at(igood), w);
534  h_2l_mm_mj_nolep_mm_mj_lep.Fill(b->mm_mj14_lep()->at(ibad), b->mm_mj14_nolep()->at(ibad), w);
535  h_2l_mm_mt_mt.Fill(b->mm_mt()->at(igood), b->mm_mt()->at(ibad), w);
536  h_2l_mm_mj_nolep_mj_nolep.Fill(b->mm_mj14_nolep()->at(igood), b->mm_mj14_nolep()->at(ibad), w);
537  h_2l_mm_mj_lep_mj_lep.Fill(b->mm_mj14_lep()->at(igood), b->mm_mj14_lep()->at(ibad), w);
538  }
539  }
540 
541  if(b->mm_ht()->at(ibad)>500. && b->mm_met()->at(ibad)>200.
542  && b->mm_njets()->at(ibad)>=5 && b->mm_nbm()->at(ibad)>=1){
543  if(b->mm_nleps()->at(ibad)==1){
544  Fill(mm, h_num_1l_mt, h_den_1l_mt, b->mm_mt()->at(ibad), w);
545  Fill(mm, h_num_1l_mj_lep, h_den_1l_mj_lep, b->mm_mj14_lep()->at(ibad), w);
546  Fill(mm, h_num_1l_mj_nolep, h_den_1l_mj_nolep, b->mm_mj14_nolep()->at(ibad), w);
547  Fill(mm, h_num_1l_met, h_den_1l_met, b->mm_met()->at(ibad), w);
548  Fill(mm, h_num_1l_njets, h_den_1l_njets, b->mm_njets()->at(ibad), w);
549  Fill(mm, h_num_1l_nbm, h_den_1l_nbm, b->mm_nbm()->at(ibad), w);
550  }else if(b->mm_nleps()->at(ibad)>=2){
551  Fill(mm, h_num_2l_mt, h_den_2l_mt, b->mm_mt()->at(ibad), w);
552  Fill(mm, h_num_2l_mj_lep, h_den_2l_mj_lep, b->mm_mj14_lep()->at(ibad), w);
553  Fill(mm, h_num_2l_mj_nolep, h_den_2l_mj_nolep, b->mm_mj14_nolep()->at(ibad), w);
554  Fill(mm, h_num_2l_met, h_den_2l_met, b->mm_met()->at(ibad), w);
555  Fill(mm, h_num_2l_njets, h_den_2l_njets, b->mm_njets()->at(ibad), w);
556  Fill(mm, h_num_2l_nbm, h_den_2l_nbm, b->mm_nbm()->at(ibad), w);
557  }
558  }
559  }
560  }
561 
562  if(false){
563  Print(h_num_1l_mt, h_den_1l_mt);
564  Print(h_num_1l_mj_lep, h_den_1l_mj_lep);
565  Print(h_num_1l_mj_nolep, h_den_1l_mj_nolep);
566  Print(h_num_1l_met, h_den_1l_met);
567  Print(h_num_1l_njets, h_den_1l_njets);
568  Print(h_num_1l_nbm, h_den_1l_nbm);
569  Print(h_num_2l_mt, h_den_2l_mt);
570  Print(h_num_2l_mj_lep, h_den_2l_mj_lep);
571  Print(h_num_2l_mj_nolep, h_den_2l_mj_nolep);
572  Print(h_num_2l_met, h_den_2l_met);
573  Print(h_num_2l_njets, h_den_2l_njets);
574  Print(h_num_2l_nbm, h_den_2l_nbm);
575 
576  Print(h_1l_mm_lep_pt);
577  Print(h_1l_mt_mj_lep);
578  Print(h_1l_mt_mj_nolep);
579  Print(h_1l_mm_mt_mm_mj_lep);
580  Print(h_1l_mm_mt_mm_mj_nolep);
581  Print(h_1l_mj_nolep_mj_lep);
582  Print(h_1l_mm_mj_nolep_mm_mj_lep);
583  Print(h_1l_mm_mt_mt);
584  Print(h_1l_mm_mj_nolep_mj_nolep);
585  Print(h_1l_mm_mj_lep_mj_lep);
586  Print(h_2l_mm_lep_pt);
587  Print(h_2l_mt_mj_lep);
588  Print(h_2l_mt_mj_nolep);
589  Print(h_2l_mm_mt_mm_mj_lep);
590  Print(h_2l_mm_mt_mm_mj_nolep);
591  Print(h_2l_mj_nolep_mj_lep);
592  Print(h_2l_mm_mj_nolep_mm_mj_lep);
593  Print(h_2l_mm_mt_mt);
594  Print(h_2l_mm_mj_nolep_mj_nolep);
595  Print(h_2l_mm_mj_lep_mj_lep);
596  }
597 
598  Print(h_1l_dmt_dmjlep);
599  Print(h_1l_dmt_dmjnolep);
600  Print(h_1l_dmt_dmjlep_highmet);
601  Print(h_1l_dmt_dmjnolep_highmet);
602  Print(h_1l_dmt_dmjlep_highnj);
603  Print(h_1l_dmt_dmjnolep_highnj);
604 
605  PrintTransfer(h_transfer_mm_lep);
606  PrintTransfer(h_transfer_all_lep);
607  PrintTransfer(h_transfer_mm_nolep);
608  PrintTransfer(h_transfer_all_nolep);
609 
610  PrintTransfer(h_transfer_mm_lep);
611  PrintTransfer(h_transfer_all_lep);
612  PrintTransfer(h_transfer_mm_nolep);
613  PrintTransfer(h_transfer_all_nolep);
614  PrintTransfer(h_transfer_lowmet_mm_lep);
615  PrintTransfer(h_transfer_lowmet_all_lep);
616  PrintTransfer(h_transfer_lowmet_mm_nolep);
617  PrintTransfer(h_transfer_lowmet_all_nolep);
618  PrintTransfer(h_transfer_medmet_mm_lep);
619  PrintTransfer(h_transfer_medmet_all_lep);
620  PrintTransfer(h_transfer_medmet_mm_nolep);
621  PrintTransfer(h_transfer_medmet_all_nolep);
622  PrintTransfer(h_transfer_highmet_mm_lep);
623  PrintTransfer(h_transfer_highmet_all_lep);
624  PrintTransfer(h_transfer_highmet_mm_nolep);
625  PrintTransfer(h_transfer_highmet_all_nolep);
626  PrintTransfer(h_transfer_lownj_mm_lep);
627  PrintTransfer(h_transfer_lownj_all_lep);
628  PrintTransfer(h_transfer_lownj_mm_nolep);
629  PrintTransfer(h_transfer_lownj_all_nolep);
630  PrintTransfer(h_transfer_highnj_mm_lep);
631  PrintTransfer(h_transfer_highnj_all_lep);
632  PrintTransfer(h_transfer_highnj_mm_nolep);
633  PrintTransfer(h_transfer_highnj_all_nolep);
634 
635  Palette colors("txt/colors.txt", "default");
636 
637  auto tt1l = Process::MakeShared<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
638  {folder_mc+"*_TTJets*Lept*.root", folder_mc+"*_TTJets_HT*.root"}, "ntruleps<=1&&stitch");
639  auto tt2l = Process::MakeShared<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
640  {folder_mc+"*_TTJets*Lept*.root", folder_mc+"*_TTJets_HT*.root"}, "ntruleps>=2&&stitch");
641  auto wjets = Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
642  {folder_mc+"*_WJetsToLNu_HT-*.root"});
643  auto single_t = Process::MakeShared<Baby_full>("Single t", Process::Type::background, colors("single_t"),
644  {folder_mc+"*_ST*channel*.root"});
645  auto ttv = Process::MakeShared<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
646  {folder_mc+"*_TTWJetsTo*.root", folder_mc+"*_TTZTo*.root"});
647  auto other = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
648  {folder_mc+"*_DYJetsToLL*.root", folder_mc+"*_QCD_HT*.root",
649  folder_mc+"*_TTGJets*.root", folder_mc+"*_TTTT*.root",
650  folder_mc+"*_WH_HToBB*.root", folder_mc+"*_WWTo*.root",
651  folder_mc+"*_WZTo*.root", folder_mc+"*_ZH*.root",
652  folder_mc+"*_ZZ*.root", folder_mc+"*_ttHJetTobb*.root"});
653 
654  vector<shared_ptr<Process> > procs = {tt1l, tt2l, wjets, single_t, ttv, other};
655  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
656  log_lumi.Title(TitleType::info)
657  .Bottom(BottomType::off)
658  .YAxis(YAxisType::log)
659  .Stack(StackType::signal_overlay);
660  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
661  vector<PlotOpt> plot_types = {log_lumi, lin_lumi};
662 
663  NamedFunc is_transfer_lep("is_transfer_lep", IsTransferLep);
664  NamedFunc is_transfer_nolep("is_transfer_nolep", IsTransferNoLep);
665 
666  PlotMaker pm;
667  pm.Push<Hist1D>(Axis(5, -0.5, 4.5, "ntruleps", "True Num. Leptons"),
668  is_transfer_lep, procs, plot_types).Tag("transfer");
669  pm.Push<Hist1D>(Axis(5, -0.5, 4.5, "mm_nleps[0]", "Correct Num. Leptons"),
670  is_transfer_lep, procs, plot_types).Tag("transfer");
671  pm.Push<Hist1D>(Axis(5, -0.5, 4.5, "mm_nleps[2]", "Mismeasured Num. Leptons"),
672  is_transfer_lep, procs, plot_types).Tag("transfer");
673  pm.Push<Hist1D>(Axis(20, 0., 2000., "mm_ht[0]", "Correct H_{T} [GeV]"),
674  is_transfer_lep, procs, plot_types).Tag("transfer");
675  pm.Push<Hist1D>(Axis(20, 0., 2000., "mm_ht[2]", "Mismeasured H_{T} [GeV]"),
676  is_transfer_lep, procs, plot_types).Tag("transfer");
677  pm.Push<Hist1D>(Axis(15, 0., 1500., "mm_met[0]", "Correct MET [GeV]"),
678  is_transfer_lep, procs, plot_types).Tag("transfer");
679  pm.Push<Hist1D>(Axis(15, 0., 1500., "mm_met[2]", "Mismeasured MET [GeV]"),
680  is_transfer_lep, procs, plot_types).Tag("transfer");
681  pm.Push<Hist1D>(Axis(16, -0.5, 15.5, "mm_njets[0]", "Correct N_{jets}"),
682  is_transfer_lep, procs, plot_types).Tag("transfer");
683  pm.Push<Hist1D>(Axis(16, -0.5, 15.5, "mm_njets[2]", "Mismeasured N_{jets}"),
684  is_transfer_lep, procs, plot_types).Tag("transfer");
685  pm.Push<Hist1D>(Axis(7, -0.5, 6.5, "mm_nbm[0]", "Correct N_{b}"),
686  is_transfer_lep, procs, plot_types).Tag("transfer");
687  pm.Push<Hist1D>(Axis(7, -0.5, 6.5, "mm_nbm[2]", "Mismeasured N_{b}"),
688  is_transfer_lep, procs, plot_types).Tag("transfer");
689  pm.Push<Hist1D>(Axis(10, 0., 700., "mm_mt[0]", "Correct m_{T} [GeV]"),
690  is_transfer_lep, procs, plot_types).Tag("transfer");
691  pm.Push<Hist1D>(Axis(10, 0., 700., "mm_mt[2]", "Mismeasured m_{T} [GeV]"),
692  is_transfer_lep, procs, plot_types).Tag("transfer");
693  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_lep[0]", "Correct M_{J} (with lep) [GeV]"),
694  is_transfer_lep, procs, plot_types).Tag("transfer");
695  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_lep[2]", "Mismeasured M_{J} (with lep) [GeV]"),
696  is_transfer_lep, procs, plot_types).Tag("transfer");
697  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_nolep[0]", "Correct M_{J} (no lep) [GeV]"),
698  is_transfer_lep, procs, plot_types).Tag("transfer");
699  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_nolep[2]", "Mismeasured M_{J} (no lep) [GeV]"),
700  is_transfer_lep, procs, plot_types).Tag("transfer");
701  pm.Push<Hist1D>(Axis(5, -0.5, 4.5, "ntruleps", "True Num. Leptons"),
702  is_transfer_nolep, procs, plot_types).Tag("transfer");
703  pm.Push<Hist1D>(Axis(5, -0.5, 4.5, "mm_nleps[0]", "Correct Num. Leptons"),
704  is_transfer_nolep, procs, plot_types).Tag("transfer");
705  pm.Push<Hist1D>(Axis(5, -0.5, 4.5, "mm_nleps[2]", "Mismeasured Num. Leptons"),
706  is_transfer_nolep, procs, plot_types).Tag("transfer");
707  pm.Push<Hist1D>(Axis(20, 0., 2000., "mm_ht[0]", "Correct H_{T} [GeV]"),
708  is_transfer_nolep, procs, plot_types).Tag("transfer");
709  pm.Push<Hist1D>(Axis(20, 0., 2000., "mm_ht[2]", "Mismeasured H_{T} [GeV]"),
710  is_transfer_nolep, procs, plot_types).Tag("transfer");
711  pm.Push<Hist1D>(Axis(15, 0., 1500., "mm_met[0]", "Correct MET [GeV]"),
712  is_transfer_nolep, procs, plot_types).Tag("transfer");
713  pm.Push<Hist1D>(Axis(15, 0., 1500., "mm_met[2]", "Mismeasured MET [GeV]"),
714  is_transfer_nolep, procs, plot_types).Tag("transfer");
715  pm.Push<Hist1D>(Axis(16, -0.5, 15.5, "mm_njets[0]", "Correct N_{jets}"),
716  is_transfer_nolep, procs, plot_types).Tag("transfer");
717  pm.Push<Hist1D>(Axis(16, -0.5, 15.5, "mm_njets[2]", "Mismeasured N_{jets}"),
718  is_transfer_nolep, procs, plot_types).Tag("transfer");
719  pm.Push<Hist1D>(Axis(7, -0.5, 6.5, "mm_nbm[0]", "Correct N_{b}"),
720  is_transfer_nolep, procs, plot_types).Tag("transfer");
721  pm.Push<Hist1D>(Axis(7, -0.5, 6.5, "mm_nbm[2]", "Mismeasured N_{b}"),
722  is_transfer_nolep, procs, plot_types).Tag("transfer");
723  pm.Push<Hist1D>(Axis(10, 0., 700., "mm_mt[0]", "Correct m_{T} [GeV]"),
724  is_transfer_nolep, procs, plot_types).Tag("transfer");
725  pm.Push<Hist1D>(Axis(10, 0., 700., "mm_mt[2]", "Mismeasured m_{T} [GeV]"),
726  is_transfer_nolep, procs, plot_types).Tag("transfer");
727  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_lep[0]", "Correct M_{J} (with lep) [GeV]"),
728  is_transfer_nolep, procs, plot_types).Tag("transfer");
729  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_lep[2]", "Mismeasured M_{J} (with lep) [GeV]"),
730  is_transfer_nolep, procs, plot_types).Tag("transfer");
731  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_nolep[0]", "Correct M_{J} (no lep) [GeV]"),
732  is_transfer_nolep, procs, plot_types).Tag("transfer");
733  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_nolep[2]", "Mismeasured M_{J} (no lep) [GeV]"),
734  is_transfer_nolep, procs, plot_types).Tag("transfer");
735  pm.Push<Hist1D>(Axis(20, 0., 1000., "mm_mj14_nolep[2]", "Mismeasured M_{J} (no lep) [GeV]"),
736  is_transfer_nolep, procs, plot_types).Tag("transfer");
737  pm.MakePlots(2.6);
738 }
int RegionIndex(const Baby &b, size_t i, double low_nj, double high_nj, double low_met, double high_met, bool cluster_leps)
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
std::vector< int > *const & mm_nbm() const
Get mm_nbm for current event and cache it.
Definition: baby.cpp:5165
TH2D Expand(const TH2D &h)
Definition: timer.hpp:9
void Print(TH1D &h, bool no_stats=false)
std::vector< int > *const & mm_nleps() const
Get mm_nleps for current event and cache it.
Definition: baby.cpp:5201
void Fill(bool pass, TH1D &h_pass, TH1D &h_total, double x, double w)
void MakePositive(TH1D &h)
std::string FullTitle(const TH1 &h)
Definition: utilities.cpp:331
void SetAxisLabels(TAxis &a, bool use_total)
std::vector< float > *const & mm_mt() const
Get mm_mt for current event and cache it.
Definition: baby.cpp:5129
Abstract base class for access to ntuple variables.
Definition: baby.hpp:16
STL namespace.
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
Definition: named_func.hpp:13
std::vector< float > *const & mm_mj14_nolep() const
Get mm_mj14_nolep for current event and cache it.
Definition: baby.cpp:5117
std::vector< float > *const & mm_ht() const
Get mm_ht for current event and cache it.
Definition: baby.cpp:5009
bool IsTransferNoLep(const Baby &b)
void Format(TH1D &h, bool no_stats=false)
TH2D ColNorm(const TH2D &hin)
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
Definition: axis.hpp:12
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 PrintTransfer(TH2D &h)
std::vector< int > *const & mm_njets() const
Get mm_njets for current event and cache it.
Definition: baby.cpp:5189
TH2D RowNorm(const TH2D &hin)
int main()
A full 1D plot with stacked/overlayed histograms.
Definition: hist1d.hpp:23
bool IsTransferLep(const Baby &b)
void Iterate()
Definition: timer.cpp:80
std::vector< float > *const & mm_met() const
Get mm_met for current event and cache it.
Definition: baby.cpp:5081
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
Definition: plot_maker.cpp:54
std::vector< float > *const & mm_mj14_lep() const
Get mm_mj14_lep for current event and cache it.
Definition: baby.cpp:5105
PlotOpt & Title(PlotOptTypes::TitleType title_type)
Definition: plot_opt.cpp:111
Loads colors from a text configuration file.
Definition: palette.hpp:8