]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTEvent.cxx
Catching up to NewIO -> Particle stores all passible PID and their probabilities
[u/mrichter/AliRoot.git] / HBTAN / AliHBTEvent.cxx
CommitLineData
8089a083 1//__________________________________________________________
2///////////////////////////////////////////////////////////////////
3//
4// class AliHBTEvent
5//
6// This class is container for paticles coming from one event
7//
8// Piotr.Skowronski@cern.ch
9//
10///////////////////////////////////////////////////////////////////
11
12
1b446896 13#include "AliHBTEvent.h"
14#include "AliHBTParticle.h"
15
16ClassImp(AliHBTEvent)
17
8089a083 18const UInt_t AliHBTEvent::fgkInitEventSize = 100;
1b446896 19
1b446896 20/**************************************************************************/
21
8089a083 22AliHBTEvent::AliHBTEvent()
1b446896 23 {
8089a083 24 if(fgkInitEventSize<1)
25 {
26 Fatal("AliHBTEvent::AliHBTEvent()",
27 "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile",
28 fgkInitEventSize);
29
30 }
31 fSize=fgkInitEventSize;
32 fParticles = new AliHBTParticle* [fSize];
33 fNParticles = 0;
34 fOwner = kTRUE;
1b446896 35 }
36/**************************************************************************/
37
38AliHBTEvent::~AliHBTEvent()
39 {
40 this->Reset();//delete all particles
41 if(fParticles)
42 {
43 delete [] fParticles; //and delete array itself
44 }
45 fParticles = 0x0;
46 }
47/**************************************************************************/
48void AliHBTEvent::Reset()
49{
8089a083 50 //deletes all particles from the event
cea431b6 51 if(fParticles && fOwner)
1b446896 52 {
53 for(Int_t i =0; i<fNParticles; i++)
54 delete fParticles[i];
55 }
56 fNParticles = 0;
57}
58
59AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
60 {
61 if( (n<0) || (fNParticles<=n) ) return 0x0;
62 else return fParticles[n];
63
64 }
65/**************************************************************************/
66
67void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
68 {
8089a083 69 //Adds new perticle to the event
1b446896 70 if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it
71 fParticles[fNParticles++] = hbtpart; //add a pointer
72 }
73
74/**************************************************************************/
8089a083 75void AliHBTEvent::AddParticle(TParticle* part, Int_t idx)
1b446896 76 {
8089a083 77 AddParticle( new AliHBTParticle(*part,idx) );
1b446896 78 }
79/**************************************************************************/
80void AliHBTEvent::
8089a083 81AddParticle(Int_t pdg, Int_t idx, Double_t px, Double_t py, Double_t pz, Double_t etot,
1b446896 82 Double_t vx, Double_t vy, Double_t vz, Double_t time)
83 {
8089a083 84 AddParticle(new AliHBTParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time) );
1b446896 85 }
86/**************************************************************************/
87
88void AliHBTEvent::Expand()
89 {
90 //expands the array with pointers to particles
91 //about the size defined in fgkInitEventSize
92
93 fSize+=fgkInitEventSize;
94 AliHBTParticle** tmpParticles = new AliHBTParticle* [fSize]; //create new array of pointers
95 //check if we got memory / if not Abort
96 if (!tmpParticles) Fatal("AliHBTEvent::Expand()","No more space in memory");
97
98
99 for(Int_t i = 0; i<fNParticles ;i++)
100 //copy pointers to the new array
101 {
102 tmpParticles[i] = fParticles[i];
103 }
104 delete [] fParticles; //delete old array
105 fParticles = tmpParticles; //copy new pointer to the array of pointers to particles
106
107 }
108
109
8089a083 110