1 #include "AliHBTEvent.h"
2 #include "AliHBTParticle.h"
6 const UInt_t AliHBTEvent::fgkInitEventSize = 10000;
10 /**************************************************************************/
12 AliHBTEvent::AliHBTEvent()
14 if(fgkInitEventSize<1)
16 Fatal("AliHBTEvent::AliHBTEvent()",
17 "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile",
21 fSize=fgkInitEventSize;
22 fParticles = new AliHBTParticle* [fSize];
26 /**************************************************************************/
28 AliHBTEvent::~AliHBTEvent()
30 this->Reset();//delete all particles
33 delete [] fParticles; //and delete array itself
37 /**************************************************************************/
38 void AliHBTEvent::Reset()
40 //deletes all particles from the event
41 if(fParticles && fOwner)
43 for(Int_t i =0; i<fNParticles; i++)
49 AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
51 if( (n<0) || (fNParticles<=n) ) return 0x0;
52 else return fParticles[n];
55 /**************************************************************************/
57 void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
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
64 /**************************************************************************/
65 void AliHBTEvent::AddParticle(TParticle* part)
67 AddParticle( new AliHBTParticle(*part) );
69 /**************************************************************************/
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)
74 AddParticle(new AliHBTParticle(pdg,px,py,pz,etot,vx,vy,vz,time) );
76 /**************************************************************************/
78 void AliHBTEvent::Expand()
80 //expands the array with pointers to particles
81 //about the size defined in fgkInitEventSize
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");
89 for(Int_t i = 0; i<fNParticles ;i++)
90 //copy pointers to the new array
92 tmpParticles[i] = fParticles[i];
94 delete [] fParticles; //delete old array
95 fParticles = tmpParticles; //copy new pointer to the array of pointers to particles