]>
Commit | Line | Data |
---|---|---|
af885e0f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | //----------------------------------------------------------------- | |
f56a9fa7 | 19 | // Implementation of the AliESDEvent class |
20 | // This is the class to deal with during the phisical analysis of data. | |
21 | // It also ensures the backward compatibility with the old ESD format. | |
22 | // | |
23 | // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch | |
af885e0f | 24 | //----------------------------------------------------------------- |
25 | ||
26 | #include "TList.h" | |
27 | #include <TNamed.h> | |
28 | ||
29 | #include "AliESDEvent.h" | |
30 | #include "AliESDfriend.h" | |
31 | #include "AliESDVZERO.h" | |
32 | #include "AliESDHLTtrack.h" | |
33 | #include "AliESDFMD.h" | |
34 | #include "AliESD.h" | |
35 | ||
36 | ||
37 | ClassImp(AliESDEvent) | |
38 | ||
60e8f114 | 39 | |
40 | ||
41 | // here we define the names, some classes are no TNamed, therefore the classnames | |
42 | // are the Names | |
43 | const char* AliESDEvent::fESDListName[kESDListN] = {"AliESDRun", | |
44 | "AliESDHeader", | |
45 | "AliESDZDC", | |
46 | "AliESDFMD", | |
47 | "AliESDVZERO", | |
48 | "AliESDTZERO", | |
49 | "SPDVertex", | |
50 | "PrimaryVertex", | |
51 | "AliMultiplicity", | |
52 | "PHOSTrigger", | |
53 | "EMCALTrigger", | |
54 | "Tracks", | |
55 | "MuonTracks", | |
56 | "PmdTracks", | |
57 | "TrdTracks", | |
58 | "V0s", | |
72da5d8c | 59 | "Cascades", |
60e8f114 | 60 | "Kinks", |
61 | "CaloClusters", | |
62 | "AliRawDataErrorLogs"}; | |
af885e0f | 63 | //______________________________________________________________________________ |
64 | AliESDEvent::AliESDEvent(): | |
65 | fESDObjects(new TList()), | |
66 | fESDRun(0), | |
67 | fHeader(0), | |
68 | fESDZDC(0), | |
69 | fESDFMD(0), | |
70 | fESDVZERO(0), | |
71 | fESDTZERO(0), | |
72 | fSPDVertex(0), | |
73 | fPrimaryVertex(0), | |
74 | fSPDMult(0), | |
75 | fPHOSTrigger(0), | |
76 | fEMCALTrigger(0), | |
77 | fTracks(0), | |
78 | fMuonTracks(0), | |
79 | fPmdTracks(0), | |
80 | fTrdTracks(0), | |
81 | fV0s(0), | |
82 | fCascades(0), | |
83 | fKinks(0), | |
84 | fCaloClusters(0), | |
85 | fErrorLogs(0), | |
86 | fESDOld(0), | |
60e8f114 | 87 | fConnected(kFALSE), |
af885e0f | 88 | fEMCALClusters(0), |
89 | fFirstEMCALCluster(-1), | |
90 | fPHOSClusters(0), | |
91 | fFirstPHOSCluster(-1) | |
92 | { | |
93 | } | |
94 | //______________________________________________________________________________ | |
95 | AliESDEvent::AliESDEvent(const AliESDEvent& esd): | |
96 | TObject(esd), | |
97 | fESDObjects(new TList()), | |
98 | fESDRun(new AliESDRun(*esd.fESDRun)), | |
99 | fHeader(new AliESDHeader(*esd.fHeader)), | |
100 | fESDZDC(new AliESDZDC(*esd.fESDZDC)), | |
101 | fESDFMD(new AliESDFMD(*esd.fESDFMD)), | |
102 | fESDVZERO(new AliESDVZERO(*esd.fESDVZERO)), | |
103 | fESDTZERO(new AliESDTZERO(*esd.fESDTZERO)), | |
104 | fSPDVertex(new AliESDVertex(*esd.fSPDVertex)), | |
105 | fPrimaryVertex(new AliESDVertex(*esd.fPrimaryVertex)), | |
106 | fSPDMult(new AliMultiplicity(*esd.fSPDMult)), | |
107 | fPHOSTrigger(new AliESDCaloTrigger(*esd.fPHOSTrigger)), | |
108 | fEMCALTrigger(new AliESDCaloTrigger(*esd.fEMCALTrigger)), | |
109 | fTracks(new TClonesArray(*esd.fTracks)), | |
110 | fMuonTracks(new TClonesArray(*esd.fMuonTracks)), | |
111 | fPmdTracks(new TClonesArray(*esd.fPmdTracks)), | |
112 | fTrdTracks(new TClonesArray(*esd.fTrdTracks)), | |
113 | fV0s(new TClonesArray(*esd.fV0s)), | |
114 | fCascades(new TClonesArray(*esd.fCascades)), | |
115 | fKinks(new TClonesArray(*esd.fKinks)), | |
116 | fCaloClusters(new TClonesArray(*esd.fCaloClusters)), | |
117 | fErrorLogs(new TClonesArray(*esd.fErrorLogs)), | |
118 | fESDOld(new AliESD(*esd.fESDOld)), | |
60e8f114 | 119 | fConnected(esd.fConnected), |
af885e0f | 120 | fEMCALClusters(esd.fEMCALClusters), |
121 | fFirstEMCALCluster(esd.fFirstEMCALCluster), | |
122 | fPHOSClusters(esd.fPHOSClusters), | |
123 | fFirstPHOSCluster(esd.fFirstPHOSCluster) | |
124 | ||
125 | { | |
126 | // CKB init in the constructor list and only add here ... | |
127 | AddObject(fESDRun); | |
128 | AddObject(fHeader); | |
129 | AddObject(fESDZDC); | |
130 | AddObject(fESDFMD); | |
131 | AddObject(fESDVZERO); | |
132 | AddObject(fESDTZERO); | |
133 | AddObject(fSPDVertex); | |
134 | AddObject(fPrimaryVertex); | |
135 | AddObject(fSPDMult); | |
136 | AddObject(fPHOSTrigger); | |
137 | AddObject(fEMCALTrigger); | |
138 | AddObject(fTracks); | |
139 | AddObject(fMuonTracks); | |
140 | AddObject(fPmdTracks); | |
141 | AddObject(fTrdTracks); | |
142 | AddObject(fV0s); | |
143 | AddObject(fCascades); | |
144 | AddObject(fKinks); | |
145 | AddObject(fCaloClusters); | |
146 | AddObject(fErrorLogs); | |
147 | ||
148 | GetStdContent(); | |
149 | ||
150 | } | |
151 | ||
152 | //______________________________________________________________________________ | |
153 | AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) { | |
154 | ||
155 | // Assignment operator | |
156 | ||
157 | if(&source == this) return *this; | |
158 | TObject::operator=(source); | |
159 | ||
160 | fESDRun = new AliESDRun(*source.fESDRun); | |
161 | fHeader = new AliESDHeader(*source.fHeader); | |
162 | fESDZDC = new AliESDZDC(*source.fESDZDC); | |
163 | fESDFMD = new AliESDFMD(*source.fESDFMD); | |
164 | fESDVZERO = new AliESDVZERO(*source.fESDVZERO); | |
165 | fESDTZERO = new AliESDTZERO(*source.fESDTZERO); | |
166 | fSPDVertex = new AliESDVertex(*source.fSPDVertex); | |
167 | fPrimaryVertex = new AliESDVertex(*source.fPrimaryVertex); | |
168 | fSPDMult = new AliMultiplicity(*source.fSPDMult); | |
169 | fPHOSTrigger = new AliESDCaloTrigger(*source.fPHOSTrigger); | |
170 | fEMCALTrigger = new AliESDCaloTrigger(*source.fEMCALTrigger); | |
171 | fTracks = new TClonesArray(*source.fTracks); | |
172 | fMuonTracks = new TClonesArray(*source.fMuonTracks); | |
173 | fPmdTracks = new TClonesArray(*source.fPmdTracks); | |
174 | fTrdTracks = new TClonesArray(*source.fTrdTracks); | |
175 | fV0s = new TClonesArray(*source.fV0s); | |
176 | fCascades = new TClonesArray(*source.fCascades); | |
177 | fKinks = new TClonesArray(*source.fKinks); | |
178 | fCaloClusters = new TClonesArray(*source.fCaloClusters); | |
179 | fErrorLogs = new TClonesArray(*source.fErrorLogs); | |
180 | fESDOld = new AliESD(*source.fESDOld); | |
181 | // CKB this way?? or | |
182 | // or AddObject( fESDZDC = new AliESDZDC(*source.fESDZDC)); | |
183 | ||
184 | fESDObjects = new TList(); | |
185 | AddObject(fESDRun); | |
186 | AddObject(fHeader); | |
187 | AddObject(fESDZDC); | |
188 | AddObject(fESDFMD); | |
189 | AddObject(fESDVZERO); | |
190 | AddObject(fESDTZERO); | |
191 | AddObject(fSPDVertex); | |
192 | AddObject(fPrimaryVertex); | |
193 | AddObject(fSPDMult); | |
194 | AddObject(fPHOSTrigger); | |
195 | AddObject(fEMCALTrigger); | |
196 | AddObject(fTracks); | |
197 | AddObject(fMuonTracks); | |
198 | AddObject(fPmdTracks); | |
199 | AddObject(fTrdTracks); | |
200 | AddObject(fV0s); | |
201 | AddObject(fCascades); | |
202 | AddObject(fKinks); | |
203 | AddObject(fCaloClusters); | |
204 | AddObject(fErrorLogs); | |
205 | ||
60e8f114 | 206 | fConnected = source.fConnected; |
af885e0f | 207 | fEMCALClusters = source.fEMCALClusters; |
208 | fFirstEMCALCluster = source.fFirstEMCALCluster; | |
209 | fPHOSClusters = source.fPHOSClusters; | |
210 | fFirstPHOSCluster = source.fFirstPHOSCluster; | |
211 | ||
212 | ||
213 | ||
214 | return *this; | |
215 | ||
216 | } | |
217 | ||
218 | ||
219 | //______________________________________________________________________________ | |
220 | AliESDEvent::~AliESDEvent() | |
221 | { | |
222 | // | |
223 | // Standard destructor | |
224 | // | |
225 | ||
001b9beb | 226 | // everthing on the list gets deleted automatically |
139f2194 | 227 | |
228 | ||
60e8f114 | 229 | if(fESDObjects&&!fConnected) |
230 | { | |
231 | delete fESDObjects; | |
232 | fESDObjects = 0; | |
233 | } | |
139f2194 | 234 | |
60e8f114 | 235 | |
af885e0f | 236 | } |
237 | ||
238 | //______________________________________________________________________________ | |
239 | void AliESDEvent::Reset() | |
240 | { | |
241 | ||
242 | ||
243 | // Reset the standard contents | |
244 | ResetStdContent(); | |
245 | ||
246 | if(fESDOld)fESDOld->Reset(); | |
001b9beb | 247 | // call reset for user supplied data? |
af885e0f | 248 | } |
249 | ||
250 | void AliESDEvent::ResetStdContent() | |
251 | { | |
252 | // Reset the standard contents | |
253 | if(fESDRun) fESDRun->Reset(); | |
254 | if(fHeader) fHeader->Reset(); | |
255 | if(fESDZDC) fESDZDC->Reset(); | |
256 | if(fESDFMD) fESDFMD->Clear(); // why clear.... need consistend names | |
257 | // if(fESDVZERO) fESDVZERO->; // NOT IMPLEMENTED | |
258 | // if(fESDVZERO) new (fESDVZERO) AliESDVZERO(); | |
259 | if(fESDTZERO) fESDTZERO->Reset(); | |
260 | // CKB no clear/reset implemented | |
261 | if(fSPDVertex){ | |
262 | new (fSPDVertex) AliESDVertex(); | |
60e8f114 | 263 | fSPDVertex->SetName(fESDListName[kSPDVertex]); |
af885e0f | 264 | } |
265 | if(fPrimaryVertex){ | |
266 | new (fPrimaryVertex) AliESDVertex(); | |
60e8f114 | 267 | fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]); |
af885e0f | 268 | } |
269 | if(fSPDMult)new (fSPDMult) AliMultiplicity(); | |
270 | if(fPHOSTrigger)fPHOSTrigger->Reset(); | |
271 | if(fEMCALTrigger)fEMCALTrigger->Reset(); | |
272 | if(fTracks)fTracks->Clear(); | |
273 | if(fMuonTracks)fMuonTracks->Clear(); | |
274 | if(fPmdTracks)fPmdTracks->Clear(); | |
275 | if(fTrdTracks)fTrdTracks->Clear(); | |
276 | if(fV0s)fV0s->Clear(); | |
277 | if(fCascades)fCascades->Clear(); | |
278 | if(fKinks)fKinks->Clear(); | |
279 | if(fCaloClusters)fCaloClusters->Clear(); | |
280 | if(fErrorLogs) fErrorLogs->Clear(); | |
281 | ||
60e8f114 | 282 | // don't reset fconnected fConnected ; |
283 | ||
af885e0f | 284 | fEMCALClusters=0; |
285 | fFirstEMCALCluster=-1; | |
286 | fPHOSClusters=0; | |
287 | fFirstPHOSCluster=-1; | |
288 | } | |
289 | ||
290 | ||
291 | Int_t AliESDEvent::AddV0(const AliESDv0 *v) { | |
292 | // | |
293 | // Add V0 | |
294 | // | |
295 | TClonesArray &fv = *fV0s; | |
296 | Int_t idx=fV0s->GetEntriesFast(); | |
297 | new(fv[idx]) AliESDv0(*v); | |
298 | return idx; | |
299 | } | |
300 | ||
301 | //______________________________________________________________________________ | |
302 | void AliESDEvent::Print(Option_t *) const | |
303 | { | |
304 | // | |
305 | // Print header information of the event | |
306 | // | |
307 | printf("ESD run information\n"); | |
308 | printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n", | |
309 | GetEventNumberInFile(), | |
310 | GetBunchCrossNumber(), | |
311 | GetOrbitNumber(), | |
312 | GetPeriodNumber(), | |
313 | GetRunNumber(), | |
314 | GetTriggerMask(), | |
315 | GetMagneticField() ); | |
316 | printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n", | |
317 | fPrimaryVertex->GetXv(), fPrimaryVertex->GetXRes(), | |
318 | fPrimaryVertex->GetYv(), fPrimaryVertex->GetYRes(), | |
319 | fPrimaryVertex->GetZv(), fPrimaryVertex->GetZRes()); | |
320 | printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n", | |
321 | GetDiamondX(),GetDiamondY()); | |
322 | printf("SPD Multiplicity. Number of tracklets %d \n", | |
323 | fSPDMult->GetNumberOfTracklets()); | |
324 | printf("Number of tracks: \n"); | |
325 | printf(" charged %d\n", GetNumberOfTracks()); | |
326 | printf(" muon %d\n", GetNumberOfMuonTracks()); | |
327 | printf(" pmd %d\n", GetNumberOfPmdTracks()); | |
328 | printf(" trd %d\n", GetNumberOfTrdTracks()); | |
329 | printf(" v0 %d\n", GetNumberOfV0s()); | |
330 | printf(" cascades %d\n", GetNumberOfCascades()); | |
331 | printf(" kinks %d\n", GetNumberOfKinks()); | |
332 | printf(" CaloClusters %d\n", GetNumberOfCaloClusters()); | |
333 | printf(" phos %d\n", GetNumberOfPHOSClusters()); | |
334 | printf(" emcal %d\n", GetNumberOfEMCALClusters()); | |
335 | printf(" FMD %s\n", (fESDFMD ? "yes" : "no")); | |
336 | printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no")); | |
337 | } | |
338 | ||
339 | void AliESDEvent::SetESDfriend(const AliESDfriend *ev) { | |
340 | // | |
341 | // Attaches the complementary info to the ESD | |
342 | // | |
343 | if (!ev) return; | |
344 | ||
5300bdab | 345 | // to be sure that we set the tracks also |
346 | // in case of old esds | |
60e8f114 | 347 | // if(fESDOld)CopyFromOldESD(); |
5300bdab | 348 | |
af885e0f | 349 | Int_t ntrk=ev->GetNumberOfTracks(); |
350 | ||
351 | for (Int_t i=0; i<ntrk; i++) { | |
352 | const AliESDfriendTrack *f=ev->GetTrack(i); | |
353 | GetTrack(i)->SetFriendTrack(f); | |
354 | } | |
355 | } | |
356 | ||
357 | Int_t AliESDEvent::AddTrack(const AliESDtrack *t) { | |
358 | // Add track | |
359 | TClonesArray &ftr = *fTracks; | |
360 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t); | |
361 | track->SetID(fTracks->GetEntriesFast()-1); | |
362 | return track->GetID(); | |
363 | } | |
364 | ||
365 | Int_t AliESDEvent::AddKink(const AliESDkink *c) { | |
366 | // Add kink | |
367 | TClonesArray &fk = *fKinks; | |
368 | AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c); | |
369 | kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps.. | |
370 | return fKinks->GetEntriesFast()-1; | |
371 | } | |
372 | ||
373 | Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) { | |
374 | // Add calocluster | |
375 | TClonesArray &fc = *fCaloClusters; | |
376 | AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c); | |
377 | clus->SetID(fCaloClusters->GetEntriesFast()-1); | |
378 | return fCaloClusters->GetEntriesFast()-1; | |
379 | } | |
380 | ||
381 | ||
60e8f114 | 382 | void AliESDEvent::SetVertex(const AliESDVertex *vertex) { |
383 | // use already allocated space | |
384 | if(fSPDVertex){ | |
385 | new(fSPDVertex) AliESDVertex(*vertex); | |
386 | fSPDVertex->SetName(fESDListName[kSPDVertex]); | |
387 | } | |
388 | } | |
389 | ||
390 | void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex) { | |
391 | // use already allocated space | |
392 | if(fPrimaryVertex){ | |
393 | new(fPrimaryVertex) AliESDVertex(*vertex); | |
394 | fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]); | |
395 | } | |
396 | } | |
397 | ||
af885e0f | 398 | void AliESDEvent::SetFMDData(AliESDFMD * obj) { |
399 | // use already allocated space | |
400 | if(fESDFMD){ | |
401 | new(fESDFMD) AliESDFMD(*obj); | |
402 | } | |
403 | } | |
404 | ||
405 | void AliESDEvent::SetVZEROData(AliESDVZERO * obj){ | |
406 | // use already allocated space | |
407 | if(fESDVZERO) | |
408 | new(fESDVZERO) AliESDVZERO(*obj); | |
409 | } | |
410 | ||
411 | void AliESDEvent::GetESDfriend(AliESDfriend *ev) const { | |
412 | // | |
413 | // Extracts the complementary info from the ESD | |
414 | // | |
415 | if (!ev) return; | |
416 | ||
417 | Int_t ntrk=GetNumberOfTracks(); | |
418 | ||
419 | for (Int_t i=0; i<ntrk; i++) { | |
420 | const AliESDtrack *t=GetTrack(i); | |
421 | const AliESDfriendTrack *f=t->GetFriendTrack(); | |
422 | ev->AddTrack(f); | |
423 | } | |
424 | } | |
425 | ||
426 | ||
427 | void AliESDEvent::AddObject(TObject* obj) | |
428 | { | |
429 | // Add an object to the list of object. | |
430 | // Please be aware that in order to increase performance you should | |
431 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
432 | fESDObjects->SetOwner(kTRUE); | |
433 | fESDObjects->AddLast(obj); | |
434 | } | |
435 | ||
436 | ||
437 | void AliESDEvent::GetStdContent() | |
438 | { | |
439 | // set pointers for standard content | |
60e8f114 | 440 | // get by name much safer and not a big overhead since not called very often |
441 | ||
442 | fESDRun = (AliESDRun*)fESDObjects->FindObject(fESDListName[kESDRun]); | |
443 | fHeader = (AliESDHeader*)fESDObjects->FindObject(fESDListName[kHeader]); | |
444 | fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fESDListName[kESDZDC]); | |
445 | fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fESDListName[kESDFMD]); | |
446 | fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fESDListName[kESDVZERO]); | |
447 | fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fESDListName[kESDTZERO]); | |
448 | fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fESDListName[kSPDVertex]); | |
449 | fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fESDListName[kPrimaryVertex]); | |
450 | fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fESDListName[kSPDMult]); | |
451 | fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fESDListName[kPHOSTrigger]); | |
452 | fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fESDListName[kEMCALTrigger]); | |
453 | fTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kTracks]); | |
454 | fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kMuonTracks]); | |
455 | fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kPmdTracks]); | |
456 | fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kTrdTracks]); | |
457 | fV0s = (TClonesArray*)fESDObjects->FindObject(fESDListName[kV0s]); | |
458 | fCascades = (TClonesArray*)fESDObjects->FindObject(fESDListName[kCascades]); | |
459 | fKinks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kKinks]); | |
460 | fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fESDListName[kCaloClusters]); | |
461 | fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fESDListName[kErrorLogs]); | |
af885e0f | 462 | |
463 | } | |
464 | ||
465 | void AliESDEvent::SetStdNames(){ | |
466 | // Set the names of the standard contents | |
60e8f114 | 467 | // |
468 | if(fESDObjects->GetEntries()==kESDListN){ | |
469 | for(int i = 0;i < fESDObjects->GetEntries();i++){ | |
470 | TObject *fObj = fESDObjects->At(i); | |
471 | if(fObj->InheritsFrom("TNamed")){ | |
472 | ((TNamed*)fObj)->SetName(fESDListName[i]); | |
473 | } | |
474 | else if(fObj->InheritsFrom("TClonesArray")){ | |
475 | ((TClonesArray*)fObj)->SetName(fESDListName[i]); | |
476 | } | |
477 | } | |
478 | } | |
479 | else{ | |
480 | printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__); | |
481 | } | |
af885e0f | 482 | } |
483 | ||
484 | void AliESDEvent::CreateStdContent() | |
485 | { | |
486 | // create the standard AOD content and set pointers | |
487 | ||
488 | // create standard objects and add them to the TList of objects | |
489 | AddObject(new AliESDRun()); | |
490 | AddObject(new AliESDHeader()); | |
491 | AddObject(new AliESDZDC()); | |
492 | AddObject(new AliESDFMD()); | |
493 | AddObject(new AliESDVZERO()); | |
494 | AddObject(new AliESDTZERO()); | |
495 | AddObject(new AliESDVertex()); | |
496 | AddObject(new AliESDVertex()); | |
497 | AddObject(new AliMultiplicity()); | |
498 | AddObject(new AliESDCaloTrigger()); | |
499 | AddObject(new AliESDCaloTrigger()); | |
500 | AddObject(new TClonesArray("AliESDtrack",0)); | |
501 | AddObject(new TClonesArray("AliESDMuonTrack",0)); | |
502 | AddObject(new TClonesArray("AliESDPmdTrack",0)); | |
503 | AddObject(new TClonesArray("AliESDTrdTrack",0)); | |
504 | AddObject(new TClonesArray("AliESDv0",0)); | |
505 | AddObject(new TClonesArray("AliESDcascade",0)); | |
506 | AddObject(new TClonesArray("AliESDkink",0)); | |
507 | AddObject(new TClonesArray("AliESDCaloCluster",0)); | |
508 | AddObject(new TClonesArray("AliRawDataErrorLog",0)); | |
509 | ||
510 | // check the order of the indices against enum... | |
511 | ||
af885e0f | 512 | // set names |
513 | SetStdNames(); | |
60e8f114 | 514 | // read back pointers |
515 | GetStdContent(); | |
516 | ||
517 | ||
af885e0f | 518 | |
519 | } | |
520 | ||
001b9beb | 521 | TObject* AliESDEvent::FindListObject(const char *name){ |
522 | if(fESDObjects)return fESDObjects->FindObject(name); | |
523 | return 0; | |
524 | } | |
525 | ||
af885e0f | 526 | void AliESDEvent::ReadFromTree(TTree *tree){ |
527 | ||
528 | ||
001b9beb | 529 | // if we find the "ESD" branch on the tree we do have the old structure |
af885e0f | 530 | if(tree->GetBranch("ESD")){ |
b93c2026 | 531 | char ** address = (char **)(tree->GetBranch("ESD")->GetAddress()); |
532 | if (!address) { | |
533 | printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__); | |
534 | tree->SetBranchAddress("ESD",&fESDOld); | |
535 | } else { | |
536 | printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__); | |
537 | printf("%s %d Branch already connected. Using existing branch address. \n",(char*)__FILE__,__LINE__); | |
538 | fESDOld = (AliESD*) (*address); | |
539 | } | |
540 | ||
541 | ||
542 | CreateStdContent(); // create for copy | |
543 | // when reading back we are not owner of the list | |
544 | // must not delete it | |
545 | fESDObjects->SetOwner(kFALSE); | |
546 | return; | |
af885e0f | 547 | } |
548 | ||
549 | fESDOld = 0; | |
550 | ||
551 | ||
552 | // Try to find AliESDEvent | |
553 | AliESDEvent *esdEvent = 0; | |
554 | esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent"); | |
bff64acf | 555 | //esdEvent = (AliESDEvent*)tree->GetUserInfo()->FindObject("AliESDEvent"); |
af885e0f | 556 | |
001b9beb | 557 | if(esdEvent){ |
941603c0 | 558 | // Check if already connected to tree |
139f2194 | 559 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
560 | if (connectedList) { | |
561 | // If connected use the connected list if objects | |
562 | fESDObjects->Delete(); | |
b5bc83df | 563 | fESDObjects = connectedList; |
564 | GetStdContent(); | |
60e8f114 | 565 | fConnected = true; |
139f2194 | 566 | return; |
567 | } | |
568 | // Connect to tree | |
001b9beb | 569 | if(fESDObjects->GetEntries()!=0){ |
570 | // this should not happen here put a warning? | |
571 | } | |
572 | // prevent a memory leak when reading back the TList | |
573 | delete fESDObjects; | |
574 | fESDObjects = 0; | |
af885e0f | 575 | // create a new TList from the UserInfo TList... |
576 | // copy constructor does not work... | |
577 | fESDObjects = (TList*)(esdEvent->GetList()->Clone()); | |
139f2194 | 578 | fESDObjects->SetOwner(kFALSE); |
af885e0f | 579 | if(fESDObjects->GetEntries()<kESDListN){ |
941603c0 | 580 | printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n", |
581 | (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN); | |
af885e0f | 582 | } |
583 | // set the branch addresses | |
584 | TIter next(fESDObjects); | |
585 | TNamed *el; | |
586 | while((el=(TNamed*)next())){ | |
587 | TString bname(el->GetName()); | |
588 | ||
589 | if(bname.CompareTo("AliESDfriend")==0) | |
590 | { | |
591 | // AliESDfriend does not have a name ... | |
60e8f114 | 592 | printf("Setting AlieSDFrien \n"); |
af885e0f | 593 | tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el)); |
594 | } | |
595 | else{ | |
596 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
597 | } | |
598 | } | |
599 | GetStdContent(); | |
600 | // when reading back we are not owner of the list | |
601 | // must not delete it | |
602 | fESDObjects->SetOwner(kFALSE); | |
60e8f114 | 603 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
139f2194 | 604 | // we are not owner of the list objects |
605 | // must not delete it | |
60e8f114 | 606 | tree->GetUserInfo()->Add(fESDObjects); |
607 | fConnected = true; | |
af885e0f | 608 | }// no esdEvent |
609 | else { | |
001b9beb | 610 | // we can't get the list from the user data, create standard content |
611 | // and set it by hand (no ESDfriend at the moment | |
af885e0f | 612 | CreateStdContent(); |
613 | TIter next(fESDObjects); | |
614 | TNamed *el; | |
615 | while((el=(TNamed*)next())){ | |
616 | TString bname(el->GetName()); | |
617 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
618 | } | |
619 | GetStdContent(); | |
620 | // when reading back we are not owner of the list | |
621 | // must not delete it | |
622 | fESDObjects->SetOwner(kFALSE); | |
623 | } | |
624 | ||
625 | ||
626 | ||
627 | } | |
628 | ||
629 | ||
630 | void AliESDEvent::CopyFromOldESD() | |
631 | { | |
632 | // Method which copies over everthing from the old esd structure to the | |
633 | // new | |
634 | ||
635 | if(fESDOld){ | |
636 | ResetStdContent(); | |
637 | // Run | |
638 | SetRunNumber(fESDOld->GetRunNumber()); | |
639 | SetPeriodNumber(fESDOld->GetPeriodNumber()); | |
640 | SetMagneticField(fESDRun->GetMagneticField()); | |
641 | ||
642 | // leave out diamond ... | |
643 | // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);} | |
644 | ||
645 | // header | |
646 | SetTriggerMask(fESDOld->GetTriggerMask()); | |
647 | SetOrbitNumber(fESDOld->GetOrbitNumber()); | |
648 | SetTimeStamp(fESDOld->GetTimeStamp()); | |
649 | SetEventType(fESDOld->GetEventType()); | |
650 | SetEventNumberInFile(fESDOld->GetEventNumberInFile()); | |
651 | SetBunchCrossNumber(fESDOld->GetBunchCrossNumber()); | |
652 | SetTriggerCluster(fESDOld->GetTriggerCluster()); | |
653 | ||
654 | // ZDC | |
655 | ||
656 | SetZDC(fESDOld->GetZDCN1Energy(), | |
657 | fESDOld->GetZDCP1Energy(), | |
658 | fESDOld->GetZDCEMEnergy(), | |
659 | fESDOld->GetZDCN2Energy(), | |
660 | fESDOld->GetZDCP2Energy(), | |
661 | fESDOld->GetZDCParticipants()); | |
662 | ||
663 | // FMD | |
664 | ||
665 | SetFMDData(fESDOld->GetFMDData()); | |
666 | ||
667 | // T0 | |
668 | ||
669 | SetT0zVertex(fESDOld->GetT0zVertex()); | |
670 | SetT0(fESDOld->GetT0()); | |
671 | // leave amps out | |
672 | ||
673 | // VZERO | |
674 | SetVZEROData(fESDOld->GetVZEROData()); | |
675 | ||
676 | SetVertex(fESDOld->GetVertex()); | |
677 | ||
678 | SetPrimaryVertex(fESDOld->GetPrimaryVertex()); | |
679 | ||
680 | SetMultiplicity(fESDOld->GetMultiplicity()); | |
681 | ||
682 | for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){ | |
683 | AddTrack(fESDOld->GetTrack(i)); | |
684 | } | |
685 | ||
686 | for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){ | |
687 | AddMuonTrack(fESDOld->GetMuonTrack(i)); | |
688 | } | |
689 | ||
690 | for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){ | |
691 | AddPmdTrack(fESDOld->GetPmdTrack(i)); | |
692 | } | |
693 | ||
694 | for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){ | |
695 | AddTrdTrack(fESDOld->GetTrdTrack(i)); | |
696 | } | |
697 | ||
698 | for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){ | |
699 | AddV0(fESDOld->GetV0(i)); | |
700 | } | |
701 | ||
702 | for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){ | |
703 | AddCascade(fESDOld->GetCascade(i)); | |
704 | } | |
705 | ||
706 | for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){ | |
707 | AddKink(fESDOld->GetKink(i)); | |
708 | } | |
709 | ||
710 | ||
711 | for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){ | |
712 | AddCaloCluster(fESDOld->GetCaloCluster(i)); | |
713 | } | |
714 | }// if fesdold | |
715 | } | |
716 | ||
717 | ||
718 |