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",
38 //______________________________________________________________________________
39 AliAODEvent::AliAODEvent() :
41 fAODObjects(new TList()),
49 // default constructor
52 //______________________________________________________________________________
53 AliAODEvent::~AliAODEvent()
59 //______________________________________________________________________________
60 void AliAODEvent::AddObject(TObject* obj)
62 // Add an object to the list of object.
63 // Please be aware that in order to increase performance you should
64 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
66 fAODObjects->AddLast(obj);
69 //______________________________________________________________________________
70 TObject *AliAODEvent::FindListObject(const char *objName)
72 // Return the pointer to the object with the given name.
74 return fAODObjects->FindObject(objName);
77 //______________________________________________________________________________
78 void AliAODEvent::CreateStdContent()
80 // create the standard AOD content and set pointers
82 // create standard objects and add them to the TList of objects
83 AddObject(new AliAODHeader());
84 AddObject(new TClonesArray("AliAODTrack", 0));
85 AddObject(new TClonesArray("AliAODVertex", 0));
86 AddObject(new TClonesArray("AliAODCluster", 0));
87 AddObject(new TClonesArray("AliAODJet", 0));
88 AddObject(new AliAODTracklets());
99 //______________________________________________________________________________
100 void AliAODEvent::SetStdNames()
102 // introduce the standard naming
104 if(fAODObjects->GetEntries()==kAODListN){
105 for(int i = 0;i < fAODObjects->GetEntries();i++){
106 TObject *fObj = fAODObjects->At(i);
107 if(fObj->InheritsFrom("TNamed")){
108 ((TNamed*)fObj)->SetName(fAODListName[i]);
110 else if(fObj->InheritsFrom("TClonesArray")){
111 ((TClonesArray*)fObj)->SetName(fAODListName[i]);
116 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
120 //______________________________________________________________________________
121 void AliAODEvent::GetStdContent()
123 // set pointers for standard content
125 fHeader = (AliAODHeader*)fAODObjects->FindObject("header");
126 fTracks = (TClonesArray*)fAODObjects->FindObject("tracks");
127 fVertices = (TClonesArray*)fAODObjects->FindObject("vertices");
128 fClusters = (TClonesArray*)fAODObjects->FindObject("clusters");
129 fJets = (TClonesArray*)fAODObjects->FindObject("jets");
130 fTracklets = (AliAODTracklets*)fAODObjects->FindObject("tracklets");
132 /* old implementation
133 fHeader = (AliAODHeader*)fAODObjects->At(0);
134 fTracks = (TClonesArray*)fAODObjects->At(1);
135 fVertices = (TClonesArray*)fAODObjects->At(2);
136 fClusters = (TClonesArray*)fAODObjects->At(3);
137 fJets = (TClonesArray*)fAODObjects->At(4);
138 fTracklets = (AliAODTracklets*)fAODObjects->At(5);
142 //______________________________________________________________________________
143 void AliAODEvent::ResetStd(Int_t trkArrSize, Int_t vtxArrSize)
145 // deletes content of standard arrays and resets size
147 if (trkArrSize > fTracks->GetSize())
148 fTracks->Expand(trkArrSize);
151 if (vtxArrSize > fVertices->GetSize())
152 fVertices->Expand(vtxArrSize);
155 void AliAODEvent::ClearStd()
157 // clears the standard arrays
162 fTracklets->DeleteContainer();
165 //______________________________________________________________________________
166 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
168 // fills the provided TRefArray with all found muon tracks
172 AliAODTrack *track = 0;
173 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
174 if ((track = GetTrack(iTrack))->IsMuonTrack()) {
175 muonTracks->Add(track);
179 return muonTracks->GetSize();
183 void AliAODEvent::ReadFromTree(TTree *tree)
185 // connects aod event to tree
190 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
191 TIter next(fAODObjects);
193 while((el=(TNamed*)next())){
194 TString bname(el->GetName());
195 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
200 //______________________________________________________________________________
201 void AliAODEvent::Print(Option_t *) const
203 // Something meaningful should be implemented here.