ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/ZbTools.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/ZbTools.C (file contents):
Revision 1.3 by buchmann, Thu Jul 12 12:53:41 2012 UTC vs.
Revision 1.25 by buchmann, Fri Feb 1 11:49:13 2013 UTC

# Line 1 | Line 1
1 +
2   #include <iostream>
3   #include <vector>
4   #include <sys/stat.h>
5 + #include <math.h>
6  
7   #include <TCut.h>
8   #include <TROOT.h>
# Line 16 | Line 18
18   #include <TProfile.h>
19   #include <TLegendEntry.h>
20  
21 + #include <RooRealVar.h>
22 + #include <RooArgSet.h>
23 + #include <RooDataSet.h>
24 + #include <RooDataHist.h>
25 + #include <RooMCStudy.h>
26 + #include <RooCategory.h>
27 +
28 + #include <RooPlot.h>
29 + #include <RooSimultaneous.h>
30 + #include <RooAddPdf.h>
31 + #include <RooFitResult.h>
32 + #include <RooVoigtian.h>
33 + #include <RooChebychev.h>
34 + #include <RooMsgService.h>
35 +
36 + #include <RooStats/ModelConfig.h>
37 + #include "RooStats/ProfileLikelihoodCalculator.h"
38 + #include "RooStats/LikelihoodInterval.h"
39 + #include "RooStats/HypoTestResult.h"
40 + #include "RooStats/SimpleLikelihoodRatioTestStat.h"
41 + #include "RooStats/ProfileLikelihoodTestStat.h"
42 + #include "RooStats/HybridCalculatorOriginal.h"
43 + #include "RooStats/HypoTestInverterOriginal.h"
44 +
45   using namespace std;
46  
47   using namespace PlottingSetup;
48  
49   namespace ZbData {
50 < vector<float> data_over_mc;
51 <
52 < TCut ZplusBsel("pt1>20&&pt2>20&&mll>60&&mll<120");
53 < TCut LeadingB("bTagProbCSVBP[0]>0.679");
28 < TCut EtaB("abs(pfJetGoodEta[0])<1.3");
29 < TCut PhiZcut("pfJetDphiZ[0]>2.7");
50 > TCut ZplusBsel("pt1>20&&pt2>20&&mll>60&&mll<120&&id1==id2");
51 > TCut LeadingB("ZbCHS3010_bTagProbCSVBP[0]>0.898");
52 > TCut EtaB("abs(ZbCHS3010_pfJetGoodEta[0])<1.3");
53 > TCut PhiZcut("abs(ZbCHS3010_pfJetDphiZ[0])>2.7");
54    
55   }
56  
57 + TCut STDWEIGHT;
58 +
59 + class ZbPointResult {
60 + public:
61 +  ZbPointResult(string var, float ptlow, float pthigh, float alphalow, float alphahigh, Value Data, Value MC);
62 +  float PtLow;
63 +  float PtHigh;
64 +  float AlphaLow;
65 +  float AlphaHigh;
66 +  string variable;
67 +  Value Data;
68 +  Value MC;
69 +  Value Ratio;
70 + };
71 +
72 + ZbPointResult::ZbPointResult(string var, float ptlow, float pthigh, float alphalow, float alphahigh, Value data, Value mc) :
73 +  variable(var), PtLow(ptlow), PtHigh(pthigh), AlphaLow(alphalow), AlphaHigh(alphahigh), Data(data), MC(mc) {
74 +    Ratio = data/mc;
75 + }
76 +  
77 + std::ostream &operator<<(std::ostream &ostr, ZbPointResult &b)
78 + {
79 +  ostr << b.PtLow << ";" << b.PtHigh << ";" << b.AlphaLow << ";" << b.AlphaHigh << ";" << b.Data.getValue() << ";" << b.Data.getError() << ";" << b.MC.getValue() << ";" << b.MC.getError() << ";" << b.Ratio.getValue() << ";" << b.Ratio.getError();
80 +  return ostr;
81 + }
82 +
83 +
84 + class ZbResultContainer {
85 + public:
86 +  string name;  
87 +  vector<ZbPointResult> MPF_Rabs_location;
88 +  Value MPF_Result_FaceValue;
89 +  Value Rabs_Result_FaceValue;
90 +  Value MPF_Result_Extrapolated;
91 +  Value Rabs_Result_Extrapolated;
92 +  
93 +  ZbResultContainer(string name);
94 +  ZbResultContainer(const ZbResultContainer &old);
95 + };
96 +
97 +
98 + ZbResultContainer::ZbResultContainer(string _name) {
99 +  name=_name;
100 +  cout<< "Result Container for \"" << name << "\" has been initialized" << endl;
101 +  
102 + }
103 +
104 + std::ostream &operator<<(std::ostream &ostr, ZbResultContainer &b)
105 + {
106 +  ostr << "Results for " << b.name << endl;
107 +  ostr << " MPF and Rabs locations: " << endl;
108 +  for(int i=0;i<b.MPF_Rabs_location.size();i++) ostr << "   " << b.MPF_Rabs_location[i] << endl;
109 +  ostr << " Results: " << endl;
110 +  ostr << "   Face Value: " << endl;
111 +  ostr << "     MPF " << b.MPF_Result_FaceValue << endl;
112 +  ostr << "     Rabs " << b.Rabs_Result_FaceValue << endl;
113 +  ostr << "   Extrapolated: " << endl;
114 +  ostr << "     MPF " << b.MPF_Result_Extrapolated << endl;
115 +  ostr << "             Rabs " << b.Rabs_Result_Extrapolated << endl;
116 +  
117 +  return ostr;
118 + }
119 +
120 +
121 +
122   using namespace ZbData;
123  
124 < void print_yield(TCut cut) {
124 >
125 > //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*  DELETE EVERYTHING BETWEEN THIS LINE /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
126 > void SpecialCutFlow(string identifier);
127 >  
128 > //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*            AND THIS LINE             /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
129 >
130 >
131 > class CutYields{
132 > public:
133 >  float data;
134 >  float Zb;
135 >  float Zc;
136 >  float Zl;
137 >  float tt;
138 >  float SiTo;
139 >  float Dibosons;
140 >  float WJets;
141 >  float Other;
142 >  
143 >  CutYields();
144 > };
145 >
146 > CutYields::CutYields() {
147 >  this->data=0;
148 >  this->Zb=0;
149 >  this->Zc=0;
150 >  this->Zl=0;
151 >  this->tt=0;
152 >  this->SiTo=0;
153 >  this->Dibosons=0;
154 >  this->WJets=0;
155 >  this->Other=0;
156 > }
157 >
158 > std::ostream &operator<<(std::ostream &ostr, CutYields y)
159 > {
160 >  return ostr << y.data << ";" << y.Zb << ";" << y.Zc << ";" << y.Zl << ";" << y.tt << ";" << y.SiTo << ";" << y.Dibosons << ";" << y.WJets << ";" << endl;
161 > }
162 >
163 >
164 > CutYields print_yield(TCut cut) {
165 >  
166 >  CutYields Yield;
167    TH1F *data  = allsamples.Draw("data",    "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,data,luminosity);
168 <  cout << "  Yields for " << (const char*) cut << endl;
169 <  cout << "     data: " << data->Integral() << endl;
168 >  dout << "  Yields for " << (const char*) cut << endl;
169 > //  dout << "     data: " << data->Integral() << endl;
170 >  
171 >  Yield.data=data->Integral();
172    THStack mcm = allsamples.DrawStack("mc", "mll",1,0,10000000, "m_{ll} [GeV]", "events", cut,mc,luminosity);
173    int nhists = mcm.GetHists()->GetEntries();
41  cout << "Going to loop over " << nhists << " histograms " << endl;
174    TFile *test = new TFile("test.root","RECREATE");
175    mcm.Write();
176    test->Close();
177    for (int i = 0; i < nhists; i++) {
178      TH1* hist = static_cast<TH1*>(mcm.GetHists()->At(i));
179 <    cout << "     " << hist->GetName() << ": " << hist->Integral() << endl;
179 >    string name=hist->GetName();
180 >    if(Contains(name,"t_bar_t")) Yield.tt+=hist->Integral();
181 >    if(Contains(name,"W_Jets")) Yield.WJets+=hist->Integral();
182 >    if(Contains(name,"Single_top")) Yield.SiTo+=hist->Integral();
183 >    if(Contains(name,"Dibosons")) Yield.Dibosons+=hist->Integral();
184 >    if(Contains(name,"Z_l_")) Yield.Zl+=hist->Integral();
185 >    if(Contains(name,"Z_c_")) Yield.Zc+=hist->Integral();
186 >    if(Contains(name,"Z_b_")) Yield.Zb+=hist->Integral();
187    }
188 +  
189 +  cout << Yield << endl;
190    cout << endl << endl;
191 +  
192    delete data;
193 +  CleanLegends();
194 +  DeleteStack(mcm);
195 +
196 +  return Yield;
197   }
198  
199   void draw_kin_variable(string variable, TCut cut, int nbins, float min, float max, string xlabel, string saveas, bool dologscale, string speciallabel="") {
54  
200    TCanvas *ckin = new TCanvas("ckin","kin variable canvas");
201 <  ckin->SetLogy(dologscale);
201 >  if(dologscale) ckin->SetLogy(1);
202    TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
203    datahisto->SetMarkerSize(DataMarkerSize);
204    THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
205    if(dologscale) datahisto->SetMaximum(3*datahisto->GetMaximum());
206    else datahisto->SetMaximum(1.5*datahisto->GetMaximum());
207 <  TText *speciall;
208 <  if(speciallabel!="") {
209 <    speciall = new TText(0.2,0.8,speciallabel.c_str());
210 <    speciall->Draw();
207 >  
208 >  float SumMC=0.0;
209 >  TIter nextH(mcstack.GetHists());
210 >  TH1F* h;
211 >  while ( h = (TH1F*)nextH() ) {
212 >    SumMC += h->Integral();
213 >  }
214 >  float scale = datahisto->Integral()/SumMC;
215 >
216 >  // Re-scale stack to data integral
217 >  nextH = TIter(mcstack.GetHists());
218 >  
219 >  while ( h = (TH1F*)nextH() ) {
220 >    h->Scale(scale);
221    }
222 +  
223 +  TText *speciall;
224    datahisto->Draw("e1");
225    ckin->Update();
226 <  mcstack.Draw("same");
226 >  mcstack.Draw("histo,same");
227    datahisto->Draw("same,e1");
228    TLegend *kinleg = allsamples.allbglegend();
229 +
230    kinleg->Draw();
231  
232    TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
233    kinpad->cd();
234 <  kinpad->SetLogy(dologscale);
234 >  if(dologscale) kinpad->SetLogy(1);
235    datahisto->Draw("e1");
236 <  mcstack.Draw("same");
236 >  mcstack.Draw("histo,same");
237    datahisto->Draw("same,e1");
238    datahisto->Draw("same,axis");
239    kinleg->Draw();
240    DrawPrelim();
241    saveas="kin/"+saveas;
242 <  save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
85 <
86 <  
242 >  kinpad->cd();
243    
244 +  if(speciallabel!="") {
245 +    speciall = write_title(speciallabel);
246 +    speciall->SetX(0.18);
247 +    speciall->SetTextAlign(11);
248 +    speciall->SetTextSize(0.03);
249 +    speciall->SetY(0.85);
250 +    speciall->Draw();
251 +  }
252    
253 <  ZbData::data_over_mc.push_back(datahisto->Integral()/CollapseStack(mcstack)->Integral());
253 >  Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
254    
255    datahisto->Delete();
256 +  delete kinleg;
257    delete ckin;
258 < }
259 <  
95 < Value getfrom2Dmap(TH2F *map, int ixbin, int iybin) {
96 <  Value sum(0,0);
97 <  for(int iy=1;iy<=iybin;iy++) {
98 <    sum=sum+Value(map->GetBinContent(ixbin,iy),map->GetBinError(ixbin,iy));
99 <  }
100 <  return sum;
101 < }
102 <  
103 <  
104 < void data_mc_agreement_2d() {
105 <  
106 <  vector<int> emptyvector;
107 <  float binX[5]={10,50,100,200,1000};
108 <  float binY[5]={0.0,0.1,0.15,0.2,0.3};
109 <  vector<float>binningx;
110 <  vector<float>binningy;
111 <  binningx.assign(binX,binX+5);
112 <  binningy.assign(binY,binY+5);
113 <  
114 <  TCut cut(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
115 <  
116 <  TCanvas *agrcan = new TCanvas("agrcan","agrcan");
117 <  
118 <  cout << "Drawing 2d for data " << endl;
119 <  TH2F *alphazptplane_data = allsamples.Draw("alphazptplane_data","alpha:pt",binningx,binningy,"Z p_{T}","#alpha",cut,data,luminosity,emptyvector,false);
120 <  cout << "Drawing 2d for MC " << endl;
121 <  TH2F *alphazptplane_mc   = allsamples.Draw("alphazptplane_mc",  "alpha:pt",binningx,binningy,"Z p_{T}","#alpha",cut,mc,  luminosity,emptyvector,false);
122 <  
123 <  
124 <  TFile *f = new TFile("test.root","RECREATE");
125 <  alphazptplane_data->Write();
126 <  f->Close();
127 <  
128 <  for(int ix=1;ix<binningx.size();ix++) {
129 <    cout << "pt in " << binningx[ix-1] << " , " << binningx[ix] << endl;
130 <    TGraphErrors gr;
131 <    for(int iy=1;iy<binningy.size();iy++) {
132 <      Value mc   = Value((getfrom2Dmap(alphazptplane_mc,ix,iy)).getValue(),0.0);// not taking MC statistics into account
133 <      Value data = getfrom2Dmap(alphazptplane_data,ix,iy);
134 <      cout << " For an alpha cut at " << binningy[iy] << " we get : mc (" << mc << ") , data (" << data << ") --> data/mc = " << data/mc << endl;
135 <      gr.SetPoint(iy-1,binningy[iy],(data/mc).getValue());
136 <      gr.SetPointError(iy-1,0,(data/mc).getError());
137 <    }
138 <
139 <    gr.Draw("AP*");
140 <    gr.GetYaxis()->SetTitle("data / mc");
141 <    gr.GetYaxis()->CenterTitle();
142 <    gr.GetXaxis()->SetTitle("#alpha");
143 <    gr.GetXaxis()->CenterTitle();
144 <    gr.GetXaxis()->SetRangeUser(0,0.4);
145 <    gr.GetYaxis()->SetRangeUser(0.5,1.5);
146 <    gr.Draw("AP*");
147 <    DrawPrelim();
148 <    stringstream ptbin;
149 <    ptbin << binningx[ix-1] << " < p_{T}^{Z} < " << binningx[ix] << " GeV";
150 <    TText *ptt = write_title(ptbin.str());
151 <    ptt->SetX(0.7);
152 <    ptt->SetY(0.7);
153 <    ptt->SetTextSize(0.03);
154 <    ptt->Draw();
155 <    TLine *l = new TLine(0.0,1.0,0.4,1.0);
156 <    l->SetLineStyle(2);
157 <    l->SetLineColor(kBlue);
158 <    l->Draw();
159 <    
160 <    stringstream saveas;
161 <    saveas << "Zplusb_data_over_mc___" << binningx[ix-1] << "to" << binningx[ix];
162 <    DrawPrelim();
163 <    CompleteSave(agrcan,saveas.str());
164 < //    agrcan->SaveAs("tester.png");
165 <  }
166 <  
167 <  delete agrcan;
168 <  
258 >  CleanLegends();
259 >  DeleteStack(mcstack);
260   }
261  
262   void print_all_b_yields() {
263 +  vector<CutYields> yields;
264    cout << "Basic selection with a b jet" << endl;
265 <  print_yield(ZplusBsel&&"pfJetGoodNumBtag>0");
265 >  yields.push_back(print_yield(ZplusBsel&&"ZbCHS3010_pfJetGoodNumBtag>0"));
266    cout << "Leading jet is a b-jet " << endl;
267 <  print_yield(ZplusBsel&&LeadingB);
267 >  yields.push_back(print_yield(ZplusBsel&&LeadingB));
268    cout << "|#eta_{b}|<1.3 " << endl;
269 <  print_yield(ZplusBsel&&LeadingB&&EtaB);
269 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB));
270    cout << "|#delta#phi(b<Z)|>2.7" << endl;
271 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
272 <  cout << "10<ptZ<1000 GeV" << endl;
273 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000");
271 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut));
272 >  cout << "30<ptZ<1000 GeV" << endl;
273 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"));
274 >  cout << "#alpha < 0.35" << endl;
275 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.35"));
276    cout << "#alpha < 0.3" << endl;
277 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.3");
278 <  cout << "#alpha < 0.2" << endl;
279 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.2");
277 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.3"));
278 > /*  cout << "#alpha < 0.2" << endl;
279 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.2"));
280    cout << "#alpha < 0.15" << endl;
281 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.15");
281 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.15"));
282    cout << "#alpha < 0.1" << endl;
283 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.1");
284 <  cout << "#alpha < 0.05" << endl;
285 <  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.05");
283 >  yields.push_back(print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000"&&"(ZbCHS3010_alpha)<0.1"));*/
284 >
285 >  for(int iy=0;iy<yields.size();iy++) {
286 >    cout << yields[iy] << endl;
287 >  }
288   }  
289  
290 + void DrawEvilCutFlow() {
291 +  stringstream MegaCut;
292 +  
293 +  MegaCut << "   1*(" << (const char*) (ZplusBsel&&TCut("ZbCHS3010_pfJetGoodNumBtag>0")) << ")";
294 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB) << ")";
295 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB) << ")";
296 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut) << ")";
297 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000")) << ")";
298 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.3")) << ")";
299 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.2")) << ")";
300 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.15")) << ")";
301 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.1")) << ")";
302 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.05")) << ")";
303 +  MegaCut << " ";
304 +  
305 +  TCanvas *can = new TCanvas("can","can");
306 +  can->SetLogy(1);
307 +  TCut basecut("mll>6||mll<10");
308 +  
309 +  
310 +  
311 +  TLegend *leg = allsamples.allbglegend();
312 +  
313 +  
314 +  TH1F *data  = allsamples.Draw("data",    MegaCut.str(),11,-0.5,10.5, "", "events", basecut,data,luminosity);
315 +  THStack mcm = allsamples.DrawStack("mc", MegaCut.str(),11,-0.5,10.5, "", "events", basecut,mc,luminosity);
316 +
317 +  float runningsum=0;
318 +  for(int i=data->GetNbinsX();i>0;i--) {
319 +    runningsum+=data->GetBinContent(i);
320 +    data->SetBinContent(i,runningsum);
321 +  }
322 +  
323 +  float minimum=data->GetMaximum();
324 +  
325 +  TH1F* h;
326 +  TIter nextOF(mcm.GetHists());
327 +  while ( h = (TH1F*)nextOF() ) {
328 +    float runningsum=0;
329 +    minimum=data->GetMaximum();//done deliberately at each step so get the minimum of the last (!) contribution
330 +    for(int i=h->GetNbinsX();i>0;i--) {
331 +      runningsum+=h->GetBinContent(i);
332 +      h->SetBinContent(i,runningsum);
333 +      if(runningsum<minimum&&runningsum>0) minimum=runningsum;
334 +    }
335 +  }
336 +  
337 +  
338 +
339 +  data->SetMinimum(0.05*minimum);
340 +  can->cd(1)->SetBottomMargin(0.25);
341 +  data->GetXaxis()->SetBinLabel(1,"Pre-selection");
342 +  data->GetXaxis()->SetBinLabel(2,"Contains b jet");
343 +  data->GetXaxis()->SetBinLabel(3,"Leading jet is b-jet");
344 +  data->GetXaxis()->SetBinLabel(4,"|#eta_{b}|<1.3 ");
345 +  data->GetXaxis()->SetBinLabel(5,"|#delta#phi(b,Z)|>2.7");
346 +  data->GetXaxis()->SetBinLabel(6,"30<p_{T}^{Z}<1000 GeV");
347 +  data->GetXaxis()->SetBinLabel(7,"#alpha < 0.3");
348 +  data->GetXaxis()->SetBinLabel(8,"#alpha < 0.2");
349 +  data->GetXaxis()->SetBinLabel(9,"#alpha < 0.15");
350 +  data->GetXaxis()->SetBinLabel(10,"#alpha < 0.1");
351 +  data->GetXaxis()->SetBinLabel(11,"#alpha < 0.05");
352 +  data->GetXaxis()->LabelsOption("v");
353 +  
354 +  data->Draw("e1");
355 +  mcm.Draw("histo,same");
356 +  data->Draw("same,e1,axis");
357 +  data->Draw("same,e1");
358 + //  data->Draw("same,TEXT");
359 +  
360 +  leg->Draw();
361 +  
362 +  DrawPrelim();
363 +  
364 +  CompleteSave(can,"CutFlow");
365 +  CleanLegends();
366 +  DeleteStack(mcm);
367 +
368 + }
369 +
370   void draw_Zb_kin_vars() {
371 <  draw_kin_variable("pfBJetDphiZ",ZplusBsel&&LeadingB,100,0,3.2,"#delta#phi (Z,b lead)","DeltaPhiZBlead",1);
372 <  draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",50,0,200,"Z p_{T}","Zpt",1);
373 <  draw_kin_variable("pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",50,0,200,"Sub-Leading Jet Pt","Jet2Pt",1);
374 <  draw_kin_variable("pfJetGoodPtlBtag[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",50,0,200,"Leading Jet Pt (B)","LeadingJetPt",1);
375 <  draw_kin_variable("alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,2,"#alpha","alpha",1);
371 >  
372 >   draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000"),25,0,200,"Z p_{T}","Official/Zpt",1);
373 >   draw_kin_variable("ZbCHS3010_pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000"),25,0,200,"Sub-Leading Jet Pt","Official/Jet2Pt",1);
374 >   draw_kin_variable("ZbCHS3010_pfJetGoodPt[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000"),25,0,200,"Leading Jet Pt (B)","Official/LeadingJetPt",1);
375 >   draw_kin_variable("ZbCHS3010_pfJetGoodPt[1]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000"),20,0,2,"p_{T}^{J2} / p_{T}^{Z}","Official/SubLeadingJetPt_Over_ZPt",1);
376 >   draw_kin_variable("ZbCHS3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<50"),   40,0,2,"#alpha","Official/alpha_pt_30_to_50",1);
377 >   draw_kin_variable("ZbCHS3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>50&&pt<75"),  40,0,2,"#alpha","Official/alpha_50_to_75",1);
378 >   draw_kin_variable("ZbCHS3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>75&&pt<125"), 40,0,2,"#alpha","Official/alpha_pt_75_to_125",1);
379 >   draw_kin_variable("ZbCHS3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>125&&pt<1000"),40,0,2,"#alpha","Official/alpha_pt_125_to_1000",1);
380 >   draw_kin_variable("ZbCHS3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000"),40,0,2,"#alpha","Official/alpha_pt_30_to_1000",1);
381 >  
382 >   draw_kin_variable("ZbCHS3010_pfBJetDphiZ[0]",ZplusBsel&&LeadingB&&TCut("pt>30&&pt<1000&&pfBJetDphiZ[0]>0"),30,0,3.2,"#delta#phi (Z,b lead)","DeltaPhiZBlead",0);
383   }
384  
385   void draw_mpf_vars() {
386 <  ZbData::data_over_mc.clear();
387 <  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.3",20,0,2,"Z+b MPF","mpf_alpha_smaller_0p3",0,"#alpha<0.3, 10 GeV < p_{T}^{Z} < 1000 GeV");
388 <  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.2",20,0,2,"Z+b MPF","mpf_alpha_smaller_0p2",0,"#alpha<0.2, 10 GeV < p_{T}^{Z} < 1000 GeV");
389 <  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.15",20,0,2,"Z+b MPF","mpf_alpha_smaller_0p15",0,"#alpha<0.15, 10 GeV < p_{T}^{Z} < 1000 GeV");
390 <  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.1",20,0,2,"Z+b MPF","mpf_alpha_smaller_0p1",0,"#alpha<0.1, 10 GeV < p_{T}^{Z} < 1000 GeV");
391 <  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.05",20,0,2,"Z+b MPF","mpf_alpha_smaller_0p05",0,"#alpha<0.05, 10 GeV < p_{T}^{Z} < 1000 GeV");
392 <  
393 <  draw_kin_variable("pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.3",20,0,2,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p3",0,"#alpha<0.3, 10 GeV < p_{T}^{Z} < 1000 GeV");
394 <  draw_kin_variable("pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.2",20,0,2,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p2",0,"#alpha<0.2, 10 GeV < p_{T}^{Z} < 1000 GeV");
395 <  draw_kin_variable("pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.15",20,0,2,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p15",0,"#alpha<0.15, 10 GeV < p_{T}^{Z} < 1000 GeV");
396 <  draw_kin_variable("pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.1",20,0,2,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p1",0,"#alpha<0.1, 10 GeV < p_{T}^{Z} < 1000 GeV");
214 <  draw_kin_variable("pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"alpha<0.05",20,0,2,"p_{T} b-jet / p_{T} Z","ptb_over_ptz__mpf_alpha_smaller_0p05",0,"#alpha<0.05, 10 GeV < p_{T}^{Z} < 1000 GeV");
386 >  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.3"), 20,0.0,2.0,"Z+b MPF","mpf_alpha_smaller_0p3",0,"#alpha<0.3, 30 GeV < p_{T}^{Z} < 1000 GeV");
387 >  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.2"), 20,0.0,2.0,"Z+b MPF","mpf_alpha_smaller_0p2",0,"#alpha<0.2, 30 GeV < p_{T}^{Z} < 1000 GeV");
388 >  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.15"),20,0.0,2.0,"Z+b MPF","mpf_alpha_smaller_0p15",0,"#alpha<0.15, 30 GeV < p_{T}^{Z} < 1000 GeV");
389 >  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.1"), 20,0.0,2.0,"Z+b MPF","mpf_alpha_smaller_0p1",0,"#alpha<0.1, 30 GeV < p_{T}^{Z} < 1000 GeV");
390 >  draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.05"),20,0.0,2.0,"Z+b MPF","mpf_alpha_smaller_0p05",0,"#alpha<0.05, 30 GeV < p_{T}^{Z} < 1000 GeV");
391 >  
392 >  draw_kin_variable("ZbCHS3010_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.3"), 20,0.0,2.0,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p3",    0,"#alpha<0.3, 30 GeV < p_{T}^{Z} < 1000 GeV");
393 >  draw_kin_variable("ZbCHS3010_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.2"), 20,0.0,2.0,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p2",    0,"#alpha<0.2, 30 GeV < p_{T}^{Z} < 1000 GeV");
394 >  draw_kin_variable("ZbCHS3010_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.15"),20,0.0,2.0,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p15",   0,"#alpha<0.15, 30 GeV < p_{T}^{Z} < 1000 GeV");
395 >  draw_kin_variable("ZbCHS3010_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.1"), 20,0.0,2.0,"p_{T} b-jet / p_{T} Z","ptb_over_ptz___alpha_smaller_0p1",    0,"#alpha<0.1, 30 GeV < p_{T}^{Z} < 1000 GeV");
396 >  draw_kin_variable("ZbCHS3010_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<1000&&ZbCHS3010_alpha<0.05"),20,0.0,2.0,"p_{T} b-jet / p_{T} Z","ptb_over_ptz__mpf_alpha_smaller_0p05",0,"#alpha<0.05, 30 GeV < p_{T}^{Z} < 1000 GeV");
397   }  
398  
399 < Value get_Zb_data_over_mc(string variable, TCut cut) {
399 > void make_RooFit(string ContainerName, TH1F *h, float &peak, float &error_peak, string saveas) {
400 >  RooRealVar mpf("mpf","mpf", -5, 5, "");
401 >  RooDataHist AllData("AllData", "CMS Real Dataset", mpf , h);
402 >
403 >  RooRealVar fraction("fraction", "fraction", 0.8, 0, 1);
404 >  RooRealVar mean("mean", "mean", 1, 0, 3);
405 >  RooRealVar sigma("sigma", "sigma", 1, 0, 5);
406 >  RooRealVar width("width", "width", 2.4, 0, 5);
407 >  RooRealVar chevvar1("chevvar1", "chevvar1", 0.2,-1.0, 1.0);
408 >  RooRealVar chevvar2("chevvar2", "chevvar2", 0.2,-1.0, 1.0);
409 >
410 >  RooVoigtian signal("signal", "signal", mpf, mean, width, sigma);
411 >  RooChebychev background("background_", "background", mpf, RooArgList(chevvar1, chevvar2));
412 >
413 >  RooAddPdf pdf("pdf",  "pdf", RooArgList(signal, background), fraction);
414 >
415 >  RooFitResult *result = pdf.fitTo(AllData, RooFit::Save());
416 >  RooPlot* frame = mpf.frame(RooFit::Bins(30), RooFit::Title("MPF")) ;
417 >  AllData.plotOn(frame);
418 >  pdf.plotOn(frame, RooFit::LineColor(kBlue)) ;
419 >  pdf.plotOn(frame, RooFit::Components(RooArgSet(background)), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed)) ;
420 >  pdf.plotOn(frame, RooFit::Components(RooArgSet(signal)), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen)) ;
421 >
422 >  RooRealVar* thePeak = (RooRealVar*) result->floatParsFinal().find("mean");
423 >  peak = thePeak->getVal();
424 >  error_peak = thePeak->getError();
425 >
426 >  string saveasFinal = saveas + "_Fit";
427 >  TCanvas* c = new TCanvas("mpfFitted","mpfFitted",800,400) ;
428 >  c->cd() ; gPad->SetLeftMargin(0.15) ; frame->GetYaxis()->SetTitleOffset(1.4) ; frame->Draw();
429 >  CompleteSave(c, ContainerName+"/Fit/"+saveasFinal);
430 >
431 >  delete c;
432 >  delete frame;
433 >  delete thePeak;
434 >  delete result;
435 > }
436 >
437 > Value get_Zb_data_over_mc(string ContainerName, ZbResultContainer &res, string variable, string variable2, TCut cut, string saveas, float pt1, float pt2, float a1, float a2) {
438   //  write_warning(__FUNCTION__,"Debugging this function, therefore always returning 3.1415+/-1.010101"); return Value(3.1415,1.010101);
439 <  TH1F *hdata  = allsamples.Draw("hdata",variable,1000,0,30, "#alpha [GeV]", "events", cut,data,luminosity);
440 <  TH1F *hmc    = allsamples.Draw("hmc" , variable,1000,0,30, "#alpha [GeV]", "events", cut,mc,  luminosity);
439 >  TCanvas *cn = new TCanvas("cn","cn");
440 >  string varname="MPF";
441 >  
442 >  bool DoFit=false;
443 >  bool UseFit=false;
444 >  bool DoRooFit=true;
445 >  
446 >  
447 >  if(Contains(variable,"pfJetGood")) varname="R_{abs}";
448 > //  TH1F *hdata  = allsamples.Draw("hdata",variable,1200,0,30, varname, "events",  cut,data,luminosity);
449 > //  TH1F *hmc    = allsamples.Draw("hmc" , variable,1200,0,30, varname, "events", cut, mc,  luminosity);
450 >  TH1F *hdata  = allsamples.Draw("hdata",variable,1200,0.5,1.5, varname, "events",  cut,data,luminosity); // making it more precise
451 >  TH1F *hmc    = allsamples.Draw("hmc" , variable,1200,0.5,1.5, varname, "events", cut, mc,  luminosity); // making it more precise
452 >  hmc->SetLineColor(kBlue);
453    
454    float a=hdata->GetMean();
455    float b=hmc->GetMean();
# Line 225 | Line 457 | Value get_Zb_data_over_mc(string variabl
457    float db=hmc->GetMeanError();
458    float factor = a / b;
459    float error = TMath::Sqrt(  (1/(b*b)) * (da*da) + ((a*a)/(b*b))*db*db);
460 +  
461 +  TF1 *gaus_data = new TF1("gaus_data","gaus",0.7,1.3);
462 +  TF1 *gaus_mc = new TF1("gaus_mc","gaus",0.7,1.3);
463 +  if(DoFit) {
464 +    gaus_data->SetParameter(0,hdata->GetMaximum());
465 +    gaus_data->SetParameter(2,hdata->GetMean());
466 +    gaus_data->SetParameter(1,hdata->GetRMS());
467 +    hdata->Fit(gaus_data);
468 +    
469 +    gaus_mc->SetParameter(0,hmc->GetMaximum());
470 +    gaus_mc->SetParameter(1,hmc->GetMean());
471 +    gaus_mc->SetParameter(2,hmc->GetRMS());
472 +    hmc->Fit(gaus_mc);
473 +  }
474 +    if(DoRooFit) {
475 +    if(hdata->Integral()>10) {
476 +      make_RooFit(ContainerName, hdata, a, da, saveas);
477 +      make_RooFit(ContainerName, hmc, b, db, saveas);
478 +      factor = a / b;
479 +      error = TMath::Sqrt(  (1/(b*b)) * (da*da) + ((a*a)/(b*b))*db*db);
480 +    } else {
481 +      factor=NAN;//set to nan
482 +      error=NAN;//set to nan
483 +    }
484 +  }
485 +
486 +  cn->cd();
487 +  hdata->Rebin(int(0.05*1200/(1.5-0.5)));
488 +  hmc->Rebin(int(0.05*1200/(1.5-0.5)));
489 +  hdata->GetYaxis()->SetTitle("events / 0.05");
490 +  hdata->SetMarkerColor(kRed);
491 +  if(DoFit) {
492 +    gaus_mc->SetLineColor(kBlue);
493 +    gaus_data->SetLineColor(kRed);
494 +  }
495 +  
496 +  hdata->GetXaxis()->SetRangeUser(0,2);
497 +  hdata->GetYaxis()->SetTitleOffset(1.3);
498 +  hdata->Draw("e1");
499 +  
500 +  hmc->Scale(hdata->Integral()/hmc->Integral());
501 +  if(hmc->GetMaximum()>hdata->GetMaximum()) hdata->SetMaximum((hmc->GetMaximum()+sqrt((double)hmc->GetMaximum()))*1.2);
502 +  
503 +  hmc->Draw("histo,same");
504 +  hdata->Draw("e1,same");
505 +  if(DoFit) {
506 +    gaus_data->Draw("same");
507 +    gaus_mc->Draw("same");
508 +  }
509 +  
510 +  stringstream summary;
511 +  summary << "#splitline{#bf{" << varname << "}}{#splitline{" << pt1 << " < p_{T}^{Z} < " << pt2 << ", " << a1 << " #leq #alpha < " << a2 << "}{#splitline{data: " << std::setprecision(4) << a << " #pm " << std::setprecision(4) << da << "}{";
512 +  summary << "#splitline{mc:   " << std::setprecision(4) << b << " #pm " << std::setprecision(4) << db << "}{#splitline{ratio: " << factor;
513 +  summary << " #pm " << error;
514 +  if(DoFit) {
515 +    summary << "}{#splitline{}{#splitline{data fit: " << std::setprecision(4) << gaus_data->GetParameter(1) << "+/-";
516 +    summary << std::setprecision(4) << gaus_data->GetParError(1) << "}{#splitline{";
517 +    summary << "mc fit:" << std::setprecision(4) << gaus_mc->GetParameter(1) << "#pm" << std::setprecision(4) << gaus_mc->GetParError(1) << "}{ratio: ";
518 +    summary << gaus_data->GetParameter(1)/gaus_mc->GetParameter(1) << "#pm" << gaus_data->GetParameter(1)/gaus_mc->GetParameter(1) * sqrt((gaus_data->GetParError(1) * gaus_data->GetParError(1))/(gaus_data->GetParameter(1)*gaus_data->GetParameter(1)) + (gaus_mc->GetParError(1) * gaus_mc->GetParError(1))/(gaus_mc->GetParameter(1)*gaus_mc->GetParameter(1)) ) << "}}}}";
519 +    summary << "}}}}";
520 +  } else {
521 +    summary << "}{}}}}}";
522 +  }
523 +  
524 +  if(UseFit) {
525 +    write_error(__FUNCTION__,"Requested using fit result for final result - not implemented yet!");
526 +    assert(0);
527 +  }
528 +    
529 +  
530 +  TText *infobox = write_title(summary.str());
531 +  infobox->SetX(0.75);
532 +  infobox->SetTextSize(0.03);
533 +  infobox->SetY(0.75);
534 +  infobox->Draw();
535 +    
536 +    
537 +  DrawPrelim();
538 +  CompleteSave(cn,ContainerName+"/ResponsePlots/"+saveas);
539 +  
540 +  res.MPF_Rabs_location.push_back(ZbPointResult(variable,pt1,pt2,a1,a2,Value(a,da),Value(b,db)));
541 +  cout << "Data;" << a << ";"<<da<<";MC;"<<b<<";"<<db<<endl;
542 +  delete cn;
543    delete hdata;
544    delete hmc;
545 +
546    return Value(factor,error);
547   }
548    
549 + int nFakes=1;
550 +
551 + float PurityInclusive=0.05;
552 + float PurityLoose=0.20;
553 + float PurityMedium=0.54;
554 + float PurityTight=0.82;
555 +
556 +
557 + void GetPtPointPosition(float AvPos[], const int nptcuts,string AlphaVariable, TCut basecut, float FaceValueToBeTakenAt, float ptcuts[]) {
558 +  for(int i=0;i<nptcuts-1;i++) {
559 +    stringstream specialcut;
560 +    specialcut << "((pt>30&& pt< 1000) && (" << AlphaVariable << "<" << FaceValueToBeTakenAt << "))";
561 +    TH1F *hdata  = allsamples.Draw("hada", "pt",100,ptcuts[i],ptcuts[i+1], "MPF", "events", TCut(basecut && specialcut.str().c_str()), data,  luminosity);
562 +    AvPos[i]=hdata->GetMean();
563 +    cout << AvPos[i] << " : ";
564 +    delete hdata;
565 +  }
566 +  cout << endl;
567 + }
568 +    
569 +
570 + void DeterminePurity(TCut basecut, int nptcuts, float ptcuts[], string AlphaVariable, string ContainerName, float FaceValueToBeTakenAt) {
571 +  
572 +  bool ComputePurity=false;
573 +  
574 +  if(ContainerName=="inclusive") ComputePurity=true;  
575 +  if(ContainerName=="loose") ComputePurity=true;
576 +  if(ContainerName=="medium") ComputePurity=true;
577 +  if(ContainerName=="reference") ComputePurity=true;
578 +  
579 +  if(!ComputePurity) return;
580 +  
581 +  stringstream specialcut;
582 +  specialcut << "((pt>30&& pt< 1000) && (" << AlphaVariable << "<" << FaceValueToBeTakenAt << "))";
583 +  
584 +  THStack mcm    = allsamples.DrawStack("mcm" , "mpf",1200,0,30, "MPF", "events", TCut(basecut && specialcut.str().c_str()), mc,  luminosity);
585 +  int nhists = mcm.GetHists()->GetEntries();
586 +  
587 +  float total=0;
588 +  float Zb=0;
589 +  
590 +  for (int i = 0; i < nhists; i++) {
591 +    TH1* hist = static_cast<TH1*>(mcm.GetHists()->At(i));
592 +    string name=hist->GetName();
593 +    if(Contains(name,"t_bar_t")) total+=hist->Integral();
594 +    if(Contains(name,"W_Jets")) total+=hist->Integral();
595 +    if(Contains(name,"Single_top")) total+=hist->Integral();
596 +    if(Contains(name,"Dibosons")) total+=hist->Integral();
597 +    if(Contains(name,"Z_l_")) total+=hist->Integral();
598 +    if(Contains(name,"Z_c_")) total+=hist->Integral();
599 +    if(Contains(name,"Z_b_")) {
600 +      total+=hist->Integral();
601 +      Zb+=hist->Integral();
602 +    }
603 +  }
604    
605 +  float purity=Zb/total;
606 +  dout << "Determined a purity of " << 100*purity << " % for the container " << ContainerName << endl;
607 +  
608 +  if(ContainerName=="inclusive") PurityInclusive=purity;
609 +  if(ContainerName=="loose") PurityLoose=purity;
610 +  if(ContainerName=="medium") PurityMedium=purity;
611 +  if(ContainerName=="reference") PurityTight=purity;
612 +  
613 +  DeleteStack(mcm);
614 + }
615  
616 < void new_data_mc_agreement_2d() {
616 > string NiceAlphaPrint(float alpha) {
617 >  //get in : 0.3, return 0p3 ...
618 >  stringstream res;
619 >  res << int(alpha) << "p" << int(100*alpha);
620 >  return res.str();
621 > }
622 >
623 > ZbResultContainer new_data_mc_agreement_2d(bool gofast, string AlphaVariable, string ContainerName, TCut BTagCut, TCut BTagWgt, float FaceValueToBeTakenAt) {
624 >  
625 >  if(gofast) write_info(__FUNCTION__,"Fast mode activated for "+ContainerName);
626 >  ZbResultContainer results(ContainerName);
627 >  
628 >  cutWeight=STDWEIGHT*BTagWgt;
629 >  LeadingB=BTagCut;
630 >  
631 >  
632    gStyle->SetOptFit(0);
633    TCut basecut(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
634 +  const int nalphacuts=6;
635 +  float alphacuts[nalphacuts] = {0.1,0.15,0.2,0.25,0.3,0.35};
636 +  
637    
239  const int nalphacuts=5;
240  float alphacuts[nalphacuts] = {0.1,0.15,0.2,0.25,0.3};
638    const int nptcuts=5;
639 <  float ptcuts[nptcuts]={10,50,100,200,1000};
639 >  float ptcuts[nptcuts]={30,50,75,125,1000};
640 >  float ptPointPosition[nptcuts];
641 >  GetPtPointPosition(ptPointPosition,nptcuts,AlphaVariable,basecut,FaceValueToBeTakenAt,ptcuts);
642 >  
643 >  
644 >  DeterminePurity(basecut, nptcuts,ptcuts, AlphaVariable, ContainerName, FaceValueToBeTakenAt);
645    
646    float MPF_Results[nalphacuts][nptcuts];
647    float MPF_Errors[nalphacuts][nptcuts];
# Line 247 | Line 649 | void new_data_mc_agreement_2d() {
649    float RABS_Errors[nalphacuts][nptcuts];
650    
651    
652 <  for(int ia=0;ia<nalphacuts;ia++) {
652 >  for(int ia=0;ia<nalphacuts && !gofast;ia++) {
653      for(int ipt=0;ipt<nptcuts-1;ipt++) {
654        stringstream specialcut;
655 <      specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (alpha<" << alphacuts[ia] << "))";
656 <      Value MPF_data_over_mc = get_Zb_data_over_mc("mpf",TCut(basecut && specialcut.str().c_str()));
657 <      Value RABS_data_over_mc = get_Zb_data_over_mc("pfJetGoodPt[0]/pt",TCut(basecut && specialcut.str().c_str()));
655 >      float alow,ahigh;
656 >      if(ia>0) {
657 >        specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (" << AlphaVariable << "<" << alphacuts[ia] << " && " << AlphaVariable << ">" << alphacuts[ia-1] << "))";
658 >        alow=alphacuts[ia-1];
659 >        ahigh=alphacuts[ia];
660 >      } else {
661 >        specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (" << AlphaVariable << "<" << alphacuts[ia] << "))";
662 >        alow=0;
663 >        ahigh=alphacuts[ia];
664 >      }
665 >      cout << specialcut.str() << endl;
666 >      Value MPF_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"mpf","",TCut(basecut && specialcut.str().c_str()),"MPF___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(NiceAlphaPrint(alphacuts[ia])), ptcuts[ipt], ptcuts[ipt+1],alow,ahigh);
667 >      Value RABS_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"ZbCHS3010_pfJetGoodPt[0]/pt","",TCut(basecut && specialcut.str().c_str()),"Rabs___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__alpha_"+any2string(NiceAlphaPrint(alphacuts[ia])), ptcuts[ipt], ptcuts[ipt+1],alow,ahigh);
668        
669        MPF_Results[ia][ipt]=MPF_data_over_mc.getValue();
670        MPF_Errors[ia][ipt]=MPF_data_over_mc.getError();
# Line 260 | Line 672 | void new_data_mc_agreement_2d() {
672        RABS_Results[ia][ipt]=RABS_data_over_mc.getValue();
673        RABS_Errors[ia][ipt]=RABS_data_over_mc.getError();
674        
675 <      cout << "alpha cut at " << alphacuts[ia] << " and pt range " << ptcuts[ipt] << " , " << ptcuts[ipt+1] << " \t : \t" << specialcut.str() << " \t \t --> " << MPF_data_over_mc << " (MPF) " << RABS_data_over_mc << " (RABS)" << endl;
675 >      cout << "alpha cut at " << alphacuts[ia+1] << " and pt range " << ptcuts[ipt] << " , " << ptcuts[ipt+1] << " \t : \t" << specialcut.str() << " \t \t --> " << MPF_data_over_mc << " (MPF) " << RABS_data_over_mc << " (RABS)" << endl;
676      }
677    }
678    
# Line 268 | Line 680 | void new_data_mc_agreement_2d() {
680    float RABS_ExtraPolatedResults[nptcuts];
681    
682    TCanvas *can = new TCanvas("can");
683 +  can->cd(1)->SetLeftMargin(0.15);
684    
685    TGraphErrors *MPF_FinalGraph = new TGraphErrors();
686    TGraphErrors *RABS_FinalGraph = new TGraphErrors();
687 +  TGraphErrors *MPF_FaceValueAtPoint3 = new TGraphErrors();
688 +  TGraphErrors *RABS_FaceValueAtPoint3 = new TGraphErrors();
689    
690    for(int ipt=0;ipt<nptcuts-1;ipt++) {
691      
# Line 279 | Line 694 | void new_data_mc_agreement_2d() {
694      cout << "Going to create histo for " << filename.str() << endl;
695      TGraphErrors *mpf_gr =new TGraphErrors();
696      TGraphErrors *rabs_gr =new TGraphErrors();
282    for(int ia=0;ia<nalphacuts;ia++) {
283      mpf_gr->SetPoint(ia,alphacuts[ia],MPF_Results[ia][ipt]);
284      mpf_gr->SetPointError(ia,0,MPF_Errors[ia][ipt]);
285      rabs_gr->SetPoint(ia,alphacuts[ia],RABS_Results[ia][ipt]);
286      rabs_gr->SetPointError(ia,0,RABS_Errors[ia][ipt]);
287    }
288    
289    mpf_gr->SetMarkerStyle(21);
290    mpf_gr->SetMarkerColor(kBlue);
291    mpf_gr->Draw("AP");
292    mpf_gr->Fit("pol1","QE"); // quiet, use minos
293    mpf_gr->GetXaxis()->SetTitle("#alpha");
294    mpf_gr->GetXaxis()->CenterTitle();
295    mpf_gr->GetYaxis()->SetTitle("data/mc");
296    mpf_gr->GetYaxis()->CenterTitle();
297    TF1 *mpf_pol=(TF1*)mpf_gr->GetFunction("pol1");
298    float mpf_a=mpf_pol->GetParameter(0);
299    float mpf_b=mpf_pol->GetParameter(1);
300    MPF_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),mpf_a);
301    MPF_FinalGraph->SetPointError(ipt,0,mpf_pol->GetParError(0));
302    
303    MPF_ExtraPolatedResults[ipt]=mpf_a;
304    
305    stringstream mpf_info;
306    mpf_info <<  "#splitline{#splitline{#splitline{" << ptcuts[ipt] << " GeV < p_{T}^{Z} < " << ptcuts[ipt+1] << " GeV }{ (MPF) }}{Extrapolated value: " << std::setprecision(3) << mpf_a << "}}{#chi^{2}/NDF : " << mpf_pol->GetChisquare() << " / " << mpf_pol->GetNDF() << "}";
307    
308    TText *mpf_mark = write_title(mpf_info.str());
309    mpf_mark->SetX(0.75);
310    mpf_mark->SetTextSize(0.03);
311    mpf_mark->SetY(0.75);
312    mpf_mark->Draw();
697      
698 <    string filenamebkp=filename.str();
699 <    filename << "__MPF";
316 <    DrawPrelim();
317 <    CompleteSave(can,filename.str());
318 <    cout << "MPF : " << mpf_a << " + " << mpf_b << " * alpha " << endl;
698 >    int rabs_counter=0;
699 >    int mpf_counter=0;
700      
701 <    filename.str("");
701 >    for(int ia=0;ia<nalphacuts && !gofast;ia++) {
702 >      cout << "Setting a point for an alpha cut at " << alphacuts[ia] << " with value " << MPF_Results[ia][ipt] << " (MPF) and " << RABS_Results[ia][ipt] << " (RABS)" << endl;
703 >      if(MPF_Results[ia][ipt]==MPF_Results[ia][ipt] && MPF_Errors[ia][ipt]==MPF_Errors[ia][ipt]) { // remove nan's
704 >       mpf_gr->SetPoint(mpf_counter,alphacuts[ia],MPF_Results[ia][ipt]);
705 >       mpf_gr->SetPointError(mpf_counter,0,MPF_Errors[ia][ipt]);
706 >       mpf_counter++;
707 >      } else {
708 >        dout << "Detected BS for MPF method (bin ignored) : " << endl;
709 >        dout << "       alpha: " << alphacuts[ia] << " , pt range: " << ptcuts[ipt] << " < pt < " << ptcuts[ipt+1] << endl;
710 >        cout << "       value (MPF) : " << MPF_Results[ia][ipt] << " +/- " << MPF_Errors[ia][ipt] << endl;
711 >      }
712 >      if(RABS_Results[ia][ipt]==RABS_Results[ia][ipt] && RABS_Errors[ia][ipt]==RABS_Errors[ia][ipt]) {
713 >       rabs_gr->SetPoint(rabs_counter,alphacuts[ia],RABS_Results[ia][ipt]);
714 >       rabs_gr->SetPointError(rabs_counter,0,RABS_Errors[ia][ipt]);
715 >       rabs_counter++;
716 >      } else {
717 >        dout << "Detected BS for RABS method (bin ignored) : " << endl;
718 >        dout << "       alpha: " << alphacuts[ia] << " , pt range: " << ptcuts[ipt] << " < pt < " << ptcuts[ipt+1] << endl;
719 >        cout << "       value (RABS) : " << RABS_Results[ia][ipt] << " +/- " << RABS_Errors[ia][ipt] << endl;
720 >      }
721 >    }
722      
723 <    rabs_gr->SetMarkerStyle(21);
724 <    rabs_gr->SetMarkerColor(kBlue);
725 <    rabs_gr->Fit("pol1","QE"); // quiet, use minos
726 <    rabs_gr->Draw("AP");
727 <    rabs_gr->GetXaxis()->SetTitle("#alpha");
728 <    rabs_gr->GetXaxis()->CenterTitle();
729 <    rabs_gr->GetYaxis()->SetTitle("data/mc");
730 <    rabs_gr->GetYaxis()->CenterTitle();
723 >    stringstream specialcut;
724 >    specialcut << "((pt>" << ptcuts[ipt] << " && pt< " << ptcuts[ipt+1] << ") && (" << AlphaVariable << "<" << FaceValueToBeTakenAt << "))";
725 >    Value MPF_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"mpf","",TCut(basecut && specialcut.str().c_str()),"MPF___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__INCLUSIVEalpha_"+any2string(FaceValueToBeTakenAt),ptcuts[ipt],ptcuts[ipt+1],0,FaceValueToBeTakenAt);
726 >    Value RABS_data_over_mc = get_Zb_data_over_mc(ContainerName,results,"ZbCHS3010_pfJetGoodPt[0]/pt","",TCut(basecut && specialcut.str().c_str()),"Rabs___pt_"+any2string(ptcuts[ipt])+"_"+any2string(ptcuts[ipt+1])+"__INCLUSIVEalpha_"+any2string(FaceValueToBeTakenAt),ptcuts[ipt],ptcuts[ipt+1],0,FaceValueToBeTakenAt);
727 >    cout << "About to add a point in pt (" << (ptcuts[ipt]+ptcuts[ipt+1])/2 << " ) to face value : " << MPF_data_over_mc << " (MPF) , " <<  RABS_data_over_mc << "(RABS)" << endl;
728 >    MPF_FaceValueAtPoint3->SetPoint(ipt,(ptcuts[ipt]+ptcuts[ipt+1])/2,MPF_data_over_mc.getValue());
729 >    MPF_FaceValueAtPoint3->SetPointError(ipt,0,MPF_data_over_mc.getError());
730 >    RABS_FaceValueAtPoint3->SetPoint(ipt,(ptcuts[ipt]+ptcuts[ipt+1])/2,RABS_data_over_mc.getValue());
731 >    RABS_FaceValueAtPoint3->SetPointError(ipt,0,RABS_data_over_mc.getError());
732      
331    TF1 *rabs_pol=(TF1*)rabs_gr->GetFunction("pol1");
332    float rabs_a=rabs_pol->GetParameter(0);
333    float rabs_b=rabs_pol->GetParameter(1);
334    RABS_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),rabs_a);
335    RABS_FinalGraph->SetPointError(ipt,0,rabs_pol->GetParError(0));
733      
337    cout << "!+!+!+!+!+!+!+!+!+ Just added a point to the final plot : " << rabs_a << " +/- " << rabs_pol->GetParError(0) << endl;
734      
735 +    if(!gofast) {
736 +      can->cd();
737 +      mpf_gr->SetMarkerStyle(21);
738 +      mpf_gr->SetMarkerColor(kBlue);
739 +      mpf_gr->Draw("AP");
740 +      mpf_gr->Fit("pol1","");
741 +      mpf_gr->GetXaxis()->SetTitle("#alpha");
742 +      mpf_gr->GetXaxis()->CenterTitle();
743 +      mpf_gr->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
744 +      mpf_gr->GetYaxis()->CenterTitle();
745 +      TF1 *mpf_pol=(TF1*)mpf_gr->GetFunction("pol1");
746 +      mpf_pol->SetLineWidth(0);
747 +      TF1 *mpf_pol_complete = new TF1("mpf_pol_complete","[0]+[1]*x");
748 +      mpf_pol_complete->SetParameters(mpf_pol->GetParameters());
749 +      mpf_pol_complete->SetLineWidth(1);
750 +      mpf_pol_complete->SetLineColor(kBlue);
751 +      
752 +      float min,max;
753 +      FindMinMax(mpf_gr,min,max);
754 +      TH1F *histo = new TH1F("histo","histo",1,0,0.4);
755 +      histo->GetXaxis()->SetTitle("#alpha");
756 +      histo->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
757 +      histo->GetXaxis()->CenterTitle();
758 +      histo->GetYaxis()->CenterTitle();
759 +      histo->GetYaxis()->SetTitleOffset(1.3);
760 +      histo->SetStats(0);
761 +      histo->GetXaxis()->SetRangeUser(0,0.4);
762 +      histo->GetYaxis()->SetRangeUser(min,max);
763 +      mpf_gr->GetYaxis()->SetRangeUser(min,max);
764 +      
765 +      TPolyLine *mpf_fit_uncert = GetFitUncertaintyShape(mpf_gr, "pol1", min, max,0.0,0.4);
766 +      mpf_pol->SetLineColor(TColor::GetColor("#0101DF"));
767 +      mpf_fit_uncert->SetFillColor(TColor::GetColor("#5353FC"));
768 +      histo->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
769 +      histo->Draw();
770 +      mpf_fit_uncert->Draw("F");
771 +      mpf_fit_uncert->Draw("");
772 +      mpf_gr->Draw("P");
773 +      mpf_pol_complete->Draw("same");
774 +      
775 +      float mpf_a=mpf_pol->GetParameter(0);
776 +      float mpf_b=mpf_pol->GetParameter(1);
777 +      MPF_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),mpf_a);
778 +      MPF_FinalGraph->SetPointError(ipt,0,mpf_pol->GetParError(0));
779 +      
780 +      MPF_ExtraPolatedResults[ipt]=mpf_a;
781 +      
782 +      stringstream mpf_info;
783 +      mpf_info <<  "#splitline{#splitline{#splitline{" << ptcuts[ipt] << " GeV < p_{T}^{Z} < " << ptcuts[ipt+1] << " GeV }{ (MPF) }}{Extrapolated value: " << std::setprecision(4) << mpf_a << "}}{#chi^{2}/NDF : " << mpf_pol->GetChisquare() << " / " << mpf_pol->GetNDF() << "}";
784 +      
785 +      TText *mpf_mark = write_title(mpf_info.str());
786 +      mpf_mark->SetX(0.75);
787 +      mpf_mark->SetTextSize(0.03);
788 +      mpf_mark->SetY(0.75);
789 +      mpf_mark->Draw();
790 +      
791 +      string filenamebkp=filename.str();
792 +      filename << "__MPF";
793 +      DrawPrelim();
794 +      CompleteSave(can,ContainerName+"/"+filename.str());
795 +      cout << "MPF : " << mpf_a << " + " << mpf_b << " * alpha " << endl;
796 +      
797 +      filename.str("");
798 +      
799 +      rabs_gr->SetMarkerStyle(21);
800 +      rabs_gr->SetMarkerColor(kRed);
801 +      rabs_gr->Draw("AP");
802 +      rabs_gr->Fit("pol1","");
803 +      rabs_gr->GetXaxis()->SetTitle("#alpha");
804 +      rabs_gr->GetXaxis()->CenterTitle();
805 +      rabs_gr->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
806 +      rabs_gr->GetYaxis()->CenterTitle();
807 +      TF1 *rabs_pol=(TF1*)rabs_gr->GetFunction("pol1");
808 +      rabs_pol->SetLineWidth(0);
809 +      TF1 *rabs_pol_complete = new TF1("rabs_pol_complete","[0]+[1]*x");
810 +      rabs_pol_complete->SetParameters(rabs_pol->GetParameters());
811 +      rabs_pol_complete->SetLineColor(kRed);
812 +      rabs_pol_complete->SetLineWidth(1);
813 +      FindMinMax(rabs_gr,min,max);
814 +      rabs_gr->GetYaxis()->SetRangeUser(min,max);
815 +      histo->GetYaxis()->SetRangeUser(min,max);
816 +      TPolyLine *rabs_fit_uncert = GetFitUncertaintyShape(rabs_gr, "pol1", min, max,0.0,0.4);
817 +      rabs_pol->SetLineColor(TColor::GetColor("#FA5858"));
818 +      rabs_pol->SetFillColor(TColor::GetColor("#FA5858"));
819 +      rabs_fit_uncert->SetLineColor(TColor::GetColor("#FA5858"));
820 +      rabs_fit_uncert->SetFillColor(TColor::GetColor("#FA5858"));
821 +      histo->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
822 +      histo->Draw();
823 +      rabs_fit_uncert->Draw("F");
824 +      rabs_fit_uncert->Draw("");
825 +      rabs_gr->Draw("P");
826 +      rabs_pol_complete->Draw("same");
827 +      
828 +      float rabs_a=rabs_pol->GetParameter(0);
829 +      float rabs_b=rabs_pol->GetParameter(1);
830 +      RABS_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),rabs_a);
831 +      RABS_FinalGraph->SetPointError(ipt,0,rabs_pol->GetParError(0));
832 +      
833 +      cout << "!+!+!+!+!+!+!+!+!+ Just added a point to the final plot : " << rabs_a << " +/- " << rabs_pol->GetParError(0) << endl;
834 +      
835 +      stringstream rabs_info;
836 +      rabs_info << "#splitline{#splitline{#splitline{" << ptcuts[ipt] << " GeV < p_{T}^{Z} < " << ptcuts[ipt+1] << " GeV }{ (R_{abs}) }}{Extrapolated value: " << std::setprecision(4) << rabs_a << "}}{#chi^{2}/NDF : " << rabs_pol->GetChisquare() << " / " << rabs_pol->GetNDF() << "}";
837 +      TText *rabs_mark = write_title(rabs_info.str());
838 +      rabs_mark->SetX(0.75);
839 +      rabs_mark->SetTextSize(0.03);
840 +      rabs_mark->SetY(0.75);
841 +      rabs_mark->Draw();
842 +      
843 +      RABS_ExtraPolatedResults[ipt]=rabs_a;
844 +      filename << filenamebkp << "__RABS";
845 +      DrawPrelim();
846 +      CompleteSave(can,ContainerName+"/"+filename.str());
847 +      cout << "RABS : " << rabs_a << " + " << rabs_b << " * alpha " << endl;
848 +    }
849 +  }
850 +  
851 +  float MPFResult;
852 +  float MPFResultError;
853 +  
854 +  float RabsResult;
855 +  float RabsResultError;
856 +
857 +  if(!gofast) {
858 +    MPF_FinalGraph->SetMarkerStyle(21);
859 +    MPF_FinalGraph->SetMarkerColor(kBlue);
860 +    MPF_FinalGraph->Fit("pol0",""); // quiet, use minos
861 +    
862 +    TF1 *mpf_pol0=(TF1*)MPF_FinalGraph->GetFunction("pol0");
863 +    TF1 *mpf_pol0_complete = new TF1("mpf_pol0_complete","[0]+[1]*x");
864 +    mpf_pol0_complete->SetLineWidth(1);
865 +    mpf_pol0_complete->SetLineColor(kBlue);
866 +    mpf_pol0->SetLineColor(kBlue);
867 +    MPF_FinalGraph->Draw("AP");
868 +    MPF_FinalGraph->GetXaxis()->SetTitle("p_{T}^{Z}");
869 +    MPF_FinalGraph->GetXaxis()->CenterTitle();
870 +    MPF_FinalGraph->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
871 +    MPF_FinalGraph->GetYaxis()->CenterTitle();
872 +    MPF_FinalGraph->Draw("AP");
873 +    mpf_pol0_complete->Draw("same");
874      
875 <    stringstream rabs_info;
876 <    rabs_info << "#splitline{#splitline{#splitline{" << ptcuts[ipt] << " GeV < p_{T}^{Z} < " << ptcuts[ipt+1] << " GeV }{ (R_{abs}) }}{Extrapolated value: " << std::setprecision(3) << rabs_a << "}}{#chi^{2}/NDF : " << rabs_pol->GetChisquare() << " / " << rabs_pol->GetNDF() << "}";
877 <    TText *rabs_mark = write_title(rabs_info.str());
878 <    rabs_mark->SetX(0.75);
879 <    rabs_mark->SetTextSize(0.03);
880 <    rabs_mark->SetY(0.75);
881 <    rabs_mark->Draw();
875 >    stringstream mpf_result;
876 >    mpf_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/mpf_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << mpf_pol0->GetParError(0)/(mpf_pol0->GetParameter(0)*mpf_pol0->GetParameter(0)) << "}{ (MPF)}";
877 >    TText *rmpf_final_mark = write_title(mpf_result.str());
878 >    rmpf_final_mark->SetX(0.75);
879 >    rmpf_final_mark->SetY(0.75);
880 >    rmpf_final_mark->SetTextSize(0.03);
881 >    rmpf_final_mark->Draw();
882 >    DrawPrelim();
883 >    MPFResult=1/mpf_pol0->GetParameter(0);
884 >    MPFResultError=mpf_pol0->GetParError(0)/(mpf_pol0->GetParameter(0)*mpf_pol0->GetParameter(0));
885      
886 +    stringstream filename2;
887 +    filename2 << "Extrapolation/FINAL_RESULT_MPF";
888 +    CompleteSave(can,ContainerName+"/"+filename2.str());
889      
890 <
891 <    RABS_ExtraPolatedResults[ipt]=rabs_a;
892 <    filename << filenamebkp << "__RABS";
890 >    RABS_FinalGraph->SetMarkerStyle(21);
891 >    RABS_FinalGraph->SetMarkerStyle(21);
892 >    RABS_FinalGraph->SetMarkerColor(kRed);
893 >    RABS_FinalGraph->Fit("pol0","QE"); // quiet, use minos
894 >    RABS_FinalGraph->Draw("AP");
895 >    RABS_FinalGraph->GetXaxis()->SetTitle("p_{T}^{Z}");
896 >    RABS_FinalGraph->GetXaxis()->CenterTitle();
897 >    RABS_FinalGraph->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
898 >    RABS_FinalGraph->GetYaxis()->CenterTitle();
899 >    RABS_FinalGraph->Draw("AP");
900 >    TF1 *rabs_pol0=(TF1*)RABS_FinalGraph->GetFunction("pol0");
901 >    stringstream rabs_result;
902 >    rabs_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/rabs_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << rabs_pol0->GetParError(0)/(rabs_pol0->GetParameter(0)*rabs_pol0->GetParameter(0)) << "}{ (R_{abs})}";;
903 >    TText *rabs_final_mark = write_title(rabs_result.str());
904 >    rabs_final_mark->SetX(0.75);
905 >    rabs_final_mark->SetY(0.75);
906 >    rabs_final_mark->SetTextSize(0.03);
907 >    rabs_final_mark->Draw();
908      DrawPrelim();
909 <    CompleteSave(can,filename.str());
910 <    cout << "RABS : " << rabs_a << " + " << rabs_b << " * alpha " << endl;
909 >    
910 >    RabsResult=1/rabs_pol0->GetParameter(0);
911 >    RabsResultError=rabs_pol0->GetParError(0)/(rabs_pol0->GetParameter(0)*rabs_pol0->GetParameter(0));
912 >    
913 >    filename2.str("");
914 >    filename2 << "Extrapolation/FINAL_RESULT_RABS";
915 >    CompleteSave(can,ContainerName+"/"+filename2.str());
916    }
917 <  
918 <  MPF_FinalGraph->SetMarkerStyle(21);
919 <  MPF_FinalGraph->SetMarkerColor(kRed);
920 <  MPF_FinalGraph->Fit("pol0","QE"); // quiet, use minos
921 <  
922 <  TF1 *mpf_pol0=(TF1*)MPF_FinalGraph->GetFunction("pol0");
923 <  MPF_FinalGraph->Draw("AP");
924 <  MPF_FinalGraph->GetXaxis()->SetTitle("p_{T}^{Z}");
925 <  MPF_FinalGraph->GetXaxis()->CenterTitle();
926 <  MPF_FinalGraph->GetYaxis()->SetTitle("data/mc");
927 <  MPF_FinalGraph->GetYaxis()->CenterTitle();
928 <  MPF_FinalGraph->Draw("AP");
929 <  
930 <  stringstream mpf_result;
931 <  mpf_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/mpf_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << mpf_pol0->GetParError(0)/(mpf_pol0->GetParameter(0)*mpf_pol0->GetParameter(0)) << "}{ (MPF)}";
932 <  TText *rmpf_final_mark = write_title(mpf_result.str());
933 <  rmpf_final_mark->SetX(0.75);
934 <  rmpf_final_mark->SetY(0.75);
935 <  rmpf_final_mark->SetTextSize(0.03);
936 <  rmpf_final_mark->Draw();
917 >
918 >  can->cd();
919 >  MPF_FaceValueAtPoint3->SetMarkerStyle(21);
920 >  MPF_FaceValueAtPoint3->SetMarkerColor(kBlue);
921 >  MPF_FaceValueAtPoint3->Fit("pol0","QE"); // quiet, use minos
922 >  MPF_FaceValueAtPoint3->Draw("AP");
923 >  MPF_FaceValueAtPoint3->GetXaxis()->SetTitle("p_{T}^{Z}");
924 >  MPF_FaceValueAtPoint3->GetXaxis()->CenterTitle();
925 >  MPF_FaceValueAtPoint3->GetYaxis()->SetTitle(((string)"<MPF>__{data}/<MPF>_{mc} for #alpha<"+any2string(FaceValueToBeTakenAt)).c_str());
926 >  MPF_FaceValueAtPoint3->GetYaxis()->CenterTitle();
927 >  MPF_FaceValueAtPoint3->Draw("AP");
928 >  TF1 *faceval_pol0=(TF1*)MPF_FaceValueAtPoint3->GetFunction("pol0");
929 >  faceval_pol0->SetLineColor(kBlue);
930 >  faceval_pol0->SetLineWidth(1);
931 >  faceval_pol0->Draw("same");
932 >  TF1 *faceval_pol0_complete = new TF1("faceval_pol0_complete","[0]+[1]*x");
933 >  faceval_pol0_complete->SetParameters(faceval_pol0->GetParameters());
934 >  stringstream faceval_result;
935 >  faceval_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/faceval_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << faceval_pol0->GetParError(0)/(faceval_pol0->GetParameter(0)*faceval_pol0->GetParameter(0)) << "}{ (MPF at #alpha<" << FaceValueToBeTakenAt << ")}";;
936 >  TText *faceval_final_mark = write_title(faceval_result.str());
937 >  faceval_final_mark->SetX(0.75);
938 >  faceval_final_mark->SetY(0.75);
939 >  faceval_final_mark->SetTextSize(0.03);
940 >  faceval_final_mark->Draw();
941    DrawPrelim();
942    
943 <  stringstream filename2;
944 <  filename2 << "Extrapolation/FINAL_RESULT_MPF";
380 <  CompleteSave(can,filename2.str());
943 >  float FaceValResult=1/faceval_pol0->GetParameter(0);
944 >  float FaceValResultError=faceval_pol0->GetParError(0)/(faceval_pol0->GetParameter(0)*faceval_pol0->GetParameter(0));
945    
946 +  stringstream filename2;
947 +  filename2.str("");
948 +  filename2 << "Extrapolation/FINAL_RESULT_MPF_FaceValp3";
949 +  CompleteSave(can,ContainerName+"/"+filename2.str());
950    
951 <  RABS_FinalGraph->SetMarkerStyle(21);
952 <  RABS_FinalGraph->SetMarkerStyle(21);
953 <  RABS_FinalGraph->SetMarkerColor(kRed);
954 <  RABS_FinalGraph->Fit("pol0","QE"); // quiet, use minos
955 <  RABS_FinalGraph->Draw("AP");
956 <  RABS_FinalGraph->GetXaxis()->SetTitle("p_{T}^{Z}");
957 <  RABS_FinalGraph->GetXaxis()->CenterTitle();
958 <  RABS_FinalGraph->GetYaxis()->SetTitle("data/mc");
959 <  RABS_FinalGraph->GetYaxis()->CenterTitle();
960 <  RABS_FinalGraph->Draw("AP");
961 <  TF1 *rabs_pol0=(TF1*)RABS_FinalGraph->GetFunction("pol0");
962 <  stringstream rabs_result;
963 <  rabs_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/rabs_pol0->GetParameter(0) << " #pm " << std::setprecision(2) << rabs_pol0->GetParError(0)/(rabs_pol0->GetParameter(0)*rabs_pol0->GetParameter(0)) << "}{ (R_{abs})}";;
964 <  TText *rabs_final_mark = write_title(rabs_result.str());
965 <  rabs_final_mark->SetX(0.75);
966 <  rabs_final_mark->SetY(0.75);
967 <  rabs_final_mark->SetTextSize(0.03);
968 <  rabs_final_mark->Draw();
951 >  can->cd();
952 >  RABS_FaceValueAtPoint3->SetMarkerStyle(21);
953 >  RABS_FaceValueAtPoint3->SetMarkerColor(kRed);
954 >  RABS_FaceValueAtPoint3->Fit("pol0","QE"); // quiet, use minos
955 >  RABS_FaceValueAtPoint3->Draw("AP");
956 >  RABS_FaceValueAtPoint3->GetXaxis()->SetTitle("p_{T}^{Z}");
957 >  RABS_FaceValueAtPoint3->GetXaxis()->CenterTitle();
958 >  RABS_FaceValueAtPoint3->GetYaxis()->SetTitle(((string)"<R_{abs}>_{data}/<R_{abs}>_{mc} for #alpha<"+any2string(FaceValueToBeTakenAt)).c_str());
959 >  RABS_FaceValueAtPoint3->GetYaxis()->CenterTitle();
960 >  RABS_FaceValueAtPoint3->Draw("AP");
961 >  TF1 *faceval_pol0RABS=(TF1*)RABS_FaceValueAtPoint3->GetFunction("pol0");
962 >  TF1 *faceval_pol0RABS_complete = new TF1("faceval_pol0_complete","[0]+[1]*x");
963 >  faceval_pol0RABS_complete->SetParameters(faceval_pol0RABS->GetParameters());
964 >  faceval_pol0RABS->SetLineWidth(1);
965 >  faceval_pol0RABS->SetLineColor(kRed);
966 >  faceval_pol0RABS_complete->Draw("same");
967 >  stringstream RABSfaceval_result;
968 >  RABSfaceval_result << "#splitline{C_{abs}= " << std::setprecision(5) << 1/faceval_pol0RABS->GetParameter(0) << " #pm " << std::setprecision(2) << faceval_pol0RABS->GetParError(0)/(faceval_pol0RABS->GetParameter(0)*faceval_pol0RABS->GetParameter(0)) << "}{ (R_{abs} at #alpha<" << FaceValueToBeTakenAt << ")}";;
969 >  TText *RABSfaceval_final_mark = write_title(RABSfaceval_result.str());
970 >  RABSfaceval_final_mark->SetX(0.75);
971 >  RABSfaceval_final_mark->SetY(0.75);
972 >  RABSfaceval_final_mark->SetTextSize(0.03);
973 >  RABSfaceval_final_mark->Draw();
974    DrawPrelim();
975    
976 +  float RABSFaceValResult=1/faceval_pol0RABS->GetParameter(0);
977 +  float RABSFaceValResultError=faceval_pol0RABS->GetParError(0)/(faceval_pol0RABS->GetParameter(0)*faceval_pol0RABS->GetParameter(0));
978 +  
979    filename2.str("");
980 <  filename2 << "Extrapolation/FINAL_RESULT_RABS";
981 <  CompleteSave(can,filename2.str());
980 >  filename2 << "Extrapolation/FINAL_RESULT_RABS_FaceValp3";
981 >  CompleteSave(can,ContainerName+"/"+filename2.str());
982 >  
983 >  cout << "FINAL RESULTS: " << endl;
984 >  if(!gofast) cout << "MPF : " << MPFResult  << " +/- " << MPFResultError  << endl;
985 >  if(!gofast) cout << "Rabs: " << RabsResult << " +/- " << RabsResultError << endl;
986 >  cout << "Face value at " << FaceValueToBeTakenAt << " :" << FaceValResult << " +/- " << FaceValResultError << "  (MPF) " << endl;
987 >  cout << "Face value at " << FaceValueToBeTakenAt << " :" << RABSFaceValResult << " +/- " << RABSFaceValResultError << "  (RABS) " << endl;
988 >  
989 >  delete can;
990 >  
991 >  results.MPF_Result_FaceValue=Value(FaceValResult,FaceValResultError);
992 >  results.Rabs_Result_FaceValue=Value(RABSFaceValResult,RABSFaceValResultError);
993 >  if(!gofast) results.MPF_Result_Extrapolated=Value(MPFResult,MPFResultError);
994 >  if(!gofast) results.Rabs_Result_Extrapolated=Value(RabsResult,RabsResultError);
995 >  cout << results << endl;
996 >  return results;
997 > }
998 >
999 >
1000 > void DoPUStudy(string identifier) {
1001 >  
1002 >  float numVtxcuts[7]={0,10,15,20};
1003 >  
1004 >  TCanvas *can = new TCanvas("can","can");
1005 >  TH1F *malpha[8];
1006 >  TH1F *dalpha[8];
1007 >  cout << identifier << ";";
1008 >  cout << endl;
1009 >  for(int i=1;i<5;i++) {
1010 >    stringstream sSpecialCut;
1011 >    if(i<4) {
1012 >      sSpecialCut << "numVtx>" << numVtxcuts[i-1] << " && numVtx<" << numVtxcuts[i];
1013 >      cout << numVtxcuts[i-1] << "  < nVtx < " << numVtxcuts[i] << ";";
1014 >    } else {
1015 >      sSpecialCut << "numVtx>" << numVtxcuts[i-1];
1016 >      cout << numVtxcuts[i-1] << ";";
1017 >    }
1018 >    
1019 >    sSpecialCut << " && " << identifier << "_alpha<0.3";
1020 >    TCut SpecialCut(sSpecialCut.str().c_str());
1021 >    
1022 >    
1023 >    malpha[i] = allsamples.Draw("malpha"+any2string(i),"mpf",1000,0,2,"MPF","events",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&SpecialCut,mc,luminosity);
1024 >    dalpha[i] = allsamples.Draw("dalpha"+any2string(i),"mpf",1000,0,2,"MPF","events",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&SpecialCut,data,luminosity);
1025 >    
1026 >    
1027 >    float a=dalpha[i]->GetMean();
1028 >    float b=malpha[i]->GetMean();
1029 >    float da=dalpha[i]->GetMeanError();
1030 >    float db=malpha[i]->GetMeanError();
1031 >    float factor = a / b;
1032 >    float error = TMath::Sqrt(  (1/(b*b)) * (da*da) + ((a*a)/(b*b))*db*db);
1033 >  
1034 >    cout << malpha[i]->GetMean() << ";" << malpha[i]->GetMeanError() << ";" << dalpha[i]->GetMean() << ";" << dalpha[i]->GetMeanError() << ";" << malpha[i]->Integral()<<";"<<dalpha[i]->Integral() << ";"<<factor << ";" << error <<  endl;
1035 >    delete malpha[i];
1036 >    delete dalpha[i];
1037 >  }
1038 >  
1039 >  delete can;
1040 >  
1041 > }
1042 >
1043 > void ScenarioComparison() {
1044 > //very dumb way to do this.
1045 >
1046 >  TGraphAsymmErrors *gr[5];
1047 >  TF1 *fit[5];
1048 >  bool dofit=true;
1049 >  
1050 >  TCanvas *can = new TCanvas("can","can",500,500);
1051 >  
1052 >  TLegend *leg = new TLegend(0.2,0.2,0.5,0.45);
1053 >  leg->SetBorderSize(0);
1054 >  leg->SetFillColor(kWhite);
1055 >  
1056 >  for(int i=0;i<6;i++) {
1057 >    gr[i] = new TGraphAsymmErrors();
1058 >    double x[4]   = {5,12.5,17.5,25};
1059 >    double dxl[4] = {5,2.5,2.5,5};
1060 >    double dxh[4] = {5,2.5,2.5,10};
1061 >    
1062 >    string name="";
1063 >    string color="";
1064 >    
1065 >    if(i==0) {
1066 >      double y[4]   = {1.01935,1.01558,0.996438,1.01901};
1067 >      double dyl[4] = {0.0132973,0.0131661,0.017629,0.0319767};
1068 >      double dyh[4] = {0.0132973,0.0131661,0.017629,0.0319767};
1069 >      name="30/30";
1070 >      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1071 >      color="#a01d99";
1072 >    }
1073 >    if(i==1) {
1074 >      double y[4]   = {1.00577,1.00706,0.991029,0.954098};
1075 >      double dyl[4] = {0.0135575,0.0136548,0.0170778,0.0263919};
1076 >      double dyh[4] = {0.0135575,0.0136548,0.0170778,0.0263919};
1077 >      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1078 >      name="30/15";
1079 >      color="#2464bc";
1080 >    }
1081 >    if(i==2) {
1082 >      double y[4]   = {1.023,1.00648,1.02217,1.03181};
1083 >      double dyl[4] = {0.0157372,0.0187778,0.0261512,0.0422295};
1084 >      double dyh[4] = {0.0157372,0.0187778,0.0261512,0.0422295};
1085 >      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1086 >      name="15/15";
1087 >      color="#f49230";
1088 >    }
1089 >    if(i==3) {
1090 >      double y[4]   = {1.02029,1.01338,0.999769,1.00357};
1091 >      double dyl[4] = {0.0129509,0.0120127,0.0160537,0.0268972};
1092 >      double dyh[4] = {0.0129509,0.0120127,0.0160537,0.0268972};
1093 >      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1094 >      name="CHS 30/30";
1095 >      color="#c72f3c";
1096 >    }
1097 >    if(i==4) {
1098 >      double y[4]   = {1.00274,1.01056,0.993214,0.997963};
1099 >      double dyl[4] = {0.0127179,0.0140344,0.0162814,0.0278914};
1100 >      double dyh[4] = {0.0127179,0.0140344,0.0162814,0.0278914};
1101 >      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1102 >      name="CHS 30/15";
1103 >      color="#7cb433";
1104 >    }
1105 >    if(i==5) {
1106 >      double y[4]   = {1.04103,1.03726,1.04649,1.05383};
1107 >      double dyl[4] = {0.0156465,0.0168194,0.0231982,0.0376114};
1108 >      double dyh[4] = {0.0156465,0.0168194,0.0231982,0.0376114};
1109 >      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1110 >      name="CHS 15/15";
1111 >      color="#DF013A";
1112 >    }
1113 >    
1114 >    
1115 >    gStyle->SetOptFit(0);
1116 >    gr[i]->SetTitle();
1117 >    gr[i]->GetXaxis()->SetTitle("N(Vtx)");
1118 >    gr[i]->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
1119 >    gr[i]->GetXaxis()->CenterTitle();
1120 >    gr[i]->GetYaxis()->CenterTitle();
1121 >    gr[i]->SetName(name.c_str());
1122 >    gr[i]->SetMarkerSize(0.00001);
1123 >    gr[i]->GetYaxis()->SetRangeUser(0.90,1.10);
1124 >    gr[i]->SetLineColor(TColor::GetColor(color.c_str()));
1125 >    gr[i]->SetMarkerColor(TColor::GetColor(color.c_str()));
1126 >    if(dofit) {
1127 >      gr[i]->Fit("pol1");
1128 >      fit[i] = (TF1*)gr[i]->GetFunction("pol1");
1129 >      fit[i]->SetLineColor(TColor::GetColor(color.c_str()));
1130 >    }
1131 >    leg->AddEntry(gr[i],name.c_str(),"l");
1132 >    if(i==0) gr[i]->Draw("AP*");
1133 >    else gr[i]->Draw("P");
1134 >  }
1135 >  leg->Draw();
1136 >  DrawPrelim();
1137 >  
1138 >  CompleteSave(can,"ScenarioComparison");
1139 >  delete can;
1140    
1141 + }
1142 +
1143 + void ScenarioComparisonInclusive() {
1144 +  //dumbest way ever to do this. but ok we only need to do it once.
1145 +  TGraphAsymmErrors *gr[5];
1146 +  TF1 *fit[5];
1147 +  bool dofit=true;
1148 +  
1149 +  TCanvas *can = new TCanvas("can","can",500,500);
1150 +  
1151 +  TLegend *leg = new TLegend(0.2,0.2,0.65,0.45);
1152 +  leg->SetBorderSize(0);
1153 +  leg->SetFillColor(kWhite);
1154 +  
1155 +  for(int i=0;i<6;i++) {
1156 +    gr[i] = new TGraphAsymmErrors();
1157 +    double x[4]   = {5,12.5,17.5,25};
1158 +    double dxl[4] = {5,2.5,2.5,5};
1159 +    double dxh[4] = {5,2.5,2.5,5};
1160 +    
1161 +    string name="";
1162 +    string color="";
1163 +    
1164 +    if(i==0) {
1165 +      double y[4]   = {1.01093,1.01379,1.0147,1.02766};
1166 +      double dyl[4] = {0.00243596,0.00242534,0.00341941,0.00600663};
1167 +      double dyh[4] = {0.00243596,0.00242534,0.00341941,0.00600663};
1168 +      name="30/30";
1169 +      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1170 +      color="#a01d99";
1171 +    }
1172 +    if(i==1) {
1173 +      double y[4]   = {1.0068,1.00779,0.999692,0.994484};
1174 +      double dyl[4] = {0.00249233,0.00257169,0.00371399,0.00631138};
1175 +      double dyh[4] = {0.00249233,0.00257169,0.00371399,0.00631138};
1176 +      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1177 +      name="30/15";
1178 +      color="#2464bc";
1179 +    }
1180 +    if(i==2) {
1181 +      double y[4]   = {1.01208,1.01991,1.02185,1.03479};
1182 +      double dyl[4] = {0.00366745,0.00400001,0.00584054,0.0104661};
1183 +      double dyh[4] = {0.00366745,0.00400001,0.00584054,0.0104661};
1184 +      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1185 +      name="15/15";
1186 +      color="#f49230";
1187 +    }
1188 +    if(i==3) {
1189 +      double y[4]   = {1.01177,1.01568,1.01616,1.03211};
1190 +      double dyl[4] = {0.00217317,0.00203014,0.00276838,0.00465643};
1191 +      double dyh[4] = {0.00217317,0.00203014,0.00276838,0.00465643};
1192 +      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1193 +      name="CHS 30/30";
1194 +      color="#c72f3c";
1195 +    }
1196 +    if(i==4) {
1197 +      double y[4]   = {1.00751,1.00964,1.00804,1.01073};
1198 +      double dyl[4] = {0.00224851,0.00215563,0.0029592,0.00499805};
1199 +      double dyh[4] = {0.00224851,0.00215563,0.0029592,0.00499805};
1200 +      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1201 +      name="CHS 30/15";
1202 +      color="#7cb433";
1203 +    }
1204 +    if(i==5) {
1205 +      double y[4]   = {1.01557,1.0318,1.03535,1.06331};
1206 +      double dyl[4] = {0.00300783,0.00302486,0.00421064,0.00739416};
1207 +      double dyh[4] = {0.00300783,0.00302486,0.00421064,0.00739416};
1208 +      gr[i] = new TGraphAsymmErrors(4,x,y,dxl,dxh,dyl,dyh);
1209 +      name="CHS 15/15";
1210 +      color="#DF013A";
1211 +    }
1212 +    
1213 +    gStyle->SetOptFit(0);
1214 +    gr[i]->SetTitle();
1215 +    gr[i]->GetXaxis()->SetTitle("N(Vtx)");
1216 +    gr[i]->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
1217 +    gr[i]->GetXaxis()->CenterTitle();
1218 +    gr[i]->GetYaxis()->CenterTitle();
1219 +    gr[i]->SetName(name.c_str());
1220 +    gr[i]->SetMarkerSize(0.00001);
1221 +    gr[i]->GetYaxis()->SetRangeUser(0.90,1.10);
1222 +    gr[i]->SetLineColor(TColor::GetColor(color.c_str()));
1223 +    gr[i]->SetMarkerColor(TColor::GetColor(color.c_str()));
1224 +    if(dofit) {
1225 +      gr[i]->Fit("pol1");
1226 +      fit[i] = (TF1*)gr[i]->GetFunction("pol1");
1227 +      fit[i]->SetLineColor(TColor::GetColor(color.c_str()));
1228 +    }
1229 +    
1230 +    stringstream nameplus;
1231 +    nameplus << name << " (slope: " << std::setprecision(3) << fit[i]->GetParameter(1) << ")";
1232 +    
1233 +    leg->AddEntry(gr[i],nameplus.str().c_str(),"l");
1234 +    if(i==0) gr[i]->Draw("AP*");
1235 +    else gr[i]->Draw("P");
1236 +  }
1237 +  leg->Draw();
1238 +  DrawPrelim();
1239    
1240 +  CompleteSave(can,"ScenarioComparisonInclusive");
1241    delete can;
1242    
1243 + }
1244 +
1245 + void compare_selection(string identifier) {
1246 +  bool recognized_scenario=false;
1247 +  
1248 +  cout << "Running with identifier " << identifier << endl;
1249 +  if(identifier=="Zb30") {
1250 +      LeadingB=TCut ("Zb30_bTagProbCSVBP[0]>0.898");
1251 +      EtaB=TCut("abs(Zb30_pfJetGoodEta[0])<1.3");
1252 +      PhiZcut=TCut("abs(Zb30_pfJetDphiZ[0])>2.7");
1253 +      recognized_scenario=true;
1254 +  }
1255 +  if(identifier=="Zb3010") {
1256 +      LeadingB=TCut ("Zb3010_bTagProbCSVBP[0]>0.898");
1257 +      EtaB=TCut("abs(Zb3010_pfJetGoodEta[0])<1.3");
1258 +      PhiZcut=TCut("abs(Zb3010_pfJetDphiZ[0])>2.7");
1259 +      recognized_scenario=true;
1260 +  }
1261 +  
1262 +  if(identifier=="ZbCHS3010") {
1263 +      LeadingB=TCut ("ZbCHS1510_bTagProbCSVBP[0]>0.898");
1264 +      EtaB=TCut("abs(ZbCHS1510_pfJetGoodEta[0])<1.3");
1265 +      PhiZcut=TCut("abs(ZbCHS1510_pfJetDphiZ[0])>2.7");
1266 +      recognized_scenario=true;
1267 +  }
1268 +  
1269 +  if(identifier=="Zb40") {
1270 +      LeadingB=TCut ("Zb40_bTagProbCSVBP[0]>0.898");
1271 +      EtaB=TCut("abs(Zb40_pfJetGoodEta[0])<1.3");
1272 +      PhiZcut=TCut("abs(Zb40_pfJetDphiZ[0])>2.7");
1273 +      recognized_scenario=true;
1274 +  }
1275 +  
1276 +  if(identifier=="ZbCHS301030") {
1277 +      LeadingB=TCut ("ZbCHS301030_bTagProbCSVBP[0]>0.898");
1278 +      EtaB=TCut("abs(ZbCHS301030_pfJetGoodEta[0])<1.3");
1279 +      PhiZcut=TCut("abs(ZbCHS301030_pfJetDphiZ[0])>2.7");
1280 +      recognized_scenario=true;
1281 +  }
1282 +  
1283 +  if(identifier=="Zb1530") {
1284 +      LeadingB=TCut ("Zb1530_bTagProbCSVBP[0]>0.898");
1285 +      EtaB=TCut("abs(Zb1530_pfJetGoodEta[0])<1.3");
1286 +      PhiZcut=TCut("abs(Zb1530_pfJetDphiZ[0])>2.7");
1287 +      recognized_scenario=true;
1288 +  }
1289 +  
1290 +  if(identifier=="ZbCHS301010") {
1291 +      LeadingB=TCut ("ZbCHS301010_bTagProbCSVBP[0]>0.898");
1292 +      EtaB=TCut("abs(ZbCHS301010_pfJetGoodEta[0])<1.3");
1293 +      PhiZcut=TCut("abs(ZbCHS301010_pfJetDphiZ[0])>2.7");
1294 +      recognized_scenario=true;
1295 +  }
1296 +  
1297 +  if(identifier=="Zb1510") {
1298 +      LeadingB=TCut ("Zb1510_bTagProbCSVBP[0]>0.898");
1299 +      EtaB=TCut("abs(Zb1510_pfJetGoodEta[0])<1.3");
1300 +      PhiZcut=TCut("abs(Zb1510_pfJetDphiZ[0])>2.7");
1301 +      recognized_scenario=true;
1302 +  }
1303 +  
1304 +  if(identifier=="ZbCHS301010") {
1305 +      LeadingB=TCut ("ZbCHS301010_bTagProbCSVBP[0]>0.898");
1306 +      EtaB=TCut("abs(ZbCHS301010_pfJetGoodEta[0])<1.3");
1307 +      PhiZcut=TCut("abs(ZbCHS301010_pfJetDphiZ[0])>2.7");
1308 +      recognized_scenario=true;
1309 +  }
1310 +  
1311 +  if(identifier=="ZbMikko") {
1312 +      LeadingB=TCut ("ZbMikko_bTagProbCSVBP[0]>0.898 && ZbMikko__IsClean");
1313 +      EtaB=TCut("abs(ZbMikko_pfJetGoodEta[0])<1.3 && ZbMikko__IsClean");
1314 +      PhiZcut=TCut("abs(ZbMikko_pfJetDphiZ[0])>2.7 && ZbMikko__IsClean");
1315 +      recognized_scenario=true;
1316 +  }
1317 +  
1318 +  if(identifier=="ZbCHS3010_SecEta3") {
1319 +      LeadingB=TCut ("ZbCHS3010_SecEta3_bTagProbCSVBP[0]>0.898");
1320 +      EtaB=TCut("abs(ZbCHS3010_SecEta3_pfJetGoodEta[0])<1.3");
1321 +      PhiZcut=TCut("abs(ZbCHS3010_SecEta3_pfJetDphiZ[0])>2.7");
1322 +      recognized_scenario=true;
1323 +  }
1324 +  
1325 +  if(identifier=="ZbCHS3010_SecEta5") {
1326 +      LeadingB=TCut ("ZbCHS3010_SecEta5_bTagProbCSVBP[0]>0.898");
1327 +      EtaB=TCut("abs(ZbCHS3010_SecEta5_pfJetGoodEta[0])<1.3");
1328 +      PhiZcut=TCut("abs(ZbCHS3010_SecEta5_pfJetDphiZ[0])>2.7");
1329 +      recognized_scenario=true;
1330 +  }
1331 +  
1332 +  if(identifier=="ZbCHS3010_p5Clean") {
1333 +      LeadingB=TCut ("ZbCHS3010_p5Clean_bTagProbCSVBP[0]>0.898 && ZbCHS3010_p5Clean_IsClean");
1334 +      EtaB=TCut("abs(ZbCHS3010_p5Clean_pfJetGoodEta[0])<1.3 && ZbCHS3010_p5Clean_IsClean");
1335 +      PhiZcut=TCut("abs(ZbCHS3010_p5Clean_pfJetDphiZ[0])>2.7 && ZbCHS3010_p5Clean_IsClean");
1336 +      recognized_scenario=true;
1337 +  }
1338 +  
1339 +  if(identifier=="ZbCHS3010") {
1340 +      LeadingB=TCut ("ZbCHS3010_bTagProbCSVBP[0]>0.898");
1341 +      EtaB=TCut("abs(ZbCHS3010_pfJetGoodEta[0])<1.3");
1342 +      PhiZcut=TCut("abs(ZbCHS3010_pfJetDphiZ[0])>2.7");
1343 +      recognized_scenario=true;
1344 +  }
1345 +  if(identifier=="ZbCHS3010") {
1346 +      LeadingB=TCut ("ZbCHS3010_bTagProbCSVBP[0]>0.898");
1347 +      EtaB=TCut("abs(ZbCHS3010_pfJetGoodEta[0])<1.3");
1348 +      PhiZcut=TCut("abs(ZbCHS3010_pfJetDphiZ[0])>2.7");
1349 +      recognized_scenario=true;
1350 +  }
1351 +  if(identifier=="ZbCHS30") {
1352 +      LeadingB=TCut ("ZbCHS30_bTagProbCSVBP[0]>0.898");
1353 +      EtaB=TCut("abs(ZbCHS30_pfJetGoodEta[0])<1.3");
1354 +      PhiZcut=TCut("abs(ZbCHS30_pfJetDphiZ[0])>2.7");
1355 +      recognized_scenario=true;
1356 +  }
1357 +  
1358 +  assert(recognized_scenario);
1359 +  
1360 +  cout << "Cuts: " << endl;
1361 +  cout << "   " << (const char*) LeadingB << endl;
1362 +  cout << "   " << (const char*) EtaB << endl;
1363 +  cout << "   " << (const char*) PhiZcut << endl;
1364 +  
1365 +  cout << endl << endl;
1366 +
1367 + //  ScenarioComparison();
1368 + //  ScenarioComparisonInclusive();
1369 +
1370 + //    DoPUStudy(identifier);
1371 + //    SpecialCutFlow(identifier);
1372 +  
1373 + //    draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000",17000,30,200,"Z p_{T}","Official/"+identifier+"/Zpt__"+identifier,1);
1374 + //    draw_kin_variable(identifier+"_pfJetGoodPt[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000",40,0,200,"Leading Jet Pt (B)","Official/"+identifier+"/LeadingJetPt__"+identifier,1);
1375 + //    draw_kin_variable(identifier+"_pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000",40,0,200,"Sub-Leading Jet Pt [GeV]","Official/"+identifier+"/Jet2Pt__"+identifier,1);
1376 + //    draw_kin_variable(identifier+"_pfJetGoodPt[1]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000",20,0,2,"p_{T}^{J2} / p_{T}^{Z}","Official/"+identifier+"/SubLeadingJetPt_Over_ZPt__"+identifier,1);
1377 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>30&&pt<50"),20,0,2,"#alpha","Official/"+identifier+"/alpha_pt_30_to_50__"+identifier,1);
1378 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>50&&pt<75"),20,0,2,"#alpha","Official/"+identifier+"/alpha_50_to_75__"+identifier,1);
1379 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>75&&pt<125"),20,0,2,"#alpha","Official/"+identifier+"/alpha_pt_75_to_125__"+identifier,1);
1380 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>125&&pt<1000"),20,0,2,"#alpha","Official/"+identifier+"/alpha_pt_125_to_1000__"+identifier,1);
1381 +  draw_kin_variable(identifier+"_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut,20,0,2,"#alpha","Official/"+identifier+"/alpha_full__"+identifier,1);
1382 +   draw_kin_variable(identifier+"_pfBJetDphiZ[0]",ZplusBsel&&LeadingB&&"pt>30&&pt<1000&&pfBJetDphiZ[0]>0",30,0,3.2,"#delta#phi (Z,b lead)","Official/"+identifier+"/DeltaPhiZBlead__"+identifier,0);
1383 +  
1384 +   draw_kin_variable("mpf",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.3").c_str()),20,0,2,"Z+b MPF","Official/"+identifier+"/mpf_alpha_smaller_0p3___"+identifier,0,"#alpha<0.3, 30 GeV < p_{T}^{Z} < 1000 GeV");
1385 +   draw_kin_variable(identifier+"_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.3").c_str()),20,0,2,"p_{T} b-jet / p_{T} Z","Official/"+identifier+"/ptb_over_ptz___alpha_smaller_0p3______"+identifier,0,"#alpha<0.3, 30 GeV < p_{T}^{Z} < 1000 GeV");
1386 +   draw_kin_variable(identifier+"_pfJetGoodPt[0]/pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<50&&"+identifier+"_alpha<0.3").c_str()),20,0,2,"p_{T} b-jet / p_{T} Z","Official/"+identifier+"/ptb_over_ptz___alpha_smaller_0p3___pt3050___"+identifier,0,"#alpha<0.3, 30 GeV < p_{T}^{Z} < 1000 GeV}{30<p_{T}^{Z}<50 GeV}");
1387 +  
1388 + }
1389 +
1390 + void GetNumberEventsInsideOutsideAlphaWindow(TCut specialcut, string title) {
1391    
1392 + //  TCut cut =  ZplusBsel&&LeadingB&&PhiZcut&&specialcut&&TCut("ZbCHS3010_alpha<0.3");
1393 +  TCut cut = specialcut;
1394 +  TCut in  =  EtaB;
1395 +  TCut out =  TCut("abs(ZbCHS3010_pfJetGoodEta[0])>1.3");
1396 +
1397 +  TH1F *data_IN  = allsamples.Draw("data_IN",    "mll",1,0,150, "nothing [GeV]", "events", cut&&in, data,luminosity);
1398 +  TH1F *data_OUT = allsamples.Draw("data_OUT",   "mll",1,0,150, "nothing [GeV]", "events", cut&&out,data,luminosity);
1399 +  TH1F *mc_IN    = allsamples.Draw("mc_IN",      "mll",1,0,150, "nothing [GeV]", "events", cut&&in, mc  ,luminosity);
1400 +  TH1F *mc_OUT   = allsamples.Draw("mc_OUT",     "mll",1,0,150, "nothing [GeV]", "events", cut&&out,mc  ,luminosity);
1401 +  
1402 +  dout << title << " : " << endl;
1403 +  dout << "  Data: In " << data_IN->Integral() << " vs out " << data_OUT->Integral() << endl;
1404 +  dout << "  MC  : In " << mc_IN->Integral()   << " vs out " << mc_OUT->Integral()   << endl;  
1405 +  dout << "       ratio in  : " << data_IN->Integral()/mc_IN->Integral() << " +/- " << (data_IN->Integral()/mc_IN->Integral()) * sqrt(1.0/mc_IN->Integral()+ 1.0/data_IN->Integral()) << endl;
1406 +  dout << "       ratio out : " << data_OUT->Integral()/mc_OUT->Integral() << " +/- " << (data_OUT->Integral()/mc_OUT->Integral()) * sqrt(1.0/mc_OUT->Integral()+ 1.0/data_OUT->Integral()) << endl;
1407 +  
1408 +  delete data_IN;
1409 +  delete data_OUT;
1410 +  delete mc_IN;
1411 +  delete mc_OUT;
1412   }
1413  
1414 + void TEST_GetNumberEventsInsideOutsideAlphaWindow() {
1415 +  TCanvas *ca = new TCanvas("ca","ca");
1416 + //   GetNumberEventsInsideOutsideAlphaWindow(TCut("id1==id2&&id1==0"), "ee");
1417 + //   GetNumberEventsInsideOutsideAlphaWindow(TCut("id1==id2&&id1==1"), "mm");
1418 + //   GetNumberEventsInsideOutsideAlphaWindow(TCut("id1==id2"), "ee/mm");
1419 +  
1420 +  cout << "BASE SELECTION" << endl;
1421 +  GetNumberEventsInsideOutsideAlphaWindow(TCut("id1==id2&&id1==0"), "ee");
1422 +  GetNumberEventsInsideOutsideAlphaWindow(TCut("id1==id2&&id1==1"), "mm");
1423 +  GetNumberEventsInsideOutsideAlphaWindow(TCut("id1==id2"), "ee/mm");
1424  
1425 +  cout << "BASE SELECTION: Z+b" << endl;
1426 +  GetNumberEventsInsideOutsideAlphaWindow(ZplusBsel&&TCut("id1==id2&&id1==0"), "ee");
1427 +  GetNumberEventsInsideOutsideAlphaWindow(ZplusBsel&&TCut("id1==id2&&id1==1"), "mm");
1428 +  GetNumberEventsInsideOutsideAlphaWindow(ZplusBsel&&TCut("id1==id2"), "ee/mm");
1429 +  
1430 +  cout << "Leading B" << endl;
1431 +  GetNumberEventsInsideOutsideAlphaWindow(LeadingB&&ZplusBsel&&TCut("id1==id2&&id1==0"), "ee");
1432 +  GetNumberEventsInsideOutsideAlphaWindow(LeadingB&&ZplusBsel&&TCut("id1==id2&&id1==1"), "mm");
1433 +  GetNumberEventsInsideOutsideAlphaWindow(LeadingB&&ZplusBsel&&TCut("id1==id2"), "ee/mm");
1434 +  
1435 +  cout << "PhiZcut" << endl;
1436 +  GetNumberEventsInsideOutsideAlphaWindow(PhiZcut&&LeadingB&&ZplusBsel&&TCut("id1==id2&&id1==0"), "ee");
1437 +  GetNumberEventsInsideOutsideAlphaWindow(PhiZcut&&LeadingB&&ZplusBsel&&TCut("id1==id2&&id1==1"), "mm");
1438 +  GetNumberEventsInsideOutsideAlphaWindow(PhiZcut&&LeadingB&&ZplusBsel&&TCut("id1==id2"), "ee/mm");
1439 +  
1440 +  cout << "alpha cut" << endl;
1441 +  GetNumberEventsInsideOutsideAlphaWindow(PhiZcut&&LeadingB&&ZplusBsel&&TCut("id1==id2&&id1==0")&&TCut("ZbCHS3010_alpha<0.3"), "ee");
1442 +  GetNumberEventsInsideOutsideAlphaWindow(PhiZcut&&LeadingB&&ZplusBsel&&TCut("id1==id2&&id1==1")&&TCut("ZbCHS3010_alpha<0.3"), "mm");
1443 +  GetNumberEventsInsideOutsideAlphaWindow(PhiZcut&&LeadingB&&ZplusBsel&&TCut("id1==id2")&&TCut("ZbCHS3010_alpha<0.3"), "ee/mm");
1444 +  
1445 +  delete ca;
1446 +  
1447 +  
1448 + }
1449 +  
1450  
1451 < void do_basic_ZB_analysis() {
1452 <  TCanvas *zbcanvas = new TCanvas("zbcanvas","zbcanvas");
1453 <  write_warning(__FUNCTION__,"TESTING NEW DATA MC AGREEMENT");
1454 <  
1455 <  /*
1456 <  write_warning(__FUNCTION__,"Not doing b yields (already implemented)");
1457 < //  print_all_b_yields();
1458 <  write_warning(__FUNCTION__,"Not drawing mpf variables (already implemented)");
1459 < //  draw_mpf_vars();
1460 <  write_warning(__FUNCTION__,"Not drawing mpf variables (already implemented)");
1461 <  draw_Zb_kin_vars();
1462 <  
1463 <  data_mc_agreement_2d();
1464 <  */
1465 <  new_data_mc_agreement_2d();
1451 > void MetSpectrumDepletionIllustration(int isdata) {
1452 >  
1453 >  TCanvas *can = new TCanvas("can","can");
1454 >  TCut basecut(ZplusBsel&&LeadingB&&EtaB&&PhiZcut);
1455 >  
1456 >  cutWeight=STDWEIGHT*TCut("ZbCHS3010_BTagWgtTUp*(1.0)*(ZbCHS3010_bTagProbCSVBP[0]>0.898)");
1457 >  TH1F *standard  = allsamples.Draw("standard","met[1]",80,0,400, "MET [GeV]", "events", basecut,isdata,luminosity);
1458 >  
1459 >  cutWeight=STDWEIGHT*TCut("ZbCHS3010_BTagWgtTUp*(1.0*softMuon)*(ZbCHS3010_bTagProbCSVBP[0]>0.898)");
1460 >  TH1F *Neutrinos  = allsamples.Draw("Neutrinos","met[1]",80,0,400, "MET [GeV]", "events", basecut,isdata,luminosity);
1461 >  
1462 >  cutWeight=STDWEIGHT*TCut("ZbCHS3010_BTagWgtTUp*(1.0*(1.0-softMuon))*(ZbCHS3010_bTagProbCSVBP[0]>0.898)");
1463 >  TH1F *NoNeutrinos  = allsamples.Draw("NoNeutrinos","met[1]",80,0,400, "MET [GeV]", "events", basecut,isdata,luminosity);
1464 >  
1465 >  standard->Scale(1.0/standard->Integral());
1466 >  Neutrinos->Scale(1.0/Neutrinos->Integral());
1467 >  NoNeutrinos->Scale(1.0/NoNeutrinos->Integral());
1468 >  
1469 >  Neutrinos->SetLineColor(kGreen);
1470 >  NoNeutrinos->SetLineColor(kRed);
1471 >  
1472 >  can->SetLogy(1);
1473 >  TLegend *leg = make_legend();
1474 >  leg->AddEntry(standard,"Standard sample","ep");
1475 >  leg->AddEntry(Neutrinos,"#nu enriched sample","l");
1476 >  leg->AddEntry(NoNeutrinos,"#nu depleted sample","l");
1477 >  leg->SetX1(0.9*leg->GetX1());
1478 >  standard->Draw("e1");
1479 >  Neutrinos->Draw("histo,same");
1480 >  NoNeutrinos->Draw("histo,same");
1481 >  if(isdata==data) leg->SetHeader("Data:");
1482 >  else leg->SetHeader("MC:");
1483 >  leg->Draw();
1484 >  DrawPrelim();
1485 >  
1486 >  if(isdata==data) CompleteSave(can,"NeutrinoMetSpectrum__Data");
1487 >  else CompleteSave(can,"NeutrinoMetSpectrum__MC");
1488 >  delete standard;
1489 >  delete Neutrinos;
1490 >  delete NoNeutrinos;
1491 >  delete can;
1492 >  CleanLegends();
1493 > }
1494 >    
1495 > void do_basic_ZB_analysis(bool DoCompleteAnalysis) {
1496 >  STDWEIGHT=TCut(cutWeight);
1497 >  cutWeight=TCut(STDWEIGHT*TCut("ZbCHS3010_BTagWgtT"));
1498 >  cout << "The lepton requirement is " << (const char*) leptoncut << endl;
1499 >  bool doquick=false;
1500 >  
1501 >   TCanvas *zbcanvas = new TCanvas("zbcanvas","zbcanvas");
1502 >  
1503 >  
1504 > //   MetSpectrumDepletionIllustration(data);
1505 > //   MetSpectrumDepletionIllustration(mc);
1506 >  
1507 > //   compare_selection("ZbCHS3010_p5Clean");
1508 > //   compare_selection("ZbCHS3010");
1509 > //   compare_selection("Zb30");
1510 > //   compare_selection("Zb3010");
1511 > //   compare_selection("Zb1510");
1512 > //   compare_selection("ZbCHS30");
1513 > //   compare_selection("ZbCHS3010");
1514 > //   compare_selection("ZbCHS3010");
1515 > //   compare_selection("ZbCHS301010");
1516 > //   compare_selection("ZbCHS3010_SecEta3");
1517 > //   compare_selection("ZbCHS3010_SecEta5");
1518 > //   compare_selection("Zb1510");
1519 > //   compare_selection("ZbCHS301010");
1520 > //   compare_selection("ZbMikko");
1521 > //   compare_selection("ZbCHS3010");
1522 > //   compare_selection("Zb40");
1523 >
1524 >  if(!doquick) {
1525 > //    draw_kin_variable("mll","",28,60.0,200.0,"m_{ll}","mll",1,"");//nice and quick test to see if the normalization is ok (i.e. all data is processed etc.)
1526 > //    print_all_b_yields();
1527 > //     draw_mpf_vars();
1528 > //    DrawEvilCutFlow();
1529 >        
1530 > //     draw_Zb_kin_vars();
1531 >        
1532 >   }
1533 >  
1534 > //  GetNumberEventsInsideOutsideAlphaWindow();
1535 >  
1536 >  if(DoCompleteAnalysis) {
1537 >    /* need to run the following scenarios:
1538 >     * - normal
1539 >     * - inclusive
1540 >     * - medium WP
1541 >     * - alpha up
1542 >     * - alpha down
1543 >     */
1544 >    
1545 >    bool fast=true;bool slow=false;//don't change these
1546 >    
1547 >    ZbResultContainer Reference = new_data_mc_agreement_2d(slow,"ZbCHS3010_alpha","reference",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtT"),0.3);
1548 >    ZbResultContainer inclusive = new_data_mc_agreement_2d(slow,"ZbCHS3010_alpha","inclusive",TCut("mll>0"),TCut("1.0"),0.3);
1549 >    
1550 >    ZbResultContainer NeutrinoQ = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","NeutrinoQ",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtTUp*(1.0*softMuon)"),0.3);
1551 >    ZbResultContainer ANeutrinoQ = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","ANeutrinoQ",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtTUp*(1.0*(1.0-softMuon))"),0.3);
1552 >    
1553 >    ZbResultContainer effmistagUp = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","effmistagUp",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtTUp"),0.3);
1554 >    ZbResultContainer effmistagDown = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","effmistagDown",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtTDown"),0.3);
1555 >    ZbResultContainer medium = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","medium",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.679"),TCut("ZbCHS3010_BTagWgtM"),0.3);
1556 >    ZbResultContainer loose = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","loose",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.244"),TCut("ZbCHS3010_BTagWgtL"),0.3);
1557 >    ZbResultContainer AlphaUp = new_data_mc_agreement_2d(fast,"ZbCHS3010_alphaUp","AlphaUp",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtT"),0.3);
1558 >    ZbResultContainer AlphaDown = new_data_mc_agreement_2d(fast,"ZbCHS3010_alphaDown","AlphaDown",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtT"),0.3);
1559 >    
1560 >    ZbResultContainer L5inclusive = new_data_mc_agreement_2d(fast,"ZbCHS3010_alphaL5","L5inclusive",TCut("mll>0"),TCut("1.0"),0.3);
1561 >    ZbResultContainer L5Reference = new_data_mc_agreement_2d(fast,"ZbCHS3010_alphaL5","L5reference",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtT"),0.3);
1562 >    
1563 >    ZbResultContainer AlphaThresholdVariationDown10 =    new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationDown10",   TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),   TCut("ZbCHS3010_BTagWgtT"),0.3-0.1*0.3);
1564 >    ZbResultContainer AlphaThresholdVariationUp10 =      new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationUp10",     TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),   TCut("ZbCHS3010_BTagWgtT"),0.3+0.1*0.3);
1565 >    ZbResultContainer AlphaThresholdVariationDown30 =    new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationDown30",   TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),   TCut("ZbCHS3010_BTagWgtT"),0.3-0.3*0.3);
1566 >    ZbResultContainer AlphaThresholdVariationUp30 =      new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationUp30",     TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),   TCut("ZbCHS3010_BTagWgtT"),0.3+0.3*0.3);
1567 >    ZbResultContainer AlphaThresholdVariationDown10inc = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationDown10inc",TCut("mll>0"),                              TCut("1.0"),0.3-0.1*0.3);
1568 >    ZbResultContainer AlphaThresholdVariationUp10inc =   new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationUp10inc",  TCut("mll>0"),                              TCut("1.0"),0.3+0.1*0.3);
1569 >    ZbResultContainer AlphaThresholdVariationDown30inc = new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationDown30inc",TCut("mll>0"),                              TCut("1.0"),0.3-0.3*0.3);
1570 >    ZbResultContainer AlphaThresholdVariationUp30inc =   new_data_mc_agreement_2d(fast,"ZbCHS3010_alpha","AlphaThresholdVariationUp30inc",  TCut("mll>0"),                              TCut("1.0"),0.3+0.3*0.3);
1571 >
1572 >    //and now let's compute some systematics!
1573 >    //1 alpha variation
1574 >    float SysMPF_Alpha_down = Reference.MPF_Result_FaceValue.getValue()-AlphaDown.MPF_Result_FaceValue.getValue();
1575 >    float SysMPF_Alpha_up = Reference.MPF_Result_FaceValue.getValue()-AlphaUp.MPF_Result_FaceValue.getValue();
1576 >    
1577 >    //2 btagging efficiency/mistag correction
1578 >    float SysMPF_EFF_down = Reference.MPF_Result_FaceValue.getValue()-effmistagDown.MPF_Result_FaceValue.getValue();
1579 >    float SysMPF_EFF_up = Reference.MPF_Result_FaceValue.getValue()-effmistagUp.MPF_Result_FaceValue.getValue();
1580 >    
1581 >    //3 Presence of soft muons (->neutrino question)
1582 >    float SysMPF_Neutrino_up = Reference.MPF_Result_FaceValue.getValue()-NeutrinoQ.MPF_Result_FaceValue.getValue();
1583 >    float SysMPF_Neutrino_down = Reference.MPF_Result_FaceValue.getValue()-ANeutrinoQ.MPF_Result_FaceValue.getValue();
1584 >    
1585 >    //4 purity
1586 >    zbcanvas->cd();
1587 >    gStyle->SetOptFit(0);
1588 >    write_info(__FUNCTION__,"Don't know the exact purity at the moment, still needs to be determined!");
1589 >    TH1F *purityhisto = new TH1F("purityhisto","purityhisto",1,0,1);
1590 >    purityhisto->GetXaxis()->SetTitle("Purity");
1591 >    purityhisto->GetYaxis()->SetTitle("C_{abs}");
1592 >    purityhisto->GetXaxis()->CenterTitle();
1593 >    purityhisto->GetYaxis()->CenterTitle();
1594 >    
1595 >    TGraphErrors *gSysMPF_Purity = new TGraphErrors();
1596 >    
1597 >    gSysMPF_Purity->SetPoint(0,PurityInclusive,inclusive.MPF_Result_FaceValue.getValue());
1598 >    gSysMPF_Purity->SetPointError(0,0.0,inclusive.MPF_Result_FaceValue.getError());
1599 >    
1600 >    gSysMPF_Purity->SetPoint(1,PurityLoose,loose.MPF_Result_FaceValue.getValue());//x value?
1601 >    gSysMPF_Purity->SetPointError(1,0.0,loose.MPF_Result_FaceValue.getError());
1602 >    gSysMPF_Purity->SetPoint(2,PurityMedium,medium.MPF_Result_FaceValue.getValue());//x value?
1603 >    gSysMPF_Purity->SetPointError(2,0.0,medium.MPF_Result_FaceValue.getError());
1604 >    gSysMPF_Purity->SetPoint(3,PurityTight,Reference.MPF_Result_FaceValue.getValue());//x value?
1605 >    gSysMPF_Purity->SetPointError(3,0.0,Reference.MPF_Result_FaceValue.getError());
1606 >    
1607 >    
1608 >    float min,max;
1609 >    FindMinMax(gSysMPF_Purity,min,max);
1610 >    purityhisto->SetStats(0);
1611 >    purityhisto->GetYaxis()->SetRangeUser(min,max);
1612 >    
1613 >    gSysMPF_Purity->Fit("pol1");
1614 >    TPolyLine *purity_fit_uncert = GetFitUncertaintyShape(gSysMPF_Purity, "pol1", min, max,0.0,1.0);
1615 >    TF1* pufit = (TF1*)gSysMPF_Purity->GetFunction("pol1");
1616 >    
1617 >    TF1* pufit_c = new TF1("pufit_c","[0]+[1]*x");
1618 >    pufit_c->SetParameters(pufit->GetParameters());
1619 >    pufit_c->SetLineColor(TColor::GetColor("#0101DF"));
1620 >    purity_fit_uncert->SetFillColor(TColor::GetColor("#5353FC"));
1621 >    pufit->SetLineColor(TColor::GetColor("#5353FC"));
1622 >    
1623 >    purityhisto->Draw();
1624 >    purity_fit_uncert->Draw("f");
1625 >    gSysMPF_Purity->Draw("P*");
1626 >    pufit_c->Draw("same");
1627 >    DrawPrelim();
1628 >    
1629 >    float ExtrapolatedResult=pufit->GetParameter(0)+1.0*pufit->GetParameter(1);
1630 >    float dExtrapolatedResult=sqrt(pufit->GetParError(0)*pufit->GetParError(0)+1.0*1.0*pufit->GetParError(1)*pufit->GetParError(1));
1631 >    
1632 >    stringstream summary;
1633 >    summary << "#splitline{Reference: " << std::setprecision(4) << Reference.MPF_Result_FaceValue.getValue() << "+/-" << std::setprecision(4) << Reference.MPF_Result_FaceValue.getError() << "}{";
1634 >    summary << "Extrapolation: " << std::setprecision(4) << ExtrapolatedResult << " +/- " << std::setprecision(4) << dExtrapolatedResult << "}";
1635 >    
1636 >    dout << "Have found an extrapolated result at 1.0 of " << ExtrapolatedResult << " ;  will use the difference between this result and the face value as ";
1637 >    dout << "purity-related systematic uncertainty" << endl;
1638 >    
1639 >    TText *infobox = write_title(summary.str());
1640 >    infobox->SetX(0.75);
1641 >    infobox->SetTextSize(0.03);
1642 >    infobox->SetY(0.75);
1643 >    infobox->Draw();
1644 >    
1645 >    CompleteSave(zbcanvas,"Systematics/Purity");
1646 >    
1647 >    
1648 >
1649 >    float SysMPF_Purity = abs(ExtrapolatedResult-Reference.MPF_Result_FaceValue.getValue());
1650 >    
1651 >    float sys_alpha    = abs(SysMPF_Alpha_down)>abs(SysMPF_Alpha_up)?abs(SysMPF_Alpha_down):abs(SysMPF_Alpha_up);
1652 >    float sys_eff      = abs(SysMPF_EFF_down)>abs(SysMPF_EFF_up)?abs(SysMPF_EFF_down):abs(SysMPF_EFF_up);
1653 >    float sys_purity   = abs(SysMPF_Purity);
1654 >    float sys_neutrino = abs(SysMPF_Neutrino_down)>abs(SysMPF_Neutrino_up)?abs(SysMPF_Neutrino_down):abs(SysMPF_Neutrino_up);
1655 >    float sys          = sqrt(sys_alpha*sys_alpha+sys_eff*sys_eff+sys_purity*sys_purity+sys_neutrino*sys_neutrino);
1656 >    
1657 >    dout << "MPF METHOD:" << endl;
1658 >    dout << "   Systematics :    down    up     (selected)" << endl;
1659 >    dout << "      Oversmearing         : " << SysMPF_Alpha_down << "   ,  " << SysMPF_Alpha_up << "   ( " << sys_alpha << ") " << endl;
1660 >    dout << "      eff/mistag variation : " << SysMPF_EFF_down << "   ,  " << SysMPF_EFF_up << "   ( " << sys_eff << ") " << endl;
1661 >    dout << "      purity               : " << SysMPF_Purity << "   ( " << sys_purity << " )" << endl;
1662 >    dout << "      neutrino             : " << SysMPF_Neutrino_down << "   ,  " << SysMPF_Neutrino_up << "   ( " << sys_neutrino << ") " << endl;
1663 >    dout << "      total                : " << sys << "     (note that this is the sys on C_{abs}^{b}, not yet on C_{corr} - there will also be an additional source!)" << endl;
1664 >    dout << endl << endl;
1665 >    dout << "   FINAL RESULTS : " << endl;
1666 >    dout << "     C_{abs}^{b}   = " << Reference.MPF_Result_FaceValue << " (stat) +/- " << sys << " (sys) " << endl;
1667 >    dout << "     C_{abs}^{inc} = " << inclusive.MPF_Result_FaceValue << " (stat) " << endl;
1668 >    
1669 >    float sysfinal = Reference.MPF_Result_FaceValue.getValue()/inclusive.MPF_Result_FaceValue.getValue();
1670 >    sysfinal *= sqrt(sys*sys/(Reference.MPF_Result_FaceValue.getValue()*Reference.MPF_Result_FaceValue.getValue()));
1671 >    //yes, this could be simplified but it would look like a bug.
1672 >    
1673 >
1674 >    
1675 >    
1676 >    dout << "Note: Varying the alpha cut (->face value) we get the following results: " << endl;
1677 >    dout << "-30%: " << AlphaThresholdVariationDown30.MPF_Result_FaceValue/AlphaThresholdVariationDown30inc.MPF_Result_FaceValue << " (stat)" << endl;
1678 >    dout << "-10%: " << AlphaThresholdVariationDown10.MPF_Result_FaceValue/AlphaThresholdVariationDown10inc.MPF_Result_FaceValue << " (stat)" << endl;
1679 >    dout << "  0%: " << Reference.MPF_Result_FaceValue/inclusive.MPF_Result_FaceValue << " (stat) +/- " << endl;
1680 >    dout << "+10%: " << AlphaThresholdVariationUp10.MPF_Result_FaceValue/AlphaThresholdVariationUp10inc.MPF_Result_FaceValue << " (stat)" << endl;
1681 >    dout << "+30%: " << AlphaThresholdVariationUp30.MPF_Result_FaceValue/AlphaThresholdVariationUp30inc.MPF_Result_FaceValue << " (stat)" << endl;
1682 >    
1683 >    dout << "          XCheck for Rabs, varying the alpha cut (->face value) we get the following results: " << endl;
1684 >    dout << "             -30%: " << AlphaThresholdVariationDown30.Rabs_Result_FaceValue/AlphaThresholdVariationDown30inc.Rabs_Result_FaceValue << " (stat)" << endl;
1685 >    dout << "             -10%: " << AlphaThresholdVariationDown10.Rabs_Result_FaceValue/AlphaThresholdVariationDown10inc.Rabs_Result_FaceValue << " (stat)" << endl;
1686 >    dout << "               0%: " << Reference.Rabs_Result_FaceValue/inclusive.Rabs_Result_FaceValue << " (stat) +/- " << endl;
1687 >    dout << "             +10%: " << AlphaThresholdVariationUp10.Rabs_Result_FaceValue/AlphaThresholdVariationUp10inc.Rabs_Result_FaceValue << " (stat)" << endl;
1688 >    dout << "             +30%: " << AlphaThresholdVariationUp30.Rabs_Result_FaceValue/AlphaThresholdVariationUp30inc.Rabs_Result_FaceValue << " (stat)" << endl;
1689 >
1690 >    
1691 >    float sys_alphavar_up   = abs(AlphaThresholdVariationUp30.MPF_Result_FaceValue.getValue()/AlphaThresholdVariationUp30inc.MPF_Result_FaceValue.getValue() - Reference.MPF_Result_FaceValue.getValue()/inclusive.MPF_Result_FaceValue.getValue());
1692 >    float sys_alphavar_down = abs(AlphaThresholdVariationDown30.MPF_Result_FaceValue.getValue()/AlphaThresholdVariationDown30inc.MPF_Result_FaceValue.getValue() - Reference.MPF_Result_FaceValue.getValue()/inclusive.MPF_Result_FaceValue.getValue());
1693 >    float sys_alphavar = sys_alphavar_up>sys_alphavar_down?sys_alphavar_up:sys_alphavar_down;
1694 >    
1695 >    dout << " -> Additional systematic (from 30%) : " << sys_alphavar << endl;
1696 >    sysfinal=sqrt(sysfinal*sysfinal+sys_alphavar*sys_alphavar);
1697 >    dout << "Final systematic is : " << sysfinal << endl;
1698 >    
1699 >    dout << "   ******************************************** <  FINAL RESULT > ******************************************** " << endl;
1700 >    dout << "     C_{corr}      = " << Reference.MPF_Result_FaceValue/inclusive.MPF_Result_FaceValue << " (stat) +/- " << sysfinal << " (sys) " << endl;
1701 >    dout << "   ******************************************** < /FINAL RESULT > ******************************************** " << endl;
1702 >    
1703 >    dout << "Note that if L5 corrections are applied, we get " << L5Reference.MPF_Result_FaceValue/L5inclusive.MPF_Result_FaceValue << " (stat) " << endl;
1704 >    
1705 >    LeadingB=TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898");
1706 >    
1707 >  } else {
1708 >    ZbResultContainer Reference = new_data_mc_agreement_2d(false,"ZbCHS3010_alpha","reference",TCut("ZbCHS3010_bTagProbCSVBP[0]>0.898"),TCut("ZbCHS3010_BTagWgtT"),0.3);
1709 >  }
1710 >  
1711    
1712    delete zbcanvas;
1713   }
1714 +
1715 +
1716 +
1717 +
1718 + //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*  DELETE EVERYTHING BELOW THIS LINE /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*//
1719 +
1720 +
1721 + const char* concatenate(string bla1, string bla2) {
1722 +  stringstream bla;
1723 +  bla << bla1 << bla2;
1724 +  return bla.str().c_str();
1725 + }
1726 +
1727 + void SpecialCutFlow(string identifier) {
1728 +  stringstream MegaCut;
1729 +  
1730 +  
1731 +  
1732 +  MegaCut << "   1*(" << (const char*) (ZplusBsel&&TCut(concatenate(identifier,"_pfJetGoodNumBtag>0"))) << ")";
1733 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB) << ")";
1734 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB) << ")";
1735 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut) << ")";
1736 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000").c_str())) << ")";
1737 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.3").c_str())) << ")";
1738 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.2").c_str())) << ")";
1739 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.15").c_str())) << ")";
1740 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.1").c_str())) << ")";
1741 +  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>30&&pt<1000&&"+identifier+"_alpha<0.05").c_str())) << ")";
1742 +  MegaCut << " ";
1743 +  
1744 +  TCanvas *can = new TCanvas("can","can");
1745 +  can->SetLogy(1);
1746 +  TCut basecut(ZplusBsel);
1747 +  
1748 +  
1749 +  
1750 +  TLegend *leg = allsamples.allbglegend();
1751 +  
1752 +  
1753 +  TH1F *data  = allsamples.Draw("data",    MegaCut.str(),11,-0.5,10.5, "", "events", basecut,data,luminosity);
1754 +  THStack mcm = allsamples.DrawStack("mc", MegaCut.str(),11,-0.5,10.5, "", "events", basecut,mc,luminosity);
1755 +
1756 +  float runningsum=0;
1757 +  for(int i=data->GetNbinsX();i>0;i--) {
1758 +    runningsum+=data->GetBinContent(i);
1759 +    data->SetBinContent(i,runningsum);
1760 +  }
1761 +  
1762 +  float minimum=data->GetMaximum();
1763 +  
1764 +  TH1F* h;
1765 +  TIter nextOF(mcm.GetHists());
1766 +  
1767 +  float mcsum=0;
1768 +  float zb=0;
1769 +  while ( h = (TH1F*)nextOF() ) {
1770 +    float runningsum=0;
1771 +    minimum=data->GetMaximum();//done deliberately at each step so get the minimum of the last (!) contribution
1772 +    for(int i=h->GetNbinsX();i>0;i--) {
1773 +      runningsum+=h->GetBinContent(i);
1774 +      h->SetBinContent(i,runningsum);
1775 +      if(runningsum<minimum&&runningsum>0) minimum=runningsum;
1776 +    }
1777 +    if(Contains(h->GetName(),"Z_b_")) {
1778 +      zb=h->GetBinContent(h->GetNbinsX());
1779 +    }
1780 +    mcsum+=h->GetBinContent(h->GetNbinsX());
1781 +  }
1782 +  
1783 +  
1784 +
1785 +  data->SetMinimum(0.05*minimum);
1786 +  can->cd(1)->SetBottomMargin(0.25);
1787 +  data->GetXaxis()->SetBinLabel(1,"Pre-selection");
1788 +  data->GetXaxis()->SetBinLabel(2,"Contains b jet");
1789 +  data->GetXaxis()->SetBinLabel(3,"Leading jet is b-jet");
1790 +  data->GetXaxis()->SetBinLabel(4,"|#eta_{b}|<1.3 ");
1791 +  data->GetXaxis()->SetBinLabel(5,"|#delta#phi(b,Z)|>2.7");
1792 +  data->GetXaxis()->SetBinLabel(6,"30<p_{T}^{Z}<1000 GeV");
1793 +  data->GetXaxis()->SetBinLabel(7,"#alpha < 0.3");
1794 +  data->GetXaxis()->SetBinLabel(8,"#alpha < 0.2");
1795 +  data->GetXaxis()->SetBinLabel(9,"#alpha < 0.15");
1796 +  data->GetXaxis()->SetBinLabel(10,"#alpha < 0.1");
1797 +  data->GetXaxis()->SetBinLabel(11,"#alpha < 0.05");
1798 +  data->GetXaxis()->LabelsOption("v");
1799 +  
1800 +  stringstream purityinfo;
1801 +  purityinfo << "Purity: " << std::setprecision(3) << 100*zb/mcsum << " %";
1802 +  stringstream neventsinfo;
1803 +  neventsinfo << "Nevents: " << data->GetBinContent(data->GetNbinsX());
1804 +  TH1F *crap = new TH1F("crap","",1,0,1);
1805 +  crap->SetLineColor(kWhite);
1806 +  leg->AddEntry(crap,purityinfo.str().c_str(),"l");
1807 +  leg->AddEntry(crap,neventsinfo.str().c_str(),"l");
1808 +  
1809 +  data->Draw("e1");
1810 +  mcm.Draw("histo,same");
1811 +  data->Draw("same,e1,axis");
1812 +  data->Draw("same,e1");
1813 + //  data->Draw("same,TEXT");
1814 +  
1815 +  leg->Draw();
1816 +  
1817 +  DrawPrelim();
1818 +  
1819 +  CompleteSave(can,"CutFlow___"+identifier);
1820 +  
1821 +  delete crap;
1822 +  delete data;
1823 +  CleanLegends();
1824 +  DeleteStack(mcm);
1825 +
1826 +  
1827 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines