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():
73 fEtaLabCut(-0.5, 0.5),
75 fPhiCut(0., TMath::TwoPi()),
79 fStudyEMCALgeo(false),
80 fRequireTOFBunchCrossing(false),
99 fEtaLabCut(-0.5, 0.5),
101 fPhiCut(0., TMath::TwoPi()),
103 fEnableSumw2(kFALSE),
105 fStudyEMCALgeo(false),
106 fRequireTOFBunchCrossing(false),
107 fNameAcceptanceOADB()
116 if(fTriggerSelection)
delete fTriggerSelection;
117 if(fHistos)
delete fHistos;
126 if(!fTrackCuts)
InitializeTrackCuts(
"standard",fInputHandler->IsA() == AliAODInputHandler::Class());
127 fTrackCuts->SaveQAObjects(
fOutput);
129 PtBinning newbinning;
130 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);
131 const TBinning *binning5D[5] = {&newbinning, &etabinning, &phibinning, &chargebinning, &primarybinning};
133 TString optionstring = fEnableSumw2 ?
"s" :
"";
135 fHistos->CreateTH1(
"hPtHard",
"Pt of the hard interaction", 1000, 0., 500);
136 const std::array<TString,7> triggers = {
"True",
"MB",
"EMC7",
"EJ1",
"EJ2",
"EG1",
"EG2"};
137 const std::array<TString,6> species = {
"El",
"Mu",
"Pi",
"Ka",
"Pr",
"Ot"};
138 for(
const auto &trg : triggers){
139 fHistos->CreateTH1(
"hEventCount" + trg,
"Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
140 fHistos->CreateTH1(
"hVertexBefore" + trg,
"Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
141 fHistos->CreateTH1(
"hVertexAfter" + trg,
"Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
143 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);
144 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);
146 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);
147 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);
151 for(
const auto &pid : species){
152 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);
153 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);
155 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);
156 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);
162 for(
auto hist : *(fHistos->GetListOfHistograms())){
170 fEventTriggers.clear();
171 AliDebugStream(1) << GetName() <<
": Using custom event selection" << std::endl;
172 if(!MCEvent())
return false;
174 fEventWeight = fWeightHandler ? fWeightHandler->GetEventWeight(
fPythiaHeader) : 1.;
181 fHistos->FillTH1(
"hPtHard",
fPtHard);
186 if((isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7)) fEventTriggers.push_back(
"MB");
190 fEventTriggers.push_back(
"EMC7");
192 fEventTriggers.push_back(
"EJ1");
194 fEventTriggers.push_back(
"EJ2");
196 fEventTriggers.push_back(
"EG1");
198 fEventTriggers.push_back(
"EG2");
200 if(!fEventTriggers.size()){
201 AliDebugStream(1) << GetName() <<
": No trigger selected" << std::endl;
204 const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
205 if(vtx->GetNContributors() < 1)
return false;
209 fHistos->FillTH1(
"hVertexBeforeTrue", vtx->GetZ(), fEventWeight);
210 for(
const auto &trg : fEventTriggers) fHistos->FillTH1(
"hVertexBefore" + trg, vtx->GetZ(), fEventWeight);
212 if(vtx->GetZ() < -10. || vtx->GetZ() > 10.)
return false;
216 fHistos->FillTH1(
"hEventCountTrue", 1, fEventWeight);
217 fHistos->FillTH1(
"hVertexAfterTrue", vtx->GetZ(), fEventWeight);
218 for(
const auto &trg : fEventTriggers){
219 fHistos->FillTH1(
"hEventCount" + trg, 1, fEventWeight);
220 fHistos->FillTH1(
"hVertexAfter" + trg, vtx->GetZ(), fEventWeight);
230 AliErrorStream() << GetName() <<
": Failed initializing AliAnalysisTaskEmcal" << std::endl;
234 if(!fTriggerSelection->GetNameClusterContainer().Length()){
239 if(fNameAcceptanceOADB.Length() && fTriggerSelection){
240 AliDebugStream(1) << GetName() <<
": Loading acceptance map from OADB file " << fNameAcceptanceOADB << std::endl;
241 AliOADBContainer acceptanceCont(
"AliEmcalTriggerAcceptance");
242 acceptanceCont.InitFromFile(fNameAcceptanceOADB.Data(),
"AliEmcalTriggerAcceptance");
243 TObjArray *acceptanceMaps =
dynamic_cast<TObjArray *
>(acceptanceCont.GetObject(fInputEvent->GetRunNumber()));
245 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EG1")))){
246 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EG1" << std::endl;
247 map->SetDirectory(
nullptr);
250 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EG2")))){
251 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EG2" << std::endl;
252 map->SetDirectory(
nullptr);
255 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DG1")))){
256 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DG1" << std::endl;
257 map->SetDirectory(
nullptr);
260 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DG2")))){
261 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DG2" << std::endl;
262 map->SetDirectory(
nullptr);
265 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EJ1")))){
266 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EJ1" << std::endl;
267 map->SetDirectory(
nullptr);
270 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"EJ2")))){
271 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger EJ2" << std::endl;
272 map->SetDirectory(
nullptr);
275 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DJ1")))){
276 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DJ1" << std::endl;
277 map->SetDirectory(
nullptr);
280 if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject(
"DJ2")))){
281 AliDebugStream(1) << GetName() <<
": Found acceptance map for trigger DJ2" << std::endl;
282 map->SetDirectory(
nullptr);
296 AliVParticle *truepart = NULL;
298 for(
int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
299 truepart = fMCEvent->GetTrack(ipart);
302 if(!fEtaLabCut.IsInRange(truepart->Eta()))
continue;
303 if(!fPhiCut.IsInRange(truepart->Phi()))
continue;
304 if(TMath::Abs(truepart->Pt()) < fMinPt)
continue;
305 if(!truepart->Charge())
continue;
307 if(!IsPhysicalPrimary(truepart, fMCEvent))
continue;
308 if(fStudyEMCALgeo) isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
313 Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
316 if(!fEtaCmsCut.IsInRange(etacent))
continue;
321 switch(TMath::Abs(truepart->PdgCode())){
322 case kPiPlus: pid =
"Pi";
break;
323 case kMuonMinus: pid =
"Mu";
break;
324 case kElectron: pid =
"El";
break;
325 case kKPlus: pid =
"Ka";
break;
326 case kProton: pid =
"Pr";
break;
327 default: pid =
"Ot";
break;
332 FillTrackHistos(
"True", fEventWeight, truepart->Charge() > 0, truepart->Pt(), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), isEMCAL,
true, pid);
342 AliVTrack *checktrack(NULL);
343 AliVParticle *assocMC(NULL);
344 double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
345 for(
int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
346 checktrack =
dynamic_cast<AliVTrack *
>(fInputEvent->GetTrack(itrk));
347 if(!checktrack)
continue;
349 assocMC = fMCEvent->GetTrack(TMath::Abs(checktrack->GetLabel()));
350 if(!assocMC)
continue;
357 if(fRequireTOFBunchCrossing){
358 if(!checktrack->IsOn(AliVTrack::kTOFout))
continue;
362 if(!fEtaLabCut.IsInRange(checktrack->Eta()))
continue;
363 if(!fPhiCut.IsInRange(checktrack->Phi()))
continue;
364 if(TMath::Abs(checktrack->Pt()) < fMinPt)
continue;
366 if(checktrack->IsA() == AliESDtrack::Class()){
367 AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
368 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
369 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
370 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
372 AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
373 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
374 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
375 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
377 Int_t supermoduleID = -1;
378 isEMCAL =
fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
380 isEMCAL = isEMCAL && supermoduleID < 10;
383 if(!fTrackCuts->IsTrackAccepted(checktrack))
continue;
385 ptparticle = TMath::Abs(assocMC->Pt());
386 etaparticle = assocMC->Eta();
391 Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
394 if(!fEtaCmsCut.IsInRange(etacent))
continue;
399 switch(TMath::Abs(assocMC->PdgCode())){
400 case kPiPlus: assocpid =
"Pi";
break;
401 case kMuonMinus: assocpid =
"Mu";
break;
402 case kElectron: assocpid =
"El";
break;
403 case kKPlus: assocpid =
"Ka";
break;
404 case kProton: assocpid =
"Pr";
break;
405 default: assocpid =
"Ot";
break;
408 for(
const auto &trg : fEventTriggers)
409 FillTrackHistos(trg, fEventWeight, checktrack->Charge() > 0, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL, IsPhysicalPrimary(assocMC, fMCEvent), assocpid);
414 void AliAnalysisTaskChargedParticlesRefMC::FillTrackHistos(
428 double kinepointall[5] = {TMath::Abs(pt), etalab, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.},
429 kinepointcent[5] = {TMath::Abs(pt), etacent, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.};
430 TString chargelabel = posCharge ?
"Pos" :
"Neg";
431 fHistos->FillTHnSparse(
"hPtEtaPhiAll" + eventclass, kinepointall, weight);
432 fHistos->FillTHnSparse(
"hPtEtaPhiCent" + eventclass, kinepointcent, weight);
435 fHistos->FillTHnSparse(
"hPtEtaPhiAll" + pid + eventclass, kinepointall, weight);
436 fHistos->FillTHnSparse(
"hPtEtaPhiCent" + pid + eventclass, kinepointcent, weight);
439 if(fStudyEMCALgeo && inEmcal){
440 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALAll" + eventclass, kinepointall, weight);
441 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALCent" + eventclass, kinepointall, weight);
444 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALAll" + pid + eventclass, kinepointall, weight);
445 fHistos->FillTHnSparse(
"hPtEtaPhiEMCALCent" + pid + eventclass, kinepointall, weight);
457 TString AliAnalysisTaskChargedParticlesRefMC::GetFiredTriggerClasses(
const TClonesArray* triggerpatches) {
459 Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
460 double minADC_EJ1 = 260.,
464 for(
auto patchIter : *(triggerpatches)){
465 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(patchIter);
466 if(!patch->IsOfflineSimple())
continue;
467 if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
468 if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
469 if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
470 if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
472 if(nEJ1) triggerstring +=
"EJ1";
474 if(triggerstring.Length()) triggerstring +=
",";
475 triggerstring +=
"EJ2";
478 if(triggerstring.Length()) triggerstring +=
",";
479 triggerstring +=
"EG1";
482 if(triggerstring.Length()) triggerstring +=
",";
483 triggerstring +=
"EG2";
485 return triggerstring;
488 Bool_t AliAnalysisTaskChargedParticlesRefMC::IsPhysicalPrimary(
const AliVParticle*
const part, AliMCEvent*
const mcevent) {
490 const AliAODMCParticle *aodmc =
dynamic_cast<const AliAODMCParticle *
>(part);
492 physprim = aodmc->IsPhysicalPrimary();
494 physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
502 TString taskname =
"chargedParticleMCQA_" + name;
509 TString outfile(mgr->GetCommonFileName());
510 outfile +=
":ChargedParticleQA_" + name;
512 task->ConnectInput(0, mgr->GetCommonInputContainer());
513 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", name.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
539 mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
543 TString outfile(mgr->GetCommonFileName());
544 outfile +=
":ChargedParticleQA" + cutname;
546 task->ConnectInput(0, mgr->GetCommonInputContainer());
547 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
555 AliAnalysisTaskChargedParticlesRefMC::PtBinning::PtBinning() :
558 this->SetMinimum(0.);
559 this->AddStep(1, 0.05);
560 this->AddStep(2, 0.1);
561 this->AddStep(4, 0.2);
562 this->AddStep(7, 0.5);
563 this->AddStep(16, 1);
564 this->AddStep(36, 2);
565 this->AddStep(40, 4);
566 this->AddStep(50, 5);
567 this->AddStep(100, 10);
568 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
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.