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