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