ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_talk.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 "core/baby.hpp"
10 #include "core/process.hpp"
11 #include "core/named_func.hpp"
12 #include "core/plot_maker.hpp"
13 #include "core/plot_opt.hpp"
14 #include "core/palette.hpp"
15 #include "core/hist1d.hpp"
16 
17 using namespace std;
18 using namespace PlotOptTypes;
19 
20 int main(){
21  gErrorIgnoreLevel = 6000;
22 
23  double lumi = 0.589;
24 
25  // 74x
26  string trig_skim_mc = "/net/cms27/cms27r0/babymaker/2016_04_29/mc/merged_1lht500met200/";
27  string trig_mc = "/net/cms27/cms27r0/babymaker/2016_04_29/mc/unskimmed/";
28 
29  Palette colors("txt/colors.txt", "default");
30 
31  auto tt1l = Process::MakeShared<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
32  {trig_skim_mc+"*_TTJets*Lept*.root", trig_skim_mc+"*_TTJets_HT*.root"},
33  "ntruleps<=1&&stitch");
34  auto tt2l = Process::MakeShared<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
35  {trig_skim_mc+"*_TTJets*Lept*.root", trig_skim_mc+"*_TTJets_HT*.root"},
36  "ntruleps>=2&&stitch");
37  auto wjets = Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
38  {trig_skim_mc+"*_WJetsToLNu*.root"});
39  auto single_t = Process::MakeShared<Baby_full>("Single t", Process::Type::background, colors("single_t"),
40  {trig_skim_mc+"*_ST_*.root"});
41  auto ttv = Process::MakeShared<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
42  {trig_skim_mc+"*_TTWJets*.root", trig_skim_mc+"*_TTZTo*.root"});
43  auto other = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
44  {trig_skim_mc+"*DYJetsToLL*.root", trig_skim_mc+"*_QCD_HT*.root",
45  trig_skim_mc+"*_ZJet*.root", trig_skim_mc+"*_WWTo*.root",
46  trig_skim_mc+"*ggZH_HToBB*.root", trig_skim_mc+"*ttHJetTobb*.root",
47  trig_skim_mc+"*_TTGJets*.root", trig_skim_mc+"*_TTTT_*.root",
48  trig_skim_mc+"*_WH_HToBB*.root", trig_skim_mc+"*_WZTo*.root",
49  trig_skim_mc+"*_ZH_HToBB*.root", trig_skim_mc+"_ZZ_*.root"});
50 
51  auto t1tttt_nc = Process::MakeShared<Baby_full>("T1tttt(1500,100)", Process::Type::signal, colors("t1tttt"),
52  {trig_mc+"*SMS-T1tttt_mGluino-1500_mLSP-100*.root"});
53  auto t1tttt_c = Process::MakeShared<Baby_full>("T1tttt(1200,800)", Process::Type::signal, colors("t1tttt"),
54  {trig_mc+"*SMS-T1tttt_mGluino-1200_mLSP-800*.root"});
55  t1tttt_c->SetLineStyle(2);
56 
57  auto data_1l = Process::MakeShared<Baby_full>("Data", Process::Type::data, kBlack,
58  {"/net/cms2/cms2r0/babymaker/babies/2016_05_31/data/met/*.root"},"pass&&trig[28]"); // 0.589 fb-1
59  vector<shared_ptr<Process> > full_trig_skim_1l = {data_1l, t1tttt_nc, t1tttt_c, tt1l, tt2l, wjets, single_t, ttv, other};
60 
61  //
62  // 2l / 0l
63  //
64  auto tt1l_unskim = Process::MakeShared<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors("tt_1l"),
65  {trig_mc+"*_TTJets*Lept*.root"},
66  "ntruleps<=1");
67  auto tt2l_unskim = Process::MakeShared<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors("tt_2l"),
68  {trig_mc+"*_TTJets*Lept*.root"},
69  "ntruleps>=2");
70  auto tt_unskim = Process::MakeShared<Baby_full>("t#bar{t}", Process::Type::background, colors("tt_1l"),
71  {trig_mc+"*_TTJets_TuneCUETP8M1_13TeV*.root"});
72  auto dy_unskim = Process::MakeShared<Baby_full>("DY", Process::Type::background, colors("wjets"),
73  {trig_mc+"*DYJetsToLL*HT*.root"});
74  auto qcd_unskim = Process::MakeShared<Baby_full>("QCD", Process::Type::background, colors("qcd"),
75  {trig_mc+"*_QCD_HT700to1000*.root",trig_mc+"*_QCD_HT1000to1500*.root",
76  trig_mc+"*_QCD_HT1500to2000*.root",trig_mc+"*_QCD_HT2000toInf*.root"});
77  auto other_unskim = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("ttv"),
78  {trig_mc+"*_TTWJet*root", trig_mc+"*_TTZTo*.root",
79  trig_mc+"*_ZJet*.root", trig_mc+"*_WWTo*.root",
80  trig_mc+"*ggZH_HToBB*.root", trig_mc+"*ttHJetTobb*.root",
81  trig_mc+"*_TTGJets*.root", trig_mc+"*_TTTT_*.root",
82  trig_mc+"*_WH_HToBB*.root", trig_mc+"*_WZTo*.root",
83  trig_skim_mc+"*_ST_*.root", trig_skim_mc+"*_WJetsToLNu*.root",
84  trig_mc+"*_ZH_HToBB*.root", trig_mc+"_ZZ_*.root"});
85 
86  auto data_2l = Process::MakeShared<Baby_full>("Data", Process::Type::data, kBlack,
87  {"/net/cms2/cms2r0/babymaker/babies/2016_05_31/data/singlelep/combined/*.root"},"pass&&(trig[20]||trig[22])"); // 0.589 fb-1
88  vector<shared_ptr<Process> > full_trig_skim_2l = {data_2l, t1tttt_nc, t1tttt_c, tt1l_unskim, tt2l_unskim, dy_unskim, other_unskim};
89 
90  auto data_0l = Process::MakeShared<Baby_full>("Data", Process::Type::data, kBlack,
91  {"/net/cms2/cms2r0/babymaker/babies/2016_05_31/data/jetht/*.root"},"pass&&trig[12]"); // FIXME: trigger
92  vector<shared_ptr<Process> > full_trig_skim_0l = {data_0l, t1tttt_nc, t1tttt_c, qcd_unskim, tt_unskim, other_unskim};
93 
94  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
95  log_lumi.Title(TitleType::preliminary)
96  .Bottom(BottomType::ratio)
97  .YAxis(YAxisType::log)
98  .Stack(StackType::data_norm);
99  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
100  PlotOpt log_shapes = log_lumi().Stack(StackType::shapes)
101  .Bottom(BottomType::off)
102  .ShowBackgroundError(false);
103  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
104  PlotOpt log_lumi_info = log_lumi().Title(TitleType::info);
105  PlotOpt lin_lumi_info = lin_lumi().Title(TitleType::info);
106  PlotOpt log_shapes_info = log_shapes().Title(TitleType::info);
107  PlotOpt lin_shapes_info = lin_shapes().Title(TitleType::info);
108  vector<PlotOpt> all_plot_types = {log_lumi_info, lin_lumi_info};
109 
110  string commoncut = "mt<140&&ht>500&&met>200";
111  PlotMaker pm;
112 
116 
117  for(int ilep=2; ilep<3; ilep++){
118  NamedFunc lepcut(true);
119  if(ilep==0) lepcut=commoncut+"&&nels==1&&nmus==0";
120  if(ilep==1) lepcut=commoncut+"&&nels==0&&nmus==1";
121  if(ilep==2) lepcut=commoncut+"&&nleps==1";
122 
123  //
124  // event-level variables except ones related to fatjet
125  //
126  pm.Push<Hist1D>(Axis(15, 500, 2000., "ht", "H_{T} [GeV]", {500.}),
127  lepcut&&"njets>=5&&nbm>=1", full_trig_skim_1l, all_plot_types);
128  pm.Push<Hist1D>(Axis(10, 200, 500., "met", "E_{T}^{miss} [GeV]", {200., 350., 500.}),
129  lepcut&&"njets>=5&&nbm>=1", full_trig_skim_1l, all_plot_types);
130  pm.Push<Hist1D>(Axis(16, -0.5, 15.5, "njets", "N_{jets}", {5.5, 8.5}),
131  lepcut&&"nbm>=1", full_trig_skim_1l, all_plot_types);
132 
133  pm.Push<Hist1D>(Axis(16, 0., 280., "mt", "m_{T} [GeV]", {140.}),
134  lepcut&&"njets>=5&&nbm>=1", full_trig_skim_1l, all_plot_types);
135 
136  //
137  // fatjets
138  //
139  pm.Push<Hist1D>(Axis(10, 0, 500., "fjets14_m[0]", "m_{J1} [GeV]"),
140  lepcut&&"njets>=5&&nbm>=1", full_trig_skim_1l, all_plot_types);
141  pm.Push<Hist1D>(Axis(20, 0, 400., "fjets14_m[0]", "m_{J1} [GeV]"),
142  lepcut&&"njets<=5&&nbm>=1", full_trig_skim_1l, all_plot_types);
143 
144  // event-level variables related to fatjet
145  pm.Push<Hist1D>(Axis(10, 0., 1500., "mj14", "M_{J} [GeV]", {400.}),
146  lepcut&&"njets>=5&&nbm>=1", full_trig_skim_1l, all_plot_types);
147 
148  }
149 
153 
154  string mll="(mumu_m*(mumu_m>0&&mumu_pt1>30)+elel_m*(elel_m>0&&elel_pt1>30))";
155  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";
156 
157  pm.Push<Hist1D>(Axis(10, 0., 1000., "mj14", "M_{J} [GeV]", {400.}),
158  "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))",
159  full_trig_skim_2l, all_plot_types);
160 
161  pm.Push<Hist1D>(Axis(10, 0., 1000., "mj14", "M_{J} [GeV]", {400.}),
162  "(nmus>=2||nels>=2)&&ht>350&&njets>=4&&"+mllcut, full_trig_skim_2l, all_plot_types);
163 
167 
168  pm.Push<Hist1D>(Axis(30, 0., 1500., "mj14", "M_{J} [GeV]", {400.}),
169  "nleps==0&&met<50&&ht>1000&&njets>=9", full_trig_skim_0l, all_plot_types);
170 
171  //
172  //
173  //
174  pm.MakePlots(lumi);
175 }
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
int main()
Definition: plot_talk.cxx:20
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
STL namespace.
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
Definition: named_func.hpp:13
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
PlotOpt & ShowBackgroundError(bool show_background_error)
Definition: plot_opt.cpp:386
A full 1D plot with stacked/overlayed histograms.
Definition: hist1d.hpp:23
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