ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
plot_ttbar.cxx
Go to the documentation of this file.
1 // plot_note: Macro that plots variables both lumi weighted and normalized to the same area.
2 
3 #include <iostream>
4 #include <vector>
5 #include "TChain.h"
6 #include "TH1D.h"
7 #include "TCanvas.h"
8 #include "TLegend.h"
9 #include "TLine.h"
10 #include "TString.h"
11 #include "TColor.h"
12 
13 #include "styles.hpp"
14 #include "utilities.hpp"
15 #include "utilities_macros.hpp"
16 #include "utilities_macros_rpv.hpp"
17 
18 namespace {
19  TString plot_type=".pdf";
20  TString plot_style="CMSPaper";
21  int section(11);
22 }
23 
24 using namespace std;
25 using std::cout;
26 using std::endl;
27 
28 int main(){
29  std::string extraWeight("w_lumi/weight");
30  std::string extraWeightTopPt("w_lumi*w_toppt/weight");
31 
32  bool showData=false;
33 
34  TString folder_links="/homes/cawest/links/";
35 
36  vector<TString> s_tt_MLM;
37  s_tt_MLM.push_back(filestring("TTJets_TuneCUETP8M1_13TeV-madgraphMLM", false));
38 
39  vector<TString> s_tt_amcatnlo;
40  s_tt_amcatnlo.push_back(filestring("TTJets_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8", false));
41 
42  vector<TString> s_tt_powheg;
43  s_tt_powheg.push_back(filestring("TT_TuneCUETP8M1_13TeV-powheg-pythia8", false));
44 
45  // Reading ntuples
46  vector<sfeats> Samples;
47  Samples.push_back(sfeats(s_tt_powheg, "t#bar{t}, Powheg", ra4::c_t1tttt, 1, cutandweight("1", extraWeight)));
48  Samples.back().doStack = false;
49  Samples.push_back(sfeats(s_tt_MLM, "t#bar{t}, aMC@NLO (LO, MLM)", ra4::c_t1tttt, 2, cutandweight("1", extraWeight)));
50  Samples.back().doStack = false;
51  // Samples.push_back(sfeats(s_tt_MLM, "t#bar{t}, (LO, p_{T} reweighted)", kBlue, 1, cutandweight("1", extraWeightTopPt)));
52  // Samples.back().doStack = false;
53  Samples.push_back(sfeats(s_tt_amcatnlo, "t#bar{t}, aMC@NLO (NLO, FxFx)", kBlack, 1, cutandweight("1", extraWeight)));
54  Samples.back().doStack = false;
55 
56 
57  // Adding non-skimmed samples
58  vector<int> ra4_sam, ra4_sam_ns;
59  unsigned nsam(Samples.size());
60  for(unsigned sam(0); sam < nsam; sam++){
61  ra4_sam.push_back(sam);
62  } // Loop over samples
63 
64  vector<hfeats> vars;
65 
66  TString cuts("(nmus+nels)==1");
67  switch(section){
68  case 11:
69 
70  if(!showData) {
71 
72  std::vector<TString> cutlist = {"(nmus+nels)==0",
73  "(nmus+nels)==1",
74  "(nmus+nels)==0&&nbm>=1&&mj>500&&njets>=6&&ht>1500",
75  "(nmus+nels)==1&&nbm>=1&&mj>500&&njets>=6&&ht>1200"};
76  for(auto icut : cutlist) {
77  vars.push_back(hfeats("ht",40, 0, 4000, ra4_sam, "H_{T} (GeV)", icut));
78  vars.push_back(hfeats("mj",25, 0, 2500, ra4_sam, "M_{J} (GeV)", icut));
79  vars.push_back(hfeats("nbm",6, 0, 6, ra4_sam, "N_{b}", icut));
80  vars.push_back(hfeats("njets",20, 0, 20, ra4_sam, "N_{jets}", icut));
81  }
82 
83 
84  }
85  else {
86  cuts = "(nmus+nels)==1&&ht>1000&&ht<1500&&nbm>=1";
87  vars.push_back(hfeats("njets",15, 0, 15, ra4_sam, "N_{jets}", cuts));
88  vars.back().normalize = true;
89  cuts = "(nmus+nels)==1&&ht>1000&&ht<1500&&nbt>=1&&njets==5";
90  vars.push_back(hfeats("nbt",6, 0, 6, ra4_sam, "N_{b,tight}", cuts));
91  vars.back().normalize = true;
92  cuts = "(nmus+nels)==1&&ht>1000&&ht<1500&&nbm>=1&&njets==5";
93  vars.push_back(hfeats("nbm",6, 0, 6, ra4_sam, "N_{b}", cuts));
94  vars.back().normalize = true;
95  vars.push_back(hfeats("mj",12, 0, 600, ra4_sam, "M_{J} (GeV)", cuts));
96  vars.back().normalize = true;
97  vars.push_back(hfeats("Max$(jets_pt)",20, 0, 1000, ra4_sam, "p_{T1} (GeV)", cuts));
98  vars.back().normalize = true;
99  vars.push_back(hfeats("(jets_csv-0.89)/0.11", 10, 0, 1, ra4_sam, "(CSV-CSV_{cut})/(CSV_{max}-CSV_{cut})", cuts));
100  vars.back().normalize = true;
101  }
102  default:
103  break;
104  }
105 
106  if(showData) {
107  plot_distributions(Samples, vars, rpv::luminosity, plot_type, plot_style, "ttbarcomp", true);
108  }
109  else {
110  plot_distributions(Samples, vars, rpv::luminosity, plot_type, plot_style, "ttbarcomp", false);
111  }
112 }
113 
void plot_distributions(std::vector< sfeats > Samples, std::vector< hfeats > vars, TString luminosity="10", TString filetype=".eps", TString namestyle="LargeLabels", TString dir="1d", bool doRatio=false, bool showcuts=false)
STL namespace.
std::string cutandweight(std::string cut, std::string weight)
TString luminosity
TString filestring(TString dataset, bool isSkimmed=true)
int main()
Definition: plot_ttbar.cxx:28