ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/ZbTools.C
Revision: 1.20
Committed: Thu Jan 17 16:25:46 2013 UTC (12 years, 3 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.19: +557 -112 lines
Log Message:
Uploaded version of ZbAnalysis on Pablo's request

File Contents

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