]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/EMCAL/AliParticleContainer.cxx
Transition to new base class (Salvatore/Marta).
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliParticleContainer.cxx
CommitLineData
e58333e0 1//
2// Particle Container
3//
4// Author: M. Verweij
5
e58333e0 6#include <TClonesArray.h>
6421eeb0 7
e58333e0 8#include "AliVEvent.h"
9#include "AliLog.h"
10
11#include "AliParticleContainer.h"
12
13ClassImp(AliParticleContainer)
14
15//________________________________________________________________________
16AliParticleContainer::AliParticleContainer():
17 AliEmcalContainer("AliParticleContainer"),
18 fParticlePtCut(0.15),
19 fParticleMinEta(-0.9),
20 fParticleMaxEta(0.9),
21 fParticleMinPhi(-10),
22 fParticleMaxPhi(10),
23 fTrackBitMap(0),
24 fMCTrackBitMap(0),
25 fMinMCLabel(0)
26{
27 // Default constructor.
28
b6f970ad 29 fClassName = "AliVParticle";
e58333e0 30}
31
32//________________________________________________________________________
33AliParticleContainer::AliParticleContainer(const char *name):
34 AliEmcalContainer(name),
35 fParticlePtCut(0.15),
36 fParticleMinEta(-0.9),
37 fParticleMaxEta(0.9),
38 fParticleMinPhi(-10),
39 fParticleMaxPhi(10),
40 fTrackBitMap(0),
41 fMCTrackBitMap(0),
42 fMinMCLabel(0)
43{
44 // Standard constructor.
45
b6f970ad 46 fClassName = "AliVParticle";
e58333e0 47}
48
49//________________________________________________________________________
b6f970ad 50AliVParticle* AliParticleContainer::GetLeadingParticle(const char* opt)
e58333e0 51{
6421eeb0 52 // Get the leading particle; use p if "p" is contained in opt
e58333e0 53
6421eeb0 54 TString option(opt);
55 option.ToLower();
56
b6f970ad 57 Int_t tempID = fCurrentID;
58
6421eeb0 59 AliVParticle *partMax = GetNextAcceptParticle(0);
60 AliVParticle *part = 0;
61
62 if (option.Contains("p")) {
63 while ((part = GetNextAcceptParticle())) {
64 if (part->P() > partMax->P()) partMax = part;
65 }
66 }
67 else {
68 while ((part = GetNextAcceptParticle())) {
69 if (part->Pt() > partMax->Pt()) partMax = part;
70 }
71 }
e58333e0 72
b6f970ad 73 fCurrentID = tempID;
74
6421eeb0 75 return partMax;
e58333e0 76}
77
78//________________________________________________________________________
79AliVParticle* AliParticleContainer::GetParticle(Int_t i) const {
80
81 //Get i^th jet in array
82
83 if(i<0 || i>fClArray->GetEntriesFast()) return 0;
84 AliVParticle *vp = static_cast<AliVParticle*>(fClArray->At(i));
85 return vp;
86
87}
88
89//________________________________________________________________________
90AliVParticle* AliParticleContainer::GetAcceptParticle(Int_t i) const {
91 //return pointer to particle if particle is accepted
92
93 AliVParticle *vp = GetParticle(i);
94 if(!vp) return 0;
95
96 if(AcceptParticle(vp))
97 return vp;
98 else {
99 AliDebug(2,"Particle not accepted.");
100 return 0;
101 }
102}
103
ef46ebe5 104//________________________________________________________________________
105AliVParticle* AliParticleContainer::GetParticleWithLabel(Int_t lab) const {
106
107 //Get particle with label lab in array
108
109 Int_t i = GetIndexFromLabel(lab);
110 return GetParticle(i);
111}
112
113//________________________________________________________________________
114AliVParticle* AliParticleContainer::GetAcceptParticleWithLabel(Int_t lab) const {
115
116 //Get particle with label lab in array
117
118 Int_t i = GetIndexFromLabel(lab);
119 return GetAcceptParticle(i);
120}
121
6421eeb0 122//________________________________________________________________________
b6f970ad 123AliVParticle* AliParticleContainer::GetNextAcceptParticle(Int_t i) {
6421eeb0 124
125 //Get next accepted particle; if i >= 0 (re)start counter from i; return 0 if no accepted particle could be found
126
b6f970ad 127 if (i>=0) fCurrentID = i;
6421eeb0 128
129 const Int_t n = GetNEntries();
130 AliVParticle *p = 0;
b6f970ad 131 while (fCurrentID < n && !p) {
132 p = GetAcceptParticle(fCurrentID);
133 fCurrentID++;
6421eeb0 134 }
135
136 return p;
137}
138
ef46ebe5 139//________________________________________________________________________
140AliVParticle* AliParticleContainer::GetNextParticle(Int_t i) {
141
142 //Get next particle; if i >= 0 (re)start counter from i; return 0 if no particle could be found
143
144 if (i>=0) fCurrentID = i;
145
146 const Int_t n = GetNEntries();
147 AliVParticle *p = 0;
148 while (fCurrentID < n && !p) {
149 p = GetParticle(fCurrentID);
150 fCurrentID++;
151 }
152
153 return p;
154}
155
6421eeb0 156//________________________________________________________________________
157void AliParticleContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
158{
159 //Get momentum of the i^th particle in array
160
161 AliVParticle *vp = GetParticle(i);
162 if(vp) mom.SetPtEtaPhiM(vp->Pt(),vp->Eta(),vp->Phi(),0.139);
163}
164
e58333e0 165//________________________________________________________________________
166Bool_t AliParticleContainer::AcceptParticle(AliVParticle *vp) const
167{
168 // Return true if vp is accepted.
169
170 if (!vp)
171 return kFALSE;
172
173 if (TMath::Abs(vp->GetLabel()) > fMinMCLabel) {
174 if(vp->TestBits(fMCTrackBitMap) != (Int_t)fMCTrackBitMap) {
175 AliDebug(2,"MC particle not accepted because of MC bit map.");
176 return kFALSE;
177 }
178 }
179 else {
180 if(vp->TestBits(fTrackBitMap) != (Int_t)fTrackBitMap) {
181 AliDebug(2,"Track not accepted because of bit map.");
182 return kFALSE;
183 }
184 }
185
186 if (vp->Pt() < fParticlePtCut)
187 return kFALSE;
188
189 if (vp->Eta() < fParticleMinEta || vp->Eta() > fParticleMaxEta ||
190 vp->Phi() < fParticleMinPhi || vp->Phi() > fParticleMaxPhi)
191 return kFALSE;
192
193 return kTRUE;
194}
b6f970ad 195
196//________________________________________________________________________
197void AliParticleContainer::SetClassName(const char *clname)
198{
199 // Set the class name
200
201 TClass cls(clname);
202 if (cls.InheritsFrom("AliVParticle")) fClassName = clname;
203 else AliError(Form("Unable to set class name %s for a AliParticleContainer, it must inherits from AliVParticle!",clname));
204}