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.20 by buchmann, Thu Jan 17 16:25:46 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines