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.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("Zb3010_bTagProbCSVBP[0]>0.898");
28 < TCut EtaB("abs(Zb3010_pfJetGoodEta[0])<1.3");
29 < TCut PhiZcut("abs(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  
# Line 62 | Line 127 | void print_yield(TCut cut) {
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;
72  if(speciallabel!="") {
73    speciall = new TText(0.2,0.8,speciallabel.c_str());
74    speciall->Draw();
75  }
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 84 | 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);
94
95  
160    
161    
162    ZbData::data_over_mc.push_back(datahisto->Integral()/CollapseStack(mcstack)->Integral());
# Line 101 | Line 165 | void draw_kin_variable(string variable,
165    delete ckin;
166   }
167    
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  
168   void print_all_b_yields() {
169    cout << "Basic selection with a b jet" << endl;
170 <  print_yield(ZplusBsel&&"Zb3010_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"&&"(Zb3010_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"&&"(Zb3010_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"&&"(Zb3010_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"&&"(Zb3010_alpha)<0.1");
131 < //  cout << "#alpha < 0.05" << endl;
132 < //  print_yield(ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000"&&"(Zb3010_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("Zb3010_pfJetGoodNumBtag>0")) << ")";
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>10&&pt<1000")) << ")";
199 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb3010_alpha<0.3")) << ")";
200 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb3010_alpha<0.2")) << ")";
201 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb3010_alpha<0.15")) << ")";
202 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb3010_alpha<0.1")) << ")";
203 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut("pt>10&&pt<1000&&Zb3010_alpha<0.05")) << ")";
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");
# Line 188 | Line 244 | void DrawEvilCutFlow() {
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,"10<p_{T}^{Z}<1000 GeV");
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");
# Line 197 | Line 253 | void DrawEvilCutFlow() {
253    data->GetXaxis()->LabelsOption("v");
254    
255    data->Draw("e1");
256 <  mcm.Draw("same");
256 >  mcm.Draw("histo,same");
257    data->Draw("same,e1,axis");
258    data->Draw("same,e1");
259   //  data->Draw("same,TEXT");
# Line 210 | Line 266 | void DrawEvilCutFlow() {
266   }
267  
268   void draw_Zb_kin_vars() {
269 <   draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Z p_{T}","Official/Zpt",1);
270 <   draw_kin_variable("Zb3010_pfJetGoodPt[1]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Sub-Leading Jet Pt","Official/Jet2Pt",1);
271 <   draw_kin_variable("Zb3010_pfJetGoodPt[0]",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",25,0,200,"Leading Jet Pt (B)","Official/LeadingJetPt",1);
272 <   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);
273 <   draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<50",   40,0,2,"#alpha","Official/alpha_pt_30_to_50",1);
274 <   draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>50&&pt<75",  40,0,2,"#alpha","Official/alpha_50_to_75",1);
275 <   draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>75&&pt<125", 40,0,2,"#alpha","Official/alpha_pt_75_to_125",1);
276 <   draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>125&&pt<1000",40,0,2,"#alpha","Official/alpha_pt_125_to_1000",1);
277 <    draw_kin_variable("Zb3010_alpha",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>30&&pt<1000",40,0,2,"#alpha","Official/alpha_pt_30_to_1000",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("pfBJetDphiZ[0]",ZplusBsel&&LeadingB&&"pt>10&&pt<1000&&pfBJetDphiZ[0]>0",30,0,3.2,"#delta#phi (Z,b lead)","DeltaPhiZBlead",0);
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>10&&pt<1000",20,0,200,"p_{T}^{l1}","Lep/pt1",1);
283 <  draw_kin_variable("pt1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id1==0",20,0,200,"p_{T}^{e1}","Lep/pt1_e",1);
284 <  draw_kin_variable("pt1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id1==1",20,0,200,"p_{T}^{#mu1}","Lep/pt1_m",1);
285 <  draw_kin_variable("pt2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,0,200,"p_{T}^{l2}","Lep/pt2",1);
286 <  draw_kin_variable("pt2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id2==0",20,0,200,"p_{T}^{e2}","Lep/pt2_e",1);
287 <  draw_kin_variable("pt2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000&&id2==1",20,0,200,"p_{T}^{#mu2}","Lep/pt2_m",1);
288 <  draw_kin_variable("eta1",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,-3.1,3.1,"#eta^{l1}","Lep/eta1",1);
289 <  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);
290 <  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);
291 <  draw_kin_variable("eta2",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",20,-3.1,3.1,"#eta^{l1}","Lep/eta2",1);
292 <  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);
293 <  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);
294 <  draw_kin_variable("numVtx",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",30,0,30,"N(Vtx)","Lep/nVtx",1);
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"&&"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");
301 <  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");
302 <  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");
303 <  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");
304 <  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");
305 <  
306 <  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");
307 <  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");
308 <  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");
309 <  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");
310 <  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");
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 <  hdata->Fit("gaus","QE");
330 <  hmc->Fit("gaus","QE");
331 <  TF1 *fdata = (TF1*) hdata->GetFunction("gaus");
332 <  TF1 *fmc   = (TF1*) hmc->GetFunction("gaus");
333 <    
334 < /*  float a=hdata->GetMean();
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();
340    float da=hdata->GetMeanError();
341 <  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);
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  
280 //    cout << a << "+/-" << da << "        " << b << "=/-" << db << endl;
281
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=5;
444 <  float alphacuts[nalphacuts] = {0.1,0.15,0.2,0.25,0.3};
292 <  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 <  }
443 >  const int nalphacuts=6;
444 >  float alphacuts[nalphacuts] = {0.1,0.15,0.2,0.25,0.3,0.35};
445    
446    const int nptcuts=5;
447    float ptcuts[nptcuts]={30,50,75,125,1000};
448    
449 +  
450 +  
451    float MPF_Results[nalphacuts][nptcuts];
452    float MPF_Errors[nalphacuts][nptcuts];
453    float RABS_Results[nalphacuts][nptcuts];
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] << ") && (Zb3010_alpha<" << alphacuts[ia] << "))";
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("mpf",TCut(basecut && specialcut.str().c_str()));
472 <      Value RABS_data_over_mc = get_Zb_data_over_mc("Zb3010_pfJetGoodPt[0]/pt",TCut(basecut && specialcut.str().c_str()));
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 329 | 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 *FaceValueAtPoint3 = 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 341 | 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();
344    for(int ia=0;ia<nalphacuts;ia++) {
345      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;
502      
503 <    filename.str("");
503 >    int rabs_counter=0;
504 >    int mpf_counter=0;
505      
506 <    rabs_gr->SetMarkerStyle(21);
507 <    rabs_gr->SetMarkerColor(kBlue);
508 <    rabs_gr->Fit("pol1","QE"); // quiet, use minos
509 <    rabs_gr->Draw("AP");
510 <    rabs_gr->GetXaxis()->SetTitle("#alpha");
511 <    rabs_gr->GetXaxis()->CenterTitle();
512 <    rabs_gr->GetYaxis()->SetTitle("<R_{abs}>_{data}/<R_{abs}>_{mc}");
513 <    rabs_gr->GetYaxis()->CenterTitle();
514 <    
515 <    TF1 *rabs_pol=(TF1*)rabs_gr->GetFunction("pol1");
516 <    float rabs_a=rabs_pol->GetParameter(0);
517 <    float rabs_b=rabs_pol->GetParameter(1);
518 <    RABS_FinalGraph->SetPoint(ipt,0.5*(ptcuts[ipt]+ptcuts[ipt+1]),rabs_a);
519 <    RABS_FinalGraph->SetPointError(ipt,0,rabs_pol->GetParError(0));
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 <    cout << "!+!+!+!+!+!+!+!+!+ Just added a point to the final plot : " << rabs_a << " +/- " << rabs_pol->GetParError(0) << endl;
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      
406    stringstream rabs_info;
407    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() << "}";
408    TText *rabs_mark = write_title(rabs_info.str());
409    rabs_mark->SetX(0.75);
410    rabs_mark->SetTextSize(0.03);
411    rabs_mark->SetY(0.75);
412    rabs_mark->Draw();
539      
540      
541 <
542 <    RABS_ExtraPolatedResults[ipt]=rabs_a;
543 <    filename << filenamebkp << "__RABS";
544 <    DrawPrelim();
545 <    CompleteSave(can,filename.str());
546 <    cout << "RABS : " << rabs_a << " + " << rabs_b << " * alpha " << endl;
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 <  MPF_FinalGraph->SetMarkerStyle(21);
659 <  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());
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 <  TCanvas *FaceValueCanvas = new TCanvas("FaceValueCanvas","FaceValueCanvas");
727 <  FaceValueAtPoint3->SetMarkerStyle(21);
728 <  FaceValueAtPoint3->SetMarkerStyle(21);
729 <  FaceValueAtPoint3->Fit("pol0","QE"); // quiet, use minos
730 <  FaceValueAtPoint3->Draw("AP");
731 <  FaceValueAtPoint3->GetXaxis()->SetTitle("p_{T}^{Z}");
732 <  FaceValueAtPoint3->GetXaxis()->CenterTitle();
733 <  FaceValueAtPoint3->GetYaxis()->SetTitle("data/mc for #alpha<0.3");
734 <  FaceValueAtPoint3->GetYaxis()->CenterTitle();
735 <  FaceValueAtPoint3->Draw("AP");
736 <  TF1 *faceval_pol0=(TF1*)FaceValueAtPoint3->GetFunction("pol0");
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<0.3)}";;
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);
# Line 499 | Line 750 | void new_data_mc_agreement_2d() {
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.str("");
755    filename2 << "Extrapolation/FINAL_RESULT_MPF_FaceValp3";
756 <  CompleteSave(can,filename2.str());
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 >  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_FaceValp3";
788 >  CompleteSave(can,ContainerName+"/"+filename2.str());
789    
790    cout << "FINAL RESULTS: " << endl;
791 <  cout << "MPF : " << MPFResult  << " +/- " << MPFResultError  << endl;
792 <  cout << "Rabs: " << RabsResult << " +/- " << RabsResultError << endl;
793 <  cout << "Face value at 0.3 :" << FaceValResult << " +/- " << FaceValResultError << 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 <  
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  
# Line 533 | Line 823 | void DoPUStudy(string identifier) {
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,10,"MPF","events",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&SpecialCut,mc,luminosity);
831 <    dalpha[i] = allsamples.Draw("dalpha"+any2string(i),"mpf",1000,0,10,"MPF","events",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&SpecialCut,data,luminosity);
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();
# Line 548 | Line 839 | void DoPUStudy(string identifier) {
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;
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++) {
842      delete malpha[i];
843      delete dalpha[i];
844    }
845 <  */
845 >  
846 >  delete can;
847    
848   }
849  
850   void ScenarioComparison() {
851 <  
851 > //very dumb way to do this.
852 >
853    TGraphAsymmErrors *gr[5];
854    TF1 *fit[5];
855 <  bool dofit=false;
855 >  bool dofit=true;
856    
857    TCanvas *can = new TCanvas("can","can",500,500);
858    
# Line 576 | Line 860 | void ScenarioComparison() {
860    leg->SetBorderSize(0);
861    leg->SetFillColor(kWhite);
862    
863 <  for(int i=0;i<5;i++) {
863 >  for(int i=0;i<6;i++) {
864      gr[i] = new TGraphAsymmErrors();
865 <    double x[4]   = {5,12.5,17.5,20};
866 <    double dxl[4] = {5,2.5,2.5,2.5};
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.008,1.013,1.003,1.007};
874 <      double dyl[4] = {0.011,0.009,0.013,0.020};
875 <      double dyh[4] = {0.011,0.009,0.013,0.020};
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.008+0.001,1.013+0.001,1.003+0.001,1.007+0.001};
882 <      double dyl[4] = {0.011,0.009,0.013,0.020};
883 <      double dyh[4] = {0.011,0.009,0.013,0.020};
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/10";
885 >      name="30/15";
886        color="#2464bc";
887      }
888      if(i==2) {
889 <      double y[4]   = {1.014,1.026,1.014,1.059};
890 <      double dyl[4] = {0.011,0.010,0.014,0.023};
891 <      double dyh[4] = {0.011,0.010,0.014,0.023};
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.015,1.020,1.008,1.050};
898 <      double dyl[4] = {0.011,0.010,0.014,0.022};
899 <      double dyh[4] = {0.011,0.010,0.014,0.022};
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="20/15";
901 >      name="CHS 30/30";
902        color="#c72f3c";
903      }
904      if(i==4) {
905 <      double y[4]   = {1.015+0.001,1.020+0.001,1.008+0.001,1.050+0.001};
906 <      double dyl[4] = {0.011,0.010,0.014,0.022};
907 <      double dyh[4] = {0.011,0.010,0.014,0.022};
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="20/20";
909 >      name="CHS 30/15";
910        color="#7cb433";
911      }
912 <    
913 <    
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}");
# Line 655 | Line 947 | void ScenarioComparison() {
947   }
948  
949   void ScenarioComparisonInclusive() {
950 <  
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.5,0.45);
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<5;i++) {
961 >  for(int i=0;i<6;i++) {
962      gr[i] = new TGraphAsymmErrors();
963 <    double x[4]   = {5,12.5,17.5,20};
964 <    double dxl[4] = {5,2.5,2.5,2.5};
965 <    double dxh[4] = {5,2.5,2.5,10};
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.01103,1.01496,1.01486,1.02785};
972 <      double dyl[4] = {0.00235044,0.00225264,0.00313574,0.00541047};
973 <      double dyh[4] = {0.00235044,0.00225264,0.00313574,0.00541047};
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.01103+0.001,1.01496+0.001,1.01486+0.001,1.02785+0.001};
980 <      double dyl[4] = {0.00235044,0.00225264,0.00313574,0.00541047};
981 <      double dyh[4] = {0.00235044,0.00225264,0.00313574,0.00541047};
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/10";
983 >      name="30/15";
984        color="#2464bc";
985      }
986      if(i==2) {
987 <      double y[4]   = {1.01575,1.02879,1.0325,1.05456};
988 <      double dyl[4] = {0.00288281,0.00278536,0.00367451,0.00590421};
989 <      double dyh[4] = {0.00288281,0.00278536,0.00367451,0.00590421};
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.01221,1.01922,1.02396,1.04677};
996 <      double dyl[4] = {0.00263821,0.00260853,0.00353673,0.00584728};
997 <      double dyh[4] = {0.00263821,0.00260853,0.00353673,0.00584728};
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="20/15";
999 >      name="CHS 30/30";
1000        color="#c72f3c";
1001      }
1002      if(i==4) {
1003 <      double y[4]   = {1.01221+0.001,1.01922+0.001,1.02396+0.001,1.04677+0.001};
1004 <      double dyl[4] = {0.00263821,0.00260853,0.00353673,0.00584728};
1005 <      double dyh[4] = {0.00263821,0.00260853,0.00353673,0.00584728};
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="20/20";
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 <    
1019 >    gStyle->SetOptFit(0);
1020      gr[i]->SetTitle();
1021      gr[i]->GetXaxis()->SetTitle("N(Vtx)");
1022      gr[i]->GetYaxis()->SetTitle("<MPF>_{data}/<MPF>_{mc}");
# Line 732 | Line 1032 | void ScenarioComparisonInclusive() {
1032        fit[i] = (TF1*)gr[i]->GetFunction("pol1");
1033        fit[i]->SetLineColor(TColor::GetColor(color.c_str()));
1034      }
1035 <    leg->AddEntry(gr[i],name.c_str(),"l");
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    }
# Line 748 | Line 1052 | 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");
# Line 755 | Line 1065 | void compare_selection(string identifier
1065        recognized_scenario=true;
1066    }
1067    
1068 <  if(identifier=="Zb3010") {
1069 <      LeadingB=TCut ("Zb3010_bTagProbCSVBP[0]>0.898");
1070 <      EtaB=TCut("abs(Zb3010_pfJetGoodEta[0])<1.3");
1071 <      PhiZcut=TCut("abs(Zb3010_pfJetDphiZ[0])>2.7");
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    
# Line 769 | Line 1079 | void compare_selection(string identifier
1079        recognized_scenario=true;
1080    }
1081    
1082 <  if(identifier=="Zb301030") {
1083 <      LeadingB=TCut ("Zb301030_bTagProbCSVBP[0]>0.898");
1084 <      EtaB=TCut("abs(Zb301030_pfJetGoodEta[0])<1.3");
1085 <      PhiZcut=TCut("abs(Zb301030_pfJetDphiZ[0])>2.7");
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    
# Line 783 | Line 1093 | void compare_selection(string identifier
1093        recognized_scenario=true;
1094    }
1095    
1096 <  if(identifier=="Zb301010") {
1097 <      LeadingB=TCut ("Zb301010_bTagProbCSVBP[0]>0.898");
1098 <      EtaB=TCut("abs(Zb301010_pfJetGoodEta[0])<1.3");
1099 <      PhiZcut=TCut("abs(Zb301010_pfJetDphiZ[0])>2.7");
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    
# Line 797 | Line 1107 | void compare_selection(string identifier
1107        recognized_scenario=true;
1108    }
1109    
1110 <  if(identifier=="Zb301010") {
1111 <      LeadingB=TCut ("Zb301010_bTagProbCSVBP[0]>0.898");
1112 <      EtaB=TCut("abs(Zb301010_pfJetGoodEta[0])<1.3");
1113 <      PhiZcut=TCut("abs(Zb301010_pfJetDphiZ[0])>2.7");
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    
# Line 811 | Line 1121 | void compare_selection(string identifier
1121        recognized_scenario=true;
1122    }
1123    
1124 <  if(identifier=="Zb3010_SecEta3") {
1125 <      LeadingB=TCut ("Zb3010_SecEta3_bTagProbCSVBP[0]>0.898");
1126 <      EtaB=TCut("abs(Zb3010_SecEta3_pfJetGoodEta[0])<1.3");
1127 <      PhiZcut=TCut("abs(Zb3010_SecEta3_pfJetDphiZ[0])>2.7");
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=="Zb3010_SecEta5") {
1132 <      LeadingB=TCut ("Zb3010_SecEta5_bTagProbCSVBP[0]>0.898");
1133 <      EtaB=TCut("abs(Zb3010_SecEta5_pfJetGoodEta[0])<1.3");
1134 <      PhiZcut=TCut("abs(Zb3010_SecEta5_pfJetDphiZ[0])>2.7");
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=="Zb3010_p5Clean") {
1139 <      LeadingB=TCut ("Zb3010_p5Clean_bTagProbCSVBP[0]>0.898 && Zb3010_p5Clean_IsClean");
1140 <      EtaB=TCut("abs(Zb3010_p5Clean_pfJetGoodEta[0])<1.3 && Zb3010_p5Clean_IsClean");
1141 <      PhiZcut=TCut("abs(Zb3010_p5Clean_pfJetDphiZ[0])>2.7 && Zb3010_p5Clean_IsClean");
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=="Zb3010CHS") {
1146 <      LeadingB=TCut ("Zb3010CHS_bTagProbCSVBP[0]>0.898");
1147 <      EtaB=TCut("abs(Zb3010CHS_pfJetGoodEta[0])<1.3");
1148 <      PhiZcut=TCut("abs(Zb3010CHS_pfJetDphiZ[0])>2.7");
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    
# Line 847 | Line 1169 | void compare_selection(string identifier
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 < //    ScenarioComparison();
1180 < //    ScenarioComparisonInclusive();
1181 <  
1182 <  
855 < //     DoPUStudy(identifier);
856 <  
857 < //   SpecialCutFlow(identifier);
858 < //    draw_kin_variable("pt",ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&"pt>10&&pt<1000",17000,30,200,"Z p_{T}","Official/"+identifier+"/Zpt__"+identifier,1);
859 < //   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);
860 < //   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);
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>10&&pt<1000&&pfBJetDphiZ[0]>0",30,0,3.2,"#delta#phi (Z,b lead)","Official/"+identifier+"/DeltaPhiZBlead__"+identifier,0);
868 <  
869 < //   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");
870 < //   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");
871 <
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 < //   */
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 do_basic_ZB_analysis() {
878 <  
879 <  
880 <  TCanvas *zbcanvas = new TCanvas("zbcanvas","zbcanvas");
1196 > void GetNumberEventsInsideOutsideAlphaWindow(TCut specialcut, string title) {
1197    
1198 < //     compare_selection("Zb3010_p5Clean");
1199 < //     compare_selection("Zb3010CHS");
1200 < //     compare_selection("Zb3010");
1201 < //     compare_selection("Zb301030");
1202 < //     compare_selection("Zb1530");
1203 < //     compare_selection("Zb301010");
1204 < //     compare_selection("Zb3010_SecEta3");
1205 < //     compare_selection("Zb3010_SecEta5");
1206 < //     compare_selection("Zb1510");
1207 < //     compare_selection("Zb301010");
1208 < //     compare_selection("ZbMikko");
1209 < //     compare_selection("Zb3010");
1210 < //     compare_selection("Zb40");
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 +  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 < //  print_all_b_yields();
898 < //  draw_mpf_vars();
899 < //  DrawEvilCutFlow();
1251 >  delete ca;
1252    
901 //  draw_Zb_kin_vars();
1253    
1254 <  new_data_mc_agreement_2d();
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    
1425    
1426    delete zbcanvas;
# Line 927 | Line 1447 | void SpecialCutFlow(string identifier) {
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>10&&pt<1000").c_str())) << ")";
1451 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.3").c_str())) << ")";
1452 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.2").c_str())) << ")";
1453 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.15").c_str())) << ")";
1454 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.1").c_str())) << ")";
1455 <  MegaCut << " + 1*(" << (const char*) (ZplusBsel&&LeadingB&&EtaB&&PhiZcut&&TCut(((string)"pt>10&&pt<1000&&"+identifier+"_alpha<0.05").c_str())) << ")";
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");
# Line 983 | Line 1503 | void SpecialCutFlow(string identifier) {
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,"10<p_{T}^{Z}<1000 GeV");
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");
# Line 1001 | Line 1521 | void SpecialCutFlow(string identifier) {
1521    leg->AddEntry(crap,neventsinfo.str().c_str(),"l");
1522    
1523    data->Draw("e1");
1524 <  mcm.Draw("same");
1524 >  mcm.Draw("histo,same");
1525    data->Draw("same,e1,axis");
1526    data->Draw("same,e1");
1527   //  data->Draw("same,TEXT");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines