2 // macro to calculate the pt RecAnCuts/MCAcc
3 // efficiency, from a CF container
7 // D0: D0 -> Kpi, from old task
8 // D0_New: D0 -> Kpi, from new CF common implementation
9 // Dplus_New: D+ -> Kpipi, from new CF common implementation
11 // eff = sum of the efficiency indexes to compute
12 // MCAcc_over_MCLimAcc = 0x001
13 // RecPPR_over_MCAcc = 0x002
14 // RecPID_over_MCAcc = 0x004
17 // selection = D origin
20 // 2 --> from both c and b
22 #include <Riostream.h>
24 extern TRandom *gRandom;
25 extern TBenchmark *gBenchmark;
26 extern TSystem *gSystem;
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");
39 gSystem->Load("libANALYSIS.so");
40 gSystem->Load("libANALYSISalice.so");
41 gSystem->Load("$ALICE_ROOT/CORRFW/libCORRFW.so") ;
42 gSystem->Load("libPWG3base.so");
43 gSystem->Load("libPWG3vertexingHF.so");
45 Int_t mcAcc_over_mcLimAcc = 0x001;
46 Int_t recPPR_over_mcAcc = 0x002;
47 Int_t recPID_over_mcAcc = 0x004;
55 // Read the container from file
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";
91 //directoryName = "PWG3_D2H_CFtaskD0toKpi_CommonFramework";
92 //containerName = "CFHFccontainer0_CommonFramework";
93 //cutName = "Cuts_CommonFramework";
94 outfileName = "fileEff_D0_CommonFramework_from_c.root";
96 else if (selection == 1){
97 directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromBOnly";
98 containerName = "CFHFccontainer0DfromB_New";
100 //directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromBOnly_CommonFramework";
101 //containerName = "CFHFccontainer0DfromB_CommonFramework";
102 //cutName = "Cuts_CommonFramework";
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";
109 //directoryName = "PWG3_D2H_CFtaskD0toKpiKeepDfromB_CommonFramework";
110 //containerName = "CFHFccontainer0allD_CommonFramework";
111 //cutName = "Cuts_CommonFramework";
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";
124 //directoryName = "PWG3_D2H_CFtaskDplustoKpipi_CommonFramework";
125 //containerName = "CFHFccontainer0_3Prong_CommonFramework";
126 //cutName = "Cuts_3Prong_CommonFramework";
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";
133 //directoryName = "PWG3_D2H_CFtaskDplustoKpipiKeepDfromBOnly_CommonFramework";
134 //containerName = "CFHFccontainer0DfromB_3Prong_CommonFramework";
135 //cutName = "Cuts_3Prong_CommonFramework";
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";
142 //directoryName = "PWG3_D2H_CFtaskDplustoKpipiKeepDfromB_CommonFramework";
143 //containerName = "CFHFccontainer0allD_3Prong_CommonFramework";
144 //cutName = "Cuts_3Prong_CommonFramework";
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()));
169 AliRDHFCuts *cutsRDHF = (AliRDHFCuts*)(d->Get(cutName.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()));
181 //construct the efficiency grid from the data container
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; //the efficiency vs pt
190 if (ieff & mcAcc_over_mcLimAcc){
191 AliCFEffGrid *eff = new AliCFEffGrid("eff"," The efficiency",*data);
192 stepDen = (Int_t)(AliCFTaskVertexingHF::kStepGeneratedLimAcc);
193 stepNum = (Int_t)(AliCFTaskVertexingHF::kStepAcceptance);
194 printf("Calculating efficiency for mcAcc_over_mcLimAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum);
195 eff->CalculateEfficiency(stepNum,stepDen); //eff= step1/step0
200 //The efficiency along the variables
201 hpteffCF = eff->Project(ipt);
202 SetHistoEff(hpteffCF,8,20,"mcAcc_over_mcLimAcc");
203 hpteffCF->Draw("hist");
204 hpteffCF->Draw("err same");
206 hpteffCF->Write("hpteffCF_mcAcc_over_mcLimAcc");
208 // printing png files
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);
218 stepDen = (Int_t)(AliCFTaskVertexingHF::kStepAcceptance);
219 stepNum = (Int_t)(AliCFTaskVertexingHF::kStepRecoPPR);
220 printf("Calculating efficiency for RecPPR_over_mcAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum);
221 eff->CalculateEfficiency(stepNum,stepDen); //eff= step1/step0
226 //The efficiency along the variables
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");
234 // printing png files
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);
244 stepDen = (Int_t)(AliCFTaskVertexingHF::kStepAcceptance);
245 stepNum = (Int_t)(AliCFTaskVertexingHF::kStepRecoPID);
246 printf("Calculating efficiency for RecPID_over_mcAcc: stepDen = %d, stepNum = %d\n",stepDen,stepNum);
247 eff->CalculateEfficiency(stepNum,stepDen); //eff= step1/step0
252 //The efficiency along the variables
253 hpteffCF = eff->Project(ipt);
254 SetHistoEff(hpteffCF,8,20,"recPID_over_mcAcc");
255 hpteffCF->Draw("hist");
256 hpteffCF->Draw("err same");
258 hpteffCF->Write("hpteffCF_RecPID_over_mcAcc");
260 // printing png files
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");
270 // writing single distributions
271 TH1D *hMCAccpt = data->ShowProjection(ipt, AliCFTaskVertexingHF::kStepAcceptance);
272 SetHistoDistribution(hMCAccpt, 1, 20);
274 TH1D *hMCLimAccpt = data->ShowProjection(ipt, AliCFHeavyFlavourTaskMultiVarMultiStep::kStepGeneratedLimAcc);
275 SetHistoDistribution(hMCLimAccpt, 4, 20);
276 TH1D *hRecoAnCutspt = data->ShowProjection(ipt, AliCFTaskVertexingHF::kStepRecoPPR);
277 SetHistoDistribution(hRecoAnCutspt, 8, 20);
278 TH1D *hRecoPIDpt = data->ShowProjection(ipt, AliCFTaskVertexingHF::kStepRecoPID);
279 SetHistoDistribution(hRecoPIDpt, 6, 20);
280 hMCAccpt->Write("hMCAccpt");
281 hMCLimAccpt->Write("hMCLimAccpt");
282 hRecoAnCutspt->Write("hRecoAnCutspt");
283 hRecoPIDpt->Write("hRecoPIDpt");
285 // fileEff->Close(); // commented out to see the canvas on the screen....
289 void SetHistoEff(TH1D* h, Int_t color, Int_t style, const char* effType){
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));
302 void SetHistoDistribution(TH1D* h, Int_t color, Int_t style){
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]");