ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_dilep_mj.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <vector>
4 #include <memory>
5 
6 #include <unistd.h>
7 #include <getopt.h>
8 
9 #include "TError.h"
10 #include "TColor.h"
11 
12 #include "core/baby.hpp"
13 #include "core/process.hpp"
14 #include "core/named_func.hpp"
15 #include "core/plot_maker.hpp"
16 #include "core/plot_opt.hpp"
17 #include "core/palette.hpp"
18 #include "core/table.hpp"
19 #include "core/hist1d.hpp"
20 #include "core/utilities.hpp"
21 
22 using namespace std;
23 using namespace PlotOptTypes;
24 
25 namespace{
26  bool single_thread = true;
27  TString method = "";
28 }
29 
30 void GetOptions(int argc, char *argv[]);
31 
32 int main(int argc, char *argv[]){
33  gErrorIgnoreLevel = 6000;
34  GetOptions(argc, argv);
35 
36  double lumi = 2.6;
37 
38  bool do_rc = true;
39  string rcfolder = "";
40  if(do_rc) rcfolder = "reclustered/";
41 
42  string bfolder("");
43  string hostname = execute("echo $HOSTNAME");
44  if(Contains(hostname, "cms") || Contains(hostname, "compute-"))
45  bfolder = "/net/cms2"; // In laptops, you can't create a /net folder
46  string lowmet_fndata(bfolder+"/cms2r0/babymaker/babies/"+rcfolder+"2016_06_26/data/merged_met150/");
47  string himet_fndata(bfolder+"/cms2r0/babymaker/babies/"+rcfolder+"2016_06_26/data/merged_standard/");
48  string himet_fodata(bfolder+"/cms2r0/babymaker/babies/"+rcfolder+"2016_04_29/data/merged_1lht500met200/");
49  string himet_fmc_74x(bfolder+"/cms2r0/babymaker/babies/"+rcfolder+"2016_04_29/mc/merged_1lht500met200/");
50  string lowmet_fmc(bfolder+"/cms2r0/babymaker/babies/"+rcfolder+"2016_06_14/mc/merged_met150/");
51  string himet_fmc(bfolder+"/cms2r0/babymaker/babies/"+rcfolder+"2016_06_14/mc/merged_standard/");
52 
53  string baseline("nleps>=1 && ht>500 && met>150 && met<500 && pass && njets>=3");
54 
55  Palette colors("txt/colors.txt", "default");
56 
57  auto ndata = Process::MakeShared<Baby_full>("Data (2016, 2.6 fb^{-1})", Process::Type::data, kBlack,
58  {lowmet_fndata+"/*.root", himet_fndata+"/*.root"},
59  baseline+"&&json2p6 && (trig[4]||trig[8]||trig[13]||trig[33])");
60  auto odata = Process::MakeShared<Baby_full>("Data (2015, 2.3 fb^{-1})", Process::Type::data, kRed+1, {himet_fodata+"/*.root"},
61  baseline+" && (trig[4]||trig[8]||trig[28]||trig[14])");
62 
63 
64  auto tt1l = Process::MakeShared<Baby_full>("tt 1lep", Process::Type::background, colors("tt_1l"),
65  {lowmet_fmc+"*_TTJets*Lept*.root", lowmet_fmc+"*_TTJets_HT*.root",
66  himet_fmc+"*_TTJets*Lept*.root", himet_fmc+"*_TTJets_HT*.root"},
67  baseline+" && stitch && ntruleps==1");
68  auto tt2l = Process::MakeShared<Baby_full>("tt 2lep", Process::Type::background, colors("tt_2l"),
69  {lowmet_fmc+"*_TTJets*Lept*.root", lowmet_fmc+"*_TTJets_HT*.root",
70  himet_fmc+"*_TTJets*Lept*.root", himet_fmc+"*_TTJets_HT*.root"},
71  baseline+" && stitch && ntruleps==2");
72  auto other = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
73  {lowmet_fmc+"*_WJetsToLNu*.root",lowmet_fmc+"*_ST_*.root",
74  lowmet_fmc+"*_TTW*.root",lowmet_fmc+"*_TTZ*.root",
75  lowmet_fmc+"*DYJetsToLL*.root",lowmet_fmc+"*QCD_HT*.root",
76  lowmet_fmc+"*_ZJet*.root",lowmet_fmc+"*_ttHJetTobb*.root",
77  lowmet_fmc+"*_TTGJets*.root",lowmet_fmc+"*_TTTT*.root",
78  lowmet_fmc+"*_WH_HToBB*.root",lowmet_fmc+"*_ZH_HToBB*.root",
79  lowmet_fmc+"*_WWTo*.root",lowmet_fmc+"*_WZ*.root",lowmet_fmc+"*_ZZ_*.root",
80  himet_fmc+"*_WJetsToLNu*.root",himet_fmc+"*_ST_*.root",
81  himet_fmc+"*_TTW*.root",himet_fmc+"*_TTZ*.root",
82  himet_fmc+"*DYJetsToLL*.root",himet_fmc+"*QCD_HT*.root",
83  himet_fmc+"*_ZJet*.root",himet_fmc+"*_ttHJetTobb*.root",
84  himet_fmc+"*_TTGJets*.root",himet_fmc+"*_TTTT*.root",
85  himet_fmc+"*_WH_HToBB*.root",himet_fmc+"*_ZH_HToBB*.root",
86  himet_fmc+"*_WWTo*.root",himet_fmc+"*_WZ*.root",himet_fmc+"*_ZZ_*.root"},
87  baseline+" && stitch");
88 
89  auto tt1l_74x = Process::MakeShared<Baby_full>("tt 1lep", Process::Type::background, colors("tt_1l"),
90  {himet_fmc_74x+"*_TTJets*Lept*.root", himet_fmc_74x+"*_TTJets_HT*.root"},
91  baseline+" && stitch && ntruleps==1");
92  auto tt2l_74x = Process::MakeShared<Baby_full>("tt 2lep", Process::Type::background, colors("tt_2l"),
93  {himet_fmc_74x+"*_TTJets*Lept*.root", himet_fmc_74x+"*_TTJets_HT*.root"},
94  baseline+" && stitch && ntruleps==2");
95  auto other_74x = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
96  {himet_fmc_74x+"*_WJetsToLNu*.root",himet_fmc_74x+"*_ST_*.root",
97  himet_fmc_74x+"*_TTW*.root",himet_fmc_74x+"*_TTZ*.root",
98  himet_fmc_74x+"*DYJetsToLL*.root",himet_fmc_74x+"*QCD_HT*.root",
99  himet_fmc_74x+"*_ZJet*.root",himet_fmc_74x+"*_ttHJetTobb*.root",
100  himet_fmc_74x+"*_TTGJets*.root",himet_fmc_74x+"*_TTTT*.root",
101  himet_fmc_74x+"*_WH_HToBB*.root",himet_fmc_74x+"*_ZH_HToBB*.root",
102  himet_fmc_74x+"*_WWTo*.root",himet_fmc_74x+"*_WZ*.root",himet_fmc_74x+"*_ZZ_*.root"},
103  baseline+" && stitch");
104 
105  vector<shared_ptr<Process> > procs_2015 = {odata, tt1l_74x, tt2l_74x, other_74x};
106  vector<shared_ptr<Process> > lowmet_procs = {ndata, tt1l, tt2l, other};
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_lumi_info = log_lumi().Title(TitleType::info);
115  PlotOpt lin_lumi_info = lin_lumi().Title(TitleType::info);
116 
117  vector<PlotOpt> plot_types = {lin_lumi_info};
118 
119  PlotMaker pm, pm_2015;
120 
121  float minx(0), maxx(460);
122  int nbins(static_cast<int>((maxx-minx)/10));
123  minx = 25; maxx = 1000; nbins = static_cast<int>((maxx-minx)/75);
124 
125  string mjname = "M_{J}^{with lep}";
126  if(do_rc) mjname = "M_{J}^{no lep}";
127 
129  Axis mj_axis(nbins, minx, maxx, "mj14", mjname+" [GeV]", {250., 400.});
130  pm_2015.Push<Hist1D>(mj_axis, "met>200&&met<500 && mt<=140 && nleps==1 && nbm>=1 && njets>=3",
131  procs_2015, plot_types);
132  if(!do_rc){
133  pm_2015.Push<Hist1D>(mj_axis, "met>200&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets>=5",
134  procs_2015, plot_types);
135  pm_2015.Push<Hist1D>(mj_axis, "met>200&&met<500 && mt<=140 && nleps==1 && nbm>=1 && njets>=6",
136  procs_2015, plot_types);
137  }
138  pm.Push<Hist1D>(mj_axis, "met>150&&met<500 && mt<=140 && nleps==1 && nbm>=1 && njets>=3",
139  lowmet_procs, plot_types);
140  if(!do_rc){
141  pm.Push<Hist1D>(mj_axis, "met>150&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets>=5",
142  lowmet_procs, plot_types);
143  pm.Push<Hist1D>(mj_axis, "met>150&&met<500 && mt<=140 && nleps==1 && nbm>=1 && njets>=6",
144  lowmet_procs, plot_types);
145  }
146 
148  pm_2015.Push<Hist1D>(mj_axis, "met>200&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets>=3",
149  procs_2015, plot_types);
150  if(!do_rc){
151  pm_2015.Push<Hist1D>(mj_axis, "met>200&&met<500 && mt<=140 && nleps==1 && nbm>=1 && njets>=5",
152  procs_2015, plot_types);
153  pm_2015.Push<Hist1D>(mj_axis, "met>200&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets>=6",
154  procs_2015, plot_types);
155  }
156 
157  pm.Push<Hist1D>(mj_axis, "met>150&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets>=3",
158  lowmet_procs, plot_types);
159  if(!do_rc){
160  pm.Push<Hist1D>(mj_axis, "met>200&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets==3",
161  lowmet_procs, plot_types);
162  pm.Push<Hist1D>(mj_axis, "met>200&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets==4",
163  lowmet_procs, plot_types);
164  pm.Push<Hist1D>(mj_axis, "met>150&&met<500 && mt<=140 && nleps==1 && nbm>=1 && njets>=5",
165  lowmet_procs, plot_types);
166  pm.Push<Hist1D>(mj_axis, "met>150&&met<500 && nels==1 && nmus==1 && nbm<=2 && njets>=6",
167  lowmet_procs, plot_types);
168  }
169 
170  if(single_thread) pm.multithreaded_ = false;
171  pm.MakePlots(lumi);
172  if(single_thread) pm_2015.multithreaded_ = false;
173  pm_2015.MakePlots(2.3);
174 
175 }
176 
177 void GetOptions(int argc, char *argv[]){
178  while(true){
179  static struct option long_options[] = {
180  {"single_thread", no_argument, 0, 's'},
181  {0, 0, 0, 0}
182  };
183 
184  char opt = -1;
185  int option_index;
186  opt = getopt_long(argc, argv, "s", long_options, &option_index);
187 
188  if( opt == -1) break;
189 
190  string optname;
191  switch(opt){
192  case 's':
193  single_thread = true;
194  break;
195  case 0:
196  optname = long_options[option_index].name;
197  if(false){
198  }else{
199  printf("Bad option! Found option name %s\n", optname.c_str());
200  }
201  break;
202  default:
203  printf("Bad option! getopt_long returned character code 0%o\n", opt);
204  break;
205  }
206  }
207 }
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.
bool Contains(const std::string &str, const std::string &pat)
Definition: utilities.cpp:44
bool multithreaded_
Definition: plot_maker.hpp:43
std::string execute(const std::string &cmd)
Definition: utilities.cpp:65
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
A full 1D plot with stacked/overlayed histograms.
Definition: hist1d.hpp:23
int main(int argc, char *argv[])
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
void GetOptions(int argc, char *argv[])
Loads colors from a text configuration file.
Definition: palette.hpp:8