19 #include <TClonesArray.h> 20 #include <THashList.h> 29 #include "AliAnalysisDataContainer.h" 30 #include "AliAnalysisManager.h" 31 #include "AliAnalysisUtils.h" 32 #include "AliAODMCHeader.h" 33 #include "AliAODInputHandler.h" 34 #include "AliAODMCParticle.h" 35 #include "AliAODTrack.h" 40 #include "AliEMCALTriggerPatchInfo.h" 41 #include "AliEMCALGeometry.h" 43 #include "AliESDEvent.h" 44 #include "AliESDtrack.h" 45 #include "AliGenPythiaEventHeader.h" 46 #include "AliInputEventHandler.h" 47 #include "AliMCEvent.h" 48 #include "AliOADBContainer.h" 49 #include "AliVEvent.h" 50 #include "AliVEventHandler.h" 51 #include "AliVVertex.h" 62 AliAnalysisTaskChargedParticlesRefMC::AliAnalysisTaskChargedParticlesRefMC():
73 fEtaLabCut(-0.5, 0.5),
75 fPhiCut(0., TMath::TwoPi()),
79 fStudyEMCALgeo(false),
80 fExclusiveMinBias(false),
81 fRequireTOFBunchCrossing(false),
100 fEtaLabCut(-0.5, 0.5),
102 fPhiCut(0., TMath::TwoPi()),
104 fEnableSumw2(kFALSE),
106 fStudyEMCALgeo(false),
107 fExclusiveMinBias(false),
108 fRequireTOFBunchCrossing(false),
109 fNameAcceptanceOADB()
118 if(fTriggerSelection)
delete fTriggerSelection;
119 if(fHistos)
delete fHistos;
128 if(!fTrackCuts)
InitializeTrackCuts(
"standard",fInputHandler->IsA() == AliAODInputHandler::Class());
129 fTrackCuts->SaveQAObjects(
fOutput);
131 PtBinning newbinning;
132 TLinearBinning etabinning(64, -0.8, 0.8), phibinning(100, 0., 2*TMath::Pi()), chargebinning(2, -1.5, 1.5), primarybinning(2, -0.5, 1.5);
133 const TBinning *binning5D[5] = {&newbinning, &etabinning, &phibinning, &chargebinning, &primarybinning};
135 TString optionstring = fEnableSumw2 ?
"s" :
"";
137 fHistos->CreateTH1(
"hPtHard",
"Pt of the hard interaction", 1000, 0., 500);
138 const std::array<TString,6> species = {{
"El",
"Mu",
"Pi",
"Ka",
"Pr",
"Ot"}};
139 std::vector<TString> triggers = {
"True",
"MB"};
140 if(!fExclusiveMinBias){
141 const std::array<TString,5> kEMCALtriggers = {{
"EMC7",
"EJ1",
"EJ2",
"EG1",
"EG2"}};
142 for(
const auto &t : kEMCALtriggers) triggers.emplace_back(t);
144 for(
const auto &trg : triggers){
145 fHistos->CreateTH1(
"hEventCount" + trg,
"Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
146 fHistos->CreateTH1(
"hVertexBefore" + trg,
"Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
147 fHistos->CreateTH1(
"hVertexAfter" + trg,
"Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
149 fHistos->CreateTHnSparse(
"hPtEtaPhiAll" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
150 fHistos->CreateTHnSparse(
"hPtEtaPhiCent" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
152 fHistos->CreateTHnSparse(
"hPtEtaPhiEMCALAll" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
153 fHistos->CreateTHnSparse(
"hPtEtaPhiEMCALCent" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
157 for(
const auto &pid : species){
158 fHistos->CreateTHnSparse(
"hPtEtaPhiAll" + pid + trg,
"p_{t}-#eta-#phi distribution of all accepted " + pid +
" for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
159 fHistos->CreateTHnSparse(
"hPtEtaPhiCent" + pid + trg,
"p_{t}-#eta-#phi distribution of all accepted " + pid +
" for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
161 fHistos->CreateTHnSparse(
"hPtEtaPhiEMCALAll" + pid + trg,
"p_{t}-#eta-#phi distribution of all accepted " + pid +
" pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
162 fHistos->CreateTHnSparse(
"hPtEtaPhiEMCALCent" + pid + trg,
"p_{t}-#eta-#phi distribution of all accepted " + pid +
" pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
168 for(
auto hist : *(fHistos->GetListOfHistograms())){
176 fEventTriggers.clear();
177 AliDebugStream(1) << GetName() <<
": Using custom event selection" << std::endl;
178 if(!MCEvent())
return false;
180 fEventWeight = fWeightHandler ? fWeightHandler->GetEventWeight(
fPythiaHeader) : 1.;
187 fHistos->FillTH1(
"hPtHard",
fPtHard);
192 if((isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7)) fEventTriggers.push_back(
"MB");
193 if(!fExclusiveMinBias){
197 fEventTriggers.push_back(
"EMC7");
199 fEventTriggers.push_back(
"EJ1");
201 fEventTriggers.push_back(
"EJ2");
203 fEventTriggers.push_back(
"EG1");
205 fEventTriggers.push_back(
"EG2");
208 if(!fEventTriggers.size()){
209 AliDebugStream(1) << GetName() <<
": No trigger selected" << std::endl;
212 const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
213 if(vtx->GetNContributors() < 1)
return false;
217 fHistos->FillTH1(
"hVertexBeforeTrue", vtx->GetZ(), fEventWeight);
218 for(
const auto &trg : fEventTriggers) fHistos->FillTH1(
"hVertexBefore" + trg, vtx->GetZ(), fEventWeight);
220 if(vtx->GetZ() < -10. || vtx->GetZ() > 10.)
return false;
224 fHistos->FillTH1(
"hEventCountTrue", 1, fEventWeight);
225 fHistos->FillTH1(
"hVertexAfterTrue", vtx->GetZ(), fEventWeight);
226 for(
const auto &trg : fEventTriggers){
227 fHistos->FillTH1(
"hEventCount" + trg, 1, fEventWeight);
228 fHistos->FillTH1(
"hVertexAfter" + trg, vtx->GetZ(), fEventWeight);
238 AliErrorStream() << GetName() <<
": Failed initializing AliAnalysisTaskEmcal" << std::endl;
242 if(fTriggerSelection && !fTriggerSelection->GetNameClusterContainer().Length()){
247 if(fNameAcceptanceOADB.Length() && fTriggerSelection){
248 AliDebugStream(1) << GetName() <<
": Loading acceptance map from OADB file " << fNameAcceptanceOADB << std::endl;
249 AliOADBContainer acceptanceCont(
"AliEmcalTriggerAcceptance");
250 acceptanceCont.InitFromFile(fNameAcceptanceOADB.Data(),
"AliEmcalTriggerAcceptance");
251 TObjArray *acceptanceMaps =
dynamic_cast<TObjArray *
>(acceptanceCont.GetObject(fInputEvent->GetRunNumber()));
253 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EG1")))){
254 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EG1" << std::endl;
255 map->SetDirectory(
nullptr);
258 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EG2")))){
259 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EG2" << std::endl;
260 map->SetDirectory(
nullptr);
263 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DG1")))){
264 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DG1" << std::endl;
265 map->SetDirectory(
nullptr);
268 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DG2")))){
269 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DG2" << std::endl;
270 map->SetDirectory(
nullptr);
273 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EJ1")))){
274 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EJ1" << std::endl;
275 map->SetDirectory(
nullptr);
278 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EJ2")))){
279 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EJ2" << std::endl;
280 map->SetDirectory(
nullptr);
283 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DJ1")))){
284 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DJ1" << std::endl;
285 map->SetDirectory(
nullptr);
288 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DJ2")))){
289 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DJ2" << std::endl;
290 map->SetDirectory(
nullptr);
304 AliVParticle *truepart = NULL;
306 for(
int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
307 truepart = fMCEvent->GetTrack(ipart);
310 if(!fEtaLabCut.IsInRange(truepart->Eta()))
continue;
311 if(!fPhiCut.IsInRange(truepart->Phi()))
continue;
312 if(TMath::Abs(truepart->Pt()) < fMinPt)
continue;
313 if(!truepart->Charge())
continue;
315 if(!IsPhysicalPrimary(truepart, fMCEvent))
continue;
316 if(fStudyEMCALgeo) isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
321 Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
324 if(!fEtaCmsCut.IsInRange(etacent))
continue;
329 switch(TMath::Abs(truepart->PdgCode())){
330 case kPiPlus: pid =
"Pi";
break;
331 case kMuonMinus: pid =
"Mu";
break;
332 case kElectron: pid =
"El";
break;
333 case kKPlus: pid =
"Ka";
break;
334 case kProton: pid =
"Pr";
break;
335 default: pid =
"Ot";
break;
340 FillTrackHistos(
"True", fEventWeight, truepart->Charge() > 0, truepart->Pt(), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), isEMCAL,
true, pid);
350 AliVTrack *checktrack(NULL);
351 AliVParticle *assocMC(NULL);
352 double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
353 for(
int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
354 checktrack =
dynamic_cast<AliVTrack *
>(fInputEvent->GetTrack(itrk));
355 if(!checktrack)
continue;
357 assocMC = fMCEvent->GetTrack(TMath::Abs(checktrack->GetLabel()));
358 if(!assocMC)
continue;
365 if(fRequireTOFBunchCrossing){
366 if(!checktrack->IsOn(AliVTrack::kTOFout))
continue;
370 if(!fEtaLabCut.IsInRange(checktrack->Eta()))
continue;
371 if(!fPhiCut.IsInRange(checktrack->Phi()))
continue;
372 if(TMath::Abs(checktrack->Pt()) < fMinPt)
continue;
374 if(checktrack->IsA() == AliESDtrack::Class()){
375 AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
376 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
377 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
378 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
380 AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
381 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
382 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
383 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
385 Int_t supermoduleID = -1;
386 isEMCAL =
fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
388 isEMCAL = isEMCAL && supermoduleID < 10;
391 if(!fTrackCuts->IsTrackAccepted(checktrack))
continue;
393 ptparticle = TMath::Abs(assocMC->Pt());
394 etaparticle = assocMC->Eta();
399 Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
402 if(!fEtaCmsCut.IsInRange(etacent))
continue;
407 switch(TMath::Abs(assocMC->PdgCode())){
408 case kPiPlus: assocpid =
"Pi";
break;
409 case kMuonMinus: assocpid =
"Mu";
break;
410 case kElectron: assocpid =
"El";
break;
411 case kKPlus: assocpid =
"Ka";
break;
412 case kProton: assocpid =
"Pr";
break;
413 default: assocpid =
"Ot";
break;
416 for(
const auto &trg : fEventTriggers)
417 FillTrackHistos(trg, fEventWeight, checktrack->Charge() > 0, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL, IsPhysicalPrimary(assocMC, fMCEvent), assocpid);
422 void AliAnalysisTaskChargedParticlesRefMC::FillTrackHistos(
436 double kinepointall[5] = {TMath::Abs(pt), etalab, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.},
437 kinepointcent[5] = {TMath::Abs(pt), etacent, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.};
438 TString chargelabel = posCharge ?
"Pos" :
"Neg";
439 fHistos->FillTHnSparse(
"hPtEtaPhiAll" + eventclass, kinepointall, weight);
440 fHistos->FillTHnSparse(
"hPtEtaPhiCent" + eventclass, kinepointcent, weight);
443 fHistos->FillTHnSparse(
"hPtEtaPhiAll" + pid + eventclass, kinepointall, weight);
444 fHistos->FillTHnSparse(
"hPtEtaPhiCent" + pid + eventclass, kinepointcent, weight);
447 if(fStudyEMCALgeo && inEmcal){
448 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALAll" + eventclass, kinepointall, weight);
449 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALCent" + eventclass, kinepointall, weight);
452 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALAll" + pid + eventclass, kinepointall, weight);
453 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALCent" + pid + eventclass, kinepointall, weight);
465 TString AliAnalysisTaskChargedParticlesRefMC::GetFiredTriggerClasses(
const TClonesArray* triggerpatches) {
467 Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
468 double minADC_EJ1 = 260.,
472 for(
auto patchIter : *(triggerpatches)){
473 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(patchIter);
474 if(!patch->IsOfflineSimple())
continue;
475 if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
476 if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
477 if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
478 if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
480 if(nEJ1) triggerstring +=
"EJ1";
482 if(triggerstring.Length()) triggerstring +=
",";
483 triggerstring +=
"EJ2";
486 if(triggerstring.Length()) triggerstring +=
",";
487 triggerstring +=
"EG1";
490 if(triggerstring.Length()) triggerstring +=
",";
491 triggerstring +=
"EG2";
493 return triggerstring;
496 Bool_t AliAnalysisTaskChargedParticlesRefMC::IsPhysicalPrimary(
const AliVParticle*
const part, AliMCEvent*
const mcevent) {
498 const AliAODMCParticle *aodmc =
dynamic_cast<const AliAODMCParticle *
>(part);
500 physprim = aodmc->IsPhysicalPrimary();
502 physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
510 TString taskname =
"chargedParticleMCQA_" + name;
517 TString outfile(mgr->GetCommonFileName());
518 outfile +=
":ChargedParticleQA_" + name;
520 task->ConnectInput(0, mgr->GetCommonInputContainer());
521 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", name.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
547 mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
551 TString outfile(mgr->GetCommonFileName());
552 outfile +=
":ChargedParticleQA" + cutname;
554 task->ConnectInput(0, mgr->GetCommonInputContainer());
555 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
563 AliAnalysisTaskChargedParticlesRefMC::PtBinning::PtBinning() :
566 this->SetMinimum(0.);
567 this->AddStep(1, 0.05);
568 this->AddStep(2, 0.1);
569 this->AddStep(4, 0.2);
570 this->AddStep(7, 0.5);
571 this->AddStep(16, 1);
572 this->AddStep(36, 2);
573 this->AddStep(40, 4);
574 this->AddStep(50, 5);
575 this->AddStep(100, 10);
576 this->AddStep(200, 20);
EMCAL L1 Jet trigger, low threshold.
void SetJetPtFactor(Float_t f)
virtual Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
void SetTrackPtFactor(Float_t f)
Bool_t fIsPythia
trigger, if it is a PYTHIA production
void SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
Set offline trigger selection.
AliAnalysisTaskChargedParticlesRefMC()
Dummy constructor.
Class creating a linear binning, used in the histogram manager.
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
DCAL L1 Jet trigger, high threshold.
EMCAL L1 Gamma trigger, high threshold.
Interface for binnings used by the histogram handler.
void SetCaloTriggerPatchInfoName(const char *n)
EMCAL L1 Jet trigger, high threshold.
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Fully-configure EMCAL track selection independent of the data type.
Bool_t CheckMCOutliers()
Filter the mc tails in pt-hard distributions.
AliEMCALGeometry * fGeom
!emcal geometry
static AliAnalysisTaskChargedParticlesRefMC * AddTaskChargedParticlesRefMCDefault(const TString &cutname="standard")
AliGenPythiaEventHeader * fPythiaHeader
!event Pythia header
AliAnalysisUtils * fAliAnalysisUtils
!vertex selection (optional)
Helper class creating user defined custom binning.
DCAL L1 Gamma trigger, high threshold.
EMCAL L1 Gamma trigger, low threshold.
virtual ~AliAnalysisTaskChargedParticlesRefMC()
Destuctor.
Test class for charged particle distributions (MC case)
virtual Bool_t IsEventSelected()
Performing event selection.
Float_t fPtHard
!event -hard
AliEmcalList * fOutput
!output list
Analysis of high- tracks in triggered events.
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Container class for histograms.
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void UserCreateOutputObjects()
Main initialization function on the worker.
void SetEMCALTrackSelection(AliEmcalTrackSelection *sel)
Set the virtual track selection.
virtual void UserCreateOutputObjects()
Create the output histograms.
static AliAnalysisTaskChargedParticlesRefMC * AddTaskChargedParticlesRefMC(const TString &suffix)
void InitializeTrackCuts(TString cutname, bool isAOD)
static AliEmcalTriggerOfflineSelection * TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2, AliEmcalTriggerOfflineSelection::EmcalEnergyDefinition_t endef=AliEmcalTriggerOfflineSelection::kFEEEnergy)
Configures EMCAL trigger offline selection used to restrict EMCAL triggered sample.
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.