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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines