1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
25 #include "AliAODEvent.h"
26 #include "AliAODHeader.h"
27 #include "AliAODTrack.h"
31 // definition of std AOD member names
32 const char* AliAODEvent::fAODListName[kAODListN] = {"header",
44 //______________________________________________________________________________
45 AliAODEvent::AliAODEvent() :
47 fAODObjects(new TList()),
60 // default constructor
63 //______________________________________________________________________________
64 AliAODEvent::~AliAODEvent()
70 //______________________________________________________________________________
71 void AliAODEvent::AddObject(TObject* obj)
73 // Add an object to the list of objects.
74 // Please be aware that in order to increase performance you should
75 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
77 fAODObjects->AddLast(obj);
80 //______________________________________________________________________________
81 void AliAODEvent::RemoveObject(TObject* obj)
83 // Removes an object from the list of objects.
85 fAODObjects->Remove(obj);
88 //______________________________________________________________________________
89 TObject *AliAODEvent::FindListObject(const char *objName)
91 // Return the pointer to the object with the given name.
93 return fAODObjects->FindObject(objName);
96 //______________________________________________________________________________
97 void AliAODEvent::CreateStdContent()
99 // create the standard AOD content and set pointers
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));
105 AddObject(new TClonesArray("AliAODv0", 0));
106 AddObject(new AliAODTracklets());
107 AddObject(new TClonesArray("AliAODJet", 0));
108 AddObject(new AliAODCaloCells());
109 AddObject(new AliAODCaloCells());
110 AddObject(new TClonesArray("AliAODCaloCluster", 0));
111 AddObject(new TClonesArray("AliAODFmdCluster", 0));
112 AddObject(new TClonesArray("AliAODPmdCluster", 0));
116 // read back pointers
122 //______________________________________________________________________________
123 void AliAODEvent::SetStdNames()
125 // introduce the standard naming
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]);
133 else if(fObj->InheritsFrom("TClonesArray")){
134 ((TClonesArray*)fObj)->SetName(fAODListName[i]);
139 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
143 //______________________________________________________________________________
144 void AliAODEvent::GetStdContent()
146 // set pointers for standard content
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");
154 fEmcalCells = (AliAODCaloCells*)fAODObjects->FindObject("emcalCells");
155 fPhosCells = (AliAODCaloCells*)fAODObjects->FindObject("phosCells");
156 fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters");
157 fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters");
158 fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters");
161 //______________________________________________________________________________
162 void AliAODEvent::ResetStd(Int_t trkArrSize,
170 // deletes content of standard arrays and resets size
173 if (trkArrSize > fTracks->GetSize())
174 fTracks->Expand(trkArrSize);
177 if (vtxArrSize > fVertices->GetSize())
178 fVertices->Expand(vtxArrSize);
181 if (v0ArrSize > fV0s->GetSize())
182 fV0s->Expand(v0ArrSize);
185 if (jetSize > fJets->GetSize())
186 fJets->Expand(jetSize);
188 fCaloClusters->Delete();
189 if (caloClusSize > fCaloClusters->GetSize())
190 fCaloClusters->Expand(caloClusSize);
192 fFmdClusters->Delete();
193 if (fmdClusSize > fFmdClusters->GetSize())
194 fFmdClusters->Expand(fmdClusSize);
196 fPmdClusters->Delete();
197 if (pmdClusSize > fPmdClusters->GetSize())
198 fPmdClusters->Expand(pmdClusSize);
200 // Reset the tracklets
201 fTracklets->DeleteContainer();
202 fPhosCells->DeleteContainer();
203 fEmcalCells->DeleteContainer();
207 void AliAODEvent::ClearStd()
209 // clears the standard arrays
213 fTracklets ->DeleteContainer();
215 fEmcalCells ->DeleteContainer();
216 fPhosCells ->DeleteContainer();
217 fCaloClusters ->Clear();
218 fFmdClusters ->Clear();
219 fPmdClusters ->Clear();
222 //______________________________________________________________________________
223 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
225 // fills the provided TRefArray with all found muon tracks
229 AliAODTrack *track = 0;
230 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
231 if ((track = GetTrack(iTrack))->IsMuonTrack()) {
232 muonTracks->Add(track);
236 return muonTracks->GetEntriesFast();
240 void AliAODEvent::ReadFromTree(TTree *tree)
242 // connects aod event to tree
247 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
248 TIter next(fAODObjects);
250 while((el=(TNamed*)next())){
251 TString bname(el->GetName());
252 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
257 //______________________________________________________________________________
258 void AliAODEvent::Print(Option_t *) const
260 // Something meaningful should be implemented here.