25 #include "AliAnalysisDataContainer.h"
26 #include "AliAnalysisManager.h"
27 #include "AliAnalysisUtils.h"
28 #include "AliAODInputHandler.h"
29 #include "AliAODTrack.h"
31 #include "AliEMCALGeometry.h"
32 #include "AliEMCALRecoUtils.h"
33 #include "AliEMCALTriggerPatchInfo.h"
35 #include "AliESDtrackCuts.h"
36 #include "AliESDEvent.h"
37 #include "AliInputEventHandler.h"
38 #include "AliPIDResponse.h"
39 #include "AliTOFPIDResponse.h"
40 #include "AliVEvent.h"
41 #include "AliVEventHandler.h"
42 #include "AliVVertex.h"
51 namespace EMCalTriggerPtAnalysis {
53 AliAnalysisTaskChargedParticlesRef::AliAnalysisTaskChargedParticlesRef() :
59 fEtaLabCut(-0.5, 0.5),
61 fPhiCut(0., TMath::TwoPi()),
63 fStudyEMCALgeo(false),
65 fRequireTOFBunchCrossing(false),
66 fStudyExoticTriggers(false)
76 fEtaLabCut(-0.5, 0.5),
78 fPhiCut(0., TMath::TwoPi()),
80 fStudyEMCALgeo(false),
82 fRequireTOFBunchCrossing(false),
83 fStudyExoticTriggers(false)
107 TLinearBinning etabinning(64, -0.8, 0.8), phibinning(100, 0., 2*TMath::Pi()), chargebinning(2, -1.5, 1.5);
108 const TBinning *binning4D[4] = {&newbinning, &etabinning, &phibinning, &chargebinning};
111 const int kdimPID = 3;
112 const int knbinsPID[kdimPID] = {1000, 200, 300};
113 const double kminPID[kdimPID] = {-100., 0., 0.}, kmaxPID[kdimPID] = {100., 200., 1.5};
115 fHistos->
CreateTH1(
"hEventCount" + trg,
"Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
117 if(!trg.Contains(
"MB"))
fHistos->
CreateTH1(
"hEventsExotricsTrigger" + trg, trg, 6, -0.5, 5.5, optionstring);
119 fHistos->
CreateTH1(
"hVertexBefore" + trg,
"Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
120 fHistos->
CreateTH1(
"hVertexAfter" + trg,
"Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
123 fHistos->
CreateTHnSparse(
"hPtEtaPhiAll" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
" ; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
124 fHistos->
CreateTHnSparse(
"hPtEtaPhiCent" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
126 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", 4, binning4D, optionstring);
127 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", 4, binning4D, optionstring);
130 fHistos->
CreateTHnSparse(
"hPtEtaPhiAllExotic" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
" ; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
131 fHistos->
CreateTHnSparse(
"hPtEtaPhiCentExotic" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
132 fHistos->
CreateTHnSparse(
"hPtEtaPhiAllNoExotic" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
" ; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
133 fHistos->
CreateTHnSparse(
"hPtEtaPhiCentNoExotic" + trg,
"p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg +
"; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
137 fHistos->
CreateTH2(Form(
"hTPCdEdxEMCAL%s", trg.Data()), Form(
"TPC dE/dx of charged particles in the EMCAL region for trigger %s", trg.Data()), 400, -20., 20., 200, 0., 200., optionstring);
138 fHistos->
CreateTH2(Form(
"hTOFBetaEMCAL%s", trg.Data()), Form(
"TOF beta of charged particles in the EMCAL region for trigger %s", trg.Data()), 400, -20., 20., 150, 0., 1.5, optionstring);
139 fHistos->
CreateTHnSparse(Form(
"hPIDcorrEMCAL%s", trg.Data()), Form(
"Correlation of PID observables for Trigger %s", trg.Data()), kdimPID, knbinsPID, kminPID, kmaxPID, optionstring);
145 Bool_t hasPIDresponse = fInputHandler->GetPIDResponse() !=
nullptr;
146 if(
fStudyPID && !hasPIDresponse) AliErrorStream() <<
"PID requested but PID response not available" << std::endl;
148 int bunchSpacingCorrection = int(bunchSpacing / 25.);
151 std::vector<TString> exoticTriggers;
154 if(t.Contains(
"MB"))
continue;
160 exoticTriggers.push_back(t);
179 AliVTrack *checktrack(
nullptr);
180 int ptmin[5] = {1,2,5,10,20};
182 Double_t etaEMCAL(0.), phiEMCAL(0.);
183 for(
int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
184 checktrack =
dynamic_cast<AliVTrack *
>(fInputEvent->GetTrack(itrk));
185 if(!checktrack)
continue;
188 if(TMath::Abs(checktrack->Pt()) <
fMinPt)
continue;
192 int tofCrossingRaw = checktrack->GetTOFBunchCrossing();
193 if(tofCrossingRaw == AliVTrack::kTOFBCNA)
continue;
194 int tofCrossingCorrected = TMath::Nint(tofCrossingRaw/bunchSpacingCorrection);
195 if(tofCrossingCorrected != fInputEvent->GetHeader()->GetBunchCrossNumber())
continue;
199 if(checktrack->IsA() == AliESDtrack::Class()){
200 AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
201 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
202 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
203 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
205 AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
206 AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(©track);
207 etaEMCAL = copytrack.GetTrackEtaOnEMCal();
208 phiEMCAL = copytrack.GetTrackPhiOnEMCal();
210 Int_t supermoduleID = -1;
211 isEMCAL =
fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
213 isEMCAL = isEMCAL && supermoduleID < 10;
226 bool posCharge = checktrack->Charge() > 0;
229 FillTrackHistos(t,
"", posCharge, checktrack->Pt(), checktrack->Eta() *
fEtaSign, etacent, checktrack->Phi(), isEMCAL);
231 if(std::find(exoticTriggers.begin(), exoticTriggers.end(), t) != exoticTriggers.end()){
233 FillTrackHistos(t,
"Exotic", posCharge, checktrack->Pt(), checktrack->Eta() *
fEtaSign, etacent, checktrack->Phi(), isEMCAL);
236 FillTrackHistos(t,
"NoExotic", posCharge, checktrack->Pt(), checktrack->Eta() *
fEtaSign, etacent, checktrack->Phi(), isEMCAL);
264 std::vector<const AliVCluster *> exoticClusters;
266 AliDebugStream(1) << GetName() <<
": Reading clusters from container" <<
fNameClusterContainer << std::endl;
268 if(
c->GetIsExotic()) exoticClusters.push_back(
c);
270 AliDebugStream(1) << GetName() <<
": Found " << exoticClusters.size() <<
" exotic clusters" << std::endl;
271 if(!exoticClusters.size()) {
273 AliDebugStream(1) << GetName() <<
": No exotic clusters in event - event declared as non-exotic" << std::endl;
278 std::function<bool (const AliEMCALTriggerPatchInfo *)> PatchSelector = [&trg, threshold] (
const AliEMCALTriggerPatchInfo *patch) ->
bool {
279 if(trg.Contains(
"G")) {
280 return patch->IsGammaLowRecalc() && patch->GetADCAmp() >= threshold;
281 }
else if (trg.Contains(
"J")) {
282 return patch->IsJetLowRecalc() && patch->GetADCAmp() >= threshold;
283 }
else if (trg.Contains(
"MC")) {
284 return patch->IsLevel0() && patch->GetADCAmp() >= threshold;
289 Bool_t hasNonExoticTriggerPatch = kFALSE;
291 AliEMCALTriggerPatchInfo *patch =
static_cast<AliEMCALTriggerPatchInfo *
>(p);
292 if(PatchSelector(patch)) {
293 bool hasMatch =
false;
294 for(
auto c : exoticClusters) {
295 TLorentzVector clustervec;
296 c->GetMomentum(clustervec,
fVertex);
297 AliCutValueRange<double> etacut(patch->GetEtaMin(), patch->GetEtaMax()), phicut(patch->GetPhiMin(), patch->GetPhiMax());
298 if(etacut.IsInRange(clustervec.Eta()) && phicut.IsInRange(clustervec.Phi())) {
301 AliDebugStream(1) << GetName() <<
", Trigger " << trg <<
": Found match of triggering patch to exotic cluster: Type "
302 << ((patch->IsJetHighRecalc() || patch->IsJetLowRecalc()) ?
"JetRecalc" : ((patch->IsGammaHighRecalc() || patch->IsGammaLowRecalc()) ?
"GammaRecalc" :
"L0"))
303 <<
", ADC" << patch->GetADCAmp() << std::endl;
309 AliDebugStream(1) << GetName() <<
": Found at least 1 non-exotic patch firing trigger " << trg << std::endl;
310 hasNonExoticTriggerPatch =
true;
315 return !hasNonExoticTriggerPatch;
330 AliDebugStream(1) << GetName() <<
": Using weight " << weight <<
" for trigger " << eventclass <<
" in particle histograms." << std::endl;
331 double kinepointall[4] = {TMath::Abs(pt), etalab, phi, posCharge ? 1. : -1.}, kinepointcent[4] = {TMath::Abs(pt), etacent, phi, posCharge ? 1. : -1.};
345 AliDebugStream(1) << GetName() <<
": Using weight " << weight <<
" for trigger " << eventclass <<
" in PID histograms." << std::endl;
346 AliPIDResponse *pid = fInputHandler->GetPIDResponse();
347 if(TMath::Abs(trk.Eta()) > 0.5)
return;
348 if(!((trk.GetStatus() & AliVTrack::kTOFout) && (trk.GetStatus() & AliVTrack::kTIME)))
return;
350 double poverz = TMath::Abs(trk.P())/static_cast<double>(trk.Charge());
351 fHistos->
FillTH2(
"hTPCdEdxEMCAL" + eventclass, poverz, trk.GetTPCsignal(), weight);
353 Double_t trtime = (trk.GetTOFsignal() - pid->GetTOFResponse().GetTimeZero()) * 1e-12;
354 Double_t v = trk.GetIntegratedLength()/(100. * trtime);
356 fHistos->
FillTH2(
"hTOFBetaEMCAL" + eventclass, poverz, beta, weight);
357 double datapoint[3] = {poverz, trk.GetTPCsignal(), beta};
373 TString outfile(mgr->GetCommonFileName());
374 outfile +=
":ChargedParticleQA_" +
suffix;
377 task->ConnectInput(0, mgr->GetCommonInputContainer());
378 mgr->ConnectOutput(task, 1, mgr->CreateContainer(containername.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
404 mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
408 TString outfile(mgr->GetCommonFileName());
409 outfile +=
":ChargedParticleQA_%s" + cutname;
411 task->ConnectInput(0, mgr->GetCommonInputContainer());
412 mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form(
"TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
virtual bool Run()
Simple task testing particle spectra in triggered events.
std::vector< TString > GetSupportedTriggers()
Double_t fEtaSign
Sign of the eta distribution (swaps when beam directions swap): p-Pb: +1, Pb-p: -1.
AliEmcalTrackSelection * fTrackCuts
Standard track selection.
Class creating a linear binning, used in the histogram manager.
THistManager * fHistos
Task Histogram container.
virtual ~AliAnalysisTaskChargedParticlesRef()
Destuctor.
Test class for charged particle distributions.
static AliAnalysisTaskChargedParticlesRef * AddTaskChargedParticlesRef(const TString &suffix)
Pre-configure task so that it can be used in subwagons.
Double_t GetTriggerWeight(const TString &triggerclass) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
virtual void SaveQAObjects(TList *outputList)
Bool_t fStudyPID
Use kinematics correlation histograms.
Double_t fMinPt
Minimum -used to select tracks.
void AddStep(Double_t max, Double_t binwidth)
virtual void UserFillHistosBeforeEventSelection()
Implementation of framework function UserFillHistosBeforeEventSelection.
Interface for binnings used by the histogram handler.
void SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
Set an offline trigger selection.
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
void SetCaloTriggerPatchInfoName(const char *n)
bool IsExoticsTrigger(const TString &trg)
Check if the trigger is fired by an exotic cluster.
AliCutValueRange< double > fEtaCmsCut
Cut applied in frame.
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Fully-configure EMCAL track selection independent of the data type.
Bool_t fStudyEMCALgeo
Add histograms for tracks pointing to the EMCAL acceptance.
Base class for analyses using EMCAL triggers.
Double_t fYshift
Rapidity shift.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
static AliAnalysisTaskChargedParticlesRef * AddTaskChargedParticlesRefDefault(const TString &cutname="standard")
Fully configure task, not intended for subwagons. Using a default cut configuration.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
TString fNameClusterContainer
Name of the cluster container in the event.
Bool_t fStudyExoticTriggers
Switch on whether to study exotic triggers or not.
AliEMCALGeometry * fGeom
!emcal geometry
virtual void CreateUserHistos()
Create the output histograms.
AliAnalysisTaskChargedParticlesRef()
Dummy constructor.
Definition of the -binning used in the histograms.
void SetEMCALTrackSelection(AliEmcalTrackSelection *sel)
Set the virtual track selection.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
Int_t GetOnlineTriggerThresholdByName(const TString &name) const
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
Helper class creating user defined custom binning.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
virtual void CreateUserObjects()
Creating user objects.
AliCutValueRange< double > fPhiCut
Cut applied in .
virtual PWG::EMCAL::AliEmcalTrackSelResultPtr IsTrackAccepted(AliVTrack *const trk)=0
Interface for track selection code.
AliEmcalList * fOutput
!output list
AliCutValueRange< double > fEtaLabCut
Cut applied in frame.
Double_t fVertex[3]
!event vertex
void FillPIDHistos(const TString &eventclass, const AliVTrack &track)
Fill PID-related histograms.
void FillTrackHistos(const TString &eventclass, const TString &histtag, Bool_t posCharge, Double_t pt, Double_t eta, Double_t etacent, Double_t phi, Bool_t inEmcal)
Fill track (kinematic) histograms.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
void InitializeTrackCuts(TString cutname, bool isAOD)
Set the track selection.
Int_t fRunNumber
!run number (triggering RunChanged()
Bool_t fRequireTOFBunchCrossing
Require that the bunch crossing ID determined by TOF matches the bunch crossing ID of the event...
virtual void UserFillHistosAfterEventSelection()
Implementation of framework function UserFillHistosAfterEventSelection.
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
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.
Bool_t fEnableSumw2
Enable sumw2 during histogram creation.
bool IsInRange(t value) const
void SetMinimum(Double_t min)