1 #include "TDirectoryFile.h"
8 #include "AliCFGridSparse.h"
9 #include "AliCFContainer.h"
10 #include "AliCFEffGrid.h"
15 #include "Riostream.h"
18 // Macro to project (and rebin) the output of CFSingleTrackEfficiencyTask
22 // variable to project and rebin
23 // steps to project (1:GenAcc/LimAcc, 2: RecCuts/GenAcc, 3: RecPID/GenAcc, 4: Rec/GenAcc, 5: RecAcc/GenAcc)
24 // container directory suffix
27 void RebinCFContainer(const char *infile="AnalysisResults.root",Int_t rebinVar=0, Int_t myEff=3, const char * name="Nch"){
29 gSystem->SetIncludePath("-I. -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/RAW -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/PWGPP -g");
31 // gROOT->LoadMacro("AliSingleTrackEffCuts.cxx++g");
32 // gROOT->LoadMacro("AliCFSingleTrackEfficiencyTask.cxx++g");
34 gROOT->SetStyle("Plain");
35 gStyle->SetPalette(1);
36 gStyle->SetOptStat(0);
37 gStyle->SetPalette(1);
38 gStyle->SetCanvasColor(0);
39 gStyle->SetFrameFillColor(0);
40 gStyle->SetOptTitle(0);
43 TFile* file = TFile::Open(infile,"read");
45 TDirectoryFile *d = 0;
46 AliCFContainer *data = 0;
47 d = (TDirectoryFile*)file->Get(Form("PWGPP_CFSingleTrack%s",name));
49 cout<<" no directory "<<endl;
52 data = (AliCFContainer*) (d->Get("container"));
54 cout <<" no container"<<endl;
58 // *********** NUMERATOR
60 AliCFGridSparse* gridSparse = 0;
61 if( myEff == 1 ) gridSparse = (AliCFGridSparse*)data->GetGrid(1); // GenAcc
62 else if( myEff == 2 ) gridSparse = (AliCFGridSparse*)data->GetGrid(6); // Rec (acc + cuts) draw reco properties
63 else if( myEff == 3 ) gridSparse = (AliCFGridSparse*)data->GetGrid(7); // RecPID
64 else if( myEff == 4 ) gridSparse = (AliCFGridSparse*)data->GetGrid(3); // Rec (no cuts)
65 else if( myEff == 5 ) gridSparse = (AliCFGridSparse*)data->GetGrid(4); // RecAcc
66 else if( myEff == 6 ) gridSparse = (AliCFGridSparse*)data->GetGrid(5); // Rec (acc + cuts) draw kine properties
68 THnSparse* numData = (THnSparse*)gridSparse->GetGrid();
70 // method 2: defining a new THnSparse changing only the axis of interest
72 THnSparse* newnumData = (THnSparse*)numData->Clone("numNew");
76 Double_t* newLimits =0;
79 newLimits = new Double_t[nLimits+1];
96 } else if (rebinVar==1) {
98 newLimits = new Double_t[nLimits+1];
110 const Int_t nnewLimits = nLimits;
113 TAxis* axis = (TAxis*)newnumData->GetAxis(rebinVar);
114 axis->Set(nnewLimits,newLimits);
115 newnumData->SetBinEdges(rebinVar,newLimits);
117 newnumData->RebinnedAdd(numData, 1);
119 // checking the bin contents
120 TH1D* h1 = (TH1D*)numData->Projection(rebinVar);
123 Printf("Original THnSparse");
124 for (Int_t ibin = 1; ibin<=h1->GetNbinsX(); ibin++){
125 Printf("ibin = %d, low edge = %f, content = %f",ibin,h1->GetBinLowEdge(ibin),h1->GetBinContent(ibin));
126 sum+=h1->GetBinContent(ibin);
129 Printf("THnSparse changing only one axis");
130 TH1D* h2num = (TH1D*)newnumData->Projection(rebinVar);
131 for (Int_t ibin = 1; ibin<=h2num->GetNbinsX(); ibin++){
132 Printf("ibin = %d, low edge = %f, content = %f",ibin,h2num->GetBinLowEdge(ibin),h2num->GetBinContent(ibin));
133 sumnew+=h2num->GetBinContent(ibin);
136 Printf("sum = %f, sumnew = %f",sum, sumnew);
139 // *********** DENOMINATOR RECPID
141 Printf("DENOMINATOR");
143 AliCFGridSparse* gridSparse2 = 0;
144 if( myEff == 1 ) gridSparse2 = (AliCFGridSparse*)data->GetGrid(0); // LimAcc
145 else gridSparse2 = (AliCFGridSparse*)data->GetGrid(1); // GenAcc
147 THnSparse* denData = (THnSparse*)gridSparse2->GetGrid();
149 // method 2: defining a new THnSparse changing only the axis of interest
151 THnSparse* newdenData = (THnSparse*)denData->Clone("denNew");
154 TAxis* axis2 = (TAxis*)newdenData->GetAxis(rebinVar);
155 axis2->Set(nnewLimits,newLimits);
156 newdenData->SetBinEdges(rebinVar,newLimits);
158 newdenData->RebinnedAdd(denData, 1);
160 // checking the bin contents
161 TH1D* h1d = (TH1D*)denData->Projection(rebinVar);
164 Printf("Original THnSparse");
165 for (Int_t ibin = 1; ibin<=h1d->GetNbinsX(); ibin++){
166 Printf("ibin = %d, low edge = %f, content = %f",ibin,h1d->GetBinLowEdge(ibin),h1d->GetBinContent(ibin));
167 sum+=h1d->GetBinContent(ibin);
170 Printf("THnSparse changing only one axis");
171 TH1D* h2 = (TH1D*)newdenData->Projection(rebinVar);
172 for (Int_t ibin = 1; ibin<=h2->GetNbinsX(); ibin++){
173 Printf("ibin = %d, low edge = %f, content = %f",ibin,h2->GetBinLowEdge(ibin),h2->GetBinContent(ibin));
174 sumnew+=h2->GetBinContent(ibin);
177 Printf("sum = %f, sumnew = %f",sum, sumnew);
179 TH1D* heff = (TH1D*)h2num->Clone("heff");
180 heff->Divide(h2num, h2,1,1,"B");
181 // heff->GetXaxis()->SetRangeUser(0,23.5);
184 fout = new TFile(Form("efficiency_STE_GenAcc_over_LimAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE");
185 heff->Write("hpteffCFLimAccGenAcc");
186 h2num->Write("hptLimAcc");
187 h2->Write("hptGenAcc");
189 else if( myEff == 2 ) {
190 fout = new TFile(Form("efficiency_STE_RecPPR_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE");
191 heff->Write("hpteffCFRecPPRGenAcc");
192 h2num->Write("hptRecPPR");
193 h2->Write("hptGenAcc");
195 else if( myEff == 3 ) {
196 fout = new TFile(Form("efficiency_STE_RecPID_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE");
197 heff->Write("hpteffCFRecPIDGenAcc");
198 h2num->Write("hptRecPID");
199 h2->Write("hptGenAcc");
201 else if( myEff == 4 ) {
202 fout = new TFile(Form("efficiency_STE_Rec_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE");
203 heff->Write("hpteffCFRecGenAcc");
204 h2num->Write("hptRec");
205 h2->Write("hptGenAcc");
207 else if( myEff == 5 ) {
208 fout = new TFile(Form("efficiency_STE_RecAcc_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE");
209 heff->Write("hpteffCFRecAccGenAcc");
210 h2num->Write("hptRecAcc");
211 h2->Write("hptGenAcc");
213 else if( myEff == 6 ) {
214 fout = new TFile(Form("efficiency_STE_RecPPRKine_over_GenAcc_rebinned_%d_%s.root",rebinVar,name),"RECREATE");
215 heff->Write("hpteffCFRecPPRKineGenAcc");
216 h2num->Write("hptRecPPRKine");
217 h2->Write("hptGenAcc");