AliPhysics  86877f2 (86877f2)
ComputeEfficiencyFromCombinHF.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TH3F.h>
3 #include <TH1D.h>
4 #include <TH2D.h>
5 #include <TPaveStats.h>
6 #include <TMath.h>
7 #include <TFile.h>
8 #include <TF1.h>
9 #include <TCanvas.h>
10 #include <TStyle.h>
11 #include <TLegend.h>
12 #include <TLatex.h>
13 #include <TSystem.h>
14 #include <TProfile.h>
15 #include <TLegendEntry.h>
16 #endif
17 
19 
20 const Int_t nPtBins=8;
21 Double_t binLims[nPtBins+1]={0.,1.,2.,3.,4.,5.,6.,8.,12.};
22 
23 TString fileNameMC="AnalysisResultsMC_train471472.root";
24 TString suffix="c3SigPID_Pt400_EM1";
25 TString fileNameToy="Acceptance_Toy_D0Kpi_yfid08_etaDau09_ptDau100_FONLL5ptshape.root";
29 
30 
32 
33 
34  // multiplicity weights
35  TString fileWeightName="trackletsWeightsMultInt_LHC13d3_08092014.root";
36  TString histoWeightName[3];
37  histoWeightName[0]="hNtrUnCorrEvWithCand";
38  histoWeightName[1]="hNtrUnCorrEvWithD";
39  histoWeightName[2]="hNtrUnCorrEvSel";
40  Int_t wcol[3]={kRed+1,kGreen+1,4};
41  Int_t wmark[3]={22,23,26};
42 
43 
44  // pt wieghts
45  TF1* funcPtWeight=0x0;
47  funcPtWeight=new TF1("funcPtWeight","([0]*x)/TMath::Power([2],(1+TMath::Power([3],x/[1])))+[4]*TMath::Exp([5]+[6]*x)+[7]*TMath::Exp([8]*x)",0.15,30.);
48  funcPtWeight->SetParameters(2.94999e+00,3.47032e+00,2.81278e+00,2.5,1.93370e-02,3.86865e+00,-1.54113e-01,8.86944e-02,2.56267e-02);
49  }else if (ptWeight==kFONLL7overLHC10f6a){
50  funcPtWeight=new TF1("funcPtWeight","([0]*x)/TMath::Power([2],(1+TMath::Power([3],x/[1])))+[4]*TMath::Exp([5]+[6]*x)+[7]*TMath::Exp([8]*x)",0.15,40.);
51  funcPtWeight->SetParameters(2.41522e+01,4.92146e+00,6.72495e+00,2.5,6.15361e-03,4.78995e+00,-4.29135e-01,3.99421e-01,-1.57220e-02);
52  }else if (ptWeight==kFONLL7overLHC10f7a){
53  funcPtWeight=new TF1("funcPtWeight","([0]*x)/TMath::Power([2],(1+TMath::Power([3],x/[1])))+[4]*TMath::Exp([5]+[6]*x)+[7]*TMath::Exp([8]*x)",0.15,40.);
54  funcPtWeight->SetParameters(3.59525,2.67871,2.70402,1.72578,4.78167e-03,4.90992,-1.26424e-01,8.21269e-02,-1.26425e-01);
55  }else if(ptWeight==kFLAToverLHC10f7a){
56  funcPtWeight=new TF1("funcPtWeight","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.15,40.);
57  funcPtWeight->SetParameters(1.99498e-01,-9.90532e-02,3.03645e-02,7.42483e-04);
58  }else{
59  funcPtWeight=new TF1("funcPtWeight","[0]");
60  funcPtWeight->SetParameter(0,1.);
61  }
62 
63  Int_t ptcol[nPtBins]={1,kRed+1,kGreen+2,4,kOrange+2,kMagenta,kAzure+5,kMagenta+2};
64 
65 
66  TString dirName=Form("PWG3_D2H_InvMassDzeroLowPt%s",suffix.Data());
67  TString lstName=Form("coutputDzero%s",suffix.Data());
68  TFile* fil=new TFile(fileNameMC.Data());
69  TDirectoryFile* df=(TDirectoryFile*)fil->Get(dirName.Data());
70  TList* l=(TList*)df->Get(lstName.Data());
71  // l->ls();
72 
73 
74 
75 
76  TH2F* hEventMultZv=(TH2F*)l->FindObject("hEventMultZv");
77  if(hEventMultZv){
78  TH2F* hEventMultZvEvSel=(TH2F*)l->FindObject("hEventMultZvEvSel");
79  hEventMultZv->GetXaxis()->SetTitle("Z_{vertex} (cm)");
80  hEventMultZv->GetYaxis()->SetTitle("N_{tracklets}");
81  hEventMultZvEvSel->GetXaxis()->SetTitle("Z_{vertex} (cm)");
82  hEventMultZvEvSel->GetYaxis()->SetTitle("N_{tracklets}");
83 
84  Int_t binzm10=hEventMultZvEvSel->GetXaxis()->FindBin(-9.999);
85  Int_t binzp10=hEventMultZvEvSel->GetXaxis()->FindBin(9.999);
86  printf("%d %f --- %d %f\n",binzm10,hEventMultZvEvSel->GetXaxis()->GetBinLowEdge(binzm10),
87  binzp10,hEventMultZvEvSel->GetXaxis()->GetBinUpEdge(binzp10));
88  TH1D* hMultAllEv=hEventMultZv->ProjectionY("hMultAllEv");
89  TH1D* hMultEvZ10=hEventMultZv->ProjectionY("hMultEvZ10",binzm10,binzp10);
90  TH1D* hMultEvSel=hEventMultZvEvSel->ProjectionY("hMultEvSel");
91  hMultAllEv->SetLineColor(1);
92  hMultEvZ10->SetLineColor(kGreen+2);
93  hMultEvSel->SetLineColor(6);
94  hMultAllEv->GetYaxis()->SetTitle("Entries");
95 
96  TH1D* hZvAllEv=hEventMultZv->ProjectionX("hZvAllEv");
97  TH1D* hZvEvSel=hEventMultZvEvSel->ProjectionX("hZvEvSel");
98  hZvAllEv->SetLineColor(1);
99  hZvEvSel->SetLineColor(6);
100  hZvAllEv->GetYaxis()->SetTitle("Entries");
101 
102  TH1D* hRatioMultEv=(TH1D*)hMultEvSel->Clone("hRatioMultEv");
103  hRatioMultEv->Divide(hMultEvSel,hMultEvZ10,1.,1.,"B");
104  hRatioMultEv->SetStats(0);
105  hRatioMultEv->GetYaxis()->SetTitle("Ratio");
106  hRatioMultEv->SetLineColor(4);
107  TH1D* hRatioMultEvAll=(TH1D*)hMultEvSel->Clone("hRatioMultEvAll");
108  hRatioMultEvAll->Divide(hMultEvSel,hMultAllEv,1.,1.,"B");
109  hRatioMultEvAll->SetStats(0);
110  hRatioMultEvAll->GetYaxis()->SetTitle("Ratio");
111  hRatioMultEvAll->SetLineColor(6);
112  TH1D* hRatioMultEvZ10=(TH1D*)hMultEvZ10->Clone("hRatioMultEvZ10");
113  hRatioMultEvZ10->Divide(hMultEvZ10,hMultAllEv,1.,1.,"B");
114  hRatioMultEvZ10->SetStats(0);
115  hRatioMultEvZ10->GetYaxis()->SetTitle("Ratio");
116  TH1D* hRatioZvEv=(TH1D*)hZvEvSel->Clone("hRatioZvEv");
117  hRatioZvEv->Divide(hZvEvSel,hZvAllEv,1.,1.,"B");
118  hRatioZvEv->SetStats(0);
119  hRatioZvEv->GetYaxis()->SetTitle("Ratio");
120 
121  TCanvas* cev=new TCanvas("cev","Event selection",1300,950);
122  cev->Divide(2,2);
123  cev->cd(1);
124  gPad->SetLogy();
125  gPad->SetTickx();
126  gPad->SetTicky();
127  hMultAllEv->GetXaxis()->SetRangeUser(0.,maxMult);
128  hMultAllEv->Draw();
129  gPad->Update();
130  TPaveStats *sta=(TPaveStats*)hMultAllEv->GetListOfFunctions()->FindObject("stats");
131  sta->SetY1NDC(0.7);
132  sta->SetY2NDC(0.89);
133  gPad->Modified();
134  hMultEvZ10->Draw("sames");
135  gPad->Update();
136  TPaveStats *stz=(TPaveStats*)hMultEvZ10->GetListOfFunctions()->FindObject("stats");
137  stz->SetY1NDC(0.5);
138  stz->SetY2NDC(0.69);
139  stz->SetTextColor(hMultEvZ10->GetLineColor());
140  gPad->Modified();
141  hMultEvSel->Draw("sames");
142  gPad->Update();
143  TPaveStats *stb=(TPaveStats*)hMultEvSel->GetListOfFunctions()->FindObject("stats");
144  stb->SetY1NDC(0.3);
145  stb->SetY2NDC(0.49);
146  stb->SetTextColor(hMultEvSel->GetLineColor());
147  gPad->Modified();
148  cev->cd(3);
149  gPad->SetTickx();
150  gPad->SetTicky();
151  hRatioMultEvAll->SetMinimum(0.);
152  hRatioMultEvAll->GetXaxis()->SetRangeUser(0.,maxMult);
153  hRatioMultEvAll->Draw();
154  hRatioMultEvZ10->Draw("same");
155  hRatioMultEv->Draw("same");
156  TLegend* leg=new TLegend(0.45,0.3,0.89,0.7);
157  leg->AddEntry(hRatioMultEvAll,"EvSel / AllEv","L")->SetTextColor(hRatioMultEvAll->GetLineColor());
158  leg->AddEntry(hRatioMultEvZ10,"Ev(|z|<10) / AllEv","L")->SetTextColor(hRatioMultEvZ10->GetLineColor());
159  leg->AddEntry(hRatioMultEv,"EvSel / Ev(|z|<10)","L")->SetTextColor(hRatioMultEv->GetLineColor());
160  leg->Draw();
161  cev->cd(2);
162  gPad->SetTickx();
163  gPad->SetTicky();
164  hZvAllEv->Draw();
165  gPad->Update();
166  TPaveStats *stc=(TPaveStats*)hZvAllEv->GetListOfFunctions()->FindObject("stats");
167  stc->SetY1NDC(0.7);
168  stc->SetY2NDC(0.89);
169  gPad->Modified();
170  hZvEvSel->Draw("sames");
171  gPad->Update();
172  TPaveStats *std=(TPaveStats*)hZvEvSel->GetListOfFunctions()->FindObject("stats");
173  std->SetY1NDC(0.5);
174  std->SetY2NDC(0.69);
175  std->SetTextColor(hZvEvSel->GetLineColor());
176  gPad->Modified();
177  cev->cd(4);
178  gPad->SetTickx();
179  gPad->SetTicky();
180  hRatioZvEv->SetMinimum(0.85);
181  hRatioZvEv->SetMaximum(1.01);
182  hRatioZvEv->Draw();
183  cev->SaveAs(Form("figures/FracEvSel%s.eps",suffix.Data()));
184  }
185 
186 
187 
188 
189  TH3F* hPtVsYVsMultReco=(TH3F*)l->FindObject("hPtVsYVsMultReco");
190  TH3F* hPtVsYVsMultGenAccEvSel=(TH3F*)l->FindObject("hPtVsYVsMultGenAccEvSel");
191  TH3F* hPtVsYVsMultGenAcc=(TH3F*)l->FindObject("hPtVsYVsMultGenAcc");
192  TH3F* hPtVsYVsMultGenLimAcc=(TH3F*)l->FindObject("hPtVsYVsMultGenLimAcc");
193 
194  TH2D* hypt=(TH2D*)hPtVsYVsMultGenAcc->Project3D("yx");
195  hypt->SetTitle("Generated in acceptance, all multiplcities");
196  TH2D* hptmult=(TH2D*)hPtVsYVsMultGenLimAcc->Project3D("xz");
197  hptmult->SetTitle("Generated in |y|<0.5");
198  hptmult->SetStats(0);
199  hypt->SetStats(0);
200  hypt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
201  hypt->GetYaxis()->SetTitle("y");
202  hptmult->GetYaxis()->SetTitle("p_{T} (GeV/c)");
203  hptmult->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
204  hptmult->GetXaxis()->SetRangeUser(0.,maxMult);
205 
206  TProfile* hMeanPtMult=hptmult->ProfileX("hMeanPtMult");
207  TCanvas* c0=new TCanvas("c0","2D plots",1200,600);
208  c0->Divide(2,1);
209  c0->cd(1);
210  gPad->SetLogz();
211  gPad->SetRightMargin(0.12);
212  hypt->Draw("colz");
213  c0->cd(2);
214  gPad->SetLogz();
215  gPad->SetRightMargin(0.13);
216  hptmult->Draw("colz");
217  hMeanPtMult->Draw("same");
218 
219 
220  TH1D* hPtReco=hPtVsYVsMultReco->ProjectionX("hPtReco");
221  TH1D* hPtGenAcc=hPtVsYVsMultGenAcc->ProjectionX("hPtGenAcc");
222  TH1D* hPtGenAccEvSel=0x0;
223  if(hPtVsYVsMultGenAccEvSel) hPtGenAccEvSel=hPtVsYVsMultGenAccEvSel->ProjectionX("hPtGenAccEvSel");
224  TH1D* hPtGenLimAcc=hPtVsYVsMultGenLimAcc->ProjectionX("hPtGenLimAcc");
225  TH1D* hPtRecoR=(TH1D*)hPtReco->Rebin(nPtBins,"hPtRecoReb",binLims);
226  TH1D* hPtGenAccR=(TH1D*)hPtGenAcc->Rebin(nPtBins,"hPtRecoReb",binLims);
227  TH1D* hPtGenLimAccR=(TH1D*)hPtGenLimAcc->Rebin(nPtBins,"hPtRecoReb",binLims);
228  TH1D* hEffVsPt=(TH1D*)hPtReco->Clone("hEff");
229  hEffVsPt->Divide(hPtReco,hPtGenAcc,1,1,"B");
230  TH1D* hEffVsPtR=(TH1D*)hPtRecoR->Clone("hEff");
231  hEffVsPtR->Divide(hPtRecoR,hPtGenAccR,1,1,"B");
232  hEffVsPt->SetStats(0);
233  hEffVsPtR->SetStats(0);
234  TH1D* hAccVsPt=(TH1D*)hPtGenAcc->Clone("hAcc");
235  hAccVsPt->Divide(hPtGenAcc,hPtGenLimAcc,1,1,"B");
236  TH1D* hAccVsPtR=(TH1D*)hPtGenAccR->Clone("hAcc");
237  hAccVsPtR->Divide(hPtGenAccR,hPtGenLimAccR,1,1,"B");
238  hAccVsPt->SetStats(0);
239  hAccVsPtR->SetStats(0);
240  TH1D* hEvSelEffVsPt=0x0;
241  if(hPtGenAccEvSel){
242  hEvSelEffVsPt=(TH1D*)hPtGenAccEvSel->Clone("hEvSelEff");
243  hEvSelEffVsPt->Divide(hPtGenAccEvSel,hPtGenAcc,1,1,"B");
244  hEvSelEffVsPt->SetStats(0);
245  }
246 
247  TFile* fileAccToy=new TFile(fileNameToy.Data());
248  TH1F* hPtGenAccToy=(TH1F*)fileAccToy->Get("hPtGenAcc");
249  TH1F* hPtGenLimAccToy=(TH1F*)fileAccToy->Get("hPtGenLimAcc");
250  TH1F* hAccToyFine=(TH1F*)fileAccToy->Get("hAccVsPt");
251  TH1F* hPtGenAccToyR=(TH1F*)hPtGenAccToy->Rebin(nPtBins,"hPtGenAccToyReb",binLims);
252  TH1F* hPtGenLimAccToyR=(TH1F*)hPtGenLimAccToy->Rebin(nPtBins,"hPtGenLimAccToyReb",binLims);
253  TH1F* hAccToy=(TH1F*)hPtGenAccToyR->Clone("hAccToy");
254  hPtGenAccToyR->Sumw2();
255  hPtGenLimAccToyR->Sumw2();
256  hAccToy->Divide(hPtGenAccToyR,hPtGenLimAccToyR,1,1,"B");
257  hAccToy->SetLineColor(kGreen+2);
258  hAccToy->SetLineWidth(3);
259  hAccToy->SetMarkerStyle(25);
260  hAccToy->SetMarkerColor(kGreen+2);
261  hAccToy->SetStats(0);
262  hAccToyFine->SetLineColor(kGreen+2);
263 
264  TCanvas* c1a=new TCanvas("c1a","AccVsPt",1200,600);
265  c1a->Divide(2,1);
266  c1a->cd(1);
267  gPad->SetLogy();
268  hPtGenLimAcc->GetXaxis()->SetTitle("p_{T} (GeV/c)");
269  hPtGenLimAcc->GetYaxis()->SetTitle("Entries");
270  hPtGenLimAcc->SetLineColor(1);
271  hPtGenLimAcc->Draw();
272  gPad->Update();
273  TPaveStats *st1=(TPaveStats*)hPtGenLimAcc->GetListOfFunctions()->FindObject("stats");
274  st1->SetY1NDC(0.7);
275  st1->SetY2NDC(0.89);
276  hPtGenAcc->SetLineColor(2);
277  hPtGenAcc->Draw("sames");
278  gPad->Update();
279  TPaveStats *st2=(TPaveStats*)hPtGenAcc->GetListOfFunctions()->FindObject("stats");
280  st2->SetY1NDC(0.5);
281  st2->SetY2NDC(0.69);
282  st2->SetTextColor(2);
283  if(hPtGenAccEvSel){
284  hPtGenAccEvSel->SetLineColor(6);
285  hPtGenAccEvSel->Draw("sames");
286  gPad->Update();
287  TPaveStats *st2s=(TPaveStats*)hPtGenAccEvSel->GetListOfFunctions()->FindObject("stats");
288  st2s->SetY1NDC(0.3);
289  st2s->SetY2NDC(0.49);
290  st2s->SetTextColor(6);
291  }
292  hPtReco->SetLineColor(4);
293  hPtReco->Draw("sames");
294  gPad->Update();
295  TPaveStats *st13=(TPaveStats*)hPtReco->GetListOfFunctions()->FindObject("stats");
296  st13->SetY1NDC(0.1);
297  st13->SetY2NDC(0.29);
298  st13->SetTextColor(4);
299  gPad->Modified();
300  c1a->cd(2);
301  hEffVsPt->SetLineColor(4);
302  hEffVsPt->SetMinimum(0);
303  hEffVsPt->SetMaximum(1.95);
304  hEffVsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
305  hEffVsPt->GetYaxis()->SetTitle("Ratio");
306  hEffVsPt->Draw();
307  hAccVsPt->SetLineColor(2);
308  hAccVsPt->Draw("same");
309  hAccToyFine->Draw("same");
310  hAccToy->Draw("same");
311  TLatex* tacc=new TLatex(0.16,0.83,"Acceptance (CombinHF, 13d3)");
312  tacc->SetNDC();
313  tacc->SetTextColor(hAccVsPt->GetLineColor());
314  tacc->Draw();
315  TLatex* tacct=new TLatex(0.16,0.76,"Acceptance (ToyMC)");
316  tacct->SetNDC();
317  tacct->SetTextColor(hAccToyFine->GetLineColor());
318  tacct->Draw();
319  TLatex* te=new TLatex(0.16,0.69,"Efficiency");
320  te->SetNDC();
321  te->SetTextColor(hEffVsPt->GetLineColor());
322  te->Draw();
323 
324 
325  TCanvas* c1e=new TCanvas("c1e","EffVsPt",1200,600);
326  c1e->Divide(2,1);
327  c1e->cd(1);
328  gPad->SetLogy();
329  hPtGenLimAcc->GetXaxis()->SetTitle("p_{T} (GeV/c)");
330  hPtGenLimAcc->GetYaxis()->SetTitle("Entries");
331  hPtGenLimAcc->SetLineColor(1);
332  hPtGenLimAcc->Draw();
333  gPad->Update();
334  TPaveStats *st11=(TPaveStats*)hPtGenLimAcc->GetListOfFunctions()->FindObject("stats");
335  st11->SetY1NDC(0.7);
336  st11->SetY2NDC(0.89);
337  hPtGenAcc->SetLineColor(2);
338  hPtGenAcc->Draw("sames");
339  gPad->Update();
340  TPaveStats *st12=(TPaveStats*)hPtGenAcc->GetListOfFunctions()->FindObject("stats");
341  st12->SetY1NDC(0.5);
342  st12->SetY2NDC(0.69);
343  st12->SetTextColor(2);
344  if(hPtGenAccEvSel){
345  hPtGenAccEvSel->SetLineColor(6);
346  hPtGenAccEvSel->Draw("sames");
347  gPad->Update();
348  TPaveStats *st12s=(TPaveStats*)hPtGenAccEvSel->GetListOfFunctions()->FindObject("stats");
349  st12s->SetY1NDC(0.3);
350  st12s->SetY2NDC(0.49);
351  st12s->SetTextColor(6);
352  }
353  hPtReco->SetLineColor(4);
354  hPtReco->Draw("sames");
355  gPad->Update();
356  TPaveStats *st3=(TPaveStats*)hPtReco->GetListOfFunctions()->FindObject("stats");
357  st3->SetY1NDC(0.1);
358  st3->SetY2NDC(0.29);
359  st3->SetTextColor(4);
360  gPad->Modified();
361  c1e->cd(2);
362  TLatex* t1=new TLatex(6.,0.25,"GenAccInEvSel / GenAcc");
363  t1->SetTextColor(6);
364  if(hPtGenAccEvSel){
365  hEvSelEffVsPt->SetLineColor(6);
366  hEvSelEffVsPt->SetMinimum(0);
367  hEvSelEffVsPt->SetMaximum(1.05);
368  hEvSelEffVsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
369  hEvSelEffVsPt->GetYaxis()->SetTitle("Ratio");
370  hEvSelEffVsPt->Draw();
371  t1->Draw();
372  }
373  hEffVsPt->Draw("same");
374  TLatex* t3=new TLatex(6.,0.15,"Reco / GenAcc");
375  t3->SetTextColor(4);
376  t3->Draw();
377  c1e->SaveAs(Form("figures/EfficVsPt_%s.eps",suffix.Data()));
378 
379 
380  TH1D* hMultRecoAllPt=hPtVsYVsMultReco->ProjectionZ("hMultReco");
381  TH1D* hMultGenAccAllPt=hPtVsYVsMultGenAcc->ProjectionZ("hMultGenAcc");
382  TH1D* hMultGenAccEvSelAllPt=0x0;
383  if(hPtVsYVsMultGenAccEvSel) hMultGenAccEvSelAllPt=hPtVsYVsMultGenAccEvSel->ProjectionZ("hMultGenAccEvSel");
384  TH1D* hMultGenLimAccAllPt=hPtVsYVsMultGenLimAcc->ProjectionZ("hMultGenLimAcc");
385  TH1D* hEffVsMultAllPt=(TH1D*)hMultRecoAllPt->Clone("hEff");
386  hEffVsMultAllPt->Divide(hMultRecoAllPt,hMultGenAccAllPt,1,1,"B");
387  TH1D* hAccEffVsMultAllPt=(TH1D*)hMultRecoAllPt->Clone("hAccEff");
388  hAccEffVsMultAllPt->Divide(hMultRecoAllPt,hMultGenLimAccAllPt,1,1,"B");
389  TH1D* hAccVsMultAllPt=(TH1D*)hMultGenAccAllPt->Clone("hAcc");
390  hAccVsMultAllPt->Divide(hMultGenAccAllPt,hMultGenLimAccAllPt,1,1,"B");
391  hEffVsMultAllPt->SetStats(0);
392  hAccVsMultAllPt->SetStats(0);
393  hAccEffVsMultAllPt->SetStats(0);
394  TH1D* hEvSelEffVsMultAllPt=0x0;
395  if(hMultGenAccEvSelAllPt){
396  hEvSelEffVsMultAllPt=(TH1D*)hMultGenAccEvSelAllPt->Clone("hEvSelEffMult");
397  hEvSelEffVsMultAllPt->Divide(hMultGenAccEvSelAllPt,hMultGenAccAllPt,1,1,"B");
398  hEvSelEffVsMultAllPt->SetStats(0);
399  }
400 
401  TCanvas* c2a=new TCanvas("c2a","AccVsMult",1200,600);
402  c2a->Divide(2,1);
403  c2a->cd(1);
404  gPad->SetLogy();
405  hMultGenLimAccAllPt->SetLineColor(1);
406  hMultGenLimAccAllPt->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
407  hMultGenLimAccAllPt->GetYaxis()->SetTitle("Entries");
408  hMultGenLimAccAllPt->GetXaxis()->SetRangeUser(0.,maxMult);
409  hMultGenLimAccAllPt->Draw();
410  gPad->Update();
411  TPaveStats *st21=(TPaveStats*)hMultGenLimAccAllPt->GetListOfFunctions()->FindObject("stats");
412  st21->SetY1NDC(0.7);
413  st21->SetY2NDC(0.89);
414  hMultGenAccAllPt->SetLineColor(2);
415  hMultGenAccAllPt->Draw("sames");
416  gPad->Update();
417  TPaveStats *st22=(TPaveStats*)hMultGenAccAllPt->GetListOfFunctions()->FindObject("stats");
418  st22->SetY1NDC(0.5);
419  st22->SetY2NDC(0.69);
420  st22->SetTextColor(2);
421  if(hMultGenAccEvSelAllPt){
422  hMultGenAccEvSelAllPt->SetLineColor(6);
423  hMultGenAccEvSelAllPt->Draw("sames");
424  gPad->Update();
425  TPaveStats *st22s=(TPaveStats*)hMultGenAccEvSelAllPt->GetListOfFunctions()->FindObject("stats");
426  st22s->SetY1NDC(0.3);
427  st22s->SetY2NDC(0.49);
428  st22s->SetTextColor(6);
429  }
430  hMultRecoAllPt->SetLineColor(4);
431  hMultRecoAllPt->Draw("sames");
432  gPad->Update();
433  TPaveStats *st23=(TPaveStats*)hMultRecoAllPt->GetListOfFunctions()->FindObject("stats");
434  st23->SetY1NDC(0.1);
435  st23->SetY2NDC(0.29);
436  st23->SetTextColor(4);
437  gPad->Modified();
438  c2a->cd(2);
439  hEffVsMultAllPt->SetLineColor(4);
440  hEffVsMultAllPt->SetMinimum(0);
441  hEffVsMultAllPt->SetMaximum(1.6);
442  hEffVsMultAllPt->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
443  hEffVsMultAllPt->GetYaxis()->SetTitle("Ratio");
444  hEffVsMultAllPt->GetXaxis()->SetRangeUser(0.,maxMult);
445  hEffVsMultAllPt->Draw();
446  hAccVsMultAllPt->SetLineColor(2);
447  hAccVsMultAllPt->Draw("same");
448  // hAccEffVsMultAllPt->SetLineColor(6);
449  // hAccEffVsMultAllPt->Draw("same");
450  TLatex* tacc2=new TLatex(0.16,0.8,"Acceptance (CombinHF, 13d3)");
451  tacc2->SetNDC();
452  tacc2->SetTextColor(hAccVsMultAllPt->GetLineColor());
453  tacc2->Draw();
454  TLatex* te2=new TLatex(0.16,0.72,"Efficiency");
455  te2->SetNDC();
456  te2->SetTextColor(hEffVsMultAllPt->GetLineColor());
457  te2->Draw();
458 
459  TCanvas* c2e=new TCanvas("c2e","EffVsMult",1200,600);
460  c2e->Divide(2,1);
461  c2e->cd(1);
462  gPad->SetLogy();
463  hMultGenLimAccAllPt->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
464  hMultGenLimAccAllPt->GetYaxis()->SetTitle("Entries");
465  hMultGenLimAccAllPt->GetXaxis()->SetRangeUser(0.,maxMult);
466  hMultGenLimAccAllPt->SetLineColor(1);
467  hMultGenLimAccAllPt->Draw();
468  gPad->Update();
469  TPaveStats *st1e=(TPaveStats*)hMultGenLimAccAllPt->GetListOfFunctions()->FindObject("stats");
470  st1e->SetY1NDC(0.7);
471  st1e->SetY2NDC(0.89);
472  hMultGenAccAllPt->SetLineColor(2);
473  hMultGenAccAllPt->Draw("sames");
474  gPad->Update();
475  TPaveStats *st2e=(TPaveStats*)hMultGenAccAllPt->GetListOfFunctions()->FindObject("stats");
476  st2e->SetY1NDC(0.5);
477  st2e->SetY2NDC(0.69);
478  st2e->SetTextColor(2);
479  if(hMultGenAccEvSelAllPt){
480  hMultGenAccEvSelAllPt->SetLineColor(6);
481  hMultGenAccEvSelAllPt->Draw("sames");
482  gPad->Update();
483  TPaveStats *st2se=(TPaveStats*)hMultGenAccEvSelAllPt->GetListOfFunctions()->FindObject("stats");
484  st2se->SetY1NDC(0.3);
485  st2se->SetY2NDC(0.49);
486  st2se->SetTextColor(6);
487  }
488  hMultRecoAllPt->SetLineColor(4);
489  hMultRecoAllPt->Draw("sames");
490  gPad->Update();
491  TPaveStats *st3s=(TPaveStats*)hMultRecoAllPt->GetListOfFunctions()->FindObject("stats");
492  st3s->SetY1NDC(0.1);
493  st3s->SetY2NDC(0.29);
494  st3s->SetTextColor(4);
495  gPad->Modified();
496  c2e->cd(2);
497  gPad->SetTickx();
498  gPad->SetTicky();
499  if(hMultGenAccEvSelAllPt){
500  hEvSelEffVsMultAllPt->SetLineColor(6);
501  hEvSelEffVsMultAllPt->SetMinimum(0);
502  hEvSelEffVsMultAllPt->SetMaximum(1.05);
503  hEvSelEffVsMultAllPt->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
504  hEvSelEffVsMultAllPt->GetYaxis()->SetTitle("Ratio");
505  hEvSelEffVsMultAllPt->GetXaxis()->SetRangeUser(0.,maxMult);
506  hEvSelEffVsMultAllPt->Draw();
507  t1->Draw();
508  }
509  hEffVsMultAllPt->SetLineColor(4);
510  hEffVsMultAllPt->Draw("same");
511  t3->Draw();
512  c2e->SaveAs(Form("figures/EfficVsMult_%s.eps",suffix.Data()));
513 
514  const Int_t nMultBins=6;
515  Double_t mulLims[nMultBins+1]={0.,5.,12.,20.,40.,80.,200.};
516  Int_t mulcol[nMultBins]={1,kRed+1,kGreen+2,4,kOrange+2,kMagenta};
517 
518  TH1D* hPtRecoM[nMultBins];
519  TH1D* hPtGenAccM[nMultBins];
520  // TH1D* hPtGenLimAccM[nMultBins];
521  TH1D* hEffVsPtM[nMultBins];
522  for(Int_t j=0; j<nMultBins; j++){
523  Int_t lowBin=hPtVsYVsMultReco->GetZaxis()->FindBin(mulLims[j]);
524  Int_t hiBin=hPtVsYVsMultReco->GetZaxis()->FindBin(mulLims[j+1]-0.001);
525  // printf("%d (%f) %d(%f)\n",lowBin,hPtVsYVsMultReco->GetZaxis()->GetBinLowEdge(lowBin),hiBin,hPtVsYVsMultReco->GetZaxis()->GetBinUpEdge(hiBin));
526 
527  hPtRecoM[j]=hPtVsYVsMultReco->ProjectionX(Form("hPtRecoM%d",j),0,-1,lowBin,hiBin);
528  hPtGenAccM[j]=hPtVsYVsMultGenAcc->ProjectionX(Form("hPtGenAccM%d",j),0,-1,lowBin,hiBin);
529  // hPtGenLimAccM[j]=hPtVsYVsMultGenLimAcc->ProjectionX(Form("hPtGenLimAccM%d",j),0,-1,lowBin,hiBin);
530  hEffVsPtM[j]=(TH1D*)hPtRecoM[j]->Clone(Form("hEffM%d",j));
531  hEffVsPtM[j]->Divide(hPtRecoM[j],hPtGenAccM[j],1,1,"B");
532  }
533 
534  hEffVsPtM[0]->SetStats(0);
535  TCanvas* cwp=new TCanvas("cwp","Eff and Weight vs pt",1200,600);
536  cwp->Divide(2,1);
537  cwp->cd(1);
538  gPad->SetLeftMargin(0.12);
539  hEffVsPtM[0]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
540  hEffVsPtM[0]->GetYaxis()->SetTitle("Efficiency");
541  hEffVsPtM[0]->GetYaxis()->SetTitleOffset(1.4);
542  hEffVsPtM[0]->SetLineColor(mulcol[0]);
543  hEffVsPtM[0]->SetMinimum(0);
544  hEffVsPtM[0]->SetMaximum(1.8);
545  hEffVsPtM[0]->Draw();
546  TLegend* legp=new TLegend(0.16,0.5,0.55,0.89);
547  legp->SetFillStyle(0);
548  legp->SetBorderSize(0);
549  legp->AddEntry(hEffVsPtM[0],Form("%.0f<N_{tracklets}<%.0f",mulLims[0],mulLims[1]),"L")->SetTextColor(mulcol[0]);
550  for(Int_t j=1; j<nMultBins; j++){
551  hEffVsPtM[j]->SetLineColor(mulcol[j]);
552  hEffVsPtM[j]->Draw("same");
553  legp->AddEntry(hEffVsPtM[j],Form("%.0f<N_{tracklets}<%.0f",mulLims[j],mulLims[j+1]),"L")->SetTextColor(mulcol[j]);
554  }
555  legp->Draw();
556  cwp->cd(2);
557  gPad->SetLeftMargin(0.12);
558  funcPtWeight->SetTitle("");
559  funcPtWeight->GetXaxis()->SetTitle("p_{T} (GeV/c)");
560  funcPtWeight->GetYaxis()->SetTitle("Weight");
561  funcPtWeight->Draw();
562  cwp->SaveAs(Form("figures/EfficVsPtMultBins_%s.eps",suffix.Data()));
563 
564 
565  TH1D* hMultReco[nPtBins];
566  TH1D* hMultGenAcc[nPtBins];
567  // TH1D* hMultGenLimAcc[nPtBins];
568  TH1D* hEffVsMult[nPtBins];
569  for(Int_t j=0; j<nPtBins; j++){
570  Int_t lowBin=hPtVsYVsMultReco->GetXaxis()->FindBin(binLims[j]);
571  Int_t hiBin=hPtVsYVsMultReco->GetXaxis()->FindBin(binLims[j+1]-0.001);
572  //printf("%d (%f) %d(%f)\n",lowBin,hPtVsYVsMultReco->GetXaxis()->GetBinLowEdge(lowBin),hiBin,hPtVsYVsMultReco->GetXaxis()->GetBinUpEdge(hiBin));
573 
574  hMultReco[j]=hPtVsYVsMultReco->ProjectionZ(Form("hMultReco%d",j),lowBin,hiBin);
575  hMultGenAcc[j]=hPtVsYVsMultGenAcc->ProjectionZ(Form("hMultGenAcc%d",j),lowBin,hiBin);
576  // hMultGenLimAcc[j]=hPtVsYVsMultGenLimAcc->ProjectionZ(Form("hMultGenLimAcc%d",j),lowBin,hiBin);
577  hEffVsMult[j]=(TH1D*)hMultReco[j]->Clone("hEff");
578  hEffVsMult[j]->Divide(hMultReco[j],hMultGenAcc[j],1,1,"B");
579  }
580 
581  // TCanvas* c2e=new TCanvas("c2e");
582  // hEffVsMult[0]->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
583  // hEffVsMult[0]->GetYaxis()->SetTitle("Efficiency");
584  // hEffVsMult[0]->GetYaxis()->SetTitleOffset(1.4);
585  // hEffVsMult[0]->SetLineColor(ptcol[0]);
586  // hEffVsMult[0]->SetMinimum(0);
587  // hEffVsMult[0]->SetMaximum(1.6);
588  // hEffVsMult[0]->Draw();
589  // TLegend* legm=new TLegend(0.16,0.5,0.4,0.89);
590  // legm->SetFillStyle(0);
591  // legm->SetBorderSize(0);
592  // legm->AddEntry(hEffVsMult[0],Form("%.0f<p_{T}<%.0f GeV/c",binLims[0],binLims[1]),"L")->SetTextColor(ptcol[0]);
593  // for(Int_t j=1; j<nPtBins; j++){
594  // hEffVsMult[j]->SetLineColor(ptcol[j]);
595  // hEffVsMult[j]->Draw("same");
596  // legm->AddEntry(hEffVsMult[j],Form("%.0f<p_{T}<%.0f GeV/c",binLims[j],binLims[j+1]),"L")->SetTextColor(ptcol[j]);
597  // }
598  // legm->Draw();
599 
600 
601  TH1F** hWeight=new TH1F*[3];
602  for(Int_t iw=0;iw<3; iw++) hWeight[iw]=0x0;
603 
604  if(gSystem->AccessPathName(fileWeightName.Data())==0){
605  printf("Open file with multiplicity weights\n");
606  TFile* filw = new TFile(fileWeightName.Data());
607  for(Int_t iw=0;iw<3; iw++){
608  hWeight[iw]=(TH1F*)filw->Get(histoWeightName[iw].Data());
609  hWeight[iw]->SetLineColor(wcol[iw]);
610  hWeight[iw]->SetStats(0);
611  hWeight[iw]->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
612  hWeight[iw]->GetYaxis()->SetTitle("Weight");
613  hWeight[iw]->GetYaxis()->SetTitleOffset(1.4);
614  hWeight[iw]->SetMaximum(3.);
615  hWeight[iw]->SetMinimum(0.);
616  }
617  }
618 
619  hEffVsMult[0]->SetStats(0);
620  TCanvas* cw=new TCanvas("cw","Eff and Weight vs mult",1200,600);
621  cw->Divide(2,1);
622  cw->cd(1);
623  gPad->SetLeftMargin(0.12);
624  hEffVsMult[0]->GetXaxis()->SetRangeUser(0.,maxMult);
625  hEffVsMult[0]->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
626  hEffVsMult[0]->GetYaxis()->SetTitle("Efficiency");
627  hEffVsMult[0]->GetYaxis()->SetTitleOffset(1.4);
628  hEffVsMult[0]->SetLineColor(ptcol[0]);
629  hEffVsMult[0]->SetMinimum(0);
630  hEffVsMult[0]->SetMaximum(1.6);
631  hEffVsMult[0]->Draw();
632  TLegend* legm=new TLegend(0.16,0.5,0.4,0.89);
633  legm->SetFillStyle(0);
634  legm->SetBorderSize(0);
635  legm->AddEntry(hEffVsMult[0],Form("%.0f<p_{T}<%.0f GeV/c",binLims[0],binLims[1]),"L")->SetTextColor(ptcol[0]);
636  for(Int_t j=1; j<nPtBins; j++){
637  hEffVsMult[j]->SetLineColor(ptcol[j]);
638  hEffVsMult[j]->Draw("same");
639  legm->AddEntry(hEffVsMult[j],Form("%.0f<p_{T}<%.0f GeV/c",binLims[j],binLims[j+1]),"L")->SetTextColor(ptcol[j]);
640  }
641  legm->Draw();
642  cw->cd(2);
643  if(hWeight[0]){
644  gPad->SetLeftMargin(0.12);
645  hWeight[0]->GetXaxis()->SetRangeUser(0.,maxMult);
646  hWeight[0]->Draw();
647  TLegend* legw=new TLegend(0.2,0.65,0.55,0.89);
648  legw->SetFillStyle(0);
649  legw->AddEntry(hWeight[0],"Candidate Weight","L");
650  if(hWeight[1]){
651  hWeight[1]->Draw("same");
652  legw->AddEntry(hWeight[1],"D Weight","L");
653  }
654  if(hWeight[2]){
655  hWeight[2]->Draw("same");
656  legw->AddEntry(hWeight[2],"EvSel Weight","L");
657  }
658  legw->Draw();
659  }
660  cw->SaveAs(Form("figures/EfficVsMultPtBins_%s.eps",suffix.Data()));
661 
662 
663  TH1D *hpteffNoWeight =new TH1D("hEffVsPtNoWeight","",nPtBins,binLims);
664  TH1D **hpteffMultWeight =new TH1D*[3];
665  hpteffMultWeight[0]=new TH1D("hEffVsPtCandWeight","",nPtBins,binLims);
666  hpteffMultWeight[1]=new TH1D("hEffVsPtDWeight","",nPtBins,binLims);
667  hpteffMultWeight[2]=new TH1D("hEffVsPtEvSelWeight","",nPtBins,binLims);
668  TH1D **hpteffMultPtWeight =new TH1D*[3];
669  hpteffMultPtWeight[0]=new TH1D("hEffVsPtCandFONLLWeight","",nPtBins,binLims);
670  hpteffMultPtWeight[1]=new TH1D("hEffVsPtDFONLLWeight","",nPtBins,binLims);
671  hpteffMultPtWeight[2]=new TH1D("hEffVsPtEvSelFONLLWeight","",nPtBins,binLims);
672 
673  TH1D* hMultRecoAllPtW=hPtVsYVsMultReco->ProjectionZ("hMultRecoW");
674  TH1D* hMultGenAccAllPtW=hPtVsYVsMultGenAcc->ProjectionZ("hMultGenAccW");
675  TH1D* hMultGenLimAccAllPtW=hPtVsYVsMultGenLimAcc->ProjectionZ("hMultGenLimAccW");
676  hMultRecoAllPtW->Reset("ines");
677  hMultGenAccAllPtW->Reset("ines");
678  hMultGenLimAccAllPtW->Reset("ines");
679 
680  Double_t countNumer[nPtBins];
681  Double_t countDenom[nPtBins];
682  Double_t countNumerMultWei[nPtBins][3];
683  Double_t countDenomMultWei[nPtBins][3];
684  Double_t countNumerMultPtWei[nPtBins][3];
685  Double_t countDenomMultPtWei[nPtBins][3];
686 
687  for(Int_t iPtBin=0; iPtBin<nPtBins; iPtBin++){
688  countNumer[iPtBin]=0.0;
689  countDenom[iPtBin]=0.0;
690  for(Int_t iw=0; iw<3; iw++){
691  countNumerMultWei[iPtBin][iw]=0.0;
692  countDenomMultWei[iPtBin][iw]=0.0;
693  countNumerMultPtWei[iPtBin][iw]=0.0;
694  countDenomMultPtWei[iPtBin][iw]=0.0;
695  }
696  }
697 
698  for(Int_t ibx=0; ibx<=hPtVsYVsMultGenAcc->GetNbinsX()+1; ibx++){
699  for(Int_t iby=0; iby<=hPtVsYVsMultGenAcc->GetNbinsY()+1; iby++){
700  for(Int_t ibz=0; ibz<=hPtVsYVsMultGenAcc->GetNbinsZ()+1; ibz++){
701  Double_t pt=hPtVsYVsMultGenAcc->GetXaxis()->GetBinCenter(ibx);
702  // Double_t y=hPtVsYVsMultGenAcc->GetYaxis()->GetBinCenter(iby);
703  Double_t mult=hPtVsYVsMultGenAcc->GetZaxis()->GetBinCenter(ibz);
704  // printf("%f %f %f\n",pt,y,mult);
705  Int_t jPtBin=TMath::BinarySearch(nPtBins+1,binLims,pt);
706  if(jPtBin>=0 && jPtBin<nPtBins){
707  Double_t wpt=funcPtWeight->Eval(pt);
708  countNumer[jPtBin]+=hPtVsYVsMultReco->GetBinContent(ibx,iby,ibz);
709  countDenom[jPtBin]+=hPtVsYVsMultGenAcc->GetBinContent(ibx,iby,ibz);
710  for(Int_t iw=0; iw<3; iw++){
711  Double_t w=0;
712  if(hWeight[iw]){
713  Int_t binw=hWeight[iw]->FindBin(mult);
714  if(binw>=1 && binw<hWeight[iw]->GetNbinsX()+1){
715  w=hWeight[iw]->GetBinContent(binw);
716  // printf("mult %.0f bin %d wei %f\n",mult,binw,w);
717  }else{
718  if(hPtVsYVsMultGenAcc->GetBinContent(ibx,iby,ibz)>0){
719  printf("mult %.0f bin %d wei %f\n",mult,binw,w);
720  getchar();
721  }
722  }
723  }else{
724  w=1;
725  }
726  if(!useMultWeight) w=1;
727  countNumerMultWei[jPtBin][iw]+=hPtVsYVsMultReco->GetBinContent(ibx,iby,ibz)*w;
728  countDenomMultWei[jPtBin][iw]+=hPtVsYVsMultGenAcc->GetBinContent(ibx,iby,ibz)*w;
729  countNumerMultPtWei[jPtBin][iw]+=hPtVsYVsMultReco->GetBinContent(ibx,iby,ibz)*w*wpt;
730  countDenomMultPtWei[jPtBin][iw]+=hPtVsYVsMultGenAcc->GetBinContent(ibx,iby,ibz)*w*wpt;
731  hMultRecoAllPtW->Fill(mult,hPtVsYVsMultReco->GetBinContent(ibx,iby,ibz)*w);
732  hMultGenAccAllPtW->Fill(mult,hPtVsYVsMultGenAcc->GetBinContent(ibx,iby,ibz)*w);
733  hMultGenLimAccAllPtW->Fill(mult,hPtVsYVsMultGenLimAcc->GetBinContent(ibx,iby,ibz)*w);
734  }
735  }
736  }
737  }
738  }
739 
740  for(Int_t iPtBin=0; iPtBin<nPtBins; iPtBin++){
741  Double_t eff1=countNumer[iPtBin]/countDenom[iPtBin];
742  Double_t erreff1=TMath::Sqrt(eff1*(1-eff1)/countDenom[iPtBin]);
743  printf("---- Pt range %.0f - %.0f ----\n",binLims[iPtBin],binLims[iPtBin+1]);
744  printf("Eff from Projection = %f/%f = %f+-%f\n",hPtRecoR->GetBinContent(iPtBin+1),hPtGenAccR->GetBinContent(iPtBin+1),hEffVsPtR->GetBinContent(iPtBin+1),hEffVsPtR->GetBinError(iPtBin+1));
745  printf("Eff No weights = %f/%f = %f+-%f\n",countNumer[iPtBin],countDenom[iPtBin],eff1,erreff1);
746  hpteffNoWeight->SetBinContent(iPtBin+1,eff1);
747  hpteffNoWeight->SetBinError(iPtBin+1,erreff1);
748  for(Int_t iw=0;iw<3; iw++){
749  Double_t eff2=countNumerMultWei[iPtBin][iw]/countDenomMultWei[iPtBin][iw];
750  Double_t erreff2=TMath::Sqrt(eff2*(1-eff2)/countDenom[iPtBin]);// countDenom is NOT a typo, it has to be like this to get proper statistical errors from the no-weight case
751  printf("Eff With mult weights %d = %f/%f = %f+-%f\n",iw,countNumerMultWei[iPtBin][iw],countDenomMultWei[iPtBin][iw],eff2,erreff2);
752  hpteffMultWeight[iw]->SetBinContent(iPtBin+1,eff2);
753  hpteffMultWeight[iw]->SetBinError(iPtBin+1,erreff2);
754  Double_t eff3=countNumerMultPtWei[iPtBin][iw]/countDenomMultPtWei[iPtBin][iw];
755  Double_t erreff3=TMath::Sqrt(eff3*(1-eff3)/countDenom[iPtBin]);// countDenom is NOT a typo, it has to be like this to get proper statistical errors from the no-weight case
756  printf("Eff With mult+pt weights %d = %f/%f = %f+-%f\n",iw,countNumerMultPtWei[iPtBin][iw],countDenomMultPtWei[iPtBin][iw],eff3,erreff3);
757  hpteffMultPtWeight[iw]->SetBinContent(iPtBin+1,eff3);
758  hpteffMultPtWeight[iw]->SetBinError(iPtBin+1,erreff3);
759  }
760  }
761 
762  TH1D* hEffVsMultAllPtW=(TH1D*)hMultRecoAllPtW->Clone("hEff");
763  hEffVsMultAllPtW->Divide(hMultRecoAllPtW,hMultGenAccAllPtW,1,1,"B");
764  TH1D* hAccVsMultAllPtW=(TH1D*)hMultGenAccAllPtW->Clone("hAcc");
765  hAccVsMultAllPtW->Divide(hMultGenAccAllPtW,hMultGenLimAccAllPtW,1,1,"B");
766  hEffVsMultAllPtW->SetStats(0);
767  hAccVsMultAllPtW->SetStats(0);
768 
769  TCanvas* c2w=new TCanvas("c2w","EffVsMultW",1200,600);
770  c2w->Divide(2,1);
771  c2w->cd(1);
772  gPad->SetLogy();
773  hMultGenLimAccAllPtW->SetLineColor(1);
774  hMultGenLimAccAllPtW->GetXaxis()->SetRangeUser(0.,maxMult);
775  hMultGenLimAccAllPtW->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
776  hMultGenLimAccAllPtW->GetYaxis()->SetTitle("Entries");
777  hMultGenLimAccAllPtW->Draw();
778  hMultGenAccAllPtW->SetLineColor(2);
779  hMultGenAccAllPtW->Draw("same");
780  hMultRecoAllPtW->SetLineColor(4);
781  hMultRecoAllPtW->Draw("same");
782  c2w->cd(2);
783  hEffVsMultAllPtW->SetLineColor(4);
784  hEffVsMultAllPtW->SetMinimum(0);
785  hEffVsMultAllPtW->SetMaximum(1.6);
786  hEffVsMultAllPtW->GetXaxis()->SetRangeUser(0.,maxMult);
787  hEffVsMultAllPtW->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
788  hEffVsMultAllPtW->GetYaxis()->SetTitle("Ratio");
789  hEffVsMultAllPtW->Draw();
790  hAccVsMultAllPtW->SetLineColor(2);
791  hAccVsMultAllPtW->Draw("same");
792  tacc2->Draw();
793  te2->Draw();
794 
795 
796 
797 
798  hEffVsPtR->SetMarkerStyle(0);
799  hEffVsPtR->SetMarkerColor(0);
800  hEffVsPtR->SetMarkerSize(1.2);
801  hEffVsPtR->SetLineColor(kGray);
802  hEffVsPtR->SetLineWidth(4);
803  hEffVsPtR->SetStats(0);
804  hpteffNoWeight->SetMarkerStyle(20);
805 
806  TH1F** hRatio=new TH1F*[3];
807  for(Int_t iw=0;iw<3; iw++){
808  hRatio[iw]=(TH1F*)hpteffMultWeight[iw]->Clone("hRatio");
809  hRatio[iw]->Divide(hpteffMultWeight[iw],hpteffNoWeight);
810  hRatio[iw]->GetYaxis()->SetTitle("With Mult weight / Without weight");
811  hRatio[iw]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
812  hRatio[iw]->GetYaxis()->SetTitleOffset(1.4);
813  hRatio[iw]->SetLineColor(wcol[iw]);
814  hRatio[iw]->SetMarkerColor(wcol[iw]);
815  hRatio[iw]->SetMarkerStyle(wmark[iw]);
816  hRatio[iw]->SetStats(0);
817  hpteffMultWeight[iw]->SetLineColor(wcol[iw]);
818  hpteffMultWeight[iw]->SetMarkerColor(wcol[iw]);
819  hpteffMultWeight[iw]->SetMarkerStyle(wmark[iw]);
820  }
821  TH1F** hRatioPtW=new TH1F*[3];
822  for(Int_t iw=0;iw<3; iw++){
823  hRatioPtW[iw]=(TH1F*)hpteffMultPtWeight[iw]->Clone("hRatio");
824  hRatioPtW[iw]->Divide(hpteffMultPtWeight[iw],hpteffMultWeight[iw]);
825  hRatioPtW[iw]->GetYaxis()->SetTitle("With Mult+p_{T} weight / With only Mult weight");
826  hRatioPtW[iw]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
827  hRatioPtW[iw]->GetYaxis()->SetTitleOffset(1.4);
828  hRatioPtW[iw]->SetLineColor(wcol[iw]);
829  hRatioPtW[iw]->SetMarkerColor(wcol[iw]);
830  hRatioPtW[iw]->SetMarkerStyle(wmark[iw]);
831  hRatioPtW[iw]->SetStats(0);
832  hpteffMultPtWeight[iw]->SetLineColor(wcol[iw]);
833  hpteffMultPtWeight[iw]->SetMarkerColor(wcol[iw]);
834  hpteffMultPtWeight[iw]->SetMarkerStyle(wmark[iw]);
835  }
836 
837  TCanvas* ceff=new TCanvas("ceff","Eff Mult Wei",1200,600);
838  ceff->Divide(2,1);
839  ceff->cd(1);
840  gPad->SetLeftMargin(0.12);
841  gPad->SetTickx();
842  gPad->SetTicky();
843  hEffVsPtR->SetMinimum(0);
844  hEffVsPtR->SetMaximum(1);
845  hEffVsPtR->Draw();
846  hEffVsPtR->GetXaxis()->SetTitle("p_{T} (GeV/c)");
847  hEffVsPtR->GetYaxis()->SetTitle("Efficiency");
848  hEffVsPtR->GetYaxis()->SetTitleOffset(1.4);
849  hpteffNoWeight->Draw("same");
850  for(Int_t iw=0;iw<3; iw++) hpteffMultWeight[iw]->Draw("same");
851  TLegend* leg=new TLegend(0.55,0.15,0.89,0.45);
852  leg->SetFillStyle(0);
853  leg->AddEntry(hEffVsPtR,"TH3F::Project","L");
854  leg->AddEntry(hpteffNoWeight,"Multiplcity slices - No Weight","PL");
855  leg->AddEntry(hpteffMultWeight[0],"Multiplcity slices - Cand Weight","PL");
856  leg->AddEntry(hpteffMultWeight[1],"Multiplcity slices - D Weight","PL");
857  leg->AddEntry(hpteffMultWeight[2],"Multiplcity slices - EvSel Weight","PL");
858  leg->Draw();
859  ceff->cd(2);
860  gPad->SetLeftMargin(0.12);
861  gPad->SetTickx();
862  gPad->SetTicky();
863  hRatio[0]->Draw();
864  hRatio[0]->SetMinimum(0.95);
865  hRatio[0]->SetMaximum(1.05);
866  for(Int_t iw=1;iw<3; iw++) hRatio[iw]->Draw("same");
867  ceff->SaveAs(Form("figures/EfficWithMultWeights_%s.eps",suffix.Data()));
868 
869 
870  TCanvas* ceff2=new TCanvas("ceff2","Eff Mult+Pt Wei",1200,600);
871  ceff2->Divide(2,1);
872  ceff2->cd(1);
873  gPad->SetLeftMargin(0.12);
874  gPad->SetTickx();
875  gPad->SetTicky();
876  hEffVsPtR->SetMinimum(0);
877  hEffVsPtR->SetMaximum(1);
878  hEffVsPtR->Draw();
879  hEffVsPtR->GetXaxis()->SetTitle("p_{T} (GeV/c)");
880  hEffVsPtR->GetYaxis()->SetTitle("Efficiency");
881  hEffVsPtR->GetYaxis()->SetTitleOffset(1.4);
882  hpteffNoWeight->Draw("same");
883  for(Int_t iw=0;iw<3; iw++) hpteffMultPtWeight[iw]->Draw("same");
884  TLegend* leg2=new TLegend(0.55,0.15,0.89,0.45);
885  leg2->SetFillStyle(0);
886  leg2->AddEntry(hEffVsPtR,"TH3F::Project","L");
887  leg2->AddEntry(hpteffNoWeight,"Multiplcity slices - No Weight","PL");
888  leg2->AddEntry(hpteffMultPtWeight[0],"Multiplcity slices - FONLL+Cand Weight","PL");
889  leg2->AddEntry(hpteffMultPtWeight[1],"Multiplcity slices - FONLL+D Weight","PL");
890  leg2->AddEntry(hpteffMultPtWeight[2],"Multiplcity slices - FONLL+EvSel Weight","PL");
891  leg2->Draw();
892  ceff2->cd(2);
893  gPad->SetLeftMargin(0.12);
894  gPad->SetTickx();
895  gPad->SetTicky();
896  hRatioPtW[0]->Draw();
897  hRatioPtW[0]->SetMinimum(0.95);
898  hRatioPtW[0]->SetMaximum(1.05);
899  for(Int_t iw=1;iw<3; iw++) hRatioPtW[iw]->Draw("same");
900  ceff2->SaveAs(Form("figures/EfficWithMultAndPtWeights_%s.eps",suffix.Data()));
901 
902  TFile* out=new TFile(Form("outputEff_%s.root",suffix.Data()),"recreate");
903  hEffVsPtR->Write();
904  hAccToy->Write();
905  hpteffMultPtWeight[0]->Write();
906  hpteffMultPtWeight[1]->Write();
907  hpteffMultPtWeight[2]->Write();
908  hEvSelEffVsPt->Write();
909  out->Close();
910 
911 }
double Double_t
Definition: External.C:58
Definition: External.C:260
void Draw(const char *filename, const char *title="", const char *others="ALL", const char *options="DEFAULT", const char *outFlg="ALL", UShort_t rebin=5, Float_t eff=0, const char *base="")
Definition: DrawdNdeta.C:3603
Definition: External.C:236
TString fileNameToy
TSystem * gSystem
Double_t binLims[nPtBins+1]
TFile * fil
Definition: InvMassFit.C:60
TString fileNameMC
Bool_t useMultWeight
int Int_t
Definition: External.C:63
Definition: External.C:228
Definition: External.C:212
void ComputeEfficiencyFromCombinHF()
bool Bool_t
Definition: External.C:53
const Int_t nPtBins
Double_t maxMult