]>
Commit | Line | Data |
---|---|---|
eec7bbb0 | 1 | // Track QA task (efficiency and pt resolution) |
2 | // | |
3 | // Author: S.Aiola | |
4 | ||
5 | #include <TH3F.h> | |
6 | #include <THnSparse.h> | |
7 | #include <TMath.h> | |
8 | #include <TString.h> | |
9 | #include <Riostream.h> | |
10 | ||
11 | #include "AliPicoTrack.h" | |
12 | #include "AliAODMCParticle.h" | |
13 | #include "AliParticleContainer.h" | |
14 | #include "AliLog.h" | |
15 | ||
16 | #include "AliEmcalTrackingQATask.h" | |
17 | ||
18 | ClassImp(AliEmcalTrackingQATask) | |
19 | ||
20 | //________________________________________________________________________ | |
21 | AliEmcalTrackingQATask::AliEmcalTrackingQATask() : | |
22 | AliAnalysisTaskEmcal("AliEmcalTrackingQA", kTRUE), | |
23 | fGeneratorLevel(0), | |
24 | fDetectorLevel(0), | |
25 | fTracksAll(0), | |
26 | fTracksSelected(0), | |
27 | fParticlesAllPhysPrim(0), | |
28 | fParticlesSelected(0), | |
29 | fParticlesFindable(0), | |
30 | fParticlesMatched(0) | |
31 | { | |
32 | // Default constructor. | |
33 | ||
34 | SetMakeGeneralHistograms(kTRUE); | |
35 | } | |
36 | ||
37 | //________________________________________________________________________ | |
38 | AliEmcalTrackingQATask::AliEmcalTrackingQATask(const char *name) : | |
39 | AliAnalysisTaskEmcal(name, kTRUE), | |
40 | fGeneratorLevel(0), | |
41 | fDetectorLevel(0), | |
42 | fTracksAll(0), | |
43 | fTracksSelected(0), | |
44 | fParticlesAllPhysPrim(0), | |
45 | fParticlesSelected(0), | |
46 | fParticlesFindable(0), | |
47 | fParticlesMatched(0) | |
48 | { | |
49 | // Standard constructor. | |
50 | ||
51 | SetMakeGeneralHistograms(kTRUE); | |
52 | } | |
53 | ||
54 | //________________________________________________________________________ | |
55 | AliEmcalTrackingQATask::~AliEmcalTrackingQATask() | |
56 | { | |
57 | // Destructor. | |
58 | } | |
59 | ||
60 | //________________________________________________________________________ | |
61 | void AliEmcalTrackingQATask::UserCreateOutputObjects() | |
62 | { | |
63 | // Create my user objects. | |
64 | ||
65 | AliAnalysisTaskEmcal::UserCreateOutputObjects(); | |
66 | ||
67 | if (!fCreateHisto) return; | |
68 | ||
69 | fTracksAll = new TH3**[fNcentBins]; | |
70 | fTracksSelected = new TH3**[fNcentBins]; | |
71 | fParticlesAllPhysPrim = new TH3*[fNcentBins]; | |
72 | fParticlesSelected = new TH3*[fNcentBins]; | |
73 | ||
74 | TString histname; | |
75 | ||
76 | for (Int_t i = 0; i < fNcentBins; i++) { | |
77 | ||
78 | fTracksAll[i] = new TH3*[3]; | |
79 | fTracksSelected[i] = new TH3*[3]; | |
80 | for (Int_t j = 0; j < 3; j++) { | |
81 | histname = Form("fTracksAll_%d_%d",i,j); | |
82 | fTracksAll[i][j] = new TH3F(histname,histname, 100, -1, 1, 101, 0, TMath::Pi() * 2.02, fNbins, fMinBinPt, fMaxBinPt); | |
83 | fTracksAll[i][j]->GetXaxis()->SetTitle("#eta"); | |
84 | fTracksAll[i][j]->GetYaxis()->SetTitle("#phi"); | |
85 | fTracksAll[i][j]->GetZaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); | |
86 | fOutput->Add(fTracksAll[i][j]); | |
87 | ||
88 | histname = Form("fTracksSelected_%d_%d",i,j); | |
89 | fTracksSelected[i][j] = new TH3F(histname,histname, 100, -1, 1, 101, 0, TMath::Pi() * 2.02, fNbins, fMinBinPt, fMaxBinPt); | |
90 | fTracksSelected[i][j]->GetXaxis()->SetTitle("#eta"); | |
91 | fTracksSelected[i][j]->GetYaxis()->SetTitle("#phi"); | |
92 | fTracksSelected[i][j]->GetZaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); | |
93 | fOutput->Add(fTracksSelected[i][j]); | |
94 | } | |
95 | ||
96 | histname = Form("fParticlesAllPhysPrim_%d",i); | |
97 | fParticlesAllPhysPrim[i] = new TH3F(histname,histname, 100, -1, 1, 101, 0, TMath::Pi() * 2.02, fNbins, fMinBinPt, fMaxBinPt); | |
98 | fParticlesAllPhysPrim[i]->GetXaxis()->SetTitle("#eta"); | |
99 | fParticlesAllPhysPrim[i]->GetYaxis()->SetTitle("#phi"); | |
100 | fParticlesAllPhysPrim[i]->GetZaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); | |
101 | fOutput->Add(fParticlesAllPhysPrim[i]); | |
102 | ||
103 | histname = Form("fParticlesSelected_%d",i); | |
104 | fParticlesSelected[i] = new TH3F(histname,histname, 100, -1, 1, 101, 0, TMath::Pi() * 2.02, fNbins, fMinBinPt, fMaxBinPt); | |
105 | fParticlesSelected[i]->GetXaxis()->SetTitle("#eta"); | |
106 | fParticlesSelected[i]->GetYaxis()->SetTitle("#phi"); | |
107 | fParticlesSelected[i]->GetZaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); | |
108 | fOutput->Add(fParticlesSelected[i]); | |
109 | } | |
110 | ||
111 | AllocateFindableParticlesTHnSparse(); | |
112 | AllocateMatchedParticlesTHnSparse(); | |
113 | ||
114 | PostData(1, fOutput); | |
115 | } | |
116 | ||
117 | //________________________________________________________________________ | |
118 | void AliEmcalTrackingQATask::AllocateFindableParticlesTHnSparse() | |
119 | { | |
120 | Int_t dim = 0; | |
121 | TString title[20]; | |
122 | Int_t nbins[20] = {0}; | |
123 | Double_t min[20] = {0}; | |
124 | Double_t max[20] = {0}; | |
125 | ||
126 | if (fForceBeamType != AliAnalysisTaskEmcal::kpp) { | |
127 | title[dim] = "Centrality %"; | |
128 | nbins[dim] = 101; | |
129 | min[dim] = 0; | |
130 | max[dim] = 101; | |
131 | dim++; | |
132 | } | |
133 | ||
134 | title[dim] = "#it{p}_{T} (GeV/#it{c})"; | |
135 | nbins[dim] = fNbins; | |
136 | min[dim] = fMinBinPt; | |
137 | max[dim] = fMaxBinPt; | |
138 | dim++; | |
139 | ||
140 | title[dim] = "#eta"; | |
141 | nbins[dim] = 100; | |
142 | min[dim] = -1; | |
143 | max[dim] = 1; | |
144 | dim++; | |
145 | ||
146 | title[dim] = "#phi"; | |
147 | nbins[dim] = 101; | |
148 | min[dim] = 0; | |
149 | max[dim] = TMath::Pi() * 2.02; | |
150 | dim++; | |
151 | ||
152 | fParticlesFindable = new THnSparseF("fParticlesFindable","fParticlesFindable",dim,nbins,min,max); | |
153 | for (Int_t i = 0; i < dim; i++) | |
154 | fParticlesFindable->GetAxis(i)->SetTitle(title[i]); | |
155 | fOutput->Add(fParticlesFindable); | |
156 | } | |
157 | ||
158 | //________________________________________________________________________ | |
159 | void AliEmcalTrackingQATask::AllocateMatchedParticlesTHnSparse() | |
160 | { | |
161 | Int_t dim = 0; | |
162 | TString title[20]; | |
163 | Int_t nbins[20] = {0}; | |
164 | Double_t min[20] = {0}; | |
165 | Double_t max[20] = {0}; | |
166 | ||
167 | if (fForceBeamType != AliAnalysisTaskEmcal::kpp) { | |
168 | title[dim] = "Centrality %"; | |
169 | nbins[dim] = 101; | |
170 | min[dim] = 0; | |
171 | max[dim] = 101; | |
172 | dim++; | |
173 | } | |
174 | ||
175 | title[dim] = "#it{p}_{T}^{gen} (GeV/#it{c})"; | |
176 | nbins[dim] = fNbins; | |
177 | min[dim] = fMinBinPt; | |
178 | max[dim] = fMaxBinPt; | |
179 | dim++; | |
180 | ||
181 | title[dim] = "#eta^{gen}"; | |
182 | nbins[dim] = 100; | |
183 | min[dim] = -1; | |
184 | max[dim] = 1; | |
185 | dim++; | |
186 | ||
187 | title[dim] = "#phi^{gen}"; | |
188 | nbins[dim] = 101; | |
189 | min[dim] = 0; | |
190 | max[dim] = TMath::Pi() * 2.02; | |
191 | dim++; | |
192 | ||
193 | title[dim] = "#it{p}_{T}^{det} (GeV/#it{c})"; | |
194 | nbins[dim] = fNbins; | |
195 | min[dim] = fMinBinPt; | |
196 | max[dim] = fMaxBinPt; | |
197 | dim++; | |
198 | ||
199 | title[dim] = "#eta^{det}"; | |
200 | nbins[dim] = 100; | |
201 | min[dim] = -1; | |
202 | max[dim] = 1; | |
203 | dim++; | |
204 | ||
205 | title[dim] = "#phi^{det}"; | |
206 | nbins[dim] = 101; | |
207 | min[dim] = 0; | |
208 | max[dim] = TMath::Pi() * 2.02; | |
209 | dim++; | |
210 | ||
211 | title[dim] = "(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}"; | |
212 | nbins[dim] = fNbins; | |
213 | min[dim] = -1; | |
214 | max[dim] = 1; | |
215 | dim++; | |
216 | ||
217 | title[dim] = "track type"; | |
218 | nbins[dim] = 3; | |
219 | min[dim] = -0.5; | |
220 | max[dim] = 2.5; | |
221 | dim++; | |
222 | ||
223 | fParticlesMatched = new THnSparseF("fParticlesMatched","fParticlesMatched",dim,nbins,min,max); | |
224 | for (Int_t i = 0; i < dim; i++) | |
225 | fParticlesMatched->GetAxis(i)->SetTitle(title[i]); | |
226 | fOutput->Add(fParticlesMatched); | |
227 | } | |
228 | ||
229 | //________________________________________________________________________ | |
230 | void AliEmcalTrackingQATask::SetGeneratorLevelName(const char* name) | |
231 | { | |
232 | if (!fGeneratorLevel) { // first check if the generator level array is set | |
233 | fGeneratorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(0)); | |
234 | if (fGeneratorLevel) { // now check if the first collection array has been added already | |
235 | fGeneratorLevel->SetArrayName(name); | |
236 | } | |
237 | else { | |
238 | fGeneratorLevel = AddParticleContainer(name); | |
239 | } | |
240 | fGeneratorLevel->SetClassName("AliAODMCParticle"); | |
241 | fGeneratorLevel->SelectPhysicalPrimaries(kTRUE); | |
242 | } | |
243 | fGeneratorLevel->SetArrayName(name); | |
244 | } | |
245 | ||
246 | //________________________________________________________________________ | |
247 | void AliEmcalTrackingQATask::SetDetectorLevelName(const char* name) | |
248 | { | |
249 | if (!fGeneratorLevel) { | |
250 | AliError("Please, first set the generatol level array!"); | |
251 | return; | |
252 | } | |
253 | if (!fDetectorLevel) { // first check if the detector level array is set | |
254 | fDetectorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(1)); | |
255 | if (fDetectorLevel) { // now check if the second collection array has been added already | |
256 | fDetectorLevel->SetArrayName(name); | |
257 | } | |
258 | else { | |
259 | fDetectorLevel = AddParticleContainer(name); | |
260 | } | |
261 | fDetectorLevel->SetClassName("AliPicoTrack"); | |
262 | fDetectorLevel->SelectPhysicalPrimaries(kTRUE); | |
263 | } | |
264 | fDetectorLevel->SetArrayName(name); | |
265 | } | |
266 | ||
267 | //________________________________________________________________________ | |
268 | void AliEmcalTrackingQATask::ExecOnce() | |
269 | { | |
270 | // Init the analysis. | |
271 | ||
272 | if (fParticleCollArray.GetEntriesFast() < 2) { | |
273 | AliFatal("This task needs at least two particle containers!"); | |
274 | } | |
275 | ||
276 | if (!fGeneratorLevel) { | |
277 | fGeneratorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(0)); | |
278 | fGeneratorLevel->SetClassName("AliAODMCParticle"); | |
279 | } | |
280 | ||
281 | if (!fDetectorLevel) { | |
282 | fDetectorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(1)); | |
283 | fDetectorLevel->SetClassName("AliPicoTrack"); | |
284 | } | |
285 | ||
286 | AliAnalysisTaskEmcal::ExecOnce(); | |
287 | } | |
288 | ||
289 | //________________________________________________________________________ | |
290 | void AliEmcalTrackingQATask::FillFindableParticlesTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt) | |
291 | { | |
292 | Double_t contents[20]={0}; | |
293 | ||
294 | for (Int_t i = 0; i < fParticlesFindable->GetNdimensions(); i++) { | |
295 | TString title(fParticlesFindable->GetAxis(i)->GetTitle()); | |
296 | if (title=="Centrality %") | |
297 | contents[i] = cent; | |
298 | else if (title=="#it{p}_{T} (GeV/#it{c})") | |
299 | contents[i] = partPt; | |
300 | else if (title=="#eta") | |
301 | contents[i] = partEta; | |
302 | else if (title=="#phi") | |
303 | contents[i] = partPhi; | |
304 | else | |
305 | AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fParticlesFindable->GetName())); | |
306 | } | |
307 | ||
308 | fParticlesFindable->Fill(contents); | |
309 | } | |
310 | ||
311 | //________________________________________________________________________ | |
312 | void AliEmcalTrackingQATask::FillMatchedParticlesTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt, | |
313 | Double_t trackEta, Double_t trackPhi, Double_t trackPt, Byte_t trackType) | |
314 | { | |
315 | Double_t contents[20]={0}; | |
316 | ||
317 | for (Int_t i = 0; i < fParticlesMatched->GetNdimensions(); i++) { | |
318 | TString title(fParticlesMatched->GetAxis(i)->GetTitle()); | |
319 | if (title=="Centrality %") | |
320 | contents[i] = cent; | |
321 | else if (title=="#it{p}_{T}^{gen} (GeV/#it{c})") | |
322 | contents[i] = partPt; | |
323 | else if (title=="#eta^{gen}") | |
324 | contents[i] = partEta; | |
325 | else if (title=="#phi^{gen}") | |
326 | contents[i] = partPhi; | |
327 | else if (title=="#it{p}_{T}^{det} (GeV/#it{c})") | |
328 | contents[i] = trackPt; | |
329 | else if (title=="#eta^{det}") | |
330 | contents[i] = trackEta; | |
331 | else if (title=="#phi^{det}") | |
332 | contents[i] = trackPhi; | |
333 | else if (title=="(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}") | |
334 | contents[i] = (partPt - trackPt) / partPt; | |
335 | else if (title=="track type") | |
336 | contents[i] = trackType; | |
337 | else | |
338 | AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fParticlesMatched->GetName())); | |
339 | } | |
340 | ||
341 | fParticlesMatched->Fill(contents); | |
342 | } | |
343 | ||
344 | //________________________________________________________________________ | |
345 | Bool_t AliEmcalTrackingQATask::FillHistograms() | |
346 | { | |
347 | // Fill the histograms. | |
348 | ||
349 | AliPicoTrack *track = static_cast<AliPicoTrack*>(fDetectorLevel->GetNextAcceptParticle(0)); | |
350 | while (track != 0) { | |
351 | Byte_t type = track->GetTrackType(); | |
352 | if (type<= 2 && type >= 0) { | |
353 | fTracksAll[fCentBin][type]->Fill(track->Eta(), track->Phi(), track->Pt()); | |
354 | ||
355 | Int_t label = TMath::Abs(track->GetLabel()); | |
356 | ||
357 | if (label==0 || track->GetGeneratorIndex() == 0) { // reject particles generated from other generator in the cocktail but keep fake tracks (label == 0) | |
358 | fTracksSelected[fCentBin][type]->Fill(track->Eta(), track->Phi(), track->Pt()); | |
359 | } | |
360 | ||
361 | if (label > 0) { | |
362 | AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetAcceptParticleWithLabel(label)); | |
363 | if (part) { | |
364 | if (part->GetGeneratorIndex() == 0) { | |
365 | Int_t pdg = TMath::Abs(part->PdgCode()); | |
366 | // select charged pions, protons, kaons , electrons, muons | |
367 | if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) { | |
368 | FillMatchedParticlesTHnSparse(fCent, part->Eta(), part->Phi(), part->Pt(), track->Eta(), track->Phi(), track->Pt(), type); | |
369 | } | |
370 | } | |
371 | } | |
372 | } | |
373 | } | |
374 | else { | |
375 | AliError(Form("Track %d has type %d not recognized!", fDetectorLevel->GetCurrentID(), type)); | |
376 | } | |
377 | ||
378 | track = static_cast<AliPicoTrack*>(fDetectorLevel->GetNextAcceptParticle()); | |
379 | } | |
380 | ||
381 | AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetNextAcceptParticle(0)); | |
382 | while (part != 0) { | |
383 | fParticlesAllPhysPrim[fCentBin]->Fill(part->Eta(), part->Phi(), part->Pt()); | |
384 | ||
385 | if (part->GetGeneratorIndex() == 0) { | |
386 | fParticlesSelected[fCentBin]->Fill(part->Eta(), part->Phi(), part->Pt()); | |
387 | ||
388 | Int_t pdg = TMath::Abs(part->PdgCode()); | |
389 | // select charged pions, protons, kaons , electrons, muons | |
390 | if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) { | |
391 | FillFindableParticlesTHnSparse(fCent, part->Eta(), part->Phi(), part->Pt()); | |
392 | } | |
393 | } | |
394 | ||
395 | part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetNextAcceptParticle()); | |
396 | } | |
397 | ||
398 | return kTRUE; | |
399 | } |