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",
43 //______________________________________________________________________________
44 AliAODEvent::AliAODEvent() :
46 fAODObjects(new TList()),
58 // default constructor
61 //______________________________________________________________________________
62 AliAODEvent::~AliAODEvent()
68 //______________________________________________________________________________
69 void AliAODEvent::AddObject(TObject* obj)
71 // Add an object to the list of object.
72 // Please be aware that in order to increase performance you should
73 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
75 fAODObjects->AddLast(obj);
78 //______________________________________________________________________________
79 TObject *AliAODEvent::FindListObject(const char *objName)
81 // Return the pointer to the object with the given name.
83 return fAODObjects->FindObject(objName);
86 //______________________________________________________________________________
87 void AliAODEvent::CreateStdContent()
89 // create the standard AOD content and set pointers
91 // create standard objects and add them to the TList of objects
92 AddObject(new AliAODHeader());
93 AddObject(new TClonesArray("AliAODTrack", 0));
94 AddObject(new TClonesArray("AliAODVertex", 0));
95 AddObject(new TClonesArray("AliAODv0", 0));
96 AddObject(new AliAODTracklets());
97 AddObject(new TClonesArray("AliAODJet", 0));
98 AddObject(new AliAODCaloCells());
99 AddObject(new TClonesArray("AliAODCaloCluster", 0));
100 AddObject(new TClonesArray("AliAODFmdCluster", 0));
101 AddObject(new TClonesArray("AliAODPmdCluster", 0));
106 // read back pointers
112 //______________________________________________________________________________
113 void AliAODEvent::SetStdNames()
115 // introduce the standard naming
117 if(fAODObjects->GetEntries()==kAODListN){
118 for(int i = 0;i < fAODObjects->GetEntries();i++){
119 TObject *fObj = fAODObjects->At(i);
120 if(fObj->InheritsFrom("TNamed")){
121 ((TNamed*)fObj)->SetName(fAODListName[i]);
123 else if(fObj->InheritsFrom("TClonesArray")){
124 ((TClonesArray*)fObj)->SetName(fAODListName[i]);
129 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
133 //______________________________________________________________________________
134 void AliAODEvent::GetStdContent()
136 // set pointers for standard content
138 fHeader = (AliAODHeader*)fAODObjects->FindObject("header");
139 fTracks = (TClonesArray*)fAODObjects->FindObject("tracks");
140 fVertices = (TClonesArray*)fAODObjects->FindObject("vertices");
141 fV0s = (TClonesArray*)fAODObjects->FindObject("v0s");
142 fTracklets = (AliAODTracklets*)fAODObjects->FindObject("tracklets");
143 fJets = (TClonesArray*)fAODObjects->FindObject("jets");
144 fCaloCells = (AliAODCaloCells*)fAODObjects->FindObject("caloCells");
145 fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters");
146 fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters");
147 fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters");
150 //______________________________________________________________________________
151 void AliAODEvent::ResetStd(Int_t trkArrSize,
159 // deletes content of standard arrays and resets size
162 if (trkArrSize > fTracks->GetSize())
163 fTracks->Expand(trkArrSize);
166 if (vtxArrSize > fVertices->GetSize())
167 fVertices->Expand(vtxArrSize);
170 if (v0ArrSize > fV0s->GetSize())
171 fV0s->Expand(v0ArrSize);
174 if (jetSize > fJets->GetSize())
175 fJets->Expand(jetSize);
177 fCaloClusters->Delete();
178 if (caloClusSize > fCaloClusters->GetSize())
179 fCaloClusters->Expand(caloClusSize);
181 fFmdClusters->Delete();
182 if (fmdClusSize > fFmdClusters->GetSize())
183 fFmdClusters->Expand(fmdClusSize);
185 fPmdClusters->Delete();
186 if (pmdClusSize > fPmdClusters->GetSize())
187 fPmdClusters->Expand(pmdClusSize);
190 void AliAODEvent::ClearStd()
192 // clears the standard arrays
196 fTracklets ->DeleteContainer();
198 fCaloCells ->DeleteContainer();
199 fCaloClusters ->Clear();
200 fFmdClusters ->Clear();
201 fPmdClusters ->Clear();
204 //______________________________________________________________________________
205 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
207 // fills the provided TRefArray with all found muon tracks
211 AliAODTrack *track = 0;
212 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
213 if ((track = GetTrack(iTrack))->IsMuonTrack()) {
214 muonTracks->Add(track);
218 return muonTracks->GetEntriesFast();
222 void AliAODEvent::ReadFromTree(TTree *tree)
224 // connects aod event to tree
229 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
230 TIter next(fAODObjects);
232 while((el=(TNamed*)next())){
233 TString bname(el->GetName());
234 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
239 //______________________________________________________________________________
240 void AliAODEvent::Print(Option_t *) const
242 // Something meaningful should be implemented here.