AliPhysics  master (3d17d9d)
AliHFAODMCParticleContainer.cxx
Go to the documentation of this file.
1 /*************************************************************************
2 * Copyright(c) 1998-2016, 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 
16 #include <TClonesArray.h>
17 #include <AliAODMCParticle.h>
18 #include <AliLog.h>
19 
21 
25 
29  fSpecialPDG(0),
30  fSpecialIndex(-10),
31  fRejectedOrigin(0),
32  fAcceptedDecay(0),
33  fRejectISR(kFALSE),
34  fHistOrigin(0)
35 {
36  // Constructor.
37 }
38 
44  fSpecialPDG(0),
45  fSpecialIndex(-10),
46  fRejectedOrigin(AliAnalysisTaskDmesonJets::kUnknownQuark | AliAnalysisTaskDmesonJets::kFromBottom),
47  fAcceptedDecay(AliAnalysisTaskDmesonJets::kAnyDecay),
48  fRejectISR(kFALSE),
49  fHistOrigin(0)
50 {
51  // Constructor.
52 }
53 
54 
57 {
58  SetSpecialPDG(421);
60  SetRejectDfromB(kTRUE);
62  SetKeepOnlyDfromB(kFALSE);
63 }
64 
67 {
68  SetSpecialPDG(413);
70  SetRejectDfromB(kTRUE);
72  SetKeepOnlyDfromB(kFALSE);
73 }
74 
82 Bool_t AliHFAODMCParticleContainer::AcceptMCParticle(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
83 {
84  // Return true if vp is accepted.
85 
87  rejectionReason |= kHFCut;
88  return kFALSE; // daughter of a special PDG particle, reject it without any other check.
89  }
90 
91  if (IsSpecialPDG(vp) || IsSpecialIndex(vp)) {
92  // Special PDG particle, skip regular MC particle cuts and apply kinematic cuts.
93  // For the future, may want to implement special kinematic cuts for D mesons
95  GetMomentumFromParticle(mom, vp);
96  return ApplyKinematicCuts(mom, rejectionReason);
97  }
98  else {
99  return AliMCParticleContainer::AcceptMCParticle(vp, rejectionReason);
100  }
101 }
102 
111 {
112  // Return true if vp is accepted.
113 
114  AliAODMCParticle* vp = GetMCParticle(i);
115 
117 
118  rejectionReason = kHFCut;
119 
120  return kFALSE; // daughter of a special PDG particle, reject it without any other check.
121  }
122 
123  if (IsSpecialPDG(vp, fHistOrigin) || IsSpecialIndex(vp)) {
124 
125  // Special PDG particle, skip regular MC particle cuts and apply particle cuts.
126  // For the future, may want to implement special kinematic cuts for D mesons
127  AliTLorentzVector mom;
128  GetMomentum(mom, i);
129  return ApplyKinematicCuts(mom, rejectionReason);
130  }
131  else {
132  return AliMCParticleContainer::AcceptMCParticle(i, rejectionReason);
133  }
134 }
135 
141 {
142  if (fSpecialPDG == 0) return kFALSE;
143 
144  const AliAODMCParticle* pm = part;
145  Int_t imo = -1;
146  while (pm != 0) {
147  imo = pm->GetMother();
148  if (imo < 0) break;
149  pm = static_cast<const AliAODMCParticle*>(fClArray->At(imo));
150  if (IsSpecialPDG(pm)) {
151  AliDebug(2, Form("Rejecting particle (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f) daughter of %d (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f)",
152  part->PdgCode(), part->Pt(), part->Eta(), part->Phi(), imo, pm->PdgCode(), pm->Pt(), pm->Eta(), pm->Phi()));
153  return kTRUE;
154  }
155  }
156  return kFALSE;
157 }
158 
163 Bool_t AliHFAODMCParticleContainer::IsSpecialPDG(const AliAODMCParticle* part, TH1* histOrigin) const
164 {
165  if (fSpecialPDG == 0) return kFALSE;
166 
167  Int_t partPdgCode = TMath::Abs(part->PdgCode());
168 
169  if (partPdgCode != fSpecialPDG) return kFALSE;
170 
171  if (!part->IsPrimary()) return kFALSE;
172 
173  if (fRejectISR) {
174  // proton has PDG code 2212
175  std::set<UInt_t> pdgSet = {2212};
177  if (origin) return kFALSE;
178  }
179 
181 
182  if (histOrigin) {
183  UInt_t rs = origin.first;
184  UShort_t p = 0;
185  while (rs >>= 1) { p++; }
186  histOrigin->Fill(p);
187  }
188 
189  if ((origin.first & fRejectedOrigin) != 0) return kFALSE;
190 
192 
193  if (fAcceptedDecay && (decayChannel & fAcceptedDecay) == 0) return kFALSE;
194 
195  AliDebug(2, Form("Including particle %d (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f)",
196  part->Label(), partPdgCode, part->Pt(), part->Eta(), part->Phi()));
197 
198  // Special PDG particle
199  return kTRUE;
200 }
201 
206 {
207  for (auto part : accepted()) {
208  if (IsSpecialPDG(part)) return kTRUE;
209  }
210  return kFALSE;
211 }
212 
218 {
219  if (fSpecialIndex == -10) return kFALSE;
220 
221  const AliAODMCParticle* pm = part;
222  Int_t imo = -1;
223  while (pm != 0) {
224  imo = pm->GetMother();
225  if (imo < 0) break;
226  pm = static_cast<const AliAODMCParticle*>(fClArray->At(imo));
227  if(imo==fSpecialIndex) return kTRUE;
228 
229  }
230 
231  return kFALSE;
232 }
233 
238 Bool_t AliHFAODMCParticleContainer::IsSpecialIndex(const AliAODMCParticle* part, TH1* histOrigin) const
239 {
240  if (fSpecialIndex == -10) return kFALSE;
241 
242  AliAODMCParticle* pmo;
243  pmo=static_cast<AliAODMCParticle*>(fClArray->At(fSpecialIndex));
244  if(pmo==0) return kFALSE;
245  if(pmo==part){
246 
247  return kTRUE;
248  }
249 
250 
251  // Special PDG particle
252  return kFALSE;
253 }
AliHFAODMCParticleContainer()
This is the default constructor, used for ROOT I/O purposes.
Analysis task for D meson jets.
Int_t fSpecialIndex
index of the given D meson, in case we want to remove the decays D by D
virtual AliAODMCParticle * GetMCParticle(Int_t i=-1) const
virtual Bool_t GetMomentum(TLorentzVector &mom, Int_t i) const
Bool_t fRejectISR
Reject initial state radiation.
virtual Bool_t AcceptMCParticle(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
static std::pair< AliAnalysisTaskDmesonJets::EMesonOrigin_t, AliAODMCParticle * > IsPromptCharm(const AliAODMCParticle *part, TClonesArray *mcArray)
Bool_t IsSpecialPDGDaughter(const AliAODMCParticle *part) const
virtual Bool_t AcceptMCParticle(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
UInt_t fAcceptedDecay
Bit mask with D meson decays that are accepted.
int Int_t
Definition: External.C:63
Bool_t IsSpecialIndexDaughter(const AliAODMCParticle *part) const
unsigned int UInt_t
Definition: External.C:33
static AliAODMCParticle * FindParticleOrigin(const AliAODMCParticle *part, TClonesArray *mcArray, EFindParticleOriginMode_t mode, const std::set< UInt_t > &pdgSet)
Int_t fSpecialPDG
include particles with this PDG code even if they are not primary particles (and exclude their daught...
Bool_t IsSpecialIndex(const AliAODMCParticle *part, TH1 *histOrigin=0) const
void SelectCharmtoDStartoKpipi()
Automatically sets parameters to select only the decay chain c->D*->Kpipi.
UInt_t fRejectedOrigin
Bit mask with D meson origins that are rejected.
Select MC particles based on specific prescriptions of HF analysis.
static EMesonDecayChannel_t CheckDecayChannel(const AliAODMCParticle *part, TClonesArray *mcArray)
virtual Bool_t GetMomentumFromParticle(TLorentzVector &mom, const AliVParticle *part, Double_t mass) const
Bool_t IsSpecialPDG(const AliAODMCParticle *part, TH1 *histOrigin=0) const
unsigned short UShort_t
Definition: External.C:28
virtual Bool_t ApplyKinematicCuts(const AliTLorentzVector &mom, UInt_t &rejectionReason) const
void SelectCharmtoD0toKpi()
Automatically sets parameters to select only the decay chain c->D0->Kpi.
TClonesArray * fClArray
! Pointer to array in input event
bool Bool_t
Definition: External.C:53
Container for MC-true particles within the EMCAL framework.
const AliMCParticleIterableContainer accepted() const
Definition: External.C:196
TH1 * fHistOrigin
! Book-keeping histogram with origin of special PDG particles