]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTRun.cxx
Redundant printout removed
[u/mrichter/AliRoot.git] / HBTAN / AliHBTRun.cxx
1 #include "AliHBTRun.h"
2
3 #include <TObjArray.h>
4
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 ///////////////////////////////////////////////////////
16
17 ClassImp(AliHBTRun)
18 /**************************************************************************/ 
19
20 AliHBTRun::AliHBTRun()
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 }
27 /**************************************************************************/
28
29 AliHBTRun::~AliHBTRun()
30 {
31   //destructor
32   delete fEvents;//delete array with events
33 }
34 /**************************************************************************/
35
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
43 void AliHBTRun::AddParticle(Int_t event, AliHBTParticle* part)
44 {
45  //Adds particle to event
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
53 void AliHBTRun::AddParticle(Int_t event, TParticle* part, Int_t idx)
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);
57  GetEvent(event)->AddParticle(part,idx);
58 }
59 /**************************************************************************/
60
61 void AliHBTRun::AddParticle(Int_t event, Int_t pdg, Int_t idx,
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);
67  GetEvent(event)->AddParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time);
68 }
69 /**************************************************************************/ 
70
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 }
84 /**************************************************************************/ 
85