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 //______________________________________________________________________________
32 AliAODEvent::AliAODEvent() :
33 fAODObjects(new TList()),
41 // default constructor
44 //______________________________________________________________________________
45 AliAODEvent::~AliAODEvent()
51 //______________________________________________________________________________
52 void AliAODEvent::AddObject(TObject* obj)
54 // Add an object to the list of object.
55 // Please be aware that in order to increase performance you should
56 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
58 fAODObjects->AddLast(obj);
61 //______________________________________________________________________________
62 TObject *AliAODEvent::GetObject(const char *objName) const
64 // Return the pointer to the object with the given name.
66 return fAODObjects->FindObject(objName);
69 //______________________________________________________________________________
70 void AliAODEvent::CreateStdContent()
72 // create the standard AOD content and set pointers
74 // create standard objects and add them to the TList of objects
75 AddObject(new AliAODHeader());
76 AddObject(new TClonesArray("AliAODTrack", 0));
77 AddObject(new TClonesArray("AliAODVertex", 0));
78 AddObject(new TClonesArray("AliAODCluster", 0));
79 AddObject(new TClonesArray("AliAODJet", 0));
80 AddObject(new AliAODTracklets());
86 fTracks->SetName("tracks");
87 fVertices->SetName("vertices");
88 fClusters->SetName("clusters");
89 fJets->SetName("jets");
90 fTracklets->SetName("tracklets");
93 //______________________________________________________________________________
94 void AliAODEvent::GetStdContent()
96 // set pointers for standard content
98 fHeader = (AliAODHeader*)fAODObjects->At(0);
99 fTracks = (TClonesArray*)fAODObjects->At(1);
100 fVertices = (TClonesArray*)fAODObjects->At(2);
101 fClusters = (TClonesArray*)fAODObjects->At(3);
102 fJets = (TClonesArray*)fAODObjects->At(4);
103 fTracklets = (AliAODTracklets*)fAODObjects->At(5);
106 //______________________________________________________________________________
107 void AliAODEvent::ResetStd(Int_t trkArrSize, Int_t vtxArrSize)
109 // deletes content of standard arrays and resets size
111 if (trkArrSize > fTracks->GetSize())
112 fTracks->Expand(trkArrSize);
115 if (vtxArrSize > fVertices->GetSize())
116 fVertices->Expand(vtxArrSize);
119 void AliAODEvent::ClearStd()
121 // clears the standard arrays
126 fTracklets->DeleteContainer();
129 //______________________________________________________________________________
130 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
132 // fills the provided TRefArray with all found muon tracks
136 AliAODTrack *track = 0;
137 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
138 if ((track = GetTrack(iTrack))->GetMostProbablePID() == AliAODTrack::kMuon) {
139 muonTracks->Add(track);
143 return muonTracks->GetSize();
148 void AliAODEvent::ReadFromTree(TTree *tree)
150 // connects aod event to tree
152 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
153 TIter next(fAODObjects);
155 while((el=(TNamed*)next())){
156 TString bname(el->GetName());
157 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));