]>
Commit | Line | Data |
---|---|---|
0dffcc8a | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
0dffcc8a | 15 | |
06351446 | 16 | // |
17 | // *** Class AliRsnEvent *** | |
18 | // | |
19 | // A container for a collection of AliRsnDaughter objects from an event. | |
20 | // Contains also the primary vertex, useful for some cuts. | |
21 | // In order to retrieve easily the tracks which have been identified | |
22 | // as a specific type and charge, there is an array of indexes which | |
23 | // allows to avoid to loop on all tracks and have only the neede ones. | |
24 | // | |
25 | // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
26 | // M. Vala (email: martin.vala@cern.ch) | |
27 | // | |
0dffcc8a | 28 | |
06351446 | 29 | #include <Riostream.h> |
78b94cbd | 30 | #include <TH1.h> |
0dffcc8a | 31 | |
7c2974c8 | 32 | #include "AliLog.h" |
7c2974c8 | 33 | |
06351446 | 34 | #include "AliRsnDaughter.h" |
0dffcc8a | 35 | #include "AliRsnEvent.h" |
06351446 | 36 | #include "AliRsnMCInfo.h" |
0dffcc8a | 37 | |
aec0ec32 | 38 | ClassImp(AliRsnEvent) |
0dffcc8a | 39 | |
7c2974c8 | 40 | //_____________________________________________________________________________ |
0dffcc8a | 41 | AliRsnEvent::AliRsnEvent() : |
aec0ec32 | 42 | TNamed("rsnEvent", ""), |
43 | fPVx(0.0), | |
44 | fPVy(0.0), | |
45 | fPVz(0.0), | |
78b94cbd | 46 | fPhiMean(0.0), |
47 | fMult(0), | |
15d5fd02 | 48 | fPVxMC(0.0), |
49 | fPVyMC(0.0), | |
50 | fPVzMC(0.0), | |
aec0ec32 | 51 | fTracks(0x0), |
71ca2775 | 52 | fTrueMult(0), |
06351446 | 53 | fNoPID(0x0), |
aec0ec32 | 54 | fPerfectPID(0x0), |
78b94cbd | 55 | fRealisticPID(0x0), |
56 | fSelPIDType(AliRsnPID::kUnknown), | |
57 | fSelCharge('0'), | |
58 | fSelPIDMethod(AliRsnDaughter::kRealistic), | |
59 | fSelCuts(0x0) | |
2f769150 | 60 | { |
06351446 | 61 | // |
62 | // Default constructor | |
7c2974c8 | 63 | // (implemented but not recommended for direct use) |
06351446 | 64 | // |
0dffcc8a | 65 | } |
7c2974c8 | 66 | |
67 | //_____________________________________________________________________________ | |
aec0ec32 | 68 | AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) : |
69 | TNamed(event), | |
70 | fPVx(event.fPVx), | |
71 | fPVy(event.fPVy), | |
72 | fPVz(event.fPVz), | |
78b94cbd | 73 | fPhiMean(event.fPhiMean), |
74 | fMult(event.fMult), | |
15d5fd02 | 75 | fPVxMC(event.fPVxMC), |
76 | fPVyMC(event.fPVyMC), | |
77 | fPVzMC(event.fPVzMC), | |
aec0ec32 | 78 | fTracks(0x0), |
71ca2775 | 79 | fTrueMult(event.fTrueMult), |
06351446 | 80 | fNoPID(0x0), |
aec0ec32 | 81 | fPerfectPID(0x0), |
78b94cbd | 82 | fRealisticPID(0x0), |
83 | fSelPIDType(AliRsnPID::kUnknown), | |
84 | fSelCharge('0'), | |
85 | fSelPIDMethod(AliRsnDaughter::kRealistic), | |
86 | fSelCuts(0x0) | |
2f769150 | 87 | { |
06351446 | 88 | // |
0dffcc8a | 89 | // Copy constructor. |
06351446 | 90 | // Copies all the tracks from the argument's collection |
91 | // to this' one, and then recreates the PID index arrays, | |
92 | // trusting on the PID informations in the copied tracks. | |
93 | // | |
94 | ||
aec0ec32 | 95 | // during track copy, counts how many faults happen |
96 | Int_t errors = Fill(event.fTracks); | |
97 | if (errors) AliWarning(Form("%d errors occurred in copy", errors)); | |
06351446 | 98 | |
aec0ec32 | 99 | // fill PID index arrays |
100 | // FillPIDArrays(); | |
06351446 | 101 | |
aec0ec32 | 102 | if (event.fNoPID) fNoPID = new AliRsnPIDIndex(* (event.fNoPID)); |
103 | if (event.fPerfectPID) fPerfectPID = new AliRsnPIDIndex(* (event.fPerfectPID)); | |
104 | if (event.fRealisticPID) fRealisticPID = new AliRsnPIDIndex(* (event.fRealisticPID)); | |
2f769150 | 105 | } |
7c2974c8 | 106 | |
107 | //_____________________________________________________________________________ | |
06351446 | 108 | AliRsnEvent& AliRsnEvent::operator= (const AliRsnEvent &event) |
0dffcc8a | 109 | { |
06351446 | 110 | // |
111 | // Works in the same way as the copy constructor. | |
112 | // | |
aec0ec32 | 113 | // copy name and title |
114 | SetName(event.GetName()); | |
115 | SetTitle(event.GetTitle()); | |
116 | ||
117 | // copy primary vertex and initialize track counter to 0 | |
118 | fPVx = event.fPVx; | |
119 | fPVy = event.fPVy; | |
120 | fPVz = event.fPVz; | |
15d5fd02 | 121 | fPVxMC = event.fPVxMC; |
122 | fPVyMC = event.fPVyMC; | |
123 | fPVzMC = event.fPVzMC; | |
124 | ||
78b94cbd | 125 | // other data |
126 | fPhiMean = event.fPhiMean; | |
127 | fMult = event.fMult; | |
71ca2775 | 128 | fTrueMult = event.fTrueMult; |
aec0ec32 | 129 | |
130 | // add tracks from array of argument | |
131 | Int_t errors = Fill(event.fTracks); | |
132 | if (errors) AliWarning(Form("%d errors occurred in copy", errors)); | |
133 | ||
134 | // fill PID arrays | |
135 | // FillPIDArrays(); | |
136 | if (event.fNoPID) | |
137 | { | |
138 | if (!fNoPID) fNoPID = new AliRsnPIDIndex(* (event.fNoPID)); | |
139 | else (*fNoPID) = * (event.fNoPID); | |
140 | } | |
141 | if (event.fPerfectPID) | |
142 | { | |
143 | if (!fPerfectPID) fPerfectPID = new AliRsnPIDIndex(* (event.fPerfectPID)); | |
144 | else (*fPerfectPID) = * (event.fPerfectPID); | |
145 | } | |
146 | if (event.fRealisticPID) | |
147 | { | |
148 | if (!fRealisticPID) fRealisticPID = new AliRsnPIDIndex(* (event.fRealisticPID)); | |
149 | else (*fRealisticPID) = * (event.fRealisticPID); | |
150 | } | |
151 | ||
152 | // return this object | |
153 | return (*this); | |
0dffcc8a | 154 | } |
7c2974c8 | 155 | |
156 | //_____________________________________________________________________________ | |
157 | AliRsnEvent::~AliRsnEvent() | |
2f769150 | 158 | { |
06351446 | 159 | // |
7c2974c8 | 160 | // Destructor. |
06351446 | 161 | // Deletes the TClonesArray, after clearing its content. |
162 | // Other memory-allocating arrays are cleared by their | |
163 | // destructor, which is automatically called from here. | |
164 | // | |
165 | ||
aec0ec32 | 166 | Clear(); |
167 | if (fTracks) delete fTracks; | |
0dffcc8a | 168 | } |
7c2974c8 | 169 | |
170 | //_____________________________________________________________________________ | |
171 | void AliRsnEvent::Init() | |
2f769150 | 172 | { |
06351446 | 173 | // |
174 | // Initialize TClonesArray data-member. | |
175 | // | |
176 | ||
aec0ec32 | 177 | fTracks = new TClonesArray("AliRsnDaughter", 1); |
178 | //fTracks->BypassStreamer (kFALSE); | |
0dffcc8a | 179 | } |
7c2974c8 | 180 | |
181 | //_____________________________________________________________________________ | |
aec0ec32 | 182 | void AliRsnEvent::Clear(Option_t* /*option*/) |
2f769150 | 183 | { |
06351446 | 184 | // |
185 | // Empties the collections (does not delete the objects). | |
186 | // The track collection is emptied only at the end. | |
187 | // Since some objects could be uninitialized, some | |
188 | // "if" statement are used. | |
189 | // | |
190 | ||
aec0ec32 | 191 | if (fTracks) fTracks->Delete(); |
192 | delete fNoPID; | |
193 | fNoPID = 0x0; | |
194 | delete fPerfectPID; | |
195 | fPerfectPID = 0x0; | |
196 | delete fRealisticPID; | |
197 | fRealisticPID = 0x0; | |
06351446 | 198 | } |
199 | ||
200 | //_____________________________________________________________________________ | |
aec0ec32 | 201 | AliRsnDaughter* AliRsnEvent::AddTrack(AliRsnDaughter track) |
06351446 | 202 | { |
203 | // | |
204 | // Stores a new track into the array and returns | |
205 | // a reference pointer to it (which is NULL in case of errors). | |
206 | // | |
207 | ||
aec0ec32 | 208 | Int_t nextIndex = fTracks->GetEntriesFast(); |
209 | TClonesArray &tracks = (*fTracks); | |
210 | AliRsnDaughter *copy = new(tracks[nextIndex]) AliRsnDaughter(track); | |
211 | return copy; | |
06351446 | 212 | } |
213 | ||
214 | //_____________________________________________________________________________ | |
215 | AliRsnDaughter* AliRsnEvent::GetTrack(Int_t index) | |
216 | { | |
217 | // | |
218 | // Returns one track in the collection | |
219 | // given the absolute index in the global TClonesArray | |
220 | // | |
aec0ec32 | 221 | return (AliRsnDaughter*) fTracks->UncheckedAt(index); |
06351446 | 222 | } |
223 | ||
224 | //_____________________________________________________________________________ | |
aec0ec32 | 225 | TArrayI* AliRsnEvent::GetCharged(Char_t sign) |
06351446 | 226 | { |
227 | // | |
228 | // Returns an array with the indexes of all tracks with a given charge | |
229 | // (arg can be '+' or '-'), irrespective of its PID. | |
230 | // When the argument is wrong, a NULL pointer is returned. | |
231 | // | |
aec0ec32 | 232 | if (fNoPID) return fNoPID->GetTracksArray(sign, AliRsnPID::kUnknown); |
233 | return 0x0; | |
06351446 | 234 | } |
235 | ||
236 | //_____________________________________________________________________________ | |
237 | TArrayI * AliRsnEvent::GetTracksArray | |
e2bafbbc | 238 | (AliRsnDaughter::EPIDMethod pidtype, Char_t sign, AliRsnPID::EType type) |
06351446 | 239 | { |
240 | // | |
241 | // Returns an array of indexes of all tracks in this event | |
242 | // which match the charge sign and PID type in the arguments, | |
243 | // according to one of the allowed PID methods (perfect or realistic). | |
244 | // It retrieves this array from the AliRsnPIDIndex data members. | |
245 | // If the arguments are wrong a NULL pointer is returned. | |
246 | // | |
247 | ||
aec0ec32 | 248 | switch (pidtype) |
249 | { | |
250 | case AliRsnDaughter::kRealistic: | |
251 | if (fRealisticPID) | |
252 | { | |
253 | return fRealisticPID->GetTracksArray(sign, type); | |
254 | } | |
255 | break; | |
256 | case AliRsnDaughter::kPerfect: | |
257 | if (fPerfectPID) | |
258 | { | |
259 | return fPerfectPID->GetTracksArray(sign, type); | |
260 | } | |
261 | break; | |
262 | case AliRsnDaughter::kNoPID: | |
263 | if (fNoPID) | |
264 | { | |
265 | return fNoPID->GetTracksArray(sign, AliRsnPID::kUnknown); | |
266 | } | |
267 | break; | |
268 | default: | |
269 | AliError("Handled PID methods here are only fNoPID,kPerfect and kRealistic. Nothing done."); | |
270 | return 0x0; | |
271 | } | |
272 | return 0x0; | |
0dffcc8a | 273 | } |
7c2974c8 | 274 | |
275 | //_____________________________________________________________________________ | |
e0baff8c | 276 | void AliRsnEvent::FillPIDArrays(Int_t arraySizeInit) |
2f769150 | 277 | { |
06351446 | 278 | // |
279 | // Initializes and fills the AliRsnPIDIndex objects containing | |
280 | // arrays of indexes for each possible charge and PID type. | |
281 | // This method is the unique way to do this, for safety reasons. | |
282 | // | |
283 | ||
aec0ec32 | 284 | if (fNoPID) delete fNoPID; |
285 | if (fPerfectPID) delete fPerfectPID; | |
286 | if (fRealisticPID) delete fRealisticPID; | |
e0baff8c | 287 | fNoPID = new AliRsnPIDIndex(arraySizeInit); |
288 | fPerfectPID = new AliRsnPIDIndex(arraySizeInit); | |
289 | fRealisticPID = new AliRsnPIDIndex(arraySizeInit); | |
aec0ec32 | 290 | |
291 | // set the default type to Realistic | |
292 | AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic); | |
293 | ||
294 | // loop on tracks and create references | |
295 | Double_t prob; | |
296 | Int_t i, icharge, type; | |
297 | Short_t charge; | |
298 | AliRsnMCInfo *mcinfo = 0; | |
299 | AliRsnDaughter *track = 0; | |
300 | TObjArrayIter iter(fTracks); | |
301 | while ((track = (AliRsnDaughter*) iter.Next())) | |
302 | { | |
303 | charge = track->Charge(); | |
304 | type = (Int_t) track->PIDType(prob); | |
305 | i = fTracks->IndexOf(track); | |
306 | mcinfo = track->GetMCInfo(); | |
307 | if (charge > 0) icharge = 0; | |
308 | else if (charge < 0) icharge = 1; | |
309 | else | |
310 | { | |
311 | AliError("Found particle with ZERO charge!!!"); | |
312 | continue; | |
313 | } | |
314 | // add to charged array | |
315 | fNoPID->AddIndex(i, icharge, (Int_t) AliRsnPID::kUnknown); | |
316 | // add to realistic PID array | |
317 | fRealisticPID->AddIndex(i, icharge, (Int_t) type); | |
318 | // add to perfect PID array (needs MCInfo present) | |
319 | if (mcinfo) | |
320 | { | |
321 | fPerfectPID->AddIndex(i, icharge, (Int_t) AliRsnPID::InternalType(mcinfo->PDG())); | |
7c2974c8 | 322 | } |
aec0ec32 | 323 | } |
06351446 | 324 | |
aec0ec32 | 325 | // adjusts the size of arrays |
326 | if (fNoPID) fNoPID->SetCorrectIndexSize(); | |
327 | if (fPerfectPID) fPerfectPID->SetCorrectIndexSize(); | |
328 | if (fRealisticPID) fRealisticPID->SetCorrectIndexSize(); | |
0dffcc8a | 329 | } |
7c2974c8 | 330 | |
331 | //_____________________________________________________________________________ | |
aec0ec32 | 332 | void AliRsnEvent::Print(Option_t *option) const |
2f769150 | 333 | { |
06351446 | 334 | // |
7c2974c8 | 335 | // Lists the details of the event, and the ones of each |
06351446 | 336 | // contained track. |
7c2974c8 | 337 | // The options are passed to AliRsnDaughter::Print(). |
338 | // Look at that method to understand option values. | |
06351446 | 339 | // |
7c2974c8 | 340 | |
aec0ec32 | 341 | cout << "...Multiplicity : " << fTracks->GetEntries() << endl; |
342 | cout << "...Primary vertex : " << fPVx << ' ' << fPVy << ' ' << fPVz << endl; | |
343 | ||
344 | TObjArrayIter iter(fTracks); | |
345 | AliRsnDaughter *d = 0; | |
346 | while ((d = (AliRsnDaughter*) iter.Next())) | |
347 | { | |
348 | cout << "....Track #" << fTracks->IndexOf(d) << endl; | |
349 | d->Print(option); | |
350 | } | |
351 | } | |
06351446 | 352 | |
e0baff8c | 353 | //_____________________________________________________________________________ |
354 | void AliRsnEvent::MakeComputations() | |
355 | { | |
356 | // | |
357 | // Computes all required overall variables: | |
358 | // - multiplicity | |
359 | // - mean phi of tracks | |
360 | // | |
361 | ||
15d5fd02 | 362 | if (!fTracks) |
0ef90328 | 363 | { |
15d5fd02 | 364 | fMult = 0; |
0ef90328 | 365 | fPhiMean = 1000.0; |
e0baff8c | 366 | } |
15d5fd02 | 367 | else |
0ef90328 | 368 | { |
e0baff8c | 369 | fMult = fTracks->GetEntries(); |
0ef90328 | 370 | if (fMult < 1) { |
371 | fPhiMean = 1000.0; | |
372 | } | |
373 | else | |
374 | { | |
375 | fPhiMean = 0.0; | |
376 | AliRsnDaughter *d = 0; | |
377 | TObjArrayIter next(fTracks); | |
378 | while ( (d = (AliRsnDaughter*)next()) ) fPhiMean += d->Phi(); | |
379 | fPhiMean /= (Double_t)fMult; | |
e0baff8c | 380 | } |
e0baff8c | 381 | } |
382 | } | |
383 | ||
15d5fd02 | 384 | //_____________________________________________________________________________ |
385 | void AliRsnEvent::CorrectTracks() | |
386 | { | |
387 | // | |
388 | // Corrects in all tracks the DCA vertex position using the primary vertex. | |
389 | // If present, also MC infos are corrected with primaryvertexMC. | |
390 | // | |
391 | ||
392 | AliRsnDaughter *track = 0; | |
393 | TObjArrayIter next(fTracks); | |
394 | ||
395 | while ( (track = (AliRsnDaughter*)next()) ) { | |
396 | track->ShiftZero(fPVx, fPVy, fPVz); | |
397 | if (track->GetMCInfo()) { | |
398 | track->GetMCInfo()->ShiftZero(fPVxMC, fPVyMC, fPVzMC); | |
399 | } | |
400 | } | |
401 | } | |
402 | ||
7c2974c8 | 403 | //_____________________________________________________________________________ |
aec0ec32 | 404 | Int_t AliRsnEvent::GetNCharged(Char_t sign) |
7c2974c8 | 405 | { |
06351446 | 406 | // |
407 | // Get number of charged tracks | |
408 | // | |
7c2974c8 | 409 | |
aec0ec32 | 410 | Int_t icharge; |
411 | icharge = ChargeIndex(sign); | |
412 | if (icharge < 0) return 0; | |
413 | TArrayI *charged = GetCharged(sign); | |
414 | if (!charged) return 0; | |
415 | return charged->GetSize(); | |
7c2974c8 | 416 | } |
417 | ||
418 | //_____________________________________________________________________________ | |
aec0ec32 | 419 | Int_t AliRsnEvent::Fill(TObjArray *array) |
7c2974c8 | 420 | { |
06351446 | 421 | // |
422 | // Fills the data-member TClonesArray of tracks with | |
423 | // the ones stored in the array passed as argument. | |
424 | // If this data-member is already present, it is cleared. | |
425 | // Returns the number of tracks which raised problems | |
426 | // while attempting to add them. Zero is the best. | |
427 | // | |
428 | ||
aec0ec32 | 429 | // clear the array if it is already instantiated, |
430 | // create if otherwise | |
431 | if (fTracks) fTracks->Delete(); | |
432 | else Init(); | |
433 | ||
434 | // copy argument entries into data-member | |
435 | Int_t errors = 0; | |
436 | AliRsnDaughter *track = 0; | |
437 | TObjArrayIter iter(array); | |
438 | while ((track = (AliRsnDaughter*) iter.Next())) | |
439 | { | |
440 | AliRsnDaughter *ref = AddTrack(*track); | |
441 | if (!ref) | |
442 | { | |
443 | AliWarning(Form("Problem occurred when copying track #%d from passed array", array->IndexOf(track))); | |
444 | errors++; | |
7c2974c8 | 445 | } |
aec0ec32 | 446 | } |
06351446 | 447 | |
aec0ec32 | 448 | return errors; |
7c2974c8 | 449 | } |
450 | ||
451 | //_____________________________________________________________________________ | |
aec0ec32 | 452 | Int_t AliRsnEvent::ChargeIndex(Char_t sign) const |
06351446 | 453 | // |
454 | // Returns the array index corresponding to charge | |
455 | // 0 for positive, 1 for negative | |
456 | // | |
2f769150 | 457 | { |
aec0ec32 | 458 | if (sign == '+') return 0; |
459 | else if (sign == '-') return 1; | |
460 | else | |
461 | { | |
462 | AliError(Form("Character '%c' not recognized as charge sign", sign)); | |
463 | return -1; | |
464 | } | |
0dffcc8a | 465 | } |
78b94cbd | 466 | //_____________________________________________________________________________ |
467 | inline void AliRsnEvent::SetSelection | |
468 | (AliRsnPID::EType pid, Char_t charge, AliRsnDaughter::EPIDMethod meth, AliRsnCutSet *cuts) | |
469 | { | |
470 | // | |
471 | // Set all selection parameters at once | |
472 | // | |
473 | ||
474 | SetSelectionPIDType(pid); | |
475 | SetSelectionCharge(charge); | |
476 | SetSelectionPIDMethod(meth); | |
477 | SetSelectionTrackCuts(cuts); | |
478 | } | |
479 | ||
480 | //_____________________________________________________________________________ | |
481 | AliRsnDaughter* AliRsnEvent::GetLeadingParticle(Double_t ptMin) | |
482 | { | |
483 | // | |
484 | // Searches the collection of all particles with given PID type and charge, | |
485 | // and returns the one with largest momentum, provided that it is greater than 1st argument. | |
486 | // If one specifies AliRsnPID::kUnknown as type or AliRsnDaughter::kNoPID as method, | |
487 | // the check is done over all particles irrespectively of their PID. | |
488 | // If the sign argument is '+' or '-', the check is done over the particles of that charge, | |
489 | // otherwise it is done irrespectively of the charge. | |
490 | // | |
491 | ||
492 | Int_t i; | |
493 | TArrayI *array = 0x0; | |
494 | AliRsnDaughter *track1 = 0x0, *track2 = 0x0, *leading = 0x0; | |
495 | ||
496 | if (fSelCharge == '+' || fSelCharge == '-') { | |
497 | // if the charge '+' or '-' does simply the search | |
498 | array = GetTracksArray(fSelPIDMethod, fSelCharge, fSelPIDType); | |
499 | for (i = 0; i < array->GetSize(); i++) { | |
500 | track1 = (AliRsnDaughter *) fTracks->At(array->At(i)); | |
501 | if (!track1) continue; | |
502 | if (track1->Pt() < ptMin) continue; | |
503 | if (!CutPass(track1)) continue; | |
504 | ptMin = track1->Pt(); | |
505 | leading = track1; | |
506 | } | |
507 | } | |
508 | else { | |
509 | track1 = GetLeadingParticle(ptMin); | |
510 | track2 = GetLeadingParticle(ptMin); | |
511 | if (track1 && track2) { | |
512 | if (track1->Pt() > track2->Pt()) leading = track1; | |
513 | else leading = track2; | |
514 | } | |
515 | else if (track1) leading = track1; | |
516 | else if (track2) leading = track2; | |
517 | else leading = 0x0; | |
518 | } | |
519 | ||
520 | return leading; | |
521 | } | |
522 | ||
523 | //_____________________________________________________________________________ | |
524 | Double_t AliRsnEvent::GetAverageMomentum(Int_t &count) | |
525 | { | |
526 | // | |
527 | // Loops on the list of tracks and computes average total momentum. | |
528 | // | |
529 | ||
530 | Int_t i; | |
531 | Double_t pmean = 0.0; | |
532 | TArrayI *array = 0x0; | |
533 | AliRsnDaughter *d = 0x0; | |
534 | ||
535 | if (fSelCharge == '+' || fSelCharge == '-') { | |
536 | // if the charge '+' or '-' does simply the search | |
537 | count = 0; | |
538 | array = GetTracksArray(fSelPIDMethod, fSelCharge, fSelPIDType); | |
539 | for (i = 0; i < array->GetSize(); i++) { | |
540 | d = (AliRsnDaughter *) fTracks->At(array->At(i)); | |
541 | if (!d) continue; | |
542 | if (!CutPass(d)) continue; | |
543 | pmean += d->P(); | |
544 | count++; | |
545 | } | |
546 | if (count > 0) pmean /= (Double_t)count; | |
547 | else pmean = 0.0; | |
548 | } | |
549 | else { | |
550 | Int_t countP, countM; | |
551 | Double_t pmeanP = GetAverageMomentum(countP); | |
552 | Double_t pmeanM = GetAverageMomentum(countM); | |
553 | if (countP && countM) { | |
554 | pmean = (pmeanP * (Double_t)countP + pmeanM * (Double_t)countM) / (countP + countM); | |
555 | count = countP + countM; | |
556 | } | |
557 | else if (countP) { | |
558 | pmean = pmeanP; | |
559 | count = countP; | |
560 | } | |
561 | else if (countM) { | |
562 | pmean = pmeanM; | |
563 | count = countM; | |
564 | } | |
565 | else { | |
566 | count = 0; | |
567 | pmean = 0.0; | |
568 | } | |
569 | } | |
15d5fd02 | 570 | |
78b94cbd | 571 | return pmean; |
572 | } | |
573 | ||
574 | //_____________________________________________________________________________ | |
575 | Bool_t AliRsnEvent::GetAngleDistrWRLeading | |
576 | (Double_t &angleMean, Double_t &angleRMS, Double_t ptMin) | |
577 | { | |
578 | // | |
579 | // Takes the leading particle and computes the mean and RMS | |
580 | // of the distribution of directions of all other tracks | |
581 | // with respect to the direction of leading particle. | |
582 | // | |
583 | ||
584 | AliRsnDaughter *leading = GetLeadingParticle(ptMin); | |
585 | if (!leading) return kFALSE; | |
15d5fd02 | 586 | |
78b94cbd | 587 | Int_t count = 0; |
588 | Double_t angle, angle2Mean; | |
589 | AliRsnDaughter *trk = 0x0; | |
590 | TObjArrayIter next(fTracks); | |
15d5fd02 | 591 | |
78b94cbd | 592 | angleMean = angle2Mean = 0.0; |
15d5fd02 | 593 | |
78b94cbd | 594 | while ( (trk = (AliRsnDaughter*)next()) ) |
595 | { | |
596 | if (trk == leading) continue; | |
15d5fd02 | 597 | |
78b94cbd | 598 | angle = leading->AngleTo(trk); |
15d5fd02 | 599 | |
78b94cbd | 600 | angleMean += angle; |
601 | angle2Mean += angle * angle; | |
602 | count++; | |
603 | } | |
15d5fd02 | 604 | |
78b94cbd | 605 | if (!count) return kFALSE; |
15d5fd02 | 606 | |
78b94cbd | 607 | angleMean /= (Double_t)count; |
608 | angle2Mean /= (Double_t)count; | |
609 | angleRMS = TMath::Sqrt(angle2Mean - angleMean*angleMean); | |
15d5fd02 | 610 | |
78b94cbd | 611 | return kTRUE; |
612 | } |