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