]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTEvent.cxx
ITS new Geometry files. Not yet ready for uses, committed to allow additional
[u/mrichter/AliRoot.git] / HBTAN / AliHBTEvent.cxx
CommitLineData
1b446896 1#include "AliHBTEvent.h"
2#include "AliHBTParticle.h"
2dc7203b 3//_________________________________________________________________________
4///////////////////////////////////////////////////////////////////////////
5// //
6// class AliHBTEvent //
7// //
8// This class stores HBT perticles for one event //
9// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html //
10// //
11///////////////////////////////////////////////////////////////////////////
1b446896 12
13ClassImp(AliHBTEvent)
14
15const UInt_t AliHBTEvent::fgkInitEventSize = 10000;
16
17
1b446896 18/**************************************************************************/
19
2dc7203b 20AliHBTEvent::AliHBTEvent():
21 fSize(fgkInitEventSize),
22 fParticles(new AliHBTParticle* [fSize]),
23 fNParticles(0),
24 fOwner(kTRUE)
1b446896 25 {
2dc7203b 26 //default constructor
1b446896 27 }
28/**************************************************************************/
29
30AliHBTEvent::~AliHBTEvent()
31 {
2dc7203b 32 //destructor
1b446896 33 this->Reset();//delete all particles
34 if(fParticles)
35 {
36 delete [] fParticles; //and delete array itself
37 }
38 fParticles = 0x0;
39 }
40/**************************************************************************/
41void AliHBTEvent::Reset()
42{
2dc7203b 43 //deletes all particles from the event
cea431b6 44 if(fParticles && fOwner)
1b446896 45 {
46 for(Int_t i =0; i<fNParticles; i++)
47 delete fParticles[i];
48 }
49 fNParticles = 0;
50}
2dc7203b 51/**************************************************************************/
1b446896 52
53AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
54 {
2dc7203b 55 //returns nth particle with range check
1b446896 56 if( (n<0) || (fNParticles<=n) ) return 0x0;
57 else return fParticles[n];
58
59 }
60/**************************************************************************/
61
62void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
63 {
2dc7203b 64 //Adds new perticle to the event
1b446896 65 if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it
66 fParticles[fNParticles++] = hbtpart; //add a pointer
67 }
68
69/**************************************************************************/
70void AliHBTEvent::AddParticle(TParticle* part)
71 {
2dc7203b 72 //Adds TParticle to event
1b446896 73 AddParticle( new AliHBTParticle(*part) );
74 }
75/**************************************************************************/
76void AliHBTEvent::
77AddParticle(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)
79 {
2dc7203b 80 //adds particle to event
1b446896 81 AddParticle(new AliHBTParticle(pdg,px,py,pz,etot,vx,vy,vz,time) );
82 }
83/**************************************************************************/
84
85void AliHBTEvent::Expand()
86 {
87 //expands the array with pointers to particles
88 //about the size defined in fgkInitEventSize
89
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");
94
95
96 for(Int_t i = 0; i<fNParticles ;i++)
97 //copy pointers to the new array
98 {
99 tmpParticles[i] = fParticles[i];
100 }
101 delete [] fParticles; //delete old array
102 fParticles = tmpParticles; //copy new pointer to the array of pointers to particles
103
104 }
105
106