]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODEvent.cxx
Check for missing file.
[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));
08e4c457 105 // set names
106 SetStdNames();
107
df9db588 108 // read back pointers
109 GetStdContent();
110
08e4c457 111 return;
df9db588 112}
113
08e4c457 114//______________________________________________________________________________
115void AliAODEvent::SetStdNames()
116{
117 // introduce the standard naming
118
119 if(fAODObjects->GetEntries()==kAODListN){
120 for(int i = 0;i < fAODObjects->GetEntries();i++){
121 TObject *fObj = fAODObjects->At(i);
122 if(fObj->InheritsFrom("TNamed")){
123 ((TNamed*)fObj)->SetName(fAODListName[i]);
124 }
125 else if(fObj->InheritsFrom("TClonesArray")){
126 ((TClonesArray*)fObj)->SetName(fAODListName[i]);
127 }
128 }
129 }
130 else{
131 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
132 }
133}
134
df9db588 135//______________________________________________________________________________
ec4af4c1 136void AliAODEvent::GetStdContent()
df9db588 137{
138 // set pointers for standard content
139
3dd9f9e3 140 fHeader = (AliAODHeader*)fAODObjects->FindObject("header");
141 fTracks = (TClonesArray*)fAODObjects->FindObject("tracks");
142 fVertices = (TClonesArray*)fAODObjects->FindObject("vertices");
143 fV0s = (TClonesArray*)fAODObjects->FindObject("v0s");
144 fTracklets = (AliAODTracklets*)fAODObjects->FindObject("tracklets");
145 fJets = (TClonesArray*)fAODObjects->FindObject("jets");
37792174 146 fEmcalCells = (AliAODCaloCells*)fAODObjects->FindObject("emcalCells");
147 fPhosCells = (AliAODCaloCells*)fAODObjects->FindObject("phosCells");
3dd9f9e3 148 fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters");
149 fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters");
150 fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters");
df9db588 151}
152
153//______________________________________________________________________________
3dd9f9e3 154void AliAODEvent::ResetStd(Int_t trkArrSize,
155 Int_t vtxArrSize,
156 Int_t v0ArrSize,
157 Int_t jetSize,
158 Int_t caloClusSize,
159 Int_t fmdClusSize,
160 Int_t pmdClusSize)
df9db588 161{
3dd9f9e3 162 // deletes content of standard arrays and resets size
163
df9db588 164 fTracks->Delete();
165 if (trkArrSize > fTracks->GetSize())
166 fTracks->Expand(trkArrSize);
167
168 fVertices->Delete();
169 if (vtxArrSize > fVertices->GetSize())
170 fVertices->Expand(vtxArrSize);
3dd9f9e3 171
172 fV0s->Delete();
173 if (v0ArrSize > fV0s->GetSize())
174 fV0s->Expand(v0ArrSize);
175
176 fJets->Delete();
177 if (jetSize > fJets->GetSize())
178 fJets->Expand(jetSize);
179
180 fCaloClusters->Delete();
181 if (caloClusSize > fCaloClusters->GetSize())
182 fCaloClusters->Expand(caloClusSize);
183
184 fFmdClusters->Delete();
185 if (fmdClusSize > fFmdClusters->GetSize())
186 fFmdClusters->Expand(fmdClusSize);
187
188 fPmdClusters->Delete();
189 if (pmdClusSize > fPmdClusters->GetSize())
190 fPmdClusters->Expand(pmdClusSize);
6989bff3 191
192 // Reset the tracklets
193 fTracklets->DeleteContainer();
194 fPhosCells->DeleteContainer();
195 fEmcalCells->DeleteContainer();
196
df9db588 197}
198
ec4af4c1 199void AliAODEvent::ClearStd()
200{
201 // clears the standard arrays
3dd9f9e3 202 fTracks ->Clear();
203 fVertices ->Clear();
204 fV0s ->Clear();
205 fTracklets ->DeleteContainer();
1c37410a 206 fJets ->Delete();
37792174 207 fEmcalCells ->DeleteContainer();
208 fPhosCells ->DeleteContainer();
209 fCaloClusters ->Clear();
210 fFmdClusters ->Clear();
211 fPmdClusters ->Clear();
ec4af4c1 212}
213
fb41236c 214//______________________________________________________________________________
215Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
216{
217 // fills the provided TRefArray with all found muon tracks
df9db588 218
fb41236c 219 muonTracks->Clear();
df9db588 220
fb41236c 221 AliAODTrack *track = 0;
222 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
08e4c457 223 if ((track = GetTrack(iTrack))->IsMuonTrack()) {
fb41236c 224 muonTracks->Add(track);
225 }
226 }
227
3dd9f9e3 228 return muonTracks->GetEntriesFast();
fb41236c 229}
ec4af4c1 230
231
8ff33247 232void AliAODEvent::ReadFromTree(TTree *tree)
233{
08e4c457 234 // connects aod event to tree
235
236 // load the TTree
237 tree->LoadTree(0);
238
239 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
240 TIter next(fAODObjects);
241 TNamed *el;
242 while((el=(TNamed*)next())){
243 TString bname(el->GetName());
244 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
245 }
246 GetStdContent();
8ff33247 247}
248
08e4c457 249//______________________________________________________________________________
250void AliAODEvent::Print(Option_t *) const
251{
252 // Something meaningful should be implemented here.
253
254 return;
255}