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"
42 #include "AliEMCALRecoUtils.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"
60 namespace EMCalTriggerPtAnalysis {
62 AliAnalysisTaskChargedParticlesRefMC::AliAnalysisTaskChargedParticlesRefMC():
72 fEtaLabCut(-0.5, 0.5),
74 fPhiCut(0., TMath::TwoPi()),
95 fEtaLabCut(-0.5, 0.5),
97 fPhiCut(0., TMath::TwoPi()),
101 fNameAcceptanceOADB()
110 if(fTriggerSelection)
delete fTriggerSelection;
111 if(fHistos)
delete fHistos;
120 if(!fTrackCuts)
InitializeTrackCuts(
"standard",fInputHandler->IsA() == AliAODInputHandler::Class());
122 PtBinning newbinning;
123 TString optionstring = fEnableSumw2 ?
"s" :
"";
125 fHistos->CreateTH1(
"hPtHard",
"Pt of the hard interaction", 1000, 0., 500);
126 const std::array<TString,7> triggers = {
"True",
"MB",
"EMC7",
"EJ1",
"EJ2",
"EG1",
"EG2"};
127 const std::array<TString,6> species = {
"El",
"Mu",
"Pi",
"Ka",
"Pr",
"Ot"};
128 const std::array<TString, 2> charges = {
"Pos",
"Neg"};
129 for(
const auto &trg : triggers){
130 fHistos->CreateTH1(
"hEventCount" + trg,
"Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
131 fHistos->CreateTH1(
"hVertexBefore" + trg,
"Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
132 fHistos->CreateTH1(
"hVertexAfter" + trg,
"Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
134 fHistos->CreateTH3(
"hPtEtaPhiAll" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
135 fHistos->CreateTH3(
"hPtEtaPhiEMCALAll" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
136 fHistos->CreateTH3(
"hPtEtaPhiCent" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
137 fHistos->CreateTH3(
"hPtEtaPhiEMCALCent" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
140 for(
const auto &
c : charges){
141 fHistos->CreateTH3(
"hPtEtaPhiAll" +
c + trg,
"p_{t}-#eta-#phi distribution of " +
c +
" accepted tracks for trigger " + trg +
" ; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
142 fHistos->CreateTH3(
"hPtEtaPhiEMCALAll" +
c + trg,
"p_{t}-#eta-#phi distribution of " +
c +
" accepted tracks pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
143 fHistos->CreateTH3(
"hPtEtaPhiCent" +
c + trg,
"p_{t}-#eta-#phi distribution of " +
c +
" accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
144 fHistos->CreateTH3(
"hPtEtaPhiEMCALCent" +
c + trg,
"p_{t}-#eta-#phi distribution of " +
c +
" accepted tracks pointing to the EMCAL for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
148 for(
const auto &pid : species){
149 fHistos->CreateTH3(
"hPtEtaPhiAll" + pid + trg,
"p_{t}-#eta-#phi distribution of all accepted " + pid +
" for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
150 fHistos->CreateTH3(
"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", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
151 fHistos->CreateTH3(
"hPtEtaPhiCent" + pid + trg,
"p_{t}-#eta-#phi distribution of all accepted " + pid +
" for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
152 fHistos->CreateTH3(
"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", newbinning,
TLinearBinning(64, -0.8, 0.8),
TLinearBinning(100, 0., 2*TMath::Pi()), optionstring);
157 for(
auto hist : *(fHistos->GetListOfHistograms())){
165 fEventTriggers.clear();
166 AliDebugStream(1) << GetName() <<
": Using custom event selection" << std::endl;
167 if(!MCEvent())
return false;
169 fEventWeight = fWeightHandler ? fWeightHandler->GetEventWeight(
fPythiaHeader) : 1.;
179 if((isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7)) fEventTriggers.push_back(
"MB");
183 fEventTriggers.push_back(
"EMC7");
185 fEventTriggers.push_back(
"EJ1");
187 fEventTriggers.push_back(
"EJ2");
189 fEventTriggers.push_back(
"EG1");
191 fEventTriggers.push_back(
"EG2");
193 if(!fEventTriggers.size()){
194 AliDebugStream(1) << GetName() <<
": No trigger selected" << std::endl;
197 const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
198 if(vtx->GetNContributors() < 1)
return false;
202 fHistos->FillTH1(
"hVertexBeforeTrue", vtx->GetZ(), fEventWeight);
203 for(
const auto &trg : fEventTriggers) fHistos->FillTH1(
"hVertexBefore" + trg, vtx->GetZ(), fEventWeight);
205 if(vtx->GetZ() < -10. || vtx->GetZ() > 10.)
return false;
209 fHistos->FillTH1(
"hEventCountTrue", 1, fEventWeight);
210 fHistos->FillTH1(
"hVertexAfterTrue", vtx->GetZ(), fEventWeight);
211 for(
const auto &trg : fEventTriggers){
212 fHistos->FillTH1(
"hEventCount" + trg, 1, fEventWeight);
213 fHistos->FillTH1(
"hVertexAfter" + trg, vtx->GetZ(), fEventWeight);
223 AliErrorStream() << GetName() <<
": Failed initializing AliAnalysisTaskEmcal" << std::endl;
227 if(!fTriggerSelection->GetNameClusterContainer().Length()){
232 if(fNameAcceptanceOADB.Length() && fTriggerSelection){
233 AliDebugStream(1) << GetName() <<
": Loading acceptance map from OADB file " << fNameAcceptanceOADB << std::endl;
234 AliOADBContainer acceptanceCont(
"AliEmcalTriggerAcceptance");
235 acceptanceCont.InitFromFile(fNameAcceptanceOADB.Data(),
"AliEmcalTriggerAcceptance");
236 TObjArray *acceptanceMaps =
dynamic_cast<TObjArray *
>(acceptanceCont.GetObject(fInputEvent->GetRunNumber()));
238 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EG1")))){
239 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EG1" << std::endl;
240 map->SetDirectory(
nullptr);
243 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EG2")))){
244 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EG2" << std::endl;
245 map->SetDirectory(
nullptr);
248 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DG1")))){
249 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DG1" << std::endl;
250 map->SetDirectory(
nullptr);
253 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DG2")))){
254 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DG2" << std::endl;
255 map->SetDirectory(
nullptr);
258 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EJ1")))){
259 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EJ1" << std::endl;
260 map->SetDirectory(
nullptr);
263 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EJ2")))){
264 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EJ2" << std::endl;
265 map->SetDirectory(
nullptr);
268 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DJ1")))){
269 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DJ1" << std::endl;
270 map->SetDirectory(
nullptr);
273 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DJ2")))){
274 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DJ2" << std::endl;
275 map->SetDirectory(
nullptr);
289 AliVParticle *truepart = NULL;
291 for(
int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
292 truepart = fMCEvent->GetTrack(ipart);
295 if(!fEtaLabCut.IsInRange(truepart->Eta()))
continue;
296 if(!fPhiCut.IsInRange(truepart->Phi()))
continue;
297 if(TMath::Abs(truepart->Pt()) < 0.1)
continue;
298 if(!truepart->Charge())
continue;
300 if(!IsPhysicalPrimary(truepart, fMCEvent))
continue;
301 isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
306 Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
309 if(!fEtaCmsCut.IsInRange(etacent))
continue;
314 switch(TMath::Abs(truepart->PdgCode())){
315 case kPiPlus: pid =
"Pi";
break;
316 case kMuonMinus: pid =
"Mu";
break;
317 case kElectron: pid =
"El";
break;
318 case kKPlus: pid =
"Ka";
break;
319 case kProton: pid =
"Pr";
break;
320 default: pid =
"Ot";
break;
325 FillTrackHistos(
"True", fEventWeight, truepart->Charge() > 0, truepart->Pt(), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), isEMCAL, pid);
335 AliVTrack *checktrack(NULL);
336 AliVParticle *assocMC(NULL);
337 double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
339 for(
int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
340 checktrack =
dynamic_cast<AliVTrack *
>(fInputEvent->GetTrack(itrk));
341 if(!checktrack)
continue;
343 assocMC = fMCEvent->GetTrack(TMath::Abs(checktrack->GetLabel()));
344 if(!assocMC)
continue;
345 if(!IsPhysicalPrimary(assocMC, fMCEvent))
continue;
348 if(!fEtaLabCut.IsInRange(checktrack->Eta()))
continue;
349 if(!fPhiCut.IsInRange(checktrack->Phi()))
continue;
350 if(TMath::Abs(checktrack->Pt()) < 0.1)
continue;
351 if(checktrack->IsA() == AliESDtrack::Class()){
352 AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
353 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
354 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
355 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
357 AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
358 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
359 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
360 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
362 Int_t supermoduleID = -1;
363 isEMCAL =
fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
365 isEMCAL = isEMCAL && supermoduleID < 10;
366 hasTRD = isEMCAL && supermoduleID >= 4;
368 if(!fTrackCuts->IsTrackAccepted(checktrack))
continue;
370 ptparticle = TMath::Abs(assocMC->Pt());
371 etaparticle = assocMC->Eta();
376 Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
379 if(!fEtaCmsCut.IsInRange(etacent))
continue;
384 switch(TMath::Abs(assocMC->PdgCode())){
385 case kPiPlus: assocpid =
"Pi";
break;
386 case kMuonMinus: assocpid =
"Mu";
break;
387 case kElectron: assocpid =
"El";
break;
388 case kKPlus: assocpid =
"Ka";
break;
389 case kProton: assocpid =
"Pr";
break;
390 default: assocpid =
"Ot";
break;
393 for(
const auto &trg : fEventTriggers)
394 FillTrackHistos(trg, fEventWeight, checktrack->Charge() > 0, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL, assocpid);
399 void AliAnalysisTaskChargedParticlesRefMC::FillTrackHistos(
412 double kinepointall[3] = {TMath::Abs(pt), etalab, phi}, kinepointcent[3] = {TMath::Abs(pt), etacent, phi};
413 TString chargelabel = posCharge ?
"" :
"";
414 fHistos->FillTH3(
"hPtEtaPhiAll" + eventclass, kinepointall, weight);
415 fHistos->FillTH3(
"hPtEtaPhiCent" + eventclass, kinepointcent, weight);
416 fHistos->FillTH3(
"hPtEtaPhiAll" + chargelabel + eventclass, kinepointall, weight);
417 fHistos->FillTH3(
"hPtEtaPhiCent" + chargelabel + eventclass, kinepointcent, weight);
420 fHistos->FillTH3(
"hPtEtaPhiAll" + pid + eventclass, kinepointall, weight);
421 fHistos->FillTH3(
"hPtEtaPhiCent" + pid + eventclass, kinepointcent, weight);
425 fHistos->FillTH3(
"hPtEtaPhiEMCALAll" + eventclass, kinepointall, weight);
426 fHistos->FillTH3(
"hPtEtaPhiEMCALCent" + eventclass, kinepointall, weight);
427 fHistos->FillTH3(
"hPtEtaPhiEMCALAll" + chargelabel + eventclass, kinepointall, weight);
428 fHistos->FillTH3(
"hPtEtaPhiEMCALCent" + chargelabel + eventclass, kinepointall, weight);
431 fHistos->FillTH3(
"hPtEtaPhiEMCALAll" + pid + eventclass, kinepointall, weight);
432 fHistos->FillTH3(
"hPtEtaPhiEMCALCent" + pid + eventclass, kinepointall, weight);
444 TString AliAnalysisTaskChargedParticlesRefMC::GetFiredTriggerClasses(
const TClonesArray* triggerpatches) {
446 Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
447 double minADC_EJ1 = 260.,
451 for(
auto patchIter : *(triggerpatches)){
452 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(patchIter);
453 if(!patch->IsOfflineSimple())
continue;
454 if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
455 if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
456 if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
457 if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
459 if(nEJ1) triggerstring +=
"EJ1";
461 if(triggerstring.Length()) triggerstring +=
",";
462 triggerstring +=
"EJ2";
465 if(triggerstring.Length()) triggerstring +=
",";
466 triggerstring +=
"EG1";
469 if(triggerstring.Length()) triggerstring +=
",";
470 triggerstring +=
"EG2";
472 return triggerstring;
475 Bool_t AliAnalysisTaskChargedParticlesRefMC::IsPhysicalPrimary(
const AliVParticle*
const part, AliMCEvent*
const mcevent) {
477 const AliAODMCParticle *aodmc =
dynamic_cast<const AliAODMCParticle *
>(part);
479 physprim = aodmc->IsPhysicalPrimary();
481 physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
489 TString taskname =
"chargedParticleMCQA_" + name;
496 TString outfile(mgr->GetCommonFileName());
497 outfile +=
":ChargedParticleQA_" + name;
499 task->ConnectInput(0, mgr->GetCommonInputContainer());
500 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", name.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
526 mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
530 TString outfile(mgr->GetCommonFileName());
531 outfile +=
":ChargedParticleQA" + cutname;
533 task->ConnectInput(0, mgr->GetCommonInputContainer());
534 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
542 AliAnalysisTaskChargedParticlesRefMC::PtBinning::PtBinning() :
545 this->SetMinimum(0.);
546 this->AddStep(1, 0.05);
547 this->AddStep(2, 0.1);
548 this->AddStep(4, 0.2);
549 this->AddStep(7, 0.5);
550 this->AddStep(16, 1);
551 this->AddStep(36, 2);
552 this->AddStep(40, 4);
553 this->AddStep(50, 5);
554 this->AddStep(100, 10);
555 this->AddStep(200, 20);
EMCAL L1 Jet trigger, low threshold.
void SetJetPtFactor(Float_t f)
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.
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.
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()
AliEmcalList * fOutput
!output list
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Container class for histograms.
void UserCreateOutputObjects()
virtual void UserCreateOutputObjects()
Create the output histograms.
static AliAnalysisTaskChargedParticlesRefMC * AddTaskChargedParticlesRefMC(const TString &suffix)
void InitializeTrackCuts(TString cutname, bool isAOD)
void SetTrackSelection(AliEmcalTrackSelection *sel)
Set the track selection.
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.