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),
25 fDoSigma1OverPt(kFALSE),
26 fDoSigmaPtOverPtGen(kFALSE),
37 fNPtRelDiffHistBins(0),
38 fPtRelDiffHistBins(0),
41 f1OverPtResHistBins(0),
42 fN1OverPtResHistBins(0),
46 fParticlesPhysPrim(0),
49 // Default constructor.
51 SetMakeGeneralHistograms(kTRUE);
56 //________________________________________________________________________
57 AliEmcalTrackingQATask::AliEmcalTrackingQATask(const char *name) :
58 AliAnalysisTaskEmcal(name, kTRUE),
60 fDoSigma1OverPt(kFALSE),
61 fDoSigmaPtOverPtGen(kFALSE),
72 fNPtRelDiffHistBins(0),
73 fPtRelDiffHistBins(0),
76 f1OverPtResHistBins(0),
77 fN1OverPtResHistBins(0),
81 fParticlesPhysPrim(0),
84 // Standard constructor.
86 SetMakeGeneralHistograms(kTRUE);
91 //________________________________________________________________________
92 AliEmcalTrackingQATask::~AliEmcalTrackingQATask()
97 //________________________________________________________________________
98 void AliEmcalTrackingQATask::GenerateHistoBins()
101 fPtHistBins = new Double_t[fNPtHistBins+1];
102 GenerateFixedBinArray(6, 0, 0.3, fPtHistBins);
103 GenerateFixedBinArray(7, 0.3, 1, fPtHistBins+6);
104 GenerateFixedBinArray(10, 1, 3, fPtHistBins+13);
105 GenerateFixedBinArray(14, 3, 10, fPtHistBins+23);
106 GenerateFixedBinArray(10, 10, 20, fPtHistBins+37);
107 GenerateFixedBinArray(15, 20, 50, fPtHistBins+47);
108 GenerateFixedBinArray(20, 50, 150, fPtHistBins+62);
111 fEtaHistBins = new Double_t[fNEtaHistBins+1];
112 GenerateFixedBinArray(fNEtaHistBins, -1, 1, fEtaHistBins);
115 fPhiHistBins = new Double_t[fNPhiHistBins+1];
116 GenerateFixedBinArray(fNPhiHistBins, 0, TMath::Pi() * 2.02, fPhiHistBins);
119 fCentHistBins = new Double_t[fNCentHistBins+1];
120 fCentHistBins[0] = 0;
121 fCentHistBins[1] = 10;
122 fCentHistBins[2] = 30;
123 fCentHistBins[3] = 50;
124 fCentHistBins[4] = 90;
126 fNPtResHistBins = 175;
127 fPtResHistBins = new Double_t[fNPtResHistBins+1];
128 GenerateFixedBinArray(50, 0, 0.05, fPtResHistBins);
129 GenerateFixedBinArray(25, 0.05, 0.10, fPtResHistBins+50);
130 GenerateFixedBinArray(25, 0.10, 0.20, fPtResHistBins+75);
131 GenerateFixedBinArray(30, 0.20, 0.50, fPtResHistBins+100);
132 GenerateFixedBinArray(25, 0.50, 1.00, fPtResHistBins+130);
133 GenerateFixedBinArray(20, 1.00, 2.00, fPtResHistBins+155);
135 fNPtRelDiffHistBins = 200;
136 fPtRelDiffHistBins = new Double_t[fNPtRelDiffHistBins+1];
137 GenerateFixedBinArray(fNPtRelDiffHistBins, -2, 2, fPtRelDiffHistBins);
139 fN1OverPtResHistBins = 385;
140 f1OverPtResHistBins = new Double_t[fN1OverPtResHistBins+1];
141 GenerateFixedBinArray(100, 0, 0.02, f1OverPtResHistBins);
142 GenerateFixedBinArray(60, 0.02, 0.05, f1OverPtResHistBins+100);
143 GenerateFixedBinArray(50, 0.05, 0.1, f1OverPtResHistBins+160);
144 GenerateFixedBinArray(50, 0.1, 0.2, f1OverPtResHistBins+210);
145 GenerateFixedBinArray(75, 0.2, 0.5, f1OverPtResHistBins+260);
146 GenerateFixedBinArray(50, 0.5, 1.5, f1OverPtResHistBins+335);
148 fNIntegerHistBins = 10;
149 fIntegerHistBins = new Double_t[fNIntegerHistBins+1];
150 GenerateFixedBinArray(fNIntegerHistBins, -0.5, 9.5, fIntegerHistBins);
153 //________________________________________________________________________
154 void AliEmcalTrackingQATask::UserCreateOutputObjects()
156 // Create my user objects.
158 AliAnalysisTaskEmcal::UserCreateOutputObjects();
160 if (fParticleCollArray.GetEntriesFast() < 1) {
161 AliFatal("This task needs at least one particle container!");
164 if (!fDetectorLevel) {
165 fDetectorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
166 fDetectorLevel->SetClassName("AliPicoTrack");
169 if (!fGeneratorLevel && fParticleCollArray.GetEntriesFast() > 1) {
170 fGeneratorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
171 fGeneratorLevel->SetClassName("AliAODMCParticle");
174 AllocateDetectorLevelTHnSparse();
176 if (fGeneratorLevel) {
177 AllocateGeneratorLevelTHnSparse();
178 AllocateMatchedParticlesTHnSparse();
182 //________________________________________________________________________
183 void AliEmcalTrackingQATask::AllocateDetectorLevelTHnSparse()
187 Int_t nbins[20] = {0};
188 Double_t *binEdges[20] = {0};
190 if (fForceBeamType != AliAnalysisTaskEmcal::kpp) {
191 title[dim] = "Centrality %";
192 nbins[dim] = fNCentHistBins;
193 binEdges[dim] = fCentHistBins;
197 title[dim] = "#it{p}_{T} (GeV/#it{c})";
198 nbins[dim] = fNPtHistBins;
199 binEdges[dim] = fPtHistBins;
203 nbins[dim] = fNEtaHistBins;
204 binEdges[dim] = fEtaHistBins;
208 nbins[dim] = fNPhiHistBins;
209 binEdges[dim] = fPhiHistBins;
213 title[dim] = "MC Generator";
215 binEdges[dim] = fIntegerHistBins;
219 title[dim] = "track type";
221 binEdges[dim] = fIntegerHistBins;
225 if (fDoSigma1OverPt) {
226 title[dim] = "#sigma(1/#it{p}_{T}) (GeV/#it{c})^{-1}";
227 nbins[dim] = fN1OverPtResHistBins;
228 binEdges[dim] = f1OverPtResHistBins;
232 title[dim] = "#sigma(#it{p}_{T}) / #it{p}_{T}";
233 nbins[dim] = fNPtResHistBins;
234 binEdges[dim] = fPtResHistBins;
239 fTracks = new THnSparseF("fTracks","fTracks",dim,nbins);
240 for (Int_t i = 0; i < dim; i++) {
241 fTracks->GetAxis(i)->SetTitle(title[i]);
242 fTracks->SetBinEdges(i, binEdges[i]);
245 fOutput->Add(fTracks);
248 //________________________________________________________________________
249 void AliEmcalTrackingQATask::AllocateGeneratorLevelTHnSparse()
253 Int_t nbins[20] = {0};
254 Double_t *binEdges[20] = {0};
256 if (fForceBeamType != AliAnalysisTaskEmcal::kpp) {
257 title[dim] = "Centrality %";
258 nbins[dim] = fNCentHistBins;
259 binEdges[dim] = fCentHistBins;
263 title[dim] = "#it{p}_{T} (GeV/#it{c})";
264 nbins[dim] = fNPtHistBins;
265 binEdges[dim] = fPtHistBins;
269 nbins[dim] = fNEtaHistBins;
270 binEdges[dim] = fEtaHistBins;
274 nbins[dim] = fNPhiHistBins;
275 binEdges[dim] = fPhiHistBins;
279 title[dim] = "MC Generator";
281 binEdges[dim] = fIntegerHistBins;
285 title[dim] = "Findable";
287 binEdges[dim] = fIntegerHistBins;
290 fParticlesPhysPrim = new THnSparseF("fParticlesPhysPrim","fParticlesPhysPrim",dim,nbins);
291 for (Int_t i = 0; i < dim; i++) {
292 fParticlesPhysPrim->GetAxis(i)->SetTitle(title[i]);
293 fParticlesPhysPrim->SetBinEdges(i, binEdges[i]);
296 fOutput->Add(fParticlesPhysPrim);
299 //________________________________________________________________________
300 void AliEmcalTrackingQATask::AllocateMatchedParticlesTHnSparse()
304 Int_t nbins[20] = {0};
305 Double_t *binEdges[20] = {0};
307 if (fForceBeamType != AliAnalysisTaskEmcal::kpp) {
308 title[dim] = "Centrality %";
309 nbins[dim] = fNCentHistBins;
310 binEdges[dim] = fCentHistBins;
314 title[dim] = "#it{p}_{T}^{gen} (GeV/#it{c})";
315 nbins[dim] = fNPtHistBins;
316 binEdges[dim] = fPtHistBins;
319 title[dim] = "#eta^{gen}";
320 nbins[dim] = fNEtaHistBins;
321 binEdges[dim] = fEtaHistBins;
324 title[dim] = "#phi^{gen}";
325 nbins[dim] = fNPhiHistBins;
326 binEdges[dim] = fPhiHistBins;
329 title[dim] = "#it{p}_{T}^{det} (GeV/#it{c})";
330 nbins[dim] = fNPtHistBins;
331 binEdges[dim] = fPtHistBins;
334 title[dim] = "#eta^{det}";
335 nbins[dim] = fNEtaHistBins;
336 binEdges[dim] = fEtaHistBins;
339 title[dim] = "#phi^{det}";
340 nbins[dim] = fNPhiHistBins;
341 binEdges[dim] = fPhiHistBins;
344 if (fDoSigmaPtOverPtGen) {
345 title[dim] = "(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}";
346 nbins[dim] = fNPtRelDiffHistBins;
347 binEdges[dim] = fPtRelDiffHistBins;
351 title[dim] = "(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{det}";
352 nbins[dim] = fNPtRelDiffHistBins;
353 binEdges[dim] = fPtRelDiffHistBins;
357 title[dim] = "track type";
359 binEdges[dim] = fIntegerHistBins;
362 fParticlesMatched = new THnSparseF("fParticlesMatched","fParticlesMatched",dim,nbins);
363 for (Int_t i = 0; i < dim; i++) {
364 fParticlesMatched->GetAxis(i)->SetTitle(title[i]);
365 fParticlesMatched->SetBinEdges(i, binEdges[i]);
368 fOutput->Add(fParticlesMatched);
371 //________________________________________________________________________
372 void AliEmcalTrackingQATask::SetGeneratorLevelName(const char* name)
374 if (!fDetectorLevel) {
375 AliError("Please, first set the detector level array!");
378 if (!fGeneratorLevel) { // first check if the generator level array is set
379 fGeneratorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
380 if (fGeneratorLevel) { // now check if the first collection array has been added already
381 fGeneratorLevel->SetArrayName(name);
384 fGeneratorLevel = AddParticleContainer(name);
386 fGeneratorLevel->SetClassName("AliAODMCParticle");
387 fGeneratorLevel->SelectPhysicalPrimaries(kTRUE);
388 fGeneratorLevel->SetParticlePtCut(0);
390 fGeneratorLevel->SetArrayName(name);
393 //________________________________________________________________________
394 void AliEmcalTrackingQATask::SetDetectorLevelName(const char* name)
396 if (!fDetectorLevel) { // first check if the detector level array is set
397 fDetectorLevel = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
398 if (fDetectorLevel) { // now check if the second collection array has been added already
399 fDetectorLevel->SetArrayName(name);
402 fDetectorLevel = AddParticleContainer(name);
404 fDetectorLevel->SetClassName("AliPicoTrack");
406 fDetectorLevel->SetArrayName(name);
409 //________________________________________________________________________
410 void AliEmcalTrackingQATask::ExecOnce()
412 // Init the analysis.
414 AliAnalysisTaskEmcal::ExecOnce();
417 //________________________________________________________________________
418 void AliEmcalTrackingQATask::FillDetectorLevelTHnSparse(Double_t cent, Double_t trackEta, Double_t trackPhi, Double_t trackPt,
419 Double_t sigma1OverPt, Int_t mcGen, Byte_t trackType)
421 Double_t contents[20]={0};
423 for (Int_t i = 0; i < fTracks->GetNdimensions(); i++) {
424 TString title(fTracks->GetAxis(i)->GetTitle());
425 if (title=="Centrality %")
427 else if (title=="#it{p}_{T} (GeV/#it{c})")
428 contents[i] = trackPt;
429 else if (title=="#eta")
430 contents[i] = trackEta;
431 else if (title=="#phi")
432 contents[i] = trackPhi;
433 else if (title=="#sigma(1/#it{p}_{T}) (GeV/#it{c})^{-1}")
434 contents[i] = sigma1OverPt;
435 else if (title=="#sigma(#it{p}_{T}) / #it{p}_{T}")
436 contents[i] = sigma1OverPt*trackPt;
437 else if (title=="MC Generator")
439 else if (title=="track type")
440 contents[i] = trackType;
442 AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fTracks->GetName()));
445 fTracks->Fill(contents);
448 //________________________________________________________________________
449 void AliEmcalTrackingQATask::FillGeneratorLevelTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt, Int_t mcGen, Byte_t findable)
451 Double_t contents[20]={0};
453 for (Int_t i = 0; i < fParticlesPhysPrim->GetNdimensions(); i++) {
454 TString title(fParticlesPhysPrim->GetAxis(i)->GetTitle());
455 if (title=="Centrality %")
457 else if (title=="#it{p}_{T} (GeV/#it{c})")
458 contents[i] = partPt;
459 else if (title=="#eta")
460 contents[i] = partEta;
461 else if (title=="#phi")
462 contents[i] = partPhi;
463 else if (title=="MC Generator")
465 else if (title=="Findable")
466 contents[i] = findable;
468 AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fParticlesPhysPrim->GetName()));
471 fParticlesPhysPrim->Fill(contents);
474 //________________________________________________________________________
475 void AliEmcalTrackingQATask::FillMatchedParticlesTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt,
476 Double_t trackEta, Double_t trackPhi, Double_t trackPt, Byte_t trackType)
478 Double_t contents[20]={0};
480 for (Int_t i = 0; i < fParticlesMatched->GetNdimensions(); i++) {
481 TString title(fParticlesMatched->GetAxis(i)->GetTitle());
482 if (title=="Centrality %")
484 else if (title=="#it{p}_{T}^{gen} (GeV/#it{c})")
485 contents[i] = partPt;
486 else if (title=="#eta^{gen}")
487 contents[i] = partEta;
488 else if (title=="#phi^{gen}")
489 contents[i] = partPhi;
490 else if (title=="#it{p}_{T}^{det} (GeV/#it{c})")
491 contents[i] = trackPt;
492 else if (title=="#eta^{det}")
493 contents[i] = trackEta;
494 else if (title=="#phi^{det}")
495 contents[i] = trackPhi;
496 else if (title=="(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}")
497 contents[i] = (partPt - trackPt) / partPt;
498 else if (title=="(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{det}")
499 contents[i] = (partPt - trackPt) / trackPt;
500 else if (title=="track type")
501 contents[i] = (Double_t)trackType;
503 AliWarning(Form("Unable to fill dimension %s of histogram %s!", title.Data(), fParticlesMatched->GetName()));
506 fParticlesMatched->Fill(contents);
509 //________________________________________________________________________
510 Bool_t AliEmcalTrackingQATask::FillHistograms()
512 // Fill the histograms.
514 AliPicoTrack *track = static_cast<AliPicoTrack*>(fDetectorLevel->GetNextAcceptParticle(0));
516 Byte_t type = track->GetTrackType();
520 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track->GetTrack());
521 if (esdTrack) sigma = TMath::Sqrt(esdTrack->GetSigma1Pt2());
524 Int_t label = TMath::Abs(track->GetLabel());
526 // reject particles generated from other generators in the cocktail but keep fake tracks (label == 0)
527 if (fSelectHIJING && (label==0 || track->GetGeneratorIndex() == 0)) mcGen = 0;
529 FillDetectorLevelTHnSparse(fCent, track->Eta(), track->Phi(), track->Pt(), sigma, mcGen, type);
531 if (fGeneratorLevel && label > 0) {
532 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetAcceptParticleWithLabel(label));
534 if (!fSelectHIJING || part->GetGeneratorIndex() == 0) {
535 Int_t pdg = TMath::Abs(part->PdgCode());
536 // select charged pions, protons, kaons , electrons, muons
537 if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) {
538 FillMatchedParticlesTHnSparse(fCent, part->Eta(), part->Phi(), part->Pt(), track->Eta(), track->Phi(), track->Pt(), type);
545 AliError(Form("Track %d has type %d not recognized!", fDetectorLevel->GetCurrentID(), type));
548 track = static_cast<AliPicoTrack*>(fDetectorLevel->GetNextAcceptParticle());
551 if (fGeneratorLevel) {
552 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetNextAcceptParticle(0));
557 if (fSelectHIJING && part->GetGeneratorIndex() == 0) mcGen = 0;
559 Int_t pdg = TMath::Abs(part->PdgCode());
560 // select charged pions, protons, kaons , electrons, muons
561 if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) findable = 1;
563 FillGeneratorLevelTHnSparse(fCent, part->Eta(), part->Phi(), part->Pt(), mcGen, findable);
564 part = static_cast<AliAODMCParticle*>(fGeneratorLevel->GetNextAcceptParticle());