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()),
40 // default constructor
43 //______________________________________________________________________________
44 AliAODEvent::~AliAODEvent()
50 //______________________________________________________________________________
51 void AliAODEvent::AddObject(TObject* obj)
53 // Add an object to the list of object.
54 // Please be aware that in order to increase performance you should
55 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
57 fAODObjects->AddLast(obj);
60 //______________________________________________________________________________
61 TObject *AliAODEvent::GetObject(const char *objName) const
63 // Return the pointer to the object with the given name.
65 return fAODObjects->FindObject(objName);
68 //______________________________________________________________________________
69 void AliAODEvent::CreateStdContent()
71 // create the standard AOD content and set pointers
73 // create standard objects and add them to the TList of objects
74 AddObject(new AliAODHeader());
75 AddObject(new TClonesArray("AliAODTrack", 0));
76 AddObject(new TClonesArray("AliAODVertex", 0));
77 AddObject(new TClonesArray("AliAODCluster", 0));
78 AddObject(new TClonesArray("AliAODJet", 0));
84 fTracks->SetName("tracks");
85 fVertices->SetName("vertices");
86 fClusters->SetName("clusters");
87 fJets->SetName("jets");
91 //______________________________________________________________________________
92 void AliAODEvent::GetStdContent()
94 // set pointers for standard content
96 fHeader = (AliAODHeader*)fAODObjects->At(0);
97 fTracks = (TClonesArray*)fAODObjects->At(1);
98 fVertices = (TClonesArray*)fAODObjects->At(2);
99 fClusters = (TClonesArray*)fAODObjects->At(3);
100 fJets = (TClonesArray*)fAODObjects->At(4);
103 //______________________________________________________________________________
104 void AliAODEvent::ResetStd(Int_t trkArrSize, Int_t vtxArrSize)
106 // deletes content of standard arrays and resets size
108 if (trkArrSize > fTracks->GetSize())
109 fTracks->Expand(trkArrSize);
112 if (vtxArrSize > fVertices->GetSize())
113 fVertices->Expand(vtxArrSize);
116 void AliAODEvent::ClearStd()
118 // clears the standard arrays
125 //______________________________________________________________________________
126 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
128 // fills the provided TRefArray with all found muon tracks
132 AliAODTrack *track = 0;
133 for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) {
134 if ((track = GetTrack(iTrack))->GetMostProbablePID() == AliAODTrack::kMuon) {
135 muonTracks->Add(track);
139 return muonTracks->GetSize();
144 void AliAODEvent::ReadFromTree(TTree *tree)
146 // connects aod event to tree
148 fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList();
149 TIter next(fAODObjects);
151 while((el=(TNamed*)next())){
152 TString bname(el->GetName());
153 tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));