1 // Track QA task (efficiency and pt resolution)
11 #include "AliPicoTrack.h"
12 #include "AliESDtrack.h"
13 #include "AliAODMCParticle.h"
14 #include "AliParticleContainer.h"
17 #include "AliEmcalTrackingQATask.h"
19 ClassImp(AliEmcalTrackingQATask)
21 //________________________________________________________________________
22 AliEmcalTrackingQATask::AliEmcalTrackingQATask() :
23 AliAnalysisTaskEmcal("AliEmcalTrackingQA", kTRUE),
37 f1OverPtResHistBins(0),
38 fN1OverPtResHistBins(0),
42 fParticlesPhysPrim(0),
45 // Default constructor.
47 SetMakeGeneralHistograms(kTRUE);
52 //________________________________________________________________________
53 AliEmcalTrackingQATask::AliEmcalTrackingQATask(const char *name) :
54 AliAnalysisTaskEmcal(name, kTRUE),
68 f1OverPtResHistBins(0),
69 fN1OverPtResHistBins(0),
73 fParticlesPhysPrim(0),
76 // Standard constructor.
78 SetMakeGeneralHistograms(kTRUE);
83 //________________________________________________________________________
84 AliEmcalTrackingQATask::~AliEmcalTrackingQATask()
89 //________________________________________________________________________
90 void AliEmcalTrackingQATask::GenerateHistoBins()
93 fPtHistBins = new Double_t[fNPtHistBins+1];
94 GenerateFixedBinArray(6, 0, 0.3, fPtHistBins);
95 GenerateFixedBinArray(7, 0.3, 1, fPtHistBins+6);
96 GenerateFixedBinArray(10, 1, 3, fPtHistBins+13);
97 GenerateFixedBinArray(14, 3, 10, fPtHistBins+23);
98 GenerateFixedBinArray(10, 10, 20, fPtHistBins+37);
99 GenerateFixedBinArray(15, 20, 50, fPtHistBins+47);
100 GenerateFixedBinArray(20, 50, 150, fPtHistBins+62);
103 fEtaHistBins = new Double_t[fNEtaHistBins+1];
104 GenerateFixedBinArray(fNEtaHistBins, -1, 1, fEtaHistBins);
107 fPhiHistBins = new Double_t[fNPhiHistBins+1];
108 GenerateFixedBinArray(fNPhiHistBins, 0, TMath::Pi() * 2.02, fPhiHistBins);
111 fCentHistBins = new Double_t[fNCentHistBins+1];
112 fCentHistBins[0] = 0;
113 fCentHistBins[1] = 10;
114 fCentHistBins[2] = 30;
115 fCentHistBins[3] = 50;
116 fCentHistBins[4] = 90;
118 fNPtResHistBins = 200;
119 fPtResHistBins = new Double_t[fNPtResHistBins+1];
120 GenerateFixedBinArray(fNPtResHistBins, -2, 2, fPtResHistBins);
122 fN1OverPtResHistBins = 325;
123 f1OverPtResHistBins = new Double_t[fN1OverPtResHistBins+1];
124 GenerateFixedBinArray(100, 0, 0.05, f1OverPtResHistBins);
125 GenerateFixedBinArray(50, 0.05, 0.1, f1OverPtResHistBins+100);
126 GenerateFixedBinArray(50, 0.1, 0.2, f1OverPtResHistBins+50);
127 GenerateFixedBinArray(75, 0.2, 0.5, f1OverPtResHistBins+50);
128 GenerateFixedBinArray(50, 0.5, 1.5, f1OverPtResHistBins+75);
130 fNIntegerHistBins = 10;
131 fIntegerHistBins = new Double_t[fNIntegerHistBins+1];
132 GenerateFixedBinArray(fNIntegerHistBins, -0.5, 9.5, fIntegerHistBins);
135 //________________________________________________________________________
136 void AliEmcalTrackingQATask::UserCreateOutputObjects()
138 // Create my user objects.
140 AliAnalysisTaskEmcal::UserCreateOutputObjects();
142 if (fParticleCollArray.GetEntriesFast() < 1) {
143 AliFatal("This task needs at least one particle container!");
146 if (!fDetectorLevel) {
147 fDetectorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
148 fDetectorLevel->SetClassName("AliPicoTrack");
151 if (!fGeneratorLevel && fParticleCollArray.GetEntriesFast() > 1) {
152 fGeneratorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
153 fGeneratorLevel->SetClassName("AliAODMCParticle");
156 AllocateDetectorLevelTHnSparse();
158 if (fGeneratorLevel) {
159 AllocateGeneratorLevelTHnSparse();
160 AllocateMatchedParticlesTHnSparse();
164 //________________________________________________________________________
165 void AliEmcalTrackingQATask::AllocateDetectorLevelTHnSparse()
169 Int_t nbins[20] = {0};
170 Double_t *binEdges[20] = {0};
172 if (fForceBeamType != AliAnalysisTaskEmcal::kpp) {
173 title[dim] = "Centrality %";
174 nbins[dim] = fNCentHistBins;
175 binEdges[dim] = fCentHistBins;
179 title[dim] = "#it{p}_{T} (GeV/#it{c})";
180 nbins[dim] = fNPtHistBins;
181 binEdges[dim] = fPtHistBins;
185 nbins[dim] = fNEtaHistBins;
186 binEdges[dim] = fEtaHistBins;
190 nbins[dim] = fNPhiHistBins;
191 binEdges[dim] = fPhiHistBins;
195 title[dim] = "MC Generator";
197 binEdges[dim] = fIntegerHistBins;
201 title[dim] = "track type";
203 binEdges[dim] = fIntegerHistBins;
207 title[dim] = "#sigma(1/#it{p}_{T}) (GeV/#it{c})^{-1}";
208 nbins[dim] = fN1OverPtResHistBins;
209 binEdges[dim] = f1OverPtResHistBins;
213 fTracks = new THnSparseF("fTracks","fTracks",dim,nbins);
214 for (Int_t i = 0; i < dim; i++) {
215 fTracks->GetAxis(i)->SetTitle(title[i]);
216 fTracks->SetBinEdges(i, binEdges[i]);
219 fOutput->Add(fTracks);
222 //________________________________________________________________________
223 void AliEmcalTrackingQATask::AllocateGeneratorLevelTHnSparse()
227 Int_t nbins[20] = {0};
228 Double_t *binEdges[20] = {0};
230 if (fForceBeamType != AliAnalysisTaskEmcal::kpp) {
231 title[dim] = "Centrality %";
232 nbins[dim] = fNCentHistBins;
233 binEdges[dim] = fCentHistBins;
237 title[dim] = "#it{p}_{T} (GeV/#it{c})";
238 nbins[dim] = fNPtHistBins;
239 binEdges[dim] = fPtHistBins;
243 nbins[dim] = fNEtaHistBins;
244 binEdges[dim] = fEtaHistBins;
248 nbins[dim] = fNPhiHistBins;
249 binEdges[dim] = fPhiHistBins;
253 title[dim] = "MC Generator";
255 binEdges[dim] = fIntegerHistBins;
259 title[dim] = "Findable";
261 binEdges[dim] = fIntegerHistBins;
264 fParticlesPhysPrim = new THnSparseF("fParticlesPhysPrim","fParticlesPhysPrim",dim,nbins);
265 for (Int_t i = 0; i < dim; i++) {
266 fParticlesPhysPrim->GetAxis(i)->SetTitle(title[i]);
267 fParticlesPhysPrim->SetBinEdges(i, binEdges[i]);
270 fOutput->Add(fParticlesPhysPrim);
273 //________________________________________________________________________
274 void AliEmcalTrackingQATask::AllocateMatchedParticlesTHnSparse()
278 Int_t nbins[20] = {0};
279 Double_t *binEdges[20] = {0};
281 if (fForceBeamType != AliAnalysisTaskEmcal::kpp) {
282 title[dim] = "Centrality %";
283 nbins[dim] = fNCentHistBins;
284 binEdges[dim] = fCentHistBins;
288 title[dim] = "#it{p}_{T}^{gen} (GeV/#it{c})";
289 nbins[dim] = fNPtHistBins;
290 binEdges[dim] = fPtHistBins;
293 title[dim] = "#eta^{gen}";
294 nbins[dim] = fNEtaHistBins;
295 binEdges[dim] = fEtaHistBins;
298 title[dim] = "#phi^{gen}";
299 nbins[dim] = fNPhiHistBins;
300 binEdges[dim] = fPhiHistBins;
303 title[dim] = "#it{p}_{T}^{det} (GeV/#it{c})";
304 nbins[dim] = fNPtHistBins;
305 binEdges[dim] = fPtHistBins;
308 title[dim] = "#eta^{det}";
309 nbins[dim] = fNEtaHistBins;
310 binEdges[dim] = fEtaHistBins;
313 title[dim] = "#phi^{det}";
314 nbins[dim] = fNPhiHistBins;
315 binEdges[dim] = fPhiHistBins;
318 title[dim] = "(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}";
319 nbins[dim] = fNPtResHistBins;
320 binEdges[dim] = fPtResHistBins;
323 title[dim] = "track type";
325 binEdges[dim] = fIntegerHistBins;
328 fParticlesMatched = new THnSparseF("fParticlesMatched","fParticlesMatched",dim,nbins);
329 for (Int_t i = 0; i < dim; i++) {
330 fParticlesMatched->GetAxis(i)->SetTitle(title[i]);
331 fParticlesMatched->SetBinEdges(i, binEdges[i]);
334 fOutput->Add(fParticlesMatched);
337 //________________________________________________________________________
338 void AliEmcalTrackingQATask::SetGeneratorLevelName(const char* name)
340 if (!fDetectorLevel) {
341 AliError("Please, first set the detector level array!");
344 if (!fGeneratorLevel) { // first check if the generator level array is set
345 fGeneratorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
346 if (fGeneratorLevel) { // now check if the first collection array has been added already
347 fGeneratorLevel->SetArrayName(name);
350 fGeneratorLevel = AddParticleContainer(name);
352 fGeneratorLevel->SetClassName("AliAODMCParticle");
353 fGeneratorLevel->SelectPhysicalPrimaries(kTRUE);
354 fGeneratorLevel->SetParticlePtCut(0);
356 fGeneratorLevel->SetArrayName(name);
359 //________________________________________________________________________
360 void AliEmcalTrackingQATask::SetDetectorLevelName(const char* name)
362 if (!fDetectorLevel) { // first check if the detector level array is set
363 fDetectorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
364 if (fDetectorLevel) { // now check if the second collection array has been added already
365 fDetectorLevel->SetArrayName(name);
368 fDetectorLevel = AddParticleContainer(name);
370 fDetectorLevel->SetClassName("AliPicoTrack");
372 fDetectorLevel->SetArrayName(name);
375 //________________________________________________________________________
376 void AliEmcalTrackingQATask::ExecOnce()
378 // Init the analysis.
380 AliAnalysisTaskEmcal::ExecOnce();
383 //________________________________________________________________________
384 void AliEmcalTrackingQATask::FillDetectorLevelTHnSparse(Double_t cent, Double_t trackEta, Double_t trackPhi, Double_t trackPt,
385 Double_t sigma1OverPt, Int_t mcGen, Byte_t trackType)
387 Double_t contents[20]={0};
389 for (Int_t i = 0; i < fTracks->GetNdimensions(); i++) {
390 TString title(fTracks->GetAxis(i)->GetTitle());
391 if (title=="Centrality %")
393 else if (title=="#it{p}_{T} (GeV/#it{c})")
394 contents[i] = trackPt;
395 else if (title=="#eta")
396 contents[i] = trackEta;
397 else if (title=="#phi")
398 contents[i] = trackPhi;
399 else if (title=="#sigma(1/#it{p}_{T}) (GeV/#it{c})^{-1}")
400 contents[i] = sigma1OverPt;
401 else if (title=="MC Generator")
403 else if (title=="track type")
404 contents[i] = trackType;
406 AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fTracks->GetName()));
409 fTracks->Fill(contents);
412 //________________________________________________________________________
413 void AliEmcalTrackingQATask::FillGeneratorLevelTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt, Int_t mcGen, Byte_t findable)
415 Double_t contents[20]={0};
417 for (Int_t i = 0; i < fParticlesPhysPrim->GetNdimensions(); i++) {
418 TString title(fParticlesPhysPrim->GetAxis(i)->GetTitle());
419 if (title=="Centrality %")
421 else if (title=="#it{p}_{T} (GeV/#it{c})")
422 contents[i] = partPt;
423 else if (title=="#eta")
424 contents[i] = partEta;
425 else if (title=="#phi")
426 contents[i] = partPhi;
427 else if (title=="MC Generator")
429 else if (title=="Findable")
430 contents[i] = findable;
432 AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fParticlesPhysPrim->GetName()));
435 fParticlesPhysPrim->Fill(contents);
438 //________________________________________________________________________
439 void AliEmcalTrackingQATask::FillMatchedParticlesTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt,
440 Double_t trackEta, Double_t trackPhi, Double_t trackPt, Byte_t trackType)
442 Double_t contents[20]={0};
444 for (Int_t i = 0; i < fParticlesMatched->GetNdimensions(); i++) {
445 TString title(fParticlesMatched->GetAxis(i)->GetTitle());
446 if (title=="Centrality %")
448 else if (title=="#it{p}_{T}^{gen} (GeV/#it{c})")
449 contents[i] = partPt;
450 else if (title=="#eta^{gen}")
451 contents[i] = partEta;
452 else if (title=="#phi^{gen}")
453 contents[i] = partPhi;
454 else if (title=="#it{p}_{T}^{det} (GeV/#it{c})")
455 contents[i] = trackPt;
456 else if (title=="#eta^{det}")
457 contents[i] = trackEta;
458 else if (title=="#phi^{det}")
459 contents[i] = trackPhi;
460 else if (title=="(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}")
461 contents[i] = (partPt - trackPt) / partPt;
462 else if (title=="track type")
463 contents[i] = (Double_t)trackType;
465 AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fParticlesMatched->GetName()));
468 fParticlesMatched->Fill(contents);
471 //________________________________________________________________________
472 Bool_t AliEmcalTrackingQATask::FillHistograms()
474 // Fill the histograms.
476 AliPicoTrack *track = static_cast<AliPicoTrack*>(fDetectorLevel->GetNextAcceptParticle(0));
478 Byte_t type = track->GetTrackType();
482 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track->GetTrack());
483 if (esdTrack) sigma = TMath::Sqrt(esdTrack->GetSigma1Pt2());
486 Int_t label = TMath::Abs(track->GetLabel());
488 // reject particles generated from other generators in the cocktail but keep fake tracks (label == 0)
489 if (fSelectHIJING && (label==0 || track->GetGeneratorIndex() == 0)) mcGen = 0;
491 FillDetectorLevelTHnSparse(fCent, track->Eta(), track->Phi(), track->Pt(), sigma, mcGen, type);
493 if (fGeneratorLevel && label > 0) {
494 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetAcceptParticleWithLabel(label));
496 if (!fSelectHIJING || part->GetGeneratorIndex() == 0) {
497 Int_t pdg = TMath::Abs(part->PdgCode());
498 // select charged pions, protons, kaons , electrons, muons
499 if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) {
500 FillMatchedParticlesTHnSparse(fCent, part->Eta(), part->Phi(), part->Pt(), track->Eta(), track->Phi(), track->Pt(), type);
507 AliError(Form("Track %d has type %d not recognized!", fDetectorLevel->GetCurrentID(), type));
510 track = static_cast<AliPicoTrack*>(fDetectorLevel->GetNextAcceptParticle());
513 if (fGeneratorLevel) {
514 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetNextAcceptParticle(0));
519 if (fSelectHIJING && part->GetGeneratorIndex() == 0) mcGen = 0;
521 Int_t pdg = TMath::Abs(part->PdgCode());
522 // select charged pions, protons, kaons , electrons, muons
523 if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) findable = 1;
525 FillGeneratorLevelTHnSparse(fCent, part->Eta(), part->Phi(), part->Pt(), mcGen, findable);
526 part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetNextAcceptParticle());