]>
Commit | Line | Data |
---|---|---|
1b446896 | 1 | #include "AliHBTEvent.h" |
2 | #include "AliHBTParticle.h" | |
3 | ||
4 | ClassImp(AliHBTEvent) | |
5 | ||
6 | const UInt_t AliHBTEvent::fgkInitEventSize = 10000; | |
7 | ||
8 | ||
9 | ||
10 | /**************************************************************************/ | |
11 | ||
12 | AliHBTEvent::AliHBTEvent() | |
13 | { | |
14 | if(fgkInitEventSize<1) | |
15 | { | |
16 | Fatal("AliHBTEvent::AliHBTEvent()", | |
17 | "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile", | |
18 | fgkInitEventSize); | |
19 | ||
20 | } | |
21 | fSize=fgkInitEventSize; | |
22 | fParticles = new AliHBTParticle* [fSize]; | |
23 | fNParticles = 0; | |
cea431b6 | 24 | fOwner = kTRUE; |
1b446896 | 25 | } |
26 | /**************************************************************************/ | |
27 | ||
28 | AliHBTEvent::~AliHBTEvent() | |
29 | { | |
30 | this->Reset();//delete all particles | |
31 | if(fParticles) | |
32 | { | |
33 | delete [] fParticles; //and delete array itself | |
34 | } | |
35 | fParticles = 0x0; | |
36 | } | |
37 | /**************************************************************************/ | |
38 | void AliHBTEvent::Reset() | |
39 | { | |
40 | //deletes all particles from the event | |
cea431b6 | 41 | if(fParticles && fOwner) |
1b446896 | 42 | { |
43 | for(Int_t i =0; i<fNParticles; i++) | |
44 | delete fParticles[i]; | |
45 | } | |
46 | fNParticles = 0; | |
47 | } | |
48 | ||
49 | AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n) | |
50 | { | |
51 | if( (n<0) || (fNParticles<=n) ) return 0x0; | |
52 | else return fParticles[n]; | |
53 | ||
54 | } | |
55 | /**************************************************************************/ | |
56 | ||
57 | void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart) | |
58 | { | |
59 | //Adds new perticle to the event | |
60 | if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it | |
61 | fParticles[fNParticles++] = hbtpart; //add a pointer | |
62 | } | |
63 | ||
64 | /**************************************************************************/ | |
65 | void AliHBTEvent::AddParticle(TParticle* part) | |
66 | { | |
67 | AddParticle( new AliHBTParticle(*part) ); | |
68 | } | |
69 | /**************************************************************************/ | |
70 | void AliHBTEvent:: | |
71 | AddParticle(Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t etot, | |
72 | Double_t vx, Double_t vy, Double_t vz, Double_t time) | |
73 | { | |
74 | AddParticle(new AliHBTParticle(pdg,px,py,pz,etot,vx,vy,vz,time) ); | |
75 | } | |
76 | /**************************************************************************/ | |
77 | ||
78 | void AliHBTEvent::Expand() | |
79 | { | |
80 | //expands the array with pointers to particles | |
81 | //about the size defined in fgkInitEventSize | |
82 | ||
83 | fSize+=fgkInitEventSize; | |
84 | AliHBTParticle** tmpParticles = new AliHBTParticle* [fSize]; //create new array of pointers | |
85 | //check if we got memory / if not Abort | |
86 | if (!tmpParticles) Fatal("AliHBTEvent::Expand()","No more space in memory"); | |
87 | ||
88 | ||
89 | for(Int_t i = 0; i<fNParticles ;i++) | |
90 | //copy pointers to the new array | |
91 | { | |
92 | tmpParticles[i] = fParticles[i]; | |
93 | } | |
94 | delete [] fParticles; //delete old array | |
95 | fParticles = tmpParticles; //copy new pointer to the array of pointers to particles | |
96 | ||
97 | } | |
98 | ||
99 | ||
100 |