1 //__________________________________________________________
2 ///////////////////////////////////////////////////////////////////
6 // This class is container for paticles coming from one event
8 // Piotr.Skowronski@cern.ch
10 ///////////////////////////////////////////////////////////////////
13 #include "AliHBTEvent.h"
14 #include "AliHBTParticle.h"
18 const UInt_t AliHBTEvent::fgkInitEventSize = 100;
20 /**************************************************************************/
22 AliHBTEvent::AliHBTEvent()
25 if(fgkInitEventSize<1)
27 Fatal("AliHBTEvent::AliHBTEvent()",
28 "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile",
32 fSize=fgkInitEventSize;
33 fParticles = new AliHBTParticle* [fSize];
37 /**************************************************************************/
39 AliHBTEvent::~AliHBTEvent()
42 this->Reset();//delete all particles
45 delete [] fParticles; //and delete array itself
49 /**************************************************************************/
50 void AliHBTEvent::Reset()
52 //deletes all particles from the event
53 if(fParticles && fOwner)
55 for(Int_t i =0; i<fNParticles; i++)
60 /**************************************************************************/
62 AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
64 //returns nth particle with range check
65 if( (n<0) || (fNParticles<=n) ) return 0x0;
66 else return fParticles[n];
68 /**************************************************************************/
70 void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
72 //Adds new perticle to the event
73 if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it
74 fParticles[fNParticles++] = hbtpart; //add a pointer
76 /**************************************************************************/
78 void AliHBTEvent::AddParticle(TParticle* part, Int_t idx)
80 //Adds TParticle to event
81 AddParticle( new AliHBTParticle(*part,idx) );
83 /**************************************************************************/
84 void AliHBTEvent::AddParticle(Int_t pdg, Int_t idx,
85 Double_t px, Double_t py, Double_t pz, Double_t etot,
86 Double_t vx, Double_t vy, Double_t vz, Double_t time)
88 //adds particle to event
89 AddParticle(new AliHBTParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time) );
91 /**************************************************************************/
93 void AliHBTEvent::Expand()
95 //expands the array with pointers to particles
96 //about the size defined in fgkInitEventSize
98 fSize+=fgkInitEventSize;
99 AliHBTParticle** tmpParticles = new AliHBTParticle* [fSize]; //create new array of pointers
100 //check if we got memory / if not Abort
101 if (!tmpParticles) Fatal("AliHBTEvent::Expand()","No more space in memory");
104 for(Int_t i = 0; i<fNParticles ;i++)
105 //copy pointers to the new array
107 tmpParticles[i] = fParticles[i];
109 delete [] fParticles; //delete old array
110 fParticles = tmpParticles; //copy new pointer to the array of pointers to particles