3 ///////////////////////////////////////////////////////
7 // Class storing and managing events //
9 // Piotr.Skowronski@cern.ch //
10 // http://aliweb.cern.ch/people/skowron/analyzer //
12 ///////////////////////////////////////////////////////
14 #include <TObjArray.h>
17 /**************************************************************************/
19 AliAODRun::AliAODRun():
20 fEvents(new TObjArray())
23 if(!fEvents) Fatal("AliAODRun::AliAODRun","Can not allocate memory");
24 fEvents->SetOwner(); //array is an owner: when is deleted or cleared it deletes objects that it contains
26 /**************************************************************************/
28 AliAODRun::~AliAODRun()
31 delete fEvents;//delete array with events
33 /**************************************************************************/
35 void AliAODRun::Reset()
37 fEvents->Clear();//clear an array with events.
38 //All events are deleted because array is an owner (set in constructor)
40 /**************************************************************************/
42 void AliAODRun::AddParticle(Int_t event, AliVAODParticle* part)
44 //Adds particle to event
45 //if there is no event of this number, crate it and add to the collection
46 if(!GetEvent(event)) fEvents->AddAtAndExpand(new AliAOD, event);
48 GetEvent(event)->AddParticle(part);
50 /**************************************************************************/
52 void AliAODRun::AddParticle(Int_t event, TParticle* part, Int_t idx)
54 //if there is no event of this number, crate it and add to the collection
55 if(!GetEvent(event)) fEvents->AddAtAndExpand(new AliAOD, event);
56 GetEvent(event)->AddParticle(part,idx);
58 /**************************************************************************/
60 void AliAODRun::AddParticle(Int_t event, Int_t pdg, Int_t idx,
61 Double_t px, Double_t py, Double_t pz, Double_t etot,
62 Double_t vx, Double_t vy, Double_t vz, Double_t time)
64 //if there is no event of this number, crate it and add to the collection
65 if(!GetEvent(event)) fEvents->AddAtAndExpand(new AliAOD, event);
66 GetEvent(event)->AddParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time);
68 /**************************************************************************/
70 void AliAODRun::SetEvent(Int_t number, AliAOD* event)
72 //adds an event to the run
75 delete fEvents->RemoveAt(number);
78 AliAOD* ev = GetEvent(number);
79 if (ev == event) return;
81 delete fEvents->RemoveAt(number);
82 fEvents->AddAtAndExpand(event, number);
85 /**************************************************************************/