AliPhysics  9c66e61 (9c66e61)
AliAnalysisTaskEmcalJetV0CF.cxx
Go to the documentation of this file.
1 #include <THnSparse.h>
2 #include <TClonesArray.h>
3 #include <TParticle.h>
4 
5 #include "AliAODEvent.h"
6 #include "AliESDEvent.h"
7 #include "AliMCEvent.h"
8 #include "AliStack.h"
9 #include "AliMCParticle.h"
10 #include "AliAODMCParticle.h"
11 
12 #include "AliEmcalJet.h"
13 #include "AliJetContainer.h"
14 #include "AliParticleContainer.h"
15 #include "AliClusterContainer.h"
16 
17 #include "AliPicoV0MC.h"
19 
21 
22 //_____________________________________________________________________________
25 fKaCutNS(0.),
26 fLaCutNS(0.),
27 fV0CutMinEta(0.),
28 fV0CutMaxEta(0.),
29 fEventAOD(nullptr),
30 fEventESD(nullptr),
31 fCentInfo(nullptr),
32 fJetsContRD(nullptr),
33 fTracksContRD(nullptr),
34 fCaloClustersContRD(nullptr),
35 fJetsContMC(nullptr),
36 fTracksContMC(nullptr),
37 fV0s(nullptr),
38 fHistoKshortInvM(nullptr),
39 fHistoLambdaInvM(nullptr),
40 fHistoAntiLaInvM(nullptr),
41 fListUserOutputs(nullptr)
42 {
43 //
44 // AliAnalysisTaskEmcalJetV0CF::AliAnalysisTaskEmcalJetV0CF
45 //
46 }
47 
48 //_____________________________________________________________________________
50 AliAnalysisTaskEmcalJet(name,bHistos),
51 fKaCutNS(6.),
52 fLaCutNS(6.),
53 fV0CutMinEta(-10.),
54 fV0CutMaxEta(10.),
55 fEventAOD(nullptr),
56 fEventESD(nullptr),
57 fCentInfo(nullptr),
58 fJetsContRD(nullptr),
59 fTracksContRD(nullptr),
60 fCaloClustersContRD(nullptr),
61 fJetsContMC(nullptr),
62 fTracksContMC(nullptr),
63 fV0s(nullptr),
64 fHistoKshortInvM(nullptr),
65 fHistoLambdaInvM(nullptr),
66 fHistoAntiLaInvM(nullptr),
67 fListUserOutputs(nullptr)
68 {
69 //
70 // AliAnalysisTaskEmcalJetV0CF::AliAnalysisTaskEmcalJetV0CF
71 //
72 
74 
75  DefineOutput(bHistos ? 2 : 1, TList::Class());
76 }
77 
78 //_____________________________________________________________________________
80 {
81 //
82 // AliAnalysisTaskEmcalJetV0CF::~AliAnalysisTaskEmcalJetV0CF
83 //
84 
85  if (fEventAOD) { delete fEventAOD; fEventAOD = nullptr; }
86  if (fEventESD) { delete fEventESD; fEventESD = nullptr; }
87  if (fCentInfo) { delete fCentInfo; fCentInfo = nullptr; }
88 
89  if (fJetsContRD) { delete fJetsContRD; fJetsContRD = nullptr; }
90  if (fTracksContRD) { delete fTracksContRD; fTracksContRD = nullptr; }
92 
93  if (fJetsContMC) { delete fJetsContMC; fJetsContMC = nullptr; }
94  if (fTracksContMC) { delete fTracksContMC; fTracksContMC = nullptr; }
95 
96  if (fV0s) { delete fV0s; fV0s = nullptr; }
97 
98  if (fHistoKshortInvM) { delete fHistoKshortInvM; fHistoKshortInvM = nullptr; }
99  if (fHistoLambdaInvM) { delete fHistoLambdaInvM; fHistoLambdaInvM = nullptr; }
100  if (fHistoAntiLaInvM) { delete fHistoAntiLaInvM; fHistoAntiLaInvM = nullptr; }
101 
102  if (fListUserOutputs) { delete fListUserOutputs; fListUserOutputs = nullptr; }
103 }
104 
105 //_____________________________________________________________________________
107 {
108 //
109 // AliAnalysisTaskEmcalJetV0CF::Init
110 //
111 
112  return;
113 }
114 
115 //_____________________________________________________________________________
117 {
118 //
119 // AliAnalysisTaskEmcalJetV0CF::UserCreateOutputObjects
120 //
121 
123 //=============================================================================
124 
126  if (fJetsContRD) {
129  }
130 
133 //=============================================================================
134 
135  fListUserOutputs = new TList();
136  fListUserOutputs->SetOwner();
138  PostData(fCreateHisto ? 2 : 1, fListUserOutputs);
139  return;
140 }
141 
142 //_____________________________________________________________________________
144 {
145 //
146 // AliAnalysisTaskEmcalJetV0CF::Terminate
147 //
148 
149  AliAnalysisTaskEmcalJet::Terminate(opt);
150 
151  return;
152 }
153 
154 //_____________________________________________________________________________
156 {
157 //
158 // AliAnalysisTaskEmcalJetV0CF::Run
159 //
160 
161  if (!AliAnalysisTaskEmcalJet::Run()) return kFALSE;
162 
163  return kTRUE;
164 }
165 
166 //_____________________________________________________________________________
168 {
169 //
170 // AliAnalysisTaskEmcalJetV0CF::RetrieveEventObjects
171 //
172 
173  if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects()) return kFALSE;
174 
175  fCentInfo = InputEvent()->GetCentrality(); if (!fCentInfo) return kFALSE;
176 
177  fEventAOD = dynamic_cast<AliAODEvent*>(InputEvent());
178  fEventESD = dynamic_cast<AliESDEvent*>(InputEvent());
179  if ((!fEventAOD) && (!fEventESD)) return kFALSE;
180 
181  return kTRUE;
182 }
183 
184 //_____________________________________________________________________________
186 {
187 //
188 // AliAnalysisTaskEmcalJetV0CF::IsEventSelected
189 //
190 
191  if (!AliAnalysisTaskEmcalJet::IsEventSelected()) return kFALSE;
192 
193  return kTRUE;
194 }
195 
196 //_____________________________________________________________________________
198 {
199 //
200 // AliAnalysisTaskEmcalJetV0CF::FillHistograms
201 //
202 
203  if (!AliAnalysisTaskEmcalJet::FillHistograms()) return kFALSE;
204 
205  if (FillRecoInfo()) return kFALSE;
206  if (FillKineInfo()) return kFALSE;
207 
208  return kTRUE;
209 }
210 
211 //_____________________________________________________________________________
213 {
214 //
215 // AliAnalysisTaskEmcalJetV0CF::FillGeneralHistograms
216 //
217 
219 
220  return kTRUE;
221 }
222 
223 //_____________________________________________________________________________
225 {
226 //
227 // AliAnalysisTaskEmcalJetV0CF::ExecOnce
228 //
229 
231 
232  if (!fInitialized) return;
233 
234  if (!fV0s) {
235  fV0s = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("PicoV0s"));
236 
237  if (!fV0s) {
238  AliError(Form("%s: Could not retrieve V0 %s!", GetName(), "PicoV0s"));
239  fInitialized = kFALSE;
240  return;
241  }
242  }
243 
244  return;
245 }
246 
247 //_____________________________________________________________________________
249 {
250 //
251 // AliAnalysisTaskEmcalJetV0CF::CreateUserOutputHistograms
252 //
253 
254  if (!fListUserOutputs) return;
255 
256  const auto b(TH1::AddDirectoryStatus());
257  TH1::AddDirectory(kFALSE);
258 
259  const Int_t nV0(8); // 0: particle type
260  // ==0, Kshort
261  // ==1, Lambda
262  // ==2, AntiLa
263  // 1: Jet pT bin
264  // == 0.5, jet pT>10.
265  // == 1.5, jet pT>15.
266  // == 2.5, jet pT>20.
267  // == 3.5, jet pT>25.
268  // 2: V0M
269  // 3: V0A
270  // 4: CL1
271  // 5: ZNA
272  // 6: eta
273  // 7: Pt
274  const Int_t nV0Bin[nV0] = { 3, 4, 210, 210, 210, 210, 100, 1000 };
275  const Double_t dV0Min[nV0] = { -0.5, 0., -10., -10., -10., -10., -5., 0. };
276  const Double_t dV0Max[nV0] = { 2.5, 4., 200., 200., 200., 200., 5., 100. };
277  fListUserOutputs->Add(new THnSparseD("hsReco", "", nV0, nV0Bin, dV0Min, dV0Max));
278  fListUserOutputs->Add(new THnSparseD("hsKine", "", nV0, nV0Bin, dV0Min, dV0Max));
279 
280  TH1::AddDirectory(b);
281  return;
282 }
283 
284 //_____________________________________________________________________________
286 {
287 //
288 // AliAnalysisTaskEmcalJetV0CF::FillRecoInfo
289 //
290 
291  if (!fV0s) return kTRUE;
292 //=============================================================================
293 
294  const auto dV0M(fCentInfo->GetCentralityPercentile("V0M"));
295  const auto dV0A(fCentInfo->GetCentralityPercentile("V0A"));
296  const auto dCL1(fCentInfo->GetCentralityPercentile("CL1"));
297  const auto dZNA(fCentInfo->GetCentralityPercentile("ZNA"));
298 
299  auto hs(static_cast<THnSparseD*>(fListUserOutputs->FindObject("hsReco")));
300 //=============================================================================
301 
302  for (auto i=0; i<fV0s->GetEntriesFast(); ++i) {
303  const auto pV0(static_cast<AliPicoV0MC*>(fV0s->At(i))); if (!pV0) continue;
304 
305  if (!pV0->IsV0PhysicalPrimary()) continue;
306  if (!pV0->IsV0InEtaAcc(fV0CutMinEta,fV0CutMaxEta)) continue;
307 
308  const auto bKshort(pV0->IsKshortMC());
309  const auto bLambda(pV0->IsLambdaMC());
310  const auto bAntiLa(pV0->IsAntiLaMC());
311  if (!(bKshort || bLambda || bAntiLa)) continue;
312 //=============================================================================
313 
314  const auto vV0(pV0->KineMC().Vect());
315  const auto dPt(vV0.Pt());
316 
317  auto histo(fHistoKshortInvM);
318  if (bLambda) histo = fHistoLambdaInvM;
319  if (bAntiLa) histo = fHistoAntiLaInvM;
320 
321  const auto k(histo->FindBin(dPt)); if (k<=0) continue;
322  const auto dMean(histo->GetBinContent(k));
323  const auto dSigma(histo->GetBinError(k));
324 
325  const auto dCutNS(bKshort ? fKaCutNS : fLaCutNS);
326  const auto dUpperL(dMean - (dCutNS * dSigma));
327  const auto dLowerR(dMean + (dCutNS * dSigma));
328 
329  auto dInvM(pV0->KineKshort().M());
330  if (bLambda) dInvM = pV0->KineLambda().M();
331  if (bAntiLa) dInvM = pV0->KineAntiLa().M();
332  if ((dInvM<dUpperL) || (dInvM>=dLowerR)) continue;
333 //=============================================================================
334 
335  Double_t dVar[8];
336  if (bKshort) dVar[0] = 0.;
337  if (bLambda) dVar[0] = 1.;
338  if (bAntiLa) dVar[0] = 2.;
339 
340  dVar[1] = -1.;
341  if (IsV0InJet(vV0,10.)) dVar[1] = 0.5;
342  if (IsV0InJet(vV0,15.)) dVar[1] = 1.5;
343  if (IsV0InJet(vV0,20.)) dVar[1] = 2.5;
344  if (IsV0InJet(vV0,25.)) dVar[1] = 3.5;
345  if (dVar[1]<0.) continue;
346 
347  dVar[2] = dV0M;
348  dVar[3] = dV0A;
349  dVar[4] = dCL1;
350  dVar[5] = dZNA;
351 
352  dVar[6] = vV0.Eta();
353  dVar[7] = dPt;
354 
355  hs->Fill(dVar);
356  }
357 //=============================================================================
358 
359  return kFALSE;
360 }
361 
362 //_____________________________________________________________________________
364 {
365 //
366 // AliAnalysisTaskEmcalJetV0CF::FillKineInfo
367 //
368 
369  const auto dV0M(fCentInfo->GetCentralityPercentile("V0M"));
370  const auto dV0A(fCentInfo->GetCentralityPercentile("V0A"));
371  const auto dCL1(fCentInfo->GetCentralityPercentile("CL1"));
372  const auto dZNA(fCentInfo->GetCentralityPercentile("ZNA"));
373 
374  auto hs(dynamic_cast<THnSparseD*>(fListUserOutputs->FindObject("hsKine")));
375 //=============================================================================
376 
377  AliStack *pStack(nullptr);
378 
379  if (fEventESD) {
380  pStack = MCEvent()->Stack();
381  if (!pStack) return kTRUE;
382  }
383 //=============================================================================
384 
385  for (Int_t i=0; i<MCEvent()->GetNumberOfTracks(); ++i) {
386  TParticle *pESD(nullptr);
387  AliMCParticle *pTmp(nullptr);
388  AliAODMCParticle *pAOD(nullptr);
389 
390  if (fEventAOD) {
391  pAOD = static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(i));
392  if (!pAOD) continue;
393  }
394 
395  if (fEventESD) {
396  pTmp = static_cast<AliMCParticle*>(MCEvent()->GetTrack(i));
397  if (!pTmp) continue;
398 
399  pESD = pTmp->Particle();
400  if (!pESD) continue;
401  }
402 //=============================================================================
403 
404  const auto bPhy(pAOD ? pAOD->IsPhysicalPrimary() : pStack->IsPhysicalPrimary(i));
405  if (bPhy) continue;
406 
407  const auto dEta(pAOD ? pAOD->Eta() : pESD->Eta());
408  if ((dEta<fV0CutMinEta) || (dEta>=fV0CutMaxEta)) continue;
409 //=============================================================================
410 
411  Double_t dVar[8];
412  const auto id(pAOD ? pAOD->GetPdgCode() : pESD->GetPdgCode());
413 
414  dVar[0] = -1.;
415  if (id== 310 ) dVar[0] = 0.;
416  if (id== 3122) dVar[0] = 1.;
417  if (id==-3122) dVar[0] = 2.;
418  if (dVar[0]<-0.5) continue;
419 //=============================================================================
420 
421  TVector3 vV0;
422  if (pAOD) vV0.SetXYZ(pAOD->Px(), pAOD->Py(), pAOD->Pz());
423  if (pESD) vV0.SetXYZ(pESD->Px(), pESD->Py(), pESD->Pz());
424 
425  dVar[1] = -1.;
426  if (IsV0InJet(vV0,10.)) dVar[1] = 0.5;
427  if (IsV0InJet(vV0,15.)) dVar[1] = 1.5;
428  if (IsV0InJet(vV0,20.)) dVar[1] = 2.5;
429  if (IsV0InJet(vV0,25.)) dVar[1] = 3.5;
430  if (dVar[1]<0.) continue;
431 //=============================================================================
432 
433  dVar[2] = dV0M;
434  dVar[3] = dV0A;
435  dVar[4] = dCL1;
436  dVar[5] = dZNA;
437  dVar[6] = dEta;
438  if (pAOD) dVar[7] = pAOD->Pt();
439  if (pESD) dVar[7] = pESD->Pt();
440  hs->Fill(dVar);
441  }
442 //=============================================================================
443 
444  return kFALSE;
445 }
446 
447 //_____________________________________________________________________________
449 {
450 //
451 // AliAnalysisTaskEmcalJetV0CF::IsV0InJet
452 //
453 
454  if (!fJetsContRD) return kFALSE;
455 //=============================================================================
456 
457  TVector3 vJet;
458  const auto dJetRadius(fJetsContRD->GetJetRadius());
459 
460  fJetsContRD->ResetCurrentID();
461  auto pJet(fJetsContRD->GetNextAcceptJet()); while (pJet) {
462  const auto dPt(fJetsContRD->GetJetPtCorr(fJetsContRD->GetCurrentID()));
463  if (dPt<dJetPtMin) { pJet = fJetsContRD->GetNextAcceptJet(); continue; }
464 
465  vJet.SetPtEtaPhi(dPt, pJet->Eta(), pJet->Phi());
466  if (vJet.DeltaR(vV0)<dJetRadius) return kTRUE;
467  pJet = fJetsContRD->GetNextAcceptJet();
468  }
469 //=============================================================================
470 
471  return kFALSE;
472 }
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.
double Double_t
Definition: External.C:58
Bool_t IsV0InJet(TVector3 vV0, Double_t dJetPtMin)
AliJetContainer * GetJetContainer(Int_t i=0) const
AliClusterContainer * GetClusterContainer() const
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.
Bool_t fGeneralHistograms
whether or not it should fill some general histograms
virtual Bool_t RetrieveEventObjects()
Retrieve common objects from event.
AliParticleContainer * GetParticleContainer() const
virtual Bool_t FillHistograms()
Function filling histograms.
virtual Bool_t FillHistograms()
Function filling histograms.
int Int_t
Definition: External.C:63
virtual Bool_t FillGeneralHistograms()
Filling general histograms.
AliEmcalJet * GetNextAcceptJet()
virtual Bool_t IsEventSelected()
Performing event selection.
Float_t GetJetRadius() const
virtual Bool_t IsEventSelected()
Performing event selection.
Bool_t fCreateHisto
whether or not create histograms
Base task in the EMCAL jet framework.
const char Option_t
Definition: External.C:48
void UserCreateOutputObjects()
Main initialization function on the worker.
virtual Bool_t FillGeneralHistograms()
Filling general histograms.
bool Bool_t
Definition: External.C:53
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
virtual void Terminate(Option_t *opt)
Double_t GetJetPtCorr(Int_t i) const