AliPhysics  9c7580a (9c7580a)
AliMCParticleContainer.cxx
Go to the documentation of this file.
1 //
2 // Container with name, TClonesArray and cuts for particles
3 //
4 // Author: M. Verweij, S. Aiola
5 
6 #include <iostream>
7 
8 #include <TClonesArray.h>
9 
10 #include "AliVEvent.h"
11 #include "AliLog.h"
12 
13 #include "AliTLorentzVector.h"
14 #include "AliMCParticleContainer.h"
15 
17 ClassImp(AliMCParticleContainer);
19 
25  fMCFlag(AliAODMCParticle::kPhysicalPrim)
26 {
27  fBaseClassName = "AliAODMCParticle";
28  SetClassName("AliAODMCParticle");
29 }
30 
37  fMCFlag(AliAODMCParticle::kPhysicalPrim)
38 {
39  fBaseClassName = "AliAODMCParticle";
40  SetClassName("AliAODMCParticle");
41 }
42 
49 {
50  Int_t i = GetIndexFromLabel(lab);
51  if (i >= 0) {
52  return GetMCParticle(i);
53  }
54  else {
55  return nullptr;
56  }
57 }
58 
65 {
66  Int_t i = GetIndexFromLabel(lab);
67  if (i >= 0) {
68  return GetAcceptMCParticle(i);
69  }
70  else {
71  return nullptr;
72  }
73 }
74 
80 AliAODMCParticle* AliMCParticleContainer::GetMCParticle(Int_t i) const
81 {
82  if (i == -1) i = fCurrentID;
83  if (i < 0 || i >= fClArray->GetEntriesFast()) return 0;
84  AliAODMCParticle *vp = static_cast<AliAODMCParticle*>(fClArray->At(i));
85  return vp;
86 }
87 
94 {
95  //return pointer to particle if particle is accepted
96 
97  UInt_t rejectionReason = 0;
98  if (i == -1) i = fCurrentID;
99  if (AcceptMCParticle(i, rejectionReason)) {
100  return GetMCParticle(i);
101  }
102  else {
103  AliDebugStream(2) << "Particle " << i << " not accepted." << std::endl;
104  return nullptr;
105  }
106 }
107 
114 {
115  const Int_t n = GetNEntries();
116  AliAODMCParticle *p = 0;
117  do {
118  fCurrentID++;
119  if (fCurrentID >= n) break;
120  p = GetAcceptMCParticle(fCurrentID);
121  } while (!p);
122 
123  return p;
124 }
125 
132 {
133  //Get next particle
134 
135  const Int_t n = GetNEntries();
136  AliAODMCParticle *p = 0;
137  do {
138  fCurrentID++;
139  if (fCurrentID >= n) break;
140  p = GetMCParticle(fCurrentID);
141  } while (!p);
142 
143  return p;
144 }
145 
155 Bool_t AliMCParticleContainer::AcceptMCParticle(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
156 {
157  // Return true if vp is accepted.
158  Bool_t r = ApplyMCParticleCuts(vp, rejectionReason);
159  if (!r) return kFALSE;
160 
161  AliTLorentzVector mom;
162  if(!GetMomentumFromParticle(mom, vp)) return false;
163 
164  return ApplyKinematicCuts(mom, rejectionReason);
165 }
166 
177 {
178  // Return true if vp is accepted.
179 
180  Bool_t r = ApplyMCParticleCuts(GetMCParticle(i), rejectionReason);
181  if (!r) return kFALSE;
182 
183  AliTLorentzVector mom;
184  if (!GetMomentum(mom, i)) return kFALSE;
185 
186  return ApplyKinematicCuts(mom, rejectionReason);
187 }
188 
197 Bool_t AliMCParticleContainer::ApplyMCParticleCuts(const AliAODMCParticle* vp, UInt_t &rejectionReason) const
198 {
199  // Return true if i^th particle is accepted.
200  // Cuts on the particle properties
201 
202  if ((vp->GetFlag() & fMCFlag) != fMCFlag) {
203  rejectionReason |= kMCFlag;
204  return kFALSE;
205  }
206 
207  return ApplyParticleCuts(vp, rejectionReason);
208 }
209 
216  return AliMCParticleIterableContainer(this, false);
217 }
218 
225  return AliMCParticleIterableContainer(this, true);
226 }
227 
234  return AliMCParticleIterableMomentumContainer(this, false);
235 }
236 
243  return AliMCParticleIterableMomentumContainer(this, true);
244 }
245 
253 {
254  static TString trackString;
255  trackString = TString::Format("%s_pT%04d", GetArrayName().Data(), static_cast<int>(GetMinPt()*1000.0));
256  return trackString.Data();
257 }
virtual AliAODMCParticle * GetMCParticle(Int_t i=-1) const
virtual Bool_t GetMomentum(TLorentzVector &mom, Int_t i) const
const AliMCParticleIterableMomentumContainer accepted_momentum() const
virtual AliAODMCParticle * GetNextMCParticle()
Declaration of class AliTLorentzVector.
virtual AliAODMCParticle * GetAcceptMCParticle(Int_t i=-1) const
virtual Bool_t ApplyParticleCuts(const AliVParticle *vp, UInt_t &rejectionReason) const
virtual Bool_t ApplyMCParticleCuts(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
const AliMCParticleIterableContainer all() const
UInt_t fMCFlag
select MC particles with flags
Container for particles within the EMCAL framework.
virtual Bool_t AcceptMCParticle(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
virtual AliAODMCParticle * GetAcceptMCParticleWithLabel(Int_t lab)
virtual AliAODMCParticle * GetNextAcceptMCParticle()
const char * GetTitle() const
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 AliMCParticleIterableMomentumContainer all_momentum() const
virtual Bool_t GetMomentumFromParticle(TLorentzVector &mom, const AliVParticle *part, Double_t mass) const
virtual Bool_t ApplyKinematicCuts(const AliTLorentzVector &mom, UInt_t &rejectionReason) const
bool Bool_t
Definition: External.C:53
EMCALIterableContainer::AliEmcalIterableContainerT< AliAODMCParticle, EMCALIterableContainer::operator_star_object< AliAODMCParticle > > AliMCParticleIterableContainer
Container for MC-true particles within the EMCAL framework.
virtual AliAODMCParticle * GetMCParticleWithLabel(Int_t lab) const
const AliMCParticleIterableContainer accepted() const
EMCALIterableContainer::AliEmcalIterableContainerT< AliAODMCParticle, EMCALIterableContainer::operator_star_pair< AliAODMCParticle > > AliMCParticleIterableMomentumContainer