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.2 by buchmann, Tue Jul 10 16:00:42 2012 UTC vs.
Revision 1.19 by buchmann, Mon Jan 7 14:42:35 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines