3 // Container with name, TClonesArray and cuts for particles
7 #include <TClonesArray.h>
12 #include "AliParticleContainer.h"
14 ClassImp(AliParticleContainer)
16 //________________________________________________________________________
17 AliParticleContainer::AliParticleContainer():
18 AliEmcalContainer("AliParticleContainer"),
20 fParticleMinEta(-0.9),
28 // Default constructor.
30 fClassName = "AliVParticle";
33 //________________________________________________________________________
34 AliParticleContainer::AliParticleContainer(const char *name):
35 AliEmcalContainer(name),
37 fParticleMinEta(-0.9),
45 // Standard constructor.
47 fClassName = "AliVParticle";
50 //________________________________________________________________________
51 AliVParticle* AliParticleContainer::GetLeadingParticle(const char* opt)
53 // Get the leading particle; use p if "p" is contained in opt
58 Int_t tempID = fCurrentID;
60 AliVParticle *partMax = GetNextAcceptParticle(0);
61 AliVParticle *part = 0;
63 if (option.Contains("p")) {
64 while ((part = GetNextAcceptParticle())) {
65 if (part->P() > partMax->P()) partMax = part;
69 while ((part = GetNextAcceptParticle())) {
70 if (part->Pt() > partMax->Pt()) partMax = part;
79 //________________________________________________________________________
80 AliVParticle* AliParticleContainer::GetParticle(Int_t i) const
82 //Get i^th jet in array
84 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
85 AliVParticle *vp = static_cast<AliVParticle*>(fClArray->At(i));
90 //________________________________________________________________________
91 AliVParticle* AliParticleContainer::GetAcceptParticle(Int_t i) const {
92 //return pointer to particle if particle is accepted
94 AliVParticle *vp = GetParticle(i);
97 if(AcceptParticle(vp))
100 AliDebug(2,"Particle not accepted.");
105 //________________________________________________________________________
106 AliVParticle* AliParticleContainer::GetParticleWithLabel(Int_t lab) const
108 //Get particle with label lab in array
110 Int_t i = GetIndexFromLabel(lab);
111 return GetParticle(i);
114 //________________________________________________________________________
115 AliVParticle* AliParticleContainer::GetAcceptParticleWithLabel(Int_t lab) const
117 //Get particle with label lab in array
119 Int_t i = GetIndexFromLabel(lab);
120 return GetAcceptParticle(i);
123 //________________________________________________________________________
124 AliVParticle* AliParticleContainer::GetNextAcceptParticle(Int_t i)
126 //Get next accepted particle; if i >= 0 (re)start counter from i; return 0 if no accepted particle could be found
128 if (i>=0) fCurrentID = i;
130 const Int_t n = GetNEntries();
132 while (fCurrentID < n && !p) {
133 p = GetAcceptParticle(fCurrentID);
140 //________________________________________________________________________
141 AliVParticle* AliParticleContainer::GetNextParticle(Int_t i)
143 //Get next particle; if i >= 0 (re)start counter from i; return 0 if no particle could be found
145 if (i>=0) fCurrentID = i;
147 const Int_t n = GetNEntries();
149 while (fCurrentID < n && !p) {
150 p = GetParticle(fCurrentID);
157 //________________________________________________________________________
158 void AliParticleContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
160 //Get momentum of the i^th particle in array
162 AliVParticle *vp = GetParticle(i);
163 if(vp) mom.SetPtEtaPhiM(vp->Pt(),vp->Eta(),vp->Phi(),0.139);
166 //________________________________________________________________________
167 Bool_t AliParticleContainer::AcceptParticle(AliVParticle *vp) const
169 // Return true if vp is accepted.
174 if (TMath::Abs(vp->GetLabel()) > fMinMCLabel) {
175 if(vp->TestBits(fMCTrackBitMap) != (Int_t)fMCTrackBitMap) {
176 AliDebug(2,"MC particle not accepted because of MC bit map.");
181 if(vp->TestBits(fTrackBitMap) != (Int_t)fTrackBitMap) {
182 AliDebug(2,"Track not accepted because of bit map.");
187 if (vp->Pt() < fParticlePtCut)
190 if (vp->Eta() < fParticleMinEta || vp->Eta() > fParticleMaxEta ||
191 vp->Phi() < fParticleMinPhi || vp->Phi() > fParticleMaxPhi)
197 //________________________________________________________________________
198 Int_t AliParticleContainer::GetNAcceptedParticles()
200 // Get number of accepted particles
204 AliVParticle *vp = GetNextAcceptParticle(0);
206 while (GetNextAcceptParticle())
212 //________________________________________________________________________
213 void AliParticleContainer::SetClassName(const char *clname)
215 // Set the class name
218 if (cls.InheritsFrom("AliVParticle")) fClassName = clname;
219 else AliError(Form("Unable to set class name %s for a AliParticleContainer, it must inherits from AliVParticle!",clname));