Version number ++
[u/mrichter/AliRoot.git] / ANALYSIS / AliAODRun.cxx
CommitLineData
a5556ea5 1#include "AliAODRun.h"
2//____________________
3///////////////////////////////////////////////////////
4// //
5// AliAODRun //
6// //
7// Class storing and managing events //
8// //
9// Piotr.Skowronski@cern.ch //
c7ffd78f 10// http://aliweb.cern.ch/people/skowron/analyzer //
a5556ea5 11// //
12///////////////////////////////////////////////////////
13
14#include <TObjArray.h>
15
16ClassImp(AliAODRun)
17/**************************************************************************/
18
19AliAODRun::AliAODRun()
20{
21 //contructor
22 fEvents = new TObjArray();//create array for AliAODs
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
25}
26/**************************************************************************/
27
28AliAODRun::~AliAODRun()
29{
30 //destructor
31 delete fEvents;//delete array with events
32}
33/**************************************************************************/
34
35void AliAODRun::Reset()
36 {
37 fEvents->Clear();//clear an array with events.
38 //All events are deleted because array is an owner (set in constructor)
39 }
40/**************************************************************************/
41
afa8b37b 42void AliAODRun::AddParticle(Int_t event, AliVAODParticle* part)
a5556ea5 43{
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);
47
48 GetEvent(event)->AddParticle(part);
49}
50/**************************************************************************/
51
52void AliAODRun::AddParticle(Int_t event, TParticle* part, Int_t idx)
53{
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);
57}
58/**************************************************************************/
59
60void 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)
63{
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);
67}
68/**************************************************************************/
69
70void AliAODRun::SetEvent(Int_t number, AliAOD* event)
71{
72 //adds an event to the run
73 if (event == 0x0)
74 {
75 delete fEvents->RemoveAt(number);
76 return;
77 }
78 AliAOD* ev = GetEvent(number);
79 if (ev == event) return;
80
81 delete fEvents->RemoveAt(number);
82 fEvents->AddAtAndExpand(event, number);
83
84}
85/**************************************************************************/
86