ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
qcd_check.cxx
Go to the documentation of this file.
1 #include "core/test.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/table.hpp"
22 #include "core/hist1d.hpp"
23 #include "core/event_scan.hpp"
24 #include "core/utilities.hpp"
25 
26 using namespace std;
27 using namespace PlotOptTypes;
28 
29 namespace{
30  bool single_thread = false;
31 }
32 
33 int main(int argc, char *argv[]){
34  string bfolder("");
35  string hostname = execute("echo $HOSTNAME");
36  if(Contains(hostname, "cms") || Contains(hostname, "compute-"))
37  bfolder = "/net/cms2"; // In laptops, you can't create a /net folder
38  gErrorIgnoreLevel = 6000;
39  GetOptions(argc, argv);
40 
41  double lumi = 20;
42 
43  string trig_skim_mc = "/cms2r0/babymaker/babies/2016_08_10/mc/merged_higmc_higloose/";
44  string trig_skim_signal = "/cms2r0/babymaker/babies/2016_08_10/TChiHH/merged_higmc_higloose/";
45 
46  Palette colors("txt/colors.txt", "default");
47  auto qcd = Process::MakeShared<Baby_full>("Inclusive QCD", Process::Type::signal, colors("qcd"),
48  {trig_skim_mc+"*_QCD_HT*00_Tune*.root", trig_skim_mc+"*_QCD_HT*Inf_Tune*.root"});
49  auto Bqcd = Process::MakeShared<Baby_full>("B-enriched QCD", Process::Type::signal, kAzure,
50  {trig_skim_mc+"*_QCD_bEnriched*.root", trig_skim_mc+"*_QCD_HT*BGenFilter*.root"});
51 
52  vector<shared_ptr<Process> > full_trig_skim = {qcd, Bqcd};
53 
54  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
55  log_lumi.Title(TitleType::preliminary)
56  .Bottom(BottomType::off)
57  .YAxis(YAxisType::log)
58  .Stack(StackType::data_norm);
59  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
60  PlotOpt log_shapes = log_lumi().Stack(StackType::shapes)
61  .ShowBackgroundError(false);
62  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
63  PlotOpt log_lumi_info = log_lumi().Title(TitleType::info);
64  PlotOpt lin_lumi_info = lin_lumi().Title(TitleType::info);
65  PlotOpt log_shapes_info = log_shapes().Title(TitleType::info);
66  PlotOpt lin_shapes_info = lin_shapes().Title(TitleType::info);
67  vector<PlotOpt> all_plot_types = {log_lumi_info, log_shapes_info};
68 
69  PlotMaker pm;
70 
71  vector<TString> nbcuts;
72  nbcuts.push_back(" nbt >= 2 && nbl <= 3");
73  nbcuts.push_back(" nbt >= 2 && nbl >= 4");
74  TString metskim("nbm>=2&&njets>=4&&njets<=5&&met>100&&nvleps==0");
75  TString trkskim("njets>=4&&njets<=5&&met>250&&nvleps==0");
76  TString skim("njets>=4&&njets<=5&&met>250&&nvleps==0&&ntks==0");
77  TString A("&&");
78  TString DeltaR("hig_drmax < 2.2");
79  TString AverageM("hig_am > 100 && hig_am < 140");
80  TString DeltaM("hig_dm < 40");
81  TString LDP("!low_dphi");
82 
83  pm.Push<Hist1D>(Axis(56,0,2800,"ht_isr_me", "H_{T}^{ISR} [GeV]"),
84  metskim, full_trig_skim, all_plot_types);
85 
86  pm.Push<Table>("QCD_cutflow", vector<TableRow>{
87  TableRow("$\\text{No b cut}$", "1"),
88  TableRow("$\\text{1M b-tags}$", "nbm>=1"),
89  TableRow("$\\text{2M b-tags}$", "nbm>=2"),
90  TableRow("$\\text{3M b-tags}$", "nbm>=3"),
91  TableRow("$\\text{4M b-tags}$", "nbm>=4"),
92  TableRow("$\\text{5M b-tags}$", "nbm>=5"),
93  TableRow("$\\text{1T b-tags}$", "nbt>=1"),
94  TableRow("$\\text{2T b-tags}$", "nbt>=2"),
95  TableRow("$\\text{3T b-tags}$", "nbt>=3"),
96  TableRow("$\\text{4T b-tags}$", "nbt>=4"),
97  },full_trig_skim, 0);
98 
99  if(single_thread) pm.multithreaded_ = false;
100  pm.min_print_ = true;
101  pm.MakePlots(lumi);
102 }
103 
104 void GetOptions(int argc, char *argv[]){
105  while(true){
106  static struct option long_options[] = {
107  {"single_thread", no_argument, 0, 's'},
108  {0, 0, 0, 0}
109  };
110 
111  char opt = -1;
112  int option_index;
113  opt = getopt_long(argc, argv, "s", long_options, &option_index);
114 
115  if( opt == -1) break;
116 
117  string optname;
118  switch(opt){
119  case 's':
120  single_thread = true;
121  break;
122  case 0:
123  optname = long_options[option_index].name;
124  if(false){
125  }else{
126  printf("Bad option! Found option name %s\n", optname.c_str());
127  }
128  break;
129  default:
130  printf("Bad option! getopt_long returned character code 0%o\n", opt);
131  break;
132  }
133  }
134 }
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
void GetOptions(int argc, char *argv[])
Definition: qcd_check.cxx:104
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
bool min_print_
Definition: plot_maker.hpp:44
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
Definition: table.hpp:15
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
int main(int argc, char *argv[])
Definition: qcd_check.cxx:33
Loads colors from a text configuration file.
Definition: palette.hpp:8