]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODEvent.cxx
Rename AliVirtualParticle to AliVParticle (Markus)
[u/mrichter/AliRoot.git] / STEER / AliAODEvent.cxx
CommitLineData
df9db588 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// AOD base class
20// Author: Markus Oldenburg, CERN
21//-------------------------------------------------------------------------
22
ec4af4c1 23#include <TTree.h>
24
df9db588 25#include "AliAODEvent.h"
26#include "AliAODHeader.h"
27#include "AliAODTrack.h"
28
29ClassImp(AliAODEvent)
30
31//______________________________________________________________________________
32AliAODEvent::AliAODEvent() :
33 fAODObjects(new TList()),
ec4af4c1 34 fHeader(0),
35 fTracks(0),
36 fVertices(0),
37 fClusters(0),
821f8f1d 38 fJets(0),
39 fTracklets(0)
df9db588 40{
41 // default constructor
42}
43
44//______________________________________________________________________________
45AliAODEvent::~AliAODEvent()
46{
ec4af4c1 47// destructor
48 delete fAODObjects;
df9db588 49}
50
51//______________________________________________________________________________
52void AliAODEvent::AddObject(TObject* obj)
53{
54 // Add an object to the list of object.
55 // Please be aware that in order to increase performance you should
56 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
57
58 fAODObjects->AddLast(obj);
59}
60
61//______________________________________________________________________________
62TObject *AliAODEvent::GetObject(const char *objName) const
63{
64 // Return the pointer to the object with the given name.
65
66 return fAODObjects->FindObject(objName);
67}
68
69//______________________________________________________________________________
70void AliAODEvent::CreateStdContent()
71{
72 // create the standard AOD content and set pointers
73
74 // create standard objects and add them to the TList of objects
75 AddObject(new AliAODHeader());
76 AddObject(new TClonesArray("AliAODTrack", 0));
77 AddObject(new TClonesArray("AliAODVertex", 0));
a9255000 78 AddObject(new TClonesArray("AliAODCluster", 0));
df9db588 79 AddObject(new TClonesArray("AliAODJet", 0));
821f8f1d 80 AddObject(new AliAODTracklets());
df9db588 81
82 // read back pointers
83 GetStdContent();
84
85 // set names
86 fTracks->SetName("tracks");
87 fVertices->SetName("vertices");
31fd97b2 88 fClusters->SetName("clusters");
df9db588 89 fJets->SetName("jets");
821f8f1d 90 fTracklets->SetName("tracklets");
df9db588 91}
92
93//______________________________________________________________________________
ec4af4c1 94void AliAODEvent::GetStdContent()
df9db588 95{
96 // set pointers for standard content
97
821f8f1d 98 fHeader = (AliAODHeader*)fAODObjects->At(0);
99 fTracks = (TClonesArray*)fAODObjects->At(1);
100 fVertices = (TClonesArray*)fAODObjects->At(2);
101 fClusters = (TClonesArray*)fAODObjects->At(3);
102 fJets = (TClonesArray*)fAODObjects->At(4);
103 fTracklets = (AliAODTracklets*)fAODObjects->At(5);
df9db588 104}
105
106//______________________________________________________________________________
107void AliAODEvent::ResetStd(Int_t trkArrSize, Int_t vtxArrSize)
108{
109 // deletes content of standard arrays and resets size
110 fTracks->Delete();
111 if (trkArrSize > fTracks->GetSize())
112 fTracks->Expand(trkArrSize);
113
114 fVertices->Delete();
115 if (vtxArrSize > fVertices->GetSize())
116 fVertices->Expand(vtxArrSize);
117}
118
ec4af4c1 119void AliAODEvent::ClearStd()
120{
121 // clears the standard arrays
122 fTracks ->Clear();
123 fVertices ->Clear();
124 fClusters ->Clear();
125 fJets ->Clear();
821f8f1d 126 fTracklets->DeleteContainer();
ec4af4c1 127}
128
fb41236c 129//______________________________________________________________________________
130Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
131{
132 // fills the provided TRefArray with all found muon tracks
df9db588 133
fb41236c 134 muonTracks->Clear();
df9db588 135
fb41236c 136 AliAODTrack *track = 0;
137 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
138 if ((track = GetTrack(iTrack))->GetMostProbablePID() == AliAODTrack::kMuon) {
139 muonTracks->Add(track);
140 }
141 }
142
143 return muonTracks->GetSize();
144}
ec4af4c1 145
146
8ff33247 147
148void AliAODEvent::ReadFromTree(TTree *tree)
149{
150 // connects aod event to tree
151
152 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
153 TIter next(fAODObjects);
154 TNamed *el;
155 while((el=(TNamed*)next())){
156 TString bname(el->GetName());
157 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
158 }
159 GetStdContent();
160}
161