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