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 object.
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 TObject *AliAODEvent::FindListObject(const char *objName)
83 // Return the pointer to the object with the given name.
85 return fAODObjects->FindObject(objName);
88 //______________________________________________________________________________
89 void AliAODEvent::CreateStdContent()
91 // create the standard AOD content and set pointers
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));
97 AddObject(new TClonesArray("AliAODv0", 0));
98 AddObject(new AliAODTracklets());
99 AddObject(new TClonesArray("AliAODJet", 0));
100 AddObject(new AliAODCaloCells());
101 AddObject(new AliAODCaloCells());
102 AddObject(new TClonesArray("AliAODCaloCluster", 0));
103 AddObject(new TClonesArray("AliAODFmdCluster", 0));
104 AddObject(new TClonesArray("AliAODPmdCluster", 0));
109 // read back pointers
115 //______________________________________________________________________________
116 void AliAODEvent::SetStdNames()
118 // introduce the standard naming
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]);
126 else if(fObj->InheritsFrom("TClonesArray")){
127 ((TClonesArray*)fObj)->SetName(fAODListName[i]);
132 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
136 //______________________________________________________________________________
137 void AliAODEvent::GetStdContent()
139 // set pointers for standard content
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");
147 fEmcalCells = (AliAODCaloCells*)fAODObjects->FindObject("emcalCells");
148 fPhosCells = (AliAODCaloCells*)fAODObjects->FindObject("phosCells");
149 fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters");
150 fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters");
151 fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters");
154 //______________________________________________________________________________
155 void AliAODEvent::ResetStd(Int_t trkArrSize,
163 // deletes content of standard arrays and resets size
166 if (trkArrSize > fTracks->GetSize())
167 fTracks->Expand(trkArrSize);
170 if (vtxArrSize > fVertices->GetSize())
171 fVertices->Expand(vtxArrSize);
174 if (v0ArrSize > fV0s->GetSize())
175 fV0s->Expand(v0ArrSize);
178 if (jetSize > fJets->GetSize())
179 fJets->Expand(jetSize);
181 fCaloClusters->Delete();
182 if (caloClusSize > fCaloClusters->GetSize())
183 fCaloClusters->Expand(caloClusSize);
185 fFmdClusters->Delete();
186 if (fmdClusSize > fFmdClusters->GetSize())
187 fFmdClusters->Expand(fmdClusSize);
189 fPmdClusters->Delete();
190 if (pmdClusSize > fPmdClusters->GetSize())
191 fPmdClusters->Expand(pmdClusSize);
194 void AliAODEvent::ClearStd()
196 // clears the standard arrays
200 fTracklets ->DeleteContainer();
202 fEmcalCells ->DeleteContainer();
203 fPhosCells ->DeleteContainer();
204 fCaloClusters ->Clear();
205 fFmdClusters ->Clear();
206 fPmdClusters ->Clear();
209 //______________________________________________________________________________
210 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
212 // fills the provided TRefArray with all found muon tracks
216 AliAODTrack *track = 0;
217 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
218 if ((track = GetTrack(iTrack))->IsMuonTrack()) {
219 muonTracks->Add(track);
223 return muonTracks->GetEntriesFast();
227 void AliAODEvent::ReadFromTree(TTree *tree)
229 // connects aod event to tree
234 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
235 TIter next(fAODObjects);
237 while((el=(TNamed*)next())){
238 TString bname(el->GetName());
239 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
244 //______________________________________________________________________________
245 void AliAODEvent::Print(Option_t *) const
247 // Something meaningful should be implemented here.