]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/macros/DrawEfficiencypp.C
add jet trigger
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / DrawEfficiencypp.C
1 TList *GetResults(const Char_t *testfile,const Char_t *plus="");
2 TObject* GetSpectrum(AliCFContainer *c, Int_t step);
3 TObject* GetEfficiency(AliCFContainer *c, Int_t step = 9);
4 TObject* GetEfficiency(AliCFContainer *c, Int_t step, Int_t step0);
5
6
7 void DrawEfficiencypp(const char *testfile,const char *name) {
8   
9   gStyle->SetPalette(1);
10   gStyle->SetOptStat(1111);
11   gStyle->SetPadBorderMode(0);
12   gStyle->SetCanvasColor(10);
13   gStyle->SetPadLeftMargin(0.13);
14   gStyle->SetPadRightMargin(0.13);
15   
16   ///////////////////////////////////
17   // Take the stuff
18   //////////////////////////////////
19
20   TList *results = GetResults(testfile,name);
21   if(!results){
22     printf("No output objects: Calculation will terminate here\n");
23     return;
24   }
25
26   AliHFEcontainer *containerhfe = (AliHFEcontainer *) results->FindObject("trackContainer");
27   if(!containerhfe) {
28     printf("No hfe container \n");
29     return;
30   }
31
32   AliCFContainer *sumcontaineresd = containerhfe->MakeMergedCFContainer("sumesd","sumesd","MCTrackCont:recTrackContReco");
33   AliCFContainer *sumcontainermc = containerhfe->MakeMergedCFContainer("summc","summc","MCTrackCont:recTrackContMC");
34   
35   if(!sumcontaineresd) {
36     printf("No container sum esd\n");
37     return;
38   }
39   
40   if(!sumcontainermc) {
41     printf("No container sum mc\n");
42     return;
43   }
44
45   Int_t numberOfEvents = (Int_t) containerhfe->GetNumberOfEvents();
46   
47   printf("Number of events for  %d after Event cut\n",numberOfEvents);
48   
49   /////////////////////////////////////
50   // Take efficiencies
51   /////////////////////////////////////
52   
53   // MC values
54
55   AliCFEffGrid  *efficiencystepMCkineITSTPC  = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecKineITSTPC,AliHFEcuts::kStepMCGeneratedZOutNoPileUpCentralityFine);
56   AliCFEffGrid  *efficiencystepMCPrim        = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecPrim,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecKineITSTPC);
57   AliCFEffGrid  *efficiencystepMCHFEcutsITS  = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsITS,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecPrim);
58   AliCFEffGrid  *efficiencystepMCHFEcutsTRD  = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsITS);
59   
60
61   AliCFEffGrid  *efficiencystepMCPIDTOF      = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD + 1,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD);
62   AliCFEffGrid  *efficiencystepMCPIDTPC      = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD + 2,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD + 1);
63
64   AliCFEffGrid  *efficiencystepMCPIDall      = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD + 2,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD);
65
66   AliCFEffGrid  *efficiencystepMCall      = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD + 1,AliHFEcuts::kStepMCGeneratedZOutNoPileUpCentralityFine);
67   AliCFEffGrid  *efficiencystepMCallwithTPC  = (AliCFEffGrid*)  GetEfficiency(sumcontainermc,AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepHFEcutsTRD + 2,AliHFEcuts::kStepMCGeneratedZOutNoPileUpCentralityFine);
68   
69
70   ///////////////////////////////////////
71   // Plot 1D
72   ///////////////////////////////////////
73   
74   TCanvas * canvascomparisonbis = new TCanvas("ITSTPCrefitStepMC","ITSTPCrefitStepMC",1000,700);
75   canvascomparisonbis->Divide(2,2);
76  
77   canvascomparisonbis->cd(1);
78   TH1D* h_effstepMCkineITSTPC1Donly = (TH1D *) efficiencystepMCkineITSTPC->Project(0);
79   h_effstepMCkineITSTPC1Donly->SetTitle("(ITS & TPC refit) / (No cut)");
80   h_effstepMCkineITSTPC1Donly->SetStats(0);
81   h_effstepMCkineITSTPC1Donly->SetLineColor(kBlue);
82   h_effstepMCkineITSTPC1Donly->SetMarkerColor(kBlue);
83   h_effstepMCkineITSTPC1Donly->SetMarkerStyle(25);
84   h_effstepMCkineITSTPC1Donly->SetXTitle("p_{T} [GeV/c]");
85   h_effstepMCkineITSTPC1Donly->SetYTitle("Efficiency");
86   h_effstepMCkineITSTPC1Donly->SetTitleOffset(1.5,"Y");
87   h_effstepMCkineITSTPC1Donly->GetXaxis()->SetRangeUser(0.3,6.0);
88   h_effstepMCkineITSTPC1Donly->Draw();
89
90   canvascomparisonbis->cd(2);
91   TH1D* h_effstepMCPrim1Donly = (TH1D *) efficiencystepMCPrim->Project(0);
92   h_effstepMCPrim1Donly->SetTitle("No Kink");
93   h_effstepMCPrim1Donly->SetStats(0);
94   h_effstepMCPrim1Donly->SetLineColor(kBlue);
95   h_effstepMCPrim1Donly->SetMarkerColor(kBlue);
96   h_effstepMCPrim1Donly->SetMarkerStyle(25);
97   h_effstepMCPrim1Donly->SetXTitle("p_{T} [GeV/c]");
98   h_effstepMCPrim1Donly->SetYTitle("Efficiency");
99   h_effstepMCPrim1Donly->SetTitleOffset(1.5,"Y");
100   h_effstepMCPrim1Donly->GetXaxis()->SetRangeUser(0.3,6.0);
101   h_effstepMCPrim1Donly->Draw();
102
103   canvascomparisonbis->cd(3);
104   TH1D* h_effstepMCHFEcutsITS1Donlya = (TH1D *) efficiencystepMCHFEcutsITS->Project(0);
105   h_effstepMCHFEcutsITS1Donlya->SetTitle("First pixel");
106   h_effstepMCHFEcutsITS1Donlya->SetStats(0);
107   h_effstepMCHFEcutsITS1Donlya->SetLineColor(kBlue);
108   h_effstepMCHFEcutsITS1Donlya->SetMarkerColor(kBlue);
109   h_effstepMCHFEcutsITS1Donlya->SetMarkerStyle(25);
110   h_effstepMCHFEcutsITS1Donlya->SetXTitle("p_{T} [GeV/c]");
111   h_effstepMCHFEcutsITS1Donlya->SetYTitle("Efficiency");
112   h_effstepMCHFEcutsITS1Donlya->SetTitleOffset(1.5,"Y");
113   h_effstepMCHFEcutsITS1Donlya->GetXaxis()->SetRangeUser(0.3,6.0);
114   h_effstepMCHFEcutsITS1Donlya->Draw();
115  
116   canvascomparisonbis->cd(4);
117   TH1D* h_effstepMCPID1Donly = (TH1D *) efficiencystepMCHFEcutsTRD->Project(0);
118   h_effstepMCPID1Donly->SetTitle("TOF matching");
119   h_effstepMCPID1Donly->SetStats(0);
120   h_effstepMCPID1Donly->SetLineColor(kBlue);
121   h_effstepMCPID1Donly->SetMarkerColor(kBlue);
122   h_effstepMCPID1Donly->SetMarkerStyle(25);
123   h_effstepMCPID1Donly->SetXTitle("p_{T} [GeV/c]");
124   h_effstepMCPID1Donly->SetYTitle("Efficiency");
125   h_effstepMCPID1Donly->SetTitleOffset(1.5,"Y");
126   h_effstepMCPID1Donly->GetXaxis()->SetRangeUser(0.3,6.0);
127   h_effstepMCPID1Donly->Draw();
128   
129   /////////
130   // PID
131   /////////
132
133   TCanvas * canvasc1DonMC = new TCanvas("PIDstepMC","PIDstepMC",1000,700);
134   canvasc1DonMC->Divide(3,1);
135   
136   canvasc1DonMC->cd(1);
137   TH1D* h_effstepPID1DMConly = (TH1D *) efficiencystepMCPIDTOF->Project(0);
138   h_effstepPID1DMConly->SetTitle("");
139   h_effstepPID1DMConly->SetStats(0);
140   h_effstepPID1DMConly->SetLineColor(kBlue);
141   h_effstepPID1DMConly->SetMarkerColor(kBlue);
142   h_effstepPID1DMConly->SetMarkerStyle(25);
143   h_effstepPID1DMConly->SetXTitle("p_{T} [GeV/c]");
144   h_effstepPID1DMConly->SetYTitle("Efficiency");
145   h_effstepPID1DMConly->SetTitleOffset(1.5,"Y");
146   h_effstepPID1DMConly->GetXaxis()->SetRangeUser(0.3,6.0); 
147   h_effstepPID1DMConly->Draw();
148  
149   canvasc1DonMC->cd(2);
150   TH1D* h_effstepPID1DMConlyy = (TH1D *) efficiencystepMCPIDTPC->Project(0);
151   h_effstepPID1DMConlyy->SetTitle("");
152   h_effstepPID1DMConlyy->SetStats(0);
153   h_effstepPID1DMConlyy->SetLineColor(kBlue);
154   h_effstepPID1DMConlyy->SetMarkerColor(kBlue);
155   h_effstepPID1DMConlyy->SetMarkerStyle(25);
156   h_effstepPID1DMConlyy->SetXTitle("p_{T} [GeV/c]");
157   h_effstepPID1DMConlyy->SetYTitle("Efficiency");
158   h_effstepPID1DMConlyy->SetTitleOffset(1.5,"Y");
159   h_effstepPID1DMConlyy->GetXaxis()->SetRangeUser(0.3,6.0);
160   h_effstepPID1DMConlyy->Draw();
161   
162   canvasc1DonMC->cd(3);
163   TH1D* h_effstepPID1DMConlyyy = (TH1D *) efficiencystepMCPIDall->Project(0);
164   h_effstepPID1DMConlyyy->SetTitle("");
165   h_effstepPID1DMConlyyy->SetStats(0);
166   h_effstepPID1DMConlyyy->SetLineColor(kBlue);
167   h_effstepPID1DMConlyyy->SetMarkerColor(kBlue);
168   h_effstepPID1DMConlyyy->SetMarkerStyle(25);
169   h_effstepPID1DMConlyyy->SetXTitle("p_{T} [GeV/c]");
170   h_effstepPID1DMConlyyy->SetYTitle("Efficiency");
171   h_effstepPID1DMConlyyy->SetTitleOffset(1.5,"Y");
172   h_effstepPID1DMConlyyy->GetXaxis()->SetRangeUser(0.3,6.0);
173   h_effstepPID1DMConlyyy->Draw();
174
175   //////////
176   // all
177   //////////
178   
179   TCanvas * canvasall = new TCanvas("AllMC","AllMC",1000,700);
180   canvasall->cd(1);
181   
182   TH1D* h_effstepPID1Dall = (TH1D *) efficiencystepMCall->Project(0);
183   h_effstepPID1Dall->SetTitle("");
184   h_effstepPID1Dall->SetStats(0);
185   h_effstepPID1Dall->SetLineColor(kBlue);
186   h_effstepPID1Dall->SetMarkerColor(kBlue);
187   h_effstepPID1Dall->SetMarkerStyle(25);
188   h_effstepPID1Dall->SetXTitle("p_{T} [GeV/c]");
189   h_effstepPID1Dall->SetYTitle("Efficiency");
190   h_effstepPID1Dall->SetTitleOffset(1.5,"Y");
191   h_effstepPID1Dall->GetXaxis()->SetRangeUser(0.3,6.0);
192   h_effstepPID1Dall->Scale(0.5);
193
194
195   TH1D* h_effstepPID1DallwithTPC = (TH1D *) efficiencystepMCallwithTPC->Project(0);
196   h_effstepPID1DallwithTPC->SetTitle("");
197   h_effstepPID1DallwithTPC->SetStats(0);
198   h_effstepPID1DallwithTPC->SetLineColor(kRed);
199   h_effstepPID1DallwithTPC->SetMarkerColor(kRed);
200   h_effstepPID1DallwithTPC->SetMarkerStyle(26);
201   h_effstepPID1DallwithTPC->SetXTitle("p_{T} [GeV/c]");
202   h_effstepPID1DallwithTPC->SetYTitle("Efficiency");
203   h_effstepPID1DallwithTPC->SetTitleOffset(1.5,"Y");
204   h_effstepPID1DallwithTPC->GetXaxis()->SetRangeUser(0.3,6.0);
205     
206   
207   gPad->SetLeftMargin(0.13);
208   //gPad->SetLogy();
209   gPad->SetTicks();
210   //gPad->SetGridx();
211   //gPad->SetGridy();
212   gPad->SetFillColor(10);
213   gPad->SetFrameFillColor(10);
214   gStyle->SetOptStat(0);
215   gStyle->SetOptFit(1111);
216   gStyle->SetOptTitle(0);
217   h_effstepPID1Dall->Draw();
218   h_effstepPID1DallwithTPC->Draw("same");
219   TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
220   leg->AddEntry(h_effstepPID1Dall,"TPC PID fixed to 1/2","p");
221   leg->AddEntry(h_effstepPID1DallwithTPC,"TPC PID MC efficiency","p");
222   leg->Draw("same");
223   
224   
225   
226 }
227
228 // ====================================================================
229 TList *GetResults(const Char_t *testfile,const Char_t *plus){
230   //
231   // read output
232   //
233   TFile *f = TFile::Open(testfile);
234   if(!f || f->IsZombie()){
235     printf("File not readable\n");
236     return 0x0;
237   }
238   TString name("HFE_Results");
239   name += plus; 
240   printf("Name of TList %s\n",(const char*)name); 
241   TList *l = dynamic_cast<TList *>(f->Get((const char*)name));
242   if(!l){
243     printf("Output container not found\n");
244     f->Close(); delete f;
245     return 0x0;
246   } 
247   TList *returnlist = dynamic_cast<TList *>(l->Clone());
248   f->Close(); delete f;
249   return returnlist;
250 }
251 //_________________________________________________________________________
252 TObject* GetSpectrum(AliCFContainer *c, Int_t step) {
253   AliCFDataGrid* data = new AliCFDataGrid("data","",*c,step);
254   //data->SetMeasured(step);
255   return data;
256 }
257 //__________________________________________________________________________
258 TObject* GetEfficiency(AliCFContainer *c, Int_t step) {
259   TString name("eff");
260   name += step;
261   AliCFEffGrid* eff = new AliCFEffGrid((const char*)name,"",*c);
262   eff->CalculateEfficiency(step,0);
263   return eff;
264 }
265 //_________________________________________________________________________
266 TObject* GetEfficiency(AliCFContainer *c, Int_t step, Int_t step0) {
267   TString name("eff");
268   name += step;
269   name+= step0;
270   AliCFEffGrid* eff = new AliCFEffGrid((const char*)name,"",*c);
271   eff->CalculateEfficiency(step,step0);
272   return eff;
273 }