1 #include "AliHBTEvent.h"
2 #include "AliHBTParticle.h"
3 //_________________________________________________________________________
4 ///////////////////////////////////////////////////////////////////////////
6 // class AliHBTEvent //
8 // This class stores HBT perticles for one event //
9 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html //
11 ///////////////////////////////////////////////////////////////////////////
15 const UInt_t AliHBTEvent::fgkInitEventSize = 10000;
18 /**************************************************************************/
20 AliHBTEvent::AliHBTEvent():
21 fSize(fgkInitEventSize),
22 fParticles(new AliHBTParticle* [fSize]),
28 /**************************************************************************/
30 AliHBTEvent::~AliHBTEvent()
33 this->Reset();//delete all particles
36 delete [] fParticles; //and delete array itself
40 /**************************************************************************/
41 void AliHBTEvent::Reset()
43 //deletes all particles from the event
44 if(fParticles && fOwner)
46 for(Int_t i =0; i<fNParticles; i++)
51 /**************************************************************************/
53 AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
55 //returns nth particle with range check
56 if( (n<0) || (fNParticles<=n) ) return 0x0;
57 else return fParticles[n];
60 /**************************************************************************/
62 void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
64 //Adds new perticle to the event
65 if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it
66 fParticles[fNParticles++] = hbtpart; //add a pointer
69 /**************************************************************************/
70 void AliHBTEvent::AddParticle(TParticle* part)
72 //Adds TParticle to event
73 AddParticle( new AliHBTParticle(*part) );
75 /**************************************************************************/
77 AddParticle(Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t etot,
78 Double_t vx, Double_t vy, Double_t vz, Double_t time)
80 //adds particle to event
81 AddParticle(new AliHBTParticle(pdg,px,py,pz,etot,vx,vy,vz,time) );
83 /**************************************************************************/
85 void AliHBTEvent::Expand()
87 //expands the array with pointers to particles
88 //about the size defined in fgkInitEventSize
90 fSize+=fgkInitEventSize;
91 AliHBTParticle** tmpParticles = new AliHBTParticle* [fSize]; //create new array of pointers
92 //check if we got memory / if not Abort
93 if (!tmpParticles) Fatal("AliHBTEvent::Expand()","No more space in memory");
96 for(Int_t i = 0; i<fNParticles ;i++)
97 //copy pointers to the new array
99 tmpParticles[i] = fParticles[i];
101 delete [] fParticles; //delete old array
102 fParticles = tmpParticles; //copy new pointer to the array of pointers to particles