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