AliPhysics  7f1bdba (7f1bdba)
AliAnalysisTaskSEPicoV0Maker.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
17 //
18 // AliAnalysisTaskSE for RecoDecay object (K0 short, Lambda,
19 // D mesons ...) filtering
20 //
21 // Author: X-M. Zhang, xmzhang@lbl.gov
23 
24 #include <TH2D.h>
25 #include <TMath.h>
26 #include <THnSparse.h>
27 #include <TClonesArray.h>
28 #include <TParticle.h>
29 
30 #include "AliStack.h"
31 #include "AliESDEvent.h"
32 #include "AliAODEvent.h"
33 #include "AliMCEvent.h"
34 
35 #include "AliHeader.h"
36 #include "AliInputEventHandler.h"
37 #include "AliGenDPMjetEventHeader.h"
38 
39 #include "AliAODv0.h"
40 #include "AliESDv0.h"
41 #include "AliV0vertexer.h"
42 
43 #include "AliESDtrack.h"
44 #include "AliAODTrack.h"
45 #include "AliMCParticle.h"
46 #include "AliAODMCParticle.h"
47 
48 #include "AliPIDResponse.h"
49 #include "AliAnalysisUtils.h"
50 
51 #include "AliCentrality.h"
52 #include "AliMultSelection.h"
53 
54 #include "AliPicoBase.h"
55 #include "AliPicoV0RD.h"
56 #include "AliPicoV0MC.h"
58 
60 //=============================================================================
61 
62 //_____________________________________________________________________________
65 fTriggerMask(0),
66 fCollisionType(0),
67 fIsAnaUseMC(kFALSE),
68 fIsDPMjetMC(kFALSE),
69 fUseMultOld(kFALSE),
70 fUseAnaUtils(kFALSE),
71 fIsSkipFastOnly(kFALSE),
72 fIsRefitV0sESD(kFALSE),
73 fRapidityShift(0.),
74 fMultEstDef(""),
75 fCutMinMult(0.),
76 fCutMaxMult(0.),
77 fCutMinV0Pt(0.),
78 fCutMaxV0Pt(0.),
79 fCutMinV0Rap(0.),
80 fCutMaxV0Rap(0.),
81 fCutMinDauPt(0.),
82 fCutMinDauEta(0.),
83 fCutMaxDauEta(0.),
84 fCutMaxV0Chi2(0.),
85 fCutMinV0Radius(0.),
86 fCutMaxV0Radius(0.),
87 fCutMaxDausDCA(0.),
88 fCutMinDauDCAtoPV(0.),
89 fCutMinDauXrowsTPC(0.),
90 fCutMinDauXrowsOverFindableClusTPC(0.),
91 fCutMaxKshortSigmaTPC(0.),
92 fCutMinKshortCosPA(0.),
93 fCutMaxKshortCtau(0.),
94 fCutMaxKshortArmFrac(0.),
95 fCutMinKshortDeltaM(0.),
96 fCutMaxLambdaSigmaTPC(0.),
97 fCutMinLambdaCosPA(0.),
98 fCutMaxLambdaCtau(0.),
99 fCutMaxLambdaArmFrac(0.),
100 fCutMinLambdaDeletaM(0.),
101 fEventAOD(nullptr),
102 fEventESD(nullptr),
103 fRespoPID(nullptr),
104 fEventAcptMask(0),
105 fMultEsti(),
106 fPicoV0sClArr(nullptr),
107 fOutputListEH(nullptr),
108 fOutputListMC(nullptr)
109 {
110 //
111 // Default constructor
112 //
113 
114  for (auto &d : fPrimaryVtx) d = -999.;
115 }
116 
117 //_____________________________________________________________________________
119 AliAnalysisTaskSE(name),
120 fTriggerMask(AliVEvent::kAny),
121 fCollisionType(AliPicoBase::kPP),
122 fIsAnaUseMC(bIsMC),
123 fIsDPMjetMC(kFALSE),
124 fUseMultOld(kFALSE),
125 fUseAnaUtils(kFALSE),
126 fIsSkipFastOnly(kTRUE),
127 fIsRefitV0sESD(kFALSE),
128 fRapidityShift(0.),
129 fMultEstDef(""),
130 fCutMinMult(-99999.),
131 fCutMaxMult(999999.),
132 fCutMinV0Pt(0.),
133 fCutMaxV0Pt(100.),
134 fCutMinV0Rap(-10.),
135 fCutMaxV0Rap(10.),
136 fCutMinDauPt(0.),
137 fCutMinDauEta(-10.),
138 fCutMaxDauEta(10.),
139 fCutMaxV0Chi2(33.),
140 fCutMinV0Radius(0.3),
141 fCutMaxV0Radius(200.),
142 fCutMaxDausDCA(1.5),
143 fCutMinDauDCAtoPV(0.05),
144 fCutMinDauXrowsTPC(70.),
145 fCutMinDauXrowsOverFindableClusTPC(0.8),
146 fCutMaxKshortSigmaTPC(-1.),
147 fCutMinKshortCosPA(0.95),
148 fCutMaxKshortCtau(30.),
149 fCutMaxKshortArmFrac(-1.),
150 fCutMinKshortDeltaM(0.003),
151 fCutMaxLambdaSigmaTPC(7.),
152 fCutMinLambdaCosPA(0.993),
153 fCutMaxLambdaCtau(40.),
154 fCutMaxLambdaArmFrac(-1.),
155 fCutMinLambdaDeletaM(-1.),
156 fEventAOD(nullptr),
157 fEventESD(nullptr),
158 fRespoPID(nullptr),
159 fEventAcptMask(0),
160 fMultEsti(),
161 fPicoV0sClArr(nullptr),
162 fOutputListEH(nullptr),
163 fOutputListMC(nullptr)
164 {
165 //
166 // Constructor
167 //
168 
169  for (auto &d : fPrimaryVtx) d = -999.;
170 
171  DefineOutput(1, TList::Class());
172  if (fIsAnaUseMC) DefineOutput(2, TList::Class());
173 }
174 
175 //_____________________________________________________________________________
177 {
178 //
179 // Default destructor
180 //
181 
182  if (fEventAOD) { delete fEventAOD; fEventAOD = nullptr; }
183  if (fEventESD) { delete fEventESD; fEventESD = nullptr; }
184  if (fRespoPID) { delete fRespoPID; fRespoPID = nullptr; }
185 
186  if (fPicoV0sClArr) { delete fPicoV0sClArr; fPicoV0sClArr = nullptr; }
187  if (fOutputListEH) { delete fOutputListEH; fOutputListEH = nullptr; }
188  if (fOutputListMC) { delete fOutputListMC; fOutputListMC = nullptr; }
189 }
190 
191 //_____________________________________________________________________________
193 {
194 //
195 // AliAnalysisTaskSEPicoV0Maker::Init
196 //
197 
198  return;
199 }
200 
201 //_____________________________________________________________________________
203 {
204 //
205 // AliAnalysisTaskSEPicoV0Maker::UserCreateOutputObjects
206 //
207 
208  InitAnalysis();
209 //=============================================================================
210 
211  if (fPicoV0sClArr) {
212  delete fPicoV0sClArr;
213  fPicoV0sClArr = nullptr;
214  }
215 
216  if (fIsAnaUseMC) {
217  fPicoV0sClArr = new TClonesArray("AliPicoV0MC");
218  fPicoV0sClArr->SetName("PicoV0s");
219  } else {
220  fPicoV0sClArr = new TClonesArray("AliPicoV0RD");
221  fPicoV0sClArr->SetName("PicoV0s");
222  }
223 //=============================================================================
224 
225  if (fOutputListEH) {
226  delete fOutputListEH;
227  fOutputListEH = nullptr;
228  }
229 
230  fOutputListEH = new TList();
231  fOutputListEH->SetOwner();
232 
234  PostData(1, fOutputListEH);
235 //=============================================================================
236 
237  if (fIsAnaUseMC) {
238  if (fOutputListMC) {
239  delete fOutputListMC;
240  fOutputListMC = nullptr;
241  }
242 
243  fOutputListMC = new TList();
244  fOutputListMC->SetOwner();
245 
247  PostData(2, fOutputListMC);
248  }
249 //=============================================================================
250 
251  return;
252 }
253 
254 //_____________________________________________________________________________
256 {
257 //
258 // AliAnalysisTaskSEPicoV0Maker::UserExec
259 //
260 
261  fPicoV0sClArr->Delete();
262  if (!(InputEvent()->FindListObject("PicoV0s"))) InputEvent()->AddObject(fPicoV0sClArr);
263 //=============================================================================
264 
265  if (IsEventNotAcpt()) return;
267 //=============================================================================
268 
269  if (IsEventNotINEL()) return;
271 //=============================================================================
272 
273  if (IsEventNotMBsa()) return;
274 //=============================================================================
275 
276  FillPicoV0s();
277  return;
278 }
279 
280 //_____________________________________________________________________________
282 {
283 //
284 // AliAnalysisTaskSEPicoV0Maker::Terminate
285 //
286 
287  return;
288 }
289 
290 //_____________________________________________________________________________
292 {
293 //
294 // AliAnalysisTaskSEPicoV0Maker::NotifyRun
295 //
296 
297  return;
298 }
299 
300 //_____________________________________________________________________________
302 {
303 //
304 // AliAnalysisTaskSEPicoV0Maker::FillPicoRecoV0s
305 //
306 
307  const auto nV0s(fEventAOD ? fEventAOD->GetNumberOfV0s() :
308  fEventESD->GetNumberOfV0s());
309 
310  if (nV0s<=0) return;
311 //=============================================================================
312 
313  auto nAt(fPicoV0sClArr->GetEntriesFast());
314  auto hKshortPtInvM(static_cast<TH2D*>(fOutputListEH->FindObject("hKshortPtInvM")));
315  auto hLambdaPtInvM(static_cast<TH2D*>(fOutputListEH->FindObject("hLambdaPtInvM")));
316  auto hAntiLaPtInvM(static_cast<TH2D*>(fOutputListEH->FindObject("hAntiLaPtInvM")));
317 //=============================================================================
318 
319  for (auto iV0=0; iV0<nV0s; ++iV0) {
320  AliPicoV0RD *pV0RD(nullptr);
321  AliPicoV0MC *pV0MC(nullptr);
322 
323  if (fEventAOD) {
324  auto pV0(fEventAOD->GetV0(iV0));
325  if (!pV0) continue;
326 
327  if (fIsAnaUseMC) {
328  pV0MC = SelectV0CandidateMC(pV0);
329  } else {
330  pV0RD = SelectV0CandidateRD(pV0);
331  }
332  }
333 
334  if (fEventESD) {
335  auto pV0(fEventESD->GetV0(iV0));
336  if (!pV0) continue;
337 
338  if (fIsAnaUseMC) {
339  pV0MC = SelectV0CandidateMC(pV0);
340  } else {
341  pV0RD = SelectV0CandidateRD(pV0);
342  }
343  }
344 //=============================================================================
345 
346  if (pV0RD) {
347  pV0RD->FillKshortPtInvM(hKshortPtInvM);
348  pV0RD->FillLambdaPtInvM(hLambdaPtInvM);
349  pV0RD->FillAntiLaPtInvM(hAntiLaPtInvM);
350  new ((*fPicoV0sClArr)[nAt++]) AliPicoV0RD(*pV0RD);
351  delete pV0RD; pV0RD=nullptr;
352  }
353 
354  if (pV0MC) {
355  pV0MC->FillKshortPtInvM(hKshortPtInvM);
356  pV0MC->FillLambdaPtInvM(hLambdaPtInvM);
357  pV0MC->FillAntiLaPtInvM(hAntiLaPtInvM);
358  new ((*fPicoV0sClArr)[nAt++]) AliPicoV0MC(*pV0MC);
359  delete pV0MC; pV0MC=nullptr;
360  }
361  }
362 //=============================================================================
363 
364  return;
365 }
366 
367 //_____________________________________________________________________________
369 {
370 //
371 // AliAnalysisTaskSEPicoV0Maker::SelectV0CandidateRD
372 //
373 
374  if (pV0->GetOnFlyStatus()) return nullptr;
375  if ((pV0->Chi2V0())>fCutMaxV0Chi2) return nullptr;
376 //=============================================================================
377 
378  const auto dV0Pt(pV0->Pt()); if ((dV0Pt<fCutMinV0Pt) || (dV0Pt>fCutMaxV0Pt)) return nullptr;
379  const auto dKaRap(pV0->RapK0Short()); if ((dKaRap<fCutMinV0Rap) || (dKaRap>fCutMaxV0Rap)) return nullptr;
380  const auto dLaRap(pV0->RapLambda()); if ((dLaRap<fCutMinV0Rap) || (dLaRap>fCutMaxV0Rap)) return nullptr;
381 //=============================================================================
382 
383  Double_t dV0Vtx[3]; pV0->GetXYZ(dV0Vtx);
384  const auto dV0Radius(TMath::Sqrt(dV0Vtx[0]*dV0Vtx[0] + dV0Vtx[1]*dV0Vtx[1]));
385  if ((dV0Radius<fCutMinV0Radius) || (dV0Radius>fCutMaxV0Radius)) return nullptr;
386 
387  const auto dDausDCA(pV0->DcaV0Daughters()); if (dDausDCA>fCutMaxDausDCA) return nullptr;
388  const auto dPosDCAtoPV(pV0->DcaPosToPrimVertex()); if (dPosDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
389  const auto dNegDCAtoPV(pV0->DcaNegToPrimVertex()); if (dNegDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
390 //=============================================================================
391 
392  auto pDauPos(static_cast<AliAODTrack*>(pV0->GetDaughter(0))); if (!pDauPos) return nullptr;
393  auto pDauNeg(static_cast<AliAODTrack*>(pV0->GetDaughter(1))); if (!pDauNeg) return nullptr;
394 
395  if (!(pDauPos->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
396  if (!(pDauNeg->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
397 
398  if ((pDauPos->GetProdVertex()->GetType())==((Char_t)AliAODVertex::kKink)) return nullptr;
399  if ((pDauNeg->GetProdVertex()->GetType())==((Char_t)AliAODVertex::kKink)) return nullptr;
400 
401  const auto dPosXrowsTPC(pDauPos->GetTPCClusterInfo(2,1));
402  const auto dNegXrowsTPC(pDauNeg->GetTPCClusterInfo(2,1));
403  const auto dDauXrowsTPC((dPosXrowsTPC<dNegXrowsTPC) ? dPosXrowsTPC : dNegXrowsTPC);
404  if (dDauXrowsTPC<fCutMinDauXrowsTPC) return nullptr;
405 
406  const auto wPosTPCNClsF(pDauPos->GetTPCNclsF()); if (wPosTPCNClsF<=0) return nullptr;
407  const auto wNegTPCNClsF(pDauNeg->GetTPCNclsF()); if (wNegTPCNClsF<=0) return nullptr;
408  const auto dPosXrowsOverFindableClusTPC( ((Double_t)dPosXrowsTPC) / ((Double_t)wPosTPCNClsF) );
409  const auto dNegXrowsOverFindableClusTPC( ((Double_t)dNegXrowsTPC) / ((Double_t)wNegTPCNClsF) );
410 
411  const auto dDauXrowsOverFindableClusTPC((dPosXrowsOverFindableClusTPC<dNegXrowsOverFindableClusTPC) ?
412  dPosXrowsOverFindableClusTPC :
413  dNegXrowsOverFindableClusTPC);
414  if (dDauXrowsOverFindableClusTPC<fCutMinDauXrowsOverFindableClusTPC) return nullptr;
415 //=============================================================================
416 
417  const auto nPosCharge(pDauPos->Charge());
418  const auto nNegCharge(pDauNeg->Charge());
419  if ((nPosCharge==0) || (nNegCharge==0) || (nPosCharge==nNegCharge)) return nullptr;
420 
421  Double_t dPosPxPyPz[3] = { 0., 0., 0. };
422  Double_t dNegPxPyPz[3] = { 0., 0., 0. };
423  if ((nPosCharge<0) && (nNegCharge>0)) {
424  pDauPos = (AliAODTrack*)pV0->GetDaughter(1);
425  pDauNeg = (AliAODTrack*)pV0->GetDaughter(0);
426 
427  dPosPxPyPz[0] = pV0->MomNegX(); dPosPxPyPz[1] = pV0->MomNegY(); dPosPxPyPz[2] = pV0->MomNegZ();
428  dNegPxPyPz[0] = pV0->MomPosX(); dNegPxPyPz[1] = pV0->MomPosY(); dNegPxPyPz[2] = pV0->MomPosZ();
429  } else {
430  dPosPxPyPz[0] = pV0->MomPosX(); dPosPxPyPz[1] = pV0->MomPosY(); dPosPxPyPz[2] = pV0->MomPosZ();
431  dNegPxPyPz[0] = pV0->MomNegX(); dNegPxPyPz[1] = pV0->MomNegY(); dNegPxPyPz[2] = pV0->MomNegZ();
432  }
433 
434  const TVector3 v3Pos(dPosPxPyPz);
435  const TVector3 v3Neg(dNegPxPyPz);
436  if ((v3Pos.Pt()<fCutMinDauPt) || (v3Neg.Pt()<fCutMinDauPt)) return nullptr;
437  const auto dPosEta(v3Pos.Eta()); if ((dPosEta<fCutMinDauEta) || (dPosEta>fCutMaxDauEta)) return nullptr;
438  const auto dNegEta(v3Neg.Eta()); if ((dNegEta<fCutMinDauEta) || (dNegEta>fCutMaxDauEta)) return nullptr;
439 //=============================================================================
440 
441  auto bIsKshort(kTRUE);
442  auto bIsLambda(kTRUE);
443  auto bIsAntiLa(kTRUE);
444  const auto dPosPionSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauPos,AliPID::kPion));
445  const auto dNegPionSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauNeg,AliPID::kPion));
446 
447  const auto dPosProtonSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauPos,AliPID::kProton));
448  const auto dNegProtonSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauNeg,AliPID::kProton));
449 
450  if (fCutMaxKshortSigmaTPC>0.) {
451  bIsKshort = ((TMath::Abs(dPosPionSigmaTPC)<fCutMaxKshortSigmaTPC) &&
452  (TMath::Abs(dNegPionSigmaTPC)<fCutMaxKshortSigmaTPC));
453  }
454 
455  if (fCutMaxLambdaSigmaTPC>0.) {
456  bIsLambda = ((TMath::Abs(dPosProtonSigmaTPC)<fCutMaxLambdaSigmaTPC) &&
457  (TMath::Abs(dNegPionSigmaTPC) <fCutMaxLambdaSigmaTPC));
458 
459  bIsAntiLa = ((TMath::Abs(dPosPionSigmaTPC) <fCutMaxLambdaSigmaTPC) &&
460  (TMath::Abs(dNegProtonSigmaTPC)<fCutMaxLambdaSigmaTPC));
461  }
462 
463  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
464 //=============================================================================
465 
466  const auto dV0CosPA(pV0->CosPointingAngle(fPrimaryVtx));
467 
468  if (bIsKshort) if (dV0CosPA<fCutMinKshortCosPA) {
469  bIsKshort = kFALSE;
470  }
471 
472  if (bIsLambda || bIsAntiLa) if (dV0CosPA<fCutMinLambdaCosPA) {
473  bIsLambda = kFALSE;
474  bIsAntiLa = kFALSE;
475  }
476 
477  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
478 //=============================================================================
479 
480  auto dV0DistToPV(0.);
481  for (auto i=0; i<3; ++i) dV0DistToPV += ((dV0Vtx[i]-fPrimaryVtx[i]) * (dV0Vtx[i]-fPrimaryVtx[i]));
482  const auto dV0DistToPVoverP(TMath::Sqrt(dV0DistToPV) / (pV0->P()+1e-10));
483 
484  if (bIsKshort) if ((dV0DistToPVoverP*AliPicoBase::MassKshort())>fCutMaxKshortCtau) {
485  bIsKshort = kFALSE;
486  }
487 
488  if (bIsLambda || bIsAntiLa) if ((dV0DistToPVoverP*AliPicoBase::MassLambda())>fCutMaxLambdaCtau) {
489  bIsLambda = kFALSE;
490  bIsAntiLa = kFALSE;
491  }
492 
493  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
494 //=============================================================================
495 
496  const auto dV0ArmFrac(pV0->PtArmV0() / (TMath::Abs(pV0->AlphaV0())+1e-12));
497  if (bIsKshort && (fCutMaxKshortArmFrac>0.)) if (dV0ArmFrac>fCutMaxKshortArmFrac) {
498  bIsKshort = kFALSE;
499  }
500 
501  if ((bIsLambda || bIsAntiLa) && fCutMaxLambdaArmFrac>0.) if (dV0ArmFrac>fCutMaxLambdaArmFrac) {
502  bIsLambda = kFALSE;
503  bIsAntiLa = kFALSE;
504  }
505 
506  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
507 //=============================================================================
508 
509  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
510  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
511 
512  TLorentzVector vPosProton; vPosProton.SetVectM(v3Pos, AliPicoBase::MassProton());
513  TLorentzVector vNegProton; vNegProton.SetVectM(v3Neg, AliPicoBase::MassProton());
514 
515  const auto dKshortInvM((vPosPion +vNegPion).M());
516  const auto dLambdaInvM((vPosProton+vNegPion).M());
517  const auto dAntiLaInvM((vNegProton+vPosPion).M());
518  if (bIsKshort) if ((dKshortInvM<(0.430006 - 0.0110029*dV0Pt)) ||
519  (dKshortInvM>(0.563707 + 0.0114979*dV0Pt))) bIsKshort = kFALSE;
520 
521  if (bIsLambda || bIsAntiLa) {
522  const auto dLower(1.09501 - 0.00523272*dV0Pt - 0.075269*TMath::Exp(-3.46339*dV0Pt));
523  const auto dUpper(1.13688 + 0.00527838*dV0Pt + 0.084222*TMath::Exp(-3.80595*dV0Pt));
524  if (bIsLambda) if ((dLambdaInvM<dLower) || (dLambdaInvM>dUpper)) bIsLambda = kFALSE;
525  if (bIsAntiLa) if ((dAntiLaInvM<dLower) || (dAntiLaInvM>dUpper)) bIsAntiLa = kFALSE;
526  }
527 
528  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
529 //=============================================================================
530 
531  if (bIsKshort && (fCutMinKshortDeltaM>0.)) {
532  if ((TMath::Abs(dLambdaInvM-AliPicoBase::MassLambda())<fCutMinKshortDeltaM) ||
533  (TMath::Abs(dAntiLaInvM-AliPicoBase::MassLambda())<fCutMinKshortDeltaM)) bIsKshort = kFALSE;
534  }
535 
536  if ((bIsLambda || bIsAntiLa) && (fCutMinLambdaDeletaM>0.)) {
537  if ((TMath::Abs(dKshortInvM-AliPicoBase::MassKshort())<fCutMinLambdaDeletaM)) {
538  bIsLambda = kFALSE;
539  bIsAntiLa = kFALSE;
540  }
541  }
542 
543  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
544 //=============================================================================
545 
546  UInt_t wMask(0);
547  if (bIsKshort) wMask |= AliPicoBase::kKshort;
548  if (bIsLambda) wMask |= AliPicoBase::kLambda;
549  if (bIsAntiLa) wMask |= AliPicoBase::kAntiLambda;
550 //=============================================================================
551 
552  auto bPosInJC(kFALSE);
553  auto bNegInJC(kFALSE);
554  return (new AliPicoV0RD(wMask,
555  dV0Radius,
556  dV0CosPA,
557  dV0DistToPVoverP,
558  dDausDCA,
559  dPosDCAtoPV,
560  dNegDCAtoPV,
561  dDauXrowsTPC,
562  dDauXrowsOverFindableClusTPC,
563  v3Pos.Px(), v3Pos.Py(), v3Pos.Pz(),
564  v3Neg.Px(), v3Neg.Py(), v3Neg.Pz(),
565  bPosInJC, bNegInJC,
566  dPosPionSigmaTPC, dPosProtonSigmaTPC,
567  dNegPionSigmaTPC, dNegProtonSigmaTPC));
568 }
569 
570 //_____________________________________________________________________________
572 {
573 //
574 // AliAnalysisTaskSEPicoV0Maker::SelectV0CandidateRD
575 //
576 
577  if (pV0->GetOnFlyStatus()) return nullptr;
578  if (pV0->GetChi2V0()>fCutMaxV0Chi2) return nullptr;
579 //=============================================================================
580 
581  const auto dV0Pt(pV0->Pt()); if ((dV0Pt<fCutMinV0Pt) || (dV0Pt>fCutMaxV0Pt)) return nullptr;
582  const auto dKaRap(pV0->RapK0Short()); if ((dKaRap<fCutMinV0Rap) || (dKaRap>fCutMaxV0Rap)) return nullptr;
583  const auto dLaRap(pV0->RapLambda()); if ((dLaRap<fCutMinV0Rap) || (dLaRap>fCutMaxV0Rap)) return nullptr;
584 //=============================================================================
585 
586  Double_t dV0Vtx[3]; pV0->GetXYZ(dV0Vtx[0], dV0Vtx[1], dV0Vtx[2]);
587  const auto dV0Radius(TMath::Sqrt(dV0Vtx[0]*dV0Vtx[0] + dV0Vtx[1]*dV0Vtx[1]));
588  if ((dV0Radius<fCutMinV0Radius) || (dV0Radius>fCutMaxV0Radius)) return nullptr;
589 
590  const auto dDausDCA(pV0->GetDcaV0Daughters()); if (dDausDCA>fCutMaxDausDCA) return nullptr;
591 //=============================================================================
592 
593  const auto nPosIndex(pV0->GetPindex()); if (nPosIndex<0) return nullptr;
594  const auto nNegIndex(pV0->GetNindex()); if (nNegIndex<0) return nullptr;
595 
596  auto pDauPos(fEventESD->GetTrack(nPosIndex)); if (!pDauPos) return nullptr;
597  auto pDauNeg(fEventESD->GetTrack(nNegIndex)); if (!pDauNeg) return nullptr;
598 
599  const auto dMegField(fEventESD->GetMagneticField());
600  const auto dPosDCAtoPV(TMath::Abs(pDauPos->GetD(fPrimaryVtx[0],fPrimaryVtx[1],dMegField)));
601  if (dPosDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
602 
603  const auto dNegDCAtoPV(TMath::Abs(pDauNeg->GetD(fPrimaryVtx[0],fPrimaryVtx[1],dMegField)));
604  if (dNegDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
605 //=============================================================================
606 
607  if (!(pDauPos->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
608  if (!(pDauNeg->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
609  if ((pDauPos->GetKinkIndex(0)>0) || (pDauNeg->GetKinkIndex(0)>0)) return nullptr;
610 
611  const auto dPosXrowsTPC(pDauPos->GetTPCClusterInfo(2,1));
612  const auto dNegXrowsTPC(pDauNeg->GetTPCClusterInfo(2,1));
613  const auto dDauXrowsTPC((dPosXrowsTPC<dNegXrowsTPC) ? dPosXrowsTPC : dNegXrowsTPC);
614  if (dDauXrowsTPC<fCutMinDauXrowsTPC) return nullptr;
615 
616  const auto wPosTPCNClsF(pDauPos->GetTPCNclsF()); if (wPosTPCNClsF<=0) return nullptr;
617  const auto wNegTPCNClsF(pDauNeg->GetTPCNclsF()); if (wNegTPCNClsF<=0) return nullptr;
618  const auto dPosXrowsOverFindableClusTPC( ((Double_t)dPosXrowsTPC) / ((Double_t)wPosTPCNClsF) );
619  const auto dNegXrowsOverFindableClusTPC( ((Double_t)dNegXrowsTPC) / ((Double_t)wNegTPCNClsF) );
620 
621  const auto dDauXrowsOverFindableClusTPC((dPosXrowsOverFindableClusTPC<dNegXrowsOverFindableClusTPC) ?
622  dPosXrowsOverFindableClusTPC :
623  dNegXrowsOverFindableClusTPC);
624  if (dDauXrowsOverFindableClusTPC<fCutMinDauXrowsOverFindableClusTPC) return nullptr;
625 //=============================================================================
626 
627  const auto nPosCharge(pDauPos->Charge());
628  const auto nNegCharge(pDauNeg->Charge());
629  if ((nPosCharge==0) || (nNegCharge==0) || (nPosCharge==nNegCharge)) return nullptr;
630 
631  Double_t dPosPxPyPz[3] = { 0., 0., 0. };
632  Double_t dNegPxPyPz[3] = { 0., 0., 0. };
633  if ((nPosCharge<0) && (nNegCharge>0)) {
634  pDauPos = fEventESD->GetTrack(nNegIndex);
635  pDauNeg = fEventESD->GetTrack(nPosIndex);
636 
637  pV0->GetNPxPyPz(dPosPxPyPz[0], dPosPxPyPz[1], dPosPxPyPz[2]);
638  pV0->GetPPxPyPz(dNegPxPyPz[0], dNegPxPyPz[1], dNegPxPyPz[2]);
639  } else {
640  pV0->GetPPxPyPz(dPosPxPyPz[0], dPosPxPyPz[1], dPosPxPyPz[2]);
641  pV0->GetNPxPyPz(dNegPxPyPz[0], dNegPxPyPz[1], dNegPxPyPz[2]);
642  }
643 
644  const TVector3 v3Pos(dPosPxPyPz);
645  const TVector3 v3Neg(dNegPxPyPz);
646  if ((v3Pos.Pt()<fCutMinDauPt) || (v3Neg.Pt()<fCutMinDauPt)) return nullptr;
647  const auto dPosEta(v3Pos.Eta()); if ((dPosEta<fCutMinDauEta) || (dPosEta>fCutMaxDauEta)) return nullptr;
648  const auto dNegEta(v3Neg.Eta()); if ((dNegEta<fCutMinDauEta) || (dNegEta>fCutMaxDauEta)) return nullptr;
649 //=============================================================================
650 
651  auto bIsKshort(kTRUE);
652  auto bIsLambda(kTRUE);
653  auto bIsAntiLa(kTRUE);
654  const auto dPosPionSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauPos,AliPID::kPion));
655  const auto dNegPionSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauNeg,AliPID::kPion));
656 
657  const auto dPosProtonSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauPos,AliPID::kProton));
658  const auto dNegProtonSigmaTPC(fRespoPID->NumberOfSigmasTPC(pDauNeg,AliPID::kProton));
659 
660  if (fCutMaxKshortSigmaTPC>0.) {
661  bIsKshort = ((TMath::Abs(dPosPionSigmaTPC)<fCutMaxKshortSigmaTPC) &&
662  (TMath::Abs(dNegPionSigmaTPC)<fCutMaxKshortSigmaTPC));
663  }
664 
665  if (fCutMaxLambdaSigmaTPC>0.) {
666  bIsLambda = ((TMath::Abs(dPosProtonSigmaTPC)<fCutMaxLambdaSigmaTPC) &&
667  (TMath::Abs(dNegPionSigmaTPC) <fCutMaxLambdaSigmaTPC));
668 
669  bIsAntiLa = ((TMath::Abs(dPosPionSigmaTPC) <fCutMaxLambdaSigmaTPC) &&
670  (TMath::Abs(dNegProtonSigmaTPC)<fCutMaxLambdaSigmaTPC));
671  }
672 
673  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
674 //=============================================================================
675 
676  const auto dV0CosPA(pV0->GetV0CosineOfPointingAngle(fPrimaryVtx[0],fPrimaryVtx[1],fPrimaryVtx[2]));
677 
678  if (bIsKshort) if (dV0CosPA<fCutMinKshortCosPA) {
679  bIsKshort = kFALSE;
680  }
681 
682  if (bIsLambda || bIsAntiLa) if (dV0CosPA<fCutMinLambdaCosPA) {
683  bIsLambda = kFALSE;
684  bIsAntiLa = kFALSE;
685  }
686 
687  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
688 //=============================================================================
689 
690  auto dV0DistToPV(0.);
691  for (auto i=0; i<3; ++i) dV0DistToPV += ((dV0Vtx[i]-fPrimaryVtx[i]) * (dV0Vtx[i]-fPrimaryVtx[i]));
692  const auto dV0DistToPVoverP(TMath::Sqrt(dV0DistToPV) / (pV0->P()+1e-10));
693 
694  if (bIsKshort) if ((dV0DistToPVoverP*AliPicoBase::MassKshort())>fCutMaxKshortCtau) {
695  bIsKshort = kFALSE;
696  }
697 
698  if (bIsLambda || bIsAntiLa) if ((dV0DistToPVoverP*AliPicoBase::MassLambda())>fCutMaxLambdaCtau) {
699  bIsLambda = kFALSE;
700  bIsAntiLa = kFALSE;
701  }
702 
703  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
704 //=============================================================================
705 
706  const auto dV0ArmFrac(pV0->PtArmV0() / (TMath::Abs(pV0->AlphaV0())+1e-12));
707  if (bIsKshort && (fCutMaxKshortArmFrac>0.)) if (dV0ArmFrac>fCutMaxKshortArmFrac) {
708  bIsKshort = kFALSE;
709  }
710 
711  if ((bIsLambda && bIsAntiLa) && (fCutMaxLambdaArmFrac>0.)) if (dV0ArmFrac>fCutMaxLambdaArmFrac) {
712  bIsLambda = kFALSE;
713  bIsAntiLa = kFALSE;
714  }
715 
716  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
717 //=============================================================================
718 
719  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
720  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
721 
722  TLorentzVector vPosProton; vPosProton.SetVectM(v3Pos, AliPicoBase::MassProton());
723  TLorentzVector vNegProton; vNegProton.SetVectM(v3Neg, AliPicoBase::MassProton());
724 
725  const auto dKshortInvM((vPosPion +vNegPion).M());
726  const auto dLambdaInvM((vPosProton+vNegPion).M());
727  const auto dAntiLaInvM((vNegProton+vPosPion).M());
728  if (bIsKshort) if ((dKshortInvM<(0.430006 - 0.0110029*dV0Pt)) ||
729  (dKshortInvM>(0.563707 + 0.0114979*dV0Pt))) bIsKshort = kFALSE;
730 
731  if (bIsLambda || bIsAntiLa) {
732  const auto dLower(1.09501 - 0.00523272*dV0Pt - 0.075269*TMath::Exp(-3.46339*dV0Pt));
733  const auto dUpper(1.13688 + 0.00527838*dV0Pt + 0.084222*TMath::Exp(-3.80595*dV0Pt));
734  if (bIsLambda) if ((dLambdaInvM<dLower) || (dLambdaInvM>dUpper)) bIsLambda = kFALSE;
735  if (bIsAntiLa) if ((dAntiLaInvM<dLower) || (dAntiLaInvM>dUpper)) bIsAntiLa = kFALSE;
736  }
737 
738  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
739 //=============================================================================
740 
741  if (bIsKshort && (fCutMinKshortDeltaM>0.)) {
742  if ((TMath::Abs(dLambdaInvM-AliPicoBase::MassLambda())<fCutMinKshortDeltaM) ||
743  (TMath::Abs(dAntiLaInvM-AliPicoBase::MassLambda())<fCutMinKshortDeltaM)) {
744  bIsKshort = kFALSE;
745  }
746  }
747 
748  if ((bIsLambda || bIsAntiLa) && (fCutMinLambdaDeletaM>0.)) {
749  if ((TMath::Abs(dKshortInvM-AliPicoBase::MassKshort())<fCutMinLambdaDeletaM)) {
750  bIsLambda = kFALSE;
751  bIsAntiLa = kFALSE;
752  }
753  }
754 
755  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
756 //=============================================================================
757 
758  UInt_t wMask(0);
759  if (bIsKshort) wMask |= AliPicoBase::kKshort;
760  if (bIsLambda) wMask |= AliPicoBase::kLambda;
761  if (bIsAntiLa) wMask |= AliPicoBase::kAntiLambda;
762 //=============================================================================
763 
764  auto bPosInJC(kFALSE);
765  auto bNegInJC(kFALSE);
766 /*if (fJetContisClArr) {
767  const auto idPos(pDauPos->GetID());
768  const auto idNeg(pDauNeg->GetID());
769  for (auto i=0; i<fJetContisClArr->GetEntriesFast(); ++i) {
770  auto pTrk(fJetContisClArr->At(i)); if (!pTrk) continue;
771 
772  const auto id(pTrkAOD->GetID());
773  if (idPos==id) bPosInJC = kTRUE;
774  if (idNeg==id) bNegInJC = kTRUE;
775  if (bPosInJC && bNegInJC) break;
776  }
777  }*/
778 //=============================================================================
779 
780  return (new AliPicoV0RD(wMask,
781  dV0Radius,
782  dV0CosPA,
783  dV0DistToPVoverP,
784  dDausDCA,
785  dPosDCAtoPV,
786  dNegDCAtoPV,
787  dDauXrowsTPC,
788  dDauXrowsOverFindableClusTPC,
789  v3Pos.Px(), v3Pos.Py(), v3Pos.Pz(),
790  v3Neg.Px(), v3Neg.Py(), v3Neg.Pz(),
791  bPosInJC, bNegInJC,
792  dPosPionSigmaTPC, dPosProtonSigmaTPC,
793  dNegPionSigmaTPC, dNegProtonSigmaTPC));
794 }
795 
796 //_____________________________________________________________________________
798 {
799 //
800 // AliAnalysisTaskSEPicoV0Maker::SelectV0CandidateMC
801 //
802 
803  if (pV0RD->GetOnFlyStatus()) return nullptr;
804  if ((pV0RD->Chi2V0())>fCutMaxV0Chi2) return nullptr;
805 
806  const auto dV0Pt(pV0RD->Pt()); if ((dV0Pt<fCutMinV0Pt) || (dV0Pt>fCutMaxV0Pt)) return nullptr;
807 //=============================================================================
808 
809  Double_t dV0Vtx[3]; pV0RD->GetXYZ(dV0Vtx);
810  const auto dV0Radius(TMath::Sqrt(dV0Vtx[0]*dV0Vtx[0] + dV0Vtx[1]*dV0Vtx[1]));
811  if ((dV0Radius<fCutMinV0Radius) || (dV0Radius>fCutMaxV0Radius)) return nullptr;
812 
813  const auto dDausDCA(pV0RD->DcaV0Daughters()); if (dDausDCA>fCutMaxDausDCA) return nullptr;
814  const auto dPosDCAtoPV(pV0RD->DcaPosToPrimVertex()); if (dPosDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
815  const auto dNegDCAtoPV(pV0RD->DcaNegToPrimVertex()); if (dNegDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
816 //=============================================================================
817 
818  auto pDauPosRD(static_cast<AliAODTrack*>(pV0RD->GetDaughter(0))); if (!pDauPosRD) return nullptr;
819  auto pDauNegRD(static_cast<AliAODTrack*>(pV0RD->GetDaughter(1))); if (!pDauNegRD) return nullptr;
820 
821  if (!(pDauPosRD->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
822  if (!(pDauNegRD->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
823 
824  if ((pDauPosRD->GetProdVertex()->GetType())==((Char_t)AliAODVertex::kKink)) return nullptr;
825  if ((pDauNegRD->GetProdVertex()->GetType())==((Char_t)AliAODVertex::kKink)) return nullptr;
826 
827  const auto dPosXrowsTPC(pDauPosRD->GetTPCClusterInfo(2,1));
828  const auto dNegXrowsTPC(pDauNegRD->GetTPCClusterInfo(2,1));
829  const auto dDauXrowsTPC(dPosXrowsTPC<dNegXrowsTPC ? dPosXrowsTPC : dNegXrowsTPC);
830  if (dDauXrowsTPC<fCutMinDauXrowsTPC) return nullptr;
831 
832  const auto wPosTPCNClsF(pDauPosRD->GetTPCNclsF()); if (wPosTPCNClsF<=0) return nullptr;
833  const auto wNegTPCNClsF(pDauNegRD->GetTPCNclsF()); if (wNegTPCNClsF<=0) return nullptr;
834  const auto dPosXrowsOverFindableClusTPC( ((Double_t)dPosXrowsTPC) / ((Double_t)wPosTPCNClsF) );
835  const auto dNegXrowsOverFindableClusTPC( ((Double_t)dNegXrowsTPC) / ((Double_t)wNegTPCNClsF) );
836 
837  const auto dDauXrowsOverFindableClusTPC(dPosXrowsOverFindableClusTPC<dNegXrowsOverFindableClusTPC ?
838  dPosXrowsOverFindableClusTPC :
839  dNegXrowsOverFindableClusTPC);
840  if (dDauXrowsOverFindableClusTPC<fCutMinDauXrowsOverFindableClusTPC) return nullptr;
841 //=============================================================================
842 
843  const auto nPosCharge(pDauPosRD->Charge());
844  const auto nNegCharge(pDauNegRD->Charge());
845  if ((nPosCharge==0) || (nNegCharge==0) || (nPosCharge==nNegCharge)) return nullptr;
846 
847  Double_t dPosPxPyPz[3] = { 0., 0., 0. };
848  Double_t dNegPxPyPz[3] = { 0., 0., 0. };
849  if ((nPosCharge<0) && (nNegCharge>0)) {
850  pDauPosRD = (AliAODTrack*)pV0RD->GetDaughter(1);
851  pDauNegRD = (AliAODTrack*)pV0RD->GetDaughter(0);
852 
853  dPosPxPyPz[0] = pV0RD->MomNegX(); dPosPxPyPz[1] = pV0RD->MomNegY(); dPosPxPyPz[2] = pV0RD->MomNegZ();
854  dNegPxPyPz[0] = pV0RD->MomPosX(); dNegPxPyPz[1] = pV0RD->MomPosY(); dNegPxPyPz[2] = pV0RD->MomPosZ();
855  } else {
856  dPosPxPyPz[0] = pV0RD->MomPosX(); dPosPxPyPz[1] = pV0RD->MomPosY(); dPosPxPyPz[2] = pV0RD->MomPosZ();
857  dNegPxPyPz[0] = pV0RD->MomNegX(); dNegPxPyPz[1] = pV0RD->MomNegY(); dNegPxPyPz[2] = pV0RD->MomNegZ();
858  }
859 
860  const TVector3 v3Pos(dPosPxPyPz);
861  const TVector3 v3Neg(dNegPxPyPz);
862  if ((v3Pos.Pt()<fCutMinDauPt) || (v3Neg.Pt()<fCutMinDauPt)) return nullptr;
863  const auto dPosEta(v3Pos.Eta()); if ((dPosEta<fCutMinDauEta) || (dPosEta>fCutMaxDauEta)) return nullptr;
864  const auto dNegEta(v3Neg.Eta()); if ((dNegEta<fCutMinDauEta) || (dNegEta>fCutMaxDauEta)) return nullptr;
865 //=============================================================================
866 
867  const auto inp(TMath::Abs(pDauPosRD->GetLabel())); if (inp<0) return nullptr;
868  auto pDauPosMC(static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(inp))); if (!pDauPosMC) return nullptr;
869  const auto imp(pDauPosMC->GetMother()); if (imp<0) return nullptr;
870 
871  const auto inn(TMath::Abs(pDauNegRD->GetLabel())); if (inn<0) return nullptr;
872  const auto pDauNegMC(static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(inn))); if (!pDauNegMC) return nullptr;
873  const auto imn(pDauNegMC->GetMother()); if (imn<0) return nullptr;
874 
875  if (imp != imn) return nullptr;
876  const auto pV0MC(static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(imp))); if (!pV0MC) return nullptr;
877  if (((pV0MC->Y())<fCutMinV0Rap) || ((pV0MC->Y())>fCutMaxV0Rap)) return nullptr;
878 
879  const auto idvMC(pV0MC->GetPdgCode());
880  const auto idp(pDauPosMC->GetPdgCode());
881  const auto idn(pDauNegMC->GetPdgCode());
882  auto bIsKshort((idp==211) && (idn==-211) && (idvMC== 310));
883  auto bIsLambda((idp==2212) && (idn==-211) && (idvMC== 3122));
884  auto bIsAntiLa((idp==211) && (idn==-2212) && (idvMC==-3122));
885  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
886 //=============================================================================
887 
888  UInt_t wsvMC(0);
889  if (pV0MC->IsPrimary()) wsvMC |= AliPicoBase::kPrimary;
890  if (pV0MC->IsPhysicalPrimary()) wsvMC |= AliPicoBase::kPhysicalPrimary;
891  if (pV0MC->IsSecondaryFromWeakDecay()) wsvMC |= AliPicoBase::kSecondaryFromWeakDecay;
892  if (pV0MC->IsSecondaryFromMaterial()) wsvMC |= AliPicoBase::kSecondaryFromMaterial;
893 
894  auto idmMC(0);
895  UInt_t wsmMC(0);
896  auto dMotherPt(0.);
897  auto dMotherEta(0.);
898  auto dMotherRap(0.);
899  if (bIsLambda || bIsAntiLa) {
900  const auto imv(pV0MC->GetMother());
901 
902  if (imv>=0) {
903  const auto pMother(static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(imv)));
904 
905  if (pMother) {
906  idmMC = pMother->GetPdgCode();
907  if ((bIsLambda && ((idmMC== 3312) || (idmMC== 3322))) ||
908  (bIsAntiLa && ((idmMC==-3312) || (idmMC==-3322)))) {
909  dMotherPt = pMother->Pt();
910  dMotherEta = pMother->Eta();
911  dMotherRap = pMother->Y();
912 
913  if (pMother->IsPrimary()) wsmMC |= AliPicoBase::kPrimary;
914  if (pMother->IsPhysicalPrimary()) wsmMC |= AliPicoBase::kPhysicalPrimary;
915  if (pMother->IsSecondaryFromWeakDecay()) wsmMC |= AliPicoBase::kSecondaryFromWeakDecay;
916  if (pMother->IsSecondaryFromMaterial()) wsmMC |= AliPicoBase::kSecondaryFromMaterial;
917  }
918  }
919  }
920  }
921 //=============================================================================
922 
923  const auto dV0CosPA(pV0RD->CosPointingAngle(fPrimaryVtx));
924 
925  if (bIsKshort) if (dV0CosPA<fCutMinKshortCosPA) {
926  bIsKshort = kFALSE;
927  }
928 
929  if (bIsLambda || bIsAntiLa) if (dV0CosPA<fCutMinLambdaCosPA) {
930  bIsLambda = kFALSE;
931  bIsAntiLa = kFALSE;
932  }
933 
934  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
935 //=============================================================================
936 
937  auto dV0DistToPV(0.);
938  for (auto i=0; i<3; ++i) dV0DistToPV += ((dV0Vtx[i]-fPrimaryVtx[i]) * (dV0Vtx[i]-fPrimaryVtx[i]));
939  const auto dV0DistToPVoverP(TMath::Sqrt(dV0DistToPV) / (pV0RD->P()+1e-10));
940 
941  if (bIsKshort) if ((dV0DistToPVoverP*AliPicoBase::MassKshort())>fCutMaxKshortCtau) {
942  bIsKshort = kFALSE;
943  }
944 
945  if (bIsLambda || bIsAntiLa) if ((dV0DistToPVoverP*AliPicoBase::MassLambda())>fCutMaxLambdaCtau) {
946  bIsLambda = kFALSE;
947  bIsAntiLa = kFALSE;
948  }
949 
950  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
951 //=============================================================================
952 
953  const auto dV0ArmFrac(pV0RD->PtArmV0() / (TMath::Abs(pV0RD->AlphaV0())+1e-12));
954 
955  if (bIsKshort && (fCutMaxKshortArmFrac>0.)) if (dV0ArmFrac>fCutMaxKshortArmFrac) {
956  bIsKshort = kFALSE;
957  }
958 
959  if ((bIsLambda || bIsAntiLa) && fCutMaxLambdaArmFrac>0.) if (dV0ArmFrac>fCutMaxLambdaArmFrac) {
960  bIsLambda = kFALSE;
961  bIsAntiLa = kFALSE;
962  }
963 
964  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
965 //=============================================================================
966 
967  UInt_t wMask(0);
968  if (bIsKshort) {
969  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
970  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
971 
972  const auto dKshortInvM((vPosPion+vNegPion).M());
973  if ((dKshortInvM<(0.430006-0.0110029*dV0Pt)) ||
974  (dKshortInvM>(0.563707+0.0114979*dV0Pt))) return nullptr;
975 
976  if (fCutMinKshortDeltaM>0.) {
977  TLorentzVector vPosProton; vPosProton.SetVectM(v3Pos, AliPicoBase::MassProton());
978  TLorentzVector vNegProton; vNegProton.SetVectM(v3Neg, AliPicoBase::MassProton());
979  if ((TMath::Abs((vPosProton+vNegPion).M()-AliPicoBase::MassLambda())<fCutMinKshortDeltaM) ||
980  (TMath::Abs((vNegProton+vPosPion).M()-AliPicoBase::MassLambda())<fCutMinKshortDeltaM)) return nullptr;
981  }
982 
983  wMask = AliPicoBase::kKshort;
984  }
985 
986  if (bIsLambda) {
987  TLorentzVector vPosProton; vPosProton.SetVectM(v3Pos, AliPicoBase::MassProton());
988  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
989 
990  const auto dLambdaInvM((vPosProton+vNegPion).M());
991  if ((dLambdaInvM<(1.09501 - 0.00523272*dV0Pt - 0.075269*TMath::Exp(-3.46339*dV0Pt))) ||
992  (dLambdaInvM>(1.13688 + 0.00527838*dV0Pt + 0.084222*TMath::Exp(-3.80595*dV0Pt)))) return nullptr;
993 
994  if (fCutMinLambdaDeletaM>0.) {
995  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
996  if ((TMath::Abs((vPosPion+vNegPion).M()-AliPicoBase::MassKshort())<fCutMinLambdaDeletaM)) return nullptr;
997  }
998 
999  wMask = AliPicoBase::kLambda;
1000  }
1001 
1002  if (bIsAntiLa) {
1003  TLorentzVector vNegProton; vNegProton.SetVectM(v3Neg, AliPicoBase::MassProton());
1004  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
1005 
1006  const auto dAntiLaInvM((vNegProton+vPosPion).M());
1007  if ((dAntiLaInvM<(1.09501 - 0.00523272*dV0Pt - 0.075269*TMath::Exp(-3.46339*dV0Pt))) ||
1008  (dAntiLaInvM>(1.13688 + 0.00527838*dV0Pt + 0.084222*TMath::Exp(-3.80595*dV0Pt)))) return nullptr;
1009 
1010  if (fCutMinLambdaDeletaM>0.) {
1011  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
1012  if ((TMath::Abs((vPosPion+vNegPion).M()-AliPicoBase::MassKshort())<fCutMinLambdaDeletaM)) return nullptr;
1013  }
1014 
1015  wMask = AliPicoBase::kAntiLambda;
1016  }
1017 //=============================================================================
1018 
1019  auto bPosInJC(kFALSE);
1020  auto bNegInJC(kFALSE);
1021  return (new AliPicoV0MC(wMask,
1022  dV0Radius,
1023  dV0CosPA,
1024  dV0DistToPVoverP,
1025  dDausDCA,
1026  dPosDCAtoPV,
1027  dNegDCAtoPV,
1028  dDauXrowsTPC,
1029  dDauXrowsOverFindableClusTPC,
1030  v3Pos.Px(), v3Pos.Py(), v3Pos.Pz(),
1031  v3Neg.Px(), v3Neg.Py(), v3Neg.Pz(),
1032  bPosInJC, bNegInJC,
1033  idvMC, wsvMC, pV0MC->Px(), pV0MC->Py(), pV0MC->Pz(), pV0MC->E(),
1034  idmMC, wsmMC, dMotherPt, dMotherEta, dMotherRap));
1035 }
1036 
1037 //_____________________________________________________________________________
1039 {
1040 //
1041 // AliAnalysisTaskSEPicoV0Maker::SelectV0CandidateMC
1042 //
1043 
1044  const auto pStack(MCEvent()->Stack()); if (!pStack) return nullptr;
1045 //=============================================================================
1046 
1047  if (pV0RD->GetOnFlyStatus()) return nullptr;
1048  if (pV0RD->GetChi2V0()>fCutMaxV0Chi2) return nullptr;
1049 
1050  const auto dV0Pt(pV0RD->Pt()); if ((dV0Pt<fCutMinV0Pt) || (dV0Pt>fCutMaxV0Pt)) return nullptr;
1051 //=============================================================================
1052 
1053  Double_t dV0Vtx[3]; pV0RD->GetXYZ(dV0Vtx[0], dV0Vtx[1], dV0Vtx[2]);
1054  const auto dV0Radius(TMath::Sqrt(dV0Vtx[0]*dV0Vtx[0] + dV0Vtx[1]*dV0Vtx[1]));
1055  if ((dV0Radius<fCutMinV0Radius) || (dV0Radius>fCutMaxV0Radius)) return nullptr;
1056 
1057  const auto dDausDCA(pV0RD->GetDcaV0Daughters()); if (dDausDCA>fCutMaxDausDCA) return nullptr;
1058 //=============================================================================
1059 
1060  const auto nPosIndex(TMath::Abs(pV0RD->GetPindex())); if (nPosIndex<0) return nullptr;
1061  const auto nNegIndex(TMath::Abs(pV0RD->GetNindex())); if (nNegIndex<0) return nullptr;
1062 
1063  auto pDauPosRD(fEventESD->GetTrack(nPosIndex)); if (!pDauPosRD) return nullptr;
1064  auto pDauNegRD(fEventESD->GetTrack(nNegIndex)); if (!pDauNegRD) return nullptr;
1065 
1066  const auto dMegField(fEventESD->GetMagneticField());
1067  const auto dPosDCAtoPV(TMath::Abs(pDauPosRD->GetD(fPrimaryVtx[0],fPrimaryVtx[1],dMegField)));
1068  if (dPosDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
1069 
1070  const auto dNegDCAtoPV(TMath::Abs(pDauNegRD->GetD(fPrimaryVtx[0],fPrimaryVtx[1],dMegField)));
1071  if (dNegDCAtoPV<fCutMinDauDCAtoPV) return nullptr;
1072 //=============================================================================
1073 
1074  if (!(pDauPosRD->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
1075  if (!(pDauNegRD->GetStatus() & AliESDtrack::kTPCrefit)) return nullptr;
1076  if ((pDauPosRD->GetKinkIndex(0)>0) || (pDauNegRD->GetKinkIndex(0)>0)) return nullptr;
1077 
1078  const auto dPosXrowsTPC(pDauPosRD->GetTPCClusterInfo(2,1));
1079  const auto dNegXrowsTPC(pDauNegRD->GetTPCClusterInfo(2,1));
1080  const auto dDauXrowsTPC((dPosXrowsTPC<dNegXrowsTPC) ? dPosXrowsTPC : dNegXrowsTPC);
1081  if (dDauXrowsTPC<fCutMinDauXrowsTPC) return nullptr;
1082 
1083  const auto wPosTPCNClsF(pDauPosRD->GetTPCNclsF()); if (wPosTPCNClsF<=0) return nullptr;
1084  const auto wNegTPCNClsF(pDauNegRD->GetTPCNclsF()); if (wNegTPCNClsF<=0) return nullptr;
1085  const auto dPosXrowsOverFindableClusTPC( ((Double_t)dPosXrowsTPC) / ((Double_t)wPosTPCNClsF) );
1086  const auto dNegXrowsOverFindableClusTPC( ((Double_t)dNegXrowsTPC) / ((Double_t)wNegTPCNClsF) );
1087 
1088  const auto dDauXrowsOverFindableClusTPC((dPosXrowsOverFindableClusTPC<dNegXrowsOverFindableClusTPC) ?
1089  dPosXrowsOverFindableClusTPC :
1090  dNegXrowsOverFindableClusTPC);
1091  if (dDauXrowsOverFindableClusTPC<fCutMinDauXrowsOverFindableClusTPC) return nullptr;
1092 //=============================================================================
1093 
1094  const auto nPosCharge(pDauPosRD->Charge());
1095  const auto nNegCharge(pDauNegRD->Charge());
1096  if ((nPosCharge==0) || (nNegCharge==0) || (nPosCharge==nNegCharge)) return nullptr;
1097 
1098  Double_t dPosPxPyPz[3] = { 0., 0., 0. };
1099  Double_t dNegPxPyPz[3] = { 0., 0., 0. };
1100  if ((nPosCharge<0) && (nNegCharge>0)) {
1101  pDauPosRD = fEventESD->GetTrack(nNegIndex);
1102  pDauNegRD = fEventESD->GetTrack(nPosIndex);
1103 
1104  pV0RD->GetNPxPyPz(dPosPxPyPz[0], dPosPxPyPz[1], dPosPxPyPz[2]);
1105  pV0RD->GetPPxPyPz(dNegPxPyPz[0], dNegPxPyPz[1], dNegPxPyPz[2]);
1106  } else {
1107  pV0RD->GetPPxPyPz(dPosPxPyPz[0], dPosPxPyPz[1], dPosPxPyPz[2]);
1108  pV0RD->GetNPxPyPz(dNegPxPyPz[0], dNegPxPyPz[1], dNegPxPyPz[2]);
1109  }
1110 
1111  const TVector3 v3Pos(dPosPxPyPz);
1112  const TVector3 v3Neg(dNegPxPyPz);
1113  if ((v3Pos.Pt()<fCutMinDauPt) || (v3Neg.Pt()<fCutMinDauPt)) return nullptr;
1114  const auto dPosEta(v3Pos.Eta()); if ((dPosEta<fCutMinDauEta) || (dPosEta>fCutMaxDauEta)) return nullptr;
1115  const auto dNegEta(v3Neg.Eta()); if ((dNegEta<fCutMinDauEta) || (dNegEta>fCutMaxDauEta)) return nullptr;
1116 //=============================================================================
1117 
1118  AliMCParticle *pDauTmpMC(nullptr);
1119  const auto inp(TMath::Abs(pDauPosRD->GetLabel())); if (inp<0) return nullptr;
1120  pDauTmpMC = static_cast<AliMCParticle*>(MCEvent()->GetTrack(inp)); if (!pDauTmpMC) return nullptr;
1121  const auto pDauPosMC(pDauTmpMC->Particle()); if (!pDauPosMC) return nullptr;
1122  const auto imp(pDauPosMC->GetFirstMother()); if (imp<0) return nullptr;
1123 
1124  const auto inn(TMath::Abs(pDauNegRD->GetLabel())); if (inn<0) return nullptr;
1125  pDauTmpMC = static_cast<AliMCParticle*>(MCEvent()->GetTrack(inn)); if (!pDauTmpMC) return nullptr;
1126  const auto pDauNegMC(pDauTmpMC->Particle()); if (!pDauNegMC) return nullptr;
1127  const auto imn(pDauNegMC->GetFirstMother()); if (imn<0) return nullptr;
1128 
1129  if (imp != imn) return nullptr;
1130  pDauTmpMC = static_cast<AliMCParticle*>(MCEvent()->GetTrack(imp)); if (!pDauTmpMC) return nullptr;
1131  const auto pV0MC(pDauTmpMC->Particle()); if (!pV0MC) return nullptr;
1132  if (((pV0MC->Y())<fCutMinV0Rap) || ((pV0MC->Y())>fCutMaxV0Rap)) return nullptr;
1133 
1134  const auto idvMC(pV0MC->GetPdgCode());
1135  const auto idp(pDauPosMC->GetPdgCode());
1136  const auto idn(pDauNegMC->GetPdgCode());
1137  auto bIsKshort((idp==211) && (idn==-211) && (idvMC== 310));
1138  auto bIsLambda((idp==2212) && (idn==-211) && (idvMC== 3122));
1139  auto bIsAntiLa((idp==211) && (idn==-2212) && (idvMC==-3122));
1140  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
1141 //=============================================================================
1142 
1143  UInt_t wsvMC(0);
1144  if (imp<pStack->GetNprimary()) wsvMC |= AliPicoBase::kPrimary;
1145  if (pStack->IsPhysicalPrimary(imp)) wsvMC |= AliPicoBase::kPhysicalPrimary;
1146  if (pStack->IsSecondaryFromWeakDecay(imp)) wsvMC |= AliPicoBase::kSecondaryFromWeakDecay;
1147  if (pStack->IsSecondaryFromMaterial(imp)) wsvMC |= AliPicoBase::kSecondaryFromMaterial;
1148 
1149  auto idmMC(0);
1150  UInt_t wsmMC(0);
1151  auto dMotherPt(0.);
1152  auto dMotherEta(0.);
1153  auto dMotherRap(0.);
1154  if (bIsLambda || bIsAntiLa) {
1155  const auto imv(pV0MC->GetFirstMother());
1156 
1157  if (imv>=0) {
1158  pDauTmpMC = static_cast<AliMCParticle*>(MCEvent()->GetTrack(imv));
1159 
1160  if (pDauTmpMC) {
1161  auto pMother(pDauTmpMC->Particle());
1162 
1163  if (pMother) {
1164  idmMC = pMother->GetPdgCode();
1165  if ((bIsLambda && ((idmMC== 3312) || (idmMC== 3322))) ||
1166  (bIsAntiLa && ((idmMC==-3312) || (idmMC==-3322)))) {
1167  dMotherPt = pMother->Pt();
1168  dMotherEta = pMother->Eta();
1169  dMotherRap = pMother->Y();
1170 
1171  if (imp<pStack->GetNprimary()) wsmMC |= AliPicoBase::kPrimary;
1172  if (pStack->IsPhysicalPrimary(imv)) wsmMC |= AliPicoBase::kPhysicalPrimary;
1173  if (pStack->IsSecondaryFromWeakDecay(imv)) wsmMC |= AliPicoBase::kSecondaryFromWeakDecay;
1174  if (pStack->IsSecondaryFromMaterial(imv)) wsmMC |= AliPicoBase::kSecondaryFromMaterial;
1175  }
1176  }
1177  }
1178  }
1179  }
1180 //=============================================================================
1181 
1182  const auto dV0CosPA(pV0RD->GetV0CosineOfPointingAngle(fPrimaryVtx[0],fPrimaryVtx[1],fPrimaryVtx[2]));
1183 
1184  if (bIsKshort) if (dV0CosPA<fCutMinKshortCosPA) {
1185  bIsKshort = kFALSE;
1186  }
1187 
1188  if (bIsLambda || bIsAntiLa) if (dV0CosPA<fCutMinLambdaCosPA) {
1189  bIsLambda = kFALSE;
1190  bIsAntiLa = kFALSE;
1191  }
1192 
1193  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
1194 //=============================================================================
1195 
1196  auto dV0DistToPV(0.);
1197  for (auto i=0; i<3; ++i) dV0DistToPV += ((dV0Vtx[i]-fPrimaryVtx[i]) * (dV0Vtx[i]-fPrimaryVtx[i]));
1198  const auto dV0DistToPVoverP(TMath::Sqrt(dV0DistToPV) / (pV0RD->P()+1e-10));
1199 
1200  if (bIsKshort) if ((dV0DistToPVoverP*AliPicoBase::MassKshort())>fCutMaxKshortCtau) {
1201  bIsKshort = kFALSE;
1202  }
1203 
1204  if (bIsLambda || bIsAntiLa) if ((dV0DistToPVoverP*AliPicoBase::MassLambda())>fCutMaxLambdaCtau) {
1205  bIsLambda = kFALSE;
1206  bIsAntiLa = kFALSE;
1207  }
1208 
1209  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
1210 //=============================================================================
1211 
1212  const auto dV0ArmFrac(pV0RD->PtArmV0() / (TMath::Abs(pV0RD->AlphaV0())+1e-12));
1213 
1214  if (bIsKshort && (fCutMaxKshortArmFrac>0.)) if (dV0ArmFrac>fCutMaxKshortArmFrac) {
1215  bIsKshort = kFALSE;
1216  }
1217 
1218  if ((bIsLambda && bIsAntiLa) && (fCutMaxLambdaArmFrac>0.)) if (dV0ArmFrac>fCutMaxLambdaArmFrac) {
1219  bIsLambda = kFALSE;
1220  bIsAntiLa = kFALSE;
1221  }
1222 
1223  if (!(bIsKshort || bIsLambda || bIsAntiLa)) return nullptr;
1224 //=============================================================================
1225 
1226  UInt_t wMask(0);
1227  if (bIsKshort) {
1228  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
1229  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
1230 
1231  const auto dKshortInvM((vPosPion+vNegPion).M());
1232  if ((dKshortInvM<(0.430006 - 0.0110029*dV0Pt)) ||
1233  (dKshortInvM>(0.563707 + 0.0114979*dV0Pt))) return nullptr;
1234 
1235  if (fCutMinKshortDeltaM>0.) {
1236  TLorentzVector vPosProton; vPosProton.SetVectM(v3Pos, AliPicoBase::MassProton());
1237  TLorentzVector vNegProton; vNegProton.SetVectM(v3Neg, AliPicoBase::MassProton());
1238  if ((TMath::Abs((vPosProton+vNegPion).M()-AliPicoBase::MassLambda())<fCutMinKshortDeltaM) ||
1239  (TMath::Abs((vNegProton+vPosPion).M()-AliPicoBase::MassLambda())<fCutMinKshortDeltaM)) return nullptr;
1240  }
1241 
1242  wMask = AliPicoBase::kKshort;
1243  }
1244 
1245  if (bIsLambda) {
1246  TLorentzVector vPosProton; vPosProton.SetVectM(v3Pos, AliPicoBase::MassProton());
1247  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
1248 
1249  const auto dLambdaInvM((vPosProton+vNegPion).M());
1250  if ((dLambdaInvM<(1.09501 - 0.00523272*dV0Pt - 0.075269*TMath::Exp(-3.46339*dV0Pt))) ||
1251  (dLambdaInvM>(1.13688 + 0.00527838*dV0Pt + 0.084222*TMath::Exp(-3.80595*dV0Pt)))) return nullptr;
1252 
1253  if (fCutMinLambdaDeletaM>0.) {
1254  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
1255  if ((TMath::Abs((vPosPion+vNegPion).M()-AliPicoBase::MassKshort())<fCutMinLambdaDeletaM)) return nullptr;
1256  }
1257 
1258  wMask = AliPicoBase::kLambda;
1259  }
1260 
1261  if (bIsAntiLa) {
1262  TLorentzVector vNegProton; vNegProton.SetVectM(v3Neg, AliPicoBase::MassProton());
1263  TLorentzVector vPosPion; vPosPion.SetVectM(v3Pos, AliPicoBase::MassPion());
1264 
1265  const auto dAntiLaInvM((vNegProton+vPosPion).M());
1266  if ((dAntiLaInvM<(1.09501 - 0.00523272*dV0Pt - 0.075269*TMath::Exp(-3.46339*dV0Pt))) ||
1267  (dAntiLaInvM>(1.13688 + 0.00527838*dV0Pt + 0.084222*TMath::Exp(-3.80595*dV0Pt)))) return nullptr;
1268 
1269  if (fCutMinLambdaDeletaM>0.) {
1270  TLorentzVector vNegPion; vNegPion.SetVectM(v3Neg, AliPicoBase::MassPion());
1271  if ((TMath::Abs((vPosPion+vNegPion).M()-AliPicoBase::MassKshort())<fCutMinLambdaDeletaM)) return nullptr;
1272  }
1273 
1274  wMask = AliPicoBase::kAntiLambda;
1275  }
1276 //=============================================================================
1277 
1278  auto bPosInJC(kFALSE);
1279  auto bNegInJC(kFALSE);
1280  return (new AliPicoV0MC(wMask,
1281  dV0Radius,
1282  dV0CosPA,
1283  dV0DistToPVoverP,
1284  dDausDCA,
1285  dPosDCAtoPV,
1286  dNegDCAtoPV,
1287  dDauXrowsTPC,
1288  dDauXrowsOverFindableClusTPC,
1289  v3Pos.Px(), v3Pos.Py(), v3Pos.Pz(),
1290  v3Neg.Px(), v3Neg.Py(), v3Neg.Pz(),
1291  bPosInJC, bNegInJC,
1292  idvMC, wsvMC, pV0MC->Px(), pV0MC->Py(), pV0MC->Pz(), pV0MC->Energy(),
1293  idmMC, wsmMC, dMotherPt, dMotherEta, dMotherRap));
1294 }
1295 
1296 //_____________________________________________________________________________
1298 {
1299 //
1300 // AliAnalysisTaskSEPicoV0Maker::IsEventNotAcpt
1301 //
1302 
1303  fEventAcptMask = 0;
1304  if (!InputEvent()) return kTRUE;
1305  if (!fInputHandler) return kTRUE;
1306 
1307  fEventAOD = dynamic_cast<AliAODEvent*>(InputEvent());
1308  fEventESD = dynamic_cast<AliESDEvent*>(InputEvent());
1309  if ((!fEventAOD) && (!fEventESD)) return kTRUE;
1310 //=============================================================================
1311 
1312  fRespoPID = fInputHandler->GetPIDResponse();
1313  if (!fRespoPID) return kTRUE;
1314 //=============================================================================
1315 
1316  if (fIsAnaUseMC) {
1317  if (MCEvent()) {
1318  if (MCEvent()->GetNumberOfTracks()<=0) return kTRUE;
1319  } else {
1320  return kTRUE;
1321  }
1322 
1323  const auto pHeader(MCEvent()->Header()); if (!pHeader) return kTRUE;
1324 
1325  if (fIsDPMjetMC) {
1326  const auto pDPMjetH(dynamic_cast<AliGenDPMjetEventHeader*>(pHeader->GenEventHeader()));
1327 
1328  if (pDPMjetH) {
1329  auto nd0(0), nd1(0), nd2(0);
1330  pDPMjetH->GetNDiffractive(nd1, nd2, nd0);
1331  if ((nd1+nd2) != (pDPMjetH->ProjectileParticipants() + pDPMjetH->TargetParticipants())) return kTRUE;
1332  }
1333  }
1334  }
1335 
1337 //=============================================================================
1338 
1339  if ((fMultEsti.GetEntries()>0) || (!fMultEstDef.IsNull())) {
1340  Float_t dMult(-999.);
1341 
1342  if (fUseMultOld) {
1343  auto pCentSel(InputEvent()->GetCentrality());
1344  if (!pCentSel) { fEventAcptMask=0; return kTRUE; }
1345  if (pCentSel->GetQuality()!=0) return kFALSE;
1346 
1347  if (fMultEsti.GetEntries()>0) {
1348  TObjString *ps(nullptr);
1349  const auto next(fMultEsti.MakeIterator());
1350  while ((ps = static_cast<TObjString*>((*next)()))) {
1351  const auto s(ps->String());
1352  const auto p(static_cast<TParameter<Float_t>*>((fMultEsti(s.Data()))));
1353  if (p) p->SetVal(pCentSel->GetCentralityPercentile(s.Data()));
1354  }
1355  }
1356 
1357  if (!fMultEstDef.IsNull()) dMult = pCentSel->GetCentralityPercentile(fMultEstDef.Data());
1358  } else {
1359  auto pMultSel(static_cast<AliMultSelection*>(InputEvent()->FindListObject("MultSelection")));
1360  if (!pMultSel) { fEventAcptMask=0; return kTRUE; }
1361 
1362  if (fMultEsti.GetEntries()>0) {
1363  TObjString *ps(nullptr);
1364  const auto next(fMultEsti.MakeIterator());
1365  while (((ps = static_cast<TObjString*>((*next)())))) {
1366  const auto s(ps->String());
1367  const auto p(static_cast<TParameter<Float_t>*>(fMultEsti(s.Data())));
1368  if (p) p->SetVal(pMultSel->GetMultiplicityPercentile(s.Data()));
1369  }
1370  }
1371 
1372  if (!fMultEstDef.IsNull()) dMult = pMultSel->GetMultiplicityPercentile(fMultEstDef.Data());
1373  }
1374 
1375  if (!fMultEstDef.IsNull()) if ((dMult<fCutMinMult) || (dMult>=fCutMaxMult)) return kFALSE;
1376  }
1377 
1379 //=============================================================================
1380 
1381  const UInt_t wMask(fInputHandler->IsEventSelected());
1382  if ((wMask & fTriggerMask) != fTriggerMask) return kFALSE;
1383  if (fIsSkipFastOnly) if ((wMask & AliVEvent::kFastOnly) == AliVEvent::kFastOnly) return kFALSE;
1384 
1386 //=============================================================================
1387 
1388  const auto pVertex(InputEvent()->GetPrimaryVertex());
1389  if (!pVertex) return kFALSE;
1390  pVertex->GetXYZ(fPrimaryVtx);
1391 
1392  if (fUseAnaUtils) {
1393  auto pUtils(new AliAnalysisUtils());
1394  if (!pUtils->IsVertexSelected2013pA(InputEvent())) return kFALSE;
1395  if (pUtils->IsSPDClusterVsTrackletBG(InputEvent())) return kFALSE;
1396  if (pUtils->IsPileUpEvent(InputEvent())) return kFALSE;
1397 
1398  if ((fCollisionType==(AliPicoBase::kPA)) ||
1400  if (pUtils->IsFirstEventInChunk(InputEvent())) return kFALSE;
1401  }
1402  }
1403 
1404 /*if ((fCollisionType==(AliPicoBase::kPA)) || (fCollisionType==(AliPicoBase::kAP))) {
1405  if (fEventAOD) {
1406  const AliAODVertex *pVtxSPD = fEventAOD->GetPrimaryVertexSPD();
1407  const AliAODVertex *pVtxTrk = fEventAOD->GetPrimaryVertex();
1408  if ((!pVtxSPD) && (!pVtxTrk)) return (fEventAcptMask==0);
1409  }
1410 
1411  if (fEventESD) {
1412  Bool_t fHasVertex = kFALSE;
1413  const AliESDVertex *pVtxESD = fEventESD->GetPrimaryVertexTracks();
1414  if (pVtxESD->GetNContributors()<1) {
1415  pVtxESD = fEventESD->GetPrimaryVertexSPD();
1416  if (pVtxESD->GetNContributors()<1) fHasVertex = kFALSE;
1417  else fHasVertex = kTRUE;
1418 
1419  Double_t cov[6] = { 0., 0., 0., 0., 0., 0. };
1420  pVtxESD->GetCovarianceMatrix(cov);
1421  Double_t zRes = TMath::Sqrt(cov[5]);
1422  if (pVtxESD->IsFromVertexerZ() && (zRes>0.25)) fHasVertex = kFALSE;
1423  } else fHasVertex = kTRUE;
1424 
1425  if (!fHasVertex) return (fEventAcptMask==0);
1426  }
1427  } else {
1428  if (fEventAOD) {
1429  const auto pVtxSPD(fEventAOD->GetPrimaryVertexSPD()); if (!pVtxSPD) return (fEventAcptMask==0);
1430  const auto pVtxTrk(fEventAOD->GetPrimaryVertex()); if (!pVtxTrk) return (fEventAcptMask==0);
1431  }
1432 
1433  if (fEventESD) {
1434  const auto pVtxPri(fEventESD->GetPrimaryVertex()); if (!pVtxPri) return (fEventAcptMask==0);
1435  const auto pVtxSPD(fEventESD->GetPrimaryVertexSPD()); if (!pVtxSPD) return (fEventAcptMask==0);
1436  const auto pVtxTrk(fEventESD->GetPrimaryVertexTracks()); if (!pVtxTrk) return (fEventAcptMask==0);
1437  if ((!(pVtxPri->GetStatus())) &&
1438  (!(pVtxSPD->GetStatus())) &&
1439  (!(pVtxTrk->GetStatus()))) return (fEventAcptMask==0);
1440  }
1441  }*/
1442 
1444 //=============================================================================
1445 
1446  if (fIsRefitV0sESD && fEventESD) {
1447  Double_t dCuts[7] = { fCutMaxV0Chi2,
1453  fCutMaxV0Radius };
1454 
1455  fEventESD->ResetV0s();
1456  AliV0vertexer aV0vtxer;
1457  aV0vtxer.SetDefaultCuts(dCuts);
1458  aV0vtxer.Tracks2V0vertices(fEventESD);
1459  }
1460 //=============================================================================
1461 
1462  return kFALSE;
1463 }
1464 
1465 //_____________________________________________________________________________
1467 {
1468 //
1469 // AliAnalysisTaskSEPicoV0Maker::IsEventNotINEL
1470 //
1471 
1472  if ((fEventAcptMask & AliPicoBase::kEventCheck) != AliPicoBase::kEventCheck) return kTRUE;
1473  if ((fEventAcptMask & AliPicoBase::kEventMult) != AliPicoBase::kEventMult) return kTRUE;
1474 
1475  return kFALSE;
1476 }
1477 
1478 //_____________________________________________________________________________
1480 {
1481 //
1482 // AliAnalysisTaskSEPicoV0Maker::IsEventNotMBsa
1483 //
1484 
1485  if (IsEventNotINEL()) return kTRUE;
1486  if ((fEventAcptMask & AliPicoBase::kEventTrigger) != AliPicoBase::kEventTrigger) return kTRUE;
1487  if ((fEventAcptMask & AliPicoBase::kEventVertex) != AliPicoBase::kEventVertex) return kTRUE;
1488 
1489  return kFALSE;
1490 }
1491 
1492 //_____________________________________________________________________________
1494 {
1495 //
1496 // AliAnalysisTaskSEPicoV0Maker::FillHistogramsEH
1497 //
1498 
1499  const auto h(static_cast<TH1D*>(fOutputListEH->FindObject("hEventCheck")));
1500 
1501  if (fEventAcptMask==0) h->Fill(0.);
1502  if ((fEventAcptMask & AliPicoBase::kEventCheck) == AliPicoBase::kEventCheck) h->Fill(1.);
1503  if ((fEventAcptMask & AliPicoBase::kEventMult) == AliPicoBase::kEventMult) h->Fill(2.);
1504  if ((fEventAcptMask & AliPicoBase::kEventTrigger) == AliPicoBase::kEventTrigger) h->Fill(3.);
1505  if ((fEventAcptMask & AliPicoBase::kEventVertex) == AliPicoBase::kEventVertex) h->Fill(4.);
1506 
1507  return;
1508 }
1509 
1510 //_____________________________________________________________________________
1512 {
1513 //
1514 // AliAnalysisTaskSEPicoV0Maker::FillHistogramsMC
1515 //
1516 
1517  auto nPrimary(0);
1518  AliStack *pStack(nullptr);
1519 
1520  if (fEventESD) {
1521  pStack = MCEvent()->Stack(); if (!pStack) return;
1522  nPrimary = pStack->GetNprimary();
1523  }
1524 //=============================================================================
1525 
1526  const auto n(6+fMultEsti.GetEntries());
1527  const auto dEvType(IsEventNotMBsa() ? 1.5 : 0.5);
1528  auto hsV0(static_cast<THnSparseD*>(fOutputListMC->FindObject("hsV0")));
1529  auto hsXi(static_cast<THnSparseD*>(fOutputListMC->FindObject("hsXi")));
1530 
1531  if (!(hsV0 && hsXi)) {
1532  AliFatal("Cannot find hsV0 or hsXi; should not happen");
1533  return;
1534  }
1535 //=============================================================================
1536 
1537  for (auto i=0; i<MCEvent()->GetNumberOfTracks(); ++i) {
1538  TParticle *pESD(nullptr);
1539  AliAODMCParticle *pAOD(nullptr);
1540 
1541  if (fEventAOD) {
1542  pAOD = static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(i));
1543  if (!pAOD) continue;
1544  }
1545 
1546  if (fEventESD) {
1547  const auto pMC(static_cast<AliMCParticle*>(MCEvent()->GetTrack(i))); if (!pMC) continue;
1548  pESD = pMC->Particle(); if (!pESD) continue;
1549  }
1550 //=============================================================================
1551 
1552  const auto bPri(pAOD ? pAOD->IsPrimary() : (i<nPrimary));
1553  const auto bPhy(pAOD ? pAOD->IsPhysicalPrimary() : pStack->IsPhysicalPrimary(i));
1554  if (!(bPri || bPhy)) continue;
1555 //=============================================================================
1556 
1557  const auto id(pAOD ? pAOD->GetPdgCode() : pESD->GetPdgCode());
1558 
1559  const auto bXi(bPri && ((id==3312) || (id==-3312)));
1560  const auto bV0(bPhy && ((id==3122) || (id==-3122) || (id==310)));
1561  if (!(bXi || bV0)) continue;
1562 //=============================================================================
1563 
1564  const auto dEta(pAOD ? pAOD->Eta() : pESD->Eta());
1565  if ((dEta<-5.) || (dEta>=5.)) continue;
1566 
1567  const auto dRapLab(pAOD ? pAOD->Y() : pESD->Y());
1568  if ((dRapLab<-5.) || (dRapLab>=5.)) continue;
1569 
1570  const auto dRapCMS(dRapLab + fRapidityShift);
1571  if ((dRapCMS<-5.) || (dRapCMS>=5.)) continue;
1572 //=============================================================================
1573 
1574  Double_t dVar[n];
1575  dVar[0] = (pAOD ? pAOD->Pt() : pESD->Pt());
1576 
1577  dVar[1] = dEta;
1578  dVar[2] = dRapLab;
1579  dVar[3] = dRapCMS;
1580  dVar[4] = dEvType;
1581 
1582  auto l(6);
1583  TObjString *ps(nullptr);
1584  const auto next(fMultEsti.MakeIterator());
1585  while ((ps = static_cast<TObjString*>((*next)()))) {
1586  const auto s(ps->String());
1587  const auto p(static_cast<TParameter<Float_t>*>(fMultEsti(s.Data())));
1588  if (p) dVar[l++] = p->GetVal();
1589  }
1590 
1591  if (bV0) {
1592  if (id== 310 ) dVar[5] = 0.;
1593  if (id== 3122) dVar[5] = 1.;
1594  if (id==-3122) dVar[5] = 2.;
1595  hsV0->Fill(dVar);
1596  }
1597 
1598  if (bXi) {
1599  if (id== 3312) dVar[5] = 0.;
1600  if (id==-3312) dVar[5] = 1.;
1601  hsXi->Fill(dVar);
1602  }
1603  }
1604 //=============================================================================
1605 
1606  return;
1607 }
1608 
1609 //_____________________________________________________________________________
1611 {
1612 //
1613 // AliAnalysisTaskSEPicoV0Maker::CreateHistogramsEH
1614 //
1615 
1616  const auto b(TH1::AddDirectoryStatus());
1617  TH1::AddDirectory(kFALSE);
1618 //=============================================================================
1619 
1620  fOutputListEH->Add(new TH1D("hEventCheck", "", 5, -0.5, 4.5));
1621  fOutputListEH->Add(new TH2D("hKshortPtInvM", "", 1000, 0., 100., 300, AliPicoBase::MassKshort()-0.15,
1622  AliPicoBase::MassKshort()+0.15));
1623 
1624  fOutputListEH->Add(new TH2D("hLambdaPtInvM", "", 1000, 0., 100., 200, AliPicoBase::MassLambda()-0.10,
1625  AliPicoBase::MassLambda()+0.10));
1626 
1627  fOutputListEH->Add(new TH2D("hAntiLaPtInvM", "", 1000, 0., 100., 200, AliPicoBase::MassLambda()-0.10,
1628  AliPicoBase::MassLambda()+0.10));
1629 
1630  TH1 *h(nullptr);
1631  TListIter next(fOutputListEH);
1632  while ((h = static_cast<TH1*>(next()))) h->Sumw2();
1633 
1634  TH1::AddDirectory(b);
1635  return;
1636 }
1637 
1638 //_____________________________________________________________________________
1640 {
1641 //
1642 // AliAnalysisTaskSEPicoV0Maker::CreateHistogramsMC
1643 //
1644 
1645  const auto b(TH1::AddDirectoryStatus());
1646  TH1::AddDirectory(kFALSE);
1647 //=============================================================================
1648 
1649  const auto nr(5); // 0: Pt
1650  // 1: eta
1651  // 2: rap in Lab
1652  // 3: rap in CMS
1653  // 4: Event type
1654  // ==0.5, INEL
1655  // ==1.5, MB
1656  // 5: particle type
1657  // V0
1658  // ==0, Kshort
1659  // ==1, Lambda
1660  // ==2, AntiLa
1661  // Xi
1662  // ==0, XiNeg
1663  // ==1, XiPos
1664  const Int_t nBin[nr] = { 1000, 100, 100, 100, 2 };
1665  const Double_t dMin[nr] = { 0., -5., -5., -5., 0. };
1666  const Double_t dMax[nr] = { 100., 5., 5., 5., 2. };
1667  const auto ns(1 + nr + fMultEsti.GetEntries());
1668 //=============================================================================
1669 
1670  Int_t nV0Bin[ns], nXiBin[ns];
1671  Double_t dV0Min[ns], dV0Max[ns];
1672  Double_t dXiMin[ns], dXiMax[ns];
1673 
1674  for (auto i=0; i<ns; ++i) {
1675  if (i<nr) {
1676  nV0Bin[i] = nXiBin[i] = nBin[i];
1677  dV0Min[i] = dXiMin[i] = dMin[i];
1678  dV0Max[i] = dXiMax[i] = dMax[i];
1679  }
1680 
1681  if (i==nr) {
1682  nV0Bin[i] = 3; dV0Min[i] = -0.5; dV0Max[i] = 2.5;
1683  nXiBin[i] = 2; dXiMin[i] = -0.5; dXiMax[i] = 1.5;
1684  }
1685 
1686  if (i>nr) {
1687  nV0Bin[i] = nXiBin[i] = 110;
1688  dV0Min[i] = dXiMin[i] = -5.;
1689  dV0Max[i] = dXiMax[i] = 105.;
1690  }
1691  }
1692 //=============================================================================
1693 
1694  const TString sa[nr+1] { "pT", "eta", "y_lab", "y_cms", "evt_t", "par_t" };
1695  fOutputListMC->Add(new THnSparseD("hsV0", "", ns, nV0Bin, dV0Min, dV0Max));
1696  fOutputListMC->Add(new THnSparseD("hsXi", "", ns, nXiBin, dXiMin, dXiMax));
1697 
1698  TObjString *ps(nullptr);
1699  THnSparseD *hs(nullptr);
1700  TListIter next(fOutputListMC);
1701  const auto pn(fMultEsti.MakeIterator());
1702  while ((hs = static_cast<THnSparseD*>(next()))) {
1703  for (auto i=0; i<nr; ++i) hs->GetAxis(i)->SetName(sa[i].Data());
1704 
1705  auto l(nr);
1706  while ((ps = static_cast<TObjString*>((*pn)()))) {
1707  const auto s(ps->String());
1708  const auto p(hs->GetAxis(l++));
1709  if (p) p->SetName(s.Data());
1710  }
1711  }
1712 //=============================================================================
1713 
1714  TH1::AddDirectory(b);
1715 
1716  return;
1717 }
1718 
1719 //_____________________________________________________________________________
1721 {
1722 //
1723 // AliAnalysisTaskSEPicoV0Maker::InitAnalysis
1724 //
1725 
1730 
1731  return;
1732 }
1733 
1734 //_____________________________________________________________________________
1736 {
1737 //
1738 // AliAnalysisTaskSEPicoV0Maker::InitParametersPP
1739 //
1740 
1741  fRapidityShift = 0.;
1742 //=============================================================================
1743 
1744  fCutMaxV0Chi2 = 33.;
1745  fCutMinV0Radius = 0.3; // default: >0.5; uncertainty: >0.3, 0.4, 0.6, 0.7;
1746  fCutMaxV0Radius = 200.; // default: not applied in pp
1747 //=============================================================================
1748 
1749  fCutMaxDausDCA = 1.5; // default: <1; uncertainty: <0.5, 0.75, 1.25, 1.5
1750  fCutMinDauDCAtoPV = 0.05; // default: >0.06; uncertainty: >0.05, 0.055, 0.07, 0.08
1751  fCutMinDauXrowsTPC = 70.; // default: >70; uncertainty: >75, 80
1752  fCutMinDauXrowsOverFindableClusTPC = 0.8; // default: >0.8; uncertainty: >0.95
1753 //=============================================================================
1754 
1755  fCutMaxKshortSigmaTPC = -1.; // default: <5; uncertainty: w/o cut
1756  fCutMinKshortCosPA = 0.95; // default: >0.97; uncertainty: >0.95, 0.96, 0.98, 0.99
1757  fCutMaxKshortCtau = 30.; // default: <20; uncertainty: <12, 30
1758  fCutMaxKshortArmFrac = -1.; // default: not applied in pp
1759  fCutMinKshortDeltaM = 0.003; // default: >0.005; uncertainty: >0.003, 0.006
1760 //=============================================================================
1761 
1762  fCutMaxLambdaSigmaTPC = 7.; // default: <5; uncertainty: 4, 6, 7
1763  fCutMinLambdaCosPA = 0.993; // default: >0.995; uncertainty: >0.993, 0.994, 0.996, 0.997
1764  fCutMaxLambdaCtau = 40.; // default: <30; uncertainty: <20, 40
1765  fCutMaxLambdaArmFrac = -1.; // default: not applied in pp
1766  fCutMinLambdaDeletaM = -1.; // default: >0.01; uncertainty: w/o rejection
1767 
1768  return;
1769 }
1770 
1771 //_____________________________________________________________________________
1773 {
1774 //
1775 // AliAnalysisTaskSEPicoV0Maker::InitParametersPA
1776 //
1777 
1778  InitParamsPP();
1779 
1780  fRapidityShift = 0.465;
1781 
1782  fCutMaxLambdaSigmaTPC = 6; // default: <5; uncertaity: <4, 6
1783 
1784  return;
1785 }
1786 
1787 //_____________________________________________________________________________
1789 {
1790 //
1791 // AliAnalysisTaskSEPicoV0Maker::InitParametersAP
1792 //
1793 
1794  InitParamsPP();
1795 
1796  fRapidityShift = -0.465;
1797 
1798  fCutMaxLambdaSigmaTPC = 6; // default: <5; uncertaity: <4, 6
1799 
1800  return;
1801 }
1802 
1803 //_____________________________________________________________________________
1805 {
1806 //
1807 // AliAnalysisTaskSEPicoV0Maker::InitParametersAA
1808 //
1809 
1810  InitParamsPP();
1811 
1812  fCutMinV0Radius = 0.9; // default: 5; uncertainty: varying around
1813  fCutMaxV0Radius = 100.;
1814 
1815 //fCutMinDauPt = 0.16; // default: 0.16
1816  fCutMinDauDCAtoPV = 0.08; // default: 0.1; uncertainty: 0.08, 0.12
1817 
1818  fCutMaxKshortSigmaTPC = 6; // default: <5; uncertainty: <4, 6;
1819  fCutMinKshortCosPA = 0.997; // default: >0.998; uncertainty: 0.997, 0.999
1820  fCutMaxKshortArmFrac = 0.2; // default: <0.2
1821 
1822  fCutMaxLambdaSigmaTPC = 6; // default: <5; uncertaity: <4, 6
1823  fCutMinLambdaCosPA = 0.997; // default: >0.998; uncertainty: 0.997, 0.999
1824  fCutMinLambdaDeletaM = 0.008; // default: >0.01; uncertainty: 0.008, 0.012
1825 
1826  return;
1827 }
void FillLambdaPtInvM(TH2D *const h, Double_t const *dCuts=nullptr) const
Definition: AliPicoV0.cxx:260
double Double_t
Definition: External.C:58
void FillKshortPtInvM(TH2D *const h, Double_t const *dCuts=nullptr) const
Definition: AliPicoV0.cxx:242
char Char_t
Definition: External.C:18
Double_t MassLambda()
Definition: AliPicoBase.h:44
Double_t MassPion()
Definition: AliPicoBase.h:41
Double_t MassProton()
Definition: AliPicoBase.h:43
Double_t MassKshort()
Definition: AliPicoBase.h:42
void FillAntiLaPtInvM(TH2D *const h, Double_t const *dCuts=nullptr) const
Definition: AliPicoV0.cxx:278
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
AliPicoV0MC * SelectV0CandidateMC(AliAODv0 const *pV0)
Definition: External.C:228
Definition: External.C:212
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
AliPicoV0RD * SelectV0CandidateRD(AliAODv0 const *pV0)
Definition: External.C:196