7 #include <AliESDtrack.h> 8 #include <AliAODTrack.h> 9 #include <AliAODMCParticle.h> 11 #include <AliAnalysisManager.h> 12 #include <AliVEventHandler.h> 25 fDoSigma1OverPt(kFALSE),
26 fDoSigmaPtOverPtGen(kFALSE),
27 fDoSeparateTRDrefit(kFALSE),
29 fGeneratorLevel(
nullptr),
30 fDetectorLevel(
nullptr),
37 f1OverPtResHistBins(),
40 fParticlesPhysPrim(
nullptr),
41 fParticlesMatched(
nullptr)
43 SetMakeGeneralHistograms(kTRUE);
53 fDoSigma1OverPt(kFALSE),
54 fDoSigmaPtOverPtGen(kFALSE),
55 fDoSeparateTRDrefit(kFALSE),
65 f1OverPtResHistBins(),
133 AliErrorStream() <<
"This task needs at least one particle container! The task won't run." << std::endl;
138 AliDebugStream(3) <<
"Loading the detector track container" << std::endl;
142 AliErrorStream() <<
"This task needs at least one particle container named 'detector'! The task won't run." << std::endl;
151 AliDebugStream(3) <<
"Loading the generator particle container" << std::endl;
155 AliInfoStream() <<
"No particle container named 'generator' was found. Assuming this is not a MC production." << std::endl;
162 AliDebugStream(3) <<
"Allocating histograms" << std::endl;
175 AliErrorStream() <<
"Could not load track array! The task won't run." << std::endl;
190 std::vector<int>
nbins;
191 for (
auto a : axis) nbins.push_back(
int(std::get<2>(a) - std::get<1>(a) - 1));
193 THnSparse* h =
new THnSparseF(name, name, nbins.size(), &nbins[0]);
195 for (
auto a : axis) {
196 h->GetAxis(i)->SetTitle(std::get<0>(a).c_str());
197 h->SetBinEdges(i, &(*(std::get<1>(a))));
209 typedef std::vector<Double_t>::iterator my_iterator;
211 std::vector<std::tuple<std::string, my_iterator, my_iterator>> axis;
240 typedef std::vector<Double_t>::iterator my_iterator;
242 std::vector<std::tuple<std::string, my_iterator, my_iterator>> axis;
264 typedef std::vector<Double_t>::iterator my_iterator;
266 std::vector<std::tuple<std::string, my_iterator, my_iterator>> axis;
298 AliDebugStream(10) <<
"Filling detector level THnSparse" << std::endl;
299 std::vector<Double_t> contents(
fTracks->GetNdimensions());
303 if (
title==
"Centrality %")
305 else if (
title==
"#it{p}_{T} (GeV/#it{c})")
306 contents[i] = trackPt;
307 else if (
title==
"#eta")
308 contents[i] = trackEta;
309 else if (
title==
"#phi")
310 contents[i] = trackPhi;
311 else if (
title==
"#sigma(1/#it{p}_{T}) (GeV/#it{c})^{-1}")
312 contents[i] = sigma1OverPt;
313 else if (
title==
"#sigma(#it{p}_{T}) / #it{p}_{T}")
314 contents[i] = sigma1OverPt*trackPt;
315 else if (
title==
"MC Generator")
317 else if (
title==
"track type")
318 contents[i] = trackType;
320 AliWarning(Form(
"Unable to fill dimension %s of histogram %s!",
title.Data(),
fTracks->GetName()));
335 if (
title==
"Centrality %")
337 else if (
title==
"#it{p}_{T} (GeV/#it{c})")
338 contents[i] = partPt;
339 else if (
title==
"#eta")
340 contents[i] = partEta;
341 else if (
title==
"#phi")
342 contents[i] = partPhi;
343 else if (
title==
"MC Generator")
345 else if (
title==
"Findable")
346 contents[i] = findable;
364 if (
title==
"Centrality %")
366 else if (
title==
"#it{p}_{T}^{gen} (GeV/#it{c})")
367 contents[i] = partPt;
368 else if (
title==
"#eta^{gen}")
369 contents[i] = partEta;
370 else if (
title==
"#phi^{gen}")
371 contents[i] = partPhi;
372 else if (
title==
"#it{p}_{T}^{det} (GeV/#it{c})")
373 contents[i] = trackPt;
374 else if (
title==
"#eta^{det}")
375 contents[i] = trackEta;
376 else if (
title==
"#phi^{det}")
377 contents[i] = trackPhi;
378 else if (
title==
"(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{gen}")
379 contents[i] = (partPt - trackPt) / partPt;
380 else if (
title==
"(#it{p}_{T}^{gen} - #it{p}_{T}^{det}) / #it{p}_{T}^{det}")
381 contents[i] = (partPt - trackPt) / trackPt;
382 else if (
title==
"track type")
385 AliWarning(Form(
"Unable to fill dimension %s of histogram %s!",
title.Data(),
fParticlesMatched->GetName()));
398 for (
auto trackIterator = iterable.begin(); trackIterator != iterable.end(); trackIterator++) {
399 auto track = trackIterator->second;
401 AliDebugStream(2) <<
"Next track of type " <<
static_cast<Int_t>(type) << std::endl;
402 Byte_t ntracklets = 0;
407 AliESDtrack *esdTrack =
dynamic_cast<AliESDtrack*
>(track);
409 sigma = TMath::Sqrt(esdTrack->GetSigma1Pt2());
410 ntracklets = esdTrack->GetTRDntracklets();
414 AliAODTrack *aodtrack =
dynamic_cast<AliAODTrack*
>(track);
415 if(!aodtrack) AliFatal(
"Not a standard AOD");
417 AliExternalTrackParam exParam;
421 aodtrack->GetCovMatrix(cov);
423 aodtrack->PxPyPz(pxpypz);
425 aodtrack->GetXYZ(xyz);
426 Short_t sign = aodtrack->Charge();
427 exParam.Set(xyz,pxpypz,cov,sign);
429 sigma = TMath::Sqrt(exParam.GetSigma1Pt2());
430 ntracklets = track->GetTRDntrackletsPID();
437 if(!((track->GetStatus() & AliVTrack::kTRDrefit) && (ntracklets >= 4))) 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 AliInfoClassStream() <<
"Allocating task." << std::endl;
530 AliInfoClassStream() <<
"Task allocated, setting containers." << std::endl;
534 AliInfoClassStream() <<
"Containers ok, adding task to the analysis manager." << std::endl;
536 mgr->AddTask(qaTask);
538 AliInfoClassStream() <<
"Task added, setting input/output." << std::endl;
540 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
543 contName +=
"_histos";
544 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(),
545 TList::Class(),AliAnalysisManager::kOutputContainer,
546 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
547 mgr->ConnectInput (qaTask, 0, cinput1 );
548 mgr->ConnectOutput (qaTask, 1, coutput1 );
551 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.
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
static AliEmcalTrackingQATask * AddTaskTrackingQA(Bool_t isMC)
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