1 |
buchmann |
1.1 |
#include <iostream>
|
2 |
|
|
|
3 |
|
|
using namespace std;
|
4 |
|
|
|
5 |
buchmann |
1.17 |
float Get_Met_Z_Prediction(TCut JetCut, float MetCut, int isdata, bool isDYonly);
|
6 |
|
|
|
7 |
|
|
|
8 |
buchmann |
1.1 |
TGraphErrors* MakeErrorGraph(TH1F *histo) {
|
9 |
|
|
|
10 |
|
|
float dx[histo->GetNbinsX()];
|
11 |
|
|
float dy[histo->GetNbinsX()];
|
12 |
|
|
float x[histo->GetNbinsX()];
|
13 |
|
|
float y[histo->GetNbinsX()];
|
14 |
|
|
for(int i=1;i<=histo->GetNbinsX();i++) {
|
15 |
|
|
x[i-1]=histo->GetBinCenter(i);
|
16 |
|
|
y[i-1]=histo->GetBinContent(i);
|
17 |
|
|
if(i>1) dx[i-1]=(histo->GetBinCenter(i)-histo->GetBinCenter(i-1))/2.0;
|
18 |
|
|
else dx[i-1]=(histo->GetBinCenter(i+1)-histo->GetBinCenter(i))/2.0;
|
19 |
|
|
dy[i-1]=histo->GetBinError(i);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
TGraphErrors *gr = new TGraphErrors(histo->GetNbinsX(),x,y,dx,dy);
|
23 |
|
|
gr->SetFillColor(TColor::GetColor("#2E9AFE"));
|
24 |
|
|
return gr;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
fronga |
1.19 |
void ProduceMetPlotsWithCut(TCut cut, string name, float cutat, float cutConHigh, int njets, bool doMC = false ) {
|
28 |
fronga |
1.16 |
|
29 |
buchmann |
1.1 |
TCanvas *tcan = new TCanvas("tcan","tcan");
|
30 |
|
|
cout << "Doing met plots" << endl;
|
31 |
buchmann |
1.2 |
stringstream MetBaseCuts;
|
32 |
fronga |
1.7 |
MetBaseCuts << "met[4]>" << cutat << "&&" << cut.GetTitle();
|
33 |
|
|
stringstream snjets;
|
34 |
|
|
snjets << njets;
|
35 |
fronga |
1.19 |
stringstream MetConCut;
|
36 |
|
|
MetConCut << "met[4]>" << cutConHigh;
|
37 |
buchmann |
1.2 |
TCut MetBaseCut(MetBaseCuts.str().c_str());
|
38 |
fronga |
1.10 |
TCut nJetsSignal(PlottingSetup::basicqualitycut&&("pfJetGoodNum40>="+snjets.str()).c_str());
|
39 |
fronga |
1.19 |
TCut nJetsControl((MetConCut.str()+"&&pfJetGoodID[0]!=0&&pfJetGoodNum40<"+snjets.str()).c_str());
|
40 |
fronga |
1.16 |
|
41 |
|
|
if ( !PlottingSetup::openBox ) {
|
42 |
|
|
nJetsSignal += TCut("mll>120");
|
43 |
|
|
}
|
44 |
buchmann |
1.1 |
|
45 |
|
|
//compute SF / OF rate in (CR1+CR2), should give 0.941 +/- 0.05
|
46 |
fronga |
1.7 |
|
47 |
|
|
// Create histograms
|
48 |
fronga |
1.9 |
//int nbins = 30;
|
49 |
|
|
int nbins = 60;
|
50 |
buchmann |
1.17 |
float xmin=15., xmax = 315.;
|
51 |
|
|
TH1F *mllsigEE = allsamples.Draw("mllsigEE","mll",nbins,xmin,xmax,"m_{ee} [GeV]", "events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==0"),data,PlottingSetup::luminosity);
|
52 |
|
|
TH1F *mllsigMM = allsamples.Draw("mllsigMM","mll",nbins,xmin,xmax,"m_{#mu#mu} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==1"),data,PlottingSetup::luminosity);
|
53 |
|
|
TH1F *mllscon = allsamples.Draw("mllscon","mll",nbins,xmin,xmax,"m_{ll} [GeV]", "events",TCut(cutOSSF&&MetBaseCut&&nJetsControl),data,PlottingSetup::luminosity);
|
54 |
fronga |
1.7 |
TH1F *mllOsig = allsamples.Draw("mllOsig", "mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsSignal),data,PlottingSetup::luminosity);
|
55 |
|
|
TH1F *mllOscon = allsamples.Draw("mllOscon","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsControl),data,PlottingSetup::luminosity);
|
56 |
|
|
|
57 |
fronga |
1.8 |
TH1F* mllsig = (TH1F*)mllsigEE->Clone("mllsig");
|
58 |
|
|
mllsig->Add(mllsigMM);
|
59 |
|
|
mllsig->GetXaxis()->SetTitle("m_{ll} [GeV]");
|
60 |
|
|
|
61 |
|
|
THStack *mcMllsig, *mcMllsigEE,*mcMllsigMM,*mcMllscon,*mcMllsconEE,*mcMllsconMM, *mcMllOsig, *mcMllOscon;
|
62 |
fronga |
1.7 |
if ( doMC ) {
|
63 |
|
|
name += "_mc";
|
64 |
fronga |
1.8 |
mcMllsig = new THStack(allsamples.DrawStack("mcMllsig","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
65 |
|
|
mcMllsigEE = new THStack(allsamples.DrawStack("mcMllsigEE","mll",nbins,xmin,xmax,"m_{ee} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==0"),mc,PlottingSetup::luminosity));
|
66 |
|
|
mcMllsigMM = new THStack(allsamples.DrawStack("mcMllsigMM","mll",nbins,xmin,xmax,"m_{#mu#mu} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsSignal&&"id1==1"),mc,PlottingSetup::luminosity));
|
67 |
|
|
mcMllscon = new THStack(allsamples.DrawStack("mcMllscon","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSSF&&MetBaseCut&&nJetsControl),mc,PlottingSetup::luminosity));
|
68 |
|
|
mcMllOsig = new THStack(allsamples.DrawStack("mcMllOsig","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsSignal),mc,PlottingSetup::luminosity));
|
69 |
fronga |
1.7 |
mcMllOscon= new THStack(allsamples.DrawStack("mcMllOscon","mll",nbins,xmin,xmax,"m_{ll} [GeV]","events",TCut(cutOSOF&&MetBaseCut&&nJetsControl),mc,PlottingSetup::luminosity));
|
70 |
fronga |
1.8 |
|
71 |
fronga |
1.7 |
}
|
72 |
fronga |
1.8 |
|
73 |
buchmann |
1.1 |
mllOsig->SetLineColor(kRed);
|
74 |
|
|
mllOscon->SetLineColor(kRed);
|
75 |
|
|
|
76 |
fronga |
1.7 |
TH1F *zlineshape = allsamples.Draw("zlineshape","mll",nbins,xmin,xmax,"m_{ll} (GeV)","events",cutOSSF&&TCut("pfJetGoodNum40==1")&&cut,data,PlottingSetup::luminosity);
|
77 |
buchmann |
1.13 |
TH1F *zlineshapeControl = (TH1F*)zlineshape->Clone("zlineshapeControl");
|
78 |
buchmann |
1.17 |
TH1F *zlineshapeFINE = allsamples.Draw("zlineshapeFINE","mll",50*nbins,xmin,xmax,"m_{ll} (GeV)","events",cutOSSF&&TCut("pfJetGoodNum40==1")&&cut,data,PlottingSetup::luminosity);
|
79 |
|
|
|
80 |
buchmann |
1.18 |
float scalefactor = Get_Met_Z_Prediction(nJetsSignal,cutat, data, false) / (zlineshapeFINE->Integral(zlineshapeFINE->FindBin(91.1-20),zlineshapeFINE->FindBin(91.1+20)));
|
81 |
|
|
float scalefactor_Control = Get_Met_Z_Prediction(nJetsControl,cutat, data, false) / (zlineshapeFINE->Integral(zlineshapeFINE->FindBin(91.1-20),zlineshapeFINE->FindBin(91.1+20)));
|
82 |
buchmann |
1.17 |
delete zlineshapeFINE;
|
83 |
buchmann |
1.6 |
|
84 |
buchmann |
1.3 |
zlineshape->Scale(scalefactor);
|
85 |
|
|
zlineshape->SetLineColor(kBlue);
|
86 |
|
|
zlineshape->SetLineStyle(2);
|
87 |
|
|
|
88 |
buchmann |
1.13 |
zlineshapeControl->Scale(scalefactor_Control);
|
89 |
|
|
zlineshapeControl->SetLineColor(kBlue);
|
90 |
|
|
zlineshapeControl->SetLineStyle(2);
|
91 |
|
|
|
92 |
buchmann |
1.3 |
TH1F *subtracted = (TH1F*)mllsig->Clone("subtracted");
|
93 |
buchmann |
1.13 |
TH1F *subtractedControl = (TH1F*)mllscon->Clone("subtractedControl");
|
94 |
buchmann |
1.3 |
TH1F *baseline = (TH1F*)mllOsig->Clone("baseline");
|
95 |
buchmann |
1.13 |
TH1F *baselineControl = (TH1F*)mllOscon->Clone("baselineControl");
|
96 |
buchmann |
1.3 |
for(int i=1;i<=subtracted->GetNbinsX();i++) {
|
97 |
|
|
subtracted->SetBinContent(i,mllsig->GetBinContent(i)-mllOsig->GetBinContent(i));
|
98 |
buchmann |
1.13 |
subtractedControl->SetBinContent(i,mllscon->GetBinContent(i)-mllOscon->GetBinContent(i));
|
99 |
buchmann |
1.3 |
baseline->SetBinContent(i,0);
|
100 |
buchmann |
1.13 |
baselineControl->SetBinContent(i,0);
|
101 |
buchmann |
1.3 |
}
|
102 |
|
|
|
103 |
|
|
TH1F *prediction = (TH1F*)mllOsig->Clone("prediction");
|
104 |
|
|
prediction->Add(zlineshape);
|
105 |
|
|
prediction->SetLineColor(TColor::GetColor("#CF35CA"));
|
106 |
fronga |
1.7 |
|
107 |
|
|
TH1F *control_prediction = (TH1F*)mllOscon->Clone("control_prediction");
|
108 |
|
|
control_prediction->SetLineColor(TColor::GetColor("#CF35CA"));
|
109 |
|
|
|
110 |
|
|
// FIX Y RANGE TO EASE COMPARISON
|
111 |
fronga |
1.19 |
mllsig->SetMaximum(80);
|
112 |
|
|
mllsigEE->SetMaximum(80);
|
113 |
|
|
mllsigMM->SetMaximum(80);
|
114 |
|
|
mllOsig->SetMaximum(80);
|
115 |
|
|
mllOscon->SetMaximum(40);
|
116 |
|
|
subtracted->SetMaximum(35);
|
117 |
|
|
subtracted->SetMinimum(-25);
|
118 |
|
|
subtractedControl->SetMaximum(25);
|
119 |
|
|
subtractedControl->SetMinimum(-15);
|
120 |
fronga |
1.7 |
|
121 |
buchmann |
1.3 |
|
122 |
fronga |
1.7 |
// 1.- Signal region comparison
|
123 |
fronga |
1.14 |
TBox *srbox = new TBox(xmin,0,70,mllsig->GetMaximum());
|
124 |
buchmann |
1.1 |
srbox->SetFillStyle(0);
|
125 |
|
|
srbox->SetLineColor(TColor::GetColor("#298A08"));
|
126 |
|
|
srbox->SetLineWidth(3);
|
127 |
fronga |
1.10 |
|
128 |
buchmann |
1.2 |
stringstream MetHeader;
|
129 |
fronga |
1.19 |
MetHeader << "N_{j}#geq" << snjets.str() << ", MET>" << cutat << " GeV";
|
130 |
|
|
stringstream MetHeaderCon;
|
131 |
|
|
MetHeaderCon << "N_{j}<" << snjets.str() << ", " << cutat << "<MET<" << cutConHigh << " GeV";
|
132 |
fronga |
1.10 |
stringstream saveasSig;
|
133 |
|
|
saveasSig << "MetPlots/mll_sig" << cutat << "__" << name;
|
134 |
|
|
|
135 |
|
|
TLegend* leg;
|
136 |
|
|
if ( !doMC ) {
|
137 |
|
|
tcan->cd();
|
138 |
|
|
//mllsig->GetYaxis()->SetRangeUser(0,mllsig->GetMaximum()*1.2);
|
139 |
|
|
mllsig->Draw();
|
140 |
|
|
TGraphErrors *stat3j = MakeErrorGraph(prediction);
|
141 |
|
|
stat3j->Draw("2,same");
|
142 |
|
|
mllOsig->Draw("histo,same");
|
143 |
|
|
zlineshape->Draw("histo,same");
|
144 |
|
|
prediction->Draw("histo,same");
|
145 |
|
|
mllsig->Draw("same");
|
146 |
|
|
DrawPrelim();
|
147 |
|
|
leg = make_legend();
|
148 |
fronga |
1.19 |
leg->SetX1(0.52);
|
149 |
|
|
leg->SetHeader(MetHeader.str().c_str());
|
150 |
fronga |
1.10 |
leg->AddEntry(mllsig,"Data","PL");
|
151 |
|
|
leg->AddEntry(prediction,"All bg prediction","L");
|
152 |
fronga |
1.7 |
leg->AddEntry(mllOsig,"bg without Z","L");
|
153 |
|
|
leg->AddEntry(zlineshape,"Z lineshape","L");
|
154 |
|
|
leg->AddEntry(stat3j,"stat. uncert.","F");
|
155 |
fronga |
1.10 |
leg->AddEntry(srbox,"SR","F");
|
156 |
|
|
leg->Draw();
|
157 |
|
|
srbox->Draw();
|
158 |
|
|
CompleteSave(tcan,saveasSig.str());
|
159 |
|
|
} else {
|
160 |
fronga |
1.19 |
|
161 |
fronga |
1.10 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
162 |
|
|
rcan->cd();
|
163 |
|
|
mllsig->Draw();
|
164 |
|
|
mcMllsig->Draw("same");
|
165 |
|
|
prediction->Draw("histo,same");
|
166 |
|
|
mllsig->Draw("same");
|
167 |
|
|
DrawPrelim();
|
168 |
|
|
leg = allsamples.allbglegend();
|
169 |
fronga |
1.19 |
leg->SetHeader(MetHeader.str().c_str());
|
170 |
|
|
leg->SetX1(0.52);
|
171 |
fronga |
1.10 |
leg->AddEntry(prediction,"All bg prediction","L");
|
172 |
|
|
leg->AddEntry(srbox,"SR","F");
|
173 |
|
|
leg->Draw();
|
174 |
|
|
srbox->Draw();
|
175 |
|
|
save_with_ratio( mllsig, *mcMllsig, rcan, saveasSig.str() );
|
176 |
fronga |
1.7 |
}
|
177 |
buchmann |
1.1 |
|
178 |
|
|
|
179 |
fronga |
1.8 |
// 1b. MC: split ee and mumu
|
180 |
|
|
if ( doMC ) {
|
181 |
fronga |
1.10 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
182 |
|
|
rcan->cd();
|
183 |
fronga |
1.8 |
mllsigEE->Draw();
|
184 |
|
|
mcMllsigEE->Draw("same");
|
185 |
|
|
mllsigEE->Draw("same");
|
186 |
|
|
DrawPrelim();
|
187 |
|
|
leg->Draw();
|
188 |
|
|
srbox->Draw();
|
189 |
fronga |
1.10 |
save_with_ratio( mllsigEE, *mcMllsigEE,rcan->cd(),saveasSig.str()+"_ee" );
|
190 |
fronga |
1.8 |
|
191 |
fronga |
1.10 |
rcan = new TPad("rcan","rcan",0,0,1,1);
|
192 |
|
|
rcan->cd();
|
193 |
fronga |
1.8 |
mllsigMM->Draw();
|
194 |
|
|
mcMllsigMM->Draw("same");
|
195 |
|
|
mllsigMM->Draw("same");
|
196 |
|
|
DrawPrelim();
|
197 |
|
|
leg->Draw();
|
198 |
|
|
srbox->Draw();
|
199 |
fronga |
1.10 |
save_with_ratio( mllsigMM, *mcMllsigMM,rcan,saveasSig.str()+"_mm" );
|
200 |
fronga |
1.8 |
}
|
201 |
fronga |
1.14 |
|
202 |
|
|
// 1c. MC: compare of and sf
|
203 |
|
|
if ( doMC ) {
|
204 |
|
|
TH1F* hMcMllsig = CollapseStack( *mcMllsig);
|
205 |
fronga |
1.15 |
leg = allsamples.allbglegend("");
|
206 |
fronga |
1.19 |
leg->SetHeader(MetHeader.str().c_str());
|
207 |
fronga |
1.15 |
// Change "Data" label by hand
|
208 |
|
|
((TLegendEntry*)leg->GetListOfPrimitives()->At(0))->SetLabel("Same-flavor (MC)");
|
209 |
fronga |
1.14 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
210 |
|
|
rcan->cd();
|
211 |
fronga |
1.19 |
hMcMllsig->SetMaximum(80);
|
212 |
fronga |
1.14 |
hMcMllsig->Draw("E");
|
213 |
|
|
mcMllOsig->Draw("same,hist");
|
214 |
|
|
hMcMllsig->Draw("same,E");
|
215 |
|
|
DrawMCPrelim();
|
216 |
fronga |
1.19 |
leg->SetX1(0.52);
|
217 |
fronga |
1.14 |
leg->AddEntry(srbox,"SR","F");
|
218 |
|
|
leg->Draw();
|
219 |
|
|
srbox->Draw();
|
220 |
|
|
save_with_ratio( hMcMllsig, *mcMllOsig, rcan, saveasSig.str()+"_mconly");
|
221 |
|
|
|
222 |
|
|
}
|
223 |
buchmann |
1.1 |
|
224 |
fronga |
1.7 |
// 2.- Signal region comparison - LOG scale
|
225 |
fronga |
1.10 |
if ( !doMC ) {
|
226 |
|
|
tcan->cd();
|
227 |
|
|
mllsig->SetMinimum(0.2); // FIX Y RANGE TO EASE COMPARISON
|
228 |
|
|
//mllsig->SetMaximum(mllsig->GetMaximum()*4.0);
|
229 |
|
|
srbox->SetY2(mllsig->GetMaximum());
|
230 |
|
|
|
231 |
|
|
tcan->SetLogy(1);
|
232 |
|
|
stringstream saveasSig2;
|
233 |
|
|
saveasSig2 << "MetPlots/mll_sig_ZLINESHAPE_" << cutat << "__" << name;
|
234 |
|
|
|
235 |
|
|
CompleteSave(tcan,saveasSig2.str());
|
236 |
|
|
tcan->SetLogy(0);
|
237 |
|
|
}
|
238 |
buchmann |
1.1 |
|
239 |
fronga |
1.7 |
|
240 |
|
|
// 3.- Signal region, background subtracted
|
241 |
fronga |
1.8 |
if ( !doMC ) {
|
242 |
fronga |
1.10 |
tcan->cd();
|
243 |
buchmann |
1.13 |
for(int i=1;i<=subtracted->GetNbinsX();i++) {
|
244 |
fronga |
1.8 |
subtracted->SetBinContent(i,subtracted->GetBinContent(i)-zlineshape->GetBinContent(i));
|
245 |
buchmann |
1.13 |
subtractedControl->SetBinContent(i,subtractedControl->GetBinContent(i)-zlineshapeControl->GetBinContent(i));
|
246 |
fronga |
1.8 |
}
|
247 |
buchmann |
1.3 |
|
248 |
fronga |
1.8 |
TGraphErrors *subtrerr = MakeErrorGraph(baseline);
|
249 |
|
|
subtracted->Draw();
|
250 |
|
|
subtrerr->Draw("2,same");
|
251 |
|
|
subtracted->Draw("same");
|
252 |
|
|
DrawPrelim();
|
253 |
|
|
TLegend *DiffLeg = make_legend();
|
254 |
|
|
DiffLeg->SetX1(0.3);
|
255 |
|
|
DiffLeg->SetFillStyle(0);
|
256 |
fronga |
1.19 |
DiffLeg->SetHeader(MetHeader.str().c_str());
|
257 |
fronga |
1.8 |
DiffLeg->AddEntry(subtracted,"observed - predicted","PL");
|
258 |
fronga |
1.19 |
DiffLeg->AddEntry(subtrerr,"stat. uncert","F");
|
259 |
fronga |
1.8 |
DiffLeg->AddEntry((TObject*)0,"","");
|
260 |
|
|
DiffLeg->AddEntry((TObject*)0,"","");
|
261 |
|
|
DiffLeg->Draw();
|
262 |
|
|
|
263 |
|
|
stringstream saveasSigSub;
|
264 |
|
|
saveasSigSub << "MetPlots/mll_sig_SUBTRACTED_" << cutat << "__" << name;
|
265 |
|
|
|
266 |
|
|
CompleteSave(tcan,saveasSigSub.str());
|
267 |
buchmann |
1.13 |
|
268 |
|
|
// 3a.- Control region, background subtracted
|
269 |
|
|
TGraphErrors *subtrerrControl = MakeErrorGraph(baselineControl);
|
270 |
|
|
subtractedControl->Draw();
|
271 |
|
|
subtrerrControl->Draw("2,same");
|
272 |
|
|
subtractedControl->Draw("same");
|
273 |
|
|
DrawPrelim();
|
274 |
fronga |
1.19 |
DiffLeg->SetHeader(MetHeaderCon.str().c_str());
|
275 |
buchmann |
1.13 |
DiffLeg->Draw();
|
276 |
|
|
saveasSigSub.str("");
|
277 |
fronga |
1.16 |
saveasSigSub << "MetPlots/mll_con_SUBTRACTED_" << cutat << "__" << name;
|
278 |
buchmann |
1.13 |
CompleteSave(tcan,saveasSigSub.str());
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
fronga |
1.8 |
// 4.- Signal region, background subtracted, errors added in quadrature
|
283 |
|
|
TGraphErrors *subtrerr2 = (TGraphErrors*)subtrerr->Clone("subtrerr2");
|
284 |
buchmann |
1.13 |
for(int i=1;i<=subtrerr2->GetN();i++) {
|
285 |
|
|
subtrerr2->SetPoint(i-1,subtracted->GetBinCenter(i),subtracted->GetBinContent(i));
|
286 |
|
|
subtrerr2->SetPointError(i-1,subtrerr2->GetErrorX(i),TMath::Sqrt(subtrerr2->GetErrorY(i)*subtrerr2->GetErrorY(i)+subtracted->GetBinError(i)*subtracted->GetBinError(i)));
|
287 |
fronga |
1.8 |
}
|
288 |
|
|
TLine* l = new TLine(subtracted->GetBinLowEdge(1),0.,subtracted->GetBinLowEdge(subtracted->GetNbinsX()-1)+subtracted->GetBinWidth(1),0.);
|
289 |
|
|
l->SetLineWidth(subtracted->GetLineWidth());
|
290 |
|
|
subtracted->Draw();
|
291 |
|
|
subtrerr2->Draw("2,same");
|
292 |
|
|
l->Draw("same");
|
293 |
|
|
subtracted->Draw("same");
|
294 |
|
|
DrawPrelim();
|
295 |
|
|
TLegend *DiffLeg2 = make_legend();
|
296 |
|
|
DiffLeg2->SetX1(0.3);
|
297 |
fronga |
1.19 |
DiffLeg2->SetHeader(MetHeader.str().c_str());
|
298 |
fronga |
1.8 |
DiffLeg2->SetFillStyle(0);
|
299 |
|
|
DiffLeg2->AddEntry(subtracted,"observed - predicted","PL");
|
300 |
fronga |
1.19 |
DiffLeg2->AddEntry(subtrerr2,"stat. uncert","F");
|
301 |
fronga |
1.8 |
DiffLeg2->AddEntry((TObject*)0,"","");
|
302 |
|
|
DiffLeg2->AddEntry((TObject*)0,"","");
|
303 |
|
|
DiffLeg2->Draw();
|
304 |
|
|
|
305 |
|
|
stringstream saveasSigSub2;
|
306 |
|
|
saveasSigSub2 << "MetPlots/mll_sig_SUBTRACTED_quadr_" << cutat << "__" << name;
|
307 |
fronga |
1.5 |
|
308 |
fronga |
1.8 |
CompleteSave(tcan,saveasSigSub2.str());
|
309 |
fronga |
1.5 |
|
310 |
buchmann |
1.13 |
|
311 |
|
|
|
312 |
|
|
//4a.- Control region, background subtracted, errors added in quadrature
|
313 |
|
|
TGraphErrors *subtrerr2Control = (TGraphErrors*)subtrerrControl->Clone("subtrerr2Control");
|
314 |
|
|
for(int i=1;i<=subtrerr2Control->GetN();i++) {
|
315 |
|
|
subtrerr2Control->SetPoint(i-1,subtractedControl->GetBinCenter(i),subtractedControl->GetBinContent(i));
|
316 |
|
|
float width=subtrerr2Control->GetErrorX(i);
|
317 |
|
|
if(i==subtrerr2Control->GetN()) width=subtrerr2Control->GetErrorX(i-1);
|
318 |
|
|
subtrerr2Control->SetPointError(i-1,width,TMath::Sqrt(subtrerr2Control->GetErrorY(i)*subtrerr2Control->GetErrorY(i)+subtractedControl->GetBinError(i)*subtractedControl->GetBinError(i)));
|
319 |
|
|
}
|
320 |
|
|
TLine* lControl = new TLine(subtractedControl->GetBinLowEdge(1),0.,subtractedControl->GetBinLowEdge(subtractedControl->GetNbinsX()-1)+subtractedControl->GetBinWidth(1),0.);
|
321 |
|
|
lControl->SetLineWidth(subtractedControl->GetLineWidth());
|
322 |
|
|
subtractedControl->Draw();
|
323 |
|
|
subtrerr2Control->Draw("2,same");
|
324 |
|
|
lControl->Draw("same");
|
325 |
|
|
subtractedControl->Draw("same");
|
326 |
|
|
DrawPrelim();
|
327 |
|
|
DiffLeg2->Draw();
|
328 |
|
|
|
329 |
|
|
saveasSigSub2.str("");
|
330 |
fronga |
1.16 |
saveasSigSub2 << "MetPlots/mll_con_SUBTRACTED_quadr_" << cutat << "__" << name;
|
331 |
buchmann |
1.13 |
|
332 |
|
|
CompleteSave(tcan,saveasSigSub2.str());
|
333 |
|
|
|
334 |
fronga |
1.8 |
delete DiffLeg;
|
335 |
|
|
delete DiffLeg2;
|
336 |
buchmann |
1.13 |
|
337 |
fronga |
1.8 |
} // !doMC
|
338 |
buchmann |
1.3 |
|
339 |
|
|
|
340 |
fronga |
1.7 |
// 5.- Control region comparison
|
341 |
fronga |
1.16 |
// scalefactor = (mllscon->Integral(scaleBinLow,scaleBinHigh)-mllOscon->Integral(scaleBinLow,scaleBinHigh));
|
342 |
|
|
// scalefactor /= zlineshape->Integral(scaleBinLow,scaleBinHigh);
|
343 |
|
|
// zlineshape->Scale(scalefactor);
|
344 |
|
|
control_prediction->Add(zlineshapeControl);
|
345 |
|
|
|
346 |
fronga |
1.19 |
control_prediction->SetMaximum(40); // FIX MAXIMUM TO EASE COMPARISON
|
347 |
fronga |
1.7 |
|
348 |
fronga |
1.14 |
TBox *cr1box = new TBox(xmin,0,70,control_prediction->GetMaximum());
|
349 |
buchmann |
1.1 |
cr1box->SetFillStyle(0);
|
350 |
|
|
cr1box->SetLineColor(TColor::GetColor("#0404B4"));
|
351 |
|
|
cr1box->SetLineWidth(3);
|
352 |
|
|
|
353 |
fronga |
1.14 |
TBox *cr2box = new TBox(120,0,xmax,control_prediction->GetMaximum());
|
354 |
buchmann |
1.1 |
cr2box->SetFillStyle(0);
|
355 |
|
|
cr2box->SetLineColor(TColor::GetColor("#0404B4"));
|
356 |
|
|
cr2box->SetLineWidth(3);
|
357 |
|
|
cr2box->SetLineStyle(2);
|
358 |
|
|
|
359 |
fronga |
1.10 |
stringstream saveasCon;
|
360 |
|
|
saveasCon << "MetPlots/mll_con" << cutat << "__" << name;
|
361 |
|
|
|
362 |
fronga |
1.7 |
TLegend *legc;
|
363 |
fronga |
1.10 |
//control_prediction->GetYaxis()->SetRangeUser(0,control_prediction->GetMaximum()*1.3);
|
364 |
|
|
if ( !doMC ) {
|
365 |
|
|
tcan->cd();
|
366 |
|
|
control_prediction->Draw("hist");
|
367 |
|
|
TGraphErrors *stat2j = MakeErrorGraph(control_prediction);
|
368 |
|
|
stat2j->Draw("2,same");
|
369 |
|
|
mllOscon->Draw("same,hist");
|
370 |
fronga |
1.16 |
zlineshapeControl->Draw("histo,same");
|
371 |
fronga |
1.10 |
control_prediction->Draw("histo,same");
|
372 |
|
|
mllscon->Draw("same");
|
373 |
|
|
DrawPrelim();
|
374 |
fronga |
1.7 |
legc = make_legend();
|
375 |
fronga |
1.19 |
legc->SetX1(0.52);
|
376 |
|
|
legc->SetHeader(MetHeaderCon.str().c_str());
|
377 |
fronga |
1.10 |
legc->AddEntry(mllscon,"Data","PL");
|
378 |
|
|
legc->AddEntry(control_prediction,"All bg","L");
|
379 |
fronga |
1.16 |
legc->AddEntry(zlineshapeControl,"Z lineshape","L");
|
380 |
fronga |
1.7 |
legc->AddEntry(mllOscon,"bg without Z","L");
|
381 |
|
|
legc->AddEntry(stat2j,"stat. uncert.","F");
|
382 |
fronga |
1.10 |
legc->AddEntry(cr1box,"CR1","F");
|
383 |
|
|
legc->AddEntry(cr2box,"CR2","F");
|
384 |
|
|
legc->Draw();
|
385 |
|
|
cr1box->Draw();
|
386 |
|
|
cr2box->Draw();
|
387 |
|
|
CompleteSave(tcan,saveasCon.str());
|
388 |
|
|
} else {
|
389 |
|
|
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
390 |
|
|
rcan->cd();
|
391 |
|
|
control_prediction->Draw("hist");
|
392 |
|
|
mcMllscon->Draw("same");
|
393 |
|
|
control_prediction->Draw("histo,same");
|
394 |
|
|
mllscon->Draw("same");
|
395 |
|
|
DrawPrelim();
|
396 |
|
|
legc = allsamples.allbglegend();
|
397 |
fronga |
1.19 |
legc->SetX1(0.52);
|
398 |
|
|
legc->SetHeader(MetHeaderCon.str().c_str());
|
399 |
fronga |
1.10 |
legc->AddEntry(control_prediction,"All bg","L");
|
400 |
|
|
legc->AddEntry(cr1box,"CR1","F");
|
401 |
|
|
legc->AddEntry(cr2box,"CR2","F");
|
402 |
|
|
legc->Draw();
|
403 |
|
|
cr1box->Draw();
|
404 |
|
|
cr2box->Draw();
|
405 |
|
|
save_with_ratio( mllscon, *mcMllscon, rcan, saveasCon.str());
|
406 |
|
|
}
|
407 |
buchmann |
1.1 |
|
408 |
fronga |
1.7 |
// 6. - Opposite-flavour data/MC comparison
|
409 |
|
|
if ( doMC ) {
|
410 |
fronga |
1.10 |
TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
|
411 |
|
|
rcan->cd();
|
412 |
fronga |
1.7 |
mllOsig->SetLineColor(kBlack);
|
413 |
|
|
mllOsig->Draw();
|
414 |
|
|
mcMllOsig->Draw("same");
|
415 |
|
|
mllOsig->Draw("same");
|
416 |
|
|
TLegend *legsdm = allsamples.allbglegend();
|
417 |
fronga |
1.19 |
legsdm->SetHeader((MetHeader.str()+", OF").c_str());
|
418 |
|
|
legsdm->SetX1(0.52);
|
419 |
fronga |
1.7 |
legsdm->Draw();
|
420 |
|
|
stringstream saveasSigOF;
|
421 |
|
|
saveasSigOF << "MetPlots/mll_sig_of_" << cutat << "__" << name;
|
422 |
fronga |
1.10 |
save_with_ratio( mllOsig, *mcMllOsig, rcan, saveasSigOF.str());
|
423 |
fronga |
1.7 |
|
424 |
fronga |
1.10 |
rcan = new TPad("rcan","rcan",0,0,1,1);
|
425 |
|
|
rcan->cd();
|
426 |
fronga |
1.7 |
mllOscon->SetLineColor(kBlack);
|
427 |
|
|
mllOscon->Draw();
|
428 |
|
|
mcMllOscon->Draw("same");
|
429 |
|
|
mllOscon->Draw("same");
|
430 |
|
|
TLegend *legcdm = allsamples.allbglegend();
|
431 |
fronga |
1.19 |
legcdm->SetHeader((MetHeaderCon.str()+", OF").c_str());
|
432 |
|
|
legcdm->SetX1(0.52);
|
433 |
fronga |
1.7 |
legcdm->Draw();
|
434 |
|
|
stringstream saveasConOF;
|
435 |
|
|
saveasConOF << "MetPlots/mll_con_of_" << cutat << "__" << name;
|
436 |
fronga |
1.10 |
save_with_ratio( mllOscon, *mcMllOscon, rcan, saveasConOF.str());
|
437 |
|
|
|
438 |
fronga |
1.7 |
delete legsdm;
|
439 |
|
|
delete legcdm;
|
440 |
fronga |
1.10 |
}
|
441 |
fronga |
1.7 |
|
442 |
fronga |
1.10 |
// Memory clean-up
|
443 |
|
|
if (doMC) {
|
444 |
fronga |
1.7 |
delete mcMllscon;
|
445 |
|
|
delete mcMllOscon;
|
446 |
|
|
delete mcMllsig;
|
447 |
fronga |
1.8 |
delete mcMllsigEE;
|
448 |
|
|
delete mcMllsigMM;
|
449 |
fronga |
1.7 |
delete mcMllOsig;
|
450 |
|
|
}
|
451 |
buchmann |
1.1 |
|
452 |
|
|
delete cr1box;
|
453 |
|
|
delete cr2box;
|
454 |
|
|
delete srbox;
|
455 |
|
|
delete legc;
|
456 |
|
|
delete leg;
|
457 |
fronga |
1.7 |
|
458 |
buchmann |
1.1 |
delete mllscon;
|
459 |
|
|
delete mllOscon;
|
460 |
|
|
delete mllsig;
|
461 |
fronga |
1.8 |
delete mllsigEE;
|
462 |
|
|
delete mllsigMM;
|
463 |
buchmann |
1.1 |
delete mllOsig;
|
464 |
fronga |
1.7 |
delete zlineshape;
|
465 |
fronga |
1.16 |
delete zlineshapeControl;
|
466 |
buchmann |
1.6 |
delete tcan;
|
467 |
buchmann |
1.1 |
}
|
468 |
|
|
|
469 |
fronga |
1.14 |
void DoMetPlots(string datajzb, string mcjzb) {
|
470 |
fronga |
1.7 |
float metCuts[] = { 100., 150. };
|
471 |
fronga |
1.19 |
float metConCuts[] = { 150., 1e6 };
|
472 |
fronga |
1.7 |
int jetCuts[] = { 3, 2 };
|
473 |
fronga |
1.11 |
//int jetCuts[] = { 3, 3 };
|
474 |
fronga |
1.19 |
string leptCuts[] = { leptoncut.GetTitle(),
|
475 |
fronga |
1.7 |
"pt1>20&&pt2>10"
|
476 |
|
|
};
|
477 |
|
|
bool nomc(0),domc(1);
|
478 |
|
|
for ( int i=0; i<2; ++i ) {
|
479 |
fronga |
1.19 |
ProduceMetPlotsWithCut(TCut(("mll>20&&"+leptCuts[i]).c_str()),"",metCuts[i], metConCuts[i], jetCuts[i],nomc);
|
480 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&"+leptCuts[i]).c_str()),"",metCuts[i], metConCuts[i], jetCuts[i],domc);
|
481 |
fronga |
1.15 |
//continue;
|
482 |
fronga |
1.19 |
// stringstream jzbcut;
|
483 |
|
|
// jzbcut << "((is_data&&("<<datajzb<<")>0)||(!is_data&&("<<mcjzb<<")>0))";
|
484 |
|
|
// ProduceMetPlotsWithCut(TCut((jzbcut.str()+"&&mll>20&&"+leptCuts[i]).c_str()),"JZBpos",metCuts[i], jetCuts[i],domc);
|
485 |
fronga |
1.11 |
//continue;
|
486 |
fronga |
1.7 |
if (!PlottingSetup::is53reco) { // Old 5_2
|
487 |
fronga |
1.19 |
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag==0&&"+leptCuts[i]).c_str()),"bTagVeto30",metCuts[i], metConCuts[i], jetCuts[i], nomc);
|
488 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag>0&&"+leptCuts[i]).c_str()),"AtLeastOneBJet30",metCuts[i], metConCuts[i], jetCuts[i], nomc);
|
489 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag==0&&"+leptCuts[i]).c_str()),"bTagVeto30",metCuts[i], metConCuts[i], jetCuts[i], domc);
|
490 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag>0&&"+leptCuts[i]).c_str()),"AtLeastOneBJet30",metCuts[i], metConCuts[i], jetCuts[i], domc);
|
491 |
fronga |
1.7 |
} else {
|
492 |
fronga |
1.19 |
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag30==0&&"+leptCuts[i]).c_str()),"bTagVeto30",metCuts[i], metConCuts[i], jetCuts[i],nomc);
|
493 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag30>0&&"+leptCuts[i]).c_str()),"AtLeastOneBJet30",metCuts[i], metConCuts[i], jetCuts[i],nomc);
|
494 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag30==0&&"+leptCuts[i]).c_str()),"bTagVeto30",metCuts[i], metConCuts[i], jetCuts[i],domc);
|
495 |
|
|
ProduceMetPlotsWithCut(TCut(("mll>20&&pfJetGoodNumBtag30>0&&"+leptCuts[i]).c_str()),"AtLeastOneBJet30",metCuts[i], metConCuts[i], jetCuts[i],domc);
|
496 |
fronga |
1.7 |
}
|
497 |
|
|
}
|
498 |
buchmann |
1.1 |
}
|
499 |
buchmann |
1.12 |
|
500 |
buchmann |
1.13 |
void compute_r_in_out() {
|
501 |
|
|
int nbins=10;
|
502 |
|
|
float xmin=10;
|
503 |
|
|
float xmax=10;
|
504 |
|
|
TCut InCut("mll>71&&mll<111&&pfJetGoodNum40>0");
|
505 |
|
|
TCut OutCut("mll>20&&mll<70&&pfJetGoodNum40>0");
|
506 |
|
|
|
507 |
|
|
TH1F *mllIN =allsamples.Draw("mllIN", "mll",nbins,xmin,xmax,"m_{ee} [GeV]", "events",TCut(cutOSSF&&InCut),mc,PlottingSetup::luminosity,allsamples.FindSample("DYJetsToLLNoTau"));
|
508 |
|
|
TH1F *mllOUT =allsamples.Draw("mllOUT","mll",nbins,xmin,xmax,"m_{ee} [GeV]", "events",TCut(cutOSSF&&OutCut),mc,PlottingSetup::luminosity,allsamples.FindSample("DYJetsToLLNoTau"));
|
509 |
|
|
|
510 |
|
|
cout << "IN: " << mllIN->Integral() << endl;
|
511 |
|
|
cout << "OUT: " << mllOUT->Integral() << endl;
|
512 |
|
|
cout << "r_oi: " <<((float) mllOUT->Integral()) / mllIN->Integral()<< endl;
|
513 |
|
|
|
514 |
|
|
delete mllIN;
|
515 |
|
|
delete mllOUT;
|
516 |
|
|
|
517 |
|
|
}
|
518 |
|
|
|
519 |
buchmann |
1.17 |
|
520 |
|
|
|
521 |
|
|
void LabelHisto(TH1 *MET_ratio,string titlex, string titley) {
|
522 |
|
|
MET_ratio->GetXaxis()->SetTitle(titlex.c_str());
|
523 |
|
|
MET_ratio->GetXaxis()->CenterTitle();
|
524 |
|
|
MET_ratio->GetYaxis()->SetTitle(titley.c_str());
|
525 |
|
|
MET_ratio->GetYaxis()->CenterTitle();
|
526 |
|
|
}
|
527 |
|
|
|
528 |
|
|
TH1F* GetPredictedAndObservedMetShapes(TCut JetCut, string sPositiveCut,string sNegativeCut,string CorrectedMet,string ObservedMet, string JZBPosvar, string JZBNegvar, float MetCut, int is_data, bool isDYonly) {
|
529 |
|
|
|
530 |
|
|
//Steps:
|
531 |
|
|
// 1) Prepare samples and histo definition (with "optimal" binning for MET cut)
|
532 |
|
|
// 2) Fill MET histograms
|
533 |
|
|
// 3) Fill JZB histograms
|
534 |
|
|
// 4) Draw them and store them
|
535 |
|
|
// 5) return predicted MET distribution as is (i.e. not scaled by factor of 2!)
|
536 |
|
|
|
537 |
|
|
cout << "** SUMMARY BEFORE STARTING DRAWING **" << endl;
|
538 |
|
|
cout << "MET variable: " << ObservedMet << endl;
|
539 |
|
|
cout << "Corr. MET var:" << CorrectedMet << endl;
|
540 |
|
|
cout << "JZB pos. var: " << JZBPosvar << endl;
|
541 |
|
|
cout << "JZB neg. var: " << JZBNegvar << endl;
|
542 |
|
|
//Step 1: Prepare samples and histo definition
|
543 |
|
|
vector<int> SelectedSamples;
|
544 |
|
|
if(is_data==mc&&isDYonly) {
|
545 |
|
|
SelectedSamples=allsamples.FindSample("Z_em_DYJetsToL");
|
546 |
|
|
if(SelectedSamples.size()==0) {
|
547 |
|
|
write_error(__FUNCTION__,"Cannot continue, there seems to be no DY sample without Taus - goodbye!");
|
548 |
|
|
assert(SelectedSamples.size()>0);
|
549 |
|
|
}
|
550 |
|
|
}
|
551 |
|
|
|
552 |
|
|
float DisplayedBinSize=10.0; // this is the bin size that we use for plotting
|
553 |
|
|
float JZB_Met_systematic=0.25; // systematic uncertainty (e.g. 0.25 for 25%)
|
554 |
|
|
|
555 |
|
|
float BinWidth=(MetCut)/20; // we want 20 bins up to the MET cut
|
556 |
|
|
if(BinWidth<1) BinWidth=1.0; // unless that implies that we have some weird binning (bins thinner than a GeV for instance)
|
557 |
|
|
float xmin=0;
|
558 |
|
|
float xmax=110;
|
559 |
|
|
if(MetCut>xmax) xmax=MetCut;
|
560 |
|
|
int nbins=int((xmax-xmin)/BinWidth);
|
561 |
|
|
stringstream basiccut;
|
562 |
|
|
basiccut << (const char*) JetCut << "&&" << (const char*) Restrmasscut << "&&" << (const char*) leptoncut << "&&pt1>20&&pt2>20";
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
stringstream cMET_observed;
|
566 |
|
|
cMET_observed << "(" << basiccut.str() << "&&(" << sPositiveCut << ")&&" << (const char*) cutOSSF << ")";
|
567 |
|
|
stringstream cMET_ttbar_pred;
|
568 |
|
|
cMET_ttbar_pred << "(" << basiccut.str() << "&&(" << sPositiveCut << ")&&" << (const char*) cutOSOF << ")";
|
569 |
|
|
stringstream cMET_osof_pred;
|
570 |
|
|
cMET_osof_pred << "(" << basiccut.str() << "&&(" << sNegativeCut << ")&&" << (const char*) cutOSOF << ")";
|
571 |
|
|
stringstream cMET_ossf_pred;
|
572 |
|
|
cMET_ossf_pred << "(" << basiccut.str() << "&&(" << sNegativeCut << ")&&" << (const char*) cutOSSF << ")";
|
573 |
|
|
|
574 |
|
|
write_warning(__FUNCTION__,"Once the rush is over you might want to define the potential sidebands ... ");
|
575 |
|
|
//Step 2: Fill Met histograms
|
576 |
|
|
TCanvas *PredictionCanvas = new TCanvas("PredictionCanvas","PredictionCanvas");
|
577 |
|
|
TH1F *MET_observed = allsamples.Draw("MET_observed",ObservedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
578 |
|
|
TCut(cMET_observed.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
579 |
|
|
TH1F *MET_ossf_pred = allsamples.Draw("MET_ossf_pred",CorrectedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
580 |
|
|
TCut(cMET_ossf_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
581 |
|
|
TH1F *MET_osof_pred = allsamples.Draw("MET_osof_pred",CorrectedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
582 |
|
|
TCut(cMET_osof_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
583 |
|
|
TH1F *MET_ttbar_pred= allsamples.Draw("MET_ttbar_pred",ObservedMet,nbins,xmin,xmax,"MET [GeV]","events",
|
584 |
|
|
TCut(cMET_ttbar_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
585 |
|
|
|
586 |
|
|
TH1F *MET_predicted=(TH1F*)MET_ossf_pred->Clone("MET_predicted");
|
587 |
|
|
MET_predicted->Add(MET_osof_pred,-1);
|
588 |
|
|
MET_predicted->Add(MET_ttbar_pred);
|
589 |
|
|
MET_predicted->SetLineColor(kRed);
|
590 |
|
|
MET_observed->SetLineColor(kBlack);
|
591 |
|
|
|
592 |
|
|
TH1F *MET_Z_prediction=(TH1F*)MET_ossf_pred->Clone("MET_Z_prediction");
|
593 |
|
|
MET_Z_prediction->Add(MET_osof_pred,-1);
|
594 |
|
|
MET_Z_prediction->SetLineColor(kBlue);
|
595 |
|
|
|
596 |
|
|
LabelHisto(MET_observed,"MET (GeV)","events");
|
597 |
|
|
|
598 |
|
|
//Step 3: Fill JZB histograms
|
599 |
|
|
TH1F *JZB_observed = allsamples.Draw("JZB_observed",JZBPosvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
600 |
|
|
TCut(cMET_observed.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
601 |
|
|
TH1F *JZB_ossf_pred = allsamples.Draw("JZB_ossf_pred",JZBNegvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
602 |
|
|
TCut(cMET_ossf_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
603 |
|
|
TH1F *JZB_osof_pred = allsamples.Draw("JZB_osof_pred",JZBNegvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
604 |
|
|
TCut(cMET_osof_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
605 |
|
|
TH1F *JZB_ttbar_pred= allsamples.Draw("JZB_ttbar_pred",JZBPosvar,nbins,xmin,xmax,"JZB [GeV]","events",
|
606 |
|
|
TCut(cMET_ttbar_pred.str().c_str()),is_data,PlottingSetup::luminosity,SelectedSamples);
|
607 |
|
|
|
608 |
|
|
TH1F *JZB_predicted=(TH1F*)JZB_ossf_pred->Clone("JZB_predicted");
|
609 |
|
|
JZB_predicted->Add(JZB_osof_pred,-1);
|
610 |
|
|
JZB_predicted->Add(JZB_ttbar_pred);
|
611 |
|
|
JZB_predicted->SetLineColor(kRed);
|
612 |
|
|
JZB_observed->SetLineColor(kBlack);
|
613 |
|
|
|
614 |
|
|
TH1F *JZB_Z_prediction=(TH1F*)JZB_ossf_pred->Clone("JZB_Z_prediction");
|
615 |
|
|
JZB_Z_prediction->Add(JZB_osof_pred,-1);
|
616 |
|
|
MET_Z_prediction->SetLineColor(kBlue);
|
617 |
|
|
|
618 |
|
|
LabelHisto(JZB_observed,"JZB (GeV)","events");
|
619 |
|
|
|
620 |
|
|
// Step 4: Draw them and store them
|
621 |
|
|
PredictionCanvas->cd();
|
622 |
|
|
TPad *toppad = new TPad("toppad","toppad",0.0,0.3,1.0,1.0);
|
623 |
|
|
toppad->Draw();
|
624 |
|
|
PredictionCanvas->cd();
|
625 |
|
|
TPad *bottompad = new TPad("bottompad","bottompad",0.0,0.0,1.0,0.3);
|
626 |
|
|
bottompad->Draw();
|
627 |
|
|
PredictionCanvas->cd();
|
628 |
|
|
|
629 |
|
|
TLegend *legend = new TLegend(0.6,0.6,0.89,0.89);
|
630 |
|
|
|
631 |
|
|
MET_ttbar_pred->SetLineColor(TColor::GetColor("#005C00"));
|
632 |
|
|
JZB_ttbar_pred->SetLineColor(TColor::GetColor("#005C00"));
|
633 |
|
|
|
634 |
|
|
legend->SetFillColor(kWhite);
|
635 |
|
|
legend->SetBorderSize(0);
|
636 |
|
|
legend->AddEntry(MET_predicted,"prediction","l");
|
637 |
|
|
legend->AddEntry(MET_observed,"observed","p");
|
638 |
|
|
legend->AddEntry(MET_Z_prediction,"predicted Z","l");
|
639 |
|
|
legend->AddEntry(MET_ttbar_pred,"OF-based prediction","l");
|
640 |
|
|
|
641 |
|
|
if(is_data==mc) legend->SetHeader("Simulation:");
|
642 |
|
|
if(is_data==mc&&isDYonly) legend->SetHeader("DY #rightarrow ee,#mu#mu only:");
|
643 |
|
|
if(is_data==data) legend->SetHeader("Data:");
|
644 |
|
|
|
645 |
|
|
stringstream SaveJZBname;
|
646 |
|
|
stringstream SaveMETname;
|
647 |
|
|
if(is_data==data) {
|
648 |
|
|
SaveJZBname << "MetPrediction/JZBdistribution_Data_METCutAt" << MetCut;
|
649 |
|
|
SaveMETname << "MetPrediction/METdistribution_Data_METCutAt" << MetCut;
|
650 |
|
|
}
|
651 |
|
|
if(is_data==mc&&!isDYonly) {
|
652 |
|
|
SaveJZBname << "MetPrediction/JZBdistribution_FullMC_METCutAt" << MetCut;
|
653 |
|
|
SaveMETname << "MetPrediction/METdistribution_FullMC_METCutAt" << MetCut;
|
654 |
|
|
}
|
655 |
|
|
if(is_data==mc&&isDYonly) {
|
656 |
|
|
SaveJZBname << "MetPrediction/JZBdistribution_DYMC_METCutAt" << MetCut;
|
657 |
|
|
SaveMETname << "MetPrediction/METdistribution_DYMC_METCutAt" << MetCut;
|
658 |
|
|
}
|
659 |
|
|
|
660 |
|
|
TH1F *ZpredClone = (TH1F*)MET_Z_prediction->Clone("ZpredClone");
|
661 |
|
|
ZpredClone->SetLineColor(kBlue);
|
662 |
|
|
MET_observed->Rebin(int(DisplayedBinSize/BinWidth));
|
663 |
|
|
ZpredClone->Rebin(int(DisplayedBinSize/BinWidth));
|
664 |
|
|
MET_predicted->Rebin(int(DisplayedBinSize/BinWidth));
|
665 |
|
|
MET_ttbar_pred->Rebin(int(DisplayedBinSize/BinWidth));
|
666 |
|
|
|
667 |
|
|
TH1F *JZBZpredClone = (TH1F*)JZB_Z_prediction->Clone("ZpredClone");
|
668 |
|
|
JZBZpredClone->SetLineColor(kBlue);
|
669 |
|
|
JZB_observed->Rebin(int(DisplayedBinSize/BinWidth));
|
670 |
|
|
JZBZpredClone->Rebin(int(DisplayedBinSize/BinWidth));
|
671 |
|
|
JZB_predicted->Rebin(int(DisplayedBinSize/BinWidth));
|
672 |
|
|
JZB_ttbar_pred->Rebin(int(DisplayedBinSize/BinWidth));
|
673 |
|
|
|
674 |
|
|
TH1F *JZB_ratio = (TH1F*)JZB_observed->Clone("JZB_ratio");
|
675 |
|
|
JZB_ratio->Divide(JZB_predicted);
|
676 |
|
|
LabelHisto(JZB_ratio,"JZB (GeV)","obs/pred");
|
677 |
|
|
TH1F *MET_ratio = (TH1F*)MET_observed->Clone("MET_ratio");
|
678 |
|
|
MET_ratio->Divide(MET_predicted);
|
679 |
|
|
MET_observed->SetMinimum(0);
|
680 |
|
|
JZB_observed->SetMinimum(0);
|
681 |
|
|
LabelHisto(MET_ratio,"MET (GeV)","obs/pred");
|
682 |
|
|
TBox *sysenvelope = new TBox(xmin,1.0-JZB_Met_systematic,xmax,1.0+JZB_Met_systematic);
|
683 |
|
|
sysenvelope->SetFillColor(TColor::GetColor("#82FA58")); // light green
|
684 |
|
|
sysenvelope->SetLineWidth(0);
|
685 |
|
|
|
686 |
|
|
toppad->cd();
|
687 |
buchmann |
1.18 |
// toppad->SetLogy(1);
|
688 |
buchmann |
1.17 |
MET_observed->Draw("e1");
|
689 |
|
|
MET_ttbar_pred->Draw("histo,same");
|
690 |
|
|
ZpredClone->Draw("histo,same");
|
691 |
|
|
MET_predicted->Draw("histo,same");
|
692 |
|
|
MET_observed->Draw("e1,same");
|
693 |
|
|
legend->Draw();
|
694 |
|
|
if(is_data==data) DrawPrelim();
|
695 |
|
|
else DrawMCPrelim();
|
696 |
|
|
|
697 |
|
|
bottompad->cd();
|
698 |
|
|
MET_ratio->GetYaxis()->SetRangeUser(0,2);
|
699 |
|
|
MET_ratio->Draw("e1");
|
700 |
|
|
sysenvelope->Draw();
|
701 |
|
|
MET_ratio->Draw("AXIS,same");
|
702 |
|
|
MET_ratio->Draw("e1,same");
|
703 |
|
|
TLine *metl = new TLine(xmin,1.0,xmax,1.0);
|
704 |
|
|
metl->SetLineColor(kBlue);
|
705 |
|
|
metl->Draw();
|
706 |
|
|
CompleteSave(PredictionCanvas,SaveMETname.str());
|
707 |
|
|
|
708 |
|
|
toppad->cd();
|
709 |
|
|
JZB_observed->Draw("e1");
|
710 |
|
|
JZB_ttbar_pred->Draw("histo,same");
|
711 |
|
|
JZBZpredClone->Draw("histo,same");
|
712 |
|
|
JZB_predicted->Draw("histo,same");
|
713 |
|
|
JZB_observed->Draw("e1,same");
|
714 |
|
|
legend->Draw();
|
715 |
|
|
if(is_data==data) DrawPrelim();
|
716 |
|
|
else DrawMCPrelim();
|
717 |
|
|
|
718 |
|
|
bottompad->cd();
|
719 |
|
|
JZB_ratio->GetYaxis()->SetRangeUser(0,2);
|
720 |
|
|
JZB_ratio->Draw("e1");
|
721 |
|
|
sysenvelope->Draw();
|
722 |
|
|
JZB_ratio->Draw("AXIS,same");
|
723 |
|
|
JZB_ratio->Draw("e1,same");
|
724 |
|
|
metl->Draw();
|
725 |
|
|
|
726 |
|
|
CompleteSave(PredictionCanvas,SaveJZBname.str());
|
727 |
|
|
|
728 |
|
|
delete PredictionCanvas;
|
729 |
|
|
delete MET_observed;
|
730 |
|
|
delete MET_predicted;
|
731 |
|
|
//do NOT delete MET_Z_prediction (it's the return value)
|
732 |
|
|
delete MET_osof_pred;
|
733 |
|
|
delete MET_ossf_pred;
|
734 |
|
|
delete MET_ttbar_pred;
|
735 |
|
|
|
736 |
|
|
delete JZB_observed;
|
737 |
|
|
delete JZB_predicted;
|
738 |
|
|
delete JZB_osof_pred;
|
739 |
|
|
delete JZB_ossf_pred;
|
740 |
|
|
delete JZB_Z_prediction;
|
741 |
|
|
delete JZB_ttbar_pred;
|
742 |
|
|
|
743 |
|
|
return MET_Z_prediction;
|
744 |
|
|
}
|
745 |
|
|
|
746 |
|
|
float Get_Met_Z_Prediction(TCut JetCut, float MetCut, int isdata, bool isDYonly) {
|
747 |
|
|
dout << "Going to compute Z region prediction for a MET cut at " << MetCut << " GeV" << endl;
|
748 |
|
|
// Steps:
|
749 |
|
|
// 1) Get peak without Pt-correction
|
750 |
|
|
// 2) use the peak for sample splitting (|jzb-epsilon|>epsilon)
|
751 |
|
|
// and for MET distribution shifting (MET+epsilon)
|
752 |
|
|
// 3) compute the estimate for MET>MetCut
|
753 |
|
|
|
754 |
|
|
// do this for data if isdata==data, otherwise for MC (full closure if isDYonly==false, otherwise use only DY sample)
|
755 |
|
|
|
756 |
|
|
// Step 1) Get peak without Pt-correction
|
757 |
|
|
|
758 |
|
|
// Do it without Pt correction
|
759 |
|
|
|
760 |
|
|
float MCPeakNoPtCorr=0,MCPeakErrorNoPtCorr=0,DataPeakNoPtCorr=0,DataPeakErrorNoPtCorr=0,MCSigma=0,DataSigma=0;
|
761 |
|
|
stringstream resultsNoPtCorr;
|
762 |
|
|
stringstream NoPtCorrdatajzb;
|
763 |
|
|
stringstream NoPtCorrmcjzb;
|
764 |
|
|
|
765 |
|
|
string originalJZBvariableDATA = PlottingSetup::jzbvariabledata;
|
766 |
|
|
string originalJZBvariableMC = PlottingSetup::jzbvariablemc;
|
767 |
|
|
|
768 |
|
|
PlottingSetup::jzbvariabledata="jzb[1]";
|
769 |
|
|
PlottingSetup::jzbvariablemc="jzb[1]";
|
770 |
|
|
|
771 |
|
|
stringstream mcjzbNoPtCorr;
|
772 |
buchmann |
1.18 |
find_peaks(MCPeakNoPtCorr,MCPeakErrorNoPtCorr, DataPeakNoPtCorr,DataPeakErrorNoPtCorr,resultsNoPtCorr,true,NoPtCorrdatajzb,NoPtCorrmcjzb,(const char*) JetCut, true);
|
773 |
|
|
|
774 |
buchmann |
1.17 |
// write_warning(__FUNCTION__,"Temporarily deactivated peak finding, setting it to a manual default");MCPeakNoPtCorr=0.547127;DataPeakNoPtCorr=-1.07825;
|
775 |
|
|
|
776 |
|
|
PlottingSetup::jzbvariabledata=originalJZBvariableDATA;
|
777 |
|
|
PlottingSetup::jzbvariablemc=originalJZBvariableMC;
|
778 |
|
|
|
779 |
|
|
float PeakPosition=0;
|
780 |
|
|
|
781 |
|
|
if(isdata==data) {
|
782 |
|
|
PeakPosition=DataPeakNoPtCorr;
|
783 |
|
|
dout << "Found peak in data at " << DataPeakNoPtCorr << " +/- " << DataPeakErrorNoPtCorr << " ; will use this result (" << PeakPosition << ")" << endl;
|
784 |
|
|
} else {
|
785 |
|
|
PeakPosition=MCPeakNoPtCorr;
|
786 |
|
|
dout << "Found peak in mc at " << MCPeakNoPtCorr << " +/- " << MCPeakErrorNoPtCorr << " ; will use this result (" << PeakPosition << ")" << endl;
|
787 |
|
|
}
|
788 |
|
|
|
789 |
|
|
// Step 2: Use peak for sample splitting and MET shifting
|
790 |
|
|
|
791 |
|
|
string CorrectedMet="met[4]+"+any2string(abs(2*(PeakPosition)));
|
792 |
|
|
if(2*(PeakPosition)<0) CorrectedMet="met[4]-"+any2string(abs(2*(PeakPosition)));
|
793 |
|
|
|
794 |
|
|
stringstream sPositiveCut;
|
795 |
|
|
if(PeakPosition>0) sPositiveCut << "((jzb[1]-" << PeakPosition << ")>" << PeakPosition << ")";
|
796 |
|
|
else sPositiveCut << "((jzb[1])>0)";
|
797 |
|
|
|
798 |
|
|
stringstream sNegativeCut;
|
799 |
|
|
if(PeakPosition<0) sNegativeCut << "((jzb[1]+" << abs(PeakPosition) << ")<" << PeakPosition << ")";
|
800 |
|
|
else sNegativeCut << "((jzb[1])<0)";
|
801 |
|
|
|
802 |
|
|
string ObservedMet="met[4]";
|
803 |
|
|
|
804 |
|
|
stringstream JZBPosvar;
|
805 |
|
|
JZBPosvar<<"(jzb[1]";
|
806 |
|
|
if(PeakPosition>0) JZBPosvar << "-" << PeakPosition << ")";
|
807 |
|
|
else JZBPosvar << ")";
|
808 |
|
|
stringstream JZBNegvar;
|
809 |
|
|
JZBNegvar<<"-(jzb[1]";
|
810 |
|
|
if(PeakPosition>0) JZBNegvar << ")";
|
811 |
|
|
else JZBNegvar << " + " << abs(PeakPosition) << ")";
|
812 |
|
|
|
813 |
|
|
// Step 3: Compute estimate
|
814 |
|
|
TH1F *predicted = GetPredictedAndObservedMetShapes(JetCut, sPositiveCut.str(),sNegativeCut.str(),CorrectedMet,ObservedMet,JZBPosvar.str(),JZBNegvar.str(), MetCut, isdata, isDYonly);
|
815 |
|
|
float ZregionZestimate=0;
|
816 |
|
|
for(int ibin=1;ibin<=(int)predicted->GetNbinsX();ibin++) {
|
817 |
|
|
if(predicted->GetBinLowEdge(ibin)+predicted->GetBinWidth(ibin)>MetCut) {
|
818 |
|
|
ZregionZestimate+=2*(predicted->GetBinContent(ibin));
|
819 |
buchmann |
1.18 |
cout << "Added " << 2*(predicted->GetBinContent(ibin)) << " to Z prediction from bin [" << predicted->GetBinLowEdge(ibin) << " , " << predicted->GetBinLowEdge(ibin)+predicted->GetBinWidth(ibin) << "] ; ZregionZestimate now: " << ZregionZestimate << endl;
|
820 |
buchmann |
1.17 |
}
|
821 |
|
|
}
|
822 |
|
|
|
823 |
|
|
return ZregionZestimate;
|
824 |
|
|
}
|
825 |
|
|
|
826 |
buchmann |
1.12 |
void ExperimentalMetPrediction() {
|
827 |
buchmann |
1.17 |
|
828 |
|
|
stringstream snjets;
|
829 |
|
|
snjets << 3;
|
830 |
buchmann |
1.12 |
|
831 |
buchmann |
1.17 |
TCut nJetsSignal(PlottingSetup::basicqualitycut&&("pfJetGoodNum40>="+snjets.str()).c_str());
|
832 |
|
|
TCut nJetsControl(("pfJetGoodID[0]!=0&&pfJetGoodNum40<"+snjets.str()).c_str());
|
833 |
|
|
|
834 |
|
|
cout << " ***** TESTING Z PREDICTION ***** " << endl;
|
835 |
|
|
cout << "Notation (you can copy & paste this to evaluate it further)" << endl;
|
836 |
|
|
cout << "Cut;Data;MC;DY;" << endl;
|
837 |
buchmann |
1.18 |
// for(float maxMET=10;maxMET<=110;maxMET+=20) {
|
838 |
|
|
float maxMET=100;
|
839 |
|
|
float MCEstimate = Get_Met_Z_Prediction(nJetsSignal,maxMET, mc, false);
|
840 |
|
|
float DYEstimate = Get_Met_Z_Prediction(nJetsSignal,maxMET, mc, true);
|
841 |
buchmann |
1.17 |
float DataEstimate = Get_Met_Z_Prediction(nJetsSignal,maxMET, data, false);
|
842 |
buchmann |
1.18 |
// cout << maxMET << ";" << DataEstimate << ";" << MCEstimate << ";" << DYEstimate << endl;
|
843 |
|
|
cout << "Found estimate in data of " << DataEstimate << endl;
|
844 |
|
|
// DataEstimate = Get_Met_Z_Prediction(nJetsSignal,maxMET, data, false);
|
845 |
|
|
cout << "Found estimate in data of " << DataEstimate << endl;
|
846 |
|
|
// }
|
847 |
buchmann |
1.12 |
}
|
848 |
buchmann |
1.17 |
|