]>
Commit | Line | Data |
---|---|---|
df9db588 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // AOD base class | |
20 | // Author: Markus Oldenburg, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
ec4af4c1 | 23 | #include <TTree.h> |
24 | ||
df9db588 | 25 | #include "AliAODEvent.h" |
26 | #include "AliAODHeader.h" | |
27 | #include "AliAODTrack.h" | |
28 | ||
29 | ClassImp(AliAODEvent) | |
30 | ||
08e4c457 | 31 | // definition of std AOD member names |
32 | const char* AliAODEvent::fAODListName[kAODListN] = {"header", | |
33 | "tracks", | |
34 | "vertices", | |
3dd9f9e3 | 35 | "v0s", |
36 | "tracklets", | |
08e4c457 | 37 | "jets", |
3dd9f9e3 | 38 | "caloCells", |
39 | "caloClusters", | |
40 | "fmdClusters", | |
41 | "pmdClusters" | |
42 | }; | |
df9db588 | 43 | //______________________________________________________________________________ |
44 | AliAODEvent::AliAODEvent() : | |
08e4c457 | 45 | AliVEvent(), |
df9db588 | 46 | fAODObjects(new TList()), |
ec4af4c1 | 47 | fHeader(0), |
48 | fTracks(0), | |
49 | fVertices(0), | |
3dd9f9e3 | 50 | fV0s(0), |
51 | fTracklets(0), | |
821f8f1d | 52 | fJets(0), |
3dd9f9e3 | 53 | fCaloCells(0), |
54 | fCaloClusters(0), | |
55 | fFmdClusters(0), | |
56 | fPmdClusters(0) | |
df9db588 | 57 | { |
58 | // default constructor | |
59 | } | |
60 | ||
61 | //______________________________________________________________________________ | |
62 | AliAODEvent::~AliAODEvent() | |
63 | { | |
ec4af4c1 | 64 | // destructor |
65 | delete fAODObjects; | |
df9db588 | 66 | } |
67 | ||
68 | //______________________________________________________________________________ | |
69 | void AliAODEvent::AddObject(TObject* obj) | |
70 | { | |
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. | |
74 | ||
75 | fAODObjects->AddLast(obj); | |
76 | } | |
77 | ||
78 | //______________________________________________________________________________ | |
08e4c457 | 79 | TObject *AliAODEvent::FindListObject(const char *objName) |
df9db588 | 80 | { |
81 | // Return the pointer to the object with the given name. | |
82 | ||
83 | return fAODObjects->FindObject(objName); | |
84 | } | |
85 | ||
86 | //______________________________________________________________________________ | |
87 | void AliAODEvent::CreateStdContent() | |
88 | { | |
89 | // create the standard AOD content and set pointers | |
90 | ||
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)); | |
3dd9f9e3 | 95 | AddObject(new TClonesArray("AliAODv0", 0)); |
821f8f1d | 96 | AddObject(new AliAODTracklets()); |
3dd9f9e3 | 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)); | |
102 | ||
08e4c457 | 103 | // set names |
104 | SetStdNames(); | |
105 | ||
df9db588 | 106 | // read back pointers |
107 | GetStdContent(); | |
108 | ||
08e4c457 | 109 | return; |
df9db588 | 110 | } |
111 | ||
08e4c457 | 112 | //______________________________________________________________________________ |
113 | void AliAODEvent::SetStdNames() | |
114 | { | |
115 | // introduce the standard naming | |
116 | ||
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]); | |
122 | } | |
123 | else if(fObj->InheritsFrom("TClonesArray")){ | |
124 | ((TClonesArray*)fObj)->SetName(fAODListName[i]); | |
125 | } | |
126 | } | |
127 | } | |
128 | else{ | |
129 | printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__); | |
130 | } | |
131 | } | |
132 | ||
df9db588 | 133 | //______________________________________________________________________________ |
ec4af4c1 | 134 | void AliAODEvent::GetStdContent() |
df9db588 | 135 | { |
136 | // set pointers for standard content | |
137 | ||
3dd9f9e3 | 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"); | |
df9db588 | 148 | } |
149 | ||
150 | //______________________________________________________________________________ | |
3dd9f9e3 | 151 | void AliAODEvent::ResetStd(Int_t trkArrSize, |
152 | Int_t vtxArrSize, | |
153 | Int_t v0ArrSize, | |
154 | Int_t jetSize, | |
155 | Int_t caloClusSize, | |
156 | Int_t fmdClusSize, | |
157 | Int_t pmdClusSize) | |
df9db588 | 158 | { |
3dd9f9e3 | 159 | // deletes content of standard arrays and resets size |
160 | ||
df9db588 | 161 | fTracks->Delete(); |
162 | if (trkArrSize > fTracks->GetSize()) | |
163 | fTracks->Expand(trkArrSize); | |
164 | ||
165 | fVertices->Delete(); | |
166 | if (vtxArrSize > fVertices->GetSize()) | |
167 | fVertices->Expand(vtxArrSize); | |
3dd9f9e3 | 168 | |
169 | fV0s->Delete(); | |
170 | if (v0ArrSize > fV0s->GetSize()) | |
171 | fV0s->Expand(v0ArrSize); | |
172 | ||
173 | fJets->Delete(); | |
174 | if (jetSize > fJets->GetSize()) | |
175 | fJets->Expand(jetSize); | |
176 | ||
177 | fCaloClusters->Delete(); | |
178 | if (caloClusSize > fCaloClusters->GetSize()) | |
179 | fCaloClusters->Expand(caloClusSize); | |
180 | ||
181 | fFmdClusters->Delete(); | |
182 | if (fmdClusSize > fFmdClusters->GetSize()) | |
183 | fFmdClusters->Expand(fmdClusSize); | |
184 | ||
185 | fPmdClusters->Delete(); | |
186 | if (pmdClusSize > fPmdClusters->GetSize()) | |
187 | fPmdClusters->Expand(pmdClusSize); | |
df9db588 | 188 | } |
189 | ||
ec4af4c1 | 190 | void AliAODEvent::ClearStd() |
191 | { | |
192 | // clears the standard arrays | |
3dd9f9e3 | 193 | fTracks ->Clear(); |
194 | fVertices ->Clear(); | |
195 | fV0s ->Clear(); | |
196 | fTracklets ->DeleteContainer(); | |
197 | fJets ->Clear(); | |
198 | fCaloCells ->DeleteContainer(); | |
199 | fCaloClusters ->Clear(); | |
200 | fFmdClusters ->Clear(); | |
201 | fPmdClusters ->Clear(); | |
ec4af4c1 | 202 | } |
203 | ||
fb41236c | 204 | //______________________________________________________________________________ |
205 | Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const | |
206 | { | |
207 | // fills the provided TRefArray with all found muon tracks | |
df9db588 | 208 | |
fb41236c | 209 | muonTracks->Clear(); |
df9db588 | 210 | |
fb41236c | 211 | AliAODTrack *track = 0; |
212 | for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) { | |
08e4c457 | 213 | if ((track = GetTrack(iTrack))->IsMuonTrack()) { |
fb41236c | 214 | muonTracks->Add(track); |
215 | } | |
216 | } | |
217 | ||
3dd9f9e3 | 218 | return muonTracks->GetEntriesFast(); |
fb41236c | 219 | } |
ec4af4c1 | 220 | |
221 | ||
8ff33247 | 222 | void AliAODEvent::ReadFromTree(TTree *tree) |
223 | { | |
08e4c457 | 224 | // connects aod event to tree |
225 | ||
226 | // load the TTree | |
227 | tree->LoadTree(0); | |
228 | ||
229 | fAODObjects = (TList*)((AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"))->GetList(); | |
230 | TIter next(fAODObjects); | |
231 | TNamed *el; | |
232 | while((el=(TNamed*)next())){ | |
233 | TString bname(el->GetName()); | |
234 | tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el)); | |
235 | } | |
236 | GetStdContent(); | |
8ff33247 | 237 | } |
238 | ||
08e4c457 | 239 | //______________________________________________________________________________ |
240 | void AliAODEvent::Print(Option_t *) const | |
241 | { | |
242 | // Something meaningful should be implemented here. | |
243 | ||
244 | return; | |
245 | } |