ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_2016-06-03_prelim_status_dump.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <vector>
4 #include <memory>
5 
6 #include "TError.h"
7 #include "TColor.h"
8 
9 #include "baby.hpp"
10 #include "process.hpp"
11 #include "named_func.hpp"
12 #include "plot_maker.hpp"
13 #include "plot_opt.hpp"
14 #include "palette.hpp"
15 
16 using namespace std;
17 using namespace PlotOptTypes;
18 
19 template<typename T>
20 shared_ptr<Process> Proc(const string process_name, Process::Type type,
21  int color, const set<string> &files, const string &cut = "1"){
22  return make_shared<Process>(process_name, type, color,
23  unique_ptr<Baby>(new T(files)),
24  cut);
25 }
26 
27 int main(){
28  gErrorIgnoreLevel = 6000;
29 
30  //double lumi = 0.218;
31  double lumi = 0.589;
32 
33  // 74x
34  string trig_skim_mc = "/net/cms27/cms27r0/babymaker/2016_04_29/mc/merged_1lht500met200/";
35  string trig_mc = "/net/cms27/cms27r0/babymaker/2016_04_29/mc/unskimmed/";
36  // 80X (ttbar, qcd, dy[ht=100-600], wjets) + 74X (rest)
37  //trig_skim_mc = "/net/cms2/cms2r0/babymaker/babies/2016_05_31/mc/skim_1lht500met200/";
38 
39  Palette colors("txt/colors.txt", "default");
40 
41  auto tt1l = Proc<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
42  {trig_skim_mc+"*_TTJets*Lept*.root", trig_skim_mc+"*_TTJets_HT*.root"},
43  "ntruleps<=1&&stitch");
44  auto tt2l = Proc<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
45  {trig_skim_mc+"*_TTJets*Lept*.root", trig_skim_mc+"*_TTJets_HT*.root"},
46  "ntruleps>=2&&stitch");
47  auto wjets = Proc<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
48  {trig_skim_mc+"*_WJetsToLNu*.root"});
49  auto single_t = Proc<Baby_full>("Single t", Process::Type::background, colors("single_t"),
50  {trig_skim_mc+"*_ST_*.root"});
51  auto ttv = Proc<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
52  {trig_skim_mc+"*_TTWJets*.root", trig_skim_mc+"*_TTZTo*.root"});
53  auto other = Proc<Baby_full>("Other", Process::Type::background, colors("other"),
54  {trig_skim_mc+"*DYJetsToLL*.root", trig_skim_mc+"*_QCD_HT*.root",
55  trig_skim_mc+"*_ZJet*.root", trig_skim_mc+"*_WWTo*.root",
56  trig_skim_mc+"*ggZH_HToBB*.root", trig_skim_mc+"*ttHJetTobb*.root",
57  trig_skim_mc+"*_TTGJets*.root", trig_skim_mc+"*_TTTT_*.root",
58  trig_skim_mc+"*_WH_HToBB*.root", trig_skim_mc+"*_WZTo*.root",
59  trig_skim_mc+"*_ZH_HToBB*.root", trig_skim_mc+"_ZZ_*.root"});
60 
61  auto t1tttt_nc = Proc<Baby_full>("T1tttt(1500,100)", Process::Type::signal, colors("t1tttt"),
62  {trig_mc+"*SMS-T1tttt_mGluino-1500_mLSP-100*.root"});
63  auto t1tttt_c = Proc<Baby_full>("T1tttt(1200,800)", Process::Type::signal, colors("t1tttt"),
64  {trig_mc+"*SMS-T1tttt_mGluino-1200_mLSP-800*.root"});
65  t1tttt_c->SetLineStyle(2);
66 
67  auto data_1l = Proc<Baby_full>("Data", Process::Type::data, kBlack,
68  //{"/net/cms24/cms24r0/jaehyeok/susy_cfa_babies/2016_05_20/data/singlelep/skim_nleps1njets2/*.root"},"pass&&(trig[4]||trig[8])"); // 0.218 fb-1
69  //{"/net/cms2/cms2r0/babymaker/babies/2016_05_20/data/met/skim_met150/*.root"},"pass&&trig[28]"); // 0.218 fb-1;
70  {"/net/cms2/cms2r0/babymaker/babies/2016_05_31/data/met/*.root"},"pass&&trig[28]"); // 0.589 fb-1
71  vector<shared_ptr<Process> > full_trig_skim_1l = {data_1l, t1tttt_nc, t1tttt_c, tt1l, tt2l, wjets, single_t, ttv, other};
72 
73  //
74  // 2l / 0l
75  //
76  auto tt1l_unskim = Proc<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
77  {trig_mc+"*_TTJets*Lept*.root"},
78  "ntruleps<=1");
79  auto tt2l_unskim = Proc<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
80  {trig_mc+"*_TTJets*Lept*.root"},
81  "ntruleps>=2");
82  auto tt_unskim = Proc<Baby_full>("t#bar{t}", Process::Type::background, colors("tt_1l"),
83  {trig_mc+"*_TTJets_TuneCUETP8M1_13TeV*.root"});
84  auto dy_unskim = Proc<Baby_full>("DY", Process::Type::background, colors("wjets"),
85  {trig_mc+"*DYJetsToLL*HT*.root"});
86  auto qcd_unskim = Proc<Baby_full>("QCD", Process::Type::background, colors("qcd"),
87  {trig_mc+"*_QCD_HT700to1000*.root",trig_mc+"*_QCD_HT1000to1500*.root",
88  trig_mc+"*_QCD_HT1500to2000*.root",trig_mc+"*_QCD_HT2000toInf*.root"});
89  auto other_unskim = Proc<Baby_full>("Other", Process::Type::background, colors("ttv"),
90  {trig_mc+"*_TTWJet*root", trig_mc+"*_TTZTo*.root",
91  trig_mc+"*_ZJet*.root", trig_mc+"*_WWTo*.root",
92  trig_mc+"*ggZH_HToBB*.root", trig_mc+"*ttHJetTobb*.root",
93  trig_mc+"*_TTGJets*.root", trig_mc+"*_TTTT_*.root",
94  trig_mc+"*_WH_HToBB*.root", trig_mc+"*_WZTo*.root",
95  trig_skim_mc+"*_ST_*.root", trig_skim_mc+"*_WJetsToLNu*.root",
96  trig_mc+"*_ZH_HToBB*.root", trig_mc+"_ZZ_*.root"});
97 
98  auto data_2l = Proc<Baby_full>("Data", Process::Type::data, kBlack,
99  //{"/net/cms24/cms24r0/jaehyeok/susy_cfa_babies/2016_05_20/data/singlelep/skim_nleps1njets2/*.root"},"pass&&(trig[20]||trig[22])"); // 0.218 fb-1
100  {"/net/cms2/cms2r0/babymaker/babies/2016_05_31/data/singlelep/combined/*.root"},"pass&&(trig[20]||trig[22])"); // 0.589 fb-1
101  vector<shared_ptr<Process> > full_trig_skim_2l = {data_2l, t1tttt_nc, t1tttt_c, tt1l_unskim, tt2l_unskim, dy_unskim, other_unskim};
102 
103  auto data_0l = Proc<Baby_full>("Data", Process::Type::data, kBlack,
104  //{"/net/cms24/cms24r0/jaehyeok/susy_cfa_babies/2016_05_27/data/jetht/*.root"},"pass&&trig[12]"); // FIXME: trigger
105  {"/net/cms2/cms2r0/babymaker/babies/2016_05_31/data/jetht/*.root"},"pass&&trig[12]"); // FIXME: trigger
106  vector<shared_ptr<Process> > full_trig_skim_0l = {data_0l, t1tttt_nc, t1tttt_c, qcd_unskim, tt_unskim, other_unskim};
107 
108  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
109  log_lumi.Title(TitleType::preliminary)
110  .Bottom(BottomType::ratio)
111  .YAxis(YAxisType::log)
112  .Stack(StackType::data_norm);
113  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
114  PlotOpt log_shapes = log_lumi().Stack(StackType::shapes)
115  .Bottom(BottomType::off)
116  .ShowBackgroundError(false);
117  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
118  PlotOpt log_lumi_info = log_lumi().Title(TitleType::info);
119  PlotOpt lin_lumi_info = lin_lumi().Title(TitleType::info);
120  PlotOpt log_shapes_info = log_shapes().Title(TitleType::info);
121  PlotOpt lin_shapes_info = lin_shapes().Title(TitleType::info);
122  vector<PlotOpt> all_plot_types = {log_lumi_info, lin_lumi_info};
123 
124 
125  string commoncut = "mt<140&&ht>500&&met>200";
126  PlotMaker pm;
127 
128  for(int ilep=0; ilep<3; ilep++)
129  {
130  string lepcut;
131  if(ilep==0) lepcut=commoncut+"&&nels==1&&nmus==0";
132  if(ilep==1) lepcut=commoncut+"&&nels==0&&nmus==1";
133  if(ilep==2) lepcut=commoncut+"&&nleps==1";
134 
135  //
136  // event-level variables except ones related to fatjet
137  //
138  pm.AddPlot(HistoDef(15, 500, 2000., "ht", "H_{T} [GeV]",
139  lepcut+"&&njets>=5&&nbm>=1", "weight", {500.}),
140  full_trig_skim_1l, all_plot_types);
141  pm.AddPlot(HistoDef(10, 200, 500., "met", "E_{T}^{miss} [GeV]",
142  lepcut+"&&njets>=5&&nbm>=1", "weight", {200., 350., 500.}),
143  full_trig_skim_1l, all_plot_types);
144  pm.AddPlot(HistoDef(16, -0.5, 15.5, "njets", "N_{jets}",
145  lepcut+"&&nbm>=1", "weight", {5.5, 8.5}),
146  full_trig_skim_1l, all_plot_types);
147  pm.AddPlot(HistoDef(7, -0.5, 6.5, "nbm", "N_{b}",
148  lepcut+"&&njets>=5", "weight", {0.5, 1.5, 2.5}),
149  full_trig_skim_1l, all_plot_types);
150 
151  pm.AddPlot(HistoDef(16, 0., 280., "mt", "m_{T} [GeV]",
152  lepcut+"&&njets>=5&&nbm>=1", "weight", {140.}),
153  full_trig_skim_1l, all_plot_types);
154  pm.AddPlot(HistoDef(16, 0., 280., "mt", "m_{T} [GeV]",
155  lepcut+"&&njets>=5&&nbm==0", "weight", {140.}),
156  full_trig_skim_1l, all_plot_types);
157 
158  //
159  // leptons
160  //
161  if(ilep==0) // electron
162  {
163  pm.AddPlot(HistoDef(10, 0, 200., "leps_pt[0]", "p_{T}(electron) [GeV]",
164  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
165  full_trig_skim_1l, all_plot_types);
166  pm.AddPlot(HistoDef(10, -2.5, 2.5, "leps_eta[0]", "#eta(electron) [GeV]",
167  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
168  full_trig_skim_1l, all_plot_types);
169  }
170  else if(ilep==1) // muon
171  {
172  pm.AddPlot(HistoDef(10, 0, 200., "leps_pt[0]", "p_{T}(muon) [GeV]",
173  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
174  full_trig_skim_1l, all_plot_types);
175  pm.AddPlot(HistoDef(10, -2.5, 2.5, "leps_eta[0]", "#eta(muon) [GeV]",
176  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
177  full_trig_skim_1l, all_plot_types);
178  }
179  else if(ilep==2) // electron or muon
180  {
181  pm.AddPlot(HistoDef(10, 0, 200., "leps_pt[0]", "p_{T}(lepton) [GeV]",
182  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
183  full_trig_skim_1l, all_plot_types);
184  pm.AddPlot(HistoDef(10, -2.5, 2.5, "leps_eta[0]", "#eta(lepton) [GeV]",
185  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
186  full_trig_skim_1l, all_plot_types);
187  }
188 
189  //
190  // jets
191  //
192  pm.AddPlot(HistoDef(10, 30, 630., "jets_pt[0]", "p_{T}(leading jet) [GeV]",
193  lepcut+"&&njets>=5&&nbm>=1&&(!jets_islep[0])", "weight", {999.}),
194  full_trig_skim_1l, all_plot_types);
195  pm.AddPlot(HistoDef(10, -2.5, 2.5, "jets_eta[0]", "#eta(leading jet) [GeV]",
196  lepcut+"&&njets>=5&&nbm>=1&&(!jets_islep[0])", "weight", {999.}),
197  full_trig_skim_1l, all_plot_types);
198  pm.AddPlot(HistoDef(10, 0, 200., "jets_m[0]", "mass(leading jet) [GeV]",
199  lepcut+"&&njets>=5&&nbm>=1&&(!jets_islep[0])", "weight", {999.}),
200  full_trig_skim_1l, all_plot_types);
201  pm.AddPlot(HistoDef(10, 30, 630., "jets_pt", "p_{T}(jet) [GeV]",
202  lepcut+"&&njets>=5&&nbm>=1&&(!jets_islep)", "weight", {999.}),
203  full_trig_skim_1l, all_plot_types);
204  pm.AddPlot(HistoDef(10, -2.5, 2.5, "jets_eta", "#eta(jet) [GeV]",
205  lepcut+"&&njets>=5&&nbm>=1&&(!jets_islep)", "weight", {999.}),
206  full_trig_skim_1l, all_plot_types);
207  pm.AddPlot(HistoDef(10, 0, 200., "jets_m", "m(jet) [GeV]",
208  lepcut+"&&njets>=5&&nbm>=1&&(!jets_islep)", "weight", {999.}),
209  full_trig_skim_1l, all_plot_types);
210 
211  //
212  // fatjets
213  //
214  pm.AddPlot(HistoDef(10, 0, 1000., "fjets14_pt[0]", "p_{T}(J1) [GeV]",
215  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
216  full_trig_skim_1l, all_plot_types);
217  pm.AddPlot(HistoDef(10, 0, 500., "fjets14_m[0]", "m_{J1} [GeV]",
218  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
219  full_trig_skim_1l, all_plot_types);
220  pm.AddPlot(HistoDef(10, -2.5, 2.5, "fjets14_eta[0]", "#eta(J1)",
221  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
222  full_trig_skim_1l, all_plot_types);
223  pm.AddPlot(HistoDef(7, 0.5, 7.5, "fjets14_nconst[0]", "N_{constituents}(J1)",
224  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
225  full_trig_skim_1l, all_plot_types);
226  pm.AddPlot(HistoDef(10, 0, 1000., "fjets14_pt", "p_{T}(J) [GeV]",
227  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
228  full_trig_skim_1l, all_plot_types);
229  pm.AddPlot(HistoDef(10, 0, 500., "fjets14_m", "m_{J} [GeV]",
230  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
231  full_trig_skim_1l, all_plot_types);
232  pm.AddPlot(HistoDef(10, -2.5, 2.5, "fjets14_eta", "#eta(J)",
233  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
234  full_trig_skim_1l, all_plot_types);
235  pm.AddPlot(HistoDef(7, 0.5, 7.5, "fjets14_nconst", "N_{constituents}(J)",
236  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
237  full_trig_skim_1l, all_plot_types);
238 
239  pm.AddPlot(HistoDef(20, 0, 400., "fjets14_m[0]", "m_{J1} [GeV]",
240  lepcut+"&&njets<=5&&nbm>=1", "weight", {999.}),
241  full_trig_skim_1l, all_plot_types);
242 
243  // event-level variables related to fatjet
244  pm.AddPlot(HistoDef(10, 0., 1500., "mj14", "M_{J} [GeV]",
245  lepcut+"&&njets>=5&&nbm>=1", "weight", {400.}),
246  full_trig_skim_1l, all_plot_types);
247  pm.AddPlot(HistoDef(7, 0.5, 7.5, "nfjets14", "N_{J} [GeV]",
248  lepcut+"&&njets>=5&&nbm>=1", "weight", {999.}),
249  full_trig_skim_1l, all_plot_types);
250 
251  }
252 
253 
254  //
255  // di-lepton events
256  //
257  string mll="(mumu_m*(mumu_m>0&&mumu_pt1>30)+elel_m*(elel_m>0&&elel_pt1>30))";
258  string mllcut="(mumu_m*(mumu_m>0&&mumu_pt1>30)+elel_m*(elel_m>0&&elel_pt1>30))>80&&(mumu_m*(mumu_m>0&&mumu_pt1>30)+elel_m*(elel_m>0&&elel_pt1>30))<100";
259 
260 // pm.AddPlot(HistoDef(10, 50., 140., mll, "m_{ll} [GeV]",
261 // "(nmus>=2||nels>=2)&&ht>350&&njets>=2", "weight", {400.}),
262 // full_trig_skim_2l, all_plot_types);
263 
264  pm.AddPlot(HistoDef(10, 0., 1000., "mj14", "M_{J} [GeV]",
265  "nels==1&&nmus==1&&ht>300&&met>100&&njets>=2&&met<400&&nbm<3&&nbm>=1&&((leps_pt[0]>30&&leps_eta[0]<2.1&&leps_eta[0]>-2.1)||(leps_pt[1]>30&&leps_eta[1]<2.1&&leps_eta[1]>-2.1))", "weight", {400.}),
266  full_trig_skim_2l, all_plot_types);
267 
268  pm.AddPlot(HistoDef(10, 0., 1000., "mj14", "M_{J} [GeV]",
269  "(nmus>=2||nels>=2)&&ht>350&&njets>=2&&njets<=3&&"+mllcut, "weight", {400.}),
270  full_trig_skim_2l, all_plot_types);
271  pm.AddPlot(HistoDef(10, 0., 1000., "mj14", "M_{J} [GeV]",
272  "(nmus>=2||nels>=2)&&ht>350&&njets>=4&&"+mllcut, "weight", {400.}),
273  full_trig_skim_2l, all_plot_types);
274 
275  //
276  // 0-lepton events
277  //
278  pm.AddPlot(HistoDef(30, 0., 1500., "mj14", "M_{J} [GeV]",
279  "nleps==0&&met<50&&ht>1000&&njets>=4&&njets<=5", "weight", {400.}),
280  full_trig_skim_0l, all_plot_types);
281  pm.AddPlot(HistoDef(30, 0., 500., "fjets14_m", "M_{J} [GeV]",
282  "nleps==0&&met<50&&ht>1000&&njets>=4&&njets<=5", "weight", {400.}),
283  full_trig_skim_0l, all_plot_types);
284 
285  pm.AddPlot(HistoDef(30, 0., 1500., "mj14", "M_{J} [GeV]",
286  "nleps==0&&met<50&&ht>1000&&njets>=6&&njets<=8", "weight", {400.}),
287  full_trig_skim_0l, all_plot_types);
288  pm.AddPlot(HistoDef(30, 0., 500., "fjets14_m", "M_{J} [GeV]",
289  "nleps==0&&met<50&&ht>1000&&njets>=6&&njets<=8", "weight", {400.}),
290  full_trig_skim_0l, all_plot_types);
291 
292  pm.AddPlot(HistoDef(30, 0., 1500., "mj14", "M_{J} [GeV]",
293  "nleps==0&&met<50&&ht>1000&&njets>=9", "weight", {400.}),
294  full_trig_skim_0l, all_plot_types);
295  pm.AddPlot(HistoDef(30, 0., 500., "fjets14_m", "M_{J} [GeV]",
296  "nleps==0&&met<50&&ht>1000&&njets>=9", "weight", {400.}),
297  full_trig_skim_0l, all_plot_types);
298 
299  //
300  //
301  //
302  pm.MakePlots(lumi);
303 }
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
STL namespace.
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
shared_ptr< Process > Proc(const string process_name, Process::Type type, int color, const set< string > &files, const string &cut="1")
PlotOpt & ShowBackgroundError(bool show_background_error)
Definition: plot_opt.cpp:386
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
Loads colors from a text configuration file.
Definition: palette.hpp:8