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