22 #include <Riostream.h>
28 void DrawEfficiency(
const char* channel, Int_t selection = 0, Int_t ieff = 7){
30 gROOT->SetStyle(
"Plain");
31 gStyle->SetPalette(1);
32 gStyle->SetOptStat(0);
33 gStyle->SetPalette(1);
34 gStyle->SetCanvasColor(0);
35 gStyle->SetFrameFillColor(0);
36 gStyle->SetOptTitle(0);
38 gSystem->SetIncludePath(
"-I. -I$ALICE_ROOT/include -I$ROOTSYS/include");
40 gSystem->Load(
"libANALYSISalice");
41 gSystem->Load(
"$ALICE_ROOT/CORRFW/libCORRFW") ;
43 gSystem->Load(
"libPWGHFvertexingHF");
45 Int_t mcAcc_over_mcLimAcc = 0x001;
46 Int_t recPPR_over_mcAcc = 0x002;
47 Int_t recPID_over_mcAcc = 0x004;
56 TFile* f =
new TFile(
"AnalysisResults.root");
57 TString directoryName;
58 TString containerName;
62 if (channel ==
"D0") {
64 directoryName =
"PWG3_D2H_CFtaskD0toKpi";
65 containerName =
"CFHFccontainer0";
67 outfileName =
"fileEff_D0_from_c.root";
69 else if (selection == 1){
70 directoryName =
"PWG3_D2H_CFtaskD0toKpiKeepD0fromBOnly";
71 containerName =
"CFHFccontainer0D0fromB";
73 outfileName =
"fileEff_D0_from_b.root";
75 else if (selection == 2){
76 directoryName =
"PWG3_D2H_CFtaskD0toKpiKeepD0fromB";
77 containerName =
"CFHFccontainer0allD0";
79 outfileName =
"fileEff_D0_from_c_and_b.root";
82 Printf(
"not a valid selection, return");
86 else if (channel ==
"D0_New"){
88 directoryName =
"PWG3_D2H_CFtaskD0toKpi_NEW";
89 containerName =
"CFHFccontainer0_New";
94 outfileName =
"fileEff_D0_CommonFramework_from_c.root";
96 else if (selection == 1){
97 directoryName =
"PWG3_D2H_CFtaskD0toKpiKeepDfromBOnly";
98 containerName =
"CFHFccontainer0DfromB_New";
103 outfileName =
"fileEff_D0_CommonFramework_from_b.root";
105 else if (selection == 2){
106 directoryName =
"PWG3_D2H_CFtaskD0toKpiKeepDfromB_NEW";
107 containerName =
"CFHFccontainer0allD_New";
108 cutName =
"Cuts_New";
112 outfileName =
"fileEff_D0_CommonFramework_from_c_and_b.root";
115 Printf(
"not a valid selection, return");
119 else if (channel ==
"Dplus_New"){
121 directoryName =
"PWG3_D2H_CFtaskDplustoKpipi_NEW";
122 containerName =
"CFHFccontainer0_New_3Prong";
123 cutName =
"Cuts_3Prong";
127 outfileName =
"fileEff_Dplus_CommonFramework_from_c.root";
129 else if (selection == 1){
130 directoryName =
"PWG3_D2H_CFtaskDplustoKpipiKeepDfromBOnly";
131 containerName =
"CFHFccontainer0DfromB_New_3Prong";
132 cutName =
"Cuts_3Prong";
136 outfileName =
"fileEff_Dplus_CommonFramework_from_b.root";
138 else if (selection == 2){
139 directoryName =
"PWG3_D2H_CFtaskDplustoKpipiKeepDfromB_NEW";
140 containerName =
"CFHFccontainer0allD_New_3Prong";
141 cutName =
"Cuts_3Prong";
145 outfileName =
"fileEff_Dplus_CommonFramework_from_c_and_b.root";
148 Printf(
"not a valid selection, return");
153 Printf(
"not a valid channel, return");
157 Printf(
"Opening file Analysisresults.root");
158 Printf(
"Reading Directory \"%s\"",directoryName.Data());
159 Printf(
"Getting CF Container \"%s\"",containerName.Data());
160 Printf(
"Getting Cut Object \"%s\"",cutName.Data());
163 TDirectoryFile* d = (TDirectoryFile*)f->Get(directoryName.Data());
165 Printf(
"Directory does not exist! Check directory name (%s) in file AnalysisResults.root - returning...", directoryName.Data());
168 AliCFContainer *data = (AliCFContainer*) (d->Get(containerName.Data()));
172 Printf(
"Container does not exist! Check container name (%s) in directory %s - returning...", containerName.Data(), directoryName.Data());
176 TFile* fileEff =
new TFile(outfileName.Data(),
"RECREATE");
177 TString plotDir(Form(
"EffPlots/%s",channel));
178 gSystem->Exec(Form(
"mkdir EffPlots"));
179 gSystem->Exec(Form(
"mkdir %s",plotDir.Data()));
182 AliCFEffGrid *eff =
new AliCFEffGrid(
"eff",
" The efficiency",*data);
184 TCanvas *ceffpt =
new TCanvas(
"ceffpt",
"Efficiency vs pt",50,50,550,550);
186 ceffpt->SetLeftMargin(0.15);
187 ceffpt->SetRightMargin(0.05);
188 TH1D *hpteffCF = 0x0;
190 if (ieff & mcAcc_over_mcLimAcc){
191 AliCFEffGrid *eff =
new AliCFEffGrid(
"eff",
" The efficiency",*data);
194 printf(
"Calculating efficiency for mcAcc_over_mcLimAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum);
195 eff->CalculateEfficiency(stepNum,stepDen);
201 hpteffCF = eff->Project(ipt);
203 hpteffCF->Draw(
"hist");
204 hpteffCF->Draw(
"err same");
206 hpteffCF->Write(
"hpteffCF_mcAcc_over_mcLimAcc");
209 ceffpt->Print(Form(
"%s/effpt_mcAcc_over_mcLimAcc.png", plotDir.Data()));
210 ceffpt->Print(Form(
"%s/effpt_mcAcc_over_mcLimAcc.eps", plotDir.Data()));
211 ceffpt->Print(Form(
"%s/effpt_mcAcc_over_mcLimAcc.gif", plotDir.Data()));
216 if (ieff & recPPR_over_mcAcc){
217 AliCFEffGrid *eff =
new AliCFEffGrid(
"eff",
" The efficiency",*data);
220 printf(
"Calculating efficiency for RecPPR_over_mcAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum);
221 eff->CalculateEfficiency(stepNum,stepDen);
227 hpteffCF = eff->Project(ipt);
228 SetHistoEff(hpteffCF,8,20,
"recAnCuts_over_mcAcc");
229 hpteffCF->Draw(
"hist");
230 hpteffCF->Draw(
"err same");
232 hpteffCF->Write(
"hpteffCF_RecAnCut_over_mcAcc");
235 ceffpt->Print(Form(
"%s/effpt_RecAnCut_over_mcAcc.png", plotDir.Data()));
236 ceffpt->Print(Form(
"%s/effpt_RecAnCut_over_mcAcc.eps", plotDir.Data()));
237 ceffpt->Print(Form(
"%s/effpt_RecAnCut_over_mcAcc.gif", plotDir.Data()));
242 if (ieff & recPID_over_mcAcc){
243 AliCFEffGrid *eff =
new AliCFEffGrid(
"eff",
" The efficiency",*data);
246 printf(
"Calculating efficiency for RecPID_over_mcAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum);
247 eff->CalculateEfficiency(stepNum,stepDen);
253 hpteffCF = eff->Project(ipt);
255 hpteffCF->Draw(
"hist");
256 hpteffCF->Draw(
"err same");
258 hpteffCF->Write(
"hpteffCF_RecPID_over_mcAcc");
261 ceffpt->Print(Form(
"%s/effpt_RecPID_over_mcAcc.png", plotDir.Data()));
262 ceffpt->Print(Form(
"%s/effpt_RecPID_over_mcAcc.eps", plotDir.Data()));
263 ceffpt->Print(Form(
"%s/effpt_RecPID_over_mcAcc.gif", plotDir.Data()));
268 cutsRDHF->Write(
"Cuts");
274 TH1D *hMCLimAccpt = data->ShowProjection(ipt, AliCFHeavyFlavourTaskMultiVarMultiStep::kStepGeneratedLimAcc);
280 hMCAccpt->Write(
"hMCAccpt");
281 hMCLimAccpt->Write(
"hMCLimAccpt");
282 hRecoAnCutspt->Write(
"hRecoAnCutspt");
283 hRecoPIDpt->Write(
"hRecoPIDpt");
291 h->SetLineColor(color);
293 h->SetMarkerStyle(style);
294 h->SetMarkerColor(color);
295 h->SetMarkerSize(1.2);
296 h->GetYaxis()->SetTitleOffset(1.5);
297 h->GetXaxis()->SetTitleOffset(1.2);
298 h->GetXaxis()->SetTitle(
"p_{t} [GeV/c]");
299 h->GetYaxis()->SetTitle(Form(
"%s, Efficiency",effType));
304 h->SetLineColor(color);
306 h->SetMarkerStyle(style);
307 h->SetMarkerColor(color);
308 h->SetMarkerSize(1.2);
309 h->GetXaxis()->SetTitleOffset(1.2);
310 h->GetXaxis()->SetTitle(
"p_{t} [GeV/c]");
void SetHistoDistribution(TH1D *h, Int_t color, Int_t style)
void SetHistoEff(TH1D *h, Int_t color, Int_t style, const char *effType)
void DrawEfficiency(const char *channel, Int_t selection=0, Int_t ieff=7)