]>
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 | ||
5c1dc41f | 23 | #include <TROOT.h> |
ec4af4c1 | 24 | #include <TTree.h> |
5c1dc41f | 25 | #include <TFolder.h> |
298d3d58 | 26 | #include <TFriendElement.h> |
c8e4f399 | 27 | #include <TProcessID.h> |
28 | #include <TCollection.h> | |
a0df0b6a | 29 | #include "Riostream.h" |
df9db588 | 30 | #include "AliAODEvent.h" |
31 | #include "AliAODHeader.h" | |
32 | #include "AliAODTrack.h" | |
33 | ||
34 | ClassImp(AliAODEvent) | |
35 | ||
08e4c457 | 36 | // definition of std AOD member names |
37 | const char* AliAODEvent::fAODListName[kAODListN] = {"header", | |
38 | "tracks", | |
39 | "vertices", | |
3dd9f9e3 | 40 | "v0s", |
9a244178 | 41 | "cascades", |
3dd9f9e3 | 42 | "tracklets", |
08e4c457 | 43 | "jets", |
37792174 | 44 | "emcalCells", |
45 | "phosCells", | |
3dd9f9e3 | 46 | "caloClusters", |
47 | "fmdClusters", | |
48 | "pmdClusters" | |
9a244178 | 49 | |
3dd9f9e3 | 50 | }; |
df9db588 | 51 | //______________________________________________________________________________ |
52 | AliAODEvent::AliAODEvent() : | |
08e4c457 | 53 | AliVEvent(), |
df9db588 | 54 | fAODObjects(new TList()), |
5c1dc41f | 55 | fAODFolder(0), |
dd389a30 | 56 | fConnected(kFALSE), |
ec4af4c1 | 57 | fHeader(0), |
58 | fTracks(0), | |
59 | fVertices(0), | |
3dd9f9e3 | 60 | fV0s(0), |
9a244178 | 61 | fCascades(0), |
3dd9f9e3 | 62 | fTracklets(0), |
821f8f1d | 63 | fJets(0), |
37792174 | 64 | fEmcalCells(0), |
65 | fPhosCells(0), | |
3dd9f9e3 | 66 | fCaloClusters(0), |
67 | fFmdClusters(0), | |
68 | fPmdClusters(0) | |
df9db588 | 69 | { |
70 | // default constructor | |
71 | } | |
72 | ||
5c1dc41f | 73 | //______________________________________________________________________________ |
74 | AliAODEvent::AliAODEvent(const AliAODEvent& aod): | |
75 | AliVEvent(aod), | |
76 | fAODObjects(new TList()), | |
77 | fAODFolder(new TFolder()), | |
dd389a30 | 78 | fConnected(kFALSE), |
5c1dc41f | 79 | fHeader(new AliAODHeader(*aod.fHeader)), |
80 | fTracks(new TClonesArray(*aod.fTracks)), | |
81 | fVertices(new TClonesArray(*aod.fVertices)), | |
82 | fV0s(new TClonesArray(*aod.fV0s)), | |
9a244178 | 83 | fCascades(new TClonesArray(*aod.fCascades)), |
5c1dc41f | 84 | fTracklets(new AliAODTracklets(*aod.fTracklets)), |
85 | fJets(new TClonesArray(*aod.fJets)), | |
86 | fEmcalCells(new AliAODCaloCells(*aod.fEmcalCells)), | |
87 | fPhosCells(new AliAODCaloCells(*aod.fPhosCells)), | |
88 | fCaloClusters(new TClonesArray(*aod.fCaloClusters)), | |
89 | fFmdClusters(new TClonesArray(*aod.fFmdClusters)), | |
90 | fPmdClusters(new TClonesArray(*aod.fPmdClusters)) | |
91 | { | |
92 | // Copy constructor | |
93 | AddObject(fHeader); | |
94 | AddObject(fTracks); | |
95 | AddObject(fVertices); | |
96 | AddObject(fV0s); | |
9a244178 | 97 | AddObject(fCascades); |
5c1dc41f | 98 | AddObject(fTracklets); |
99 | AddObject(fJets); | |
100 | AddObject(fEmcalCells); | |
101 | AddObject(fPhosCells); | |
102 | AddObject(fCaloClusters); | |
103 | AddObject(fFmdClusters); | |
104 | AddObject(fPmdClusters); | |
dd389a30 | 105 | fConnected = aod.fConnected; |
5c1dc41f | 106 | GetStdContent(); |
107 | } | |
108 | ||
109 | //______________________________________________________________________________ | |
110 | AliAODEvent & AliAODEvent::operator=(const AliAODEvent& aod) { | |
111 | ||
112 | // Assignment operator | |
113 | ||
114 | if(&aod == this) return *this; | |
115 | AliVEvent::operator=(aod); | |
116 | ||
117 | fAODObjects = new TList(); | |
118 | fAODFolder = new TFolder(); | |
dd389a30 | 119 | fConnected = aod.fConnected; |
5c1dc41f | 120 | fHeader = new AliAODHeader(*aod.fHeader); |
121 | fTracks = new TClonesArray(*aod.fTracks); | |
122 | fVertices = new TClonesArray(*aod.fVertices); | |
123 | fV0s = new TClonesArray(*aod.fV0s); | |
9a244178 | 124 | fCascades = new TClonesArray(*aod.fCascades); |
5c1dc41f | 125 | fTracklets = new AliAODTracklets(*aod.fTracklets); |
126 | fJets = new TClonesArray(*aod.fJets); | |
127 | fEmcalCells = new AliAODCaloCells(*aod.fEmcalCells); | |
128 | fPhosCells = new AliAODCaloCells(*aod.fPhosCells); | |
129 | fCaloClusters = new TClonesArray(*aod.fCaloClusters); | |
130 | fFmdClusters = new TClonesArray(*aod.fFmdClusters); | |
131 | fPmdClusters = new TClonesArray(*aod.fPmdClusters); | |
132 | ||
5c1dc41f | 133 | |
134 | AddObject(fHeader); | |
135 | AddObject(fTracks); | |
136 | AddObject(fVertices); | |
137 | AddObject(fV0s); | |
9a244178 | 138 | AddObject(fCascades); |
5c1dc41f | 139 | AddObject(fTracklets); |
140 | AddObject(fJets); | |
141 | AddObject(fEmcalCells); | |
142 | AddObject(fPhosCells); | |
143 | AddObject(fCaloClusters); | |
144 | AddObject(fFmdClusters); | |
145 | AddObject(fPmdClusters); | |
146 | GetStdContent(); | |
147 | return *this; | |
148 | } | |
149 | ||
150 | ||
df9db588 | 151 | //______________________________________________________________________________ |
152 | AliAODEvent::~AliAODEvent() | |
153 | { | |
ec4af4c1 | 154 | // destructor |
dd389a30 | 155 | if(fAODObjects&&!fConnected) |
156 | { | |
157 | delete fAODObjects; | |
158 | fAODObjects = 0; | |
159 | } | |
160 | ||
5c1dc41f | 161 | delete fAODFolder; |
df9db588 | 162 | } |
163 | ||
164 | //______________________________________________________________________________ | |
165 | void AliAODEvent::AddObject(TObject* obj) | |
166 | { | |
4b3de353 | 167 | // Add an object to the list of objects. |
df9db588 | 168 | // Please be aware that in order to increase performance you should |
169 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
170 | ||
171 | fAODObjects->AddLast(obj); | |
172 | } | |
173 | ||
4b3de353 | 174 | //______________________________________________________________________________ |
175 | void AliAODEvent::RemoveObject(TObject* obj) | |
176 | { | |
177 | // Removes an object from the list of objects. | |
178 | ||
179 | fAODObjects->Remove(obj); | |
180 | } | |
181 | ||
df9db588 | 182 | //______________________________________________________________________________ |
08e4c457 | 183 | TObject *AliAODEvent::FindListObject(const char *objName) |
df9db588 | 184 | { |
185 | // Return the pointer to the object with the given name. | |
186 | ||
187 | return fAODObjects->FindObject(objName); | |
188 | } | |
189 | ||
190 | //______________________________________________________________________________ | |
191 | void AliAODEvent::CreateStdContent() | |
192 | { | |
193 | // create the standard AOD content and set pointers | |
194 | ||
195 | // create standard objects and add them to the TList of objects | |
196 | AddObject(new AliAODHeader()); | |
197 | AddObject(new TClonesArray("AliAODTrack", 0)); | |
198 | AddObject(new TClonesArray("AliAODVertex", 0)); | |
3dd9f9e3 | 199 | AddObject(new TClonesArray("AliAODv0", 0)); |
9a244178 | 200 | AddObject(new TClonesArray("AliAODcascade", 0)); |
821f8f1d | 201 | AddObject(new AliAODTracklets()); |
3dd9f9e3 | 202 | AddObject(new TClonesArray("AliAODJet", 0)); |
203 | AddObject(new AliAODCaloCells()); | |
37792174 | 204 | AddObject(new AliAODCaloCells()); |
3dd9f9e3 | 205 | AddObject(new TClonesArray("AliAODCaloCluster", 0)); |
206 | AddObject(new TClonesArray("AliAODFmdCluster", 0)); | |
207 | AddObject(new TClonesArray("AliAODPmdCluster", 0)); | |
08e4c457 | 208 | // set names |
209 | SetStdNames(); | |
210 | ||
df9db588 | 211 | // read back pointers |
212 | GetStdContent(); | |
5c1dc41f | 213 | CreateStdFolders(); |
08e4c457 | 214 | return; |
df9db588 | 215 | } |
216 | ||
c8e4f399 | 217 | void AliAODEvent::MakeEntriesReferencable() |
218 | { | |
219 | // Make all entries referencable in a subsequent process | |
220 | // | |
221 | TIter next(fAODObjects); | |
222 | TObject* obj; | |
8ac4fa64 | 223 | while ((obj = next())) |
c8e4f399 | 224 | { |
225 | if(obj->InheritsFrom("TCollection")) | |
226 | { | |
227 | AssignIDtoCollection((TCollection*)obj); | |
228 | } | |
229 | } | |
230 | } | |
231 | ||
08e4c457 | 232 | //______________________________________________________________________________ |
233 | void AliAODEvent::SetStdNames() | |
234 | { | |
235 | // introduce the standard naming | |
236 | ||
237 | if(fAODObjects->GetEntries()==kAODListN){ | |
238 | for(int i = 0;i < fAODObjects->GetEntries();i++){ | |
239 | TObject *fObj = fAODObjects->At(i); | |
240 | if(fObj->InheritsFrom("TNamed")){ | |
241 | ((TNamed*)fObj)->SetName(fAODListName[i]); | |
242 | } | |
243 | else if(fObj->InheritsFrom("TClonesArray")){ | |
244 | ((TClonesArray*)fObj)->SetName(fAODListName[i]); | |
245 | } | |
246 | } | |
247 | } | |
248 | else{ | |
249 | printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__); | |
250 | } | |
251 | } | |
252 | ||
5c1dc41f | 253 | void AliAODEvent::CreateStdFolders() |
254 | { | |
255 | // Create the standard folder structure | |
256 | fAODFolder = gROOT->GetRootFolder()->AddFolder("AOD", "AOD"); | |
257 | if(fAODObjects->GetEntries()==kAODListN){ | |
258 | for(int i = 0;i < fAODObjects->GetEntries();i++){ | |
259 | TObject *fObj = fAODObjects->At(i); | |
260 | if(fObj->InheritsFrom("TClonesArray")){ | |
261 | fAODFolder->AddFolder(fAODListName[i], fAODListName[i], (TCollection*) fObj); | |
262 | } else { | |
263 | fAODFolder->AddFolder(fAODListName[i], fAODListName[i], 0); | |
264 | } | |
265 | } | |
266 | } | |
267 | else{ | |
268 | printf("%s:%d CreateStdFolders() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__); | |
269 | } | |
270 | } | |
271 | ||
df9db588 | 272 | //______________________________________________________________________________ |
ec4af4c1 | 273 | void AliAODEvent::GetStdContent() |
df9db588 | 274 | { |
275 | // set pointers for standard content | |
276 | ||
3dd9f9e3 | 277 | fHeader = (AliAODHeader*)fAODObjects->FindObject("header"); |
278 | fTracks = (TClonesArray*)fAODObjects->FindObject("tracks"); | |
279 | fVertices = (TClonesArray*)fAODObjects->FindObject("vertices"); | |
280 | fV0s = (TClonesArray*)fAODObjects->FindObject("v0s"); | |
9a244178 | 281 | fCascades = (TClonesArray*)fAODObjects->FindObject("cascades"); |
3dd9f9e3 | 282 | fTracklets = (AliAODTracklets*)fAODObjects->FindObject("tracklets"); |
283 | fJets = (TClonesArray*)fAODObjects->FindObject("jets"); | |
37792174 | 284 | fEmcalCells = (AliAODCaloCells*)fAODObjects->FindObject("emcalCells"); |
285 | fPhosCells = (AliAODCaloCells*)fAODObjects->FindObject("phosCells"); | |
3dd9f9e3 | 286 | fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters"); |
287 | fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters"); | |
288 | fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters"); | |
df9db588 | 289 | } |
290 | ||
291 | //______________________________________________________________________________ | |
3dd9f9e3 | 292 | void AliAODEvent::ResetStd(Int_t trkArrSize, |
293 | Int_t vtxArrSize, | |
9a244178 | 294 | Int_t v0ArrSize, |
295 | Int_t cascadeArrSize, | |
3dd9f9e3 | 296 | Int_t jetSize, |
297 | Int_t caloClusSize, | |
298 | Int_t fmdClusSize, | |
9a244178 | 299 | Int_t pmdClusSize |
300 | ) | |
df9db588 | 301 | { |
3dd9f9e3 | 302 | // deletes content of standard arrays and resets size |
9a244178 | 303 | |
df9db588 | 304 | fTracks->Delete(); |
305 | if (trkArrSize > fTracks->GetSize()) | |
306 | fTracks->Expand(trkArrSize); | |
307 | ||
308 | fVertices->Delete(); | |
309 | if (vtxArrSize > fVertices->GetSize()) | |
310 | fVertices->Expand(vtxArrSize); | |
9a244178 | 311 | |
3dd9f9e3 | 312 | fV0s->Delete(); |
313 | if (v0ArrSize > fV0s->GetSize()) | |
314 | fV0s->Expand(v0ArrSize); | |
9a244178 | 315 | |
316 | fCascades->Delete(); | |
317 | if (cascadeArrSize > fCascades->GetSize()) | |
318 | fCascades->Expand(cascadeArrSize); | |
319 | ||
3dd9f9e3 | 320 | fJets->Delete(); |
9a244178 | 321 | if (jetSize > fJets->GetSize()) |
3dd9f9e3 | 322 | fJets->Expand(jetSize); |
323 | ||
324 | fCaloClusters->Delete(); | |
325 | if (caloClusSize > fCaloClusters->GetSize()) | |
326 | fCaloClusters->Expand(caloClusSize); | |
327 | ||
328 | fFmdClusters->Delete(); | |
329 | if (fmdClusSize > fFmdClusters->GetSize()) | |
330 | fFmdClusters->Expand(fmdClusSize); | |
331 | ||
332 | fPmdClusters->Delete(); | |
333 | if (pmdClusSize > fPmdClusters->GetSize()) | |
334 | fPmdClusters->Expand(pmdClusSize); | |
6989bff3 | 335 | |
336 | // Reset the tracklets | |
337 | fTracklets->DeleteContainer(); | |
338 | fPhosCells->DeleteContainer(); | |
339 | fEmcalCells->DeleteContainer(); | |
340 | ||
df9db588 | 341 | } |
342 | ||
ec4af4c1 | 343 | void AliAODEvent::ClearStd() |
344 | { | |
345 | // clears the standard arrays | |
d8f5fda5 | 346 | fHeader ->RemoveQTheta(); |
347 | fTracks ->Delete(); | |
348 | fVertices ->Delete(); | |
349 | fV0s ->Delete(); | |
9a244178 | 350 | fCascades ->Delete(); |
3dd9f9e3 | 351 | fTracklets ->DeleteContainer(); |
1c37410a | 352 | fJets ->Delete(); |
37792174 | 353 | fEmcalCells ->DeleteContainer(); |
354 | fPhosCells ->DeleteContainer(); | |
d8f5fda5 | 355 | fCaloClusters ->Delete(); |
37792174 | 356 | fFmdClusters ->Clear(); |
357 | fPmdClusters ->Clear(); | |
ec4af4c1 | 358 | } |
359 | ||
78902954 | 360 | //_________________________________________________________________ |
361 | Int_t AliAODEvent::GetPHOSClusters(TRefArray *clusters) const | |
362 | { | |
363 | // fills the provided TRefArray with all found phos clusters | |
364 | ||
365 | clusters->Clear(); | |
366 | ||
367 | AliAODCaloCluster *cl = 0; | |
a0df0b6a | 368 | Bool_t first = kTRUE; |
78902954 | 369 | for (Int_t i = 0; i < GetNCaloClusters() ; i++) { |
78902954 | 370 | if ( (cl = GetCaloCluster(i)) ) { |
371 | if (cl->IsPHOSCluster()){ | |
a0df0b6a | 372 | if(first) { |
373 | new (clusters) TRefArray(TProcessID::GetProcessWithUID(cl)); | |
374 | first=kFALSE; | |
375 | } | |
78902954 | 376 | clusters->Add(cl); |
a0df0b6a | 377 | //printf("IsPHOS cluster %d, E %2.3f Size: %d \n",i,cl->E(),clusters->GetEntriesFast()); |
78902954 | 378 | } |
379 | } | |
380 | } | |
381 | return clusters->GetEntriesFast(); | |
382 | } | |
383 | ||
384 | //_________________________________________________________________ | |
385 | Int_t AliAODEvent::GetEMCALClusters(TRefArray *clusters) const | |
386 | { | |
387 | // fills the provided TRefArray with all found emcal clusters | |
388 | ||
389 | clusters->Clear(); | |
78902954 | 390 | AliAODCaloCluster *cl = 0; |
a0df0b6a | 391 | Bool_t first = kTRUE; |
78902954 | 392 | for (Int_t i = 0; i < GetNCaloClusters(); i++) { |
78902954 | 393 | if ( (cl = GetCaloCluster(i)) ) { |
394 | if (cl->IsEMCALCluster()){ | |
a0df0b6a | 395 | if(first) { |
396 | new (clusters) TRefArray(TProcessID::GetProcessWithUID(cl)); | |
397 | first=kFALSE; | |
398 | } | |
78902954 | 399 | clusters->Add(cl); |
a0df0b6a | 400 | //printf("IsEMCal cluster %d, E %2.3f Size: %d \n",i,cl->E(),clusters->GetEntriesFast()); |
78902954 | 401 | } |
402 | } | |
403 | } | |
404 | return clusters->GetEntriesFast(); | |
405 | } | |
406 | ||
407 | ||
fb41236c | 408 | //______________________________________________________________________________ |
409 | Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const | |
410 | { | |
411 | // fills the provided TRefArray with all found muon tracks | |
df9db588 | 412 | |
fb41236c | 413 | muonTracks->Clear(); |
df9db588 | 414 | |
fb41236c | 415 | AliAODTrack *track = 0; |
416 | for (Int_t iTrack = 0; iTrack < GetNTracks(); iTrack++) { | |
08e4c457 | 417 | if ((track = GetTrack(iTrack))->IsMuonTrack()) { |
fb41236c | 418 | muonTracks->Add(track); |
419 | } | |
420 | } | |
421 | ||
3dd9f9e3 | 422 | return muonTracks->GetEntriesFast(); |
fb41236c | 423 | } |
ec4af4c1 | 424 | |
425 | ||
3b93c32a | 426 | void AliAODEvent::ReadFromTree(TTree *tree, Option_t* opt /*= ""*/) |
8ff33247 | 427 | { |
3b93c32a | 428 | // Connects aod event to tree |
08e4c457 | 429 | |
61cb38c7 | 430 | if(!tree){ |
431 | Printf("%s %d AliAODEvent::ReadFromTree() Zero Pointer to Tree \n",(char*)__FILE__,__LINE__); | |
432 | return; | |
433 | } | |
08e4c457 | 434 | // load the TTree |
61cb38c7 | 435 | if(!tree->GetTree())tree->LoadTree(0); |
436 | ||
437 | // Try to find AliAODEvent | |
438 | AliAODEvent *aodEvent = 0; | |
439 | aodEvent = (AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent"); | |
440 | if(aodEvent){ | |
441 | // Check if already connected to tree | |
442 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("AODObjectsConnectedToTree")); | |
3b93c32a | 443 | if (connectedList && (strcmp(opt, "reconnect"))) { |
d8f5fda5 | 444 | // If connected use the connected list of objects |
3b93c32a | 445 | fAODObjects->Delete(); |
446 | fAODObjects = connectedList; | |
447 | GetStdContent(); | |
dd389a30 | 448 | fConnected = kTRUE; |
3b93c32a | 449 | return; |
d8f5fda5 | 450 | } |
61cb38c7 | 451 | // Connect to tree |
452 | // prevent a memory leak when reading back the TList | |
d8f5fda5 | 453 | if (!(strcmp(opt, "reconnect"))) fAODObjects->Delete(); |
316cf4cc | 454 | |
61cb38c7 | 455 | // create a new TList from the UserInfo TList... |
456 | // copy constructor does not work... | |
457 | fAODObjects = (TList*)(aodEvent->GetList()->Clone()); | |
316cf4cc | 458 | fAODObjects->SetOwner(kTRUE); |
61cb38c7 | 459 | if(fAODObjects->GetEntries()<kAODListN){ |
460 | printf("%s %d AliAODEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n", | |
461 | (char*)__FILE__,__LINE__,fAODObjects->GetEntries(),kAODListN); | |
462 | } | |
298d3d58 | 463 | // |
464 | // Let's find out whether we have friends | |
ced57103 | 465 | TList* friendL = tree->GetTree()->GetListOfFriends(); |
298d3d58 | 466 | if (friendL) |
467 | { | |
468 | TIter next(friendL); | |
469 | TFriendElement* fe; | |
470 | while ((fe = (TFriendElement*)next())){ | |
471 | aodEvent = (AliAODEvent*)(fe->GetTree()->GetUserInfo()->FindObject("AliAODEvent")); | |
472 | if (!aodEvent) { | |
473 | printf("No UserInfo on tree \n"); | |
474 | } else { | |
475 | ||
476 | TList* objL = (TList*)(aodEvent->GetList()->Clone()); | |
477 | printf("Get list of object from tree %d !!\n", objL->GetEntries()); | |
478 | TIter nextobject(objL); | |
479 | TObject* obj = 0; | |
8ac4fa64 | 480 | while((obj = nextobject())) |
298d3d58 | 481 | { |
482 | printf("Adding object from friend %s !\n", obj->GetName()); | |
483 | fAODObjects->Add(obj); | |
484 | } // object "branch" loop | |
485 | } // has userinfo | |
486 | } // friend loop | |
487 | } // has friends | |
488 | ||
489 | ||
490 | // set the branch addresses | |
61cb38c7 | 491 | TIter next(fAODObjects); |
492 | TNamed *el; | |
493 | while((el=(TNamed*)next())){ | |
494 | TString bname(el->GetName()); | |
495 | // check if branch exists under this Name | |
ced57103 | 496 | TBranch *br = tree->GetTree()->GetBranch(bname.Data()); |
61cb38c7 | 497 | if(br){ |
498 | tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el)); | |
ced57103 | 499 | } else { |
298d3d58 | 500 | br = tree->GetBranch(Form("%s.",bname.Data())); |
501 | if(br){ | |
502 | tree->SetBranchAddress(Form("%s.",bname.Data()),fAODObjects->GetObjectRef(el)); | |
503 | } | |
504 | else{ | |
505 | printf("%s %d AliAODEvent::ReadFromTree() No Branch found with Name %s. \n", | |
506 | (char*)__FILE__,__LINE__,bname.Data()); | |
507 | } | |
61cb38c7 | 508 | } |
509 | } | |
61cb38c7 | 510 | GetStdContent(); |
511 | // when reading back we are not owner of the list | |
512 | // must not delete it | |
316cf4cc | 513 | fAODObjects->SetOwner(kTRUE); |
61cb38c7 | 514 | fAODObjects->SetName("AODObjectsConnectedToTree"); |
515 | // we are not owner of the list objects | |
516 | // must not delete it | |
517 | tree->GetUserInfo()->Add(fAODObjects); | |
dd389a30 | 518 | fConnected = kTRUE; |
61cb38c7 | 519 | }// no aodEvent |
520 | else { | |
521 | // we can't get the list from the user data, create standard content | |
522 | // and set it by hand | |
523 | CreateStdContent(); | |
524 | TIter next(fAODObjects); | |
525 | TNamed *el; | |
526 | while((el=(TNamed*)next())){ | |
527 | TString bname(el->GetName()); | |
528 | tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el)); | |
529 | } | |
530 | GetStdContent(); | |
531 | // when reading back we are not owner of the list | |
532 | // must not delete it | |
316cf4cc | 533 | fAODObjects->SetOwner(kTRUE); |
08e4c457 | 534 | } |
8ff33247 | 535 | } |
536 | ||
08e4c457 | 537 | //______________________________________________________________________________ |
538 | void AliAODEvent::Print(Option_t *) const | |
539 | { | |
4922c144 | 540 | // Print the names of the all branches |
541 | TIter next(fAODObjects); | |
542 | TNamed *el; | |
543 | Printf(">>>>> AOD Content <<<<<"); | |
544 | while((el=(TNamed*)next())){ | |
545 | Printf(">> %s ",el->GetName()); | |
546 | } | |
547 | Printf(">>>>> <<<<<"); | |
08e4c457 | 548 | |
549 | return; | |
550 | } | |
c8e4f399 | 551 | |
552 | void AliAODEvent::AssignIDtoCollection(TCollection* col) | |
553 | { | |
554 | // Static method which assigns a ID to each object in a collection | |
555 | // In this way the objects are marked as referenced and written with | |
556 | // an ID. This has the advantage that TRefs to this objects can be | |
557 | // written by a subsequent process. | |
558 | TIter next(col); | |
559 | TObject* obj; | |
8ac4fa64 | 560 | while ((obj = next())) |
c8e4f399 | 561 | TProcessID::AssignID(obj); |
562 | } |