ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/MetPlotting.C
Revision: 1.18
Committed: Thu Sep 6 10:20:54 2012 UTC (12 years, 8 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.17: +15 -10 lines
Log Message:
Extracting peak position individually for each jet selection; refined Z peak estimate used on mll spectrum

File Contents

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