AliPhysics  master (3d17d9d)
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 
20 
21 TString configFileName="configfile4lowptanalysis.txt";
25 
26 const Int_t maxPtBins=30;
28 Double_t binLims[maxPtBins+1]={0.,1.,2.,3.,4.,5.,6.,8.,12.};
29 Int_t ptcol[maxPtBins]={1,kRed+1,kRed,kGreen+2,kCyan,4,kOrange+2,kMagenta,kMagenta+2,kBlue+1,kGray,kGray+2,kGreen,kYellow+7};
30 
34 Double_t maxMult=-1;//200;
35 
36 TH1F* hAccToyFine=0x0;
37 TH1F* hAccToy=0x0;
38 TF1* funcPtWeight=0x0;
39 TF1* funcPtBWeight=0x0;
40 
41 TH1F** hWeight=new TH1F*[3];
42 Int_t wcol[3]={kRed+1,kGreen+1,4};
43 Int_t wmark[3]={22,23,26};
44 
45 void ComputeAndWriteEff(TList* l, TString dCase, TString var3="Mult");
46 Bool_t ReadConfig(TString configName);
47 
49 
50 
51  if(configFileName.Length()>0){
52  if(gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",configFileName.Data()))==0){
53  printf("Read configuration from file %s\n",configFileName.Data());
54  Bool_t readOK=ReadConfig(configFileName);
55  if(!readOK){
56  printf("Error in reading configuration file\n");
57  return;
58  }
59  }
60  }
61 
62  // multiplicity weights
63  TString fileWeightName="trackletsWeightsMultInt_LHC13d3_08092014.root";
64  TString histoWeightName[3];
65  histoWeightName[0]="hNtrUnCorrEvWithCand";
66  histoWeightName[1]="hNtrUnCorrEvWithD";
67  histoWeightName[2]="hNtrUnCorrEvSel";
68  for(Int_t iw=0;iw<3; iw++) hWeight[iw]=0x0;
69 
70  if(gSystem->AccessPathName(fileWeightName.Data())==0){
71  printf("Open file with multiplicity weights\n");
72  TFile* filw = new TFile(fileWeightName.Data());
73  for(Int_t iw=0;iw<3; iw++){
74  hWeight[iw]=(TH1F*)filw->Get(histoWeightName[iw].Data());
75  hWeight[iw]->SetLineColor(wcol[iw]);
76  hWeight[iw]->SetStats(0);
77  hWeight[iw]->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
78  hWeight[iw]->GetYaxis()->SetTitle("Weight");
79  hWeight[iw]->GetYaxis()->SetTitleOffset(1.4);
80  hWeight[iw]->SetMaximum(3.);
81  hWeight[iw]->SetMinimum(0.);
82  }
83  }
84 
85 
86  // pt weights
88  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.);
89  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);
90  }else if (ptWeight==kFONLL7overLHC10f6a){
91  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.);
92  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);
93  }else if (ptWeight==kFONLL7overLHC10f7a){
94  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.);
95  funcPtWeight->SetParameters(3.59525,2.67871,2.70402,1.72578,4.78167e-03,4.90992,-1.26424e-01,8.21269e-02,-1.26425e-01);
96  }else if(ptWeight==kFLAToverLHC10f7a){
97  funcPtWeight=new TF1("funcPtWeight","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.15,40.);
98  funcPtWeight->SetParameters(1.99498e-01,-9.90532e-02,3.03645e-02,7.42483e-04);
99  }else{
100  funcPtWeight=new TF1("funcPtWeight","[0]");
101  funcPtWeight->SetParameter(0,1.);
102  }
104  funcPtBWeight=new TF1("ff","[0]+[1]*x+[2]*TMath::Exp(-(x-[3])*(x-[3])/2/[4]/[4])+[5]*TMath::Exp(-(x-[6])*(x-[6])/2/[7]/[7])+[8]*x*x",0.,50.);
105  funcPtBWeight->SetParameters(5.359e-01,-1.921e-02,7.247e-01,6.899e+00,5.310e+00,2.273e-01,3.474e+00,1.444e+00,1.800e-04);
106  }else{
107  funcPtBWeight=new TF1("funcPtWeight","[0]");
108  funcPtBWeight->SetParameter(0,1.);
109  }
110 
111  TString dirName=Form("PWG3_D2H_InvMassDzeroLowPt%s",suffix.Data());
112  TString lstName=Form("coutputDzero%s",suffix.Data());
113  TFile* fil=new TFile(fileNameMC.Data());
114  TDirectoryFile* df=(TDirectoryFile*)fil->Get(dirName.Data());
115  TList* l=(TList*)df->Get(lstName.Data());
116 
117 
118  // aceptance from toy MC
119  TFile* fileAccToy=new TFile(fileNameToy.Data());
120  TH1F* hPtGenAccToy=(TH1F*)fileAccToy->Get("hPtGenAcc");
121  TH1F* hPtGenLimAccToy=(TH1F*)fileAccToy->Get("hPtGenLimAcc");
122  hAccToyFine=(TH1F*)fileAccToy->Get("hAccVsPt");
123  TH1F* hPtGenAccToyR=(TH1F*)hPtGenAccToy->Rebin(nPtBins,"hPtGenAccToyReb",binLims);
124  TH1F* hPtGenLimAccToyR=(TH1F*)hPtGenLimAccToy->Rebin(nPtBins,"hPtGenLimAccToyReb",binLims);
125  hAccToy=(TH1F*)hPtGenAccToyR->Clone("hAccToy");
126  hPtGenAccToyR->Sumw2();
127  hPtGenLimAccToyR->Sumw2();
128  hAccToy->Divide(hPtGenAccToyR,hPtGenLimAccToyR,1,1,"B");
129  hAccToy->SetLineColor(kGreen+2);
130  hAccToy->SetLineWidth(3);
131  hAccToy->SetMarkerStyle(25);
132  hAccToy->SetMarkerColor(kGreen+2);
133  hAccToy->SetStats(0);
134  hAccToyFine->SetLineColor(kGreen+2);
135 
136 
137  TFile* out=new TFile(Form("outputEff%s.root",suffix.Data()),"recreate");
138  hAccToy->Write();
139  out->Close();
140 
141 
142 
143  TH2F* hEventMultZv=(TH2F*)l->FindObject("hEventMultZv");
144  if(hEventMultZv){
145  TH2F* hEventMultZvEvSel=(TH2F*)l->FindObject("hEventMultZvEvSel");
146  hEventMultZv->GetXaxis()->SetTitle("Z_{vertex} (cm)");
147  hEventMultZv->GetYaxis()->SetTitle("N_{tracklets}");
148  hEventMultZvEvSel->GetXaxis()->SetTitle("Z_{vertex} (cm)");
149  hEventMultZvEvSel->GetYaxis()->SetTitle("N_{tracklets}");
150  Int_t binzm10=hEventMultZvEvSel->GetXaxis()->FindBin(-9.999);
151  Int_t binzp10=hEventMultZvEvSel->GetXaxis()->FindBin(9.999);
152  printf("%d %f --- %d %f\n",binzm10,hEventMultZvEvSel->GetXaxis()->GetBinLowEdge(binzm10),
153  binzp10,hEventMultZvEvSel->GetXaxis()->GetBinUpEdge(binzp10));
154  TH1D* hMultAllEv=hEventMultZv->ProjectionY("hMultAllEv");
155  TH1D* hMultEvZ10=hEventMultZv->ProjectionY("hMultEvZ10",binzm10,binzp10);
156  TH1D* hMultEvSel=hEventMultZvEvSel->ProjectionY("hMultEvSel");
157  hMultAllEv->SetLineColor(1);
158  hMultEvZ10->SetLineColor(kGreen+2);
159  hMultEvSel->SetLineColor(6);
160  hMultAllEv->GetYaxis()->SetTitle("Entries");
161 
162  TH1D* hZvAllEv=hEventMultZv->ProjectionX("hZvAllEv");
163  TH1D* hZvEvSel=hEventMultZvEvSel->ProjectionX("hZvEvSel");
164  hZvAllEv->SetLineColor(1);
165  hZvEvSel->SetLineColor(6);
166  hZvAllEv->GetYaxis()->SetTitle("Entries");
167 
168  TH1D* hRatioMultEv=(TH1D*)hMultEvSel->Clone("hRatioMultEv");
169  hRatioMultEv->Divide(hMultEvSel,hMultEvZ10,1.,1.,"B");
170  hRatioMultEv->SetStats(0);
171  hRatioMultEv->GetYaxis()->SetTitle("Ratio");
172  hRatioMultEv->SetLineColor(4);
173  TH1D* hRatioMultEvAll=(TH1D*)hMultEvSel->Clone("hRatioMultEvAll");
174  hRatioMultEvAll->Divide(hMultEvSel,hMultAllEv,1.,1.,"B");
175  hRatioMultEvAll->SetStats(0);
176  hRatioMultEvAll->GetYaxis()->SetTitle("Ratio");
177  hRatioMultEvAll->SetLineColor(6);
178  TH1D* hRatioMultEvZ10=(TH1D*)hMultEvZ10->Clone("hRatioMultEvZ10");
179  hRatioMultEvZ10->Divide(hMultEvZ10,hMultAllEv,1.,1.,"B");
180  hRatioMultEvZ10->SetStats(0);
181  hRatioMultEvZ10->GetYaxis()->SetTitle("Ratio");
182  TH1D* hRatioZvEv=(TH1D*)hZvEvSel->Clone("hRatioZvEv");
183  hRatioZvEv->Divide(hZvEvSel,hZvAllEv,1.,1.,"B");
184  hRatioZvEv->SetStats(0);
185  hRatioZvEv->GetYaxis()->SetTitle("Ratio");
186 
187  TCanvas* cev=new TCanvas("cev","Event selection",1300,950);
188  cev->Divide(2,2);
189  cev->cd(1);
190  gPad->SetLogy();
191  gPad->SetTickx();
192  gPad->SetTicky();
193  if(maxMult>0) hMultAllEv->GetXaxis()->SetRangeUser(0.,maxMult);
194  hMultAllEv->Draw();
195  gPad->Update();
196  TPaveStats *sta=(TPaveStats*)hMultAllEv->GetListOfFunctions()->FindObject("stats");
197  sta->SetY1NDC(0.7);
198  sta->SetY2NDC(0.89);
199  gPad->Modified();
200  hMultEvZ10->Draw("sames");
201  gPad->Update();
202  TPaveStats *stz=(TPaveStats*)hMultEvZ10->GetListOfFunctions()->FindObject("stats");
203  stz->SetY1NDC(0.5);
204  stz->SetY2NDC(0.69);
205  stz->SetTextColor(hMultEvZ10->GetLineColor());
206  gPad->Modified();
207  hMultEvSel->Draw("sames");
208  gPad->Update();
209  TPaveStats *stb=(TPaveStats*)hMultEvSel->GetListOfFunctions()->FindObject("stats");
210  stb->SetY1NDC(0.3);
211  stb->SetY2NDC(0.49);
212  stb->SetTextColor(hMultEvSel->GetLineColor());
213  gPad->Modified();
214  cev->cd(3);
215  gPad->SetTickx();
216  gPad->SetTicky();
217  hRatioMultEvAll->SetMinimum(0.);
218  if(maxMult>0) hRatioMultEvAll->GetXaxis()->SetRangeUser(0.,maxMult);
219  hRatioMultEvAll->Draw();
220  hRatioMultEvZ10->Draw("same");
221  hRatioMultEv->Draw("same");
222  TLegend* leg=new TLegend(0.45,0.3,0.89,0.7);
223  leg->AddEntry(hRatioMultEvAll,"EvSel / AllEv","L")->SetTextColor(hRatioMultEvAll->GetLineColor());
224  leg->AddEntry(hRatioMultEvZ10,"Ev(|z|<10) / AllEv","L")->SetTextColor(hRatioMultEvZ10->GetLineColor());
225  leg->AddEntry(hRatioMultEv,"EvSel / Ev(|z|<10)","L")->SetTextColor(hRatioMultEv->GetLineColor());
226  leg->Draw();
227  cev->cd(2);
228  gPad->SetTickx();
229  gPad->SetTicky();
230  hZvAllEv->Draw();
231  gPad->Update();
232  TPaveStats *stc=(TPaveStats*)hZvAllEv->GetListOfFunctions()->FindObject("stats");
233  stc->SetY1NDC(0.7);
234  stc->SetY2NDC(0.89);
235  gPad->Modified();
236  hZvEvSel->Draw("sames");
237  gPad->Update();
238  TPaveStats *std=(TPaveStats*)hZvEvSel->GetListOfFunctions()->FindObject("stats");
239  std->SetY1NDC(0.5);
240  std->SetY2NDC(0.69);
241  std->SetTextColor(hZvEvSel->GetLineColor());
242  gPad->Modified();
243  cev->cd(4);
244  gPad->SetTickx();
245  gPad->SetTicky();
246  hRatioZvEv->SetMinimum(0.85);
247  hRatioZvEv->SetMaximum(1.01);
248  hRatioZvEv->Draw();
249  cev->SaveAs(Form("figures/FracEvSel%s.eps",suffix.Data()));
250  }
251 
252  ComputeAndWriteEff(l,"Prompt","Mult");
253  if(ptBWeight==kNoPtBWei){
254  ComputeAndWriteEff(l,"Feeddw","Mult");
255  }else{
256  ComputeAndWriteEff(l,"Feeddw","PtB");
257  }
258 
259  TFile* outup=new TFile(Form("outputEff%s.root",suffix.Data()),"update");
260  outup->ls();
261  TH1D* hEffPr=(TH1D*)outup->Get("hEffPromptVsPtNoWeight");
262  TH1D* hEffFd=(TH1D*)outup->Get("hEffFeeddwVsPtNoWeight");
263  if(ptBWeight!=kNoPtBWei) hEffFd=(TH1D*)outup->Get("hEffFeeddwVsPtPtBWeight");
264  hEffFd->SetLineColor(kGray+1);
265  hEffFd->SetMarkerColor(kGray+1);
266  hEffFd->SetMarkerStyle(24);
267 
268  TCanvas* cpf=new TCanvas("cpf","Prompt vs Feeddown",1200,600);
269  cpf->Divide(2,1);
270  cpf->cd(1);
271  gPad->SetTickx();
272  gPad->SetTicky();
273  hAccToy->GetYaxis()->SetTitle("Efficiency, acceptance");
274  hAccToy->GetYaxis()->SetTitleOffset(1.3);
275  hAccToy->Draw();
276  hAccToy->SetMinimum(0);
277  hEffPr->DrawCopy("same");
278  hEffFd->DrawCopy("same");
279  TH1D* hEffD=(TH1D*)hEffPr->Clone("hEffD");
280  hEffD->Reset("imen");
281  TH1D* hEffB=(TH1D*)hEffFd->Clone("hEffB");
282  hEffB->Reset("imen");
283  TH1D* hRatioEff=(TH1D*)hEffFd->Clone("hRatioEff");
284  hRatioEff->Reset("imen");
285 
286  for(Int_t iBin=1; iBin<=hEffPr->GetNbinsX(); iBin++){
287  Double_t lowPt=hEffPr->GetXaxis()->GetBinLowEdge(iBin);
288  Double_t highPt=hEffPr->GetXaxis()->GetBinUpEdge(iBin);
289  Double_t pt=hEffPr->GetBinCenter(iBin);
290 
291  Int_t theBinB=hEffFd->FindBin(pt);
292  Double_t lowPtB=hEffFd->GetXaxis()->GetBinLowEdge(theBinB);
293  Double_t highPtB=hEffFd->GetXaxis()->GetBinUpEdge(theBinB);
294 
295  Int_t theBinA=hAccToy->FindBin(pt);
296  Double_t lowPtA=hAccToy->GetXaxis()->GetBinLowEdge(theBinA);
297  Double_t highPtA=hAccToy->GetXaxis()->GetBinUpEdge(theBinA);
298 
299  if(TMath::Abs(lowPtA-lowPt)>0.001 ||
300  TMath::Abs(lowPtB-lowPt)>0.001 ||
301  TMath::Abs(highPtA-highPt)>0.001 ||
302  TMath::Abs(highPtB-highPt)>0.001){
303  printf("ERROR IN BINNING: %f %f %f %f %f %f\n",lowPt,highPt,lowPtA,highPtA,lowPtB,highPtB);
304  return;
305  }
306 
307  Double_t effD=hEffPr->GetBinContent(iBin);
308  Double_t acc=hAccToy->GetBinContent(theBinA);
309  Double_t effB=hEffFd->GetBinContent(theBinB);
310 
311  Double_t effDerr=hEffPr->GetBinError(iBin);
312  Double_t accerr=hAccToy->GetBinError(theBinA);
313  Double_t effBerr=hEffFd->GetBinError(theBinB);
314 
315  Double_t acceffD=effD*acc;
316  Double_t acceffB=effB*acc;
317  Double_t acceffDerr=TMath::Sqrt(acc*acc*effDerr*effDerr+effD*effD*accerr*accerr);
318  Double_t acceffBerr=TMath::Sqrt(acc*acc*effBerr*effBerr+effB*effB*accerr*accerr);
319 
320  Double_t r=-999.;
321  Double_t er=0.;
322  if(effD>0 && effB>0){
323  r=effB/effD;
324  er=r*TMath::Sqrt(effDerr/effD*effDerr/effD+effBerr/effB*effBerr/effB);
325  }
326  printf("Bin %d acc=%f+-%f\n",iBin,acc,accerr);
327  printf(" effD=%f+-%f acc*effD=%f+-%f\n",effD,effDerr,acceffD,acceffDerr);
328  printf(" effB=%f+-%f acc*effB=%f+-%f\n",effB,effBerr,acceffB,acceffBerr);
329  printf(" r=%f+-%f\n",r,er);
330  hEffD->SetBinContent(iBin,acceffD);
331  hEffD->SetBinError(iBin,acceffDerr);
332  hEffB->SetBinContent(iBin,acceffB);
333  hEffB->SetBinError(iBin,acceffBerr);
334  hRatioEff->SetBinContent(iBin,r);
335  hRatioEff->SetBinError(iBin,er);
336 
337  }
338 
339  hEffD->SetMarkerStyle(21);
340  hEffD->SetMarkerColor(2);
341  hEffD->SetLineColor(2);
342  hEffD->DrawCopy("same");
343  hEffB->SetMarkerStyle(25);
344  hEffB->SetMarkerColor(kRed+1);
345  hEffB->SetLineColor(kRed+1);
346  hEffB->DrawCopy("same");
347 
348  TLegend* legpf=new TLegend(0.6,0.16,0.89,0.36);
349  legpf->AddEntry(Form("%s_copy",hEffPr->GetName()),"Effic. prompt","P");
350  legpf->AddEntry(Form("%s_copy",hEffFd->GetName()),"Effic. feeddown","P");
351  legpf->AddEntry(hAccToy,"Acceptance","P");
352  legpf->AddEntry(Form("%s_copy",hEffD->GetName()),"Acc x eff prompt","P");
353  legpf->AddEntry(Form("%s_copy",hEffB->GetName()),"Acc x eff feeddown","P");
354  legpf->Draw();
355  cpf->cd(2);
356  gPad->SetTickx();
357  gPad->SetTicky();
358  hRatioEff->SetStats(0);
359  hRatioEff->SetMarkerColor(kBlue+1);
360  hRatioEff->SetLineColor(kBlue+1);
361  hRatioEff->SetMarkerStyle(20);
362  hRatioEff->SetMinimum(0.92);
363  hRatioEff->SetMaximum(1.07);
364  hRatioEff->GetYaxis()->SetTitle("Ratio efficiency feeddown/prompt");
365  hRatioEff->GetYaxis()->SetTitleOffset(1.3);
366  hRatioEff->DrawCopy();
367  cpf->SaveAs(Form("figures/EfficVsPt_PromptFd_%s.eps",suffix.Data()));
368 
369  outup->cd();
370  hEffD->Write();
371  hEffB->Write();
372  outup->Close();
373 
374 
375 
376 }
377 
378 void ComputeAndWriteEff(TList* l, TString dCase, TString var3){
379 
380  TH3F* hPtVsYVsVar3Reco=(TH3F*)l->FindObject(Form("hPtVsYVs%sReco%s",var3.Data(),dCase.Data()));
381  if(var3=="PtB" && !hPtVsYVsVar3Reco){
382  printf("WARNING: pt(B) weight cannot be applied because histos are not there -> re-run with more recent version of the task\n");
383  printf(" ---> Resort to mult weights\n");
384  var3="Mult";
385  hPtVsYVsVar3Reco=(TH3F*)l->FindObject(Form("hPtVsYVs%sReco%s",var3.Data(),dCase.Data()));
386  }
387  TH3F* hPtVsYVsVar3GenAccEvSel=(TH3F*)l->FindObject(Form("hPtVsYVs%sGenAccEvSel%s",var3.Data(),dCase.Data()));
388  TH3F* hPtVsYVsVar3GenAcc=(TH3F*)l->FindObject(Form("hPtVsYVs%sGenAcc%s",var3.Data(),dCase.Data()));
389  TH3F* hPtVsYVsVar3GenLimAcc=(TH3F*)l->FindObject(Form("hPtVsYVs%sGenLimAcc%s",var3.Data(),dCase.Data()));
390  TString zTitle="N_{tracklets} in |#eta|<1";
391  if(var3=="PtB"){
392  zTitle="B-hadron p_{T} (GeV/c)";
393  maxMult=-1;
394  }
395 
396  TH2D* hypt=(TH2D*)hPtVsYVsVar3GenAcc->Project3D("yx");
397  hypt->SetTitle(Form("Generated in acceptance, all multiplcities, %s",dCase.Data()));
398  TH2D* hptmult=(TH2D*)hPtVsYVsVar3GenLimAcc->Project3D("xz");
399  hptmult->SetTitle(Form("Generated in |y|<0.5, %s",dCase.Data()));
400  hptmult->SetStats(0);
401  hypt->SetStats(0);
402  hypt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
403  hypt->GetYaxis()->SetTitle("y");
404  hptmult->GetYaxis()->SetTitle("p_{T} (GeV/c)");
405  hptmult->GetXaxis()->SetTitle(zTitle.Data());
406  if(maxMult>0) hptmult->GetXaxis()->SetRangeUser(0.,maxMult);
407  TProfile* hMeanPtVar3=hptmult->ProfileX(Form("hMeanPt%s%s",var3.Data(),dCase.Data()));
408 
409  TCanvas* c0=new TCanvas(Form("c0%s",dCase.Data()),Form("%s - 2D plots",dCase.Data()),1200,600);
410  c0->Divide(2,1);
411  c0->cd(1);
412  gPad->SetLogz();
413  gPad->SetRightMargin(0.12);
414  hypt->Draw("colz");
415  c0->cd(2);
416  gPad->SetLogz();
417  gPad->SetRightMargin(0.13);
418  hptmult->Draw("colz");
419  hMeanPtVar3->Draw("same");
420 
421  TH1D* hPtReco=hPtVsYVsVar3Reco->ProjectionX(Form("hPtReco%s",dCase.Data()));
422  TH1D* hPtGenAcc=hPtVsYVsVar3GenAcc->ProjectionX(Form("hPtGenAcc%s",dCase.Data()));
423  TH1D* hPtGenAccEvSel=0x0;
424  if(hPtVsYVsVar3GenAccEvSel) hPtGenAccEvSel=hPtVsYVsVar3GenAccEvSel->ProjectionX(Form("hPtGenAccEvSel%s",dCase.Data()));
425  TH1D* hPtGenLimAcc=hPtVsYVsVar3GenLimAcc->ProjectionX(Form("hPtGenLimAcc%s",dCase.Data()));
426  TH1D* hPtRecoR=(TH1D*)hPtReco->Rebin(nPtBins,Form("hPtReco%sReb",dCase.Data()),binLims);
427  TH1D* hPtGenAccR=(TH1D*)hPtGenAcc->Rebin(nPtBins,Form("hPtGenAcc%sReb",dCase.Data()),binLims);
428  TH1D* hPtGenLimAccR=(TH1D*)hPtGenLimAcc->Rebin(nPtBins,Form("hPtGenLimAcc%sReb",dCase.Data()),binLims);
429  TH1D* hEffVsPt=(TH1D*)hPtReco->Clone(Form("hEff%s",dCase.Data()));
430  hEffVsPt->Divide(hPtReco,hPtGenAcc,1,1,"B");
431  TH1D* hEffVsPtR=(TH1D*)hPtRecoR->Clone(Form("hEff%sRebin",dCase.Data()));
432  hEffVsPtR->Divide(hPtRecoR,hPtGenAccR,1,1,"B");
433  hEffVsPt->SetStats(0);
434  hEffVsPtR->SetStats(0);
435  TH1D* hAccVsPt=(TH1D*)hPtGenAcc->Clone(Form("hAcc%s",dCase.Data()));
436  hAccVsPt->Divide(hPtGenAcc,hPtGenLimAcc,1,1,"B");
437  TH1D* hAccVsPtR=(TH1D*)hPtGenAccR->Clone(Form("hAcc%sReb",dCase.Data()));
438  hAccVsPtR->Divide(hPtGenAccR,hPtGenLimAccR,1,1,"B");
439  hAccVsPt->SetStats(0);
440  hAccVsPtR->SetStats(0);
441  TH1D* hEvSelEffVsPt=0x0;
442  if(hPtGenAccEvSel){
443  hEvSelEffVsPt=(TH1D*)hPtGenAccEvSel->Clone(Form("hEvSelEff%s",dCase.Data()));
444  hEvSelEffVsPt->Divide(hPtGenAccEvSel,hPtGenAcc,1,1,"B");
445  hEvSelEffVsPt->SetStats(0);
446  }
447 
448 
449  TCanvas* c1a=new TCanvas(Form("c1a%s",dCase.Data()),Form("%s - AccVsPt",dCase.Data()),1200,600);
450  c1a->Divide(2,1);
451  c1a->cd(1);
452  gPad->SetLogy();
453  hPtGenLimAcc->GetXaxis()->SetTitle("p_{T} (GeV/c)");
454  hPtGenLimAcc->GetYaxis()->SetTitle("Entries");
455  hPtGenLimAcc->SetLineColor(1);
456  hPtGenLimAcc->Draw();
457  gPad->Update();
458  TPaveStats *st1=(TPaveStats*)hPtGenLimAcc->GetListOfFunctions()->FindObject("stats");
459  st1->SetY1NDC(0.7);
460  st1->SetY2NDC(0.89);
461  hPtGenAcc->SetLineColor(2);
462  hPtGenAcc->Draw("sames");
463  gPad->Update();
464  TPaveStats *st2=(TPaveStats*)hPtGenAcc->GetListOfFunctions()->FindObject("stats");
465  st2->SetY1NDC(0.5);
466  st2->SetY2NDC(0.69);
467  st2->SetTextColor(2);
468  if(hPtGenAccEvSel){
469  hPtGenAccEvSel->SetLineColor(6);
470  hPtGenAccEvSel->Draw("sames");
471  gPad->Update();
472  TPaveStats *st2s=(TPaveStats*)hPtGenAccEvSel->GetListOfFunctions()->FindObject("stats");
473  st2s->SetY1NDC(0.3);
474  st2s->SetY2NDC(0.49);
475  st2s->SetTextColor(6);
476  }
477  hPtReco->SetLineColor(4);
478  hPtReco->Draw("sames");
479  gPad->Update();
480  TPaveStats *st13=(TPaveStats*)hPtReco->GetListOfFunctions()->FindObject("stats");
481  st13->SetY1NDC(0.1);
482  st13->SetY2NDC(0.29);
483  st13->SetTextColor(4);
484  gPad->Modified();
485  c1a->cd(2);
486  hEffVsPt->SetLineColor(4);
487  hEffVsPt->SetMinimum(0);
488  hEffVsPt->SetMaximum(1.95);
489  hEffVsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
490  hEffVsPt->GetYaxis()->SetTitle("Ratio");
491  hEffVsPt->Draw();
492  hAccVsPt->SetLineColor(2);
493  hAccVsPt->Draw("same");
494  hAccToyFine->Draw("same");
495  hAccToy->Draw("same");
496  TLatex* tacc=new TLatex(0.16,0.83,"Acceptance (CombinHF)");
497  tacc->SetNDC();
498  tacc->SetTextColor(hAccVsPt->GetLineColor());
499  tacc->Draw();
500  TLatex* tacct=new TLatex(0.16,0.76,"Acceptance (ToyMC)");
501  tacct->SetNDC();
502  tacct->SetTextColor(hAccToyFine->GetLineColor());
503  tacct->Draw();
504  TLatex* te=new TLatex(0.16,0.69,"Efficiency");
505  te->SetNDC();
506  te->SetTextColor(hEffVsPt->GetLineColor());
507  te->Draw();
508 
509 
510  TCanvas* c1e=new TCanvas(Form("c1e%s",dCase.Data()),Form("%s - EffVsPt",dCase.Data()),1200,600);
511  c1e->Divide(2,1);
512  c1e->cd(1);
513  gPad->SetLogy();
514  hPtGenLimAcc->GetXaxis()->SetTitle("p_{T} (GeV/c)");
515  hPtGenLimAcc->GetYaxis()->SetTitle("Entries");
516  hPtGenLimAcc->SetLineColor(1);
517  hPtGenLimAcc->Draw();
518  gPad->Update();
519  TPaveStats *st11=(TPaveStats*)hPtGenLimAcc->GetListOfFunctions()->FindObject("stats");
520  st11->SetY1NDC(0.7);
521  st11->SetY2NDC(0.89);
522  hPtGenAcc->SetLineColor(2);
523  hPtGenAcc->Draw("sames");
524  gPad->Update();
525  TPaveStats *st12=(TPaveStats*)hPtGenAcc->GetListOfFunctions()->FindObject("stats");
526  st12->SetY1NDC(0.5);
527  st12->SetY2NDC(0.69);
528  st12->SetTextColor(2);
529  if(hPtGenAccEvSel){
530  hPtGenAccEvSel->SetLineColor(6);
531  hPtGenAccEvSel->Draw("sames");
532  gPad->Update();
533  TPaveStats *st12s=(TPaveStats*)hPtGenAccEvSel->GetListOfFunctions()->FindObject("stats");
534  st12s->SetY1NDC(0.3);
535  st12s->SetY2NDC(0.49);
536  st12s->SetTextColor(6);
537  }
538  hPtReco->SetLineColor(4);
539  hPtReco->Draw("sames");
540  gPad->Update();
541  TPaveStats *st3=(TPaveStats*)hPtReco->GetListOfFunctions()->FindObject("stats");
542  st3->SetY1NDC(0.1);
543  st3->SetY2NDC(0.29);
544  st3->SetTextColor(4);
545  gPad->Modified();
546  c1e->cd(2);
547  TLatex* t1=new TLatex(6.,0.25,"GenAccInEvSel / GenAcc");
548  t1->SetTextColor(6);
549  if(hPtGenAccEvSel){
550  hEvSelEffVsPt->SetLineColor(6);
551  hEvSelEffVsPt->SetMinimum(0);
552  hEvSelEffVsPt->SetMaximum(1.05);
553  hEvSelEffVsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
554  hEvSelEffVsPt->GetYaxis()->SetTitle("Ratio");
555  hEvSelEffVsPt->Draw();
556  t1->Draw();
557  }
558  hEffVsPt->Draw("same");
559  TLatex* t3=new TLatex(6.,0.15,"Reco / GenAcc");
560  t3->SetTextColor(4);
561  t3->Draw();
562  c1e->SaveAs(Form("figures/EfficVsPt_%s_%s.eps",suffix.Data(),dCase.Data()));
563 
564  TH1D* hVar3RecoAllPt=hPtVsYVsVar3Reco->ProjectionZ(Form("hVar3Reco%s",dCase.Data()));
565  TH1D* hVar3GenAccAllPt=hPtVsYVsVar3GenAcc->ProjectionZ(Form("hVar3GenAcc%s",dCase.Data()));
566  TH1D* hVar3GenAccEvSelAllPt=0x0;
567  if(hPtVsYVsVar3GenAccEvSel) hVar3GenAccEvSelAllPt=hPtVsYVsVar3GenAccEvSel->ProjectionZ(Form("hVar3GenAccEvSel%s",dCase.Data()));
568  TH1D* hVar3GenLimAccAllPt=hPtVsYVsVar3GenLimAcc->ProjectionZ(Form("hVar3GenLimAcc%s",dCase.Data()));
569  TH1D* hEffVsVar3AllPt=(TH1D*)hVar3RecoAllPt->Clone(Form("hEff%s",dCase.Data()));
570  hEffVsVar3AllPt->Divide(hVar3RecoAllPt,hVar3GenAccAllPt,1,1,"B");
571  TH1D* hAccEffVsVar3AllPt=(TH1D*)hVar3RecoAllPt->Clone(Form("hAccEff%s",dCase.Data()));
572  hAccEffVsVar3AllPt->Divide(hVar3RecoAllPt,hVar3GenLimAccAllPt,1,1,"B");
573  TH1D* hAccVsVar3AllPt=(TH1D*)hVar3GenAccAllPt->Clone(Form("hAcc%s",dCase.Data()));
574  hAccVsVar3AllPt->Divide(hVar3GenAccAllPt,hVar3GenLimAccAllPt,1,1,"B");
575  hEffVsVar3AllPt->SetStats(0);
576  hAccVsVar3AllPt->SetStats(0);
577  hAccEffVsVar3AllPt->SetStats(0);
578  TH1D* hEvSelEffVsVar3AllPt=0x0;
579  if(hVar3GenAccEvSelAllPt){
580  hEvSelEffVsVar3AllPt=(TH1D*)hVar3GenAccEvSelAllPt->Clone(Form("hEvSelEff%s%s",var3.Data(),dCase.Data()));
581  hEvSelEffVsVar3AllPt->Divide(hVar3GenAccEvSelAllPt,hVar3GenAccAllPt,1,1,"B");
582  hEvSelEffVsVar3AllPt->SetStats(0);
583  }
584 
585  TCanvas* c2a=new TCanvas(Form("c2a%s",dCase.Data()),Form("%s - AccVs%s",dCase.Data(),var3.Data()),1200,600);
586  c2a->Divide(2,1);
587  c2a->cd(1);
588  gPad->SetLogy();
589  hVar3GenLimAccAllPt->SetLineColor(1);
590  hVar3GenLimAccAllPt->GetXaxis()->SetTitle(zTitle.Data());
591  hVar3GenLimAccAllPt->GetYaxis()->SetTitle("Entries");
592  if(maxMult>0) hVar3GenLimAccAllPt->GetXaxis()->SetRangeUser(0.,maxMult);
593  hVar3GenLimAccAllPt->Draw();
594  gPad->Update();
595  TPaveStats *st21=(TPaveStats*)hVar3GenLimAccAllPt->GetListOfFunctions()->FindObject("stats");
596  st21->SetY1NDC(0.7);
597  st21->SetY2NDC(0.89);
598  hVar3GenAccAllPt->SetLineColor(2);
599  hVar3GenAccAllPt->Draw("sames");
600  gPad->Update();
601  TPaveStats *st22=(TPaveStats*)hVar3GenAccAllPt->GetListOfFunctions()->FindObject("stats");
602  st22->SetY1NDC(0.5);
603  st22->SetY2NDC(0.69);
604  st22->SetTextColor(2);
605  if(hVar3GenAccEvSelAllPt){
606  hVar3GenAccEvSelAllPt->SetLineColor(6);
607  hVar3GenAccEvSelAllPt->Draw("sames");
608  gPad->Update();
609  TPaveStats *st22s=(TPaveStats*)hVar3GenAccEvSelAllPt->GetListOfFunctions()->FindObject("stats");
610  st22s->SetY1NDC(0.3);
611  st22s->SetY2NDC(0.49);
612  st22s->SetTextColor(6);
613  }
614  hVar3RecoAllPt->SetLineColor(4);
615  hVar3RecoAllPt->Draw("sames");
616  gPad->Update();
617  TPaveStats *st23=(TPaveStats*)hVar3RecoAllPt->GetListOfFunctions()->FindObject("stats");
618  st23->SetY1NDC(0.1);
619  st23->SetY2NDC(0.29);
620  st23->SetTextColor(4);
621  gPad->Modified();
622  c2a->cd(2);
623  hEffVsVar3AllPt->SetLineColor(4);
624  hEffVsVar3AllPt->SetMinimum(0);
625  hEffVsVar3AllPt->SetMaximum(1.6);
626  hEffVsVar3AllPt->GetXaxis()->SetTitle(zTitle.Data());
627  hEffVsVar3AllPt->GetYaxis()->SetTitle("Ratio");
628  if(maxMult>0) hEffVsVar3AllPt->GetXaxis()->SetRangeUser(0.,maxMult);
629  hEffVsVar3AllPt->Draw();
630  hAccVsVar3AllPt->SetLineColor(2);
631  hAccVsVar3AllPt->Draw("same");
632  // hAccEffVsVar3AllPt->SetLineColor(6);
633  // hAccEffVsVar3AllPt->Draw("same");
634  TLatex* tacc2=new TLatex(0.16,0.8,"Acceptance (CombinHF)");
635  tacc2->SetNDC();
636  tacc2->SetTextColor(hAccVsVar3AllPt->GetLineColor());
637  tacc2->Draw();
638  TLatex* te2=new TLatex(0.16,0.72,"Efficiency");
639  te2->SetNDC();
640  te2->SetTextColor(hEffVsVar3AllPt->GetLineColor());
641  te2->Draw();
642 
643  TCanvas* c2e=new TCanvas(Form("c2e%s",dCase.Data()),Form("%s - EffVs%s",dCase.Data(),var3.Data()),1200,600);
644  c2e->Divide(2,1);
645  c2e->cd(1);
646  gPad->SetLogy();
647  hVar3GenLimAccAllPt->GetXaxis()->SetTitle(zTitle.Data());
648  hVar3GenLimAccAllPt->GetYaxis()->SetTitle("Entries");
649  if(maxMult>0) hVar3GenLimAccAllPt->GetXaxis()->SetRangeUser(0.,maxMult);
650  hVar3GenLimAccAllPt->SetLineColor(1);
651  hVar3GenLimAccAllPt->Draw();
652  gPad->Update();
653  TPaveStats *st1e=(TPaveStats*)hVar3GenLimAccAllPt->GetListOfFunctions()->FindObject("stats");
654  st1e->SetY1NDC(0.7);
655  st1e->SetY2NDC(0.89);
656  hVar3GenAccAllPt->SetLineColor(2);
657  hVar3GenAccAllPt->Draw("sames");
658  gPad->Update();
659  TPaveStats *st2e=(TPaveStats*)hVar3GenAccAllPt->GetListOfFunctions()->FindObject("stats");
660  st2e->SetY1NDC(0.5);
661  st2e->SetY2NDC(0.69);
662  st2e->SetTextColor(2);
663  if(hVar3GenAccEvSelAllPt){
664  hVar3GenAccEvSelAllPt->SetLineColor(6);
665  hVar3GenAccEvSelAllPt->Draw("sames");
666  gPad->Update();
667  TPaveStats *st2se=(TPaveStats*)hVar3GenAccEvSelAllPt->GetListOfFunctions()->FindObject("stats");
668  st2se->SetY1NDC(0.3);
669  st2se->SetY2NDC(0.49);
670  st2se->SetTextColor(6);
671  }
672  hVar3RecoAllPt->SetLineColor(4);
673  hVar3RecoAllPt->Draw("sames");
674  gPad->Update();
675  TPaveStats *st3s=(TPaveStats*)hVar3RecoAllPt->GetListOfFunctions()->FindObject("stats");
676  st3s->SetY1NDC(0.1);
677  st3s->SetY2NDC(0.29);
678  st3s->SetTextColor(4);
679  gPad->Modified();
680  c2e->cd(2);
681  gPad->SetTickx();
682  gPad->SetTicky();
683  if(hVar3GenAccEvSelAllPt){
684  hEvSelEffVsVar3AllPt->SetLineColor(6);
685  hEvSelEffVsVar3AllPt->SetMinimum(0);
686  hEvSelEffVsVar3AllPt->SetMaximum(1.05);
687  hEvSelEffVsVar3AllPt->GetXaxis()->SetTitle(zTitle.Data());
688  hEvSelEffVsVar3AllPt->GetYaxis()->SetTitle("Ratio");
689  if(maxMult>0) hEvSelEffVsVar3AllPt->GetXaxis()->SetRangeUser(0.,maxMult);
690  hEvSelEffVsVar3AllPt->Draw();
691  t1->Draw();
692  }
693  hEffVsVar3AllPt->SetLineColor(4);
694  hEffVsVar3AllPt->Draw("same");
695  t3->Draw();
696  c2e->SaveAs(Form("figures/EfficVs%s_%s_%s.eps",var3.Data(),suffix.Data(),dCase.Data()));
697 
698  if(var3=="Mult"){
699 
700  const Int_t nMultBins=6;
701  Double_t mulLims[nMultBins+1]={0.,5.,12.,20.,40.,80.,200.};
702  if(hPtVsYVsVar3Reco->GetZaxis()->GetXmax()>300. && maxMult<0){
703  for(Int_t jb=0; jb<=nMultBins; jb++) mulLims[jb]=(Double_t)jb/nMultBins*hPtVsYVsVar3Reco->GetZaxis()->GetXmax();
704  }
705  Int_t mulcol[nMultBins]={1,kRed+1,kGreen+2,4,kOrange+2,kMagenta};
706 
707  TH1D* hPtRecoM[nMultBins];
708  TH1D* hPtGenAccM[nMultBins];
709  // TH1D* hPtGenLimAccM[nMultBins];
710  TH1D* hEffVsPtM[nMultBins];
711  for(Int_t j=0; j<nMultBins; j++){
712  Int_t lowBin=hPtVsYVsVar3Reco->GetZaxis()->FindBin(mulLims[j]);
713  Int_t hiBin=hPtVsYVsVar3Reco->GetZaxis()->FindBin(mulLims[j+1]-0.001);
714  // printf("%d (%f) %d(%f)\n",lowBin,hPtVsYVsMultReco->GetZaxis()->GetBinLowEdge(lowBin),hiBin,hPtVsYVsMultReco->GetZaxis()->GetBinUpEdge(hiBin));
715 
716  hPtRecoM[j]=hPtVsYVsVar3Reco->ProjectionX(Form("hPtRecoM%d",j),0,-1,lowBin,hiBin);
717  hPtGenAccM[j]=hPtVsYVsVar3GenAcc->ProjectionX(Form("hPtGenAccM%d",j),0,-1,lowBin,hiBin);
718  // hPtGenLimAccM[j]=hPtVsYVsVar3GenLimAcc->ProjectionX(Form("hPtGenLimAccM%d",j),0,-1,lowBin,hiBin);
719  hEffVsPtM[j]=(TH1D*)hPtRecoM[j]->Clone(Form("hEffM%d",j));
720  hEffVsPtM[j]->Divide(hPtRecoM[j],hPtGenAccM[j],1,1,"B");
721  }
722 
723  hEffVsPtM[0]->SetStats(0);
724  TCanvas* cwp=new TCanvas(Form("cwp%s",dCase.Data()),Form("%s - Eff and Wei vs. Pt",dCase.Data()),1200,600);
725  cwp->Divide(2,1);
726  cwp->cd(1);
727  gPad->SetLeftMargin(0.12);
728  hEffVsPtM[0]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
729  hEffVsPtM[0]->GetYaxis()->SetTitle("Efficiency");
730  hEffVsPtM[0]->GetYaxis()->SetTitleOffset(1.4);
731  hEffVsPtM[0]->SetLineColor(mulcol[0]);
732  hEffVsPtM[0]->SetMinimum(0);
733  hEffVsPtM[0]->SetMaximum(1.8);
734  hEffVsPtM[0]->Draw();
735  TLegend* legp=new TLegend(0.16,0.5,0.55,0.89);
736  legp->SetFillStyle(0);
737  legp->SetBorderSize(0);
738  legp->AddEntry(hEffVsPtM[0],Form("%.0f<N_{tracklets}<%.0f",mulLims[0],mulLims[1]),"L")->SetTextColor(mulcol[0]);
739  for(Int_t j=1; j<nMultBins; j++){
740  hEffVsPtM[j]->SetLineColor(mulcol[j]);
741  hEffVsPtM[j]->Draw("same");
742  legp->AddEntry(hEffVsPtM[j],Form("%.0f<N_{tracklets}<%.0f",mulLims[j],mulLims[j+1]),"L")->SetTextColor(mulcol[j]);
743  }
744  legp->Draw();
745  cwp->cd(2);
746  gPad->SetLeftMargin(0.12);
747  funcPtWeight->SetTitle("");
748  funcPtWeight->GetXaxis()->SetTitle("p_{T} (GeV/c)");
749  funcPtWeight->GetYaxis()->SetTitle("Weight");
750  funcPtWeight->Draw();
751  cwp->SaveAs(Form("figures/EfficVsPtMultBins_%s_%s.eps",suffix.Data(),dCase.Data()));
752 
753  TH1D* hMultReco[nPtBins];
754  TH1D* hMultGenAcc[nPtBins];
755  // TH1D* hMultGenLimAcc[nPtBins];
756  TH1D* hEffVsMult[nPtBins];
757  for(Int_t j=0; j<nPtBins; j++){
758  Int_t lowBin=hPtVsYVsVar3Reco->GetXaxis()->FindBin(binLims[j]);
759  Int_t hiBin=hPtVsYVsVar3Reco->GetXaxis()->FindBin(binLims[j+1]-0.001);
760  //printf("%d (%f) %d(%f)\n",lowBin,hPtVsYVsVar3Reco->GetXaxis()->GetBinLowEdge(lowBin),hiBin,hPtVsYVsVar3Reco->GetXaxis()->GetBinUpEdge(hiBin));
761 
762  hMultReco[j]=hPtVsYVsVar3Reco->ProjectionZ(Form("hMultReco%s%d",dCase.Data(),j),lowBin,hiBin);
763  hMultGenAcc[j]=hPtVsYVsVar3GenAcc->ProjectionZ(Form("hMultGenAcc%s%d",dCase.Data(),j),lowBin,hiBin);
764  // hMultGenLimAcc[j]=hPtVsYVsVar3GenLimAcc->ProjectionZ(Form("hMultGenLimAcc%d",j),lowBin,hiBin);
765  hEffVsMult[j]=(TH1D*)hMultReco[j]->Clone(Form("hEff%s%d",dCase.Data(),j));
766  hEffVsMult[j]->Divide(hMultReco[j],hMultGenAcc[j],1,1,"B");
767  }
768 
769  // TCanvas* c2e=new TCanvas("c2e");
770  // hEffVsMult[0]->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
771  // hEffVsMult[0]->GetYaxis()->SetTitle("Efficiency");
772  // hEffVsMult[0]->GetYaxis()->SetTitleOffset(1.4);
773  // hEffVsMult[0]->SetLineColor(ptcol[0]);
774  // hEffVsMult[0]->SetMinimum(0);
775  // hEffVsMult[0]->SetMaximum(1.6);
776  // hEffVsMult[0]->Draw();
777  // TLegend* legm=new TLegend(0.16,0.5,0.4,0.89);
778  // legm->SetFillStyle(0);
779  // legm->SetBorderSize(0);
780  // legm->AddEntry(hEffVsMult[0],Form("%.0f<p_{T}<%.0f GeV/c",binLims[0],binLims[1]),"L")->SetTextColor(ptcol[0]);
781  // for(Int_t j=1; j<nPtBins; j++){
782  // hEffVsMult[j]->SetLineColor(ptcol[j]);
783  // hEffVsMult[j]->Draw("same");
784  // legm->AddEntry(hEffVsMult[j],Form("%.0f<p_{T}<%.0f GeV/c",binLims[j],binLims[j+1]),"L")->SetTextColor(ptcol[j]);
785  // }
786  // legm->Draw();
787 
788 
789 
790  hEffVsMult[0]->SetStats(0);
791  TCanvas* cw=new TCanvas(Form("cw%s",dCase.Data()),Form("%s - Eff and wei vs. mult",dCase.Data()),1200,600);
792  cw->Divide(2,1);
793  cw->cd(1);
794  gPad->SetLeftMargin(0.12);
795  if(maxMult>0) hEffVsMult[0]->GetXaxis()->SetRangeUser(0.,maxMult);
796  hEffVsMult[0]->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
797  hEffVsMult[0]->GetYaxis()->SetTitle("Efficiency");
798  hEffVsMult[0]->GetYaxis()->SetTitleOffset(1.4);
799  hEffVsMult[0]->SetLineColor(ptcol[0]);
800  hEffVsMult[0]->SetMinimum(0);
801  hEffVsMult[0]->SetMaximum(1.6);
802  hEffVsMult[0]->Draw();
803  TLegend* legm=new TLegend(0.16,0.5,0.4,0.89);
804  legm->SetFillStyle(0);
805  legm->SetBorderSize(0);
806  legm->AddEntry(hEffVsMult[0],Form("%.0f<p_{T}<%.0f GeV/c",binLims[0],binLims[1]),"L")->SetTextColor(ptcol[0]);
807  for(Int_t j=1; j<nPtBins; j++){
808  hEffVsMult[j]->SetLineColor(ptcol[j]);
809  hEffVsMult[j]->Draw("same");
810  legm->AddEntry(hEffVsMult[j],Form("%.0f<p_{T}<%.0f GeV/c",binLims[j],binLims[j+1]),"L")->SetTextColor(ptcol[j]);
811  }
812  legm->Draw();
813  cw->cd(2);
814  if(hWeight[0]){
815  gPad->SetLeftMargin(0.12);
816  if(maxMult>0) hWeight[0]->GetXaxis()->SetRangeUser(0.,maxMult);
817  hWeight[0]->Draw();
818  TLegend* legw=new TLegend(0.2,0.65,0.55,0.89);
819  legw->SetFillStyle(0);
820  legw->AddEntry(hWeight[0],"Candidate Weight","L");
821  if(hWeight[1]){
822  hWeight[1]->Draw("same");
823  legw->AddEntry(hWeight[1],"D Weight","L");
824  }
825  if(hWeight[2]){
826  hWeight[2]->Draw("same");
827  legw->AddEntry(hWeight[2],"EvSel Weight","L");
828  }
829  legw->Draw();
830  }
831  cw->SaveAs(Form("figures/Effic%sVsMultPtBins_%s.eps",dCase.Data(),suffix.Data()));
832  }else{
833  TCanvas* cwb=new TCanvas("cwb",Form("%s - ptB weight",dCase.Data()),800,800);
834  funcPtBWeight->SetTitle("");
835  funcPtBWeight->GetXaxis()->SetTitle("B-hadron p_{T} (GeV/c)");
836  funcPtBWeight->GetYaxis()->SetTitle("Weight (FONLL/MC)");
837  funcPtBWeight->Draw();
838  }
839 
840  TH1D *hpteffNoWeight =new TH1D(Form("hEff%sVsPtNoWeight",dCase.Data()),"",nPtBins,binLims);
841  TH1D **hpteffMultWeight =new TH1D*[3];
842  hpteffMultWeight[0]=new TH1D(Form("hEff%sVsPtCandWeight",dCase.Data()),"",nPtBins,binLims);
843  hpteffMultWeight[1]=new TH1D(Form("hEff%sVsPtDWeight",dCase.Data()),"",nPtBins,binLims);
844  hpteffMultWeight[2]=new TH1D(Form("hEff%sVsPtEvSelWeight",dCase.Data()),"",nPtBins,binLims);
845  TH1D **hpteffMultPtWeight =new TH1D*[3];
846  hpteffMultPtWeight[0]=new TH1D(Form("hEff%sVsPtCandFONLLWeight",dCase.Data()),"",nPtBins,binLims);
847  hpteffMultPtWeight[1]=new TH1D(Form("hEff%sVsPtDFONLLWeight",dCase.Data()),"",nPtBins,binLims);
848  hpteffMultPtWeight[2]=new TH1D(Form("hEff%sVsPtEvSelFONLLWeight",dCase.Data()),"",nPtBins,binLims);
849  TH1D *hpteffPtBWeight =new TH1D(Form("hEff%sVsPtPtBWeight",dCase.Data()),"",nPtBins,binLims);
850 
851  TH1D* hMultRecoAllPtW=hPtVsYVsVar3Reco->ProjectionZ(Form("hMultRecoW%s",dCase.Data()));
852  TH1D* hMultGenAccAllPtW=hPtVsYVsVar3GenAcc->ProjectionZ(Form("hMultGenAccW%s",dCase.Data()));
853  TH1D* hMultGenLimAccAllPtW=hPtVsYVsVar3GenLimAcc->ProjectionZ(Form("hMultGenLimAccW%s",dCase.Data()));
854  hMultRecoAllPtW->Reset("ines");
855  hMultGenAccAllPtW->Reset("ines");
856  hMultGenLimAccAllPtW->Reset("ines");
857 
858  Double_t countNumer[nPtBins];
859  Double_t countDenom[nPtBins];
860  Double_t countNumerPtBWei[nPtBins];
861  Double_t countDenomPtBWei[nPtBins];
862 
863  Double_t countNumerMultWei[nPtBins][3];
864  Double_t countDenomMultWei[nPtBins][3];
865  Double_t countNumerMultPtWei[nPtBins][3];
866  Double_t countDenomMultPtWei[nPtBins][3];
867 
868  for(Int_t iPtBin=0; iPtBin<nPtBins; iPtBin++){
869  countNumer[iPtBin]=0.0;
870  countDenom[iPtBin]=0.0;
871  countNumerPtBWei[iPtBin]=0.0;
872  countDenomPtBWei[iPtBin]=0.0;
873  for(Int_t iw=0; iw<3; iw++){
874  countNumerMultWei[iPtBin][iw]=0.0;
875  countDenomMultWei[iPtBin][iw]=0.0;
876  countNumerMultPtWei[iPtBin][iw]=0.0;
877  countDenomMultPtWei[iPtBin][iw]=0.0;
878  }
879  }
880 
881  for(Int_t ibx=0; ibx<=hPtVsYVsVar3GenAcc->GetNbinsX()+1; ibx++){
882  for(Int_t iby=0; iby<=hPtVsYVsVar3GenAcc->GetNbinsY()+1; iby++){
883  for(Int_t ibz=0; ibz<=hPtVsYVsVar3GenAcc->GetNbinsZ()+1; ibz++){
884  Double_t pt=hPtVsYVsVar3GenAcc->GetXaxis()->GetBinCenter(ibx);
885  // Double_t y=hPtVsYVsVar3GenAcc->GetYaxis()->GetBinCenter(iby);
886  Double_t v3=hPtVsYVsVar3GenAcc->GetZaxis()->GetBinCenter(ibz);
887  // printf("%f %f %f\n",pt,y,mult);
888  Int_t jPtBin=TMath::BinarySearch(nPtBins+1,binLims,pt);
889  if(jPtBin>=0 && jPtBin<nPtBins){
890  Double_t crec=hPtVsYVsVar3Reco->GetBinContent(ibx,iby,ibz);
891  Double_t cgen=hPtVsYVsVar3GenAcc->GetBinContent(ibx,iby,ibz);
892  Double_t wpt=funcPtWeight->Eval(pt);
893  countNumer[jPtBin]+=crec;
894  countDenom[jPtBin]+=cgen;
895  if(var3=="PtB"){
896  Double_t w=funcPtBWeight->Eval(v3);
897  countNumerPtBWei[jPtBin]+=crec*w;
898  countDenomPtBWei[jPtBin]+=cgen*w;
899  }else{
900  for(Int_t iw=0; iw<3; iw++){
901  Double_t w=0;
902  if(hWeight[iw]){
903  Int_t binw=hWeight[iw]->FindBin(v3);
904  if(binw>=1 && binw<hWeight[iw]->GetNbinsX()+1){
905  w=hWeight[iw]->GetBinContent(binw);
906  // printf("mult %.0f bin %d wei %f\n",mult,binw,w);
907  }else{
908  if(cgen>0){
909  printf("mult %.0f bin %d wei %f\n",v3,binw,w);
910  getchar();
911  }
912  }
913  }else{
914  w=1;
915  }
916  if(!useMultWeight) w=1;
917  countNumerMultWei[jPtBin][iw]+=crec*w;
918  countDenomMultWei[jPtBin][iw]+=cgen*w;
919  countNumerMultPtWei[jPtBin][iw]+=crec*w*wpt;
920  countDenomMultPtWei[jPtBin][iw]+=cgen*w*wpt;
921  hMultRecoAllPtW->Fill(v3,crec*w);
922  hMultGenAccAllPtW->Fill(v3,cgen*w);
923  hMultGenLimAccAllPtW->Fill(v3,hPtVsYVsVar3GenLimAcc->GetBinContent(ibx,iby,ibz)*w);
924  }
925  }
926  }
927  }
928  }
929  }
930 
931  for(Int_t iPtBin=0; iPtBin<nPtBins; iPtBin++){
932  Double_t eff1=countNumer[iPtBin]/countDenom[iPtBin];
933  Double_t erreff1=TMath::Sqrt(eff1*(1-eff1)/countDenom[iPtBin]);
934  printf("---- Pt range %.0f - %.0f ----\n",binLims[iPtBin],binLims[iPtBin+1]);
935  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));
936  printf("Eff No weights = %f/%f = %f+-%f\n",countNumer[iPtBin],countDenom[iPtBin],eff1,erreff1);
937  hpteffNoWeight->SetBinContent(iPtBin+1,eff1);
938  hpteffNoWeight->SetBinError(iPtBin+1,erreff1);
939  if(var3=="PtB"){
940  Double_t eff4=countNumerPtBWei[iPtBin]/countDenomPtBWei[iPtBin];
941  Double_t erreff4=TMath::Sqrt(eff4*(1-eff4)/countDenom[iPtBin]);// countDenom is NOT a typo, it has to be like this to get proper statistical errors from the no-weight case
942  printf("Eff With pt(B) weights = %f/%f = %f+-%f\n",countNumerPtBWei[iPtBin],countDenomPtBWei[iPtBin],eff4,erreff4);
943  hpteffPtBWeight->SetBinContent(iPtBin+1,eff4);
944  hpteffPtBWeight->SetBinError(iPtBin+1,erreff4);
945  }else{
946  for(Int_t iw=0;iw<3; iw++){
947  Double_t eff2=countNumerMultWei[iPtBin][iw]/countDenomMultWei[iPtBin][iw];
948  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
949  printf("Eff With mult weights %d = %f/%f = %f+-%f\n",iw,countNumerMultWei[iPtBin][iw],countDenomMultWei[iPtBin][iw],eff2,erreff2);
950  hpteffMultWeight[iw]->SetBinContent(iPtBin+1,eff2);
951  hpteffMultWeight[iw]->SetBinError(iPtBin+1,erreff2);
952  Double_t eff3=countNumerMultPtWei[iPtBin][iw]/countDenomMultPtWei[iPtBin][iw];
953  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
954  printf("Eff With mult+pt weights %d = %f/%f = %f+-%f\n",iw,countNumerMultPtWei[iPtBin][iw],countDenomMultPtWei[iPtBin][iw],eff3,erreff3);
955  hpteffMultPtWeight[iw]->SetBinContent(iPtBin+1,eff3);
956  hpteffMultPtWeight[iw]->SetBinError(iPtBin+1,erreff3);
957  }
958  }
959  }
960 
961  hEffVsPtR->SetMarkerStyle(0);
962  hEffVsPtR->SetMarkerColor(0);
963  hEffVsPtR->SetMarkerSize(1.2);
964  hEffVsPtR->SetLineColor(kGray);
965  hEffVsPtR->SetLineWidth(4);
966  hEffVsPtR->SetStats(0);
967  hpteffNoWeight->SetMarkerStyle(20);
968 
969  if(var3=="Mult"){
970  TH1D* hEffVsMultAllPtW=(TH1D*)hMultRecoAllPtW->Clone(Form("hEff%s",dCase.Data()));
971  TH1D* hAccVsMultAllPtW=(TH1D*)hMultGenAccAllPtW->Clone(Form("hAcc%s",dCase.Data()));
972  hEffVsMultAllPtW->Divide(hMultRecoAllPtW,hMultGenAccAllPtW,1,1,"B");
973  hAccVsMultAllPtW->Divide(hMultGenAccAllPtW,hMultGenLimAccAllPtW,1,1,"B");
974  hEffVsMultAllPtW->SetStats(0);
975  hAccVsMultAllPtW->SetStats(0);
976 
977  TCanvas* c2w=new TCanvas(Form("c2w%s",dCase.Data()),Form("%s - EffVsMultW",dCase.Data()),1200,600);
978  c2w->Divide(2,1);
979  c2w->cd(1);
980  gPad->SetLogy();
981  hMultGenLimAccAllPtW->SetLineColor(1);
982  if(maxMult>0) hMultGenLimAccAllPtW->GetXaxis()->SetRangeUser(0.,maxMult);
983  hMultGenLimAccAllPtW->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
984  hMultGenLimAccAllPtW->GetYaxis()->SetTitle("Entries");
985  hMultGenLimAccAllPtW->Draw();
986  hMultGenAccAllPtW->SetLineColor(2);
987  hMultGenAccAllPtW->Draw("same");
988  hMultRecoAllPtW->SetLineColor(4);
989  hMultRecoAllPtW->Draw("same");
990  c2w->cd(2);
991  hEffVsMultAllPtW->SetLineColor(4);
992  hEffVsMultAllPtW->SetMinimum(0);
993  hEffVsMultAllPtW->SetMaximum(1.6);
994  if(maxMult>0) hEffVsMultAllPtW->GetXaxis()->SetRangeUser(0.,maxMult);
995  hEffVsMultAllPtW->GetXaxis()->SetTitle("N_{tracklets} in |#eta|<1");
996  hEffVsMultAllPtW->GetYaxis()->SetTitle("Ratio");
997  hEffVsMultAllPtW->Draw();
998  hAccVsMultAllPtW->SetLineColor(2);
999  hAccVsMultAllPtW->Draw("same");
1000  tacc2->Draw();
1001  te2->Draw();
1002 
1003 
1004 
1005  TH1F** hRatio=new TH1F*[3];
1006  for(Int_t iw=0;iw<3; iw++){
1007  hRatio[iw]=(TH1F*)hpteffMultWeight[iw]->Clone(Form("hRatio%s",dCase.Data()));
1008  hRatio[iw]->Divide(hpteffMultWeight[iw],hpteffNoWeight);
1009  hRatio[iw]->GetYaxis()->SetTitle("With Mult weight / Without weight");
1010  hRatio[iw]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1011  hRatio[iw]->GetYaxis()->SetTitleOffset(1.4);
1012  hRatio[iw]->SetLineColor(wcol[iw]);
1013  hRatio[iw]->SetMarkerColor(wcol[iw]);
1014  hRatio[iw]->SetMarkerStyle(wmark[iw]);
1015  hRatio[iw]->SetStats(0);
1016  hpteffMultWeight[iw]->SetLineColor(wcol[iw]);
1017  hpteffMultWeight[iw]->SetMarkerColor(wcol[iw]);
1018  hpteffMultWeight[iw]->SetMarkerStyle(wmark[iw]);
1019  }
1020  TH1F** hRatioPtW=new TH1F*[3];
1021  for(Int_t iw=0;iw<3; iw++){
1022  hRatioPtW[iw]=(TH1F*)hpteffMultPtWeight[iw]->Clone(Form("hRatioWei%s",dCase.Data()));
1023  hRatioPtW[iw]->Divide(hpteffMultPtWeight[iw],hpteffMultWeight[iw]);
1024  hRatioPtW[iw]->GetYaxis()->SetTitle("With Mult+p_{T} weight / With only Mult weight");
1025  hRatioPtW[iw]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1026  hRatioPtW[iw]->GetYaxis()->SetTitleOffset(1.4);
1027  hRatioPtW[iw]->SetLineColor(wcol[iw]);
1028  hRatioPtW[iw]->SetMarkerColor(wcol[iw]);
1029  hRatioPtW[iw]->SetMarkerStyle(wmark[iw]);
1030  hRatioPtW[iw]->SetStats(0);
1031  hpteffMultPtWeight[iw]->SetLineColor(wcol[iw]);
1032  hpteffMultPtWeight[iw]->SetMarkerColor(wcol[iw]);
1033  hpteffMultPtWeight[iw]->SetMarkerStyle(wmark[iw]);
1034  }
1035 
1036  TCanvas* ceff=new TCanvas(Form("ceff%s",dCase.Data()),Form("%s - Eff Mult Wei",dCase.Data()),1200,600);
1037  ceff->Divide(2,1);
1038  ceff->cd(1);
1039  gPad->SetLeftMargin(0.12);
1040  gPad->SetTickx();
1041  gPad->SetTicky();
1042  hEffVsPtR->SetMinimum(0);
1043  hEffVsPtR->SetMaximum(1);
1044  hEffVsPtR->Draw();
1045  hEffVsPtR->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1046  hEffVsPtR->GetYaxis()->SetTitle("Efficiency");
1047  hEffVsPtR->GetYaxis()->SetTitleOffset(1.4);
1048  hpteffNoWeight->Draw("same");
1049  for(Int_t iw=0;iw<3; iw++) hpteffMultWeight[iw]->Draw("same");
1050  TLegend* leg=new TLegend(0.55,0.15,0.89,0.45);
1051  leg->SetFillStyle(0);
1052  leg->AddEntry(hEffVsPtR,"TH3F::Project","L");
1053  leg->AddEntry(hpteffNoWeight,"Multiplcity slices - No Weight","PL");
1054  leg->AddEntry(hpteffMultWeight[0],"Multiplcity slices - Cand Weight","PL");
1055  leg->AddEntry(hpteffMultWeight[1],"Multiplcity slices - D Weight","PL");
1056  leg->AddEntry(hpteffMultWeight[2],"Multiplcity slices - EvSel Weight","PL");
1057  leg->Draw();
1058  ceff->cd(2);
1059  gPad->SetLeftMargin(0.12);
1060  gPad->SetTickx();
1061  gPad->SetTicky();
1062  hRatio[0]->Draw();
1063  hRatio[0]->SetMinimum(0.95);
1064  hRatio[0]->SetMaximum(1.05);
1065  for(Int_t iw=1;iw<3; iw++) hRatio[iw]->Draw("same");
1066  ceff->SaveAs(Form("figures/Effic%sWithMultWeights%s.eps",dCase.Data(),suffix.Data()));
1067 
1068  TCanvas* ceff2=new TCanvas(Form("ceff2%s",dCase.Data()),Form("%s - Eff Mult+Pt wei",dCase.Data()),1200,600);
1069  ceff2->Divide(2,1);
1070  ceff2->cd(1);
1071  gPad->SetLeftMargin(0.12);
1072  gPad->SetTickx();
1073  gPad->SetTicky();
1074  hEffVsPtR->SetMinimum(0);
1075  hEffVsPtR->SetMaximum(1);
1076  hEffVsPtR->Draw();
1077  hEffVsPtR->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1078  hEffVsPtR->GetYaxis()->SetTitle("Efficiency");
1079  hEffVsPtR->GetYaxis()->SetTitleOffset(1.4);
1080  hpteffNoWeight->Draw("same");
1081  for(Int_t iw=0;iw<3; iw++) hpteffMultPtWeight[iw]->Draw("same");
1082  TLegend* leg2=new TLegend(0.55,0.15,0.89,0.45);
1083  leg2->SetFillStyle(0);
1084  leg2->AddEntry(hEffVsPtR,"TH3F::Project","L");
1085  leg2->AddEntry(hpteffNoWeight,"Multiplcity slices - No Weight","PL");
1086  leg2->AddEntry(hpteffMultPtWeight[0],"Multiplicity slices - FONLL+Cand Weight","PL");
1087  leg2->AddEntry(hpteffMultPtWeight[1],"Multiplicity slices - FONLL+D Weight","PL");
1088  leg2->AddEntry(hpteffMultPtWeight[2],"Multiplicity slices - FONLL+EvSel Weight","PL");
1089  leg2->Draw();
1090  ceff2->cd(2);
1091  gPad->SetLeftMargin(0.12);
1092  gPad->SetTickx();
1093  gPad->SetTicky();
1094  hRatioPtW[0]->Draw();
1095  hRatioPtW[0]->SetMinimum(0.95);
1096  hRatioPtW[0]->SetMaximum(1.05);
1097  for(Int_t iw=1;iw<3; iw++) hRatioPtW[iw]->Draw("same");
1098  ceff2->SaveAs(Form("figures/Effic%sWithMultAndPtWeights%s.eps",dCase.Data(),suffix.Data()));
1099  }else{
1100  hpteffPtBWeight->SetMarkerStyle(21);
1101  hpteffPtBWeight->SetMarkerColor(kRed+1);
1102  hpteffPtBWeight->SetLineColor(kRed+1);
1103 
1104  TCanvas* ceff3=new TCanvas(Form("ceff3%s",dCase.Data()),Form("%s - Eff PtB wei",dCase.Data()),1200,600);
1105  ceff3->Divide(2,1);
1106  ceff3->cd(1);
1107  gPad->SetLeftMargin(0.12);
1108  gPad->SetTickx();
1109  gPad->SetTicky();
1110  hEffVsPtR->SetMinimum(0);
1111  hEffVsPtR->SetMaximum(1);
1112  hEffVsPtR->Draw();
1113  hEffVsPtR->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1114  hEffVsPtR->GetYaxis()->SetTitle("Efficiency");
1115  hEffVsPtR->GetYaxis()->SetTitleOffset(1.4);
1116  hpteffNoWeight->Draw("same");
1117  hpteffPtBWeight->Draw("same");
1118  TLegend* leg3=new TLegend(0.55,0.15,0.89,0.45);
1119  leg3->SetFillStyle(0);
1120  leg3->AddEntry(hEffVsPtR,"TH3F::Project","L");
1121  leg3->AddEntry(hpteffNoWeight,"Counting - No Weight","PL");
1122  leg3->AddEntry(hpteffPtBWeight,"Counting - p_{T}(B) Weight","PL");
1123  leg3->Draw();
1124  ceff3->cd(2);
1125  gPad->SetLeftMargin(0.12);
1126  gPad->SetTickx();
1127  gPad->SetTicky();
1128  TH1F* hRatioPtB=(TH1F*)hpteffPtBWeight->Clone(Form("hRatioPtB%s",dCase.Data()));
1129  hRatioPtB->Divide(hpteffPtBWeight,hpteffNoWeight);
1130  hRatioPtB->GetYaxis()->SetTitle("With/without p_{T}(B) weight");
1131  hRatioPtB->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1132  hRatioPtB->GetYaxis()->SetTitleOffset(1.4);
1133  hRatioPtB->SetStats(0);
1134  hRatioPtB->Draw();
1135  }
1136 
1137  TFile* out=new TFile(Form("outputEff%s.root",suffix.Data()),"update");
1138  hEffVsPtR->Write();
1139  hpteffNoWeight->Write();
1140  hpteffMultWeight[0]->Write();
1141  hpteffMultWeight[1]->Write();
1142  hpteffMultWeight[2]->Write();
1143  hpteffMultPtWeight[0]->Write();
1144  hpteffMultPtWeight[1]->Write();
1145  hpteffMultPtWeight[2]->Write();
1146  hpteffPtBWeight->Write();
1147  hEvSelEffVsPt->Write();
1148  out->Close();
1149 
1150 }
1151 
1152 
1154  FILE* confFil=fopen(configName.Data(),"r");
1155  char line[50];
1156  char name[200];
1157  int n;
1158  float x;
1159  bool readok;
1160  while(!feof(confFil)){
1161  readok=fscanf(confFil,"%s:",line);
1162  if(strstr(line,"MCFile")){
1163  readok=fscanf(confFil,"%s",name);
1164  fileNameMC=name;
1165  }
1166  else if(strstr(line,"SuffixMC")){
1167  readok=fscanf(confFil,"%s",name);
1168  suffix=name;
1169  }
1170  else if(strstr(line,"AcceptanceFile")){
1171  readok=fscanf(confFil,"%s",name);
1172  fileNameToy=name;
1173  }
1174  else if(strstr(line,"NumOfPtBins")){
1175  readok=fscanf(confFil,"%d",&n);
1176  nPtBins=n;
1177  }
1178  else if(strstr(line,"BinLimits")){
1179  readok=fscanf(confFil," [ ");
1180  for(int j=0; j<nPtBins; j++){
1181  readok=fscanf(confFil,"%f,",&x);
1182  binLims[j]=x;
1183  if(j>0 && binLims[j]<=binLims[j-1]){
1184  printf("ERROR in array of pt bin limits\n");
1185  return kFALSE;
1186  }
1187  }
1188  readok=fscanf(confFil,"%f",&x);
1189  binLims[nPtBins]=x;
1190  readok=fscanf(confFil," ] ");
1191  }
1192  }
1193  return kTRUE;
1194 }
1195 
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
const Int_t maxPtBins
TString fileNameToy
TString configFileName
TH1F * hAccToyFine
TSystem * gSystem
Double_t binLims[maxPtBins+1]
Int_t wmark[3]
TFile * fil
Definition: InvMassFit.C:61
TString fileNameMC
Bool_t useMultWeight
int Int_t
Definition: External.C:63
Definition: External.C:228
Definition: External.C:212
Int_t ptcol[maxPtBins]
void ComputeEfficiencyFromCombinHF()
void ComputeAndWriteEff(TList *l, TString dCase, TString var3="Mult")
Bool_t ReadConfig(TString configName)
bool Bool_t
Definition: External.C:53
Double_t maxMult