ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
plot_rpv_mjvsht.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <vector>
4 
5 #include "TCanvas.h"
6 #include "TFile.h"
7 #include "TH2D.h"
8 #include "TStyle.h"
9 
10 #include "utilities.hpp"
11 #include "utilities_macros.hpp"
12 #include "utilities_macros_rpv.hpp"
13 
14 namespace{
15  TString plot_type=".pdf";
16  TString outdir="rpv_mjvsht";
17 
18 }
19 
20 using namespace std;
21 
22 int main(){
23 
24  TString sig_folder = "/homes/cawest/babymaker/CMSSW_7_4_14/src/babymaker/";
25  TString folder = "/net/cms29/cms29r0/cawest/skims/ht1200/";
26 
27  TChain* sig1000 = new TChain("tree");
28  sig1000->Add(sig_folder+"RPV_M1000.root");
29  TChain* sig1200 = new TChain("tree");
30  sig1200->Add(sig_folder+"RPV_M1200.root");
31  TChain* sig1400 = new TChain("tree");
32  sig1400->Add(sig_folder+"RPV_M1400.root");
33 
34  TChain* bkg = new TChain("tree");
35  bkg->Add(folder+"*QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
36  bkg->Add(folder+"*QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1*");
37  bkg->Add(folder+"*QCD_HT1500to2000_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
38  bkg->Add(folder+"*QCD_HT1500to2000_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1*");
39  bkg->Add(folder+"*QCD_HT2000toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
40  bkg->Add(folder+"*QCD_HT2000toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1*");
41  bkg->Add(folder+"*TTJets_TuneCUETP8M1_13TeV-madgraphMLM*"); //Skimmed so there are no leptons in the dataset
42  bkg->Add(folder+"*TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
43  bkg->Add(folder+"*TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1*");
44  bkg->Add(folder+"*TTJets_SingleLeptFromT_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
45  bkg->Add(folder+"*TTJets_SingleLeptFromT_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1*");
46  bkg->Add(folder+"*TTJets_SingleLeptFromTbar_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
47  bkg->Add(folder+"*TTJets_SingleLeptFromTbar_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1*");
48  bkg->Add(folder+"*ST_s-channel_4f_leptonDecays_13TeV-amcatnlo-pythia8_TuneCUETP8M1*");
49  bkg->Add(folder+"*ST_t-channel_antitop_4f_leptonDecays_13TeV-powheg-pythia8_TuneCUETP8M1*");
50  bkg->Add(folder+"*ST_t-channel_top_4f_leptonDecays_13TeV-powheg-pythia8_TuneCUETP8M1*");
51  bkg->Add(folder+"*ST_tW_antitop_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M1*");
52  bkg->Add(folder+"*ST_tW_top_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M1*");
53  bkg->Add(folder+"*DYJetsToLL_M-50_HT-600toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
54  bkg->Add(folder+"*ttHJetTobb_M125_13TeV_amcatnloFXFX_madspin_pythia8*");
55  bkg->Add(folder+"*TTTT_TuneCUETP8M1_13TeV-amcatnlo-pythia8*");
56  bkg->Add(folder+"*TTWJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8*");
57  bkg->Add(folder+"*TTWJetsToQQ_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8*");
58  bkg->Add(folder+"*TTZToLLNuNu_M-10_TuneCUETP8M1_13TeV-amcatnlo-pythia8*");
59  bkg->Add(folder+"*TTZToQQ_TuneCUETP8M1_13TeV-amcatnlo-pythia8*");
60  bkg->Add(folder+"*WJetsToLNu_HT-600ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
61  bkg->Add(folder+"*WJetsToQQ_HT-600ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8*");
62  bkg->Add(folder+"*ZJetsToQQ_HT600toInf_13TeV-madgraph*");
63 
64  //Cuts
65  vector<TString> lepcuts = {"0", "1"};
66  vector<TString> htcuts = {"1200","1400","1600","1800", "2000"};
67  vector<TString> mjcuts = {"400","600","800","1000","1200"};
68 
69  // Background yields
70  double bkg_yields[2][5][5];
71  double bkg_yield = -999, bkg_error = -999;
72  for(unsigned int ilep=0; ilep<lepcuts.size(); ilep++){
73  cout<<"Getting "+lepcuts[ilep]+" lepton background yields..."<<endl;
74  for(unsigned int iht=0; iht<htcuts.size(); iht++){
75  for(unsigned int imj=0; imj<mjcuts.size(); imj++){
76  TString cut = "njets>=4&&nleps=="+lepcuts[ilep]+"&&ht>"+htcuts[iht]+"&&mj>"+mjcuts[imj];
77  getYieldErr(*bkg,"2.69*weight*w_pu_rpv/eff_trig*("+cut+")", bkg_yield, bkg_error);
78  bkg_yields[ilep][iht][imj] = bkg_yield;
79  }
80  }
81  }
82 
83  cout<<"Getting signal yields..."<<endl;
84 
85  //Signal yields
86  double sig1000_yields[2][5][5];
87  double sig1200_yields[2][5][5];
88  double sig1400_yields[2][5][5];
89 
90  double sig_yield = -999, sig_error = -999;
91  for(unsigned int ilep=0; ilep<lepcuts.size(); ilep++){
92  for(unsigned int iht=0; iht<htcuts.size(); iht++){
93  for(unsigned int imj=0; imj<mjcuts.size(); imj++){
94  TString cut = "nbm>=2&&njets>=8&&nleps=="+lepcuts[ilep]+"&&ht>"+htcuts[iht]+"&&mj>"+mjcuts[imj];
95  if(ilep==1) cut.ReplaceAll("njets>=8","njets>=6");
96  //M1000
97  getYieldErr(*sig1000,"2.69*weight*w_pu_rpv/eff_trig*("+cut+")", sig_yield, sig_error);
98  sig1000_yields[ilep][iht][imj] = sig_yield;
99  //M1200
100  getYieldErr(*sig1200,"2.69*weight*w_pu_rpv/eff_trig*("+cut+")", sig_yield, sig_error);
101  sig1200_yields[ilep][iht][imj] = sig_yield;
102  //M1400
103  getYieldErr(*sig1400,"2.69*weight*w_pu_rpv/eff_trig*("+cut+")", sig_yield, sig_error);
104  sig1400_yields[ilep][iht][imj] = sig_yield;
105  }
106  }
107  }
108  //Plot printing
109  cout<<"Printing plots..."<<endl;
110 
111  // S/sqrt(B), Signal, Backround and 0-lepton,1-lepton
112  TH2D* h_sig1000[3][2];
113  h_sig1000[0][0] = new TH2D("srb_sig1000_nlep0","S/sqrt(B);HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
114  h_sig1000[0][1] = new TH2D("srb_sig1000_nlep1","S/sqrt(B);HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
115  h_sig1000[1][0] = new TH2D("s_sig1000_nlep0","S;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
116  h_sig1000[1][1] = new TH2D("s_sig1000_nlep1","S;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
117  h_sig1000[2][0] = new TH2D("b_sig1000_nlep0","B;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
118  h_sig1000[2][1] = new TH2D("b_sig1000_nlep1","B;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
119 
120  TH2D* h_sig1200[3][2];
121  h_sig1200[0][0] = new TH2D("srb_sig1200_nlep0","S/sqrt(B);HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
122  h_sig1200[0][1] = new TH2D("srb_sig1200_nlep1","S/sqrt(B);HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
123  h_sig1200[1][0] = new TH2D("s_sig1200_nlep0","S;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
124  h_sig1200[1][1] = new TH2D("s_sig1200_nlep1","S;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
125  h_sig1200[2][0] = new TH2D("b_sig1200_nlep0","B;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
126  h_sig1200[2][1] = new TH2D("b_sig1200_nlep1","B;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
127 
128  TH2D* h_sig1400[3][2];
129  h_sig1400[0][0] = new TH2D("srb_sig1400_nlep0","S/sqrt(B);HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
130  h_sig1400[0][1] = new TH2D("srb_sig1400_nlep1","S/sqrt(B);HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
131  h_sig1400[1][0] = new TH2D("s_sig1400_nlep0","S;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
132  h_sig1400[1][1] = new TH2D("s_sig1400_nlep1","S;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
133  h_sig1400[2][0] = new TH2D("b_sig1400_nlep0","B;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
134  h_sig1400[2][1] = new TH2D("b_sig1400_nlep1","B;HT>X [GeV];MJ>Y [GeV]",5,1200,2200,5,400,1400);
135 
136  for(unsigned int ilep=0; ilep<lepcuts.size(); ilep++){
137  for(unsigned int iht=0; iht<htcuts.size(); iht++){
138  for(unsigned int imj=0; imj<mjcuts.size(); imj++){
139  // S/sqrt(B)
140  h_sig1000[0][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),sig1000_yields[ilep][iht][imj]/sqrt(bkg_yields[ilep][iht][imj]));
141  h_sig1200[0][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),sig1200_yields[ilep][iht][imj]/sqrt(bkg_yields[ilep][iht][imj]));
142  h_sig1400[0][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),sig1400_yields[ilep][iht][imj]/sqrt(bkg_yields[ilep][iht][imj]));
143 
144  // Signal
145  h_sig1000[1][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),sig1000_yields[ilep][iht][imj]);
146  h_sig1200[1][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),sig1200_yields[ilep][iht][imj]);
147  h_sig1400[1][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),sig1400_yields[ilep][iht][imj]);
148 
149  //Background
150  h_sig1000[2][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),bkg_yields[ilep][iht][imj]);
151  h_sig1200[2][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),bkg_yields[ilep][iht][imj]);
152  h_sig1400[2][ilep]->Fill(htcuts[iht].Atoi(),mjcuts[imj].Atoi(),bkg_yields[ilep][iht][imj]);
153  }
154  }
155  TCanvas c1;
156  gStyle->SetOptStat(0);
157  gStyle->SetPaintTextFormat("8.2f");
158  for(int iplot=0; iplot<3; iplot++){
159  //Sig1000
160  h_sig1000[iplot][ilep]->SetMarkerSize(2);
161  h_sig1000[iplot][ilep]->GetXaxis()->CenterLabels(true);
162  h_sig1000[iplot][ilep]->GetXaxis()->SetNdivisions(205);
163  h_sig1000[iplot][ilep]->GetYaxis()->CenterLabels(true);
164  h_sig1000[iplot][ilep]->GetYaxis()->SetNdivisions(205);
165  h_sig1000[iplot][ilep]->Draw("colz text");
166  c1.SaveAs("./plots/"+outdir+"/"+h_sig1000[iplot][ilep]->GetName()+plot_type);
167  //Sig1200
168  h_sig1200[iplot][ilep]->SetMarkerSize(2);
169  h_sig1200[iplot][ilep]->GetXaxis()->CenterLabels(true);
170  h_sig1200[iplot][ilep]->GetXaxis()->SetNdivisions(205);
171  h_sig1200[iplot][ilep]->GetYaxis()->CenterLabels(true);
172  h_sig1200[iplot][ilep]->GetYaxis()->SetNdivisions(205);
173  h_sig1200[iplot][ilep]->Draw("colz text");
174  c1.SaveAs("./plots/"+outdir+"/"+h_sig1200[iplot][ilep]->GetName()+plot_type);
175  //Sig1400
176  h_sig1400[iplot][ilep]->SetMarkerSize(2);
177  h_sig1400[iplot][ilep]->GetXaxis()->CenterLabels(true);
178  h_sig1400[iplot][ilep]->GetXaxis()->SetNdivisions(205);
179  h_sig1400[iplot][ilep]->GetYaxis()->CenterLabels(true);
180  h_sig1400[iplot][ilep]->GetYaxis()->SetNdivisions(205);
181  h_sig1400[iplot][ilep]->Draw("colz text");
182  c1.SaveAs("./plots/"+outdir+"/"+h_sig1400[iplot][ilep]->GetName()+plot_type);
183  }
184  }
185 }
long getYieldErr(TChain &tree, TString cut, double &yield, double &uncertainty)
STL namespace.
int main()