]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMiniEvent.cxx
- Removed small bug (otherwise chargeVector was not filled for normal data)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMiniEvent.cxx
1 //
2 // Mini-Event
3 // Contains only the useful quantities computed on the event
4 // which can be used for event mixing, or for direct output
5 // when doing analysis w.r. to multiplicity or event plane, for example.
6 //
7 // Author: A. Pulvirenti
8 //
9
10 #include "AliRsnMiniParticle.h"
11 #include "AliRsnMiniEvent.h"
12
13 ClassImp(AliRsnMiniEvent)
14
15 //__________________________________________________________________________________________________
16 void AliRsnMiniEvent::AddParticle(AliRsnMiniParticle copy)
17 {
18 //
19 // Add a new particle to the list and returns a pointer to it,
20 // in order to allow to se its parameters.
21 //
22
23    Int_t n = fParticles.GetEntries();
24    new (fParticles[n]) AliRsnMiniParticle(copy);
25 }
26
27 //__________________________________________________________________________________________________
28 AliRsnMiniParticle* AliRsnMiniEvent::GetParticle(Int_t i)
29 {
30 //
31 // Return the leading particle
32 //
33
34    if (i < 0 || i > fParticles.GetEntriesFast()) return 0x0;
35    
36    return (AliRsnMiniParticle*)fParticles[i];
37 }
38
39 //__________________________________________________________________________________________________
40 AliRsnMiniParticle* AliRsnMiniEvent::LeadingParticle()
41 {
42 //
43 // Return the leading particle
44 //
45
46    if (fLeading < 0) return 0x0;
47    if (fLeading >= fParticles.GetEntriesFast()) return 0x0;
48    
49    return (AliRsnMiniParticle*)fParticles[fLeading];
50 }
51
52 //__________________________________________________________________________________________________
53 Int_t AliRsnMiniEvent::CountParticles(TArrayI &found, Char_t charge, Int_t cutID)
54 {
55 //
56 // Counts how many particles have the specified charge and cut bit
57 // if charge is not '+', '-' or '0', all charges are considered
58 // if cut bit is < 0, it is not checked
59 //
60
61    Int_t i, npart = fParticles.GetEntriesFast();
62    Int_t    count = 0;
63    AliRsnMiniParticle *part = 0x0;
64    
65    found.Set(npart);
66    
67    for (i = 0; i < npart; i++) {
68       part = (AliRsnMiniParticle*)fParticles[i];
69       if (charge == '+' || charge == '-' || charge == '0') {
70          if (part->Charge() != charge) continue;
71       }
72       if (cutID >= 0) {
73          if (!part->HasCutBit(cutID)) continue;
74       }
75       found[count] = i;
76       count++;
77    }
78    
79    found.Set(count);
80    return count;
81 }