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];
25 /**************************************************************************/
27 AliHBTEvent::~AliHBTEvent()
29 this->Reset();//delete all particles
32 delete [] fParticles; //and delete array itself
36 /**************************************************************************/
37 void AliHBTEvent::Reset()
39 //deletes all particles from the event
42 for(Int_t i =0; i<fNParticles; i++)
48 AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
50 if( (n<0) || (fNParticles<=n) ) return 0x0;
51 else return fParticles[n];
54 /**************************************************************************/
56 void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
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
63 /**************************************************************************/
64 void AliHBTEvent::AddParticle(TParticle* part)
66 AddParticle( new AliHBTParticle(*part) );
68 /**************************************************************************/
70 AddParticle(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)
73 AddParticle(new AliHBTParticle(pdg,px,py,pz,etot,vx,vy,vz,time) );
75 /**************************************************************************/
77 void AliHBTEvent::Expand()
79 //expands the array with pointers to particles
80 //about the size defined in fgkInitEventSize
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");
88 for(Int_t i = 0; i<fNParticles ;i++)
89 //copy pointers to the new array
91 tmpParticles[i] = fParticles[i];
93 delete [] fParticles; //delete old array
94 fParticles = tmpParticles; //copy new pointer to the array of pointers to particles