AliPhysics  a9863a5 (a9863a5)
 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 
46 AliAODMCParticle* AliMCParticleContainer::GetMCParticleWithLabel(Int_t lab) const
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 
81 AliAODMCParticle* AliMCParticleContainer::GetAcceptMCParticle(Int_t i) const
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;
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;
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 
164 Bool_t AliMCParticleContainer::AcceptMCParticle(Int_t i, UInt_t &rejectionReason) const
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 
204 {
205  static TString trackString;
206 
207  if (GetMinPt() == 0) {
208  trackString = TString::Format("%s_pT0000", GetArrayName().Data());
209  }
210  else if (GetMinPt() < 1.0) {
211  trackString = TString::Format("%s_pT0%3.0f", GetArrayName().Data(), GetMinPt()*1000.0);
212  }
213  else {
214  trackString = TString::Format("%s_pT%4.0f", GetArrayName().Data(), GetMinPt()*1000.0);
215  }
216 
217  return trackString.Data();
218 }
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
virtual AliAODMCParticle * GetMCParticle(Int_t i=-1) const
virtual Bool_t GetMomentum(TLorentzVector &mom, Int_t i) const
Int_t GetIndexFromLabel(Int_t lab) const
virtual AliAODMCParticle * GetNextMCParticle()
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
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
Double_t GetMinPt() const
virtual AliAODMCParticle * GetAcceptMCParticleWithLabel(Int_t lab)
virtual AliAODMCParticle * GetNextAcceptMCParticle()
Cut on the MC flag.
void SetClassName(const char *clname)
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 TString & GetArrayName() const
virtual Bool_t GetMomentumFromParticle(TLorentzVector &mom, const AliVParticle *part, Double_t mass) const
TString fBaseClassName
name of the base class that this container can handle
virtual Bool_t ApplyKinematicCuts(const AliTLorentzVector &mom, UInt_t &rejectionReason) const
TClonesArray * fClArray
! Pointer to array in input event
Int_t GetNEntries() const
Int_t fCurrentID
! current ID for automatic loops
virtual AliAODMCParticle * GetMCParticleWithLabel(Int_t lab) const