]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODEvent.cxx
Coding conventions and minor fixes
[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
08e4c457 31// definition of std AOD member names
32 const char* AliAODEvent::fAODListName[kAODListN] = {"header",
33 "tracks",
34 "vertices",
3dd9f9e3 35 "v0s",
36 "tracklets",
08e4c457 37 "jets",
37792174 38 "emcalCells",
39 "phosCells",
3dd9f9e3 40 "caloClusters",
41 "fmdClusters",
42 "pmdClusters"
43};
df9db588 44//______________________________________________________________________________
45AliAODEvent::AliAODEvent() :
08e4c457 46 AliVEvent(),
df9db588 47 fAODObjects(new TList()),
ec4af4c1 48 fHeader(0),
49 fTracks(0),
50 fVertices(0),
3dd9f9e3 51 fV0s(0),
52 fTracklets(0),
821f8f1d 53 fJets(0),
37792174 54 fEmcalCells(0),
55 fPhosCells(0),
3dd9f9e3 56 fCaloClusters(0),
57 fFmdClusters(0),
58 fPmdClusters(0)
df9db588 59{
60 // default constructor
61}
62
63//______________________________________________________________________________
64AliAODEvent::~AliAODEvent()
65{
ec4af4c1 66// destructor
67 delete fAODObjects;
df9db588 68}
69
70//______________________________________________________________________________
71void AliAODEvent::AddObject(TObject* obj)
72{
73 // Add an object to the list of object.
74 // Please be aware that in order to increase performance you should
75 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
76
77 fAODObjects->AddLast(obj);
78}
79
80//______________________________________________________________________________
08e4c457 81TObject *AliAODEvent::FindListObject(const char *objName)
df9db588 82{
83 // Return the pointer to the object with the given name.
84
85 return fAODObjects->FindObject(objName);
86}
87
88//______________________________________________________________________________
89void AliAODEvent::CreateStdContent()
90{
91 // create the standard AOD content and set pointers
92
93 // create standard objects and add them to the TList of objects
94 AddObject(new AliAODHeader());
95 AddObject(new TClonesArray("AliAODTrack", 0));
96 AddObject(new TClonesArray("AliAODVertex", 0));
3dd9f9e3 97 AddObject(new TClonesArray("AliAODv0", 0));
821f8f1d 98 AddObject(new AliAODTracklets());
3dd9f9e3 99 AddObject(new TClonesArray("AliAODJet", 0));
100 AddObject(new AliAODCaloCells());
37792174 101 AddObject(new AliAODCaloCells());
3dd9f9e3 102 AddObject(new TClonesArray("AliAODCaloCluster", 0));
103 AddObject(new TClonesArray("AliAODFmdCluster", 0));
104 AddObject(new TClonesArray("AliAODPmdCluster", 0));
105
08e4c457 106 // set names
107 SetStdNames();
108
df9db588 109 // read back pointers
110 GetStdContent();
111
08e4c457 112 return;
df9db588 113}
114
08e4c457 115//______________________________________________________________________________
116void AliAODEvent::SetStdNames()
117{
118 // introduce the standard naming
119
120 if(fAODObjects->GetEntries()==kAODListN){
121 for(int i = 0;i < fAODObjects->GetEntries();i++){
122 TObject *fObj = fAODObjects->At(i);
123 if(fObj->InheritsFrom("TNamed")){
124 ((TNamed*)fObj)->SetName(fAODListName[i]);
125 }
126 else if(fObj->InheritsFrom("TClonesArray")){
127 ((TClonesArray*)fObj)->SetName(fAODListName[i]);
128 }
129 }
130 }
131 else{
132 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
133 }
134}
135
df9db588 136//______________________________________________________________________________
ec4af4c1 137void AliAODEvent::GetStdContent()
df9db588 138{
139 // set pointers for standard content
140
3dd9f9e3 141 fHeader = (AliAODHeader*)fAODObjects->FindObject("header");
142 fTracks = (TClonesArray*)fAODObjects->FindObject("tracks");
143 fVertices = (TClonesArray*)fAODObjects->FindObject("vertices");
144 fV0s = (TClonesArray*)fAODObjects->FindObject("v0s");
145 fTracklets = (AliAODTracklets*)fAODObjects->FindObject("tracklets");
146 fJets = (TClonesArray*)fAODObjects->FindObject("jets");
37792174 147 fEmcalCells = (AliAODCaloCells*)fAODObjects->FindObject("emcalCells");
148 fPhosCells = (AliAODCaloCells*)fAODObjects->FindObject("phosCells");
3dd9f9e3 149 fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters");
150 fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters");
151 fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters");
df9db588 152}
153
154//______________________________________________________________________________
3dd9f9e3 155void AliAODEvent::ResetStd(Int_t trkArrSize,
156 Int_t vtxArrSize,
157 Int_t v0ArrSize,
158 Int_t jetSize,
159 Int_t caloClusSize,
160 Int_t fmdClusSize,
161 Int_t pmdClusSize)
df9db588 162{
3dd9f9e3 163 // deletes content of standard arrays and resets size
164
df9db588 165 fTracks->Delete();
166 if (trkArrSize > fTracks->GetSize())
167 fTracks->Expand(trkArrSize);
168
169 fVertices->Delete();
170 if (vtxArrSize > fVertices->GetSize())
171 fVertices->Expand(vtxArrSize);
3dd9f9e3 172
173 fV0s->Delete();
174 if (v0ArrSize > fV0s->GetSize())
175 fV0s->Expand(v0ArrSize);
176
177 fJets->Delete();
178 if (jetSize > fJets->GetSize())
179 fJets->Expand(jetSize);
180
181 fCaloClusters->Delete();
182 if (caloClusSize > fCaloClusters->GetSize())
183 fCaloClusters->Expand(caloClusSize);
184
185 fFmdClusters->Delete();
186 if (fmdClusSize > fFmdClusters->GetSize())
187 fFmdClusters->Expand(fmdClusSize);
188
189 fPmdClusters->Delete();
190 if (pmdClusSize > fPmdClusters->GetSize())
191 fPmdClusters->Expand(pmdClusSize);
df9db588 192}
193
ec4af4c1 194void AliAODEvent::ClearStd()
195{
196 // clears the standard arrays
3dd9f9e3 197 fTracks ->Clear();
198 fVertices ->Clear();
199 fV0s ->Clear();
200 fTracklets ->DeleteContainer();
1c37410a 201 fJets ->Delete();
37792174 202 fEmcalCells ->DeleteContainer();
203 fPhosCells ->DeleteContainer();
204 fCaloClusters ->Clear();
205 fFmdClusters ->Clear();
206 fPmdClusters ->Clear();
ec4af4c1 207}
208
fb41236c 209//______________________________________________________________________________
210Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
211{
212 // fills the provided TRefArray with all found muon tracks
df9db588 213
fb41236c 214 muonTracks->Clear();
df9db588 215
fb41236c 216 AliAODTrack *track = 0;
217 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
08e4c457 218 if ((track = GetTrack(iTrack))->IsMuonTrack()) {
fb41236c 219 muonTracks->Add(track);
220 }
221 }
222
3dd9f9e3 223 return muonTracks->GetEntriesFast();
fb41236c 224}
ec4af4c1 225
226
8ff33247 227void AliAODEvent::ReadFromTree(TTree *tree)
228{
08e4c457 229 // connects aod event to tree
230
231 // load the TTree
232 tree->LoadTree(0);
233
234 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
235 TIter next(fAODObjects);
236 TNamed *el;
237 while((el=(TNamed*)next())){
238 TString bname(el->GetName());
239 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
240 }
241 GetStdContent();
8ff33247 242}
243
08e4c457 244//______________________________________________________________________________
245void AliAODEvent::Print(Option_t *) const
246{
247 // Something meaningful should be implemented here.
248
249 return;
250}