ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
scatter.cxx
Go to the documentation of this file.
1 #include "ra4/scatter.hpp"
2 
3 #include <cstdlib>
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 #include <memory>
8 
9 #include <unistd.h>
10 #include <getopt.h>
11 
12 #include "TError.h"
13 #include "TColor.h"
14 
15 #include "core/baby.hpp"
16 #include "core/process.hpp"
17 #include "core/named_func.hpp"
18 #include "core/plot_maker.hpp"
19 #include "core/plot_opt.hpp"
20 #include "core/palette.hpp"
21 #include "core/hist2d.hpp"
22 #include "core/utilities.hpp"
23 
24 using namespace std;
25 using namespace PlotOptTypes;
26 
27 namespace{
28  bool single_thread = false;
29 }
30 
31 int main(int argc, char *argv[]){
32  gErrorIgnoreLevel = 6000;
33  GetOptions(argc, argv);
34 
35  double lumi = 12.9;
36 
37  string base_path = "";
38  string hostname = execute("echo $HOSTNAME");
39  if(Contains(hostname, "cms") || Contains(hostname,"compute-")){
40  base_path = "/net/cms2";
41  }
42  string mc_dir = base_path+"/cms2r0/babymaker/babies/2016_08_10/mc/merged_mcbase_stdnj5/";
43 
44  Palette colors("txt/colors.txt", "default");
45 
46  auto tt1l = Process::MakeShared<Baby_full>("t#bar{t} (1l)", Process::Type::background, colors.RGB(1,57,166),
47  {mc_dir+"*_TTJets*Lept*.root", mc_dir+"*_TTJets_HT*.root"},
48  "ntruleps<=1&&stitch");
49  tt1l->SetMarkerStyle(23);
50  tt1l->SetMarkerSize(0.8);
51  auto tt2l = Process::MakeShared<Baby_full>("t#bar{t} (2l)", Process::Type::background, colors.RGB(86,160,211),
52  {mc_dir+"*_TTJets*Lept*.root", mc_dir+"*_TTJets_HT*.root"},
53  "ntruleps>=2&&stitch");
54  tt2l->SetMarkerStyle(22);
55  tt2l->SetMarkerSize(0.8);
56  auto wjets = Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
57  {mc_dir+"*_WJetsToLNu*.root"});
58  auto single_t = Process::MakeShared<Baby_full>("Single t", Process::Type::background, colors("single_t"),
59  {mc_dir+"*_ST_*.root"});
60  auto ttv = Process::MakeShared<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
61  {mc_dir+"*_TTWJets*.root", mc_dir+"*_TTZTo*.root"});
62  auto other = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
63  {mc_dir+"*DYJetsToLL*.root", mc_dir+"*_QCD_HT*.root",
64  mc_dir+"*_ZJet*.root", mc_dir+"*_WWTo*.root",
65  mc_dir+"*ggZH_HToBB*.root", mc_dir+"*ttHJetTobb*.root",
66  mc_dir+"*_TTGJets*.root", mc_dir+"*_TTTT_*.root",
67  mc_dir+"*_WH_HToBB*.root", mc_dir+"*_WZTo*.root",
68  mc_dir+"*_ZH_HToBB*.root", mc_dir+"*_ZZ_*.root"});
69 
70  auto t1tttt = Process::MakeShared<Baby_full>("T1tttt(1500,100)", Process::Type::signal, colors("t1tttt"),
71  {mc_dir+"*SMS-T1tttt_mGluino-1500_mLSP-100*.root"});
72  t1tttt->SetMarkerStyle(21);
73  t1tttt->SetMarkerSize(0.9);
74 
75  auto data = Process::MakeShared<Baby_full>("Data", Process::Type::data, kBlack,
76  {base_path+"/cms2r0/babymaker/babies/2016_08_10/data/merged_database_stdnj5/*.root"},"pass&&trig_ra4&&json12p9");
77  data->SetMarkerStyle(20);
78  data->SetMarkerSize(1.);
79 
80  vector<shared_ptr<Process> > all_procs = {data, t1tttt, tt1l, tt2l, wjets, single_t, ttv, other};
81  vector<shared_ptr<Process> > tt_sig = {tt1l, tt2l, t1tttt};
82 
83  PlotOpt style("txt/plot_styles.txt", "Scatter");
84  vector<PlotOpt> bkg_hist = {style().Stack(StackType::data_norm).Title(TitleType::preliminary)};
85  vector<PlotOpt> bkg_pts = {style().Stack(StackType::lumi_shapes).Title(TitleType::info)};
86 
87  NamedFunc baseline = "nleps==1&&st>500&&met>150&&njets>=6&&nbm>=1";
88  NamedFunc weight = "weight";
89  vector<NamedFunc> met_bins = {"met>200", "met>150&&met<=200", "met>200&&met<=350", "met>350&&met<500", "met>500"};
90  vector<NamedFunc> nbm_bins = {"nbm>=1", "nbm==1", "nbm>=2"};
91 
92  PlotMaker pm;
93  for(const auto &met_bin: met_bins){
94  for(const auto &nbm_bin: nbm_bins){
95  NamedFunc cut = baseline && met_bin && nbm_bin;
96  pm.Push<Hist2D>(Axis(48, 0., 1200., "mj14", "M_{J} [GeV]", {250., 400.}),
97  Axis(25, 0., 700., "mt", "m_{T} [GeV]", {140.}),
98  cut, all_procs, bkg_hist);
99  pm.Push<Hist2D>(Axis(48, 0., 1200., "mj14", "M_{J} [GeV]", {250., 400.}),
100  Axis(25, 0., 700., "mt", "m_{T} [GeV]", {140.}),
101  cut, tt_sig, bkg_pts);
102  }
103  }
104 
105  if(single_thread) pm.multithreaded_ = false;
106  pm.MakePlots(lumi);
107 }
108 
109 void GetOptions(int argc, char *argv[]){
110  while(true){
111  static struct option long_options[] = {
112  {"single_thread", no_argument, 0, 's'},
113  {0, 0, 0, 0}
114  };
115 
116  char opt = -1;
117  int option_index;
118  opt = getopt_long(argc, argv, "s", long_options, &option_index);
119 
120  if( opt == -1) break;
121 
122  string optname;
123  switch(opt){
124  case 's':
125  single_thread = true;
126  break;
127  case 0:
128  optname = long_options[option_index].name;
129  if(false){
130  }else{
131  printf("Bad option! Found option name %s\n", optname.c_str());
132  }
133  break;
134  default:
135  printf("Bad option! getopt_long returned character code 0%o\n", opt);
136  break;
137  }
138  }
139 }
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
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
bool multithreaded_
Definition: plot_maker.hpp:43
int main(int argc, char *argv[])
Definition: scatter.cxx:31
std::string execute(const std::string &cmd)
Definition: utilities.cpp:65
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
Definition: axis.hpp:12
static Int_t RGB(Int_t r, Int_t g, Int_t b)
Gets the ROOT color number corresponding to a given RGB color.
Definition: palette.cpp:149
Organizes efficient production of plots with single loop over each process.
Definition: plot_maker.hpp:14
void GetOptions(int argc, char *argv[])
Definition: scatter.cxx:109
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