8 #include <AliESDtrack.h> 9 #include <AliAODTrack.h> 10 #include <AliAODMCParticle.h> 12 #include <AliAnalysisManager.h> 13 #include <AliVEventHandler.h> 26 fDoSigma1OverPt(kFALSE),
27 fDoSigmaPtOverPtGen(kFALSE),
28 fDoSeparateTRDrefit(kFALSE),
30 fGeneratorLevel(
nullptr),
31 fDetectorLevel(
nullptr),
38 f1OverPtResHistBins(),
41 fParticlesPhysPrim(
nullptr),
42 fParticlesMatched(
nullptr)
44 SetMakeGeneralHistograms(kTRUE);
54 fDoSigma1OverPt(kFALSE),
55 fDoSigmaPtOverPtGen(kFALSE),
56 fDoSeparateTRDrefit(kFALSE),
66 f1OverPtResHistBins(),
134 AliErrorStream() <<
"This task needs at least one particle container! The task won't run." << std::endl;
139 AliDebugStream(3) <<
"Loading the detector track container" << std::endl;
143 AliErrorStream() <<
"This task needs at least one particle container named 'detector'! The task won't run." << std::endl;
152 AliDebugStream(3) <<
"Loading the generator particle container" << std::endl;
156 AliInfoStream() <<
"No particle container named 'generator' was found. Assuming this is not a MC production." << std::endl;
163 AliDebugStream(3) <<
"Allocating histograms" << std::endl;
176 AliErrorStream() <<
"Could not load track array! The task won't run." << std::endl;
191 std::vector<int>
nbins;
192 for (
auto a : axis) nbins.push_back(
int(std::get<2>(a) - std::get<1>(a) - 1));
194 THnSparse* h =
new THnSparseF(name, name, nbins.size(), &nbins[0]);
196 for (
auto a : axis) {
197 h->GetAxis(i)->SetTitle(std::get<0>(a).c_str());
198 h->SetBinEdges(i, &(*(std::get<1>(a))));
210 typedef std::vector<Double_t>::iterator my_iterator;
212 std::vector<std::tuple<std::string, my_iterator, my_iterator>> axis;
241 typedef std::vector<Double_t>::iterator my_iterator;
243 std::vector<std::tuple<std::string, my_iterator, my_iterator>> axis;
265 typedef std::vector<Double_t>::iterator my_iterator;
267 std::vector<std::tuple<std::string, my_iterator, my_iterator>> axis;
299 AliDebugStream(10) <<
"Filling detector level THnSparse" << std::endl;
300 std::vector<Double_t> contents(
fTracks->GetNdimensions());
304 if (
title==
"Centrality %")
306 else if (
title==
"#it{p}_{T} (GeV/#it{c})")
307 contents[i] = trackPt;
308 else if (
title==
"#eta")
309 contents[i] = trackEta;
310 else if (
title==
"#phi")
311 contents[i] = trackPhi;
312 else if (
title==
"#sigma(1/#it{p}_{T}) (GeV/#it{c})^{-1}")
313 contents[i] = sigma1OverPt;
314 else if (
title==
"#sigma(#it{p}_{T}) / #it{p}_{T}")
315 contents[i] = sigma1OverPt*trackPt;
316 else if (
title==
"MC Generator")
318 else if (
title==
"track type")
319 contents[i] = trackType;
321 AliWarning(Form(
"Unable to fill dimension %s of histogram %s!",
title.Data(),
fTracks->GetName()));
336 if (
title==
"Centrality %")
338 else if (
title==
"#it{p}_{T} (GeV/#it{c})")
339 contents[i] = partPt;
340 else if (
title==
"#eta")
341 contents[i] = partEta;
342 else if (
title==
"#phi")
343 contents[i] = partPhi;
344 else if (
title==
"MC Generator")
346 else if (
title==
"Findable")
347 contents[i] = findable;
365 if (
title==
"Centrality %")
367 else if (
title==
"#it{p}_{T}^{gen} (GeV/#it{c})")
368 contents[i] = partPt;
369 else if (
title==
"#eta^{gen}")
370 contents[i] = partEta;
371 else if (
title==
"#phi^{gen}")
372 contents[i] = partPhi;
373 else if (
title==
"#it{p}_{T}^{det} (GeV/#it{c})")
374 contents[i] = trackPt;
375 else if (
title==
"#eta^{det}")
376 contents[i] = trackEta;
377 else if (
title==
"#phi^{det}")
378 contents[i] = trackPhi;
379 else if (
title==
"(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}")
380 contents[i] = (partPt - trackPt) / partPt;
381 else if (
title==
"(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{det}")
382 contents[i] = (partPt - trackPt) / trackPt;
383 else if (
title==
"track type")
386 AliWarning(Form(
"Unable to fill dimension %s of histogram %s!",
title.Data(),
fParticlesMatched->GetName()));
399 for (
auto trackIterator = iterable.begin(); trackIterator != iterable.end(); trackIterator++) {
400 auto track = trackIterator->second;
402 AliDebugStream(2) <<
"Next track of type " <<
static_cast<Int_t>(type) << std::endl;
403 Byte_t ntracklets = 0;
408 AliESDtrack *esdTrack =
dynamic_cast<AliESDtrack*
>(track);
410 sigma = TMath::Sqrt(esdTrack->GetSigma1Pt2());
411 ntracklets = esdTrack->GetTRDntracklets();
415 AliAODTrack *aodtrack =
dynamic_cast<AliAODTrack*
>(track);
416 if(!aodtrack) AliFatal(
"Not a standard AOD");
418 AliExternalTrackParam exParam;
422 aodtrack->GetCovMatrix(cov);
424 aodtrack->PxPyPz(pxpypz);
426 aodtrack->GetXYZ(xyz);
427 Short_t sign = aodtrack->Charge();
428 exParam.Set(xyz,pxpypz,cov,sign);
430 sigma = TMath::Sqrt(exParam.GetSigma1Pt2());
431 ntracklets = track->GetTRDntrackletsPID();
437 if(ntracklets < 3) type += 4;
440 Int_t label = TMath::Abs(track->GetLabel());
441 AliDebugStream(10) <<
"Track " << trackIterator.current_index() <<
" with type " << int(type) <<
" and label " << label <<
442 ", pt = " << track->Pt() << std::endl;
445 if (label == 0 || track->GetGeneratorIndex() <= 0) mcGen = 0;
452 if (part->GetGeneratorIndex() <= 0) {
453 Int_t pdg = TMath::Abs(part->PdgCode());
455 if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) {
463 AliErrorStream() <<
"Track " << trackIterator.current_index() <<
" has type " << type <<
" not recognized!" << std::endl;
469 for (
auto partIterator = iterable.begin(); partIterator != iterable.end(); partIterator++) {
470 auto part = partIterator->second;
475 if (part->GetGeneratorIndex() <= 0) mcGen = 0;
477 Int_t pdg = TMath::Abs(part->PdgCode());
479 if (pdg == 211 || pdg == 2212 || pdg == 321 || pdg == 11 || pdg == 13) findable = 1;
497 AliErrorClassStream() <<
"No analysis manager to connect to." << std::endl;
502 AliVEventHandler* handler = mgr->GetInputEventHandler();
504 AliErrorClassStream() <<
"This task requires an input event handler" << std::endl;
508 AliInfoClassStream() <<
"Event handler ok!" << std::endl;
513 if (handler->InheritsFrom(
"AliESDInputHandler")) {
515 AliInfoClassStream() <<
"Data type is ESD." << std::endl;
517 else if (handler->InheritsFrom(
"AliAODInputHandler")) {
519 AliInfoClassStream() <<
"Data type is AOD." << std::endl;
523 if (dataType ==
kESD) track_name =
"Tracks";
526 TString name(
"AliEmcalTrackingQATask");
527 if(strlen(suffix)) name += TString::Format(
"_%s", suffix);
528 AliInfoClassStream() <<
"Allocating task." << std::endl;
531 AliInfoClassStream() <<
"Task allocated, setting containers." << std::endl;
535 AliInfoClassStream() <<
"Containers ok, adding task to the analysis manager." << std::endl;
537 mgr->AddTask(qaTask);
539 AliInfoClassStream() <<
"Task added, setting input/output." << std::endl;
541 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
544 contName +=
"_histos";
545 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(),
546 TList::Class(),AliAnalysisManager::kOutputContainer,
547 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
548 mgr->ConnectInput (qaTask, 0, cinput1 );
549 mgr->ConnectOutput (qaTask, 1, coutput1 );
552 AliInfoClassStream() <<
"Task configuration done." << std::endl;
void UserCreateOutputObjects()
Bool_t fInhibit
!inhibit execution of the task
TList * fOutput
!output list
std::vector< Double_t > fEtaHistBins
! eta bins
EDataType_t
Switch for the data type.
static AliEmcalTrackingQATask * AddTaskTrackingQA(Bool_t isMC, const char *suffix="")
AliTrackContainer * fDetectorLevel
! detector level container
void AllocateMatchedParticlesTHnSparse()
std::vector< Double_t > fIntegerHistBins
! integer bins
const AliMCParticleIterableMomentumContainer accepted_momentum() const
virtual ~AliEmcalTrackingQATask()
std::vector< Double_t > f1OverPtResHistBins
! 1/pt res bins
Container with name, TClonesArray and cuts for particles.
static std::vector< double > GenerateFixedBinArray(int n, double min, double max, bool last=true)
THnSparse * GenerateTHnSparse(const char *name, const std::vector< std::tuple< std::string, std::vector< Double_t >::iterator, std::vector< Double_t >::iterator >> &axis)
std::vector< Double_t > fPtHistBins
! pt bins
EBeamType_t fForceBeamType
forced beam type
void FillMatchedParticlesTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt, Double_t trackEta, Double_t trackPhi, Double_t trackPt, Byte_t trackType)
void FillDetectorLevelTHnSparse(Double_t cent, Double_t trackEta, Double_t trackPhi, Double_t trackPt, Double_t sigma1OverPt, Int_t mcGen, Byte_t trackType)
Bool_t fIsEsd
! whether it is ESD data
std::vector< Double_t > fPtResHistBins
! pt res bins
Base task in the EMCAL framework (lighter version of AliAnalysisTaskEmcal)
void AllocateDetectorLevelTHnSparse()
virtual AliAODMCParticle * GetAcceptMCParticleWithLabel(Int_t lab)
std::vector< Double_t > fCentHistBins
! cent bins
Int_t GetNAcceptedTracks()
std::vector< Double_t > fPtRelDiffHistBins
! pt relative difference bins
void FillGeneratorLevelTHnSparse(Double_t cent, Double_t partEta, Double_t partPhi, Double_t partPt, Int_t mcGen, Byte_t findable)
AliParticleContainer * AddParticleContainer(std::string branchName, std::string contName="")
AliMCParticleContainer * fGeneratorLevel
! generator level container
Char_t GetTrackType(const AliVTrack *track) const
std::map< std::string, AliParticleContainer * > fParticleCollArray
particle/track collection array
void SetVzRange(Double_t min, Double_t max)
const AliTrackIterableMomentumContainer accepted_momentum() const
Bool_t fDoSigma1OverPt
add sigma(1/pt), if false add sigma(pt)/pt instead
std::vector< Double_t > fPhiHistBins
! phi bins
THnSparse * fParticlesPhysPrim
all tracks
Bool_t fDoSeparateTRDrefit
Separate tracks into tracks with TRD refit and 4 tracklets (gold) or not (sub-gold) ...
Container for MC-true particles within the EMCAL framework.
void AllocateGeneratorLevelTHnSparse()
void UserCreateOutputObjects()
void SetMakeGeneralHistograms(Bool_t g)
Double_t fCent
!event centrality
THnSparse * fParticlesMatched
all physical primary particles