AliPhysics  cf1a5e2 (cf1a5e2)
AliMCHFParticleSelector.cxx
Go to the documentation of this file.
1 //
2 // Class to select particles in MC events.
3 //
4 // Author: S. Aiola
5 
7 
8 #include <TClonesArray.h>
9 
10 #include <AliVEvent.h>
11 #include <AliMCEvent.h>
12 #include <AliAODMCParticle.h>
13 #include <AliMCParticle.h>
14 #include <AliStack.h>
15 #include <AliLog.h>
16 
18 
20 
21 //________________________________________________________________________
24  fSpecialPDG(0),
25  fRejectQuarkNotFound(kTRUE),
26  fRejectDfromB(kTRUE),
27  fKeepOnlyDfromB(kFALSE),
28  fKeepOnlyD0toKpi(kFALSE),
29  fKeepOnlyDStartoKpipi(kFALSE)
30 {
31  // Constructor.
32 }
33 
34 //________________________________________________________________________
37  fSpecialPDG(0),
38  fRejectQuarkNotFound(kTRUE),
39  fRejectDfromB(kTRUE),
40  fKeepOnlyDfromB(kFALSE),
41  fKeepOnlyD0toKpi(kFALSE),
42  fKeepOnlyDStartoKpipi(kFALSE)
43 {
44  // Constructor.
45 }
46 
47 //________________________________________________________________________
49 {
50  // Destructor.
51 }
52 
53 //________________________________________________________________________
55 {
56  SetSpecialPDG(421);
57  SetKeepOnlyD0toKpi(kTRUE);
59  SetRejectDfromB(kTRUE);
61  SetKeepOnlyDfromB(kFALSE);
62 }
63 
64 //________________________________________________________________________
66 {
67  SetSpecialPDG(413);
68  SetKeepOnlyD0toKpi(kFALSE);
70  SetRejectDfromB(kTRUE);
72  SetKeepOnlyDfromB(kFALSE);
73 }
74 
75 //________________________________________________________________________
77 {
78  // Determine whether the MC particle is accepted.
79 
80  if (!part) return kFALSE;
81 
82  Int_t partPdgCode = TMath::Abs(part->PdgCode());
83 
84  if (fOnlyHIJING && (part->GetGeneratorIndex() != 0)) return kFALSE;
85 
86  if (fEtaMax > 0. && TMath::Abs(part->Eta()) > fEtaMax) return kFALSE;
87 
88  if (fRejectNK && (partPdgCode == 130 || partPdgCode == 2112)) return kFALSE;
89 
90  Bool_t isSpecialPdg = (fSpecialPDG != 0 && partPdgCode == fSpecialPDG && part->IsPrimary());
91 
92  if (isSpecialPdg) {
93  Int_t origin = -1;
94 
95  if (fIsESD) {
96  origin = AliAnalysisTaskSEDmesonsFilterCJ::CheckOrigin(part->Label(), fMC->Stack());
97  }
98  else {
100  }
101 
102  if (origin < 0) isSpecialPdg = kFALSE;
103 
105  isSpecialPdg = kFALSE;
106  }
108  isSpecialPdg = kFALSE;
109  }
111  isSpecialPdg = kFALSE;
112  }
113 
114  Int_t decayChannel = -1;
115 
116  if (fIsESD) {
117  decayChannel = AliAnalysisTaskSEDmesonsFilterCJ::CheckDecayChannel(part->Label(), fMC->Stack());
118  }
119  else {
121  }
122 
124  isSpecialPdg = kFALSE;
125  }
127  isSpecialPdg = kFALSE;
128  }
129  }
130 
131  if (isSpecialPdg) {
132  AliDebug(2, Form("Including particle %d (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f)",
133  part->Label(), partPdgCode, part->Pt(), part->Eta(), part->Phi()));
134  }
135 
136  if (!isSpecialPdg) {
137  if (fChargedMC && part->Charge() == 0) return kFALSE;
138  if (fOnlyPhysPrim && !part->IsPhysicalPrimary()) return kFALSE;
139  }
140 
141  if (fIsESD) {
142  if (IsSpecialPDGDaughter(part->Label())) return kFALSE;
143  }
144  else {
145  if (IsSpecialPDGDaughter(part)) return kFALSE;
146  }
147 
148  return kTRUE;
149 }
150 
151 //________________________________________________________________________
153 {
154  // Check if particle it's a daughter of a "special" PDG particle: AOD mode
155 
156  if (fSpecialPDG == 0) return kTRUE;
157 
158  AliAODMCParticle* pm = part;
159  Int_t imo = -1;
160  while (pm != 0) {
161  imo = pm->GetMother();
162  if (imo < 0) break;
163  pm = static_cast<AliAODMCParticle*>(fParticlesIn->At(imo));
164  if (TMath::Abs(pm->GetPdgCode()) == fSpecialPDG && pm->IsPrimary()) {
165  AliDebug(2, Form("Rejecting particle (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f) daughter of %d (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f)",
166  part->PdgCode(), part->Pt(), part->Eta(), part->Phi(), imo, pm->PdgCode(), pm->Pt(), pm->Eta(), pm->Phi()));
167  return kTRUE;
168  }
169  }
170  return kFALSE;
171 }
172 
173 //________________________________________________________________________
175 {
176  // Check if particle it's a daughter of a "special" PDG particle: ESD mode
177 
178  if (fSpecialPDG == 0) return kTRUE;
179 
180  AliStack* stack = fMC->Stack();
181  TParticle* part = stack->Particle(iPart);
182  TParticle* pm = part;
183  Int_t imo = -1;
184  while (pm != 0) {
185  imo = pm->GetFirstMother();
186  if (imo < 0) break;
187  pm = stack->Particle(imo);
188  if (TMath::Abs(pm->GetPdgCode()) == fSpecialPDG && imo < stack->GetNprimary()) {
189  AliDebug(2, Form("Rejecting particle (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f) daughter of %d (PDG = %d, pT = %.3f, eta = %.3f, phi = %.3f)",
190  part->GetPdgCode(), part->Pt(), part->Eta(), part->Phi(), imo, pm->GetPdgCode(), pm->Pt(), pm->Eta(), pm->Phi()));
191  return kTRUE;
192  }
193  }
194  return kFALSE;
195 }
static Int_t CheckOrigin(AliAODRecoDecay *cand, TClonesArray *mcArray)
Bool_t fIsESD
MC event (ESD)
AliStack * stack
TString part
use mixed event to constrain combinatorial background
Definition: InvMassFit.C:52
int Int_t
Definition: External.C:63
static Int_t CheckDecayChannel(AliAODMCParticle *part, TClonesArray *mcArray)
bool Bool_t
Definition: External.C:53
TClonesArray * fParticlesIn
true = task initialized
Bool_t IsSpecialPDGDaughter(AliAODMCParticle *part) const
Bool_t AcceptParticle(AliAODMCParticle *part) const