1 |
dkralph |
1.1 |
#include "compute_fakes.h"
|
2 |
|
|
|
3 |
|
|
//=== MAIN =================================================================================================
|
4 |
dkralph |
1.2 |
void makeHTML(FOFlags &ctrl, const TString outDir);
|
5 |
|
|
TGraphAsymmErrors* computeFakeRate1D(const TH1D* hpass, const TH1D* htotal);
|
6 |
dkralph |
1.1 |
void computeFakeRate2D(const TH2D *hpass, const TH2D* htotal,
|
7 |
|
|
TH2D *hresult, TH2D* herrl, TH2D* herrh);
|
8 |
|
|
|
9 |
|
|
int main(int argc, char** argv)
|
10 |
|
|
{
|
11 |
|
|
|
12 |
|
|
TString input("./NonMCBackground/data/elefr.input");
|
13 |
|
|
TString format("png");
|
14 |
|
|
Bool_t doAbsEta = kFALSE;
|
15 |
dkralph |
1.2 |
TString seletype("ID mva + Iso mva");
|
16 |
|
|
TString tightness("loose");
|
17 |
dkralph |
1.1 |
|
18 |
|
|
//
|
19 |
|
|
// args
|
20 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
21 |
|
|
FOFlags ctrl;
|
22 |
|
|
parse_foargs( argc, argv, ctrl );
|
23 |
|
|
ctrl.dump();
|
24 |
|
|
|
25 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
26 |
|
|
// Settings
|
27 |
|
|
//==============================================================================================================
|
28 |
|
|
|
29 |
|
|
// bin edges for kinematic variables
|
30 |
|
|
vector<Double_t> ptBinEdgesv;
|
31 |
|
|
vector<Double_t> etaBinEdgesv;
|
32 |
|
|
vector<Double_t> phiBinEdgesv;
|
33 |
|
|
|
34 |
dkralph |
1.2 |
ifstream ifs;
|
35 |
|
|
string line;
|
36 |
|
|
|
37 |
|
|
// parse input information
|
38 |
|
|
TString ntupledir;
|
39 |
|
|
vector<TString> infiles;
|
40 |
|
|
ifs.open(ctrl.config); assert(ifs.is_open());
|
41 |
|
|
while(getline(ifs,line)) {
|
42 |
|
|
if(line[0]=='#') continue;
|
43 |
|
|
if(line[0]=='$') continue;
|
44 |
|
|
|
45 |
|
|
stringstream ss(line);
|
46 |
|
|
if(line[0]=='^') {
|
47 |
|
|
TString dummy;
|
48 |
|
|
if(TString(line).Contains("^ntupdir")) ss >> dummy >> ntupledir;
|
49 |
|
|
// if(TString(line).Contains("^skim")) ss >> dummy >> ntupledir;
|
50 |
|
|
continue;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
TString dataset;
|
55 |
|
|
ss >> dataset;
|
56 |
|
|
infiles.push_back(ntupledir+"/"+ctrl.faketype+"/"+dataset+"/merged.root");
|
57 |
|
|
}
|
58 |
|
|
ifs.close();
|
59 |
dkralph |
1.1 |
|
60 |
|
|
vector<TString> fnamev;
|
61 |
|
|
vector<Int_t> colorv;
|
62 |
|
|
vector<TString> labelv;
|
63 |
dkralph |
1.2 |
|
64 |
|
|
// parse FR config info
|
65 |
dkralph |
1.1 |
ifs.open(input.Data());
|
66 |
|
|
assert(ifs.is_open());
|
67 |
|
|
Int_t state=0;
|
68 |
|
|
while(getline(ifs,line)) {
|
69 |
|
|
if(line[0]=='#') continue;
|
70 |
|
|
if(line[0]=='%') {
|
71 |
|
|
state++;
|
72 |
|
|
continue;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
if(state==0) {
|
76 |
|
|
|
77 |
|
|
} else if(state==1) {
|
78 |
|
|
stringstream ss(line);
|
79 |
|
|
string fname;
|
80 |
|
|
Int_t color;
|
81 |
|
|
ss >> fname >> color;
|
82 |
|
|
string label = line.substr(line.find('@')+1);
|
83 |
|
|
// fnamev.push_back(fname);
|
84 |
|
|
fnamev.push_back(ctrl.inputdir); // not used!
|
85 |
|
|
colorv.push_back(color);
|
86 |
|
|
labelv.push_back(label);
|
87 |
|
|
|
88 |
|
|
} else if(state>=2 && state<=4) {
|
89 |
|
|
Double_t edge;
|
90 |
|
|
stringstream ss(line);
|
91 |
|
|
ss >> edge;
|
92 |
|
|
if(state==2) { etaBinEdgesv.push_back(edge); }
|
93 |
|
|
else if(state==3) { ptBinEdgesv.push_back(edge); }
|
94 |
|
|
else if(state==4) { phiBinEdgesv.push_back(edge); }
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
ifs.close();
|
98 |
|
|
|
99 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
100 |
|
|
// Main analysis code
|
101 |
|
|
//==============================================================================================================
|
102 |
|
|
|
103 |
|
|
//
|
104 |
|
|
// Set up histograms
|
105 |
|
|
//
|
106 |
dkralph |
1.2 |
TH1D *hNumerPt0=0, *hNumerEta0=0, *hNumerPhi0=0;
|
107 |
|
|
TH1D *hDenomPt0=0, *hDenomEta0=0, *hDenomPhi0=0;
|
108 |
dkralph |
1.1 |
|
109 |
dkralph |
1.2 |
vector<TH1D*> hNumerPtv;
|
110 |
|
|
vector<TH1D*> hNumerEtav;
|
111 |
|
|
vector<TH1D*> hNumerPhiv;
|
112 |
|
|
|
113 |
|
|
vector<TH1D*> hDenomPtv;
|
114 |
|
|
vector<TH1D*> hDenomEtav;
|
115 |
|
|
vector<TH1D*> hDenomPhiv;
|
116 |
dkralph |
1.1 |
|
117 |
|
|
vector<TGraphAsymmErrors*> effPtv;
|
118 |
|
|
vector<TGraphAsymmErrors*> effEtav;
|
119 |
|
|
vector<TGraphAsymmErrors*> effPhiv;
|
120 |
|
|
|
121 |
|
|
vector<TH2D*> hNumerEtaPtv, hDenomEtaPtv, hEffEtaPtv, hErrlEtaPtv, hErrhEtaPtv;
|
122 |
|
|
|
123 |
|
|
Int_t nbins = ptBinEdgesv.size()-1;
|
124 |
|
|
Double_t *ptbinning = new Double_t[ptBinEdgesv.size()];
|
125 |
|
|
for(UInt_t i=0; i<ptBinEdgesv.size(); i++) { ptbinning[i] = ptBinEdgesv[i]; }
|
126 |
dkralph |
1.2 |
hNumerPt0 = new TH1D("hNumerPt0","",nbins,ptbinning);
|
127 |
|
|
hDenomPt0 = new TH1D("hDenomPt0","",nbins,ptbinning);
|
128 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<fnamev.size(); ifile++) {
|
129 |
|
|
char hname[100];
|
130 |
dkralph |
1.2 |
sprintf(hname,"hNumerPt_%i",ifile); hNumerPtv.push_back(new TH1D(hname,"",nbins,ptbinning)); hNumerPtv[ifile]->Sumw2();
|
131 |
|
|
sprintf(hname,"hDenomPt_%i",ifile); hDenomPtv.push_back(new TH1D(hname,"",nbins,ptbinning)); hDenomPtv[ifile]->Sumw2();
|
132 |
dkralph |
1.1 |
}
|
133 |
|
|
|
134 |
|
|
nbins = etaBinEdgesv.size()-1;
|
135 |
|
|
Double_t *etabinning = new Double_t[etaBinEdgesv.size()];
|
136 |
|
|
for(UInt_t i=0; i<etaBinEdgesv.size(); i++) { etabinning[i] = etaBinEdgesv[i]; }
|
137 |
dkralph |
1.2 |
hNumerEta0 = new TH1D("hNumerEta0","",nbins,etabinning);
|
138 |
|
|
hDenomEta0 = new TH1D("hDenomEta0","",nbins,etabinning);
|
139 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<fnamev.size(); ifile++) {
|
140 |
|
|
char hname[100];
|
141 |
dkralph |
1.2 |
sprintf(hname,"hNumerEta_%i",ifile); hNumerEtav.push_back(new TH1D(hname,"",nbins,etabinning)); hNumerEtav[ifile]->Sumw2();
|
142 |
|
|
sprintf(hname,"hDenomEta_%i",ifile); hDenomEtav.push_back(new TH1D(hname,"",nbins,etabinning)); hDenomEtav[ifile]->Sumw2();
|
143 |
dkralph |
1.1 |
}
|
144 |
|
|
|
145 |
|
|
nbins = phiBinEdgesv.size()-1;
|
146 |
|
|
Double_t *phibinning = new Double_t[phiBinEdgesv.size()];
|
147 |
|
|
for(UInt_t i=0; i<phiBinEdgesv.size(); i++) { phibinning[i] = phiBinEdgesv[i]; }
|
148 |
dkralph |
1.2 |
hNumerPhi0 = new TH1D("hNumerPhi0","",nbins,phibinning);
|
149 |
|
|
hDenomPhi0 = new TH1D("hDenomPhi0","",nbins,phibinning);
|
150 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<fnamev.size(); ifile++) {
|
151 |
|
|
char hname[100];
|
152 |
dkralph |
1.2 |
sprintf(hname,"hNumerPhi_%i",ifile); hNumerPhiv.push_back(new TH1D(hname,"",nbins,phibinning)); hNumerPhiv[ifile]->Sumw2();
|
153 |
|
|
sprintf(hname,"hDenomPhi_%i",ifile); hDenomPhiv.push_back(new TH1D(hname,"",nbins,phibinning)); hDenomPhiv[ifile]->Sumw2();
|
154 |
dkralph |
1.1 |
}
|
155 |
|
|
|
156 |
|
|
for(UInt_t ifile=0; ifile<fnamev.size(); ifile++) {
|
157 |
|
|
char hname[100];
|
158 |
|
|
sprintf(hname,"hNumerEtaPt_%i",ifile);
|
159 |
|
|
hNumerEtaPtv.push_back(new TH2D(hname,"",etaBinEdgesv.size()-1,etabinning,ptBinEdgesv.size()-1,ptbinning));
|
160 |
|
|
hNumerEtaPtv[ifile]->Sumw2();
|
161 |
|
|
|
162 |
|
|
sprintf(hname,"hDenomEtaPt_%i",ifile);
|
163 |
|
|
hDenomEtaPtv.push_back(new TH2D(hname,"",etaBinEdgesv.size()-1,etabinning,ptBinEdgesv.size()-1,ptbinning));
|
164 |
|
|
hDenomEtaPtv[ifile]->Sumw2();
|
165 |
|
|
|
166 |
|
|
sprintf(hname,"hEffEtaPt_%i",ifile);
|
167 |
|
|
hEffEtaPtv.push_back(new TH2D(hname,"",etaBinEdgesv.size()-1,etabinning,ptBinEdgesv.size()-1,ptbinning));
|
168 |
|
|
hEffEtaPtv[ifile]->Sumw2();
|
169 |
|
|
|
170 |
|
|
sprintf(hname,"hErrlEtaPt_%i",ifile);
|
171 |
|
|
hErrlEtaPtv.push_back(new TH2D(hname,"",etaBinEdgesv.size()-1,etabinning,ptBinEdgesv.size()-1,ptbinning));
|
172 |
|
|
hErrlEtaPtv[ifile]->Sumw2();
|
173 |
|
|
|
174 |
|
|
sprintf(hname,"hErrhEtaPt_%i",ifile);
|
175 |
|
|
hErrhEtaPtv.push_back(new TH2D(hname,"",etaBinEdgesv.size()-1,etabinning,ptBinEdgesv.size()-1,ptbinning));
|
176 |
|
|
hErrhEtaPtv[ifile]->Sumw2();
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
delete [] ptbinning;
|
180 |
|
|
delete [] etabinning;
|
181 |
|
|
delete [] phibinning;
|
182 |
|
|
|
183 |
|
|
TChain *inchain = new TChain("FO","FO");
|
184 |
dkralph |
1.2 |
for(unsigned ifile=0; ifile<infiles.size(); ifile++) {
|
185 |
|
|
cout << "Adding: " << infiles[ifile] << "... " << endl;
|
186 |
|
|
inchain->Add(infiles[ifile]);
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
Double_t yhigh1 = 3*(double(inchain->GetEntries("pass")) / inchain->GetEntries());
|
190 |
dkralph |
1.1 |
|
191 |
|
|
Float_t pt,eta,phi,pass,jpt;
|
192 |
|
|
inchain->SetBranchAddress( "pt", &pt);
|
193 |
|
|
inchain->SetBranchAddress( "eta", &eta);
|
194 |
|
|
inchain->SetBranchAddress( "phi", &phi);
|
195 |
|
|
inchain->SetBranchAddress( "pass", &pass);
|
196 |
|
|
inchain->SetBranchAddress( "jpt", &jpt);
|
197 |
|
|
|
198 |
|
|
for(UInt_t ientry=0; ientry<inchain->GetEntries(); ientry++) {
|
199 |
|
|
inchain->GetEntry(ientry);
|
200 |
|
|
|
201 |
|
|
if(pt < ptBinEdgesv.front() || pt > ptBinEdgesv.back()) continue;
|
202 |
|
|
if(doAbsEta) {
|
203 |
|
|
if(fabs(eta) < etaBinEdgesv.front() || fabs(eta) > etaBinEdgesv.back()) continue;
|
204 |
|
|
} else {
|
205 |
|
|
if(eta < etaBinEdgesv.front() || eta > etaBinEdgesv.back()) continue;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
double weight = 1;
|
209 |
|
|
|
210 |
|
|
hDenomPt0 ->Fill(pt,weight);
|
211 |
|
|
hDenomEta0->Fill(doAbsEta ? fabs(eta) : eta,weight);
|
212 |
|
|
|
213 |
|
|
hDenomPtv[0] ->Fill(pt,weight);
|
214 |
|
|
hDenomEtav[0]->Fill(doAbsEta ? fabs(eta) : eta,weight);
|
215 |
|
|
hDenomEtaPtv[0]->Fill(doAbsEta ? fabs(eta) : eta,pt,weight);
|
216 |
|
|
|
217 |
|
|
if(pass) {
|
218 |
|
|
hNumerPt0 ->Fill(pt,weight);
|
219 |
|
|
hNumerEta0->Fill(doAbsEta ? fabs(eta) : eta,weight);
|
220 |
|
|
|
221 |
|
|
hNumerPtv[0] ->Fill(pt,weight);
|
222 |
|
|
hNumerEtav[0]->Fill(doAbsEta ? fabs(eta) : eta,weight);
|
223 |
|
|
hNumerEtaPtv[0]->Fill(doAbsEta ? fabs(eta) : eta,pt,weight);
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
TGraphAsymmErrors *frPt = computeFakeRate1D(hNumerPtv[0],hDenomPtv[0]);
|
229 |
|
|
TGraphAsymmErrors *frEta = computeFakeRate1D(hNumerEtav[0],hDenomEtav[0]);
|
230 |
|
|
|
231 |
|
|
computeFakeRate2D(hNumerEtaPtv[0],hDenomEtaPtv[0],hEffEtaPtv[0],hErrlEtaPtv[0],hErrhEtaPtv[0]);
|
232 |
|
|
|
233 |
|
|
TH2D *frEtaPt = (TH2D*)hEffEtaPtv[0]->Clone("frEtaPt");
|
234 |
|
|
TH2D *errlEtaPt = (TH2D*)hErrlEtaPtv[0]->Clone("errlEtaPt");
|
235 |
|
|
TH2D *errhEtaPt = (TH2D*)hErrhEtaPtv[0]->Clone("errhEtaPt");
|
236 |
|
|
|
237 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
238 |
|
|
// Make plots
|
239 |
|
|
//==============================================================================================================
|
240 |
|
|
TCanvas *c = new TCanvas("c","c",800,600);
|
241 |
|
|
char ylabel[100];
|
242 |
|
|
TString etalabel = (doAbsEta) ? "#scale[1.3]{|#eta|}" : "#scale[1.3]{#eta}";
|
243 |
|
|
|
244 |
|
|
//
|
245 |
|
|
// Denominator distributions
|
246 |
|
|
//
|
247 |
|
|
sprintf(ylabel,"Events / %.1f GeV/c",hDenomPtv[0]->GetBinWidth(1));
|
248 |
dkralph |
1.2 |
CPlot plotDenomPt("denompt","","denominator p_{T} [GeV/c]",ylabel,ctrl.outdir+"/plots");
|
249 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<1; ifile++) {
|
250 |
|
|
plotDenomPt.AddToStack(hDenomPtv[ifile],labelv[ifile],colorv[ifile]);
|
251 |
|
|
}
|
252 |
|
|
plotDenomPt.TransLegend(0.1,0);
|
253 |
|
|
plotDenomPt.Draw(c,kTRUE,format);
|
254 |
|
|
|
255 |
|
|
plotDenomPt.SetName("denomptlog");
|
256 |
|
|
// plotDenomPt.SetLogy();
|
257 |
|
|
plotDenomPt.Draw(c,kTRUE,format);
|
258 |
|
|
|
259 |
|
|
sprintf(ylabel,"Events / %.1f",hDenomEtav[0]->GetBinWidth(1));
|
260 |
dkralph |
1.2 |
CPlot plotDenomEta("denometa","","denominator #eta",ylabel,ctrl.outdir+"/plots");
|
261 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<1; ifile++) {
|
262 |
|
|
plotDenomEta.AddToStack(hDenomEtav[ifile],labelv[ifile],colorv[ifile]);
|
263 |
|
|
}
|
264 |
|
|
plotDenomEta.SetYRange(0,2.0*(plotDenomEta.GetStack()->GetMaximum()));
|
265 |
|
|
plotDenomEta.Draw(c,kTRUE,format);
|
266 |
|
|
|
267 |
|
|
//
|
268 |
|
|
// Numerator distributions
|
269 |
|
|
//
|
270 |
|
|
sprintf(ylabel,"Events / %.1f GeV/c",hNumerPtv[0]->GetBinWidth(1));
|
271 |
dkralph |
1.2 |
CPlot plotNumerPt("numerpt","","numerator p_{T} [GeV/c]",ylabel,ctrl.outdir+"/plots");
|
272 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<1; ifile++) {
|
273 |
|
|
plotNumerPt.AddToStack(hNumerPtv[ifile],labelv[ifile],colorv[ifile]);
|
274 |
|
|
}
|
275 |
|
|
plotNumerPt.TransLegend(0.1,0);
|
276 |
|
|
plotNumerPt.Draw(c,kTRUE,format);
|
277 |
|
|
|
278 |
|
|
plotNumerPt.SetName("numerptlog");
|
279 |
|
|
// plotNumerPt.SetLogy();
|
280 |
|
|
plotNumerPt.Draw(c,kTRUE,format);
|
281 |
|
|
|
282 |
|
|
sprintf(ylabel,"Events / %.1f",hNumerEtav[0]->GetBinWidth(1));
|
283 |
dkralph |
1.2 |
CPlot plotNumerEta("numereta","","numerator #eta",ylabel,ctrl.outdir+"/plots");
|
284 |
dkralph |
1.1 |
for(UInt_t ifile=0; ifile<1; ifile++) {
|
285 |
|
|
plotNumerEta.AddToStack(hNumerEtav[ifile],labelv[ifile],colorv[ifile]);
|
286 |
|
|
}
|
287 |
|
|
plotNumerEta.SetYRange(0,2.0*(plotNumerEta.GetStack()->GetMaximum()));
|
288 |
|
|
plotNumerEta.Draw(c,kTRUE,format);
|
289 |
|
|
|
290 |
|
|
//
|
291 |
|
|
// Fakeable object kinematic distributions
|
292 |
|
|
//
|
293 |
|
|
sprintf(ylabel,"Events / %.1f GeV/c",hDenomPt0->GetBinWidth(1));
|
294 |
dkralph |
1.2 |
CPlot plotPt("pt","","p_{T} [GeV/c]",ylabel,ctrl.outdir+"/plots");
|
295 |
dkralph |
1.1 |
plotPt.AddHist1D(hDenomPt0,"loose","hist",kBlue,7);
|
296 |
|
|
plotPt.AddHist1D(hNumerPt0,"tight","hist",kRed);
|
297 |
|
|
plotPt.TransLegend(0.1,0);
|
298 |
|
|
plotPt.Draw(c,kTRUE,format);
|
299 |
|
|
|
300 |
|
|
plotPt.SetName("ptlog");
|
301 |
|
|
plotPt.SetYRange(1e-4*(hDenomPt0->GetMaximum()),10*(hDenomPt0->GetMaximum()));
|
302 |
|
|
// plotPt.SetLogy();
|
303 |
|
|
plotPt.Draw(c,kTRUE,format);
|
304 |
|
|
|
305 |
|
|
sprintf(ylabel,"Events / %.1f",hDenomEta0->GetBinWidth(1));
|
306 |
dkralph |
1.2 |
CPlot plotEta("eta","","#eta",ylabel,ctrl.outdir+"/plots");
|
307 |
dkralph |
1.1 |
plotEta.AddHist1D(hDenomEta0,"loose","hist",kBlue,7);
|
308 |
|
|
plotEta.AddHist1D(hNumerEta0,"tight","hist",kRed);
|
309 |
|
|
plotEta.SetYRange(0,2.0*(hDenomEta0->GetMaximum()));
|
310 |
|
|
plotEta.Draw(c,kTRUE,format);
|
311 |
|
|
|
312 |
|
|
//
|
313 |
|
|
// Fake rate plots
|
314 |
|
|
//
|
315 |
dkralph |
1.2 |
CPlot plotFRPt("frpt","","#scale[1.3]{p_{T} [GeV/c]}","#scale[1.5]{#varepsilon_{fake}}",ctrl.outdir+"/plots");
|
316 |
dkralph |
1.1 |
plotFRPt.AddGraph(frPt,"");
|
317 |
|
|
plotFRPt.SetYRange(0,yhigh1);
|
318 |
|
|
plotFRPt.AddTextBox(seletype+" "+tightness,0.25,0.75,0.45,0.85);
|
319 |
|
|
plotFRPt.Draw(c,kTRUE,format);
|
320 |
|
|
|
321 |
dkralph |
1.2 |
CPlot plotFREta("freta","",etalabel,"#scale[1.5]{#varepsilon_{fake}}",ctrl.outdir+"/plots");
|
322 |
dkralph |
1.1 |
plotFREta.AddGraph(frEta,"");
|
323 |
|
|
plotFREta.SetYRange(0,yhigh1);
|
324 |
|
|
plotFREta.AddTextBox(seletype+" "+tightness,0.25,0.75,0.45,0.85);
|
325 |
|
|
plotFREta.Draw(c,kTRUE,format);
|
326 |
|
|
|
327 |
|
|
// gStyle->SetPalette(1);
|
328 |
|
|
c->SetRightMargin(0.15);
|
329 |
|
|
c->SetLeftMargin(0.15);
|
330 |
|
|
frEtaPt->SetTitleOffset(1.2,"Y");
|
331 |
|
|
// TPaletteAxis *paxis = (TPaletteAxis*)frEtaPt->GetListOfFunctions()->FindObject("palette");
|
332 |
|
|
// paxis->SetX1NDC(0.87);
|
333 |
|
|
// paxis->SetX2NDC(0.92);
|
334 |
dkralph |
1.2 |
CPlot plotFRPtEta("frpteta","",etalabel,"p_{T} [GeV/c]",ctrl.outdir+"/plots");
|
335 |
dkralph |
1.1 |
plotFRPtEta.AddHist2D(frEtaPt,"COLZ");
|
336 |
|
|
plotFRPtEta.Draw(c,kTRUE,format);
|
337 |
|
|
|
338 |
|
|
//--------------------------------------------------------------------------------------------------------------
|
339 |
|
|
// Summary print out
|
340 |
|
|
//==============================================================================================================
|
341 |
|
|
|
342 |
dkralph |
1.2 |
TFile outfile(ctrl.outdir + TString("/fr.root"),"RECREATE");
|
343 |
dkralph |
1.1 |
frPt->Write();
|
344 |
|
|
frEta->Write();
|
345 |
|
|
frEtaPt->Write();
|
346 |
|
|
errlEtaPt->Write();
|
347 |
|
|
errhEtaPt->Write();
|
348 |
|
|
outfile.Close();
|
349 |
|
|
|
350 |
dkralph |
1.2 |
makeHTML(ctrl,ctrl.outdir);
|
351 |
dkralph |
1.1 |
|
352 |
dkralph |
1.2 |
cout << " <> Output saved in " << ctrl.outdir << "/" << endl;
|
353 |
dkralph |
1.1 |
cout << endl;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
|
357 |
|
|
//=== FUNCTION DEFINITIONS ======================================================================================
|
358 |
|
|
|
359 |
|
|
//--------------------------------------------------------------------------------------------------
|
360 |
dkralph |
1.2 |
TGraphAsymmErrors* computeFakeRate1D(const TH1D* hpass, const TH1D* htotal)
|
361 |
dkralph |
1.1 |
{
|
362 |
|
|
const Int_t nbins = htotal->GetNbinsX();
|
363 |
|
|
Double_t xval[nbins], xerr[nbins], yval[nbins], yerrl[nbins], yerrh[nbins];
|
364 |
|
|
for(Int_t ibin=1; ibin<=nbins; ibin++) {
|
365 |
|
|
xval[ibin-1] = htotal->GetBinCenter(ibin);
|
366 |
|
|
xerr[ibin-1] = 0.5*htotal->GetBinWidth(ibin);
|
367 |
|
|
|
368 |
|
|
Int_t total = htotal->GetBinContent(ibin);
|
369 |
|
|
Int_t passed = hpass->GetBinContent(ibin);
|
370 |
|
|
yval[ibin-1] = (total>0) ? (Double_t)passed/(Double_t)total : 0;
|
371 |
|
|
yerrl[ibin-1] = (total>0) ? yval[ibin-1] - TEfficiency::ClopperPearson(total,passed,0.68269,kFALSE) : 0;
|
372 |
|
|
yerrh[ibin-1] = (total>0) ? TEfficiency::ClopperPearson(total,passed,0.68269,kTRUE) - yval[ibin-1] : 0;
|
373 |
|
|
}
|
374 |
|
|
|
375 |
|
|
return new TGraphAsymmErrors(nbins,xval,yval,xerr,xerr,yerrl,yerrh);
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
//--------------------------------------------------------------------------------------------------
|
379 |
|
|
void computeFakeRate2D(const TH2D *hpass, const TH2D* htotal,
|
380 |
|
|
TH2D *hresult, TH2D* herrl, TH2D* herrh)
|
381 |
|
|
{
|
382 |
|
|
assert(hresult);
|
383 |
|
|
assert(herrl);
|
384 |
|
|
assert(herrh);
|
385 |
|
|
|
386 |
|
|
const Int_t nbinsx = htotal->GetNbinsX();
|
387 |
|
|
const Int_t nbinsy = htotal->GetNbinsY();
|
388 |
|
|
for(Int_t ix=1; ix<=nbinsx; ix++) {
|
389 |
|
|
for(Int_t iy=1; iy<=nbinsy; iy++) {
|
390 |
|
|
Int_t total = htotal->GetCellContent(ix,iy);
|
391 |
|
|
Int_t passed = hpass->GetCellContent(ix,iy);
|
392 |
|
|
Double_t eff = (total>0) ? (Double_t)passed/(Double_t)total : 0;
|
393 |
|
|
Double_t errl = (total>0) ? eff - TEfficiency::ClopperPearson(total,passed,0.68269,kFALSE) : 0;
|
394 |
|
|
Double_t errh = (total>0) ? TEfficiency::ClopperPearson(total,passed,0.68269,kTRUE) - eff : 0;
|
395 |
|
|
hresult->SetCellContent(ix,iy,eff);
|
396 |
|
|
herrl ->SetCellContent(ix,iy,errl);
|
397 |
|
|
herrh ->SetCellContent(ix,iy,errh);
|
398 |
|
|
}
|
399 |
|
|
}
|
400 |
|
|
}
|
401 |
|
|
|
402 |
|
|
//--------------------------------------------------------------------------------------------------
|
403 |
dkralph |
1.2 |
void makeHTML(FOFlags &ctrl, const TString outDir)
|
404 |
dkralph |
1.1 |
{
|
405 |
dkralph |
1.2 |
TString title(ctrl.inputdir);
|
406 |
|
|
title = title(title.Last('/')+1,title.Length());
|
407 |
dkralph |
1.1 |
ofstream htmlfile;
|
408 |
|
|
char htmlfname[100];
|
409 |
|
|
sprintf(htmlfname,"%s/fr.html",outDir.Data());
|
410 |
|
|
htmlfile.open(htmlfname);
|
411 |
dkralph |
1.2 |
|
412 |
dkralph |
1.1 |
htmlfile << "<!DOCTYPE html" << endl;
|
413 |
|
|
htmlfile << " PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
|
414 |
|
|
htmlfile << "<html>" << endl;
|
415 |
|
|
|
416 |
dkralph |
1.2 |
htmlfile << "<head><title>"+title+"</title></head>" << endl;
|
417 |
dkralph |
1.1 |
htmlfile << "<body bgcolor=\"EEEEEE\">" << endl;
|
418 |
dkralph |
1.2 |
htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
|
419 |
dkralph |
1.1 |
|
420 |
|
|
htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
|
421 |
|
|
htmlfile << "<tr>" << endl;
|
422 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frpteta.png\"><img src=\"plots/frpteta.png\" alt=\"plots/frpteta.png\" width=\"100%\"></a></td>" << endl;
|
423 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frpt.png\"><img src=\"plots/frpt.png\" alt=\"plots/frpt.png\" width=\"100%\"></a></td>" << endl;
|
424 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/freta.png\"><img src=\"plots/freta.png\" alt=\"plots/freta.png\" width=\"100%\"></a></td>" << endl;
|
425 |
dkralph |
1.2 |
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frphi.png\"><img src=\"plots/frphi.png\" alt=\"plots/frphi.png\" width=\"100%\"></a></td>" << endl;
|
426 |
dkralph |
1.1 |
htmlfile << "</tr>" << endl;
|
427 |
|
|
htmlfile << "<tr>" << endl;
|
428 |
dkralph |
1.2 |
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frnpv.png\"><img src=\"plots/frnpv.png\" alt=\"plots/frnpv.png\" width=\"100%\"></a></td>" << endl;
|
429 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frptnpv.png\"><img src=\"plots/frptnpv.png\" alt=\"plots/frptnpv.png\" width=\"100%\"></a></td>" << endl;
|
430 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fretanpv.png\"><img src=\"plots/fretanpv.png\" alt=\"plots/fretanpv.png\" width=\"100%\"></a></td>" << endl;
|
431 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frphinpv.png\"><img src=\"plots/frphinpv.png\" alt=\"plots/frphinpv.png\" width=\"100%\"></a></td>" << endl;
|
432 |
dkralph |
1.1 |
htmlfile << "</tr>" << endl;
|
433 |
|
|
htmlfile << "</table>" << endl;
|
434 |
|
|
htmlfile << "<hr />" << endl;
|
435 |
|
|
|
436 |
|
|
htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
|
437 |
|
|
htmlfile << "<tr>" << endl;
|
438 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/denompt.png\"><img src=\"plots/denompt.png\" alt=\"plots/denompt.png\" width=\"100%\"></a></td>" << endl;
|
439 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/denomptlog.png\"><img src=\"plots/denomptlog.png\" alt=\"plots/denomptlog.png\" width=\"100%\"></a></td>" << endl;
|
440 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/denometa.png\"><img src=\"plots/denometa.png\" alt=\"plots/denometa.png\" width=\"100%\"></a></td>" << endl;
|
441 |
dkralph |
1.2 |
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/denomphi.png\"><img src=\"plots/denomphi.png\" alt=\"plots/denomphi.png\" width=\"100%\"></a></td>" << endl;
|
442 |
dkralph |
1.1 |
htmlfile << "</tr>" << endl;
|
443 |
|
|
htmlfile << "<tr>" << endl;
|
444 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/numerpt.png\"><img src=\"plots/numerpt.png\" alt=\"plots/numerpt.png\" width=\"100%\"></a></td>" << endl;
|
445 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/numerptlog.png\"><img src=\"plots/numerptlog.png\" alt=\"plots/numerptlog.png\" width=\"100%\"></a></td>" << endl;
|
446 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/numereta.png\"><img src=\"plots/numereta.png\" alt=\"plots/numereta.png\" width=\"100%\"></a></td>" << endl;
|
447 |
dkralph |
1.2 |
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/numerphi.png\"><img src=\"plots/numerphi.png\" alt=\"plots/numerphi.png\" width=\"100%\"></a></td>" << endl;
|
448 |
dkralph |
1.1 |
htmlfile << "</tr>" << endl;
|
449 |
|
|
htmlfile << "<tr>" << endl;
|
450 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt.png\"><img src=\"plots/pt.png\" alt=\"plots/pt.png\" width=\"100%\"></a></td>" << endl;
|
451 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ptlog.png\"><img src=\"plots/ptlog.png\" alt=\"plots/ptlog.png\" width=\"100%\"></a></td>" << endl;
|
452 |
|
|
htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta.png\"><img src=\"plots/eta.png\" alt=\"plots/eta.png\" width=\"100%\"></a></td>" << endl;
|
453 |
dkralph |
1.2 |
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/phi.png\"><img src=\"plots/phi.png\" alt=\"plots/phi.png\" width=\"100%\"></a></td>" << endl;
|
454 |
dkralph |
1.1 |
htmlfile << "</tr>" << endl;
|
455 |
|
|
htmlfile << "</table>" << endl;
|
456 |
|
|
htmlfile << "<hr />" << endl;
|
457 |
|
|
|
458 |
|
|
htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
|
459 |
dkralph |
1.2 |
// htmlfile << "<tr>" << endl;
|
460 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/jetpt.png\"><img src=\"plots/jetpt.png\" alt=\"plots/jetpt.png\" width=\"100%\"></a></td>" << endl;
|
461 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/jetptlog.png\"><img src=\"plots/jetptlog.png\" alt=\"plots/jetptlog.png\" width=\"100%\"></a></td>" << endl;
|
462 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frjetpt.png\"><img src=\"plots/frjetpt.png\" alt=\"plots/frjetpt.png\" width=\"100%\"></a></td>" << endl;
|
463 |
|
|
// htmlfile << "<td width=\"25%\"></td>" << endl;
|
464 |
|
|
// htmlfile << "</tr>" << endl;
|
465 |
|
|
// htmlfile << "<tr>" << endl;
|
466 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fojetpt.png\"><img src=\"plots/fojetpt.png\" alt=\"plots/fojetpt.png\" width=\"100%\"></a></td>" << endl;
|
467 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fojetptlog.png\"><img src=\"plots/fojetptlog.png\" alt=\"plots/fojetptlog.png\" width=\"100%\"></a></td>" << endl;
|
468 |
|
|
// htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/frfojetpt.png\"><img src=\"plots/frfojetpt.png\" alt=\"plots/frfojetpt.png\" width=\"100%\"></a></td>" << endl;
|
469 |
|
|
// htmlfile << "<td width=\"25%\"></td>" << endl;
|
470 |
|
|
// htmlfile << "</tr>" << endl;
|
471 |
dkralph |
1.1 |
htmlfile << "</table>" << endl;
|
472 |
|
|
htmlfile << "<hr />" << endl;
|
473 |
|
|
|
474 |
|
|
htmlfile << "</body>" << endl;
|
475 |
|
|
htmlfile << "</html>" << endl;
|
476 |
|
|
htmlfile.close();
|
477 |
|
|
}
|