AliPhysics  251aa1e (251aa1e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <TClonesArray.h>
7 
8 #include "AliVEvent.h"
9 #include "AliLog.h"
10 
11 #include "AliTLorentzVector.h"
12 #include "AliMCParticleContainer.h"
13 
17 
23  fMCFlag(AliAODMCParticle::kPhysicalPrim)
24 {
25  fBaseClassName = "AliAODMCParticle";
26  SetClassName("AliAODMCParticle");
27 }
28 
35  fMCFlag(AliAODMCParticle::kPhysicalPrim)
36 {
37  fBaseClassName = "AliAODMCParticle";
38  SetClassName("AliAODMCParticle");
39 }
40 
47 {
48  Int_t i = GetIndexFromLabel(lab);
49  return GetMCParticle(i);
50 }
51 
58 {
59  Int_t i = GetIndexFromLabel(lab);
60  return GetAcceptMCParticle(i);
61 }
62 
68 AliAODMCParticle* AliMCParticleContainer::GetMCParticle(Int_t i) const
69 {
70  if (i == -1) i = fCurrentID;
71  if (i < 0 || i >= fClArray->GetEntriesFast()) return 0;
72  AliAODMCParticle *vp = static_cast<AliAODMCParticle*>(fClArray->At(i));
73  return vp;
74 }
75 
82 {
83  //return pointer to particle if particle is accepted
84 
85  UInt_t rejectionReason = 0;
86  if (i == -1) i = fCurrentID;
87  if (AcceptMCParticle(i, rejectionReason)) {
88  return GetMCParticle(i);
89  }
90  else {
91  AliDebug(2,"Particle not accepted.");
92  return 0;
93  }
94 }
95 
102 {
103  const Int_t n = GetNEntries();
104  AliAODMCParticle *p = 0;
105  do {
106  fCurrentID++;
107  if (fCurrentID >= n) break;
108  p = GetAcceptMCParticle(fCurrentID);
109  } while (!p);
110 
111  return p;
112 }
113 
120 {
121  //Get next particle
122 
123  const Int_t n = GetNEntries();
124  AliAODMCParticle *p = 0;
125  do {
126  fCurrentID++;
127  if (fCurrentID >= n) break;
128  p = GetMCParticle(fCurrentID);
129  } while (!p);
130 
131  return p;
132 }
133 
143 Bool_t AliMCParticleContainer::AcceptMCParticle(const AliAODMCParticle *vp, UInt_t &rejectionReason) const
144 {
145  // Return true if vp is accepted.
146  Bool_t r = ApplyMCParticleCuts(vp, rejectionReason);
147  if (!r) return kFALSE;
148 
149  AliTLorentzVector mom;
150  GetMomentumFromParticle(mom, vp);
151 
152  return ApplyKinematicCuts(mom, rejectionReason);
153 }
154 
165 {
166  // Return true if vp is accepted.
167  Bool_t r = ApplyMCParticleCuts(GetMCParticle(i), rejectionReason);
168  if (!r) return kFALSE;
169 
170  AliTLorentzVector mom;
171  GetMomentum(mom, i);
172 
173  return ApplyKinematicCuts(mom, rejectionReason);
174 }
175 
184 Bool_t AliMCParticleContainer::ApplyMCParticleCuts(const AliAODMCParticle* vp, UInt_t &rejectionReason) const
185 {
186  // Return true if i^th particle is accepted.
187  // Cuts on the particle properties
188 
189  if ((vp->GetFlag() & fMCFlag) != fMCFlag) {
190  rejectionReason |= kMCFlag;
191  return kFALSE;
192  }
193 
194  return ApplyParticleCuts(vp, rejectionReason);
195 }
196 
203  return AliMCParticleIterableContainer(this, false);
204 }
205 
212  return AliMCParticleIterableContainer(this, true);
213 }
214 
221  return AliMCParticleIterableMomentumContainer(this, false);
222 }
223 
230  return AliMCParticleIterableMomentumContainer(this, true);
231 }
232 
240 {
241  static TString trackString;
242 
243  if (GetMinPt() == 0) {
244  trackString = TString::Format("%s_pT0000", GetArrayName().Data());
245  }
246  else if (GetMinPt() < 1.0) {
247  trackString = TString::Format("%s_pT0%3.0f", GetArrayName().Data(), GetMinPt()*1000.0);
248  }
249  else {
250  trackString = TString::Format("%s_pT%4.0f", GetArrayName().Data(), GetMinPt()*1000.0);
251  }
252 
253  return trackString.Data();
254 }
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
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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