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