]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/drawProtonQAResults.C
FXS File ID renamed to match DA output file
[u/mrichter/AliRoot.git] / PWG2 / drawProtonQAResults.C
1 void drawProtonQAResults(const char* filename = "Protons.QA.root") {
2   gStyle->SetPalette(1,0);
3
4   const Int_t NQAHISTOSPERLIST = 15;
5   
6   Double_t gEntriesQA2DList[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
7   Double_t gEntriesQAPrimaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryProtonsRejectedList[NQAHISTOSPERLIST];
8   Double_t gEntriesQASecondaryProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryProtonsRejectedList[NQAHISTOSPERLIST];
9   Double_t gEntriesQAPrimaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQAPrimaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
10   Double_t gEntriesQASecondaryAntiProtonsAcceptedList[NQAHISTOSPERLIST], gEntriesQASecondaryAntiProtonsRejectedList[NQAHISTOSPERLIST];
11
12   for(Int_t i = 0; i < NQAHISTOSPERLIST; i++) {
13     gEntriesQAPrimaryProtonsAcceptedList[i] = 0.0;
14     gEntriesQAPrimaryProtonsRejectedList[i] = 0.0;
15     gEntriesQASecondaryProtonsAcceptedList[i] = 0.0;
16     gEntriesQASecondaryProtonsRejectedList[i] = 0.0;
17     gEntriesQAPrimaryAntiProtonsAcceptedList[i] = 0.0;
18     gEntriesQAPrimaryAntiProtonsRejectedList[i] = 0.0;
19     gEntriesQASecondaryAntiProtonsAcceptedList[i] = 0.0;
20     gEntriesQASecondaryAntiProtonsRejectedList[i] = 0.0;
21   }
22
23   TFile *f = TFile::Open(filename);
24   TList *list = (TList *)f->Get("outputList1");
25
26   TList *fQA2DList = (TList *)list->At(0);
27   GetQAEntries(fQA2DList,gEntriesQA2DList);
28
29   TList *fQAPrimaryProtonsAcceptedList = (TList *)list->At(1);
30   GetQAEntries(fQAPrimaryProtonsAcceptedList,gEntriesQAPrimaryProtonsAcceptedList);
31
32   TList *fQAPrimaryProtonsRejectedList = (TList *)list->At(2);
33   GetQAEntries(fQAPrimaryProtonsRejectedList,gEntriesQAPrimaryProtonsRejectedList);
34
35   TList *fQASecondaryProtonsAcceptedList = (TList *)list->At(3);
36   GetQAEntries(fQASecondaryProtonsAcceptedList,gEntriesQASecondaryProtonsAcceptedList);
37
38   TList *fQASecondaryProtonsRejectedList = (TList *)list->At(4);
39   GetQAEntries(fQASecondaryProtonsRejectedList,gEntriesQASecondaryProtonsRejectedList);
40
41   TList *fQAPrimaryAntiProtonsAcceptedList = (TList *)list->At(5);
42   GetQAEntries(fQAPrimaryAntiProtonsAcceptedList,gEntriesQAPrimaryAntiProtonsAcceptedList);
43
44   TList *fQAPrimaryAntiProtonsRejectedList = (TList *)list->At(6);
45   GetQAEntries(fQAPrimaryAntiProtonsRejectedList,gEntriesQAPrimaryAntiProtonsRejectedList);
46
47   TList *fQASecondaryAntiProtonsAcceptedList = (TList *)list->At(7);
48   GetQAEntries(fQASecondaryAntiProtonsAcceptedList,gEntriesQASecondaryAntiProtonsAcceptedList);
49
50   TList *fQASecondaryAntiProtonsRejectedList = (TList *)list->At(8);
51   GetQAEntries(fQASecondaryAntiProtonsRejectedList,gEntriesQASecondaryAntiProtonsRejectedList);
52
53   //_______________________________________________________//
54   //Create the histograms
55   const Int_t nx = 21;
56   char *fCutName[nx] = {"Tracks","",
57                         "ITS Clusters",
58                         "#chi^{2}/N_{ITS-Clusters}",
59                         "TPC Clusters",
60                         "#chi^{2}/N_{TPC-Clusters}",
61                         "ExtCov11",
62                         "ExtCov22",
63                         "ExtCov33",
64                         "ExtCov44",
65                         "ExtCov55",
66                         "#sigma_{Vertex}",
67                         "#sigma_{Vertex-TPC}",
68                         "ITS refit",
69                         "TPC refit",
70                         "ESD pid",
71                         "TPC pid","",
72                         "N_{Secondaries}/N_{total}","",""};
73
74   TH2F *hEmpty = new TH2F("hEmpty","",nx,0,nx,100,0,100); 
75   hEmpty->SetStats(kFALSE); 
76   hEmpty->SetMarkerStyle(kFullCircle);
77   hEmpty->SetLineColor(2); hEmpty->SetMarkerColor(2);
78   hEmpty->GetYaxis()->SetTitle("Influence of the cuts [%]");
79   for(Int_t i = 1; i <= nx; i++) 
80     hEmpty->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
81   hEmpty->GetXaxis()->SetLabelOffset(0.01); 
82   hEmpty->GetXaxis()->SetLabelSize(0.045);
83
84   //primary protons
85   TH1F *hPrimaryProtons = new TH1F("hPrimaryProtons","",nx,0,nx); 
86   hPrimaryProtons->SetStats(kFALSE); 
87   hPrimaryProtons->SetMarkerStyle(kFullCircle);
88   hPrimaryProtons->SetLineColor(4); hPrimaryProtons->SetLineWidth(2); 
89   hPrimaryProtons->SetMarkerColor(4);
90   hPrimaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
91   for(Int_t i = 1; i <= nx; i++) {
92     hPrimaryProtons->SetBinContent(i,-10.);
93     hPrimaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
94   }
95   hPrimaryProtons->GetXaxis()->SetLabelOffset(0.01); 
96   hPrimaryProtons->GetXaxis()->SetLabelSize(0.045);
97
98   //secondary protons
99   TH1F *hSecondaryProtons = new TH1F("hSecondaryProtons","",nx,0,nx); 
100   hSecondaryProtons->SetStats(kFALSE); 
101   hSecondaryProtons->SetMarkerStyle(22);
102   hSecondaryProtons->SetMarkerSize(1.4);
103   hSecondaryProtons->SetLineColor(2); hSecondaryProtons->SetLineWidth(2); 
104   hSecondaryProtons->SetMarkerColor(2);
105   hSecondaryProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
106   for(Int_t i = 1; i <= nx; i++) {
107     hSecondaryProtons->SetBinContent(i,-10.);
108     hSecondaryProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
109   }
110   hSecondaryProtons->GetXaxis()->SetLabelOffset(0.01); 
111   hSecondaryProtons->GetXaxis()->SetLabelSize(0.045);
112
113   //primary antiprotons
114   TH1F *hPrimaryAntiProtons = new TH1F("hPrimaryAntiProtons","",nx,0,nx); 
115   hPrimaryAntiProtons->SetStats(kFALSE); 
116   hPrimaryAntiProtons->SetMarkerStyle(kFullCircle);
117   hPrimaryAntiProtons->SetLineColor(4); hPrimaryAntiProtons->SetLineWidth(2); 
118   hPrimaryAntiProtons->SetMarkerColor(4);
119   hPrimaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
120   for(Int_t i = 1; i <= nx; i++) {
121     hPrimaryAntiProtons->SetBinContent(i,-10.);
122     hPrimaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
123   }
124   hPrimaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
125   hPrimaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
126
127   //secondary antiprotons
128   TH1F *hSecondaryAntiProtons = new TH1F("hSecondaryAntiProtons","",nx,0,nx); 
129   hSecondaryAntiProtons->SetStats(kFALSE); 
130   hSecondaryAntiProtons->SetMarkerStyle(22);
131   hSecondaryAntiProtons->SetMarkerSize(1.4);
132   hSecondaryAntiProtons->SetLineColor(2); hSecondaryAntiProtons->SetLineWidth(2); 
133   hSecondaryAntiProtons->SetMarkerColor(2);
134   hSecondaryAntiProtons->GetYaxis()->SetTitle("Influence of the cuts [%]");
135   for(Int_t i = 1; i <= nx; i++) {
136     hSecondaryAntiProtons->SetBinContent(i,-10.);
137     hSecondaryAntiProtons->GetXaxis()->SetBinLabel(i,fCutName[i-1]);
138   }
139   hSecondaryAntiProtons->GetXaxis()->SetLabelOffset(0.01); 
140   hSecondaryAntiProtons->GetXaxis()->SetLabelSize(0.045);
141   //_______________________________________________________//
142
143   //1D for primary protons
144   cout<<"_____________________________________________________"<<endl;
145   cout<<"_______________PRIMARY PROTONS_______________________"<<endl;
146   hPrimaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[1]));
147
148   for(Int_t i = 2; i < 17; i++) 
149     hPrimaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryProtonsAcceptedList[i-2],
150                                                    gEntriesQAPrimaryProtonsRejectedList[i-2]));
151   
152   //1D for secondary protons
153   cout<<"_____________________________________________________"<<endl;
154   cout<<"_______________SECONDARY PROTONS_____________________"<<endl;
155   hSecondaryProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[2],gEntriesQA2DList[3]));
156   hSecondaryProtons->SetBinContent(19,GetPercentage(gEntriesQA2DList[0],gEntriesQA2DList[2]));
157
158   for(Int_t i = 2; i < 17; i++) 
159     hSecondaryProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryProtonsAcceptedList[i-2],
160                                                      gEntriesQASecondaryProtonsRejectedList[i-2]));
161
162   //1D for primary antiprotons
163   cout<<"_________________________________________________________"<<endl;
164   cout<<"_______________PRIMARY ANTIPROTONS_______________________"<<endl;
165   hPrimaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[5]));
166
167   for(Int_t i = 2; i < 17; i++) 
168     hPrimaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQAPrimaryAntiProtonsAcceptedList[i-2],
169                                                        gEntriesQAPrimaryAntiProtonsRejectedList[i-2]));
170
171   //1D for secondary antiprotons
172   cout<<"_________________________________________________________"<<endl;
173   cout<<"_______________SECONDARY ANTIPROTONS_____________________"<<endl;
174   hSecondaryAntiProtons->SetBinContent(1,GetPercentage(gEntriesQA2DList[6],gEntriesQA2DList[7]));
175   hSecondaryAntiProtons->SetBinContent(19,GetPercentage(gEntriesQA2DList[4],gEntriesQA2DList[6]));
176
177   for(Int_t i = 2; i < 17; i++) 
178     hSecondaryAntiProtons->SetBinContent(i+1,GetPercentage(gEntriesQASecondaryAntiProtonsAcceptedList[i-2],
179                                                          gEntriesQASecondaryAntiProtonsRejectedList[i-2]));
180
181   TLatex *t1 = new TLatex();
182   t1->SetTextSize(0.04);
183   //_________________________________________________________//
184   TCanvas *c1 = new TCanvas("c1","Cut Influence - Protons",0,0,450,450);
185   c1->SetFillColor(10); c1->GetFrame()->SetFillColor(10);
186   c1->SetHighLightColor(10); c1->SetBottomMargin(0.15);
187   c1->SetGridx(); c1->SetGridy();
188
189   for(Int_t i = 1; i <= nx; i++) {
190     hPrimaryProtons->SetBinError(i,1.0);
191     hSecondaryProtons->SetBinError(i,1.0);
192   }
193   hEmpty->Draw();
194   hPrimaryProtons->Draw("EHISTSAME");
195   hSecondaryProtons->Draw("EHISTSAME");
196   DrawMarker(14.5, 80, 20, 1.2, 4);
197   t1->DrawLatex(15,78,"Primary p");
198   DrawMarker(14.5, 70, 22, 1.2, 2);
199   t1->DrawLatex(15,68,"Secondary p");
200
201   c1->SaveAs("CutInfluence-Protons,gif");
202
203   //_________________________________________________________//
204   TCanvas *c2 = new TCanvas("c2","Cut Influence - AntiProtons",450,0,450,450);
205   c2->SetFillColor(10); c2->GetFrame()->SetFillColor(10);
206   c2->SetHighLightColor(10); c2->SetBottomMargin(0.15);
207   c2->SetGridx(); c2->SetGridy();
208
209   for(Int_t i = 1; i <= nx; i++) {
210     hPrimaryAntiProtons->SetBinError(i,1.0);
211     hSecondaryAntiProtons->SetBinError(i,1.0);
212   }
213   hEmpty->Draw();
214   hPrimaryAntiProtons->Draw("EHISTSAME");
215   hSecondaryAntiProtons->Draw("EHISTSAME");
216   DrawMarker(14.5, 80, 20, 1.2, 4);
217   t1->DrawLatex(15,78,"Primary #bar{p}");
218   DrawMarker(14.5, 70, 22, 1.2, 2);
219   t1->DrawLatex(15,68,"Secondary #bar{p}");
220
221   c2->SaveAs("CutInfluence-AntiProtons,gif");
222 }
223
224 //________________________________________________//
225 void GetQAEntries(TList *inputList, Double_t *entries) {
226   //loops over the list entries
227   //extracts the entries for each histogram
228   cout<<"Extracting the entries for the histograms in the list: "<<
229     inputList->GetName()<<"..."<<endl;
230
231   for(Int_t i = 0; i < inputList->GetEntries(); i++) {
232     TH1F *gHist = (TH1F *)inputList->At(i);
233     entries[i] = gHist->GetEntries();
234     cout<<"Histogram: "<<gHist->GetName()<<
235       " - Entries: "<<entries[i]<<endl;
236     gHist = 0;
237   }
238 }
239
240 //________________________________________________//
241 Double_t GetPercentage(Double_t nPassEntries,
242                        Double_t nRejectEntries) {
243   //returns the percentage of tracks that were rejected by a cut
244   Int_t nTotalEntries = nPassEntries + nRejectEntries;
245
246   if(nTotalEntries == 0)
247     return -1;
248
249   return 100.*nRejectEntries/nTotalEntries;
250 }
251
252 //________________________________________________//
253 void DrawMarker(Double_t x, Double_t y, Int_t style, Double_t size, Int_t color) {
254   TMarker *m = new TMarker(x,y,style);
255   m->SetMarkerSize(size);
256   m->SetMarkerColor(color);
257   m->Draw();
258 }