1 |
#include <iostream>
|
2 |
|
3 |
using namespace std;
|
4 |
|
5 |
float Get_Met_Z_Prediction(TCut JetCut, float MetCut, int isdata, bool isDYonly, bool isAachen);
|
6 |
|
7 |
namespace MetPlotsSpace {
|
8 |
float Zprediction_Uncertainty=0.2;
|
9 |
float OFprediction_Uncertainty=0.07;
|
10 |
float Zestimate__data=-1;
|
11 |
float Zestimate__data_sys=-1;
|
12 |
float Zestimate__data_stat=-1;
|
13 |
float Zestimate__mc=-1;
|
14 |
float Zestimate__mc_sys=-1;
|
15 |
float Zestimate__mc_stat=-1;
|
16 |
float Zestimate__dy=-1;
|
17 |
float Zestimate__dy_sys=-1;
|
18 |
float Zestimate__dy_stat=-1;
|
19 |
|
20 |
bool Debug=true;
|
21 |
}
|
22 |
|
23 |
void ExperimentalMetPrediction(bool QuickRun, bool isAachen, bool override_cuts=true);
|
24 |
void ProvideEEOverMMEstimate(TCut);
|
25 |
|
26 |
void makeOneRinoutPlot( TH2F* hrange, Int_t* bins, Int_t nBins, TString var, string name, bool doMC, TCut kCut = "" ) {
|
27 |
|
28 |
Float_t systematics = 0.25;
|
29 |
|
30 |
// mll settings
|
31 |
Int_t nbins = 100;
|
32 |
Float_t xmin = 20., xmax = 120.;
|
33 |
TCanvas* mycan = new TCanvas("mycan","Canvas");
|
34 |
mycan->SetLeftMargin(0.2);
|
35 |
mycan->SetLogy(0);
|
36 |
|
37 |
|
38 |
TCut kbase("pfJetGoodNum40>1&&pfJetGoodID[0]!=0"&&passtrig&&kCut);
|
39 |
TCut kSF("id1==id2");
|
40 |
TCut kOF("id1!=id2");
|
41 |
|
42 |
// Reference: inclusive selection
|
43 |
TCut kZP("pfJetGoodNum40==2");
|
44 |
TH1F* h1, *h1OF;
|
45 |
if ( !doMC ) {
|
46 |
h1 = allsamples.Draw("h1", "mll",nbins,xmin,xmax,"m_{ll}","events",kbase&&kZP&&kSF,data,luminosity);
|
47 |
h1OF = allsamples.Draw("h1OF","mll",nbins,xmin,xmax,"m_{ll}","events",kbase&&kZP&&kOF,data,luminosity);
|
48 |
} else {
|
49 |
h1 = allsamples.Draw("h1", "mll",nbins,xmin,xmax,"m_{ll}","events",kbase&&kZP&&kSF,mc,luminosity,allsamples.FindSample("Z_em"));
|
50 |
h1OF = allsamples.Draw("h1OF","mll",nbins,xmin,xmax,"m_{ll}","events",kbase&&kZP&&kOF,mc,luminosity,allsamples.FindSample("Z_em"));
|
51 |
}
|
52 |
|
53 |
Int_t minBinSR = h1->FindBin(20.);
|
54 |
Int_t maxBinSR = h1->FindBin(70.)-1;
|
55 |
|
56 |
Int_t minBinZP = h1->FindBin(81.);
|
57 |
Int_t maxBinZP = h1->FindBin(101.)-1;
|
58 |
|
59 |
dout << "Integrating SR from " << h1->GetBinLowEdge(minBinSR) << " to " << h1->GetBinLowEdge(maxBinSR)+h1->GetBinWidth(maxBinSR) << std::endl;
|
60 |
dout << "Integrating ZP from " << h1->GetBinLowEdge(minBinZP) << " to " << h1->GetBinLowEdge(maxBinZP)+h1->GetBinWidth(maxBinZP) << std::endl;
|
61 |
|
62 |
// Subtract OF
|
63 |
h1->Add(h1OF,-1);
|
64 |
h1->SetLineColor(kRed);
|
65 |
|
66 |
// Compute ratio
|
67 |
Double_t yZP, eyZP, ySR, eySR;
|
68 |
ySR = h1->IntegralAndError(minBinSR,maxBinSR,eySR);
|
69 |
yZP = h1->IntegralAndError(minBinZP,maxBinZP,eyZP);
|
70 |
dout << "Ratio: " << ySR/yZP << "+-" << computeRatioError(ySR,eySR,yZP,eyZP) << std::endl;
|
71 |
|
72 |
std::stringstream twoJetsLegend;
|
73 |
twoJetsLegend << std::setprecision(1) << std::fixed;
|
74 |
twoJetsLegend << "2-jets ratio: (" << ySR/yZP*100. << "#pm" << computeRatioError(ySR,eySR,yZP,eyZP)*100. << "#pm" << systematics*ySR/yZP*100. << ")%";
|
75 |
|
76 |
TLine* line = new TLine(hrange->GetXaxis()->GetXmin(),ySR/yZP,hrange->GetXaxis()->GetXmax(),ySR/yZP);
|
77 |
line->SetLineColor(kRed);
|
78 |
TBox* errorBox = new TBox(hrange->GetXaxis()->GetXmin(),ySR/yZP*(1-systematics),hrange->GetXaxis()->GetXmax(),ySR/yZP*(1+systematics));
|
79 |
errorBox->SetFillColor(kCyan);
|
80 |
errorBox->SetFillStyle(1001);
|
81 |
errorBox->SetLineColor(kWhite);
|
82 |
|
83 |
TGraphErrors* ratio = new TGraphErrors(nBins);
|
84 |
// Various cuts
|
85 |
for ( int ibin = 0; ibin<nBins; ++ibin ) {
|
86 |
std::stringstream cut;
|
87 |
cut << var << ">=" << bins[ibin];
|
88 |
if ( ibin+1<nBins ) cut << "&&" << var << "<" << bins[ibin+1];
|
89 |
TCut kadd(cut.str().c_str());
|
90 |
|
91 |
TH1F* h2, *h2OF;
|
92 |
if ( !doMC ) {
|
93 |
h2 = allsamples.Draw("h2", "mll",nbins,xmin,xmax,"var","events",kbase&&kadd&&kSF,data,luminosity);
|
94 |
h2OF = allsamples.Draw("h2OF","mll",nbins,xmin,xmax,"var","events",kbase&&kadd&&kOF,data,luminosity);
|
95 |
} else {
|
96 |
h2 = allsamples.Draw("h2", "mll",nbins,xmin,xmax,"var","events",kbase&&kadd&&kSF,mc,luminosity,allsamples.FindSample("Z_em"));
|
97 |
h2OF = allsamples.Draw("h2OF","mll",nbins,xmin,xmax,"var","events",kbase&&kadd&&kOF,mc,luminosity,allsamples.FindSample("Z_em"));
|
98 |
}
|
99 |
h2->Add(h2OF,-1);
|
100 |
h2->SetLineColor(kBlue);
|
101 |
|
102 |
ySR = h2->IntegralAndError(minBinSR,maxBinSR,eySR);
|
103 |
yZP = h2->IntegralAndError(minBinZP,maxBinZP,eyZP);
|
104 |
|
105 |
if ( ibin+1<nBins ) {
|
106 |
ratio->SetPoint(ibin,(bins[ibin+1]+bins[ibin])/2.0,ySR/yZP);
|
107 |
ratio->SetPointError(ibin,(bins[ibin+1]-bins[ibin])/2.0,computeRatioError(ySR,eySR,yZP,eyZP));
|
108 |
} else {
|
109 |
Float_t width = ratio->GetErrorX(ibin-1);
|
110 |
ratio->SetPoint(ibin,bins[ibin]+width,ySR/yZP);
|
111 |
ratio->SetPointError(ibin,width,computeRatioError(ySR,eySR,yZP,eyZP));
|
112 |
}
|
113 |
|
114 |
dout << "Ratio " << cut.str() << ": " << ySR/yZP << "+-" << computeRatioError(ySR,eySR,yZP,eyZP) << std::endl;
|
115 |
|
116 |
h2->Delete();
|
117 |
h2OF->Delete();
|
118 |
|
119 |
}
|
120 |
|
121 |
std::stringstream syserrLegend;
|
122 |
syserrLegend << std::setprecision(0) << std::fixed << systematics*100. << "% systematic unc.";
|
123 |
|
124 |
hrange->GetYaxis()->SetTitleOffset(1.3);
|
125 |
hrange->GetYaxis()->SetDecimals(kTRUE);
|
126 |
hrange->Draw();
|
127 |
errorBox->Draw();
|
128 |
line->Draw();
|
129 |
ratio->Draw("P");
|
130 |
|
131 |
TLegend* legend = new TLegend(0.25,0.6,0.8,0.9);
|
132 |
legend->SetFillStyle(0);
|
133 |
legend->SetBorderSize(0);
|
134 |
if ( doMC ) legend->AddEntry(ratio,"DY Z+jets MC","lp");
|
135 |
else legend->AddEntry(ratio,"Data","lp");
|
136 |
legend->AddEntry(line,twoJetsLegend.str().c_str(),"l");
|
137 |
legend->AddEntry(errorBox,syserrLegend.str().c_str(),"f");
|
138 |
legend->Draw();
|
139 |
|
140 |
mycan->RedrawAxis();
|
141 |
if (!doMC) DrawPrelim();
|
142 |
else DrawMCPrelim();
|
143 |
|
144 |
CompleteSave(mycan,"MetPlots/Zlineshape_vs_"+name+(doMC?"_mc_":""));
|
145 |
|
146 |
h1->Delete();
|
147 |
h1OF->Delete();
|
148 |
delete mycan;
|
149 |
|
150 |
}
|
151 |
|
152 |
int zlineshapeMet(bool doMC=true, string suffix="", float ymax = 0.2, TCut kCut = "" ) {
|
153 |
|
154 |
TH2F* hrange = new TH2F("hrange","Range ; MET [GeV] ; Ratio low mass / Z peak",2,-1,61,2,0,ymax);
|
155 |
Int_t metBins[] = { 0, 10, 20, 30, 40, 50 };
|
156 |
Int_t nMetBins = sizeof(metBins)/sizeof(Int_t);
|
157 |
makeOneRinoutPlot( hrange, metBins, nMetBins, "met[4]/MetFactor", "met"+suffix, doMC, kCut );
|
158 |
hrange->Delete();
|
159 |
return 0;
|
160 |
|
161 |
}
|
162 |
|
163 |
int zlineshapeJets(bool doMC=true, string suffix="", float ymax = 0.2, TCut kCut = "" ) {
|
164 |
TH2F* hrange = new TH2F("hrange","Range ; #(jets) ; Ratio low mass / Z peak",2,1.9,6.1,2,0,ymax);
|
165 |
Int_t bins[] = { 2, 3, 4, 5 };
|
166 |
|
167 |
Int_t nBins = sizeof(bins)/sizeof(Int_t);
|
168 |
makeOneRinoutPlot( hrange, bins, nBins, "pfJetGoodNum40", "njets"+suffix, doMC, kCut );
|
169 |
hrange->Delete();
|
170 |
return 0;
|
171 |
|
172 |
}
|
173 |
|
174 |
int zlineshapes(string suffix = "", TCut cut="" ) {
|
175 |
|
176 |
dout << "--- Calculating R_in/out" << std::endl;
|
177 |
zlineshapeMet(false,suffix,0.2,cut);
|
178 |
zlineshapeJets(false,suffix,0.2,cut);
|
179 |
zlineshapeMet(true,suffix,0.2,cut);
|
180 |
zlineshapeJets(true,suffix,0.2,cut);
|
181 |
dout << "--- DONE (Calculating R_in/out)" << std::endl;
|
182 |
|
183 |
return 0;
|
184 |
}
|
185 |
|
186 |
void ExtractScaleFactor(TH1F *mllSF,TH1F *mllOF, THStack* mcMllSF, THStack* mcMllOF, TH1F *prediction, TLegend *leg, string saveasSig, TBox *srbox) {
|
187 |
Int_t minbin = mllSF->FindBin(20.);
|
188 |
Int_t maxbin = mllSF->FindBin(70.-1);
|
189 |
|
190 |
// Get yields in OF region
|
191 |
Float_t iDataOF = mllOF->Integral();
|
192 |
Float_t iDataOFSR = mllOF->Integral(minbin,maxbin);
|
193 |
Float_t iMCOF = 0.0;
|
194 |
Float_t iMCOFSR = 0.0;
|
195 |
TIter nextOF(mcMllOF->GetHists());
|
196 |
TH1F* h;
|
197 |
while ( h = (TH1F*)nextOF() ) {
|
198 |
iMCOF += h->Integral();
|
199 |
iMCOFSR += h->Integral(minbin,maxbin);
|
200 |
}
|
201 |
Float_t scale = iDataOF/iMCOF;
|
202 |
|
203 |
// Re-scale OF
|
204 |
nextOF = TIter(mcMllOF->GetHists());
|
205 |
|
206 |
while ( h = (TH1F*)nextOF() ) {
|
207 |
h->Scale(scale);
|
208 |
}
|
209 |
|
210 |
nextOF = TIter(mcMllOF->GetHists());
|
211 |
|
212 |
// Rescale SF and count in signal region
|
213 |
dout << "Integrating from " << mllSF->GetBinLowEdge(minbin) << " to " << mllSF->GetBinLowEdge(maxbin)+mllSF->GetBinWidth(maxbin) << std::endl;
|
214 |
|
215 |
Float_t iDataSFSR = mllSF->Integral(minbin,maxbin);
|
216 |
Float_t iMCSFSR = 0.0;
|
217 |
TIter nextSF = TIter(mcMllSF->GetHists());
|
218 |
while ( h = (TH1F*)nextSF() ) {
|
219 |
h->Scale(scale);
|
220 |
iMCSFSR += h->Integral(minbin,maxbin);
|
221 |
}
|
222 |
|
223 |
nextSF = TIter(mcMllSF->GetHists());
|
224 |
while ( h = (TH1F*)nextSF() ) {
|
225 |
iMCSFSR += h->Integral(minbin,maxbin);
|
226 |
}
|
227 |
mcMllSF->Modified();
|
228 |
|
229 |
TPad* rcan2 = new TPad("rcan2","rcan2",0,0,1,1);
|
230 |
rcan2->cd();
|
231 |
mllSF->Draw();
|
232 |
mcMllSF->Draw("histo,same");
|
233 |
prediction->Draw("histo,same");
|
234 |
mllSF->Draw("same");
|
235 |
DrawPrelim();
|
236 |
stringstream leghead;
|
237 |
leghead << "MC scaled by " << std::setprecision(2) << scale << "";
|
238 |
dout << "SCALE: " << scale << endl;
|
239 |
TH1F *histo = new TH1F("histo","histo",1,0,1);histo->SetLineColor(kWhite);
|
240 |
leg->AddEntry(histo,leghead.str().c_str(),"l");
|
241 |
leg->Draw();
|
242 |
srbox->Draw();
|
243 |
stringstream saveasSig2;
|
244 |
saveasSig2 << saveasSig << "__mcScaled";
|
245 |
rcan2->Update();
|
246 |
Save_With_Ratio( mllSF, *mcMllSF, rcan2, saveasSig2.str() );
|
247 |
|
248 |
// restore original stacks
|
249 |
nextOF = TIter(mcMllOF->GetHists());
|
250 |
|
251 |
while ( h = (TH1F*)nextOF() ) {
|
252 |
h->Scale(1/scale);
|
253 |
}
|
254 |
|
255 |
nextSF = TIter(mcMllSF->GetHists());
|
256 |
while ( h = (TH1F*)nextSF() ) {
|
257 |
h->Scale(1/scale);
|
258 |
}
|
259 |
mcMllSF->Modified();
|
260 |
mcMllOF->Modified();
|
261 |
|
262 |
}
|
263 |
|
264 |
TGraphErrors* MakeErrorGraph(TH1F *histo) {
|
265 |
|
266 |
float dx[histo->GetNbinsX()];
|
267 |
float dy[histo->GetNbinsX()];
|
268 |
float x[histo->GetNbinsX()];
|
269 |
float y[histo->GetNbinsX()];
|
270 |
for(int i=1;i<=histo->GetNbinsX();i++) {
|
271 |
x[i-1]=histo->GetBinCenter(i);
|
272 |
y[i-1]=histo->GetBinContent(i);
|
273 |
if(i>1) dx[i-1]=(histo->GetBinCenter(i)-histo->GetBinCenter(i-1))/2.0;
|
274 |
else dx[i-1]=(histo->GetBinCenter(i+1)-histo->GetBinCenter(i))/2.0;
|
275 |
dy[i-1]=histo->GetBinError(i);
|
276 |
}
|
277 |
|
278 |
TGraphErrors *gr = new TGraphErrors(histo->GetNbinsX(),x,y,dx,dy);
|
279 |
gr->SetFillColor(TColor::GetColor("#2E9AFE"));
|
280 |
return gr;
|
281 |
}
|
282 |
|
283 |
TGraphErrors* MakeErrorGraphSystematicAndStatistical(TH1F *ofpred, TH1F *sfpred, TH1F *prediction, TH1F *SystHisto) {
|
284 |
|
285 |
float dx[ofpred->GetNbinsX()];
|
286 |
float dy[ofpred->GetNbinsX()];
|
287 |
float x[ofpred->GetNbinsX()];
|
288 |
float y[ofpred->GetNbinsX()];
|
289 |
for(int i=1;i<=ofpred->GetNbinsX();i++) {
|
290 |
x[i-1]=prediction->GetBinCenter(i);
|
291 |
y[i-1]=prediction->GetBinContent(i);
|
292 |
if(i>1) dx[i-1]=(prediction->GetBinCenter(i)-prediction->GetBinCenter(i-1))/2.0;
|
293 |
else dx[i-1]=(prediction->GetBinCenter(i+1)-prediction->GetBinCenter(i))/2.0;
|
294 |
if(ofpred->GetBinCenter(i)>20 && ofpred->GetBinCenter(i)<70) {
|
295 |
//need to increase uncertainty by 5% due to extrapolation
|
296 |
dy[i-1] = (MetPlotsSpace::Zprediction_Uncertainty+0.05)*(MetPlotsSpace::Zprediction_Uncertainty+0.05)*sfpred->GetBinContent(i)*sfpred->GetBinContent(i); //systematic for Z+Jets prediction
|
297 |
} else {
|
298 |
dy[i-1] = MetPlotsSpace::Zprediction_Uncertainty*MetPlotsSpace::Zprediction_Uncertainty*sfpred->GetBinContent(i)*sfpred->GetBinContent(i); //systematic for Z+Jets prediction
|
299 |
}
|
300 |
dy[i-1]+= MetPlotsSpace::OFprediction_Uncertainty*MetPlotsSpace::OFprediction_Uncertainty* ofpred->GetBinContent(i) * ofpred->GetBinContent(i); //systematic for OF prediction
|
301 |
float sys=sqrt(dy[i-1])/prediction->GetBinContent(i);
|
302 |
if(prediction->GetBinContent(i)==0) sys=0.0;
|
303 |
if(sys!=sys || sys<0) sys=0;
|
304 |
SystHisto->SetBinContent(i,sys);
|
305 |
dy[i-1]+= prediction->GetBinError(i) * prediction->GetBinError(i); // plus statistical!
|
306 |
dy[i-1]=sqrt(dy[i-1]);
|
307 |
}
|
308 |
|
309 |
TGraphErrors *gr = new TGraphErrors(ofpred->GetNbinsX(),x,y,dx,dy);
|
310 |
gr->SetFillColor(TColor::GetColor("#2E9AFE"));//blue
|
311 |
// gr->SetFillColor(TColor::GetColor("#FF8000"));//orange
|
312 |
return gr;
|
313 |
}
|
314 |
|
315 |
|
316 |
float DetectEtaCut() {
|
317 |
string Sbasicqualitycut = (const char*) basicqualitycut;
|
318 |
|
319 |
if ((int)Sbasicqualitycut.find(")<1.4")>1) return 1.4;
|
320 |
if ((int)Sbasicqualitycut.find(")<2.4")>1) return 2.4;
|
321 |
|
322 |
string Sbasiccut = (const char*)basiccut;
|
323 |
if ((int)Sbasiccut.find(")<1.4")>1) return 1.4;
|
324 |
if ((int)Sbasiccut.find(")<2.4")>1) return 2.4;
|
325 |
|
326 |
string Sessentialcut = (const char*)essentialcut;
|
327 |
if ((int)Sessentialcut.find(")<1.4")>1) return 1.4;
|
328 |
if ((int)Sessentialcut.find(")<2.4")>1) return 2.4;
|
329 |
|
330 |
string Sleptoncut = (const char*)leptoncut;
|
331 |
if ((int)Sleptoncut.find(")<1.4")>1) return 1.4;
|
332 |
if ((int)Sleptoncut.find(")<2.4")>1) return 2.4;
|
333 |
}
|
334 |
|
335 |
|
336 |
float GetAppropriateZestimate(bool isAachen) {
|
337 |
|
338 |
bool IsInclusiveEtaRange=false;
|
339 |
|
340 |
|
341 |
if(Contains((const char*) basicqualitycut,"<2.4")) IsInclusiveEtaRange=true;
|
342 |
if(Contains((const char*) essentialcut,"<2.4")) IsInclusiveEtaRange=true;
|
343 |
if(Contains((const char*) basiccut,"<2.4")) IsInclusiveEtaRange=true;
|
344 |
if(Contains((const char*) leptoncut,"<2.4")) IsInclusiveEtaRange=true;
|
345 |
if(Contains((const char*) essential,"<2.4")) IsInclusiveEtaRange=true;
|
346 |
|
347 |
if(IsInclusiveEtaRange && isAachen) {
|
348 |
// ab , aachen
|
349 |
MetPlotsSpace::Zestimate__data=39;
|
350 |
MetPlotsSpace::Zestimate__data_stat=9;
|
351 |
return 39;
|
352 |
}
|
353 |
|
354 |
if(IsInclusiveEtaRange && !isAachen) {
|
355 |
// ab , eth
|
356 |
MetPlotsSpace::Zestimate__data=53;
|
357 |
MetPlotsSpace::Zestimate__data_stat=10;
|
358 |
return 53;
|
359 |
}
|
360 |
|
361 |
if(!IsInclusiveEtaRange && isAachen) {
|
362 |
// a , aachen
|
363 |
MetPlotsSpace::Zestimate__data=29;
|
364 |
MetPlotsSpace::Zestimate__data_stat=7;
|
365 |
return 29;
|
366 |
}
|
367 |
|
368 |
if(!IsInclusiveEtaRange && !isAachen) {
|
369 |
// a , eth
|
370 |
MetPlotsSpace::Zestimate__data=38;
|
371 |
MetPlotsSpace::Zestimate__data_stat=8;
|
372 |
return 38;
|
373 |
}
|
374 |
}
|
375 |
|
376 |
void ProduceMetPlotsWithCut(bool isAachen, TCut cut, string name, float cutat, int njets, bool doMC = false, float ymax = 80 ) {
|
377 |
|
378 |
dout << " *-*-*-*-*-*-*-*- " << __FUNCTION__ << " *-*-*-*-*-*-*-*- " << endl;
|
379 |
|
380 |
ofstream NiceSummary;
|
381 |
NiceSummary.open("Summary.txt",ios::app);
|
382 |
|
383 |
NiceSummary << " *********************************" << endl;
|
384 |
time_t t = time(0); // get time now
|
385 |
struct tm * now = localtime( & t );
|
386 |
NiceSummary << "run on : " << now->tm_hour << ":" << now->tm_min << " on " << now->tm_mday << "." << (now->tm_mon + 1) << "." << (now->tm_year + 1900) << endl;
|
387 |
NiceSummary << "Cut : " << (const char*) cut << endl;
|
388 |
NiceSummary << "Name : " << name << endl;
|
389 |
bool UseSpecialZprediction=false;
|
390 |
|
391 |
TText *sel = WriteSelection(njets);
|
392 |
if(cutat==100 && name=="") {
|
393 |
UseSpecialZprediction=true;
|
394 |
bool ReRunEstimate=false;
|
395 |
//need to check if the results have already been stored; if not, need to get the estimate!
|
396 |
if(MetPlotsSpace::Zestimate__data<0) ReRunEstimate=true;
|
397 |
if(MetPlotsSpace::Zestimate__data_stat<0) ReRunEstimate=true;
|
398 |
if(MetPlotsSpace::Zestimate__data_sys<0) ReRunEstimate=true;
|
399 |
if(MetPlotsSpace::Zestimate__mc<0) ReRunEstimate=true;
|
400 |
if(MetPlotsSpace::Zestimate__mc_stat<0) ReRunEstimate=true;
|
401 |
if(MetPlotsSpace::Zestimate__mc_sys<0) ReRunEstimate=true;
|
402 |
if(MetPlotsSpace::Zestimate__dy<0) ReRunEstimate=true;
|
403 |
if(MetPlotsSpace::Zestimate__dy_stat<0) ReRunEstimate=true;
|
404 |
if(MetPlotsSpace::Zestimate__dy_sys<0) ReRunEstimate=true;
|
405 |
dout << "****************** About to do Z prediction " << endl;
|
406 |
write_info(__FUNCTION__,"Not using recomputation but using global values");
|
407 |
//if(ReRunEstimate) ExperimentalMetPrediction(true,isAachen);//doing quick run (i.e. only data)
|
408 |
dout << "****************** Done predicting the Z " << endl;
|
409 |
}
|
410 |
|
411 |
|
412 |
TCanvas *tcan = new TCanvas("tcan","tcan");
|
413 |
dout << "Doing met plots" << endl;
|
414 |
stringstream MetBaseCuts;
|
415 |
MetBaseCuts << "met[4]/MetFactor>" << cutat << "&&" << cut.GetTitle() << " && mll>20";
|
416 |
stringstream snjets;
|
417 |
snjets << njets;
|
418 |
TCut MetBaseCut(MetBaseCuts.str().c_str());
|
419 |
TCut nJetsSignal(PlottingSetup::basicqualitycut&&TCut(("pfJetGoodNum40>="+snjets.str()).c_str())&&TCut("mll>20"));
|
420 |
TCut nJetsControl(PlottingSetup::basiccut&&"met[4]/MetFactor>100&&met[4]/MetFactor<150&&pfJetGoodID[0]!=0&&pfJetGoodNum40==2&&mll>20"); // Common CR (modulo lepton selection)
|
421 |
//TCut nJetsControl(PlottingSetup::basiccut&&"met[4]/MetFactor>75&&met[4]/MetFactor<150&&pfJetGoodNumBtag30>0&&pfJetGoodID[0]!=0&&pfJetGoodNum40==2"); // Alternative CR
|
422 |
|
423 |
//compute SF / OF rate in (CR1+CR2), should give 0.941 +/- 0.05
|
424 |
|
425 |
// Create histograms
|
426 |
//int nbins = 30;
|
427 |
int nbins = 60-4;
|
428 |
float xmin=20., xmax = 300.;
|
429 |
|
430 |
//with extra fine binning for zline shape scaling
|
431 |
TH1F *mllsigFine = allsamples.Draw("mllsigFine","mll",int(xmax-xmin),xmin,xmax,"m_{ee} [GeV]","events",cutOSSF&&MetBaseCut&&nJetsSignal,data,PlottingSetup::luminosity);
|
432 |
TH1F *mllOsigFine = allsamples.Draw("mllOsigFine","mll",int(xmax-xmin),xmin,xmax,"m_{ee} [GeV]","events",cutOSOF&&MetBaseCut&&nJetsSignal,data,PlottingSetup::luminosity);
|
433 |
|
434 |
TH1F *mllsconFine = allsamples.Draw("mllsconFine","mll",int(xmax-xmin),xmin,xmax,"m_{ll} [GeV]", "events",cutOSSF&&cut&&nJetsControl,data,PlottingSetup::luminosity);
|
435 |
TH1F *mllOsconFine = allsamples.Draw("mllOsconFine","mll",int(xmax-xmin),xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&cut&&nJetsControl),data,PlottingSetup::luminosity);
|
436 |
|
437 |
TH1F *mllsigEE = allsamples.Draw("mllsigEE","mll",nbins,xmin,xmax,"m_{ee} [GeV]", "events",cutOSSF&&MetBaseCut&&nJetsSignal&&TCut("id1==0"),data,PlottingSetup::luminosity);
|
438 |
TH1F *mllsigMM = allsamples.Draw("mllsigMM","mll",nbins,xmin,xmax,"m_{#mu#mu} [GeV]","events",cutOSSF&&MetBaseCut&&nJetsSignal&&TCut("id1==1"),data,PlottingSetup::luminosity);
|
439 |
TH1F *mllsconEE = allsamples.Draw("mllsconEE","mll",nbins,xmin,xmax,"m_{ll} [GeV]", "events",cutOSSF&&cut&&nJetsControl&&TCut("id1==0"),data,PlottingSetup::luminosity);
|
440 |
TH1F *mllsconMM = allsamples.Draw("mllsconMM","mll",nbins,xmin,xmax,"m_{ll} [GeV]", "events",cutOSSF&&cut&&nJetsControl&&TCut("id1==1"),data,PlottingSetup::luminosity);
|
441 |
TH1F *mllOsigEM = allsamples.Draw("mllOsigEM", "mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",cutOSOF&&MetBaseCut&&nJetsSignal&&TCut("id1==0"),data,PlottingSetup::luminosity);
|
442 |
TH1F *mllOsigME = allsamples.Draw("mllOsigME", "mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",cutOSOF&&MetBaseCut&&nJetsSignal&&TCut("id1==1"),data,PlottingSetup::luminosity);
|
443 |
TH1F *mllOsconEM = allsamples.Draw("mllOsconEM","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&cut&&nJetsControl&&TCut("id1==0")),data,PlottingSetup::luminosity);
|
444 |
TH1F *mllOsconME = allsamples.Draw("mllOsconME","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&cut&&nJetsControl&&TCut("id1==1")),data,PlottingSetup::luminosity);
|
445 |
TH1F *ptsig = allsamples.Draw("ptsig", "pt",40,xmin,400,"m_{T}^{ll} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal),data,PlottingSetup::luminosity);
|
446 |
TH1F *ptOsig = allsamples.Draw("ptOsig", "pt",40,xmin,400,"p_{T}^{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsSignal),data,PlottingSetup::luminosity);
|
447 |
TH1F *mllscon = (TH1F*)mllsconEE->Clone("mllscon");
|
448 |
|
449 |
mllscon->Add(mllsconMM);
|
450 |
TH1F *mllOscon = (TH1F*)mllOsconEM->Clone("mllOscon");
|
451 |
mllOscon->Add(mllOsconME);
|
452 |
TH1F *mllOsig = (TH1F*)mllOsigEM->Clone("mllOsig");
|
453 |
mllOsig->Add(mllOsigME);
|
454 |
|
455 |
TH1F* mllsig = (TH1F*)mllsigEE->Clone("mllsig");
|
456 |
mllsig->Add(mllsigMM);
|
457 |
mllsig->GetXaxis()->SetTitle("m_{ll} [GeV]");
|
458 |
|
459 |
THStack *mcMllsig, *mcMllsigEE,*mcMllsigMM,*mcMllscon,*mcMllsconEE,*mcMllsconMM, *mcMllOsig, *mcMllOscon, *mcptsig, *mcptOsig;
|
460 |
if ( doMC ) {
|
461 |
name += "_mc";
|
462 |
mcMllsig = new THStack(allsamples.DrawStack("mcMllsig","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
463 |
mcMllsigEE = new THStack(allsamples.DrawStack("mcMllsigEE","mll",nbins,xmin,xmax,"m_{ee} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==0"),mc,PlottingSetup::luminosity));
|
464 |
mcMllsigMM = new THStack(allsamples.DrawStack("mcMllsigMM","mll",nbins,xmin,xmax,"m_{#mu#mu} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==1"),mc,PlottingSetup::luminosity));
|
465 |
mcMllscon = new THStack(allsamples.DrawStack("mcMllscon","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSSF&&cut&&nJetsControl),mc,PlottingSetup::luminosity));
|
466 |
mcMllOsig = new THStack(allsamples.DrawStack("mcMllOsig","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
467 |
mcMllOscon= new THStack(allsamples.DrawStack("mcMllOscon","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&cut&&nJetsControl),mc,PlottingSetup::luminosity));
|
468 |
mcptsig = new THStack(allsamples.DrawStack("mcptsig", "pt",40,xmin,400,"m_{T}^{ll} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
469 |
mcptOsig = new THStack(allsamples.DrawStack("mcptOsig", "pt",40,xmin,400,"p_{T}^{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
470 |
}
|
471 |
|
472 |
|
473 |
if ( doMC ) {
|
474 |
write_info(__FUNCTION__,"Writing yields in MC");
|
475 |
dout << "Signal region, low mass " << endl;
|
476 |
WriteYield(mcMllsig,20,70);
|
477 |
WriteYield(mcMllOsig,20,70);
|
478 |
dout << "Signal region, high mass " << endl;
|
479 |
WriteYield(mcMllsig,120,1000);
|
480 |
WriteYield(mcMllOsig,120,1000);
|
481 |
THStack *sdata = new THStack();
|
482 |
sdata->Add(mllsig);
|
483 |
THStack *sodata = new THStack();
|
484 |
sodata->Add(mllOsig);
|
485 |
dout << "NOW ALL DATA **** " << endl;
|
486 |
dout << "Signal region, low mass " << endl;
|
487 |
dout << "SF : " << endl;
|
488 |
WriteYield(sdata,20,70);
|
489 |
dout << endl;
|
490 |
dout << "OF : " << endl;
|
491 |
WriteYield(sodata,20,70);
|
492 |
dout << "Signal region, high mass " << endl;
|
493 |
dout << "SF : " << endl;
|
494 |
WriteYield(sdata,120,1000);
|
495 |
dout << endl;
|
496 |
dout << "OF : " << endl;
|
497 |
WriteYield(sodata,120,1000);
|
498 |
}
|
499 |
|
500 |
if(doMC) {
|
501 |
TH1F *mllsigt = allsamples.Draw("mllsigt","mll",300,0,300,"m_{#mu#mu} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal),data,PlottingSetup::luminosity);
|
502 |
THStack *mcMllsigt = new THStack(allsamples.DrawStack("mcMllsigt","mll",300,0,300,"m_{ll} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
503 |
ProduceYields(20,70,mllsigt,mcMllsigt);
|
504 |
ProduceYields(91-10,91+10,mllsigt,mcMllsigt);
|
505 |
write_warning(__FUNCTION__,"WATCH OUT Z REGION HAS BEEN DEACTIVATED");
|
506 |
cout << (const char*) TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==0") << endl;
|
507 |
delete mllsigt;
|
508 |
delete mcMllsigt;
|
509 |
}
|
510 |
|
511 |
mllOsig->SetLineColor(kRed);
|
512 |
mllOscon->SetLineColor(kRed);
|
513 |
|
514 |
TH1F *zlineshape = allsamples.Draw("zlineshape","mll",nbins,xmin,xmax,"m_{ll} (GeV)","events",cutOSSF&&TCut("pfJetGoodNum40==2")&&cut,data,PlottingSetup::luminosity);
|
515 |
TH1F *Ozlineshape = allsamples.Draw("Ozlineshape","mll",nbins,xmin,xmax,"m_{ll} (GeV)","events",cutOSOF&&TCut("pfJetGoodNum40==2")&&cut,data,PlottingSetup::luminosity);
|
516 |
zlineshape->Add(Ozlineshape,-1);
|
517 |
TH1F *zlineshapeControl = (TH1F*)zlineshape->Clone("zlineshapeControl");
|
518 |
|
519 |
TH1F *zlineshapeFine = allsamples.Draw("zlineshapeFine","mll",int(xmax-xmin),xmin,xmax,"m_{ll} (GeV)","events",cutOSSF&&TCut("pfJetGoodNum40==2")&&cut,data,PlottingSetup::luminosity);
|
520 |
TH1F *OzlineshapeFine = allsamples.Draw("OzlineshapeFine","mll",int(xmax-xmin),xmin,xmax,"m_{ll} (GeV)","events",cutOSOF&&TCut("pfJetGoodNum40==2")&&cut,data,PlottingSetup::luminosity);
|
521 |
zlineshapeFine->Add(OzlineshapeFine,-1);
|
522 |
|
523 |
TH1F *zlineshapeControlFine = (TH1F*)zlineshapeFine->Clone("zlineshapeControlFine");
|
524 |
|
525 |
//
|
526 |
// float scalefactor = Get_Met_Z_Prediction(nJetsSignal,cutat, data, false) / (zlineshapeFINE->Integral(zlineshapeFINE->FindBin(91.1-20),zlineshapeFINE->FindBin(91.1+20)));
|
527 |
// float scalefactor_Control = Get_Met_Z_Prediction(nJetsControl,cutat, data, false) / (zlineshapeFINE->Integral(zlineshapeFINE->FindBin(91.1-20),zlineshapeFINE->FindBin(91.1+20)));
|
528 |
// delete zlineshapeFINE;
|
529 |
|
530 |
|
531 |
Int_t scaleBinLow = mllsigFine->FindBin(81);
|
532 |
Int_t scaleBinHigh = mllsigFine->FindBin(101);
|
533 |
float scalefactor = (mllsigFine->Integral(scaleBinLow,scaleBinHigh)-mllOsigFine->Integral(scaleBinLow,scaleBinHigh));
|
534 |
scalefactor /= zlineshapeFine->Integral(scaleBinLow,scaleBinHigh);
|
535 |
|
536 |
float scalefactor_Control = (mllsconFine->Integral(scaleBinLow,scaleBinHigh)-mllOsconFine->Integral(scaleBinLow,scaleBinHigh));
|
537 |
scalefactor_Control /= zlineshapeControlFine->Integral(scaleBinLow,scaleBinHigh);
|
538 |
|
539 |
if(UseSpecialZprediction) {
|
540 |
scaleBinLow = mllsigFine->FindBin(81);
|
541 |
scaleBinHigh = mllsigFine->FindBin(101);
|
542 |
scalefactor = GetAppropriateZestimate(isAachen)/ (zlineshapeFine->Integral(scaleBinLow,scaleBinHigh));
|
543 |
dout << "Dividing: " << MetPlotsSpace::Zestimate__data << " by " << (zlineshapeFine->Integral(scaleBinLow,scaleBinHigh)) << endl;
|
544 |
write_warning(__FUNCTION__,"Not using JZB prediction for control region!");
|
545 |
}
|
546 |
|
547 |
dout << "Bins for scaling : " << scaleBinLow << " : " << scaleBinHigh << endl;
|
548 |
|
549 |
dout << "Scale factors : " << scalefactor << " : " << scalefactor_Control << endl;
|
550 |
if(UseSpecialZprediction) dout << " NOTE: Used JZB prediction for scaling! (Bins )" << scaleBinLow << " to " << scaleBinHigh << endl;
|
551 |
|
552 |
zlineshape->Scale(scalefactor);
|
553 |
|
554 |
zlineshape->SetLineColor(kBlue);
|
555 |
zlineshape->SetLineStyle(2);
|
556 |
|
557 |
zlineshapeControl->Scale(scalefactor_Control);
|
558 |
zlineshapeControl->SetLineColor(kBlue);
|
559 |
zlineshapeControl->SetLineStyle(2);
|
560 |
|
561 |
|
562 |
if(UseSpecialZprediction) {
|
563 |
//need to update each bin with correct stat uncert
|
564 |
float relDYerr = MetPlotsSpace::Zestimate__data_stat/MetPlotsSpace::Zestimate__data;
|
565 |
for(int iz=1;iz<=zlineshape->GetNbinsX();iz++) {
|
566 |
float bincontent=zlineshape->GetBinContent(iz);
|
567 |
float binerror=zlineshape->GetBinError(iz);
|
568 |
float finalerr=0;
|
569 |
if(bincontent>0) finalerr+= (binerror/bincontent) * (binerror/bincontent);
|
570 |
if(MetPlotsSpace::Zestimate__data>0) finalerr+= relDYerr*relDYerr;
|
571 |
finalerr=bincontent * TMath::Sqrt(finalerr);
|
572 |
zlineshape->SetBinError(iz,finalerr);
|
573 |
}
|
574 |
}
|
575 |
|
576 |
|
577 |
delete mllsigFine;
|
578 |
delete mllOsigFine;
|
579 |
delete mllsconFine;
|
580 |
delete mllOsconFine;
|
581 |
delete zlineshapeFine;
|
582 |
delete OzlineshapeFine;
|
583 |
delete zlineshapeControlFine;
|
584 |
|
585 |
|
586 |
|
587 |
//**************************
|
588 |
write_info(__FUNCTION__,"LOW MASS YIELDS : ");
|
589 |
float yields_mllsf=0,yields_mllmm=0,yields_mllee=0,yields_mllof=0,yields_mllofme=0,yields_mllofem=0;
|
590 |
for(int i=1;i<=mllsigEE->GetNbinsX();i++) {
|
591 |
if(mllsigEE->GetBinCenter(i)>20 && mllsigEE->GetBinCenter(i)<70) {
|
592 |
yields_mllee+=mllsigEE->GetBinContent(i);
|
593 |
yields_mllmm+=mllsigMM->GetBinContent(i);
|
594 |
yields_mllsf+=mllsigEE->GetBinContent(i);
|
595 |
yields_mllsf+=mllsigMM->GetBinContent(i);
|
596 |
yields_mllof+=mllOsig->GetBinContent(i);
|
597 |
yields_mllofem+=mllOsigEM->GetBinContent(i);
|
598 |
yields_mllofme+=mllOsigME->GetBinContent(i);
|
599 |
}
|
600 |
}
|
601 |
dout << "Observed : " << yields_mllsf << " (" << yields_mllee << "ee , " << yields_mllmm << "mm )" << endl;
|
602 |
dout << "Predicted: " << yields_mllof << " (from OF, " << yields_mllofem << " em, " << yields_mllofme << " me) " << endl;
|
603 |
|
604 |
NiceSummary << "Low mass observed : " << yields_mllsf << " (" << yields_mllee << "ee , " << yields_mllmm << "mm )" << endl;
|
605 |
NiceSummary << "Low mass predicted: " << yields_mllof << " (from OF, " << yields_mllofem << " em, " << yields_mllofme << " me) " << endl;
|
606 |
|
607 |
|
608 |
//**************************
|
609 |
write_info(__FUNCTION__,"CONTROL REGION YIELDS : ");
|
610 |
float cr1yields_mllsf=0,cr1yields_mllmm=0,cr1yields_mllee=0,cr1yields_mllof=0,cr1yields_mllofem=0,cr1yields_mllofme=0;
|
611 |
float cr2yields_mllsf=0,cr2yields_mllmm=0,cr2yields_mllee=0,cr2yields_mllof=0,cr2yields_mllofem=0,cr2yields_mllofme=0;
|
612 |
float pyields_mllsf=0,pyields_mllmm=0,pyields_mllee=0,pyields_mllof=0,pyields_mllofem=0,pyields_mllofme=0,pyields_mlldy=0,pyields_mllpred;
|
613 |
for(int i=1;i<=mllsigEE->GetNbinsX();i++) {
|
614 |
if(mllsigEE->GetBinCenter(i)>20 && mllsigEE->GetBinCenter(i)<70) {
|
615 |
cr1yields_mllee+=mllsconEE->GetBinContent(i);
|
616 |
cr1yields_mllmm+=mllsconMM->GetBinContent(i);
|
617 |
cr1yields_mllsf+=mllsconEE->GetBinContent(i);
|
618 |
cr1yields_mllsf+=mllsconMM->GetBinContent(i);
|
619 |
cr1yields_mllof+=mllOscon->GetBinContent(i);
|
620 |
cr1yields_mllofem+=mllOsconEM->GetBinContent(i);
|
621 |
cr1yields_mllofme+=mllOsconME->GetBinContent(i);
|
622 |
}
|
623 |
if(mllsigEE->GetBinCenter(i)>120) {
|
624 |
cr2yields_mllee+=mllsconEE->GetBinContent(i);
|
625 |
cr2yields_mllmm+=mllsconMM->GetBinContent(i);
|
626 |
cr2yields_mllsf+=mllsconEE->GetBinContent(i);
|
627 |
cr2yields_mllsf+=mllsconMM->GetBinContent(i);
|
628 |
cr2yields_mllof+=mllOscon->GetBinContent(i);
|
629 |
cr2yields_mllofem+=mllOsconEM->GetBinContent(i);
|
630 |
cr2yields_mllofme+=mllOsconME->GetBinContent(i);
|
631 |
}
|
632 |
if(mllsigEE->GetBinCenter(i)>=80 && mllsigEE->GetBinCenter(i)<=100) {
|
633 |
// cout << "Bin center at " << mllsigEE->GetBinCenter(i) << " dy " << zlineshapeControl->GetBinContent(i) << " , of " << mllOscon->GetBinContent(i) << " , sf " << mllsconEE->GetBinContent(i)+mllsconMM->GetBinContent(i) << endl;
|
634 |
pyields_mllee+=mllsconEE->GetBinContent(i);
|
635 |
pyields_mllmm+=mllsconMM->GetBinContent(i);
|
636 |
pyields_mllsf+=mllsconEE->GetBinContent(i);
|
637 |
pyields_mllsf+=mllsconMM->GetBinContent(i);
|
638 |
pyields_mllof+=mllOscon->GetBinContent(i);
|
639 |
pyields_mllofem+=mllOsconEM->GetBinContent(i);
|
640 |
pyields_mllofme+=mllOsconME->GetBinContent(i);
|
641 |
pyields_mlldy+=zlineshapeControl->GetBinContent(i);
|
642 |
pyields_mllpred+=mllOscon->GetBinContent(i)+zlineshapeControl->GetBinContent(i);
|
643 |
}
|
644 |
}
|
645 |
|
646 |
dout << " CR1::Observed : " << cr1yields_mllsf << " (" << cr1yields_mllee << "ee , " << cr1yields_mllmm << "mm )" << endl;
|
647 |
dout << " CR1::Predicted(OF) : " << cr1yields_mllof << " (from OF, " << cr1yields_mllofem << " em, " << cr1yields_mllofme << " me) " << endl;
|
648 |
dout << " CR1::Ratio : " << cr1yields_mllsf/cr1yields_mllof << " +/- " << (cr1yields_mllsf/cr1yields_mllof) * sqrt(1.0/cr1yields_mllsf + 1.0/cr1yields_mllof) << endl;
|
649 |
|
650 |
dout << " CR2::Observed : " << cr2yields_mllsf << " (" << cr2yields_mllee << "ee , " << cr2yields_mllmm << "mm )" << endl;
|
651 |
dout << " CR2::Predicted(OF) : " << cr2yields_mllof << " (from OF, " << cr2yields_mllofem << " em, " << cr2yields_mllofme << " me) " << endl;
|
652 |
dout << " CR2::Ratio : " << cr2yields_mllsf/cr2yields_mllof << " +/- " << (cr2yields_mllsf/cr2yields_mllof) * sqrt(1.0/cr2yields_mllsf + 1.0/cr2yields_mllof) << endl;
|
653 |
|
654 |
dout << " Peak::Observed : " << pyields_mllsf << " (" << pyields_mllee << "ee , " << pyields_mllmm << "mm )" << endl;
|
655 |
dout << " Peak::Predicted : " << pyields_mllpred << " (from OF, " << pyields_mllofem << " em, " << pyields_mllofme << " me --> " << pyields_mllof << " em/me and DY " << pyields_mlldy << " ) " << endl;
|
656 |
|
657 |
NiceSummary << " CR1::Observed : " << cr1yields_mllsf << " (" << cr1yields_mllee << "ee , " << cr1yields_mllmm << "mm )" << endl;
|
658 |
NiceSummary << " CR1::Predicted(OF) : " << cr1yields_mllof << " (from OF) " << endl;
|
659 |
NiceSummary << " CR1::Ratio : " << cr1yields_mllsf/cr1yields_mllof << " +/- " << (cr1yields_mllsf/cr1yields_mllof) * sqrt(1.0/cr1yields_mllsf + 1.0/cr1yields_mllof) << endl;
|
660 |
|
661 |
NiceSummary << " CR2::Observed : " << cr2yields_mllsf << " (" << cr2yields_mllee << "ee , " << cr2yields_mllmm << "mm )" << endl;
|
662 |
NiceSummary << " CR2::Predicted(OF) : " << cr2yields_mllof << " (from OF) " << endl;
|
663 |
NiceSummary << " CR2::Ratio : " << cr2yields_mllsf/cr2yields_mllof << " +/- " << (cr2yields_mllsf/cr2yields_mllof) * sqrt(1.0/cr2yields_mllsf + 1.0/cr2yields_mllof) << endl;
|
664 |
|
665 |
//**************************
|
666 |
|
667 |
|
668 |
TH1F *subtracted = (TH1F*)mllsig->Clone("subtracted");
|
669 |
TH1F *subtractedControl = (TH1F*)mllscon->Clone("subtractedControl");
|
670 |
TH1F *baseline = (TH1F*)mllOsig->Clone("baseline");
|
671 |
TH1F *baselineControl = (TH1F*)mllOscon->Clone("baselineControl");
|
672 |
for(int i=1;i<=subtracted->GetNbinsX();i++) {
|
673 |
subtracted->SetBinContent(i,mllsig->GetBinContent(i)-mllOsig->GetBinContent(i));
|
674 |
subtractedControl->SetBinContent(i,mllscon->GetBinContent(i)-mllOscon->GetBinContent(i));
|
675 |
baseline->SetBinContent(i,0);
|
676 |
baselineControl->SetBinContent(i,0);
|
677 |
}
|
678 |
|
679 |
TH1F *prediction = (TH1F*)mllOsig->Clone("prediction");
|
680 |
prediction->Add(zlineshape);
|
681 |
prediction->SetLineColor(TColor::GetColor("#CF35CA"));
|
682 |
|
683 |
TH1F *control_prediction = (TH1F*)mllOscon->Clone("control_prediction");
|
684 |
control_prediction->SetLineColor(TColor::GetColor("#CF35CA"));
|
685 |
|
686 |
prediction->SetLineColor(TColor::GetColor("#cc0066"));
|
687 |
mllOsig->SetLineColor(TColor::GetColor("#0000cc"));
|
688 |
|
689 |
if(!doMC) mllOsig->SetLineStyle(2);
|
690 |
zlineshape->SetLineColor(TColor::GetColor("#006600"));
|
691 |
zlineshape->SetFillColor(TColor::GetColor("#006600"));
|
692 |
zlineshape->SetFillStyle(3002); // light dots, not crushing other information
|
693 |
if(!doMC) {
|
694 |
mllOsig->SetLineWidth(2);
|
695 |
prediction->SetLineWidth(2);
|
696 |
zlineshape->SetLineWidth(2);
|
697 |
}
|
698 |
|
699 |
// FIX Y RANGE TO EASE COMPARISON
|
700 |
mllsig->SetMaximum(ymax);
|
701 |
float PreviousMinimum=mllsig->GetMinimum();
|
702 |
mllsig->SetMinimum(0);
|
703 |
mllsigEE->SetMaximum(ymax);
|
704 |
mllsigMM->SetMaximum(ymax);
|
705 |
mllOsig->SetMaximum(ymax);
|
706 |
mllOscon->SetMaximum(ymax);
|
707 |
subtracted->SetMaximum(60);
|
708 |
subtracted->SetMinimum(-30);
|
709 |
subtractedControl->SetMaximum(65);
|
710 |
subtractedControl->SetMinimum(-30);
|
711 |
|
712 |
|
713 |
// 1.- Signal region comparison
|
714 |
TBox *srbox = new TBox(20,0,70,mllsig->GetMaximum());
|
715 |
srbox->SetFillStyle(0);
|
716 |
srbox->SetLineColor(TColor::GetColor("#298A08"));
|
717 |
srbox->SetLineWidth(3);
|
718 |
|
719 |
|
720 |
float EtaCut=DetectEtaCut();
|
721 |
|
722 |
stringstream MetHeader1;
|
723 |
stringstream MetHeader2;
|
724 |
MetHeader1 << "N_{jets}#geq" << snjets.str() << ", E_{T}^{miss}>" << cutat << " GeV";
|
725 |
MetHeader2 << "|#eta|<" << EtaCut;
|
726 |
stringstream MetHeaderCon;
|
727 |
// MetHeaderCon << "N_{j}=2, N_{b}>0, 75<MET<150 GeV";
|
728 |
MetHeaderCon << "N_{jets}=2, 100<E_{T}^{miss}<150 GeV";
|
729 |
stringstream saveasSig;
|
730 |
saveasSig << "MetPlots/mll_sig" << cutat << "__" << name;
|
731 |
|
732 |
TLegend* leg;
|
733 |
|
734 |
|
735 |
srbox->SetLineColor(TColor::GetColor("#00cc33"));
|
736 |
TH1F *emptyh = new TH1F();
|
737 |
|
738 |
if ( !doMC ) {
|
739 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
740 |
rcan->cd();
|
741 |
mllsig->Draw();
|
742 |
TGraphErrors *stat3j = MakeErrorGraph(prediction);
|
743 |
stat3j->Draw("2,same");
|
744 |
mllOsig->Draw("histo,same");
|
745 |
zlineshape->Draw("histo,same");
|
746 |
prediction->Draw("histo,same");
|
747 |
mllsig->Draw("same");
|
748 |
DrawPrelim();
|
749 |
leg = make_legend();
|
750 |
leg->SetX1(0.52);
|
751 |
leg->AddEntry(emptyh,MetHeader1.str().c_str(),"h");
|
752 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
753 |
leg->AddEntry(mllsig,"Data","PL");
|
754 |
leg->AddEntry(prediction,"All bg prediction","L");
|
755 |
leg->AddEntry(mllOsig,"bg without Z","L");
|
756 |
if(!UseSpecialZprediction) leg->AddEntry(zlineshape,"Z lineshape","L");
|
757 |
else leg->AddEntry(zlineshape,"bg with Z (JZB)","L");
|
758 |
leg->AddEntry(stat3j,"stat. uncert.","F");
|
759 |
leg->AddEntry(srbox,"SR","F");
|
760 |
leg->Draw();
|
761 |
srbox->Draw();
|
762 |
sel->Draw();
|
763 |
Save_With_Ratio_And_Line( mllsig, prediction, rcan, saveasSig.str() );
|
764 |
|
765 |
//now also add systematic as a nice touch :-)
|
766 |
TPad* rcan2 = new TPad("rcan2","rcan2",0,0,1,1);
|
767 |
|
768 |
|
769 |
float ConsideredZWidth=20;
|
770 |
if(Contains((const char*)Restrmasscut,")<10")) ConsideredZWidth=10;
|
771 |
|
772 |
|
773 |
TLine *SRline = new TLine(70,0,70,ymax);
|
774 |
TLine *ZLowLine = new TLine(91.2-ConsideredZWidth,0,91.2-ConsideredZWidth,ymax);
|
775 |
TLine *ZHiLine = new TLine(91.2+ConsideredZWidth,0,91.2+ConsideredZWidth,ymax);
|
776 |
SRline->SetLineStyle(2);
|
777 |
ZLowLine->SetLineStyle(2);
|
778 |
ZHiLine->SetLineStyle(2);
|
779 |
SRline->SetLineColor(kGray+2);
|
780 |
ZLowLine->SetLineColor(kGray+2);
|
781 |
ZHiLine->SetLineColor(kGray+2);
|
782 |
|
783 |
rcan2->cd();
|
784 |
mllsig->Draw();
|
785 |
TH1F *SystHisto = (TH1F*)prediction->Clone("SystHisto");
|
786 |
TGraphErrors *stat3jS = MakeErrorGraphSystematicAndStatistical(mllOsig,zlineshape,prediction,SystHisto);
|
787 |
stat3jS->Draw("2,same");
|
788 |
zlineshape->Draw("histo,same");
|
789 |
prediction->Draw("histo,same");
|
790 |
mllsig->Draw("same");
|
791 |
DrawPrelim();
|
792 |
leg = make_legend();
|
793 |
leg->SetX1(0.52);
|
794 |
leg->AddEntry(emptyh,MetHeader1.str().c_str(),"h");
|
795 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
796 |
leg->AddEntry(mllsig,"Data","PL");
|
797 |
leg->AddEntry(prediction,"Total backgrounds","L");
|
798 |
if(!UseSpecialZprediction) leg->AddEntry(zlineshape,"DY (scaled) ","FL");
|
799 |
else leg->AddEntry(zlineshape,"DY (data-driven)","F");
|
800 |
leg->AddEntry(stat3jS,"Total uncert.","F");
|
801 |
leg->Draw();
|
802 |
sel->Draw();
|
803 |
SRline->Draw();
|
804 |
ZLowLine->Draw();
|
805 |
ZHiLine->Draw();
|
806 |
|
807 |
|
808 |
save_with_ratio_and_sys_band(ConsideredZWidth,mllsig, prediction, rcan2, (saveasSig.str()+"__WithSys"), false, false, "data/pred",SystHisto );
|
809 |
|
810 |
mllsig->GetYaxis()->SetRangeUser(0.1,ymax);
|
811 |
|
812 |
TPad *rcan3 = new TPad("rcan3","rcan3",0,0,1,1);
|
813 |
rcan3->cd();
|
814 |
rcan3->SetLogy(1);
|
815 |
rcan3->cd(); //need to switch back to pad (otherwise it's blank for some reason)
|
816 |
mllsig->Draw();
|
817 |
stat3jS->Draw("2,same");
|
818 |
zlineshape->Draw("histo,same");
|
819 |
prediction->Draw("histo,same");
|
820 |
mllsig->Draw("same");
|
821 |
DrawPrelim();
|
822 |
sel->Draw();
|
823 |
save_with_ratio_and_sys_band(ConsideredZWidth, mllsig, prediction, rcan3, (saveasSig.str()+"__WithSys___LOG"), false, false, "data/pred",SystHisto );
|
824 |
|
825 |
} else {
|
826 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
827 |
rcan->cd();
|
828 |
mllsig->Draw();
|
829 |
mcMllsig->Draw("same,hist");
|
830 |
prediction->Draw("histo,same");
|
831 |
mllsig->Draw("same");
|
832 |
DrawPrelim();
|
833 |
leg = allsamples.allbglegend();
|
834 |
leg->AddEntry(emptyh,MetHeader1.str().c_str(),"h");
|
835 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
836 |
leg->SetX1(0.52);
|
837 |
leg->AddEntry(prediction,"All bg prediction","L");
|
838 |
leg->AddEntry(srbox,"SR","F");
|
839 |
leg->Draw();
|
840 |
srbox->Draw();
|
841 |
sel->Draw();
|
842 |
Save_With_Ratio_And_Line( mllsig, *mcMllsig, rcan, saveasSig.str() );
|
843 |
|
844 |
ExtractScaleFactor(mllsig,mllOsig,mcMllsig,mcMllOsig,prediction,leg,saveasSig.str(),srbox);
|
845 |
}
|
846 |
|
847 |
// 1b. MC: split ee and mumu
|
848 |
if ( doMC ) {
|
849 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
850 |
rcan->cd();
|
851 |
mllsigEE->Draw();
|
852 |
mcMllsigEE->Draw("same,hist");
|
853 |
mllsigEE->Draw("same");
|
854 |
DrawPrelim();
|
855 |
leg->Draw();
|
856 |
srbox->Draw();
|
857 |
sel->Draw();
|
858 |
Save_With_Ratio_And_Line( mllsigEE, *mcMllsigEE,rcan->cd(),saveasSig.str()+"_ee" );
|
859 |
|
860 |
rcan = new TPad("rcan","rcan",0,0,1,1);
|
861 |
rcan->cd();
|
862 |
mllsigMM->Draw();
|
863 |
mcMllsigMM->Draw("histo,same");
|
864 |
mllsigMM->Draw("same");
|
865 |
DrawPrelim();
|
866 |
leg->Draw();
|
867 |
srbox->Draw();
|
868 |
sel->Draw();
|
869 |
Save_With_Ratio_And_Line( mllsigMM, *mcMllsigMM,rcan,saveasSig.str()+"_mm" );
|
870 |
}
|
871 |
|
872 |
// 1c. MC: compare of and sf
|
873 |
if ( doMC ) {
|
874 |
TH1F* hMcMllsig = CollapseStack( *mcMllsig);
|
875 |
leg = allsamples.allbglegend("");
|
876 |
leg->AddEntry(emptyh,MetHeader1.str().c_str(),"h");
|
877 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
878 |
// Change "Data" label by hand
|
879 |
((TLegendEntry*)leg->GetListOfPrimitives()->At(0))->SetLabel("Same-flavor (MC)");
|
880 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
881 |
rcan->cd();
|
882 |
hMcMllsig->SetMaximum(ymax);
|
883 |
hMcMllsig->Draw("E");
|
884 |
mcMllOsig->Draw("same,hist");
|
885 |
hMcMllsig->Draw("same,E");
|
886 |
DrawMCPrelim();
|
887 |
leg->SetX1(0.52);
|
888 |
leg->AddEntry(srbox,"SR","F");
|
889 |
leg->Draw();
|
890 |
srbox->Draw();
|
891 |
sel->Draw();
|
892 |
Save_With_Ratio_And_Line( hMcMllsig, *mcMllOsig, rcan, saveasSig.str()+"_mconly");
|
893 |
|
894 |
}
|
895 |
|
896 |
// 2.- Signal region comparison - LOG scale
|
897 |
if ( !doMC ) {
|
898 |
tcan->cd();
|
899 |
mllsig->SetMinimum(0.2); // FIX Y RANGE TO EASE COMPARISON
|
900 |
//mllsig->SetMaximum(mllsig->GetMaximum()*4.0);
|
901 |
srbox->SetY2(mllsig->GetMaximum());
|
902 |
tcan->SetLogy(1);
|
903 |
stringstream saveasSig2;
|
904 |
saveasSig2 << "MetPlots/mll_sig_ZLINESHAPE_" << cutat << "__" << name;
|
905 |
|
906 |
sel->Draw();
|
907 |
CompleteSave(tcan,saveasSig2.str());
|
908 |
tcan->SetLogy(0);
|
909 |
}
|
910 |
|
911 |
|
912 |
// 3.- Signal region, background subtracted
|
913 |
if ( !doMC ) {
|
914 |
tcan->cd();
|
915 |
for(int i=1;i<=subtracted->GetNbinsX();i++) {
|
916 |
subtracted->SetBinContent(i,subtracted->GetBinContent(i)-zlineshape->GetBinContent(i));
|
917 |
subtractedControl->SetBinContent(i,subtractedControl->GetBinContent(i)-zlineshapeControl->GetBinContent(i));
|
918 |
}
|
919 |
|
920 |
TGraphErrors *subtrerr = MakeErrorGraph(baseline);
|
921 |
subtracted->Draw();
|
922 |
subtrerr->Draw("2,same");
|
923 |
subtracted->Draw("same");
|
924 |
DrawPrelim();
|
925 |
TLegend *DiffLeg = make_legend();
|
926 |
DiffLeg->SetX1(0.4);
|
927 |
DiffLeg->SetFillStyle(0);
|
928 |
leg->AddEntry(emptyh,MetHeader1.str().c_str(),"h");
|
929 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
930 |
DiffLeg->AddEntry(subtracted,"observed - predicted","PL");
|
931 |
DiffLeg->AddEntry(subtrerr,"stat. uncert","F");
|
932 |
DiffLeg->AddEntry((TObject*)0,"","");
|
933 |
DiffLeg->AddEntry((TObject*)0,"","");
|
934 |
DiffLeg->Draw();
|
935 |
sel->Draw();
|
936 |
|
937 |
stringstream saveasSigSub;
|
938 |
saveasSigSub << "MetPlots/mll_sig_SUBTRACTED_" << cutat << "__" << name;
|
939 |
|
940 |
//CompleteSave(tcan,saveasSigSub.str());
|
941 |
|
942 |
// 3a.- Control region, background subtracted
|
943 |
TGraphErrors *subtrerrControl = MakeErrorGraph(baselineControl);
|
944 |
subtractedControl->Draw();
|
945 |
subtrerrControl->Draw("2,same");
|
946 |
subtractedControl->Draw("same");
|
947 |
DrawPrelim();
|
948 |
DiffLeg->SetHeader(MetHeaderCon.str().c_str());
|
949 |
DiffLeg->Draw();
|
950 |
saveasSigSub.str("");
|
951 |
saveasSigSub << "MetPlots/mll_con_SUBTRACTED_" << cutat << "__" << name;
|
952 |
//CompleteSave(tcan,saveasSigSub.str());
|
953 |
|
954 |
|
955 |
|
956 |
// 4.- Signal region, background subtracted, errors added in quadrature
|
957 |
TGraphErrors *subtrerr2 = (TGraphErrors*)subtrerr->Clone("subtrerr2");
|
958 |
for(int i=1;i<=subtrerr2->GetN();i++) {
|
959 |
subtrerr2->SetPoint(i-1,subtracted->GetBinCenter(i),subtracted->GetBinContent(i));
|
960 |
subtrerr2->SetPointError(i-1,subtrerr2->GetErrorX(i),TMath::Sqrt(subtrerr2->GetErrorY(i)*subtrerr2->GetErrorY(i)+subtracted->GetBinError(i)*subtracted->GetBinError(i)));
|
961 |
}
|
962 |
TLine* l = new TLine(subtracted->GetBinLowEdge(1),0.,subtracted->GetBinLowEdge(subtracted->GetNbinsX()-1)+subtracted->GetBinWidth(1),0.);
|
963 |
l->SetLineWidth(subtracted->GetLineWidth());
|
964 |
subtracted->Draw();
|
965 |
subtrerr2->Draw("2,same");
|
966 |
l->Draw("same");
|
967 |
subtracted->Draw("same");
|
968 |
DrawPrelim();
|
969 |
TLegend *DiffLeg2 = make_legend();
|
970 |
DiffLeg2->SetX1(0.4);
|
971 |
DiffLeg2->AddEntry(emptyh,MetHeader1.str().c_str(),"h");
|
972 |
DiffLeg2->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
973 |
DiffLeg2->SetFillStyle(0);
|
974 |
DiffLeg2->AddEntry(subtracted,"observed - predicted","PL");
|
975 |
DiffLeg2->AddEntry(subtrerr2,"stat. uncert","F");
|
976 |
DiffLeg2->AddEntry((TObject*)0,"","");
|
977 |
DiffLeg2->AddEntry((TObject*)0,"","");
|
978 |
DiffLeg2->Draw();
|
979 |
|
980 |
stringstream saveasSigSub2;
|
981 |
saveasSigSub2 << "MetPlots/mll_sig_SUBTRACTED_quadr_" << cutat << "__" << name;
|
982 |
|
983 |
sel->Draw();
|
984 |
CompleteSave(tcan,saveasSigSub2.str());
|
985 |
|
986 |
|
987 |
|
988 |
//4a.- Control region, background subtracted, errors added in quadrature
|
989 |
TGraphErrors *subtrerr2Control = (TGraphErrors*)subtrerrControl->Clone("subtrerr2Control");
|
990 |
for(int i=1;i<=subtrerr2Control->GetN();i++) {
|
991 |
subtrerr2Control->SetPoint(i-1,subtractedControl->GetBinCenter(i),subtractedControl->GetBinContent(i));
|
992 |
float width=subtrerr2Control->GetErrorX(i);
|
993 |
if(i==subtrerr2Control->GetN()) width=subtrerr2Control->GetErrorX(i-1);
|
994 |
subtrerr2Control->SetPointError(i-1,width,TMath::Sqrt(subtrerr2Control->GetErrorY(i)*subtrerr2Control->GetErrorY(i)+subtractedControl->GetBinError(i)*subtractedControl->GetBinError(i)));
|
995 |
}
|
996 |
TLine* lControl = new TLine(subtractedControl->GetBinLowEdge(1),0.,subtractedControl->GetBinLowEdge(subtractedControl->GetNbinsX()-1)+subtractedControl->GetBinWidth(1),0.);
|
997 |
lControl->SetLineWidth(subtractedControl->GetLineWidth());
|
998 |
subtractedControl->Draw();
|
999 |
subtrerr2Control->Draw("2,same");
|
1000 |
lControl->Draw("same");
|
1001 |
subtractedControl->Draw("same");
|
1002 |
DrawPrelim();
|
1003 |
DiffLeg2->SetHeader(MetHeaderCon.str().c_str());
|
1004 |
DiffLeg2->Draw();
|
1005 |
|
1006 |
saveasSigSub2.str("");
|
1007 |
saveasSigSub2 << "MetPlots/mll_con_SUBTRACTED_quadr_" << cutat << "__" << name;
|
1008 |
|
1009 |
sel->Draw();
|
1010 |
CompleteSave(tcan,saveasSigSub2.str());
|
1011 |
|
1012 |
delete DiffLeg;
|
1013 |
delete DiffLeg2;
|
1014 |
|
1015 |
} // !doMC
|
1016 |
|
1017 |
|
1018 |
// 5.- Control region comparison
|
1019 |
// scalefactor = (mllscon->Integral(scaleBinLow,scaleBinHigh)-mllOscon->Integral(scaleBinLow,scaleBinHigh));
|
1020 |
// scalefactor /= zlineshape->Integral(scaleBinLow,scaleBinHigh);
|
1021 |
// zlineshape->Scale(scalefactor);
|
1022 |
control_prediction->Add(zlineshapeControl);
|
1023 |
|
1024 |
control_prediction->SetMaximum(ymax); // FIX MAXIMUM TO EASE COMPARISON
|
1025 |
control_prediction->SetMinimum(0);
|
1026 |
|
1027 |
TBox *cr1box = new TBox(20,0,70,control_prediction->GetMaximum());
|
1028 |
cr1box->SetFillStyle(0);
|
1029 |
cr1box->SetLineColor(TColor::GetColor("#0404B4"));
|
1030 |
cr1box->SetLineWidth(3);
|
1031 |
|
1032 |
TBox *cr2box = new TBox(120,0,xmax,control_prediction->GetMaximum());
|
1033 |
cr2box->SetFillStyle(0);
|
1034 |
cr2box->SetLineColor(TColor::GetColor("#0404B4"));
|
1035 |
cr2box->SetLineWidth(3);
|
1036 |
cr2box->SetLineStyle(2);
|
1037 |
|
1038 |
stringstream saveasCon;
|
1039 |
saveasCon << "MetPlots/mll_con" << cutat << "__" << name;
|
1040 |
|
1041 |
TLegend *legc;
|
1042 |
//control_prediction->GetYaxis()->SetRangeUser(0,control_prediction->GetMaximum()*1.3);
|
1043 |
if ( !doMC ) {
|
1044 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1045 |
rcan->cd();
|
1046 |
Color_t control_prediction_color = control_prediction->GetLineColor();
|
1047 |
int LineWidth = control_prediction->GetLineWidth();
|
1048 |
control_prediction->SetLineColor(TColor::GetColor("#FF4000"));
|
1049 |
control_prediction->SetLineWidth(2);
|
1050 |
|
1051 |
TH1F *ControlSystHisto = (TH1F*)control_prediction->Clone("SystHisto");
|
1052 |
TGraphErrors *stat3jS = MakeErrorGraphSystematicAndStatistical(mllOscon,zlineshapeControl,control_prediction,ControlSystHisto);
|
1053 |
control_prediction->Draw("hist");
|
1054 |
stat3jS->Draw("2,same");
|
1055 |
zlineshapeControl->Draw("histo,same");
|
1056 |
control_prediction->Draw("histo,same");
|
1057 |
mllscon->Draw("same");
|
1058 |
DrawPrelim();
|
1059 |
legc = make_legend();
|
1060 |
legc->SetX1(0.52);
|
1061 |
legc->SetHeader(MetHeaderCon.str().c_str());
|
1062 |
legc->AddEntry(mllscon,"Data","PL");
|
1063 |
legc->AddEntry(control_prediction,"Total backgrounds","L");
|
1064 |
legc->AddEntry(zlineshapeControl,"DY (scaled)","FL");
|
1065 |
legc->AddEntry(stat3jS,"Total uncert.","F");
|
1066 |
legc->AddEntry(cr1box,"CR1","F");
|
1067 |
legc->AddEntry(cr2box,"CR2","F");
|
1068 |
legc->Draw();
|
1069 |
cr1box->Draw();
|
1070 |
cr2box->Draw();
|
1071 |
sel->Draw();
|
1072 |
|
1073 |
save_with_ratio_and_sys_band(ConsideredZWidth, mllscon, control_prediction, rcan, saveasCon.str() , false, false, "data/pred",ControlSystHisto );
|
1074 |
|
1075 |
control_prediction->SetLineColor(control_prediction_color);
|
1076 |
control_prediction->SetLineWidth(LineWidth);
|
1077 |
} else {
|
1078 |
control_prediction->SetLineColor(TColor::GetColor("#FF4000"));
|
1079 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1080 |
rcan->cd();
|
1081 |
control_prediction->Draw("hist");
|
1082 |
mcMllscon->Draw("same,hist");
|
1083 |
control_prediction->Draw("histo,same");
|
1084 |
mllscon->Draw("same");
|
1085 |
DrawPrelim();
|
1086 |
legc = allsamples.allbglegend();
|
1087 |
legc->SetX1(0.52);
|
1088 |
legc->SetHeader(MetHeaderCon.str().c_str());
|
1089 |
legc->AddEntry(control_prediction,"All bg","L");
|
1090 |
legc->AddEntry(cr1box,"CR1","F");
|
1091 |
legc->AddEntry(cr2box,"CR2","F");
|
1092 |
legc->Draw();
|
1093 |
cr1box->Draw();
|
1094 |
cr2box->Draw();
|
1095 |
sel->Draw();
|
1096 |
Save_With_Ratio_And_Line( mllscon, *mcMllscon, rcan, saveasCon.str());
|
1097 |
}
|
1098 |
|
1099 |
// 6. - Opposite-flavour data/MC comparison
|
1100 |
if ( doMC ) {
|
1101 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1102 |
rcan->cd();
|
1103 |
mllOsig->SetLineColor(kBlack);
|
1104 |
mllOsig->Draw();
|
1105 |
mcMllOsig->Draw("same,hist");
|
1106 |
mllOsig->Draw("same");
|
1107 |
TLegend *legsdm = allsamples.allbglegend();
|
1108 |
leg->AddEntry(emptyh,(MetHeader1.str()+", OF").c_str(),"h");
|
1109 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
1110 |
legsdm->SetX1(0.52);
|
1111 |
legsdm->Draw();
|
1112 |
stringstream saveasSigOF;
|
1113 |
saveasSigOF << "MetPlots/mll_sig_of_" << cutat << "__" << name;
|
1114 |
sel->Draw();
|
1115 |
Save_With_Ratio_And_Line( mllOsig, *mcMllOsig, rcan, saveasSigOF.str());
|
1116 |
|
1117 |
rcan = new TPad("rcan","rcan",0,0,1,1);
|
1118 |
rcan->cd();
|
1119 |
mllOscon->SetLineColor(kBlack);
|
1120 |
mllOscon->Draw();
|
1121 |
mcMllOscon->Draw("same,hist");
|
1122 |
mllOscon->Draw("same");
|
1123 |
TLegend *legcdm = allsamples.allbglegend();
|
1124 |
legcdm->SetHeader((MetHeaderCon.str()+", OF").c_str());
|
1125 |
legcdm->SetX1(0.52);
|
1126 |
legcdm->Draw();
|
1127 |
stringstream saveasConOF;
|
1128 |
saveasConOF << "MetPlots/mll_con_of_" << cutat << "__" << name;
|
1129 |
sel->Draw();
|
1130 |
Save_With_Ratio_And_Line( mllOscon, *mcMllOscon, rcan, saveasConOF.str());
|
1131 |
|
1132 |
delete legsdm;
|
1133 |
delete legcdm;
|
1134 |
}
|
1135 |
|
1136 |
// 7. - Opposite flavor data/MC comparison for pt (!)
|
1137 |
if ( doMC ) {
|
1138 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1139 |
rcan->cd();
|
1140 |
rcan->SetLogy(1);
|
1141 |
|
1142 |
ptsig->SetLineColor(kBlack);
|
1143 |
ptsig->Draw();
|
1144 |
mcptsig->Draw("same,hist");
|
1145 |
ptsig->Draw("same");
|
1146 |
TLegend *legsdm = allsamples.allbglegend();
|
1147 |
legsdm->AddEntry(emptyh,(MetHeader1.str()+", SF").c_str(),"h");
|
1148 |
legsdm->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
1149 |
legsdm->SetX1(0.52);
|
1150 |
legsdm->Draw();
|
1151 |
stringstream saveasSigOF2;
|
1152 |
saveasSigOF2 << "MetPlots/mll_sig_sf_PTdist_" << cutat << "__" << name;
|
1153 |
sel->Draw();
|
1154 |
Save_With_Ratio_And_Line( ptsig, *mcptsig, rcan, saveasSigOF2.str());
|
1155 |
|
1156 |
delete legsdm;
|
1157 |
}
|
1158 |
|
1159 |
|
1160 |
// 8. - Opposite flavor data/MC comparison for pt (!)
|
1161 |
if ( doMC ) {
|
1162 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1163 |
rcan->cd();
|
1164 |
rcan->SetLogy(1);
|
1165 |
|
1166 |
ptOsig->SetLineColor(kBlack);
|
1167 |
ptOsig->Draw();
|
1168 |
mcptOsig->Draw("same,hist");
|
1169 |
ptOsig->Draw("same");
|
1170 |
TLegend *legsdm = allsamples.allbglegend();
|
1171 |
leg->AddEntry(emptyh,(MetHeader1.str()+", OF").c_str(),"h");
|
1172 |
leg->AddEntry(emptyh,MetHeader2.str().c_str(),"h");
|
1173 |
legsdm->SetX1(0.52);
|
1174 |
legsdm->Draw();
|
1175 |
stringstream saveasSigOF3;
|
1176 |
saveasSigOF3 << "MetPlots/mll_sig_of_PTdist_" << cutat << "__" << name;
|
1177 |
sel->Draw();
|
1178 |
Save_With_Ratio_And_Line( ptOsig, *mcptOsig, rcan, saveasSigOF3.str());
|
1179 |
|
1180 |
delete legsdm;
|
1181 |
}
|
1182 |
|
1183 |
// 9. - Shape comparison between SR and CR
|
1184 |
if ( !doMC ) { // SF
|
1185 |
TH1F* scaled_conSF = (TH1F*)mllscon->Clone("scaled_conSF");
|
1186 |
scaled_conSF->SetLineColor(kBlue);
|
1187 |
scaled_conSF->Scale(mllsig->Integral()/scaled_conSF->Integral());
|
1188 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1189 |
rcan->cd();
|
1190 |
mllsig->Draw();
|
1191 |
scaled_conSF->Draw("same,hist");
|
1192 |
mllsig->Draw("same");
|
1193 |
TLegend *leg9 = make_legend("Same-flavor",0.5,0.7,false);
|
1194 |
leg9->SetHeader("Same-flavor");
|
1195 |
leg9->AddEntry(mllsig,"SR","pl");
|
1196 |
leg9->AddEntry(scaled_conSF,"CR (scaled)","l");
|
1197 |
leg9->Draw();
|
1198 |
DrawPrelim();
|
1199 |
stringstream saveas9;
|
1200 |
saveas9 << "MetPlots/mll_compSF_" << cutat << "__" << name;
|
1201 |
sel->Draw();
|
1202 |
Save_With_Ratio_And_Line( mllsig, scaled_conSF, rcan, saveas9.str());
|
1203 |
delete leg9;
|
1204 |
} else {
|
1205 |
TH1F* hMcMllsig = CollapseStack( *mcMllsig,"hMcMllSig");
|
1206 |
TH1F* scaled_conSF = CollapseStack( *mcMllscon,"scaled_conSF");
|
1207 |
scaled_conSF->SetLineColor(kBlue);
|
1208 |
scaled_conSF->SetFillStyle(0);
|
1209 |
scaled_conSF->Scale(hMcMllsig->Integral()/scaled_conSF->Integral());
|
1210 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1211 |
rcan->cd();
|
1212 |
hMcMllsig->SetMaximum(ymax);
|
1213 |
hMcMllsig->Draw();
|
1214 |
scaled_conSF->Draw("same,hist");
|
1215 |
hMcMllsig->Draw("same");
|
1216 |
TLegend *leg9 = make_legend("Same-flavor MC",0.5,0.7,false);
|
1217 |
leg9->SetHeader("Same-flavor MC");
|
1218 |
leg9->AddEntry(hMcMllsig,"SF SR","pl");
|
1219 |
leg9->AddEntry(scaled_conSF,"SF CR (scaled)","l");
|
1220 |
leg9->Draw();
|
1221 |
DrawMCPrelim();
|
1222 |
stringstream saveas9;
|
1223 |
saveas9 << "MetPlots/mll_compSF_" << cutat << "__" << name;
|
1224 |
sel->Draw();
|
1225 |
Save_With_Ratio_And_Line( hMcMllsig, scaled_conSF, rcan, saveas9.str());
|
1226 |
delete leg9;
|
1227 |
}
|
1228 |
if ( !doMC ) { // OF
|
1229 |
TH1F* scaled_conOF = (TH1F*)control_prediction->Clone("scaled_conOF");
|
1230 |
scaled_conOF->SetLineColor(kBlue);
|
1231 |
scaled_conOF->Scale(mllOsig->Integral()/scaled_conOF->Integral());
|
1232 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1233 |
rcan->cd();
|
1234 |
mllOsig->SetLineColor(kBlack);
|
1235 |
mllOsig->Draw();
|
1236 |
scaled_conOF->Draw("same,hist");
|
1237 |
mllOsig->Draw("same");
|
1238 |
TLegend *leg9 = make_legend("Opposite-flavor",0.5,0.7,false);
|
1239 |
leg9->AddEntry(mllOsig,"OF SR","pl");
|
1240 |
leg9->AddEntry(scaled_conOF,"OF CR (scaled)","l");
|
1241 |
leg9->Draw();
|
1242 |
DrawPrelim();
|
1243 |
stringstream saveas9;
|
1244 |
saveas9 << "MetPlots/mll_compOF_" << cutat << "__" << name;
|
1245 |
sel->Draw();
|
1246 |
Save_With_Ratio_And_Line( mllOsig, scaled_conOF, rcan, saveas9.str());
|
1247 |
|
1248 |
delete leg9;
|
1249 |
} else { // SF MC
|
1250 |
TH1F* hMcMllOsig = CollapseStack( *mcMllOsig, "hMcMllOsig");
|
1251 |
TH1F* scaled_conOF = CollapseStack( *mcMllOscon, "scaled_conOF");
|
1252 |
scaled_conOF->SetLineColor(kBlue);
|
1253 |
scaled_conOF->SetFillStyle(0);
|
1254 |
scaled_conOF->Scale(hMcMllOsig->Integral()/scaled_conOF->Integral());
|
1255 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
1256 |
rcan->cd();
|
1257 |
hMcMllOsig->SetMaximum(ymax);
|
1258 |
hMcMllOsig->Draw();
|
1259 |
scaled_conOF->Draw("same,hist");
|
1260 |
hMcMllOsig->Draw("same");
|
1261 |
TLegend *leg9 = make_legend("Opposite-flavor MC",0.5,0.7,false);
|
1262 |
leg9->AddEntry(hMcMllOsig, "OF SR","pl");
|
1263 |
leg9->AddEntry(scaled_conOF,"OF CR (scaled)","l");
|
1264 |
leg9->Draw();
|
1265 |
DrawMCPrelim();
|
1266 |
stringstream saveas9;
|
1267 |
saveas9 << "MetPlots/mll_compOF_" << cutat << "__" << name;
|
1268 |
sel->Draw();
|
1269 |
Save_With_Ratio_And_Line( hMcMllOsig, scaled_conOF, rcan, saveas9.str());
|
1270 |
delete leg9;
|
1271 |
}
|
1272 |
|
1273 |
|
1274 |
// Memory clean-up
|
1275 |
if (doMC) {
|
1276 |
delete mcMllscon;
|
1277 |
delete mcMllOscon;
|
1278 |
delete mcMllsig;
|
1279 |
delete mcMllsigEE;
|
1280 |
delete mcMllsigMM;
|
1281 |
delete mcMllOsig;
|
1282 |
}
|
1283 |
|
1284 |
delete cr1box;
|
1285 |
delete cr2box;
|
1286 |
delete srbox;
|
1287 |
delete legc;
|
1288 |
delete leg;
|
1289 |
|
1290 |
delete emptyh;
|
1291 |
|
1292 |
delete mllscon;
|
1293 |
delete mllsconEE;
|
1294 |
delete mllsconMM;
|
1295 |
delete mllOscon;
|
1296 |
delete mllOsconEM;
|
1297 |
delete mllOsconME;
|
1298 |
delete mllsig;
|
1299 |
delete mllsigEE;
|
1300 |
delete mllsigMM;
|
1301 |
delete mllOsig;
|
1302 |
delete mllOsigEM;
|
1303 |
delete mllOsigME;
|
1304 |
delete ptsig;
|
1305 |
delete ptOsig;
|
1306 |
delete zlineshape;
|
1307 |
delete Ozlineshape;
|
1308 |
delete zlineshapeControl;
|
1309 |
delete tcan;
|
1310 |
|
1311 |
NiceSummary.close();
|
1312 |
|
1313 |
}
|
1314 |
|
1315 |
|
1316 |
void DoMetPlots(string datajzb, string mcjzb, bool do_only_aachen=false, bool do_only_eth=false) {
|
1317 |
switch_overunderflow(true);
|
1318 |
float metCuts[] = { 100., 150. };
|
1319 |
//float ymax[] = { 180., 170. };
|
1320 |
float ymax[] = { 120., 140. };
|
1321 |
int jetCuts[] = { 3, 2 };
|
1322 |
string leptCuts[] = { "pt1>20&&pt2>20", "pt1>20&&pt2>20&&pfTightHT>100" };
|
1323 |
bool nomc(0),domc(1);
|
1324 |
string backup_basicqualitycut = (const char*) basicqualitycut;
|
1325 |
string backup_essentialcut = (const char*) essentialcut;
|
1326 |
string backup_basiccut = (const char*) basiccut;
|
1327 |
string backup_leptoncut = (const char*) leptoncut;
|
1328 |
|
1329 |
//zlineshapes(); // Rinout plots
|
1330 |
|
1331 |
int initial_i=do_only_aachen;
|
1332 |
int final_i=2-do_only_eth;
|
1333 |
|
1334 |
for ( int i=initial_i; i<final_i; ++i ) {
|
1335 |
//need to make sure that the above changes actually have some effect. we therefore check all relevant cuts and
|
1336 |
//set the pt condition to 10/10 (yes you read that right). the addition cut (above) will therefore elevate it
|
1337 |
// to 20,10 or 20,20. otherwise basicqualitycut will impose 20,20 ...
|
1338 |
|
1339 |
bool isAachen=i;//1=Aachen, 0=not.
|
1340 |
string Sbasicqualitycut = backup_basicqualitycut;
|
1341 |
if(i==1) Sbasicqualitycut = ReplaceAll(Sbasicqualitycut,")<1.4",")<2.4");
|
1342 |
basicqualitycut=TCut(Sbasicqualitycut.c_str());
|
1343 |
|
1344 |
string Sbasiccut = backup_basiccut;
|
1345 |
if(i==1) Sbasiccut = ReplaceAll(Sbasiccut,")<1.4",")<2.4");
|
1346 |
basiccut=TCut(Sbasiccut.c_str());
|
1347 |
|
1348 |
string Sessentialcut = backup_essentialcut;
|
1349 |
if(i==1) Sessentialcut = ReplaceAll(Sessentialcut,")<1.4",")<2.4");
|
1350 |
essentialcut=TCut(Sessentialcut.c_str());
|
1351 |
|
1352 |
string Sleptoncut = backup_leptoncut;
|
1353 |
if(i==1) Sleptoncut = ReplaceAll(Sleptoncut,")<1.4",")<2.4");
|
1354 |
if(i==1) leptoncut=TCut(Sleptoncut.c_str());
|
1355 |
|
1356 |
cout << "Basic cut : " << (const char*) basiccut << endl;
|
1357 |
cout << "Essential cut : " << (const char*) essentialcut << endl;
|
1358 |
|
1359 |
//ProvideEEOverMMEstimate(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut(("mll>20&&"+leptCuts[i]).c_str()));
|
1360 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&"+leptCuts[i]).c_str()),"",metCuts[i],jetCuts[i],nomc,ymax[i]);
|
1361 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&"+leptCuts[i]).c_str()),"",metCuts[i],jetCuts[i],domc,ymax[i]);
|
1362 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&pfJetGoodNumBtag30==0&&"+leptCuts[i]).c_str()),"bTagVeto30",metCuts[i], jetCuts[i],nomc,ymax[i]);
|
1363 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&pfJetGoodNumBtag30>0&&"+leptCuts[i]).c_str()),"AtLeastOneBJet30",metCuts[i],jetCuts[i],nomc,ymax[i]);
|
1364 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&pfJetGoodNumBtag30==0&&"+leptCuts[i]).c_str()),"bTagVeto30",metCuts[i], jetCuts[i],domc,ymax[i]);
|
1365 |
|
1366 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&pfJetGoodNumBtag30>0&&"+leptCuts[i]).c_str()),"AtLeastOneBJet30",metCuts[i], jetCuts[i],domc,ymax[i]);
|
1367 |
|
1368 |
|
1369 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&pfJetGoodNumBtag30>1&&"+leptCuts[i]).c_str()),"AtLeastTwoBJet30",metCuts[i],jetCuts[i],nomc,ymax[i]);
|
1370 |
ProduceMetPlotsWithCut(isAachen, TCut(("mll>20&&pfJetGoodNumBtag30>2&&"+leptCuts[i]).c_str()),"AtLeastThreeBJet30",metCuts[i],jetCuts[i],nomc,ymax[i]);
|
1371 |
|
1372 |
}
|
1373 |
basicqualitycut=TCut(backup_basicqualitycut.c_str());
|
1374 |
basiccut =TCut(backup_basiccut.c_str());
|
1375 |
essentialcut =TCut(backup_essentialcut.c_str());
|
1376 |
leptoncut =TCut(backup_leptoncut.c_str());
|
1377 |
switch_overunderflow(false);
|
1378 |
}
|
1379 |
|
1380 |
void LabelHisto(TH1 *MET_ratio,string titlex, string titley) {
|
1381 |
MET_ratio->GetXaxis()->SetTitle(titlex.c_str());
|
1382 |
MET_ratio->GetXaxis()->CenterTitle();
|
1383 |
MET_ratio->GetYaxis()->SetTitle(titley.c_str());
|
1384 |
MET_ratio->GetYaxis()->CenterTitle();
|
1385 |
}
|
1386 |
|
1387 |
TH1F* GetPredictedAndObservedMetShapes(TCut JetCut, string sPositiveCut,string sNegativeCut,string CorrectedMet,string ObservedMet, string JZBPosvar, string JZBNegvar, float MetCut, int is_data, bool isDYonly, bool isAachen) {
|
1388 |
|
1389 |
//Steps:
|
1390 |
// 1) Prepare samples and histo definition (with "optimal" binning for MET cut)
|
1391 |
// 2) Fill MET histograms
|
1392 |
// 3) Fill JZB histograms
|
1393 |
// 4) Draw them and store them
|
1394 |
// 5) return predicted MET distribution as is (i.e. not scaled by factor of 2!)
|
1395 |
|
1396 |
dout << "*************************************" << endl;
|
1397 |
if(MetPlotsSpace::Debug) {
|
1398 |
cout << "** SUMMARY BEFORE STARTING DRAWING **" << endl;
|
1399 |
cout << "MET variable: " << ObservedMet << endl;
|
1400 |
cout << "Corr. MET var:" << CorrectedMet << endl;
|
1401 |
cout << "JZB pos. var: " << JZBPosvar << endl;
|
1402 |
cout << "JZB neg. var: " << JZBNegvar << endl;
|
1403 |
cout << "JZB pos cut : " << sPositiveCut << endl;
|
1404 |
cout << "JZB neg cut : " << sNegativeCut << endl;
|
1405 |
}
|
1406 |
|
1407 |
if(isAachen) MetPlotsSpace::Zprediction_Uncertainty=0.3;
|
1408 |
|
1409 |
//Step 1: Prepare samples and histo definition
|
1410 |
vector<int> SelectedSamples;
|
1411 |
if(is_data==mc&&isDYonly) {
|
1412 |
SelectedSamples=allsamples.FindSample("DYJets");
|
1413 |
if(SelectedSamples.size()==0) {
|
1414 |
write_error(__FUNCTION__,"Cannot continue, there seems to be no DY sample without Taus - goodbye!");
|
1415 |
assert(SelectedSamples.size()>0);
|
1416 |
}
|
1417 |
}
|
1418 |
|
1419 |
float DisplayedBinSize=10.0; // this is the bin size that we use for plotting
|
1420 |
|
1421 |
float BinWidth=1.0;
|
1422 |
float xmin=0;
|
1423 |
float xmax=150;
|
1424 |
if(isAachen) xmax=160;
|
1425 |
if(MetCut>=xmax) xmax=MetCut+10;
|
1426 |
int nbins=int((xmax-xmin)/BinWidth);
|
1427 |
|
1428 |
float pt2cut=20;
|
1429 |
if(isAachen)pt2cut=10;
|
1430 |
|
1431 |
stringstream basiccut;
|
1432 |
basiccut << (const char*) JetCut << "&&" << (const char*) Restrmasscut << "&&" << (const char*) leptoncut << "&&pt1>20&&pt2>" << pt2cut;
|
1433 |
|
1434 |
if(is_data==mc&&isDYonly) basiccut << " && !EventZToTaus";
|
1435 |
|
1436 |
stringstream cMET_observed;
|
1437 |
cMET_observed << "(" << basiccut.str() << "&&(" << sPositiveCut << ")&&" << (const char*) cutOSSF << ")";
|
1438 |
stringstream cMET_ttbar_pred;
|
1439 |
cMET_ttbar_pred << "(" << basiccut.str() << "&&(" << sPositiveCut << ")&&" << (const char*) cutOSOF << ")";
|
1440 |
stringstream cMET_osof_pred;
|
1441 |
cMET_osof_pred << "(" << basiccut.str() << "&&(" << sNegativeCut << ")&&" << (const char*) cutOSOF << ")";
|
1442 |
stringstream cMET_ossf_pred;
|
1443 |
cMET_ossf_pred << "(" << basiccut.str() << "&&(" << sNegativeCut << ")&&" << (const char*) cutOSSF << ")";
|
1444 |
|
1445 |
//Step 2: Fill Met histograms
|
1446 |
float bottommargin=gStyle->GetPadBottomMargin();
|
1447 |
float canvas_height=gStyle->GetCanvasDefH();
|
1448 |
float canvas_width=gStyle->GetCanvasDefW();
|
1449 |
float ratiospace=0.25;// space the ratio should take up (relative to original pad)
|
1450 |
|
1451 |
float ratiobottommargin=0.3;
|
1452 |
float ratiotopmargin=0.1;
|
1453 |
|
1454 |
float xstretchfactor=((1-ratiospace)*(1-gStyle->GetPadTopMargin()))/((1)*ratiospace);
|
1455 |
|
1456 |
TCanvas *main_canvas = new TCanvas("main_canvas","main_canvas",(Int_t)canvas_width,(Int_t)(canvas_height*(1+ratiospace)));
|
1457 |
TPad *mainpad = new TPad("mainpad","mainpad",0,1-(1.0/(1+ratiospace)),1,1);//top (main) pad
|
1458 |
TPad *coverpad = new TPad("coverpad","coverpad",gStyle->GetPadLeftMargin()-0.008,1-(1.0/(1+ratiospace))-0.04,1,1-(1.0/(1+ratiospace))+0.103);//pad covering up the x scale
|
1459 |
TPad *bottompad = new TPad("bottompad", "Ratio Pad",0,0,1,(1-(1-bottommargin)/(1+ratiospace))-0.015); //bottom pad
|
1460 |
|
1461 |
main_canvas->Range(0,0,1,1);
|
1462 |
main_canvas->SetBorderSize(0);
|
1463 |
main_canvas->SetFrameFillColor(0);
|
1464 |
|
1465 |
mainpad->Draw();
|
1466 |
mainpad->cd();
|
1467 |
mainpad->SetLogy(1);
|
1468 |
mainpad->Range(0,0,1,1);
|
1469 |
mainpad->SetFillColor(kWhite);
|
1470 |
mainpad->SetBorderSize(0);
|
1471 |
mainpad->SetFrameFillColor(0);
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
TH1F *MET_observed = allsamples.Draw("MET_observed",ObservedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
1477 |
TCut(cMET_observed.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1478 |
TH1F *MET_ossf_pred = allsamples.Draw("MET_ossf_pred",CorrectedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
1479 |
TCut(cMET_ossf_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1480 |
TH1F *MET_osof_pred = allsamples.Draw("MET_osof_pred",CorrectedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
1481 |
TCut(cMET_osof_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1482 |
TH1F *MET_ttbar_pred= allsamples.Draw("MET_ttbar_pred",ObservedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
1483 |
TCut(cMET_ttbar_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1484 |
|
1485 |
|
1486 |
if((isDYonly && is_data==mc) || is_data==data) {
|
1487 |
TH1F *MET_truth = allsamples.Draw("MET_truth",ObservedMet,1,MetCut,10000,"MET [GeV]","events",TCut(((string)"met[4]/MetFactor>"+any2string(MetCut)).c_str())&&cutOSSF&&TCut(basiccut.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1488 |
TH1F *eeMET_truth = allsamples.Draw("eeMET_truth",ObservedMet,1,MetCut,10000,"MET [GeV]","events",TCut(((string)"id1==0 && met[4]/MetFactor>"+any2string(MetCut)).c_str())&&cutOSSF&&TCut(basiccut.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1489 |
TH1F *mmMET_truth = allsamples.Draw("mmMET_truth",ObservedMet,1,MetCut,10000,"MET [GeV]","events",TCut(((string)"id1==1 && met[4]/MetFactor>"+any2string(MetCut)).c_str())&&cutOSSF&&TCut(basiccut.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1490 |
TH1F *MET_otruth = allsamples.Draw("MET_otruth",ObservedMet,1,MetCut,10000,"MET [GeV]","events",TCut(((string)"met[4]/MetFactor>"+any2string(MetCut)).c_str())&&cutOSOF&&TCut(basiccut.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1491 |
if(is_data==mc) write_info(__FUNCTION__,"In Z peak: DY Truth is : "+any2string(MET_truth->Integral()));
|
1492 |
if(is_data==data) {
|
1493 |
ofstream NiceSummary;
|
1494 |
NiceSummary.open("Summary.txt",ios::app);
|
1495 |
write_info(__FUNCTION__,"In Z peak: Observed : " +any2string(MET_truth->Integral()) + "( ee: "+any2string(eeMET_truth->Integral()) + " , mm: "+any2string(mmMET_truth->Integral())+" )");
|
1496 |
write_info(__FUNCTION__,"In Z peak: TTbar est: " +any2string(MET_otruth->Integral()));
|
1497 |
NiceSummary << " **** Z peak estimation **** " << endl;
|
1498 |
NiceSummary << "Z peak observed : " << any2string(MET_truth->Integral()) << "( ee: " <<any2string(eeMET_truth->Integral()) << " , mm: "<<any2string(mmMET_truth->Integral()) << " )" << endl;
|
1499 |
NiceSummary << "Z peak ttbar pred: " << any2string(MET_otruth->Integral()) << endl;
|
1500 |
NiceSummary.close();
|
1501 |
}
|
1502 |
delete MET_truth;
|
1503 |
delete MET_otruth;
|
1504 |
delete eeMET_truth;
|
1505 |
delete mmMET_truth;
|
1506 |
}
|
1507 |
|
1508 |
// write_info(__FUNCTION__,"Full cut!");
|
1509 |
// cout << (const char*)(TCut(((string)"met[4]/MetFactor>"+any2string(MetCut)).c_str())&&cutOSSF&&TCut(basiccut.str().c_str())) << endl;
|
1510 |
|
1511 |
TH1F *MET_predicted=(TH1F*)MET_ossf_pred->Clone("MET_predicted");
|
1512 |
MET_predicted->Add(MET_osof_pred,-1);
|
1513 |
MET_predicted->Add(MET_ttbar_pred);
|
1514 |
MET_predicted->SetLineColor(kRed);
|
1515 |
MET_observed->SetLineColor(kBlack);
|
1516 |
|
1517 |
TH1F *MET_Z_prediction=(TH1F*)MET_ossf_pred->Clone("MET_Z_prediction");
|
1518 |
MET_Z_prediction->Add(MET_osof_pred,-1);
|
1519 |
MET_Z_prediction->SetLineColor(kBlue);
|
1520 |
|
1521 |
LabelHisto(MET_observed,"MET (GeV)","events");
|
1522 |
|
1523 |
//Step 3: Fill JZB histograms
|
1524 |
|
1525 |
TH1F *JZB_observed = allsamples.Draw("JZB_observed",JZBPosvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
1526 |
TCut(cMET_observed.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1527 |
TH1F *JZB_ossf_pred = allsamples.Draw("JZB_ossf_pred",JZBNegvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
1528 |
TCut(cMET_ossf_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1529 |
TH1F *JZB_osof_pred = allsamples.Draw("JZB_osof_pred",JZBNegvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
1530 |
TCut(cMET_osof_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1531 |
TH1F *JZB_ttbar_pred= allsamples.Draw("JZB_ttbar_pred",JZBPosvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
1532 |
TCut(cMET_ttbar_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
1533 |
|
1534 |
TH1F *JZB_predicted=(TH1F*)JZB_ossf_pred->Clone("JZB_predicted");
|
1535 |
JZB_predicted->Add(JZB_osof_pred,-1);
|
1536 |
JZB_predicted->Add(JZB_ttbar_pred);
|
1537 |
JZB_predicted->SetLineColor(kRed);
|
1538 |
JZB_observed->SetLineColor(kBlack);
|
1539 |
|
1540 |
TH1F *JZB_Z_prediction=(TH1F*)JZB_ossf_pred->Clone("JZB_Z_prediction");
|
1541 |
JZB_Z_prediction->Add(JZB_osof_pred,-1);
|
1542 |
MET_Z_prediction->SetLineColor(kBlue);
|
1543 |
|
1544 |
LabelHisto(JZB_observed,"JZB (GeV)","events");
|
1545 |
|
1546 |
// Step 4: Draw them and store them
|
1547 |
|
1548 |
TLegend *legend = new TLegend(0.6,0.6,0.89,0.89);
|
1549 |
|
1550 |
MET_ttbar_pred->SetLineColor(TColor::GetColor("#005C00"));
|
1551 |
JZB_ttbar_pred->SetLineColor(TColor::GetColor("#005C00"));
|
1552 |
|
1553 |
legend->SetFillColor(kWhite);
|
1554 |
legend->SetBorderSize(0);
|
1555 |
legend->AddEntry(MET_predicted,"prediction","l");
|
1556 |
legend->AddEntry(MET_observed,"observed","p");
|
1557 |
legend->AddEntry(MET_Z_prediction,"predicted Z","l");
|
1558 |
legend->AddEntry(MET_ttbar_pred,"OF-based prediction","l");
|
1559 |
|
1560 |
if(is_data==mc) legend->SetHeader("Simulation:");
|
1561 |
if(is_data==mc&&isDYonly) legend->SetHeader("DY #rightarrow ee,#mu#mu only:");
|
1562 |
if(is_data==data) legend->SetHeader("Data:");
|
1563 |
|
1564 |
stringstream SaveJZBname;
|
1565 |
stringstream SaveMETname;
|
1566 |
if(is_data==data) {
|
1567 |
SaveJZBname << "MetPrediction/JZBdistribution_Data_METCutAt" << MetCut;
|
1568 |
SaveMETname << "MetPrediction/METdistribution_Data_METCutAt" << MetCut;
|
1569 |
}
|
1570 |
if(is_data==mc&&!isDYonly) {
|
1571 |
SaveJZBname << "MetPrediction/JZBdistribution_FullMC_METCutAt" << MetCut;
|
1572 |
SaveMETname << "MetPrediction/METdistribution_FullMC_METCutAt" << MetCut;
|
1573 |
}
|
1574 |
if(is_data==mc&&isDYonly) {
|
1575 |
SaveJZBname << "MetPrediction/JZBdistribution_DYMC_METCutAt" << MetCut;
|
1576 |
SaveMETname << "MetPrediction/METdistribution_DYMC_METCutAt" << MetCut;
|
1577 |
}
|
1578 |
|
1579 |
dout << "Shape summary (MET>50) for ";
|
1580 |
if(is_data==data) dout << "data";
|
1581 |
if(is_data==mc&&isDYonly) dout<< "DY ";
|
1582 |
if(is_data==mc&&!isDYonly) dout << " Full MC";
|
1583 |
dout << " (note that this is only half of the dataset, i.e. comparing JZB<0 to JZB>0) : " << endl;
|
1584 |
|
1585 |
dout << " observed : " << MET_observed->Integral(MET_observed->FindBin(50),MET_observed->FindBin(xmax)) << endl;
|
1586 |
dout << " predicted : " << MET_predicted->Integral(MET_predicted->FindBin(50),MET_predicted->FindBin(xmax)) << endl;
|
1587 |
dout << " Z pred : " << MET_Z_prediction->Integral(MET_Z_prediction->FindBin(50),MET_Z_prediction->FindBin(xmax)) << endl;
|
1588 |
dout << " ttbar : " << MET_ttbar_pred->Integral(MET_ttbar_pred->FindBin(50),MET_ttbar_pred->FindBin(xmax)) << endl;
|
1589 |
|
1590 |
if(1) {
|
1591 |
dout << "Shape summary (MET>80) for ";
|
1592 |
if(is_data==data) dout << "data";
|
1593 |
if(is_data==mc&&isDYonly) dout<< "DY ";
|
1594 |
if(is_data==mc&&!isDYonly) dout << " Full MC";
|
1595 |
dout << " : " << endl;
|
1596 |
|
1597 |
dout << " observed : " << MET_observed->Integral(MET_observed->FindBin(80),MET_observed->FindBin(xmax)) << endl;
|
1598 |
dout << " predicted : " << MET_predicted->Integral(MET_predicted->FindBin(80),MET_predicted->FindBin(xmax)) << endl;
|
1599 |
dout << " Z pred : " << MET_Z_prediction->Integral(MET_Z_prediction->FindBin(80),MET_Z_prediction->FindBin(xmax)) << endl;
|
1600 |
dout << " ttbar : " << MET_ttbar_pred->Integral(MET_ttbar_pred->FindBin(80),MET_ttbar_pred->FindBin(xmax)) << endl;
|
1601 |
}
|
1602 |
|
1603 |
if(1) {
|
1604 |
dout << "Shape summary (MET>100) for ";
|
1605 |
if(is_data==data) dout << "data";
|
1606 |
if(is_data==mc&&isDYonly) dout<< "DY ";
|
1607 |
if(is_data==mc&&!isDYonly) dout << " Full MC";
|
1608 |
dout << " : " << endl;
|
1609 |
|
1610 |
dout << " observed : " << MET_observed->Integral(MET_observed->FindBin(100),MET_observed->FindBin(xmax)) << endl;
|
1611 |
dout << " predicted : " << MET_predicted->Integral(MET_predicted->FindBin(100),MET_predicted->FindBin(xmax)) << endl;
|
1612 |
dout << " Z pred : " << MET_Z_prediction->Integral(MET_Z_prediction->FindBin(100),MET_Z_prediction->FindBin(xmax)) << endl;
|
1613 |
dout << " ttbar : " << MET_ttbar_pred->Integral(MET_ttbar_pred->FindBin(100),MET_ttbar_pred->FindBin(xmax)) << endl;
|
1614 |
}
|
1615 |
|
1616 |
TH1F *ZpredClone = (TH1F*)MET_Z_prediction->Clone("ZpredClone");
|
1617 |
ZpredClone->SetLineColor(kBlue);
|
1618 |
MET_observed->Rebin(int(DisplayedBinSize/BinWidth));
|
1619 |
ZpredClone->Rebin(int(DisplayedBinSize/BinWidth));
|
1620 |
MET_predicted->Rebin(int(DisplayedBinSize/BinWidth));
|
1621 |
MET_ttbar_pred->Rebin(int(DisplayedBinSize/BinWidth));
|
1622 |
|
1623 |
TH1F *JZBZpredClone = (TH1F*)JZB_Z_prediction->Clone("ZpredClone");
|
1624 |
JZBZpredClone->SetLineColor(kBlue);
|
1625 |
JZB_observed->Rebin(int(DisplayedBinSize/BinWidth));
|
1626 |
JZBZpredClone->Rebin(int(DisplayedBinSize/BinWidth));
|
1627 |
JZB_predicted->Rebin(int(DisplayedBinSize/BinWidth));
|
1628 |
JZB_ttbar_pred->Rebin(int(DisplayedBinSize/BinWidth));
|
1629 |
|
1630 |
TH1F *JZB_ratio = (TH1F*)JZB_observed->Clone("JZB_ratio");
|
1631 |
JZB_ratio->Divide(JZB_predicted);
|
1632 |
LabelHisto(JZB_ratio,"JZB (GeV)","obs/pred");
|
1633 |
TH1F *MET_ratio = (TH1F*)MET_observed->Clone("MET_ratio");
|
1634 |
MET_ratio->Divide(MET_predicted);
|
1635 |
MET_observed->SetMaximum(5*MET_observed->GetMaximum());
|
1636 |
JZB_observed->SetMaximum(5*JZB_observed->GetMaximum());
|
1637 |
MET_observed->SetMinimum(0.5);
|
1638 |
JZB_observed->SetMinimum(0.5);
|
1639 |
LabelHisto(MET_ratio,"MET (GeV)","obs/pred");
|
1640 |
TBox *sysenvelope = new TBox(xmin,1.0-MetPlotsSpace::Zprediction_Uncertainty,xmax,1.0+MetPlotsSpace::Zprediction_Uncertainty);
|
1641 |
sysenvelope->SetFillColor(TColor::GetColor("#82FA58")); // light green
|
1642 |
sysenvelope->SetLineWidth(0);
|
1643 |
TBox *dsysenvelope = new TBox(xmin,1.0-2*MetPlotsSpace::Zprediction_Uncertainty,xmax,1.0+2*MetPlotsSpace::Zprediction_Uncertainty);
|
1644 |
dsysenvelope->SetFillColor(TColor::GetColor("#F3F781")); // light yellow
|
1645 |
dsysenvelope->SetLineWidth(0);
|
1646 |
|
1647 |
MET_ratio->GetYaxis()->SetNdivisions(502,false);
|
1648 |
JZB_ratio->GetYaxis()->SetNdivisions(502,false);
|
1649 |
|
1650 |
|
1651 |
MET_observed->Draw("e1");
|
1652 |
MET_ttbar_pred->Draw("histo,same");
|
1653 |
ZpredClone->Draw("histo,same");
|
1654 |
MET_predicted->Draw("histo,same");
|
1655 |
MET_observed->Draw("e1,same");
|
1656 |
legend->Draw();
|
1657 |
if(is_data==data) DrawPrelim();
|
1658 |
else DrawMCPrelim();
|
1659 |
|
1660 |
mainpad->Modified();
|
1661 |
main_canvas->cd();
|
1662 |
coverpad->Draw();
|
1663 |
coverpad->cd();
|
1664 |
coverpad->Range(0,0,1,1);
|
1665 |
coverpad->SetFillColor(kWhite);
|
1666 |
coverpad->SetBorderSize(0);
|
1667 |
coverpad->SetFrameFillColor(0);
|
1668 |
coverpad->Modified();
|
1669 |
main_canvas->cd();
|
1670 |
bottompad->SetTopMargin(ratiotopmargin);
|
1671 |
bottompad->SetBottomMargin(ratiobottommargin);
|
1672 |
bottompad->Draw();
|
1673 |
bottompad->cd();
|
1674 |
bottompad->Range(0,0,1,1);
|
1675 |
bottompad->SetFillColor(kWhite);
|
1676 |
|
1677 |
MET_ratio->GetYaxis()->SetRangeUser(0,2);
|
1678 |
MET_ratio->GetXaxis()->SetLabelSize(xstretchfactor*MET_ratio->GetXaxis()->GetLabelSize());
|
1679 |
MET_ratio->GetYaxis()->SetLabelSize(xstretchfactor*MET_ratio->GetYaxis()->GetLabelSize());
|
1680 |
MET_ratio->GetXaxis()->SetTitleSize(xstretchfactor*gStyle->GetTitleSize());
|
1681 |
MET_ratio->GetYaxis()->SetTitleSize(xstretchfactor*gStyle->GetTitleSize());
|
1682 |
|
1683 |
MET_ratio->Draw("e1");
|
1684 |
// dsysenvelope->Draw();
|
1685 |
sysenvelope->Draw();
|
1686 |
MET_ratio->Draw("AXIS,same");
|
1687 |
MET_ratio->Draw("e1,same");
|
1688 |
TLine *metl = new TLine(xmin,1.0,xmax,1.0);
|
1689 |
metl->SetLineColor(kBlue);
|
1690 |
metl->Draw();
|
1691 |
CompleteSave(main_canvas,SaveMETname.str());
|
1692 |
|
1693 |
//--------------------------------------------------------------------------------------------
|
1694 |
mainpad->cd();
|
1695 |
|
1696 |
JZB_observed->Draw("e1");
|
1697 |
JZB_ttbar_pred->Draw("histo,same");
|
1698 |
JZBZpredClone->Draw("histo,same");
|
1699 |
JZB_predicted->Draw("histo,same");
|
1700 |
JZB_observed->Draw("e1,same");
|
1701 |
legend->Draw();
|
1702 |
if(is_data==data) DrawPrelim();
|
1703 |
else DrawMCPrelim();
|
1704 |
|
1705 |
main_canvas->cd();
|
1706 |
coverpad->Draw();
|
1707 |
main_canvas->cd();
|
1708 |
bottompad->Draw();
|
1709 |
bottompad->cd();
|
1710 |
JZB_ratio->GetYaxis()->SetRangeUser(0,2);
|
1711 |
|
1712 |
JZB_ratio->GetXaxis()->SetLabelSize(xstretchfactor*JZB_ratio->GetXaxis()->GetLabelSize());
|
1713 |
JZB_ratio->GetYaxis()->SetLabelSize(xstretchfactor*JZB_ratio->GetYaxis()->GetLabelSize());
|
1714 |
JZB_ratio->GetXaxis()->SetTitleSize(xstretchfactor*gStyle->GetTitleSize());
|
1715 |
JZB_ratio->GetYaxis()->SetTitleSize(xstretchfactor*gStyle->GetTitleSize());
|
1716 |
|
1717 |
JZB_ratio->Draw("e1");
|
1718 |
// dsysenvelope->Draw();
|
1719 |
sysenvelope->Draw();
|
1720 |
JZB_ratio->Draw("AXIS,same");
|
1721 |
JZB_ratio->Draw("e1,same");
|
1722 |
metl->Draw();
|
1723 |
|
1724 |
CompleteSave(main_canvas,SaveJZBname.str());
|
1725 |
|
1726 |
//--------------------------------------------------------------------------------------------
|
1727 |
mainpad->cd();
|
1728 |
|
1729 |
TH1F *SystHisto = (TH1F*)MET_predicted->Clone("SystHisto");
|
1730 |
TGraphErrors *stat3jS = MakeErrorGraphSystematicAndStatistical(MET_ttbar_pred,ZpredClone,MET_predicted,SystHisto);
|
1731 |
MET_predicted->SetLineColor(TColor::GetColor("#cc0066"));
|
1732 |
ZpredClone->SetLineColor(TColor::GetColor("#006600"));
|
1733 |
ZpredClone->SetFillColor(TColor::GetColor("#006600"));
|
1734 |
ZpredClone->SetFillStyle(3002); // light dots, not crushing other information
|
1735 |
ZpredClone->SetLineStyle(2);
|
1736 |
|
1737 |
TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
|
1738 |
kinpad->SetLogy(1);
|
1739 |
kinpad->cd();
|
1740 |
|
1741 |
MET_observed->Draw("e1");
|
1742 |
stat3jS->Draw("2,same");
|
1743 |
MET_observed->Draw("e1,same");
|
1744 |
ZpredClone->Draw("histo,same");
|
1745 |
MET_predicted->Draw("histo,same");
|
1746 |
MET_observed->Draw("e1,same");
|
1747 |
|
1748 |
TLegend *legend2 = make_legend();
|
1749 |
legend2->SetX1(0.52);
|
1750 |
if (isAachen) legend2->SetHeader("N_{j}#geq 2");
|
1751 |
else legend2->SetHeader("N_{j}#geq 3");
|
1752 |
legend2->AddEntry(MET_observed,"Data","PL");
|
1753 |
legend2->AddEntry(MET_predicted,"Total backgrounds","L");
|
1754 |
legend2->AddEntry(ZpredClone,"DY (JZB)","FL");
|
1755 |
legend2->AddEntry(stat3jS,"Total uncert.","F");
|
1756 |
|
1757 |
legend2->Draw();
|
1758 |
if(is_data==data) DrawPrelim();
|
1759 |
else DrawMCPrelim();
|
1760 |
|
1761 |
cout << "About to store syst plot ... " << endl;
|
1762 |
save_with_ratio_and_sys_band(0.0, MET_observed, MET_predicted, kinpad, (SaveMETname.str()+"__WithSys"), false, false, "data/pred",SystHisto );
|
1763 |
|
1764 |
delete main_canvas;
|
1765 |
delete MET_observed;
|
1766 |
delete MET_predicted;
|
1767 |
//do NOT delete MET_Z_prediction (it's the return value)
|
1768 |
delete MET_osof_pred;
|
1769 |
delete MET_ossf_pred;
|
1770 |
delete MET_ttbar_pred;
|
1771 |
|
1772 |
delete JZB_observed;
|
1773 |
delete JZB_predicted;
|
1774 |
delete JZB_osof_pred;
|
1775 |
delete JZB_ossf_pred;
|
1776 |
delete JZB_Z_prediction;
|
1777 |
delete JZB_ttbar_pred;
|
1778 |
|
1779 |
return MET_Z_prediction;
|
1780 |
}
|
1781 |
|
1782 |
float extract_correction(string jzbvariable) {
|
1783 |
int position = (int)jzbvariable.find("[1]");
|
1784 |
if(position==-1) return 0.0;
|
1785 |
string correction=jzbvariable.substr(position+3,jzbvariable.length()-position-3);
|
1786 |
position = (int)correction.find("*");
|
1787 |
if(position==-1) return 0.0;
|
1788 |
correction=correction.substr(0,position);
|
1789 |
float correctionvalue=atof(correction.c_str());
|
1790 |
assert(correctionvalue<1&&correctionvalue>0);
|
1791 |
return correctionvalue;
|
1792 |
}
|
1793 |
|
1794 |
float Get_Met_Z_Prediction(TCut JetCut, float MetCut, int isdata, bool isDYonly, bool isAachen=false) {
|
1795 |
dout << "Going to compute Z region prediction for a MET cut at " << MetCut << " GeV" << endl;
|
1796 |
// Steps:
|
1797 |
// 1) Get peak
|
1798 |
// 2) use the peak and pt correction for sample splitting
|
1799 |
// and for MET distribution shifting
|
1800 |
// 3) compute the estimate for MET>MetCut
|
1801 |
|
1802 |
// do this for data if isdata==data, otherwise for MC (full closure if isDYonly==false, otherwise use only DY sample)
|
1803 |
|
1804 |
// Step 0 : If we're dealing with DY, we need to make sure PURW is off!
|
1805 |
// string bkpcutweight = (const char*) cutWeight;
|
1806 |
// if(isdata==mc && isDYonly) cutWeight=TCut("1.0");
|
1807 |
|
1808 |
// Step 1) Get peak
|
1809 |
float MCPeakNoPtCorr=0,MCPeakErrorNoPtCorr=0,DataPeakNoPtCorr=0,DataPeakErrorNoPtCorr=0,MCSigma=0,DataSigma=0;
|
1810 |
stringstream resultsNoPtCorr;
|
1811 |
stringstream NoPtCorrdatajzb;
|
1812 |
stringstream NoPtCorrmcjzb;
|
1813 |
|
1814 |
if(isAachen) {
|
1815 |
//need to make sure that none of the typical basic cuts contain problematic selections!
|
1816 |
/* string Sleptoncut = (const char*) leptoncut;
|
1817 |
if((int)Sleptoncut.find("abs(eta1)<1.4")>-1) {
|
1818 |
write_error(__FUNCTION__,"You're trying to compute the Aachen estimate but are requiring abs(eta1)<1.4 ... please check your config.");
|
1819 |
assert((int)Sleptoncut.find("abs(eta1)<1.4")==-1);
|
1820 |
assert((int)Sleptoncut.find("abs(eta1)<1.4")==-1);
|
1821 |
}*/
|
1822 |
} else {
|
1823 |
/* string Sleptoncut = (const char*) leptoncut;
|
1824 |
if((int)Sleptoncut.find("abs(eta1)<2.4")>-1) {
|
1825 |
write_error(__FUNCTION__,"You're trying to compute the ETH estimate but you are using non-central leptons ... please check your config.");
|
1826 |
assert((int)Sleptoncut.find("abs(eta1)<2.4")==-1);
|
1827 |
assert((int)Sleptoncut.find("abs(eta2)<2.4")==-1);
|
1828 |
}*/
|
1829 |
}
|
1830 |
|
1831 |
|
1832 |
float Ptcorrection=0.0;
|
1833 |
|
1834 |
if(isdata==data) Ptcorrection=extract_correction(PlottingSetup::jzbvariabledata);
|
1835 |
else Ptcorrection=extract_correction(PlottingSetup::jzbvariablemc);
|
1836 |
|
1837 |
bool OverFlowStatus=addoverunderflowbins;
|
1838 |
|
1839 |
find_peaks(MCPeakNoPtCorr,MCPeakErrorNoPtCorr, DataPeakNoPtCorr,DataPeakErrorNoPtCorr,resultsNoPtCorr,true,NoPtCorrdatajzb,NoPtCorrmcjzb,(const char*) JetCut, true);
|
1840 |
switch_overunderflow(OverFlowStatus);
|
1841 |
|
1842 |
float PeakPosition=0.0;
|
1843 |
string jzbvariable;
|
1844 |
if(isdata==data) {
|
1845 |
PeakPosition=DataPeakNoPtCorr;
|
1846 |
jzbvariable=jzbvariabledata;
|
1847 |
dout << "Found peak in data at " << DataPeakNoPtCorr << " +/- " << DataPeakErrorNoPtCorr << " ; will use this result (" << PeakPosition << ")" << endl;
|
1848 |
} else {
|
1849 |
PeakPosition=MCPeakNoPtCorr;
|
1850 |
jzbvariable=jzbvariablemc;
|
1851 |
dout << "Found peak in mc at " << MCPeakNoPtCorr << " +/- " << MCPeakErrorNoPtCorr << " ; will use this result (" << PeakPosition << ")" << endl;
|
1852 |
}
|
1853 |
|
1854 |
// Step 2: Use peak for sample splitting and MET shifting
|
1855 |
string CorrectedMet="met[4]/MetFactor-"+any2string(Ptcorrection)+"*pt +"+any2string(abs(1.0*(PeakPosition)));
|
1856 |
if(2*(PeakPosition)<0) CorrectedMet="met[4]/MetFactor-"+any2string(Ptcorrection)+"*pt -"+any2string(abs(1.0*(PeakPosition)));
|
1857 |
|
1858 |
stringstream sPositiveCut;
|
1859 |
if(PeakPosition>0) sPositiveCut << "((" << jzbvariable << "-" << PeakPosition << ")>0)";
|
1860 |
else sPositiveCut << "( " << jzbvariable << "+" << abs(PeakPosition) << ")>0)";
|
1861 |
|
1862 |
stringstream sNegativeCut;
|
1863 |
if(PeakPosition<0) sNegativeCut << "((" << jzbvariable << "+" << abs(PeakPosition) << ")<0)";
|
1864 |
else sNegativeCut << "(( " << jzbvariable << "-" << abs(PeakPosition) << ")<0)";
|
1865 |
|
1866 |
string ObservedMet="met[4]/MetFactor";
|
1867 |
|
1868 |
stringstream JZBPosvar;
|
1869 |
JZBPosvar<<jzbvariable;
|
1870 |
if(PeakPosition>0) JZBPosvar << "-" << PeakPosition;
|
1871 |
else JZBPosvar << "+" << abs(PeakPosition);
|
1872 |
|
1873 |
stringstream JZBNegvar;
|
1874 |
JZBNegvar<<"-(" << jzbvariable;
|
1875 |
if(PeakPosition>0) JZBNegvar << "-" << PeakPosition << ")";
|
1876 |
else JZBNegvar << "+" << abs(PeakPosition) << ")";
|
1877 |
|
1878 |
|
1879 |
// Step 3: Compute estimate
|
1880 |
TH1F *predicted = GetPredictedAndObservedMetShapes(JetCut, sPositiveCut.str(),sNegativeCut.str(),CorrectedMet,ObservedMet,JZBPosvar.str(),JZBNegvar.str(), MetCut, isdata, isDYonly, isAachen);
|
1881 |
|
1882 |
float ZregionZestimate=0;
|
1883 |
for(int ibin=1;ibin<=(int)predicted->GetNbinsX();ibin++) {
|
1884 |
if(predicted->GetBinLowEdge(ibin)+predicted->GetBinWidth(ibin)>MetCut) {
|
1885 |
ZregionZestimate+=2*(predicted->GetBinContent(ibin));
|
1886 |
}
|
1887 |
}
|
1888 |
|
1889 |
dout << " Z region estimate in MET>" << MetCut << " for this sample: " << ZregionZestimate << endl;
|
1890 |
ofstream NiceSummary;
|
1891 |
NiceSummary.open("Summary.txt",ios::app);
|
1892 |
NiceSummary<< " Z peak Z estimate in MET>" << MetCut << " for this sample: " << ZregionZestimate << endl;
|
1893 |
NiceSummary.close();
|
1894 |
|
1895 |
if(isdata==data) {
|
1896 |
MetPlotsSpace::Zestimate__data=ZregionZestimate;
|
1897 |
MetPlotsSpace::Zestimate__data_stat=2*TMath::Sqrt(ZregionZestimate/2);
|
1898 |
MetPlotsSpace::Zestimate__data_sys=ZregionZestimate*MetPlotsSpace::Zprediction_Uncertainty;
|
1899 |
}
|
1900 |
if(isdata==mc && isDYonly) {
|
1901 |
MetPlotsSpace::Zestimate__dy=ZregionZestimate;
|
1902 |
MetPlotsSpace::Zestimate__dy_stat=2*TMath::Sqrt(ZregionZestimate/2);
|
1903 |
MetPlotsSpace::Zestimate__dy_sys=ZregionZestimate*MetPlotsSpace::Zprediction_Uncertainty;
|
1904 |
}
|
1905 |
if(isdata==mc && !isDYonly) {
|
1906 |
MetPlotsSpace::Zestimate__mc=ZregionZestimate;
|
1907 |
MetPlotsSpace::Zestimate__mc_stat=2*TMath::Sqrt(ZregionZestimate/2);
|
1908 |
MetPlotsSpace::Zestimate__mc_sys=ZregionZestimate*MetPlotsSpace::Zprediction_Uncertainty;
|
1909 |
}
|
1910 |
|
1911 |
|
1912 |
|
1913 |
// if(isdata==mc && isDYonly) cutWeight=TCut(bkpcutweight.c_str());
|
1914 |
|
1915 |
return ZregionZestimate;
|
1916 |
}
|
1917 |
|
1918 |
void ProvideEEOverMMEstimate(TCut GeneralCut) {
|
1919 |
TCanvas *eemmcan = new TCanvas("eemmcan","eemmcan");
|
1920 |
TCut completecut = TCut(GeneralCut&&Restrmasscut);
|
1921 |
TH1F *eeh = allsamples.Draw("eeh", "mll",1,70,120,"m_{ll}","events",completecut&&TCut("id1==0"),data,luminosity);
|
1922 |
TH1F *mmh = allsamples.Draw("mmh", "mll",1,70,120,"m_{ll}","events",completecut&&TCut("id1==1"),data,luminosity);
|
1923 |
|
1924 |
float Nee = eeh->Integral();
|
1925 |
float Nmm = mmh->Integral();
|
1926 |
|
1927 |
dout << "Ratio R(ee/mm) = " << Nee/Nmm << " +/- " << sqrt(1/(Nee) + 1/(Nmm)) << endl;
|
1928 |
|
1929 |
delete eemmcan;
|
1930 |
delete eeh;
|
1931 |
delete mmh;
|
1932 |
}
|
1933 |
|
1934 |
void ExperimentalMetPrediction(bool QuickRun=false, bool isAachen=false, bool override_cuts) {
|
1935 |
|
1936 |
switch_overunderflow(true);
|
1937 |
|
1938 |
bool HighPurityMode=true; // High Purity = |mll-91|<10 GeV , else <20
|
1939 |
|
1940 |
if(QuickRun) {
|
1941 |
HighPurityMode=true;
|
1942 |
}
|
1943 |
|
1944 |
string restrmasscutbkp=(const char*) PlottingSetup::Restrmasscut;
|
1945 |
|
1946 |
if(HighPurityMode) PlottingSetup::Restrmasscut=TCut("abs(mll-91)<10");
|
1947 |
else PlottingSetup::Restrmasscut= TCut("abs(mll-91)<20");
|
1948 |
|
1949 |
dout << "Aachen mode (20/10, 2 jets) ? " << isAachen << endl;
|
1950 |
dout << "High Purity mode? " << HighPurityMode << endl;
|
1951 |
dout << "Quick Mode ? " << QuickRun << endl;
|
1952 |
|
1953 |
string backup_basicqualitycut = (const char*) basicqualitycut;
|
1954 |
string backup_essentialcut = (const char*) essentialcut;
|
1955 |
string backup_basiccut = (const char*) basiccut;
|
1956 |
string backup_leptoncut = (const char*) leptoncut;
|
1957 |
|
1958 |
if(isAachen && override_cuts) {
|
1959 |
cout << "Overriding cuts for Aachen" << endl;
|
1960 |
string Sbasicqualitycut = backup_basicqualitycut;
|
1961 |
Sbasicqualitycut = ReplaceAll(Sbasicqualitycut,")<1.4",")<2.4");
|
1962 |
basicqualitycut=TCut(Sbasicqualitycut.c_str());
|
1963 |
|
1964 |
string Sleptoncut = backup_leptoncut;
|
1965 |
Sleptoncut = ReplaceAll(Sleptoncut,")<1.4",")<2.4");
|
1966 |
leptoncut=TCut(Sleptoncut.c_str());
|
1967 |
|
1968 |
string Sbasiccut = backup_basiccut;
|
1969 |
Sbasiccut = ReplaceAll(Sbasiccut,")<1.4",")<2.4");
|
1970 |
basiccut=TCut(Sbasiccut.c_str());
|
1971 |
|
1972 |
string Sessentialcut = backup_essentialcut;
|
1973 |
Sessentialcut = ReplaceAll(Sessentialcut,")<1.4",")<2.4");
|
1974 |
essentialcut=TCut(Sessentialcut.c_str());
|
1975 |
|
1976 |
}
|
1977 |
|
1978 |
cout << "Basic cut : " << (const char*) basiccut << endl;
|
1979 |
cout << "Essential cut : " << (const char*) essentialcut << endl;
|
1980 |
|
1981 |
stringstream snjets;
|
1982 |
if(isAachen) snjets << 2;
|
1983 |
else snjets << 3;
|
1984 |
float maxMET=100;
|
1985 |
if(isAachen) maxMET=150;
|
1986 |
|
1987 |
TCut nJetsSignal(PlottingSetup::basicqualitycut&&("pfJetGoodNum40>="+snjets.str()).c_str());
|
1988 |
|
1989 |
|
1990 |
dout << " ***** TESTING Z PREDICTION ***** " << endl;
|
1991 |
dout << "Notation (you can copy & paste this to evaluate it further)" << endl;
|
1992 |
dout << "Cut;Data;MC;DY;" << endl;
|
1993 |
float DataEstimate = -1;
|
1994 |
DataEstimate = Get_Met_Z_Prediction(Restrmasscut&&nJetsSignal,maxMET, data, false, isAachen);
|
1995 |
float DYEstimate=-1;
|
1996 |
if(!QuickRun) DYEstimate = Get_Met_Z_Prediction(Restrmasscut&&nJetsSignal,maxMET, mc, true, isAachen);
|
1997 |
float MCEstimate=-1;
|
1998 |
if(!QuickRun) MCEstimate = Get_Met_Z_Prediction(Restrmasscut&&nJetsSignal,maxMET, mc, false, isAachen);
|
1999 |
|
2000 |
dout << "Z prediction (JZB based) " << DataEstimate << endl;
|
2001 |
write_info(__FUNCTION__,"Z prediction (JZB based) "+any2string(DataEstimate));
|
2002 |
if(QuickRun) return;
|
2003 |
dout << maxMET << ";" << DataEstimate << ";" << MCEstimate << ";" << DYEstimate << endl;
|
2004 |
|
2005 |
float Diff=20.0;
|
2006 |
if(HighPurityMode) Diff=10;
|
2007 |
TCut cut("mll>20&&pt1>20&&pt2>20");
|
2008 |
if (isAachen) cut = TCut("mll>20&&pt1>20&&pt2>20&&pfTightHT>100");
|
2009 |
|
2010 |
TCanvas *qcan = new TCanvas("qcan","qcan");
|
2011 |
TH1F *zlineshape = allsamples.Draw("zlineshape","mll",int((91+25-18)*5),18,91+25,"m_{ll} (GeV)","events",cutOSSF&&TCut("pfJetGoodNum40==2")&&cut,data,PlottingSetup::luminosity); // bins of 0.2 GeV
|
2012 |
TH1F *Ozlineshape = allsamples.Draw("Ozlineshape","mll",int((91+25-18)*5),18,91+25,"m_{ll} (GeV)","events",cutOSOF&&TCut("pfJetGoodNum40==2")&&cut,data,PlottingSetup::luminosity); // bins of 0.2 GeV
|
2013 |
zlineshape->Add(Ozlineshape,-1);
|
2014 |
delete qcan;
|
2015 |
float a = (zlineshape->Integral(zlineshape->FindBin(20),zlineshape->FindBin(70)));
|
2016 |
float b = (zlineshape->Integral(zlineshape->FindBin(91-Diff),zlineshape->FindBin(91+Diff)));
|
2017 |
float r = a/b;
|
2018 |
float dr= (a/b)*TMath::Sqrt(1/a+1/b);
|
2019 |
|
2020 |
float SysUncertainty = TMath::Sqrt(DataEstimate*DataEstimate*dr*dr + r*r*(DataEstimate*MetPlotsSpace::Zprediction_Uncertainty*DataEstimate*MetPlotsSpace::Zprediction_Uncertainty));
|
2021 |
float StatUncertainty = TMath::Sqrt(DataEstimate);
|
2022 |
|
2023 |
dout << "Z estimate in peak : " << DataEstimate << " +/- " << DataEstimate*MetPlotsSpace::Zprediction_Uncertainty << " (sys) +/- " << TMath::Sqrt(2*DataEstimate) << " (stat) " << endl;
|
2024 |
dout << "Z ESTIMATE IN SR : " << DataEstimate*r << " +/- " << SysUncertainty << " (sys) +/- " << StatUncertainty << " (stat) " << endl;
|
2025 |
// cout << endl;
|
2026 |
dout << "r = " << r << " +/- " << dr << endl;
|
2027 |
|
2028 |
|
2029 |
delete Ozlineshape;
|
2030 |
delete zlineshape;
|
2031 |
|
2032 |
PlottingSetup::Restrmasscut=TCut(restrmasscutbkp.c_str());
|
2033 |
|
2034 |
basicqualitycut=TCut(backup_basicqualitycut.c_str());
|
2035 |
basiccut =TCut(backup_basiccut.c_str());
|
2036 |
essentialcut =TCut(backup_essentialcut.c_str());
|
2037 |
leptoncut =TCut(backup_leptoncut.c_str());
|
2038 |
|
2039 |
switch_overunderflow(false);
|
2040 |
|
2041 |
}
|
2042 |
|
2043 |
|
2044 |
|
2045 |
void ComputeRMuE(string basecut, string name) {
|
2046 |
|
2047 |
|
2048 |
dout << "Starting with computation of rmue, but need to reset the essential cut first to make sure no restriction on eta is in there" << endl;
|
2049 |
|
2050 |
string backup_essentialcut = (const char*) essentialcut;
|
2051 |
string NewEssentialCut = backup_essentialcut;
|
2052 |
NewEssentialCut = ReplaceAll(NewEssentialCut,")<1.4",")<2.4");
|
2053 |
essentialcut = TCut(NewEssentialCut.c_str());
|
2054 |
|
2055 |
TCut kbase((basecut+" && mll>60 && mll<120").c_str());
|
2056 |
TCut ee("id1==id2&&id1==0");
|
2057 |
TCut mm("id1==id2&&id1==1");
|
2058 |
|
2059 |
TH1F *Dee = allsamples.Draw("Dee", "mll",100,60,120,"m_{ll}","events",kbase&&ee,data,luminosity);
|
2060 |
TH1F *Dmm = allsamples.Draw("Dmm", "mll",100,60,120,"m_{ll}","events",kbase&&mm,data,luminosity);
|
2061 |
TH1F *Mee = allsamples.Draw("Mee", "mll",100,60,120,"m_{ll}","events",kbase&&ee,mc,luminosity);
|
2062 |
TH1F *Mmm = allsamples.Draw("Mmm", "mll",100,60,120,"m_{ll}","events",kbase&&mm,mc,luminosity);
|
2063 |
|
2064 |
|
2065 |
float mc_rmue=sqrt(Mmm->Integral()/Mee->Integral());
|
2066 |
float d_mc_rmue = sqrt(1/(4*Mee->Integral())+Mmm->Integral()/(4*Mee->Integral()*Mee->Integral()));
|
2067 |
float data_rmue=sqrt(Dmm->Integral()/Dee->Integral());
|
2068 |
float d_data_rmue = sqrt(1/(4*Dee->Integral())+Dmm->Integral()/(4*Dee->Integral()*Dee->Integral()));
|
2069 |
|
2070 |
dout << "Rmu table (" << name << ") : " << endl;
|
2071 |
dout << " \t n_{\\mu\\mu} \t n_{ee} \t r_{\\mu e} \\pm stat" << endl;
|
2072 |
dout << fixed << "MC \t " << Mmm->Integral() << " \t " << Mee->Integral() << "\t" << mc_rmue << " \\pm " << d_mc_rmue << endl;
|
2073 |
dout << fixed << "Data\t" << Dmm->Integral() << " \t " << Dee->Integral() << "\t" << data_rmue << " \\pm " << d_data_rmue << endl;
|
2074 |
|
2075 |
delete Dee;
|
2076 |
delete Dmm;
|
2077 |
delete Mee;
|
2078 |
delete Mmm;
|
2079 |
|
2080 |
essentialcut =TCut(backup_essentialcut.c_str());
|
2081 |
}
|
2082 |
|
2083 |
|
2084 |
void ComputeRMuE() {
|
2085 |
TCanvas *rmucanvas = new TCanvas("rmucanvas","rmucanvas");
|
2086 |
dout << "Starting with our selection (ETH/Tight) : " << endl;
|
2087 |
ComputeRMuE("abs(eta1)<1.4 && abs(eta2)<1.4 && pt1>20 && pt2>20"," Tight selection");
|
2088 |
dout << "And now the Aachen selection (Aachen/Loose) : " << endl;
|
2089 |
ComputeRMuE("abs(eta1)<2.4 && abs(eta2)<2.4 && pt1>20 && pt2>20"," Loose selection");
|
2090 |
delete rmucanvas;
|
2091 |
}
|
2092 |
|