ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_mjshapes.cxx
Go to the documentation of this file.
1 #include <cmath>
2 #include <stdio.h>
3 #include <chrono>
4 
5 #include "TError.h"
6 #include "TVector2.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 #include "core/table.hpp"
15 #include "core/slide_maker.hpp"
16 
17 using namespace std;
18 using namespace PlotOptTypes;
19 
20 namespace{
21  bool do_metbins = true;
22  bool do_met150 = true;
23  bool do_met100 = true;
24 }
25 
26 int main(){
27  gErrorIgnoreLevel = 6000;
28 
29  chrono::high_resolution_clock::time_point begTime;
30  begTime = chrono::high_resolution_clock::now();
31 
32  double lumi = 2.6;
33  string bfolder("");
34  string hostname(execute("echo $HOSTNAME"));
35  if(Contains(hostname, "cms") || Contains(hostname, "compute-"))
36  bfolder = "/net/cms2"; // In laptops, you can't create a /net folder
37 
38  string ntupletag="metG200";
39  if(do_met150 && do_met100) ntupletag="";
40  string foldermc(bfolder+"/cms2r0/babymaker/babies/2016_08_10/mc/merged_mcbase_met100_stdnj5/");
41 
42  Palette colors("txt/colors.txt", "default");
43 
44 
45 <<<<<<< HEAD
46  set<string> files_tt({folder_mc+"*_TTJets*Lept*.root", folder_mc+"*_TTJets_HT*.root"});
47  set<string> files_wjets({folder_mc+"*_WJetsToLNu*.root"});
48  set<string> files_st({folder_mc+"*_ST_*.root"});
49  set<string> files_other({
50  folder_mc+"*DYJetsToLL*.root", folder_mc+"*_QCD_HT*.root",
51  folder_mc+"*_ZJet*.root", folder_mc+"*_WWTo*.root",
52  folder_mc+"*ggZH_HToBB*.root", folder_mc+"*ttHJetTobb*.root",
53  folder_mc+"*_TTGJets*.root", folder_mc+"*_TTTT_*.root",
54  folder_mc+"*_TTWJets*.root", folder_mc+"*_TTZTo*.root",
55  folder_mc+"*_WH_HToBB*.root", folder_mc+"*_WZTo*.root",
56  folder_mc+"*_ZH_HToBB*.root", folder_mc+"_ZZ_*.root"});
57 =======
58  NamedFunc baseline = "stitch && nleps==1 && nveto==0 && st>500 && met>100 && njets>=5 && nbm>=1 && weight<1";
59 
60  set<string> allfiles = {foldermc+"*_TTJets*Lept*"+ntupletag+"*.root", foldermc+"*_TTJets_HT*"+ntupletag+"*.root",
61  foldermc+"*_WJetsToLNu*"+ntupletag+"*.root",foldermc+"*_ST_*"+ntupletag+"*.root",
62  foldermc+"*_TTW*"+ntupletag+"*.root",foldermc+"*_TTZ*"+ntupletag+"*.root",
63  foldermc+"*_TTGJets*"+ntupletag+"*.root",foldermc+"*_TTTT*"+ntupletag+"*.root",
64  foldermc+"*QCD_HT*Inf_Tune*"+ntupletag+"*.root",
65  foldermc+"*QCD_HT*0_Tune*"+ntupletag+"*.root",foldermc+"*DYJetsToLL*"+ntupletag+"*.root",
66  foldermc+"*_ZJet*"+ntupletag+"*.root",foldermc+"*_ttHJetTobb*"+ntupletag+"*.root",
67  foldermc+"*_WH_HToBB*"+ntupletag+"*.root",foldermc+"*_ZH_HToBB*"+ntupletag+"*.root",
68  foldermc+"*_WWTo*"+ntupletag+"*.root",foldermc+"*_WZ*"+ntupletag+"*.root",
69  foldermc+"*_ZZ_*"+ntupletag+"*.root"
70  };
71 
72  set<string> ttfiles = {foldermc+"*_TTJets*Lept*"+ntupletag+"*.root", foldermc+"*_TTJets_HT*"+ntupletag+"*.root"};
73  set<string> wfiles = {foldermc+"*_WJetsToLNu*"+ntupletag+"*.root"};
74  // set<string> stfiles = {foldermc+"*_ST_*"+ntupletag+"*.root"};
75  set<string> otherfiles = {foldermc+"*_ST_*"+ntupletag+"*.root", foldermc+"*_TTW*"+ntupletag+"*.root",foldermc+"*_TTZ*"+ntupletag+"*.root",
76  foldermc+"*_TTGJets*"+ntupletag+"*.root",foldermc+"*_TTTT*"+ntupletag+"*.root",
77  foldermc+"*QCD_HT*Inf_Tune*"+ntupletag+"*.root",
78  foldermc+"*QCD_HT*0_Tune*"+ntupletag+"*.root",foldermc+"*DYJetsToLL*"+ntupletag+"*.root",
79  foldermc+"*_ZJet*"+ntupletag+"*.root",foldermc+"*_ttHJetTobb*"+ntupletag+"*.root",
80  foldermc+"*_WH_HToBB*"+ntupletag+"*.root",foldermc+"*_ZH_HToBB*"+ntupletag+"*.root",
81  foldermc+"*_WWTo*"+ntupletag+"*.root",foldermc+"*_WZ*"+ntupletag+"*.root",
82  foldermc+"*_ZZ_*"+ntupletag+"*.root"};
83 
84  auto proc_2l = Process::MakeShared<Baby_full>("tru 2l", Process::Type::background, kPink-2,
85  allfiles, baseline && "stitch && ntruleps>=2");
86  auto proc_1lgood = Process::MakeShared<Baby_full>("tru 1l m_{T}-m_{T}^{tru}#leq60", Process::Type::background, kPink-6,
87  allfiles, baseline && "stitch && ntruleps==1 && mt-mt_tru<=60");
88  auto proc_1lbad = Process::MakeShared<Baby_full>("tru 1l m_{T}-m_{T}^{tru}>60", Process::Type::background, kBlue+1,
89  allfiles, baseline && "stitch && ntruleps==1 && mt-mt_tru>60");
90 
91  auto proc_2l_himt = Process::MakeShared<Baby_full>("True 2l, m_{T}>140", Process::Type::background,kCyan-3, //kGreen+1,
92  allfiles, baseline && "stitch && ntruleps>=2 && mt>140");
93  auto proc_1lgood_himt = Process::MakeShared<Baby_full>("tru 1l well meas. m_{T}>140", Process::Type::background, kGreen-3,
94  allfiles, baseline && "stitch && ntruleps==1 && mt_tru>=140 && mt>140");
95  auto proc_1lbad_himt = Process::MakeShared<Baby_full>("tru 1l mismeas. m_{T}>140", Process::Type::background, kRed,
96  allfiles, baseline && "stitch && ntruleps==1 && mt_tru<=140 && mt>140");
97  auto proc_0l_himt = Process::MakeShared<Baby_full>("True 0l, m_{T}>140", Process::Type::background,colors("other"),
98  allfiles, baseline && "stitch && ntruleps==0 && mt>140");
99 
101  auto proc_lomt = Process::MakeShared<Baby_full>("All bkg. m_{T}#leq140", Process::Type::background, 1,
102  allfiles, baseline && "stitch && mt<=140");
103  auto proc_tt_lomt = Process::MakeShared<Baby_full>("t#bar{t} m_{T}#leq140", Process::Type::background, 1,
104  ttfiles, baseline && "stitch && mt<=140 && ntruleps==1");
105 
107  auto proc_1l_himt = Process::MakeShared<Baby_full>("True 1l, m_{T}>140", Process::Type::background,colors("tt_1l"),
108  allfiles, baseline && "stitch && ntruleps==1 && mt>140");
109  auto proc_01l_himt = Process::MakeShared<Baby_full>("True 0-1l, m_{T}>140", Process::Type::background,kRed+1,
110  allfiles, baseline && "stitch && ntruleps<=1 && mt>140");
111 
113  auto proc_tt2l_himt = Process::MakeShared<Baby_full>("t#bar{t} 2l, m_{T}>140", Process::Type::background,
114  colors("tt_2l"), ttfiles,
115  baseline && "stitch && ntruleps>=2 && mt>140");
116  auto proc_tt1l_himt = Process::MakeShared<Baby_full>("t#bar{t} 1l, m_{T}>140", Process::Type::background,
117  colors("tt_1l"), ttfiles,
118  baseline && "stitch && ntruleps==1 && mt>140");
119  auto proc_w_himt = Process::MakeShared<Baby_full>("W+jets, m_{T}>140", Process::Type::background,
120  colors("wjets"), wfiles,
121  baseline && "stitch && mt>140");
122  // auto proc_st_himt = Process::MakeShared<Baby_full>("Single t, m_{T}>140", Process::Type::background,
123  // colors("single_t"), stfiles,
124  // baseline && "stitch && mt>140");
125  auto proc_other_himt = Process::MakeShared<Baby_full>("Other, m_{T}>140", Process::Type::background,
126  colors("other"), otherfiles,
127  baseline && "stitch && mt>140");
128 >>>>>>> b1f888b55e7125d5a772cc4a7067bd650781e35f
129 
130 
131  //vector<shared_ptr<Process> > all_procs = {proc_1lgood, proc_2l, proc_1lbad, proc_0l};
132  vector<shared_ptr<Process> > goodbad_procs = {proc_lomt, proc_1lbad_himt, proc_1lgood_himt, proc_2l_himt};
133  vector<shared_ptr<Process> > goodbad0_procs = {proc_lomt, proc_0l_himt, proc_1lbad_himt, proc_1lgood_himt, proc_2l_himt};
134  vector<shared_ptr<Process> > proc_procs = {proc_lomt, proc_other_himt,
135  proc_w_himt, proc_tt1l_himt, proc_tt2l_himt};
136  vector<shared_ptr<Process> > lep_procs = {proc_lomt, proc_01l_himt, proc_2l_himt};
137 
138  PlotOpt log_shapes("txt/plot_styles.txt", "CMSPaper");
139  log_shapes.Title(TitleType::info)
140 <<<<<<< HEAD
141  .Bottom(BottomType::ratio)
142  .YAxis(YAxisType::log)
143  .Stack(StackType::shapes)
144  .RatioMaximum(2.4);
145  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
146  vector<PlotOpt> plot_types = {lin_shapes};
147 
148  NamedFunc baseline_1l = "stitch && nleps==1 && nveto==0 && nbm>=1 && weight<1";
149  NamedFunc baseline_2l = "stitch && nleps==2";
150  NamedFunc baseline_lveto = "stitch && nleps==1 && nveto==1 && nbm>=1 && mt>140";
151 
152  auto tt1l_lowmt = Process::MakeShared<Baby_full>("t#bar{t}(1l), m_{T} #leq 140",
153  Process::Type::background, colors("tt_1l"), files_tt, baseline_1l && "ntruleps>=1 && mt<=140");
154  tt1l_lowmt->SetLineStyle(2);
155  auto tt1l_highmt = Process::MakeShared<Baby_full>("t#bar{t}(1l), m_{T} > 140",
156  Process::Type::background, colors("tt_1l"), files_tt, baseline_1l && "ntruleps>=1 && mt>140");
157  auto tt2l = Process::MakeShared<Baby_full>("t#bar{t}(2l)",
158  Process::Type::background, kGreen+2, files_tt, baseline_2l && "ntruleps>=1");
159  auto ttlveto = Process::MakeShared<Baby_full>("t#bar{t}(lv), m_{T} > 140",
160  Process::Type::background, kOrange+1, files_tt, baseline_lveto && "ntruleps>=1");
161 
162  auto tt1l_highmt_2trul = Process::MakeShared<Baby_full>("t#bar{t}(1l), m_{T} > 140, tru: 2l",
163  Process::Type::background, colors("tt_2l"), files_tt,
164  baseline_1l && "ntruleps>=1 && ntruels+ntrumus+ntrutausl==2 && mt>140");
165  auto tt1l_highmt_1trul_1trutauh = Process::MakeShared<Baby_full>("t#bar{t}(1l), m_{T} > 140, tru: l#tau_{h}",
166  Process::Type::background, kBlue-6, files_tt,
167  baseline_1l && "ntruleps>=1 && ntruels+ntrumus+ntrutausl==1 && ntrutaush==1 && mt>140");
168  auto tt1l_highmt_1trul = Process::MakeShared<Baby_full>("t#bar{t}(1l), m_{T} > 140, tru: 1l",
169  Process::Type::background, kTeal-6, files_tt,
170  baseline_1l && "ntruleps>=1 && ntruels+ntrumus+ntrutausl==1 && ntrutaush==0 && mt>140");
171 
172  auto bkg1l_lowmt = Process::MakeShared<Baby_full>("Tot. bkgd (1l), m_{T}#leq140",
173  Process::Type::background, kGray+3, files_all, baseline_1l && "mt<=140");
174  bkg1l_lowmt->SetLineStyle(2);
175  auto bkg1l_highmt = Process::MakeShared<Baby_full>("Tot. bkgd (1l), m_{T}>140",
176  Process::Type::background, kGray+3, files_all, baseline_1l && "mt>140");
177  auto bkg2l = Process::MakeShared<Baby_full>("Tot. bkgd (2l)",
178  Process::Type::background, kGreen-5, files_all, baseline_2l);
179  auto bkglveto = Process::MakeShared<Baby_full>("Tot. bkgd (lv), m_{T} > 140",
180  Process::Type::background, kOrange+1, files_all, baseline_lveto);
181 
182  auto wjets1l_lowmt = Process::MakeShared<Baby_full>("W+jets (1l), m_{T}#leq140",
183  Process::Type::background, colors("wjets"), files_wjets, baseline_1l && "mt<=140");
184  // wjets1l_lowmt->SetLineStyle(2);
185  auto st1l_lowmt = Process::MakeShared<Baby_full>("Single t (1l), m_{T}#leq140",
186  Process::Type::background, colors("single_t"), files_st, baseline_1l && "mt<=140");
187  // st1l_lowmt->SetLineStyle(2);
188  auto other1l_lowmt = Process::MakeShared<Baby_full>("Other (1l), m_{T}#leq140",
189  Process::Type::background, colors("other"), files_other, baseline_1l && "mt<=140");
190  // other1l_lowmt->SetLineStyle(2);
191  auto nontt2l = Process::MakeShared<Baby_full>("Non-t#bar{t} (2l)",
192  Process::Type::background, colors("other"), files_nontt, baseline_2l);
193  auto nontt1l_highmt = Process::MakeShared<Baby_full>("Non-t#bar{t} (1l), m_{T}>140",
194  Process::Type::background, colors("other"), files_nontt, baseline_1l && "mt>140");
195 
196  map<string, vector<shared_ptr<Process> > > procs, procs_pie, procs_isr;
197  // compare the shapes of the low-mT components: tt, st, w, other
198  procs["lowmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, other1l_lowmt, st1l_lowmt, wjets1l_lowmt});
199  procs_pie["lowmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, other1l_lowmt, st1l_lowmt, wjets1l_lowmt});
200  // compare the tt@low-mT shape to the high-mT components: tru 2l, tru 1l+tauh, non-tt
201  procs["highmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, tt1l_highmt_2trul,
202  tt1l_highmt_1trul_1trutauh, tt1l_highmt_1trul, nontt1l_highmt});
203  procs_isr["highmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, tt1l_highmt_2trul,
204  tt1l_highmt_1trul_1trutauh, tt1l_highmt_1trul});
205  procs_pie["highmt"] = vector<shared_ptr<Process> >({tt1l_highmt_2trul,
206  tt1l_highmt_1trul_1trutauh, tt1l_highmt_1trul, nontt1l_highmt});
207  // compare the tt@low-mT shape to the dilepton test pieces: tt 2l, non-tt 2l and lveto
208  procs["dilep"] = vector<shared_ptr<Process> >({tt1l_lowmt, nontt2l, ttlveto, tt2l});
209  procs_isr["dilep"] = vector<shared_ptr<Process> >({tt1l_lowmt, ttlveto, tt2l});
210  procs_pie["dilep"] = vector<shared_ptr<Process> >({nontt2l, ttlveto, tt2l});
211  // compare full background: low-mT, high-mT, 2l and lveto
212  procs["totbkg"] = vector<shared_ptr<Process> >({bkg1l_lowmt, bkg2l, bkglveto, bkg1l_highmt});
213  procs_pie["totbkg"] = vector<shared_ptr<Process> >({bkg2l, bkglveto, bkg1l_highmt});
214 
215  vector<NamedFunc> htopt;
216  if (do_htopts) {
217  htopt.push_back(NamedFunc("ht"));
218  htopt.push_back(NamedFunc("st", [](const Baby &b) -> NamedFunc::ScalarType{
219  float st = b.ht();
220  for (const auto &pt: *(b.leps_pt())) st += pt;
221  return st;
222  }));
223  htopt.push_back(NamedFunc("ht1l_stmin2l", [](const Baby &b) -> NamedFunc::ScalarType{
224  float ht_proxy = b.ht();
225  if (b.nleps()==2) ht_proxy = b.ht()+b.leps_pt()->at(1);
226  return ht_proxy;
227  }));
228  htopt.push_back(NamedFunc("ht1l_stave2l", [](const Baby &b) -> NamedFunc::ScalarType{
229  float ht_proxy = b.ht();
230  if (b.nleps()==2) ht_proxy = b.ht()+(b.leps_pt()->at(0)+b.leps_pt()->at(1))/2.;
231  return ht_proxy;
232  }));
233  }
234  htopt.push_back(NamedFunc("ht1l_stmax2l", [](const Baby &b) -> NamedFunc::ScalarType{
235  float ht_proxy = b.ht();
236  if (b.nleps()==2) ht_proxy = b.ht()+b.leps_pt()->at(0);
237  return ht_proxy;
238  }));
239 =======
240  .Bottom(BottomType::ratio)
241  .YAxis(YAxisType::log)
242  .Stack(StackType::shapes)
243  .RatioMaximum(2.8);
244  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
245  vector<PlotOpt> plot_types = {lin_shapes};
246 
247 >>>>>>> b1f888b55e7125d5a772cc4a7067bd650781e35f
248 
249  vector<NamedFunc> metbins;
250  if (do_met100) metbins.push_back(NamedFunc("met>100&&met<=150"));
251  if (do_met150) metbins.push_back(NamedFunc("met>150&&met<=200"));
252  if (do_metbins) {
253  metbins.push_back(NamedFunc("met>200&&met<=350"));
254  metbins.push_back(NamedFunc("met>350&&met<=500"));
255  metbins.push_back(NamedFunc("met>500"));
256  } else {
257  metbins.push_back(NamedFunc("met>200"));
258  }
259 <<<<<<< HEAD
260 
261  NamedFunc ave_toppt("ave_toppt",[](const Baby &b) -> NamedFunc::ScalarType{
262  float toppt = 0;
263  for (size_t imc(0); imc<b.mc_pt()->size(); imc++){
264  if (fabs(b.mc_id()->at(imc))==6 && b.mc_status()->at(imc)==62) toppt += b.mc_pt()->at(imc);
265  }
266  return toppt/2.;
267  });
268 
269  map<bool, vector<string> > nobjbins;
270  // with leptons clustered
271  nobjbins[true] = vector<string>();
272  nobjbins[true].push_back("njets+nleps==6");
273  nobjbins[true].push_back("njets+nleps>=7 && njets+nleps<=9");
274  nobjbins[true].push_back("njets+nleps>=10");
275  // without leptons clustered
276  nobjbins[false] = vector<string>();
277  nobjbins[false].push_back("njets==5");
278  nobjbins[false].push_back("njets>=6 && njets<=8");
279  nobjbins[false].push_back("njets>=9");
280 =======
281  vector<string> nobjbins;
282  nobjbins = vector<string>();
283  // nobjbins.push_back("njets==5");
284  // nobjbins.push_back("njets>=6 && njets<=8");
285  // nobjbins.push_back("njets>=9");
286  nobjbins.push_back("njets>=6");
287  nobjbins.push_back("njets>=9");
288 >>>>>>> b1f888b55e7125d5a772cc4a7067bd650781e35f
289 
290  int Nplots=0;
291  PlotMaker pm;
292 <<<<<<< HEAD
293  vector<bool> rcopts = {true, false}; // plot both
294  if (!Contains(folder_mc,"reclustered") || !compare_mj_nolep) rcopts = {true};
295  for (auto mj_lep: {true, false}){
296  string xtitle = mj_lep ? "M_{J} [GeV]" : "M_{J} (no lep) [GeV]";
297  string var = (Contains(folder_mc,"reclustered") && mj_lep) ? "mj14_original" : "mj14";
298  for (auto &iproc:procs){
299  vector<TableRow> table_cuts;
300  for (auto &imet: metbins) {
301  for (auto &inobj: nobjbins[mj_lep]) {
302  for (auto &iht: htopt){
303  // no dilepton test for njets==5
304  if(iproc.first == "dilep" && Contains(inobj,"==6")) continue;
305  vector<shared_ptr<Process> > procs_tmp = iproc.second;
306  //similarly, remove 2l for njets==5 category
307  if (iproc.first == "totbkg" && Contains(inobj,"==6"))
308  procs_tmp = vector<shared_ptr<Process> >({bkg1l_lowmt, bkglveto, bkg1l_highmt});
309  // histograms
310  NamedFunc icut = imet && inobj && iht>500;
311  pm.Push<Hist1D>(Axis(10, 100., 850., var, xtitle, {250., 400.}),
312  icut, procs_tmp, plot_types).Tag(CodeToPlainText(iproc.first+"_"+iht.Name()));
313  plot_names.insert(pm.GetLast<Hist1D>()->Name()+"_OPT_"+plot_types[0].TypeString()+".pdf");
314 
315  if (procs_isr.find(iproc.first)!=procs_isr.end()) {
316  pm.Push<Hist1D>(Axis(10, 0., 800., ave_toppt, "Ave. top p_{T} [GeV]"),
317  icut && var+">250", procs_isr[iproc.first], plot_types).Tag(CodeToPlainText(iproc.first+"_"+iht.Name()));
318  plot_names.insert(pm.GetLast<Hist1D>()->Name()+"_OPT_"+plot_types[0].TypeString()+".pdf");
319  pm.Push<Hist1D>(Axis(10, 0., 800., "isr_tru_pt", "True ISR p_{T} [GeV]"),
320  icut && var+">250", procs_isr[iproc.first], plot_types).Tag(CodeToPlainText(iproc.first+"_"+iht.Name()));
321  plot_names.insert(pm.GetLast<Hist1D>()->Name()+"_OPT_"+plot_types[0].TypeString()+".pdf");
322  }
323  // pies
324  table_cuts.push_back(TableRow("",icut));
325  pie_names.insert(CodeToPlainText("pie_"+iproc.first+"_"+icut.Name()+"_perc_lumi"+RoundNumber(lumi,0).Data()+".pdf"));
326  Nplots++;
327  } // loop over ht options
328  } // loop over nobj bins
329  } // loop over met bins
330  pm.Push<Table>(iproc.first, table_cuts, procs_pie[iproc.first], false, true, true);
331  } // loop over proc sets
332  } // loop over cluster vs not-cluster leptons
333  pm.min_print_ = true;
334  pm.MakePlots(lumi);
335 
336  // slides comparing closure for MJ_lep and MJ_nolep
337  if (Contains(folder_mc,"reclustered") && compare_mj_nolep) {
338  SlideMaker sm_mjnolep("mjlep_vs_nolep.tex","1610");
339  for (auto &iht: htopt){
340  for (auto &imet: metbins) {
341  for (size_t inobj(0); inobj<nobjbins[true].size(); inobj++) {
342  vector<string> pnames;
343  for (auto mj_lep: {true, false}) {
344  for (auto &iproc: procs){
345  string proc = iproc.first;
346  if(proc == "dilep" && (Contains(nobjbins[mj_lep][inobj],"==6") || Contains(nobjbins[mj_lep][inobj],"==5"))) continue;
347  NamedFunc icut = imet && nobjbins[mj_lep][inobj] && iht>500;
348  string var = mj_lep ? "mj14_original" : "mj14";
349  string iname = CodeToPlainText(proc+"_"+iht.Name()+"_VAR_"+var+"_CUT_"+icut.Name()
350  +"_WGT_weight_OPT_"+plot_types[0].TypeString()+".pdf");
351  if (plot_names.find(iname)!=plot_names.end()) pnames.push_back(iname);
352  }
353  }
354  sm_mjnolep.AddSlide(pnames,4);
355  }
356  }
357  }
358  sm_mjnolep.Close();
359  }
360 
361  // Make slides to show comparison between the different modified HT options
362  if (do_htopts){
363  for (auto mj_lep: {true, false}){
364  string sname = mj_lep ? "plots_mj.tex" : "plots_mj_nolep.tex";
365  SlideMaker sm_htopt(sname);
366  string var = (Contains(folder_mc,"reclustered") && mj_lep) ? "mj14_original" : "mj14";
367  for (auto &iproc: procs){
368  string proc = iproc.first;
369  for (auto &imet: metbins) {
370  for (auto &inobj: nobjbins[mj_lep]) {
371  vector<string> pnames(15,"");
372  for (size_t iht(0); iht<htopt.size(); iht++){
373  NamedFunc icut = imet && inobj && htopt[iht]>500;
374  string iname = CodeToPlainText(proc+"_"+htopt[iht].Name()+"_VAR_"+var + "_CUT_" + icut.Name()
375  + "_WGT_weight_OPT_"+plot_types[0].TypeString()+".pdf");
376  if (plot_names.find(iname)!=plot_names.end()){
377  pnames[iht] = CodeToPlainText("pie_"+proc+"_"+icut.Name()+"_perc_lumi"+RoundNumber(lumi,0).Data()+".pdf");
378  pnames[htopt.size()+iht] = iname;
379  }
380  icut = icut && var+">250";
381  iname = CodeToPlainText(proc+"_"+htopt[iht].Name()+"_VAR_isr_tru_pt_CUT_" + icut.Name()
382  + "_WGT_weight_OPT_"+plot_types[0].TypeString()+".pdf");
383  if (plot_names.find(iname)!=plot_names.end()) pnames[2*htopt.size()+iht] = iname;
384  }
385  sm_htopt.AddSlide(pnames,5);
386  }
387  }
388  }
389  sm_htopt.Close();
390  }
391  }
392 =======
393  for (auto &imet: metbins) {
394  for (auto &inobj: nobjbins) {
395  NamedFunc icut = imet && inobj;
396  pm.Push<Hist1D>(Axis(10, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
397  icut, goodbad_procs, plot_types).Tag("thin_goodbad");
398  pm.Push<Hist1D>(Axis(10, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
399  icut, goodbad0_procs, plot_types).Tag("thin_goodbad0");
400  pm.Push<Hist1D>(Axis(10, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
401  icut, proc_procs, plot_types).Tag("thin_proc");
402  pm.Push<Hist1D>(Axis(10, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
403  icut, lep_procs, plot_types).Tag("thin_lep");
404 
405  pm.Push<Hist1D>(Axis(5, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
406  icut, goodbad_procs, plot_types).Tag("fat_goodbad");
407  pm.Push<Hist1D>(Axis(5, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
408  icut, goodbad0_procs, plot_types).Tag("fat_goodbad0");
409  pm.Push<Hist1D>(Axis(5, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
410  icut, proc_procs, plot_types).Tag("fat_proc");
411  pm.Push<Hist1D>(Axis(5, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
412  icut, lep_procs, plot_types).Tag("fat_lep");
413 
414  // pm.Push<Hist1D>(Axis(10, 100., 850., "mj14", "M_{J} [GeV]", {250., 400.}),
415  // icut, lep_procs, plot_types).Tag("lep");
416  // pm.Push<Hist1D>(Axis(12, 0., 420., "mt", "m_{T} [GeV]", {140.}),
417  // icut, all_procs, plot_types).Tag("mt");
418  Nplots += 1;
419  } // Loop over nobj bins
420  } // Loop over met bins
421  pm.min_print_ = true;
422  pm.MakePlots(lumi);
423 
424 
425 >>>>>>> b1f888b55e7125d5a772cc4a7067bd650781e35f
426 
427  double seconds = (chrono::duration<double>(chrono::high_resolution_clock::now() - begTime)).count();
428  TString hhmmss = HoursMinSec(seconds);
429  cout<<endl<<"Making "<<Nplots<<" plots took "<<round(seconds)<<" seconds ("<<hhmmss<<")"<<endl<<endl;
430 }
431 
std::vector< int > *const & mc_status() const
Get mc_status for current event and cache it.
Definition: baby.cpp:4625
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
TString HoursMinSec(float fseconds)
Definition: utilities.cpp:337
std::string Name() const
Definition: hist1d.cpp:479
std::vector< float > *const & leps_pt() const
Get leps_pt for current event and cache it.
Definition: baby.cpp:4493
int const & nleps() const
Get nleps for current event and cache it.
Definition: baby.cpp:6053
std::string CodeToPlainText(std::string code)
Definition: utilities.cpp:79
const std::string & Name() const
Get the string representation of this function.
Definition: named_func.cpp:376
Abstract base class for access to ntuple variables.
Definition: baby.hpp:16
void Close()
Definition: slide_maker.cpp:37
STL namespace.
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
int main()
std::string execute(const std::string &cmd)
Definition: utilities.cpp:65
double ScalarType
Definition: named_func.hpp:15
std::vector< float > *const & mc_pt() const
Get mc_pt for current event and cache it.
Definition: baby.cpp:4613
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
Definition: axis.hpp:12
bool min_print_
Definition: plot_maker.hpp:44
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
PlotOpt & RatioMaximum(double ratio_maximum)
Definition: plot_opt.cpp:368
std::vector< int > *const & mc_id() const
Get mc_id for current event and cache it.
Definition: baby.cpp:4553
FigureType * GetLast()
Definition: plot_maker.hpp:34
A full 1D plot with stacked/overlayed histograms.
Definition: hist1d.hpp:23
Definition: table.hpp:15
const NamedFunc st("st", [](const Baby &b) -> NamedFunc::ScalarType{float stvar=b.ht();for(const auto &pt:*(b.leps_pt())) stvar+=pt;return stvar;})
void AddSlide(std::vector< std::string > pnames, int ncols=-1, std::string title="")
Definition: slide_maker.cpp:15
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
float const & ht() const
Get ht for current event and cache it.
Definition: baby.cpp:3929
Loads colors from a text configuration file.
Definition: palette.hpp:8