]>
Commit | Line | Data |
---|---|---|
06351446 | 1 | // |
2 | // *** Class AliRsnEvent *** | |
3 | // | |
4 | // A container for a collection of AliRsnDaughter objects from an event. | |
5 | // Contains also the primary vertex, useful for some cuts. | |
6 | // In order to retrieve easily the tracks which have been identified | |
7 | // as a specific type and charge, there is an array of indexes which | |
8 | // allows to avoid to loop on all tracks and have only the neede ones. | |
9 | // | |
10 | // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
11 | // M. Vala (email: martin.vala@cern.ch) | |
12 | // | |
0dffcc8a | 13 | |
4fbb2459 | 14 | #include <TArrayF.h> |
0dffcc8a | 15 | |
7c2974c8 | 16 | #include "AliLog.h" |
5eb970a4 | 17 | #include "AliVEvent.h" |
18 | #include "AliESDEvent.h" | |
19 | #include "AliAODEvent.h" | |
20 | #include "AliMCEvent.h" | |
21 | #include "AliStack.h" | |
4fbb2459 | 22 | #include "AliGenEventHeader.h" |
7c2974c8 | 23 | |
0dffcc8a | 24 | #include "AliRsnEvent.h" |
25 | ||
aec0ec32 | 26 | ClassImp(AliRsnEvent) |
0dffcc8a | 27 | |
7c2974c8 | 28 | //_____________________________________________________________________________ |
5eb970a4 | 29 | AliRsnEvent::AliRsnEvent(AliVEvent *ref, AliMCEvent *refMC) : |
4fbb2459 | 30 | fRef(ref), |
31 | fRefMC(refMC), | |
32 | fPIDDefESD() | |
2f769150 | 33 | { |
06351446 | 34 | // |
4fbb2459 | 35 | // Default constructor. |
36 | // Set the prior probabilities to some default values | |
06351446 | 37 | // |
4fbb2459 | 38 | |
39 | fPrior[0] = 0.02; | |
40 | fPrior[1] = 0.02; | |
41 | fPrior[2] = 0.83; | |
42 | fPrior[3] = 0.07; | |
43 | fPrior[4] = 0.06; | |
0dffcc8a | 44 | } |
7c2974c8 | 45 | |
46 | //_____________________________________________________________________________ | |
aec0ec32 | 47 | AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) : |
4fbb2459 | 48 | TObject(event), |
49 | fRef(event.fRef), | |
50 | fRefMC(event.fRefMC), | |
51 | fPIDDefESD(event.fPIDDefESD) | |
2f769150 | 52 | { |
06351446 | 53 | // |
0dffcc8a | 54 | // Copy constructor. |
06351446 | 55 | // |
2f769150 | 56 | } |
7c2974c8 | 57 | |
58 | //_____________________________________________________________________________ | |
06351446 | 59 | AliRsnEvent& AliRsnEvent::operator= (const AliRsnEvent &event) |
0dffcc8a | 60 | { |
06351446 | 61 | // |
62 | // Works in the same way as the copy constructor. | |
63 | // | |
aec0ec32 | 64 | |
5eb970a4 | 65 | (TObject)(*this) = (TObject)event; |
66 | fRef = event.fRef; | |
67 | fRefMC = event.fRefMC; | |
4fbb2459 | 68 | fPIDDefESD = event.fPIDDefESD; |
5eb970a4 | 69 | |
aec0ec32 | 70 | return (*this); |
0dffcc8a | 71 | } |
7c2974c8 | 72 | |
73 | //_____________________________________________________________________________ | |
74 | AliRsnEvent::~AliRsnEvent() | |
2f769150 | 75 | { |
06351446 | 76 | // |
7c2974c8 | 77 | // Destructor. |
06351446 | 78 | // |
06351446 | 79 | } |
80 | ||
81 | //_____________________________________________________________________________ | |
5eb970a4 | 82 | void AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i) |
06351446 | 83 | { |
84 | // | |
5eb970a4 | 85 | // Return a track stored here in format of AliRsnDaughter. |
86 | // and finds in the reference event the informations to set | |
87 | // the proprietary data members of AliRsnDaughter | |
06351446 | 88 | // |
06351446 | 89 | |
5eb970a4 | 90 | // retrieve reference particle from reference event |
4fbb2459 | 91 | // if it is found, by defaul track can be used (good) |
5eb970a4 | 92 | AliVParticle *ref = (AliVParticle*)fRef->GetTrack(i); |
5eb970a4 | 93 | if (!ref) return; |
4fbb2459 | 94 | out.SetRef(ref); |
95 | out.SetGood(); | |
06351446 | 96 | |
5eb970a4 | 97 | // if MC info is present, retrieve from it |
98 | TParticle *refMC = 0; | |
99 | if (fRefMC) { | |
100 | Int_t label = TMath::Abs(ref->GetLabel()); | |
101 | refMC = fRefMC->Stack()->Particle(label); | |
4fbb2459 | 102 | out.SetParticle(refMC); |
5eb970a4 | 103 | out.FindMotherPDG(fRefMC->Stack()); |
4fbb2459 | 104 | } |
bd6bf3ee | 105 | |
106 | // if fRef is MC event return | |
107 | AliMCEvent *mc = dynamic_cast<AliMCEvent *> (fRef); | |
108 | if (mc) return; | |
5eb970a4 | 109 | |
4fbb2459 | 110 | // retrieve vertex and set impact parameters |
5eb970a4 | 111 | Double_t dx = out.Xv(), dy = out.Yv(), dz = out.Zv(); |
112 | const AliVVertex *v = fRef->GetPrimaryVertex(); | |
113 | if (v) { | |
114 | dx -= v->GetX(); | |
115 | dy -= v->GetY(); | |
116 | dz -= v->GetZ(); | |
4fbb2459 | 117 | } else if (fRefMC) { |
118 | // if reference is an MC event, no primary vertex is supplied | |
119 | // but it is possible to retrieve it from header | |
120 | TArrayF fvertex(3); | |
121 | fRefMC->GenEventHeader()->PrimaryVertex(fvertex); | |
122 | dx -= fvertex[0]; | |
123 | dy -= fvertex[1]; | |
124 | dz -= fvertex[2]; | |
aec0ec32 | 125 | } |
5eb970a4 | 126 | out.SetDr(TMath::Sqrt(dx*dx + dy*dy)); |
127 | out.SetDz(dz); | |
128 | ||
4fbb2459 | 129 | // compute PID probabilities by combining |
130 | // the PID weights in the source with priors | |
131 | // and eventually using the PIDDefESD | |
132 | // (the AliRsnDaughter objec knows how to manage the latter) | |
133 | out.CombineWithPriors(fPrior, &fPIDDefESD); | |
134 | ||
5eb970a4 | 135 | // dynamic reference to true nature of referenced event |
136 | // to get kink index | |
137 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(fRef); | |
138 | AliAODEvent *aod = dynamic_cast<AliAODEvent*>(fRef); | |
139 | ||
140 | if (esd) { | |
141 | AliESDtrack *esdTrack = esd->GetTrack(i); | |
142 | out.FindKinkIndex(esdTrack); | |
143 | } else if (aod) { | |
144 | out.FindKinkIndex(aod); | |
aec0ec32 | 145 | } |
e0baff8c | 146 | } |
147 | ||
15d5fd02 | 148 | //_____________________________________________________________________________ |
5eb970a4 | 149 | AliRsnDaughter AliRsnEvent::GetDaughter(Int_t i) |
15d5fd02 | 150 | { |
151 | // | |
5eb970a4 | 152 | // Return an AliRsnDaughter taken from this event, |
153 | // with all additional data members well set. | |
15d5fd02 | 154 | // |
155 | ||
5eb970a4 | 156 | AliRsnDaughter out; |
157 | SetDaughter(out, i); | |
15d5fd02 | 158 | |
5eb970a4 | 159 | return out; |
15d5fd02 | 160 | } |
161 | ||
7c2974c8 | 162 | //_____________________________________________________________________________ |
5eb970a4 | 163 | Int_t AliRsnEvent::GetMultiplicity() |
7c2974c8 | 164 | { |
06351446 | 165 | // |
5eb970a4 | 166 | // Returns event multiplicity |
06351446 | 167 | // |
5eb970a4 | 168 | AliDebug(AliLog::kDebug+2,"<-"); |
169 | if (!fRef) return 0; | |
170 | AliDebug(AliLog::kDebug+2,"->"); | |
171 | return fRef->GetNumberOfTracks(); | |
7c2974c8 | 172 | } |
173 | ||
174 | //_____________________________________________________________________________ | |
5eb970a4 | 175 | Double_t AliRsnEvent::GetVz() |
78b94cbd | 176 | { |
177 | // | |
5eb970a4 | 178 | // Return Z coord of primary vertex |
78b94cbd | 179 | // |
5eb970a4 | 180 | AliDebug(AliLog::kDebug+2,"<-"); |
181 | return fRef->GetPrimaryVertex()->GetZ(); | |
182 | AliDebug(AliLog::kDebug+2,"->"); | |
78b94cbd | 183 | } |
184 | ||
185 | //_____________________________________________________________________________ | |
5eb970a4 | 186 | AliRsnDaughter AliRsnEvent::GetLeadingParticle |
187 | (Double_t ptMin, AliPID::EParticleType type) | |
78b94cbd | 188 | { |
189 | // | |
190 | // Searches the collection of all particles with given PID type and charge, | |
191 | // and returns the one with largest momentum, provided that it is greater than 1st argument. | |
192 | // If one specifies AliRsnPID::kUnknown as type or AliRsnDaughter::kNoPID as method, | |
193 | // the check is done over all particles irrespectively of their PID. | |
194 | // If the sign argument is '+' or '-', the check is done over the particles of that charge, | |
195 | // otherwise it is done irrespectively of the charge. | |
196 | // | |
197 | ||
5eb970a4 | 198 | Int_t i, nTracks = fRef->GetNumberOfTracks(); |
199 | AliRsnDaughter output; | |
200 | ||
201 | for (i = 0; i < nTracks; i++) { | |
202 | AliRsnDaughter track = GetDaughter(i); | |
203 | if (!AcceptTrackPID(&track, type)) continue; | |
204 | if (track.Pt() < ptMin) continue; | |
205 | if (!output.IsOK() || track.Pt() > output.Pt()) { | |
206 | output = track; | |
207 | output.SetGood(); | |
78b94cbd | 208 | } |
78b94cbd | 209 | } |
210 | ||
5eb970a4 | 211 | return output; |
78b94cbd | 212 | } |
213 | ||
5eb970a4 | 214 | //_________________________________________________________________________________________________ |
215 | Double_t AliRsnEvent::GetAverageMomentum(Int_t &count, AliPID::EParticleType type) | |
78b94cbd | 216 | { |
217 | // | |
218 | // Loops on the list of tracks and computes average total momentum. | |
219 | // | |
220 | ||
5eb970a4 | 221 | Int_t i, nTracks = fRef->GetNumberOfTracks(); |
78b94cbd | 222 | Double_t pmean = 0.0; |
5eb970a4 | 223 | |
224 | for (i = 0, count = 0; i < nTracks; i++) { | |
225 | AliRsnDaughter track = GetDaughter(i); | |
226 | if (!AcceptTrackPID(&track, type)) continue; | |
227 | pmean += track.P(); | |
228 | count++; | |
78b94cbd | 229 | } |
15d5fd02 | 230 | |
5eb970a4 | 231 | if (count > 0) pmean /= (Double_t)count; |
232 | else pmean = 0.0; | |
233 | ||
78b94cbd | 234 | return pmean; |
235 | } | |
236 | ||
237 | //_____________________________________________________________________________ | |
5eb970a4 | 238 | Bool_t AliRsnEvent::GetAngleDistr |
239 | (Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter leading) | |
78b94cbd | 240 | { |
241 | // | |
242 | // Takes the leading particle and computes the mean and RMS | |
243 | // of the distribution of directions of all other tracks | |
244 | // with respect to the direction of leading particle. | |
245 | // | |
246 | ||
5eb970a4 | 247 | if (!leading.IsOK()) return kFALSE; |
15d5fd02 | 248 | |
5eb970a4 | 249 | Int_t i, count, nTracks = fRef->GetNumberOfTracks(); |
250 | Double_t angle, angle2Mean = 0.0; | |
15d5fd02 | 251 | |
78b94cbd | 252 | angleMean = angle2Mean = 0.0; |
15d5fd02 | 253 | |
5eb970a4 | 254 | for (i = 0, count = 0; i < nTracks; i++) { |
255 | AliRsnDaughter trk = GetDaughter(i); | |
256 | if (trk.GetID() == leading.GetID()) continue; | |
15d5fd02 | 257 | |
5eb970a4 | 258 | angle = leading.AngleTo(trk); |
15d5fd02 | 259 | |
78b94cbd | 260 | angleMean += angle; |
261 | angle2Mean += angle * angle; | |
262 | count++; | |
263 | } | |
15d5fd02 | 264 | |
78b94cbd | 265 | if (!count) return kFALSE; |
15d5fd02 | 266 | |
78b94cbd | 267 | angleMean /= (Double_t)count; |
268 | angle2Mean /= (Double_t)count; | |
269 | angleRMS = TMath::Sqrt(angle2Mean - angleMean*angleMean); | |
15d5fd02 | 270 | |
78b94cbd | 271 | return kTRUE; |
272 | } | |
5eb970a4 | 273 | |
274 | //_____________________________________________________________________________ | |
4fbb2459 | 275 | void AliRsnEvent::SetPriorProbability(Double_t *const out) |
276 | { | |
277 | // | |
278 | // Set all prior probabilities at once, using an assayr of values. | |
279 | // | |
280 | ||
281 | Int_t i; | |
282 | ||
283 | for (i = 0; i < AliPID::kSPECIES; i++) | |
284 | { | |
285 | fPrior[i] = out[i]; | |
286 | } | |
287 | } | |
288 | ||
289 | //_____________________________________________________________________________ | |
290 | void AliRsnEvent::DumpPriors() | |
291 | { | |
292 | // | |
293 | // Print all prior probabilities. | |
294 | // Printout is done using AliInfo, so this will not appear when | |
295 | // the GlobalLogLevel is set to higher level errors. | |
296 | // | |
297 | ||
298 | Int_t i; | |
299 | ||
300 | for (i = 0; i < AliPID::kSPECIES; i++) | |
301 | { | |
302 | AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i])); | |
303 | } | |
304 | } | |
305 | ||
306 | //_____________________________________________________________________________ | |
307 | void AliRsnEvent::GetPriorProbability(Double_t *out) const | |
308 | { | |
309 | // | |
310 | // Stores in the passed argument all the values. | |
311 | // | |
312 | ||
313 | Int_t i; | |
314 | ||
315 | for (i = 0; i < AliPID::kSPECIES; i++) | |
316 | { | |
317 | out[i] = fPrior[i]; | |
318 | } | |
319 | ||
320 | } | |
321 | ||
322 | //_____________________________________________________________________________ | |
323 | Bool_t AliRsnEvent::AcceptTrackPID(AliRsnDaughter * const d, AliPID::EParticleType type) | |
5eb970a4 | 324 | { |
325 | // | |
326 | // [PRIVATE] | |
327 | // Checks if the track PID (according to method in use) corresponds | |
328 | // to the required identification species. | |
329 | // If the second argument is "kUnknown", answer of this method is always YES. | |
330 | // | |
331 | ||
332 | if (type == AliPID::kUnknown) return kTRUE; | |
333 | ||
334 | return (d->AssignedPID() == type); | |
335 | } |