1 |
dkralph |
1.1 |
#if !defined(__CINT__) || defined(__MAKECINT__)
|
2 |
|
|
#include <TROOT.h> // access to gROOT, entry point to ROOT system
|
3 |
|
|
#include <TFile.h> // file handle class
|
4 |
|
|
#include <TTree.h> // class to access ntuples
|
5 |
|
|
#include <TChain.h>
|
6 |
|
|
#include <TCanvas.h> // class for drawing
|
7 |
|
|
#include <TH1F.h> // 1D histograms
|
8 |
|
|
#include <TH2F.h> // 2D histograms
|
9 |
|
|
#include <TBenchmark.h> // class to track macro running statistics
|
10 |
|
|
#include <TVector3.h> // 3D vector class
|
11 |
|
|
#include <TRegexp.h> // 3D vector class
|
12 |
|
|
#include <vector> // STL vector class
|
13 |
|
|
#include <iostream> // standard I/O
|
14 |
|
|
#include <iomanip> // functions to format standard I/O
|
15 |
|
|
#include <fstream> // functions for file I/O
|
16 |
|
|
#include <string> // C++ string class
|
17 |
|
|
#include <sstream> // class for parsing strings
|
18 |
|
|
#include "RooHistPdf.h"
|
19 |
|
|
#include "RooGlobalFunc.h"
|
20 |
|
|
#include "RooPlot.h"
|
21 |
|
|
#include "RooRealVar.h"
|
22 |
|
|
#include "RooDataHist.h"
|
23 |
|
|
#include "RooGenericPdf.h"
|
24 |
|
|
#include "RooDataSet.h"
|
25 |
|
|
#include "RooAddPdf.h"
|
26 |
|
|
#include "RooFormulaVar.h"
|
27 |
|
|
#include "RooCurve.h"
|
28 |
|
|
#include "RooBinning.h"
|
29 |
|
|
#include "Common/CPlot.hh" // helper class for plots
|
30 |
|
|
#include "Common/MitStyleRemix.hh" // style settings for drawing
|
31 |
|
|
#include "Common/MyTools.hh" // miscellaneous helper functions
|
32 |
|
|
#include "Common/CSample.hh" // helper class for organizing input ntuple files
|
33 |
|
|
|
34 |
|
|
#endif
|
35 |
|
|
using namespace RooFit;
|
36 |
|
|
|
37 |
|
|
TString scheme = "bdt-medium";
|
38 |
|
|
TString lumi = "4700";
|
39 |
|
|
TCanvas *c = new TCanvas("c","c");
|
40 |
|
|
vector<TString> fnamev,labelv;
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
//----------------------------------------------------------------------------------------
|
44 |
|
|
class filestuff
|
45 |
|
|
{
|
46 |
|
|
public:
|
47 |
|
|
filestuff(TString nameval, TString filename);
|
48 |
|
|
TString name;
|
49 |
|
|
TChain *chain;
|
50 |
|
|
TString fname;
|
51 |
|
|
};
|
52 |
|
|
filestuff::filestuff(TString nameval, TString filename)
|
53 |
|
|
{
|
54 |
|
|
name = nameval;
|
55 |
|
|
fname = filename;
|
56 |
|
|
chain = new TChain(nameval,nameval);
|
57 |
|
|
chain->AddFile(fname,-1,"passtuple");
|
58 |
|
|
}
|
59 |
|
|
//----------------------------------------------------------------------------------------
|
60 |
|
|
TH1F* get_FR_pred(filestuff fs, TString var, TString extra, int nbins, double xmin, double xmax, double &integral, bool oneZ=false) {
|
61 |
|
|
TString hname = "hFR_"+fs.name+var;
|
62 |
|
|
TH1F* hFR = new TH1F(hname,"",nbins,xmin,xmax); hFR->Sumw2();
|
63 |
|
|
if(oneZ) fs.chain->Draw(var+">>"+hname,"w*(w!=1)"+extra); // for Z + one fake 'w' is fake weight
|
64 |
|
|
else fs.chain->Draw(var+">>"+hname,"w"+extra); //
|
65 |
|
|
integral = hFR->Integral();
|
66 |
|
|
return hFR;
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
TH1F* get_Obs(filestuff fs, TString var, TString extra, int nbins, double xmin, double xmax, double &integral) {
|
70 |
|
|
TString hname = "hObs_"+fs.name+var;
|
71 |
|
|
TH1F* hObs = new TH1F(hname,"",nbins,xmin,xmax); hObs->Sumw2();
|
72 |
|
|
fs.chain->Draw(var+">>"+hname,"(w==1)"+extra);
|
73 |
|
|
integral = hObs->Integral();
|
74 |
|
|
return hObs;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
TH1F* get_MC(filestuff fs, TString var, TString extra, int nbins, double xmin, double xmax, double &integral, bool oneZ=false) {
|
78 |
|
|
TString hname = "hMC_"+fs.name+var;
|
79 |
|
|
TH1F *hMC = new TH1F(hname,"",nbins,xmin,xmax); hMC->Sumw2();
|
80 |
|
|
if(oneZ) fs.chain->Draw(var+">>"+hname,lumi+"*xswgt*npuw*(w==1)"+extra); // here 'w' is the fake weight (1 for tight events)
|
81 |
|
|
else fs.chain->Draw(var+">>"+hname,lumi+"*npuw*w*won*woff"+extra); // but in these files, 'w' is the xs weight
|
82 |
|
|
integral = hMC->Integral();
|
83 |
|
|
return hMC;
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
TH1F* get_MC_FR_pred(filestuff fs, TString var, TString extra, int nbins, double xmin, double xmax, double &integral, bool oneZ=false) {
|
87 |
|
|
TString hname = "hMC_FR_pred_"+fs.name+var;
|
88 |
|
|
TH1F *hMC_FR_pred = new TH1F(hname,"",nbins,xmin,xmax); hMC_FR_pred->Sumw2();
|
89 |
|
|
if(oneZ) fs.chain->Draw(var+">>"+hname,lumi+"*w*(w!=1)*npuw*xswgt"+extra); // here 'w' is the fake weight
|
90 |
|
|
else fs.chain->Draw(var+">>"+hname,lumi+"*w*npuw*xswgt*won*woff"+extra); // (and here...)
|
91 |
|
|
integral = hMC_FR_pred->Integral();
|
92 |
|
|
return hMC_FR_pred;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
void plot_fakes()
|
96 |
|
|
{
|
97 |
|
|
CPlot::sOutDir = "~/public_html/4lfakes";
|
98 |
|
|
|
99 |
|
|
map<TString,TTree*> treemap;
|
100 |
|
|
map<TString,TString> labelmap;
|
101 |
|
|
|
102 |
|
|
// reference
|
103 |
|
|
filestuff single("single","root/ntuples/singleEle-bdt-medium-nomctrig.root");
|
104 |
|
|
filestuff doublel("doublel","root/ntuples/doubleEle-bdt-medium-nomctrig.root");
|
105 |
|
|
filestuff zjets_sele("zjets_sele","root/ntuples/full-zjets.root");
|
106 |
|
|
filestuff wzmg_sele("wzmg_sele","root/ntuples/full-wzmg.root");
|
107 |
|
|
filestuff zllg_sele("zllg_sele","root/ntuples/full-zllg.root");
|
108 |
|
|
filestuff zjets_single("zjets_single","root/ntuples/singleEle-bdt-medium-zjets-nomctrig.root");
|
109 |
|
|
filestuff zjets_double("zjets_double","root/ntuples/doubleEle-bdt-medium-zjets-nomctrig.root");
|
110 |
|
|
filestuff tt2l_single("tt2l_single","root/ntuples/singleEle-bdt-medium-tt2l-iso07.root");
|
111 |
|
|
filestuff tt2l_double("tt2l_double","root/ntuples/doubleEle-bdt-medium-tt2l-iso07.root");
|
112 |
|
|
filestuff zz_single("zz_single","root/ntuples/singleEle-bdt-medium-ZZ-powheg-nomctrig.root");
|
113 |
|
|
filestuff gg2zz_single("gg2zz_single","root/ntuples/singleEle-bdt-medium-gg2zz-nomctrig.root");
|
114 |
|
|
filestuff gg2zz_double("gg2zz_double","root/ntuples/doubleEle-bdt-medium-gg2zz-nomctrig.root");
|
115 |
|
|
filestuff zllg_single("zllg_single","root/ntuples/singleEle-bdt-medium-zllg-nomctrig.root");
|
116 |
|
|
filestuff zllg_double("zllg_double","root/ntuples/doubleEle-bdt-medium-zllg-nomctrig.root");
|
117 |
|
|
filestuff wzmg_single("wzmg_single","root/ntuples/singleEle-bdt-medium-wzmg-nomctrig.root");
|
118 |
|
|
|
119 |
|
|
// Z + one fake
|
120 |
|
|
filestuff oneZ_data("oneZ_data","root/ntuples/oneZ-bdt-medium-iso07-new.root");
|
121 |
|
|
filestuff oneZ_zjets("oneZ_zjets","root/ntuples/oneZ-bdt-medium-zjets-iso07-new.root");
|
122 |
|
|
|
123 |
|
|
double xmin,xmax,integral;
|
124 |
|
|
int nbins;
|
125 |
|
|
TString var,cut,extra,ylabel;
|
126 |
|
|
TH1F *htmp,*htmp2;
|
127 |
|
|
//----------------------------------------------------------------------------------------
|
128 |
|
|
|
129 |
|
|
cut = "*(1)";
|
130 |
|
|
ylabel = "events";
|
131 |
|
|
|
132 |
|
|
var = "m4l";
|
133 |
|
|
xmin = 0; xmax = 750; nbins = 10;
|
134 |
|
|
extra = cut;
|
135 |
|
|
CPlot plotm4l_single(var+"_single","","#bf{m4l [GeV]}",ylabel);
|
136 |
|
|
htmp = get_FR_pred(single,var,extra,nbins,xmin,xmax,integral);
|
137 |
|
|
plotm4l_single.AddHist1D(htmp,"single loop","E");
|
138 |
|
|
plotm4l_single.AddToStack(get_MC_FR_pred(wzmg_single,var,extra,nbins,xmin,xmax,integral),"wz single loop",kBlue);
|
139 |
|
|
plotm4l_single.AddToStack(get_MC_FR_pred(gg2zz_single,var,extra,nbins,xmin,xmax,integral),"ggzz single loop",kRed);
|
140 |
|
|
// plotm4l_single.AddToStack(get_MC_FR_pred(zllg_single,var,extra,nbins,xmin,xmax,integral),"zllg single loop",843);
|
141 |
|
|
plotm4l_single.AddToStack(get_MC_FR_pred(zz_single,var,extra,nbins,xmin,xmax,integral),"zz single loop",kGray);
|
142 |
|
|
plotm4l_single.AddToStack(get_MC_FR_pred(zjets_single,var,extra,nbins,xmin,xmax,integral),"z+jets single loop",kCyan-6);
|
143 |
|
|
plotm4l_single.SetYRange(0,1.4*htmp->GetMaximum());
|
144 |
|
|
plotm4l_single.Draw(c,kTRUE,"png");
|
145 |
|
|
|
146 |
|
|
var = "m4l";
|
147 |
|
|
xmin = 0; xmax = 750; nbins = 40;
|
148 |
|
|
extra = cut;
|
149 |
|
|
CPlot plotm4l_single_dataonly(var+"_single_dataonly","","#bf{m4l [GeV]}",ylabel);
|
150 |
|
|
htmp = get_FR_pred(single,var,extra,nbins,xmin,xmax,integral);
|
151 |
|
|
plotm4l_single_dataonly.AddToStack(htmp,"FR prediction",kCyan-6);
|
152 |
|
|
plotm4l_single_dataonly.SetYRange(0,1.4*htmp->GetMaximum());
|
153 |
|
|
plotm4l_single_dataonly.Draw(c,kTRUE,"png");
|
154 |
|
|
|
155 |
|
|
var = "met";
|
156 |
|
|
xmin = 0; xmax = 120; nbins = 10;
|
157 |
|
|
extra = cut;
|
158 |
|
|
CPlot plotmet_single(var+"_single","","#bf{met [GeV]}",ylabel);
|
159 |
|
|
htmp = get_FR_pred(single,var,extra,nbins,xmin,xmax,integral);
|
160 |
|
|
plotmet_single.AddHist1D(htmp,"single loop","E");
|
161 |
|
|
htmp2 = get_FR_pred(doublel,var,extra,nbins,xmin,xmax,integral); htmp2->Scale(2.);
|
162 |
|
|
// plotmet_single.AddHist1D(htmp2,"2*(double loop)","hist",kRed);
|
163 |
|
|
plotmet_single.AddToStack(get_MC_FR_pred(wzmg_single,var,extra,nbins,xmin,xmax,integral),"wz single loop",kBlue);
|
164 |
|
|
plotmet_single.AddToStack(get_MC_FR_pred(tt2l_single,var,extra,nbins,xmin,xmax,integral),"t#bar{t} single loop",kRed);
|
165 |
|
|
// plotmet_single.AddToStack(get_MC_FR_pred(zllg_single,var,extra,nbins,xmin,xmax,integral),"zllg single loop",843);
|
166 |
|
|
plotmet_single.AddToStack(get_MC_FR_pred(zz_single,var,extra,nbins,xmin,xmax,integral),"zz single loop",kGray);
|
167 |
|
|
plotmet_single.AddToStack(get_MC_FR_pred(zjets_single,var,extra,nbins,xmin,xmax,integral),"z+jets single loop",kCyan-6);
|
168 |
|
|
plotmet_single.SetYRange(0,1.4*htmp->GetMaximum());
|
169 |
|
|
plotmet_single.Draw(c,kTRUE,"png");
|
170 |
|
|
|
171 |
|
|
var = "mt";
|
172 |
|
|
xmin = 7; xmax = 150; nbins = 10;
|
173 |
|
|
extra = cut;
|
174 |
|
|
CPlot plotpt4_single(var+"_single","","#bf{p_{T} [GeV]}",ylabel);
|
175 |
|
|
htmp = get_FR_pred(single,var,extra,nbins,xmin,xmax,integral);
|
176 |
|
|
plotpt4_single.AddHist1D(htmp,"single loop","E");
|
177 |
|
|
htmp2 = get_FR_pred(doublel,var,extra,nbins,xmin,xmax,integral);
|
178 |
|
|
htmp2->Scale(2.);
|
179 |
|
|
// plotpt4_single.AddHist1D(htmp2,"2*(double loop)","hist",kRed);
|
180 |
|
|
plotpt4_single.AddToStack(get_MC_FR_pred(wzmg_single,var,extra,nbins,xmin,xmax,integral),"wz single loop",kBlue);
|
181 |
|
|
// plotpt4_single.AddToStack(get_MC_FR_pred(zllg_single,var,extra,nbins,xmin,xmax,integral),"zllg single loop",843);
|
182 |
|
|
plotpt4_single.AddToStack(get_MC_FR_pred(zz_single,var,extra,nbins,xmin,xmax,integral),"zz single loop",kGray);
|
183 |
|
|
plotpt4_single.AddToStack(get_MC_FR_pred(zjets_single,var,extra,nbins,xmin,xmax,integral),"z+jets single loop",kCyan-6);
|
184 |
|
|
plotpt4_single.SetYRange(0,1.4*htmp->GetMaximum());
|
185 |
|
|
plotpt4_single.Draw(c,kTRUE,"png");
|
186 |
|
|
|
187 |
|
|
var = "m4l";
|
188 |
|
|
xmin = 0; xmax = 750; nbins = 10;
|
189 |
|
|
extra = cut;
|
190 |
|
|
CPlot plotm4l_double(var+"_double","","#bf{m4l [GeV]}",ylabel);
|
191 |
|
|
plotm4l_double.AddHist1D(get_FR_pred(doublel,var,extra,nbins,xmin,xmax,integral),"double loop","E");
|
192 |
|
|
plotm4l_double.AddToStack(get_MC_FR_pred(zjets_double,var,extra,nbins,xmin,xmax,integral),"z+jets double loop",kCyan-6);
|
193 |
|
|
htmp = get_MC_FR_pred(zjets_single,var,extra,nbins,xmin,xmax,integral);
|
194 |
|
|
htmp->Scale(1./2);
|
195 |
|
|
plotm4l_double.AddHist1D(htmp,"0.5*(z+jets single loop)","hist",kRed);
|
196 |
|
|
plotm4l_double.Draw(c,kTRUE,"png");
|
197 |
|
|
|
198 |
|
|
var = "m3l";
|
199 |
|
|
xmin = 50; xmax = 500; nbins = 20;
|
200 |
|
|
extra = cut + "/w";
|
201 |
|
|
CPlot plotm3l(var,"","#bf{m3l [GeV]}",ylabel);
|
202 |
|
|
plotm3l.AddHist1D(get_FR_pred(single,var,extra,nbins,xmin,xmax,integral),"single loop","E");
|
203 |
|
|
plotm3l.AddToStack(get_MC_FR_pred(wzmg_single,var,extra,nbins,xmin,xmax,integral),"wz single loop",kBlue);
|
204 |
|
|
plotm3l.AddToStack(get_MC_FR_pred(zjets_single,var,extra,nbins,xmin,xmax,integral),"z+jets single loop",kCyan-6);
|
205 |
|
|
plotm3l.Draw(c,kTRUE,"png");
|
206 |
|
|
|
207 |
|
|
//
|
208 |
|
|
// Z + one fake
|
209 |
|
|
//
|
210 |
|
|
var = "met";
|
211 |
|
|
xmin = 0; xmax = 100; nbins = 40;
|
212 |
|
|
extra = cut + "*(mZ1>0)";
|
213 |
|
|
CPlot plotOneZ_met(var+"_oneZ","","#bf{MET [GeV]}",ylabel);
|
214 |
|
|
plotOneZ_met.AddHist1D(get_Obs(oneZ_data,var,extra,nbins,xmin,xmax,integral),"Obs","E");
|
215 |
|
|
plotOneZ_met.AddHist1D(get_FR_pred(oneZ_data,var,extra,nbins,xmin,xmax,integral,true),"FR predic","hist",kBlue);
|
216 |
|
|
plotOneZ_met.AddHist1D(get_MC(oneZ_zjets,var,extra,nbins,xmin,xmax,integral,true),"z+jets","hist",kRed);
|
217 |
|
|
plotOneZ_met.AddToStack(get_MC_FR_pred(oneZ_zjets,var,extra,nbins,xmin,xmax,integral,true),"z+jets FR prediction",kCyan-6);
|
218 |
|
|
plotOneZ_met.Draw(c,kTRUE,"png");
|
219 |
|
|
|
220 |
|
|
var = "mZ1";
|
221 |
|
|
xmin = 60; xmax = 110; nbins = 50;
|
222 |
|
|
extra = cut + "*(mZ1>0)";
|
223 |
|
|
CPlot plotOneZ_mZ1(var+"_oneZ","","#bf{mZ1 [GeV]}",ylabel);
|
224 |
|
|
plotOneZ_mZ1.AddHist1D(get_Obs(oneZ_data,var,extra,nbins,xmin,xmax,integral),"Obs","E");
|
225 |
|
|
cout << "Data obs.:\t\t" << integral << endl;
|
226 |
|
|
plotOneZ_mZ1.AddHist1D(get_FR_pred(oneZ_data,var,extra,nbins,xmin,xmax,integral,true),"FR predic","hist",kBlue);
|
227 |
|
|
cout << "Data FR predic.:\t" << integral << endl;
|
228 |
|
|
plotOneZ_mZ1.AddHist1D(get_MC(oneZ_zjets,var,extra,nbins,xmin,xmax,integral,true),"z+jets","hist",kRed);
|
229 |
|
|
cout << "z+jets obs.:\t\t" << integral << endl;
|
230 |
|
|
plotOneZ_mZ1.AddToStack(get_MC_FR_pred(oneZ_zjets,var,extra,nbins,xmin,xmax,integral,true),"z+jets FR prediction",kCyan-6);
|
231 |
|
|
cout << "z+jets FR predic.:\t" << integral << endl;
|
232 |
|
|
plotOneZ_mZ1.TransLegend(-.4,0);
|
233 |
|
|
plotOneZ_mZ1.Draw(c,kTRUE,"png");
|
234 |
|
|
|
235 |
|
|
}
|