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.10 by buchmann, Wed Nov 14 14:52:54 2012 UTC vs.
Revision 1.29 by buchmann, Fri Apr 26 07:18:47 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines