ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_2016-09-09_pie.cxx
Go to the documentation of this file.
1 
3 #include <fstream>
4 #include <iostream>
5 #include <vector>
6 #include <ctime>
7 
8 #include "TError.h" // Controls error level reporting
9 
10 #include "core/utilities.hpp"
11 #include "core/baby.hpp"
12 #include "core/process.hpp"
13 #include "core/named_func.hpp"
14 #include "core/plot_maker.hpp"
15 #include "core/palette.hpp"
16 #include "core/table.hpp"
17 #include "core/plot_opt.hpp"
18 
19 namespace{
20  //bool do_met150 = true;
21 }
22 
23 using namespace std;
24 
25 int main(){
26  gErrorIgnoreLevel=6000; // Turns off ROOT errors due to missing branches
27 
28  time_t begtime, endtime;
29  time(&begtime);
30 
33  string bfolder("");
34  string hostname = execute("echo $HOSTNAME");
35  if(Contains(hostname, "cms") || Contains(hostname, "compute-"))
36  bfolder = "/net/cms2"; // In laptops, you can't create a /net folder
37 
38  string foldermc(bfolder+"/cms2r0/babymaker/babies/2016_08_10/mc/merged_mcbase_stdnj5/");
39  //if(do_met150) foldermc = (bfolder+"/cms2r0/babymaker/babies/2016_06_14/mc/merged_met150/");
40  Palette colors("txt/colors.txt", "default");
41 
42  // Cuts in baseline speed up the yield finding
43  string base1l = "mj14>250 && nleps==1 && nveto==0 && st>500 && met>200 && pass && weight<1 && njets>=6 && nbm>=1"; // Excluding one QCD event
44  string base2l = "mj14>250 && ((nleps==1 && nveto==1 && njets>=6 && nbm>=1 && mt>140) || (nleps==2 && njets>=5 && nbm<=2)) && st>500 && met>200 && met<500 && pass && weight<1"; // Excluding one QCD event
45 
46  string ntupletag = "*metG200*.root";
47  auto proc_tt1l = Process::MakeShared<Baby_full>("t#bar{t} (l)", Process::Type::background, colors("tt_1l"),
48  {foldermc+"*_TTJets*SingleLept"+ntupletag, foldermc+"*_TTJets_HT"+ntupletag},
49  "stitch && ntruleps==1");
50  auto proc_tt2l = Process::MakeShared<Baby_full>("t#bar{t} (ll)", Process::Type::background, colors("tt_2l"),
51  {foldermc+"*_TTJets*DiLept"+ntupletag, foldermc+"*_TTJets_HT"+ntupletag},
52  "stitch && ntruleps==2 ");
53  auto proc_wjets = Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
54  {foldermc+"*_WJetsToLNu"+ntupletag}, "stitch");
55  auto proc_single_t = Process::MakeShared<Baby_full>("Single t", Process::Type::background, colors("single_t"),
56  {foldermc+"*_ST_"+ntupletag}, "1");
57  auto proc_ttv = Process::MakeShared<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
58  {foldermc+"*_TTWJets"+ntupletag, foldermc+"*_TTZ"+ntupletag}, "1");
59  auto proc_other = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
60  {foldermc+"*DYJetsToLL"+ntupletag,foldermc+"*QCD_HT*0_Tune"+ntupletag,foldermc+"*QCD_HT*Inf_Tune"+ntupletag,
61  foldermc+"*_ZJet"+ntupletag,foldermc+"*_ttHJetTobb"+ntupletag,
62  foldermc+"*_TTGJets"+ntupletag,foldermc+"*_TTTT"+ntupletag,
63  foldermc+"*_WH_HToBB"+ntupletag,foldermc+"*_ZH_HToBB"+ntupletag,
64  foldermc+"*_WWTo"+ntupletag,foldermc+"*_WZ"+ntupletag,foldermc+"*_ZZ_"+ntupletag},
65  "stitch");
66 
67  vector<shared_ptr<Process> > all_procs = {proc_tt1l, proc_tt2l, proc_wjets, proc_single_t, proc_ttv, proc_other};
68 
69  vector<TString> cuts;
70  cuts.push_back(base1l + "&& mt<=140 && mj14<=400");
71  cuts.push_back(base1l + "&& mt<=140 && mj14>400");
72  cuts.push_back(base1l + "&& mt>140 && mj14<=400");
73  cuts.push_back(base1l + "&& mt>140 && mj14>400");
74  cuts.push_back(base2l + "&& mj14<=400");
75  cuts.push_back(base2l + "&& mj14>400");
76 
77  vector<TableRow> table_cuts;
78  for(size_t icut=0; icut<cuts.size(); icut++){
79  table_cuts.push_back(TableRow(cuts2tex(cuts[icut]).Data(), cuts[icut].Data()));
80  }
81 
82  PlotMaker pm;
83  pm.Push<Table>("chart", table_cuts, all_procs, true, true, true);
84  pm.min_print_ = true;
85  pm.MakePlots(40.);
86 
87  time(&endtime);
88  cout<<endl<<"Making "<<table_cuts.size()<<" piecharts took "<<difftime(endtime, begtime)<<" seconds"<<endl<<endl;
89 }
STL namespace.
bool Contains(const std::string &str, const std::string &pat)
Definition: utilities.cpp:44
std::string execute(const std::string &cmd)
Definition: utilities.cpp:65
int main()
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
bool min_print_
Definition: plot_maker.hpp:44
Organizes efficient production of plots with single loop over each process.
Definition: plot_maker.hpp:14
Definition: table.hpp:15
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
Definition: plot_maker.cpp:54
Loads colors from a text configuration file.
Definition: palette.hpp:8