]>
Commit | Line | Data |
---|---|---|
1b446896 | 1 | #include "AliHBTRun.h" |
2 | ||
3 | #include <TObjArray.h> | |
4 | ||
e1c43ab8 | 5 | //____________________ |
6 | /////////////////////////////////////////////////////// | |
7 | // // | |
8 | // AliHBTRun // | |
9 | // // | |
10 | // Class storing and managing events // | |
11 | // // | |
12 | // Piotr.Skowronski@cern.ch // | |
13 | // http://alisoft.cern.ch/people/skowron/analyzer // | |
14 | // // | |
15 | /////////////////////////////////////////////////////// | |
1b446896 | 16 | |
17 | ClassImp(AliHBTRun) | |
18 | /**************************************************************************/ | |
19 | ||
20 | AliHBTRun::AliHBTRun() | |
e1c43ab8 | 21 | { |
22 | //contructor | |
23 | fEvents = new TObjArray();//create array for AliHBTEvents | |
24 | if(!fEvents) Fatal("AliHBTRun::AliHBTRun","Can not allocate memory"); | |
25 | fEvents->SetOwner(); //array is an owner: when is deleted or cleared it deletes objects that it contains | |
26 | } | |
1b446896 | 27 | /**************************************************************************/ |
1b446896 | 28 | |
e1c43ab8 | 29 | AliHBTRun::~AliHBTRun() |
30 | { | |
31 | //destructor | |
32 | delete fEvents;//delete array with events | |
33 | } | |
1b446896 | 34 | /**************************************************************************/ |
e1c43ab8 | 35 | |
1b446896 | 36 | void AliHBTRun::Reset() |
37 | { | |
38 | fEvents->Clear();//clear an array with events. | |
39 | //All events are deleted because array is an owner (set in constructor) | |
40 | } | |
41 | /**************************************************************************/ | |
42 | ||
1b446896 | 43 | void AliHBTRun::AddParticle(Int_t event, AliHBTParticle* part) |
44 | { | |
45 | //Adds particle to event | |
1b446896 | 46 | //if there is no event of this number, crate it and add to the collection |
47 | if(!GetEvent(event)) fEvents->AddAtAndExpand(new AliHBTEvent, event); | |
48 | ||
49 | GetEvent(event)->AddParticle(part); | |
50 | } | |
51 | /**************************************************************************/ | |
52 | ||
8089a083 | 53 | void AliHBTRun::AddParticle(Int_t event, TParticle* part, Int_t idx) |
1b446896 | 54 | { |
55 | //if there is no event of this number, crate it and add to the collection | |
56 | if(!GetEvent(event)) fEvents->AddAtAndExpand(new AliHBTEvent, event); | |
8089a083 | 57 | GetEvent(event)->AddParticle(part,idx); |
1b446896 | 58 | } |
59 | /**************************************************************************/ | |
60 | ||
8089a083 | 61 | void AliHBTRun::AddParticle(Int_t event, Int_t pdg, Int_t idx, |
1b446896 | 62 | Double_t px, Double_t py, Double_t pz, Double_t etot, |
63 | Double_t vx, Double_t vy, Double_t vz, Double_t time) | |
64 | { | |
65 | //if there is no event of this number, crate it and add to the collection | |
66 | if(!GetEvent(event)) fEvents->AddAtAndExpand(new AliHBTEvent, event); | |
8089a083 | 67 | GetEvent(event)->AddParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time); |
1b446896 | 68 | } |
bed069a4 | 69 | /**************************************************************************/ |
1b446896 | 70 | |
bed069a4 | 71 | void AliHBTRun::SetEvent(Int_t number, AliHBTEvent* event) |
72 | { | |
73 | //adds an event to the run | |
74 | // makes an own copy of the event! | |
75 | if (event == 0x0) | |
76 | { | |
77 | delete fEvents->RemoveAt(number); | |
78 | return; | |
79 | } | |
80 | AliHBTEvent* ev = GetEvent(number); | |
81 | if (ev) *ev = *event; | |
82 | else fEvents->AddAtAndExpand(new AliHBTEvent(*event), number); | |
83 | } | |
1b446896 | 84 | /**************************************************************************/ |
bed069a4 | 85 |