X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=HBTAN%2FAliHBTEvent.cxx;h=9f5275523d788512a24ff307affcfa947f90f3be;hp=003a062980c1358f42858285a09f059917d67f8f;hb=4e8faf08e308ee74b6689b0f9f35275b1e7f1272;hpb=cea431b64f0c148c3139cd253e27a2894373fe3b diff --git a/HBTAN/AliHBTEvent.cxx b/HBTAN/AliHBTEvent.cxx index 003a062980c..9f5275523d7 100644 --- a/HBTAN/AliHBTEvent.cxx +++ b/HBTAN/AliHBTEvent.cxx @@ -1,38 +1,86 @@ +//__________________________________________________________ +/////////////////////////////////////////////////////////////////// +// +// class AliHBTEvent +// +// This class is container for paticles coming from one event +// +// Piotr.Skowronski@cern.ch +// +/////////////////////////////////////////////////////////////////// + + #include "AliHBTEvent.h" #include "AliHBTParticle.h" ClassImp(AliHBTEvent) -const UInt_t AliHBTEvent::fgkInitEventSize = 10000; - - +const UInt_t AliHBTEvent::fgkInitEventSize = 100; /**************************************************************************/ -AliHBTEvent::AliHBTEvent() +AliHBTEvent::AliHBTEvent(): + fSize(fgkInitEventSize), + fParticles(new AliHBTParticle* [fSize]), + fNParticles(0), + fOwner(kTRUE), + fRandomized(kFALSE) { - if(fgkInitEventSize<1) - { - Fatal("AliHBTEvent::AliHBTEvent()", - "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile", - fgkInitEventSize); - - } - fSize=fgkInitEventSize; - fParticles = new AliHBTParticle* [fSize]; - fNParticles = 0; - fOwner = kTRUE; +//default constructor + if(fgkInitEventSize<1) + { + Fatal("AliHBTEvent::AliHBTEvent()", + "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile", + fgkInitEventSize); + + } } /**************************************************************************/ + +AliHBTEvent::AliHBTEvent(const AliHBTEvent& source): + TObject(source), + fSize(source.fSize), + fParticles(new AliHBTParticle* [fSize]), + fNParticles(source.fNParticles), + fOwner(source.fNParticles), + fRandomized(source.fRandomized) +{ +//copy constructor + for(Int_t i =0; iReset();//delete all particles - if(fParticles) - { - delete [] fParticles; //and delete array itself - } - fParticles = 0x0; +//destructor + this->Reset();//delete all particles + if(fParticles) + { + delete [] fParticles; //and delete array itself + } + fParticles = 0x0; } /**************************************************************************/ void AliHBTEvent::Reset() @@ -41,60 +89,76 @@ void AliHBTEvent::Reset() if(fParticles && fOwner) { for(Int_t i =0; i= fSize) Expand(); //if there is no space in array, expand it - fParticles[fNParticles++] = hbtpart; //add a pointer - } - +{ + //Adds new perticle to the event + if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it + fParticles[fNParticles++] = hbtpart; //add a pointer +} /**************************************************************************/ -void AliHBTEvent::AddParticle(TParticle* part) - { - AddParticle( new AliHBTParticle(*part) ); - } + +void AliHBTEvent::AddParticle(TParticle* part, Int_t idx) +{ + //Adds TParticle to event + AddParticle( new AliHBTParticle(*part,idx) ); +} /**************************************************************************/ -void AliHBTEvent:: -AddParticle(Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t etot, - Double_t vx, Double_t vy, Double_t vz, Double_t time) - { - AddParticle(new AliHBTParticle(pdg,px,py,pz,etot,vx,vy,vz,time) ); - } +void AliHBTEvent::AddParticle(Int_t pdg, Int_t idx, + Double_t px, Double_t py, Double_t pz, Double_t etot, + Double_t vx, Double_t vy, Double_t vz, Double_t time) +{ + //adds particle to event + AddParticle(new AliHBTParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time) ); +} /**************************************************************************/ void AliHBTEvent::Expand() - { - //expands the array with pointers to particles - //about the size defined in fgkInitEventSize - - fSize+=fgkInitEventSize; - AliHBTParticle** tmpParticles = new AliHBTParticle* [fSize]; //create new array of pointers - //check if we got memory / if not Abort - if (!tmpParticles) Fatal("AliHBTEvent::Expand()","No more space in memory"); - - - for(Int_t i = 0; i=fNParticles)) return; + if ( (j<0) || (j>=fNParticles)) return; - } - - - + AliHBTParticle* tmp = fParticles[i]; + fParticles[i] = fParticles[j]; + fParticles[j] = tmp; +}