ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
met_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 tchi127 = Process::MakeShared<Baby_full>("m_{#chi} = 127", Process::Type::signal, kAzure,
48  {trig_skim_signal+"*TChiHH_mGluino-127*.root"});
49  auto tchi300 = Process::MakeShared<Baby_full>("m_{#chi} = 300", Process::Type::signal, kGreen+2,
50  {trig_skim_signal+"*TChiHH_mGluino-300*.root"});
51  auto tchi400 = Process::MakeShared<Baby_full>("m_{#chi} = 400", Process::Type::signal, kRed,
52  {trig_skim_signal+"*TChiHH_mGluino-400*.root"});
53  auto tchi500 = Process::MakeShared<Baby_full>("m_{#chi} = 500", Process::Type::signal, kViolet-6,
54  {trig_skim_signal+"*TChiHH_mGluino-500*.root"});
55  auto tchi600 = Process::MakeShared<Baby_full>("m_{#chi} = 600", Process::Type::signal, kYellow,
56  {trig_skim_signal+"*TChiHH_mGluino-600*.root"});
57  auto tchi700 = Process::MakeShared<Baby_full>("m_{#chi} = 700", Process::Type::signal, kMagenta+1,
58  {trig_skim_signal+"*TChiHH_mGluino-700*.root"});
59  auto tchi850 = Process::MakeShared<Baby_full>("m_{#chi} = 850", Process::Type::signal, kCyan+1,
60  {trig_skim_signal+"*TChiHH_mGluino-850*.root"});
61  auto tchi1000 = Process::MakeShared<Baby_full>("m_{#chi} = 1000", Process::Type::signal, kOrange-3,
62  {trig_skim_signal+"*TChiHH_mGluino-1000*.root"});
63 
64  vector<shared_ptr<Process> > full_trig_skim = {tchi127, tchi300, tchi400, tchi500, tchi600, tchi700, tchi850, tchi1000};
65 
66  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
67  log_lumi.Title(TitleType::preliminary)
68  .Bottom(BottomType::off)
69  .YAxis(YAxisType::log)
70  .Stack(StackType::data_norm);
71  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
72  PlotOpt log_shapes = log_lumi().Stack(StackType::shapes)
73  .ShowBackgroundError(false);
74  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
75  PlotOpt log_lumi_info = log_lumi().Title(TitleType::info);
76  PlotOpt lin_lumi_info = lin_lumi().Title(TitleType::info);
77  PlotOpt log_shapes_info = log_shapes().Title(TitleType::info);
78  PlotOpt lin_shapes_info = lin_shapes().Title(TitleType::info);
79  vector<PlotOpt> all_plot_types = {log_lumi_info, log_shapes_info};
80 
81  PlotMaker pm;
82 
83  vector<TString> nbcuts;
84  nbcuts.push_back(" nbt >= 2 && nbl <= 3");
85  nbcuts.push_back(" nbt >= 2 && nbl >= 4");
86  TString metskim("njets>=4&&njets<=5&&met>100&&nvleps==0");
87  TString trkskim("njets>=4&&njets<=5&&met>250&&nvleps==0");
88  TString skim("njets>=4&&njets<=5&&met>250&&nvleps==0&&ntks==0");
89  TString A("&&");
90  TString DeltaR("hig_drmax < 2.2");
91  TString AverageM("hig_am > 100 && hig_am < 140");
92  TString DeltaM("hig_dm < 40");
93  TString LDP("!low_dphi");
94 
95  pm.Push<Hist1D>(Axis(40,100,1700,"met", "E_{T}^{miss} [GeV]", {150., 250.}),
96  metskim, full_trig_skim, all_plot_types);
97 
98  pm.Push<Table>("TChiMass_cutflow", vector<TableRow>{
99  TableRow("$MET > 100$, $\\text{2M b-tags}$, $\\text{4 or 5 jets}$, $0\\ell$", "1"),
100  TableRow("$\\Delta\\phi_{\\text{min}}$", LDP),
101  TableRow("$\\Delta m < 40$", DeltaM+A+LDP,1,0),
102  TableRow("$\\left< m \\right> \\in (100,140)$", AverageM+A+LDP),
103  TableRow("$\\Delta R_{\\text{max}} < 2.2$", DeltaR+A+LDP)
104  },full_trig_skim, 0);
105 
106  if(single_thread) pm.multithreaded_ = false;
107  pm.min_print_ = true;
108  pm.MakePlots(lumi);
109 }
110 
111 void GetOptions(int argc, char *argv[]){
112  while(true){
113  static struct option long_options[] = {
114  {"single_thread", no_argument, 0, 's'},
115  {0, 0, 0, 0}
116  };
117 
118  char opt = -1;
119  int option_index;
120  opt = getopt_long(argc, argv, "s", long_options, &option_index);
121 
122  if( opt == -1) break;
123 
124  string optname;
125  switch(opt){
126  case 's':
127  single_thread = true;
128  break;
129  case 0:
130  optname = long_options[option_index].name;
131  if(false){
132  }else{
133  printf("Bad option! Found option name %s\n", optname.c_str());
134  }
135  break;
136  default:
137  printf("Bad option! getopt_long returned character code 0%o\n", opt);
138  break;
139  }
140  }
141 }
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
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
void GetOptions(int argc, char *argv[])
Definition: met_check.cxx:111
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
int main(int argc, char *argv[])
Definition: met_check.cxx:33
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