]>
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), | |
dff86c2a | 24 | fMinDistanceTPCSectorEdge(-1), |
e58333e0 | 25 | fTrackBitMap(0), |
26 | fMCTrackBitMap(0), | |
bf9072ca | 27 | fMinMCLabel(0), |
f7eb9904 | 28 | fMinMCLabelAccept(-1), |
bf9072ca | 29 | fMCFlag(0), |
82aa1543 | 30 | fGeneratorIndex(-1), |
31 | fCharge(-1) | |
e58333e0 | 32 | { |
33 | // Default constructor. | |
34 | ||
b6f970ad | 35 | fClassName = "AliVParticle"; |
e58333e0 | 36 | } |
37 | ||
38 | //________________________________________________________________________ | |
39 | AliParticleContainer::AliParticleContainer(const char *name): | |
40 | AliEmcalContainer(name), | |
41 | fParticlePtCut(0.15), | |
42 | fParticleMinEta(-0.9), | |
43 | fParticleMaxEta(0.9), | |
44 | fParticleMinPhi(-10), | |
45 | fParticleMaxPhi(10), | |
dff86c2a | 46 | fMinDistanceTPCSectorEdge(-1), |
e58333e0 | 47 | fTrackBitMap(0), |
48 | fMCTrackBitMap(0), | |
bf9072ca | 49 | fMinMCLabel(0), |
f7eb9904 | 50 | fMinMCLabelAccept(-1), |
bf9072ca | 51 | fMCFlag(0), |
82aa1543 | 52 | fGeneratorIndex(-1), |
53 | fCharge(-1) | |
e58333e0 | 54 | { |
55 | // Standard constructor. | |
56 | ||
b6f970ad | 57 | fClassName = "AliVParticle"; |
e58333e0 | 58 | } |
59 | ||
60 | //________________________________________________________________________ | |
b6f970ad | 61 | AliVParticle* AliParticleContainer::GetLeadingParticle(const char* opt) |
e58333e0 | 62 | { |
6421eeb0 | 63 | // Get the leading particle; use p if "p" is contained in opt |
e58333e0 | 64 | |
6421eeb0 | 65 | TString option(opt); |
66 | option.ToLower(); | |
67 | ||
b6f970ad | 68 | Int_t tempID = fCurrentID; |
69 | ||
6421eeb0 | 70 | AliVParticle *partMax = GetNextAcceptParticle(0); |
71 | AliVParticle *part = 0; | |
72 | ||
73 | if (option.Contains("p")) { | |
74 | while ((part = GetNextAcceptParticle())) { | |
75 | if (part->P() > partMax->P()) partMax = part; | |
76 | } | |
77 | } | |
78 | else { | |
79 | while ((part = GetNextAcceptParticle())) { | |
80 | if (part->Pt() > partMax->Pt()) partMax = part; | |
81 | } | |
82 | } | |
e58333e0 | 83 | |
b6f970ad | 84 | fCurrentID = tempID; |
85 | ||
6421eeb0 | 86 | return partMax; |
e58333e0 | 87 | } |
88 | ||
89 | //________________________________________________________________________ | |
37509f02 CL |
90 | AliVParticle* AliParticleContainer::GetParticle(Int_t i) const |
91 | { | |
e58333e0 | 92 | //Get i^th jet in array |
93 | ||
db2fb8aa | 94 | if(i<0 || i>=fClArray->GetEntriesFast()) return 0; |
e58333e0 | 95 | AliVParticle *vp = static_cast<AliVParticle*>(fClArray->At(i)); |
96 | return vp; | |
97 | ||
98 | } | |
99 | ||
100 | //________________________________________________________________________ | |
6504c17f | 101 | AliVParticle* AliParticleContainer::GetAcceptParticle(Int_t i) { |
e58333e0 | 102 | //return pointer to particle if particle is accepted |
103 | ||
104 | AliVParticle *vp = GetParticle(i); | |
105 | if(!vp) return 0; | |
106 | ||
107 | if(AcceptParticle(vp)) | |
82aa1543 | 108 | return vp; |
e58333e0 | 109 | else { |
110 | AliDebug(2,"Particle not accepted."); | |
111 | return 0; | |
112 | } | |
113 | } | |
114 | ||
ef46ebe5 | 115 | //________________________________________________________________________ |
37509f02 CL |
116 | AliVParticle* AliParticleContainer::GetParticleWithLabel(Int_t lab) const |
117 | { | |
ef46ebe5 | 118 | //Get particle with label lab in array |
119 | ||
120 | Int_t i = GetIndexFromLabel(lab); | |
121 | return GetParticle(i); | |
122 | } | |
123 | ||
124 | //________________________________________________________________________ | |
6504c17f | 125 | AliVParticle* AliParticleContainer::GetAcceptParticleWithLabel(Int_t lab) |
37509f02 | 126 | { |
ef46ebe5 | 127 | //Get particle with label lab in array |
128 | ||
129 | Int_t i = GetIndexFromLabel(lab); | |
130 | return GetAcceptParticle(i); | |
131 | } | |
132 | ||
bf9072ca | 133 | |
6421eeb0 | 134 | //________________________________________________________________________ |
37509f02 CL |
135 | AliVParticle* AliParticleContainer::GetNextAcceptParticle(Int_t i) |
136 | { | |
6421eeb0 | 137 | //Get next accepted particle; if i >= 0 (re)start counter from i; return 0 if no accepted particle could be found |
138 | ||
b6f970ad | 139 | if (i>=0) fCurrentID = i; |
6421eeb0 | 140 | |
141 | const Int_t n = GetNEntries(); | |
142 | AliVParticle *p = 0; | |
b6f970ad | 143 | while (fCurrentID < n && !p) { |
144 | p = GetAcceptParticle(fCurrentID); | |
145 | fCurrentID++; | |
6421eeb0 | 146 | } |
147 | ||
148 | return p; | |
149 | } | |
150 | ||
ef46ebe5 | 151 | //________________________________________________________________________ |
37509f02 CL |
152 | AliVParticle* AliParticleContainer::GetNextParticle(Int_t i) |
153 | { | |
ef46ebe5 | 154 | //Get next particle; if i >= 0 (re)start counter from i; return 0 if no particle could be found |
155 | ||
156 | if (i>=0) fCurrentID = i; | |
157 | ||
158 | const Int_t n = GetNEntries(); | |
159 | AliVParticle *p = 0; | |
160 | while (fCurrentID < n && !p) { | |
161 | p = GetParticle(fCurrentID); | |
162 | fCurrentID++; | |
163 | } | |
164 | ||
165 | return p; | |
166 | } | |
167 | ||
6421eeb0 | 168 | //________________________________________________________________________ |
169 | void AliParticleContainer::GetMomentum(TLorentzVector &mom, Int_t i) const | |
170 | { | |
171 | //Get momentum of the i^th particle in array | |
172 | ||
173 | AliVParticle *vp = GetParticle(i); | |
174 | if(vp) mom.SetPtEtaPhiM(vp->Pt(),vp->Eta(),vp->Phi(),0.139); | |
175 | } | |
176 | ||
e58333e0 | 177 | //________________________________________________________________________ |
6504c17f | 178 | Bool_t AliParticleContainer::AcceptParticle(AliVParticle *vp) |
e58333e0 | 179 | { |
180 | // Return true if vp is accepted. | |
181 | ||
6504c17f | 182 | fRejectionReason = 0; |
183 | ||
184 | if (!vp) { | |
185 | fRejectionReason |= kNullObject; | |
e58333e0 | 186 | return kFALSE; |
6504c17f | 187 | } |
188 | ||
189 | if (vp->Pt() < fParticlePtCut) { | |
190 | fRejectionReason |= kPtCut; | |
191 | return kFALSE; | |
192 | } | |
193 | ||
194 | if (vp->Eta() < fParticleMinEta || vp->Eta() > fParticleMaxEta || | |
195 | vp->Phi() < fParticleMinPhi || vp->Phi() > fParticleMaxPhi) { | |
196 | fRejectionReason |= kAcceptanceCut; | |
197 | return kFALSE; | |
198 | } | |
e58333e0 | 199 | |
dff86c2a | 200 | if(fMinDistanceTPCSectorEdge>0.) { |
201 | const Double_t pi = TMath::Pi(); | |
202 | const Double_t kSector = pi/9; | |
203 | Double_t phiDist = TMath::Abs(vp->Phi() - TMath::FloorNint(vp->Phi()/kSector)*kSector); | |
204 | if(phiDist<fMinDistanceTPCSectorEdge) { | |
205 | fRejectionReason |= kMinDistanceTPCSectorEdgeCut; | |
206 | return kFALSE; | |
207 | } | |
208 | } | |
209 | ||
f7eb9904 | 210 | if (TMath::Abs(vp->GetLabel()) < fMinMCLabelAccept) { |
211 | AliDebug(2,"Particle not accepted because label too small."); | |
212 | fRejectionReason |= kMinMCLabelAccept; | |
213 | return kFALSE; | |
214 | } | |
215 | ||
e58333e0 | 216 | if (TMath::Abs(vp->GetLabel()) > fMinMCLabel) { |
217 | if(vp->TestBits(fMCTrackBitMap) != (Int_t)fMCTrackBitMap) { | |
218 | AliDebug(2,"MC particle not accepted because of MC bit map."); | |
6504c17f | 219 | fRejectionReason |= kBitMapCut; |
e58333e0 | 220 | return kFALSE; |
221 | } | |
222 | } | |
223 | else { | |
224 | if(vp->TestBits(fTrackBitMap) != (Int_t)fTrackBitMap) { | |
225 | AliDebug(2,"Track not accepted because of bit map."); | |
6504c17f | 226 | fRejectionReason |= kBitMapCut; |
e58333e0 | 227 | return kFALSE; |
228 | } | |
229 | } | |
230 | ||
6504c17f | 231 | if ((vp->GetFlag() & fMCFlag) != fMCFlag) { |
232 | fRejectionReason |= kMCFlag; | |
bf9072ca | 233 | return kFALSE; |
6504c17f | 234 | } |
bf9072ca | 235 | |
6504c17f | 236 | if (fGeneratorIndex >= 0 && fGeneratorIndex != vp->GetGeneratorIndex()) { |
237 | fRejectionReason |= kMCGeneratorCut; | |
bf9072ca | 238 | return kFALSE; |
6504c17f | 239 | } |
82aa1543 | 240 | |
6504c17f | 241 | if (fCharge>=0 && fCharge != vp->Charge()) { |
242 | fRejectionReason |= kChargeCut; | |
82aa1543 | 243 | return kFALSE; |
6504c17f | 244 | } |
e58333e0 | 245 | |
246 | return kTRUE; | |
247 | } | |
b6f970ad | 248 | |
8612dfc8 | 249 | //________________________________________________________________________ |
250 | Int_t AliParticleContainer::GetNAcceptedParticles() | |
251 | { | |
37509f02 | 252 | // Get number of accepted particles |
8612dfc8 | 253 | |
254 | Int_t nPart = 0; | |
255 | ||
256 | AliVParticle *vp = GetNextAcceptParticle(0); | |
257 | if(vp) nPart = 1; | |
258 | while (GetNextAcceptParticle()) | |
259 | nPart++; | |
260 | ||
261 | return nPart; | |
262 | } | |
263 | ||
b6f970ad | 264 | //________________________________________________________________________ |
265 | void AliParticleContainer::SetClassName(const char *clname) | |
266 | { | |
267 | // Set the class name | |
268 | ||
269 | TClass cls(clname); | |
270 | if (cls.InheritsFrom("AliVParticle")) fClassName = clname; | |
271 | else AliError(Form("Unable to set class name %s for a AliParticleContainer, it must inherits from AliVParticle!",clname)); | |
272 | } |