]>
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" | |
f0106218 | 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 | ||
d64bd07d | 375 | Bool_t AliESDEvent::RemoveTrack(Int_t /*i*/) { |
376 | // --------------------------------------------------------- | |
377 | // Remove track | |
378 | // --------------------------------------------------------- | |
379 | ||
380 | // Check if this track comes from a reconstructed decay | |
381 | // if (yes) return kFALSE | |
382 | ||
383 | // Remap the indices of the daughters of recosntructed decays | |
384 | ||
385 | // Remove the track | |
386 | // delete fTracks->RemoveAt(i); | |
387 | ||
388 | // Compress the array with tracks | |
389 | // fTracks->Compress(); | |
390 | ||
391 | return kTRUE; | |
392 | } | |
393 | ||
394 | ||
af885e0f | 395 | Int_t AliESDEvent::AddTrack(const AliESDtrack *t) { |
396 | // Add track | |
397 | TClonesArray &ftr = *fTracks; | |
398 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t); | |
399 | track->SetID(fTracks->GetEntriesFast()-1); | |
400 | return track->GetID(); | |
401 | } | |
402 | ||
f0106218 | 403 | void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t) { |
404 | TClonesArray &fmu = *fMuonTracks; | |
405 | new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t); | |
406 | } | |
407 | ||
408 | void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t) { | |
409 | TClonesArray &fpmd = *fPmdTracks; | |
410 | new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t); | |
411 | } | |
412 | ||
413 | void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t) { | |
414 | TClonesArray &ftrd = *fTrdTracks; | |
415 | new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t); | |
416 | } | |
417 | ||
418 | ||
419 | ||
420 | ||
af885e0f | 421 | Int_t AliESDEvent::AddKink(const AliESDkink *c) { |
422 | // Add kink | |
423 | TClonesArray &fk = *fKinks; | |
424 | AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c); | |
425 | kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps.. | |
426 | return fKinks->GetEntriesFast()-1; | |
427 | } | |
428 | ||
f0106218 | 429 | |
430 | void AliESDEvent::AddCascade(const AliESDcascade *c) { | |
431 | TClonesArray &fc = *fCascades; | |
432 | new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c); | |
433 | } | |
434 | ||
435 | ||
af885e0f | 436 | Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) { |
437 | // Add calocluster | |
438 | TClonesArray &fc = *fCaloClusters; | |
439 | AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c); | |
440 | clus->SetID(fCaloClusters->GetEntriesFast()-1); | |
441 | return fCaloClusters->GetEntriesFast()-1; | |
442 | } | |
443 | ||
444 | ||
f0106218 | 445 | void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) { |
446 | TClonesArray &errlogs = *fErrorLogs; | |
447 | new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log); | |
448 | } | |
449 | ||
60e8f114 | 450 | void AliESDEvent::SetVertex(const AliESDVertex *vertex) { |
451 | // use already allocated space | |
452 | if(fSPDVertex){ | |
453 | new(fSPDVertex) AliESDVertex(*vertex); | |
454 | fSPDVertex->SetName(fESDListName[kSPDVertex]); | |
455 | } | |
456 | } | |
457 | ||
458 | void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex) { | |
459 | // use already allocated space | |
460 | if(fPrimaryVertex){ | |
461 | new(fPrimaryVertex) AliESDVertex(*vertex); | |
462 | fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]); | |
463 | } | |
464 | } | |
465 | ||
f0106218 | 466 | void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) { |
467 | if(fSPDMult){ | |
468 | new (fSPDMult) AliMultiplicity(*mul); | |
469 | } | |
470 | } | |
471 | ||
472 | ||
af885e0f | 473 | void AliESDEvent::SetFMDData(AliESDFMD * obj) { |
474 | // use already allocated space | |
475 | if(fESDFMD){ | |
476 | new(fESDFMD) AliESDFMD(*obj); | |
477 | } | |
478 | } | |
479 | ||
480 | void AliESDEvent::SetVZEROData(AliESDVZERO * obj){ | |
481 | // use already allocated space | |
482 | if(fESDVZERO) | |
483 | new(fESDVZERO) AliESDVZERO(*obj); | |
484 | } | |
485 | ||
486 | void AliESDEvent::GetESDfriend(AliESDfriend *ev) const { | |
487 | // | |
488 | // Extracts the complementary info from the ESD | |
489 | // | |
490 | if (!ev) return; | |
491 | ||
492 | Int_t ntrk=GetNumberOfTracks(); | |
493 | ||
494 | for (Int_t i=0; i<ntrk; i++) { | |
495 | const AliESDtrack *t=GetTrack(i); | |
496 | const AliESDfriendTrack *f=t->GetFriendTrack(); | |
497 | ev->AddTrack(f); | |
498 | } | |
499 | } | |
500 | ||
501 | ||
502 | void AliESDEvent::AddObject(TObject* obj) | |
503 | { | |
504 | // Add an object to the list of object. | |
505 | // Please be aware that in order to increase performance you should | |
506 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
507 | fESDObjects->SetOwner(kTRUE); | |
508 | fESDObjects->AddLast(obj); | |
509 | } | |
510 | ||
511 | ||
512 | void AliESDEvent::GetStdContent() | |
513 | { | |
514 | // set pointers for standard content | |
60e8f114 | 515 | // get by name much safer and not a big overhead since not called very often |
516 | ||
517 | fESDRun = (AliESDRun*)fESDObjects->FindObject(fESDListName[kESDRun]); | |
518 | fHeader = (AliESDHeader*)fESDObjects->FindObject(fESDListName[kHeader]); | |
519 | fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fESDListName[kESDZDC]); | |
520 | fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fESDListName[kESDFMD]); | |
521 | fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fESDListName[kESDVZERO]); | |
522 | fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fESDListName[kESDTZERO]); | |
523 | fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fESDListName[kSPDVertex]); | |
524 | fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fESDListName[kPrimaryVertex]); | |
525 | fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fESDListName[kSPDMult]); | |
526 | fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fESDListName[kPHOSTrigger]); | |
527 | fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fESDListName[kEMCALTrigger]); | |
528 | fTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kTracks]); | |
529 | fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kMuonTracks]); | |
530 | fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kPmdTracks]); | |
531 | fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kTrdTracks]); | |
532 | fV0s = (TClonesArray*)fESDObjects->FindObject(fESDListName[kV0s]); | |
533 | fCascades = (TClonesArray*)fESDObjects->FindObject(fESDListName[kCascades]); | |
534 | fKinks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kKinks]); | |
535 | fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fESDListName[kCaloClusters]); | |
536 | fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fESDListName[kErrorLogs]); | |
af885e0f | 537 | |
538 | } | |
539 | ||
540 | void AliESDEvent::SetStdNames(){ | |
541 | // Set the names of the standard contents | |
60e8f114 | 542 | // |
543 | if(fESDObjects->GetEntries()==kESDListN){ | |
544 | for(int i = 0;i < fESDObjects->GetEntries();i++){ | |
545 | TObject *fObj = fESDObjects->At(i); | |
546 | if(fObj->InheritsFrom("TNamed")){ | |
547 | ((TNamed*)fObj)->SetName(fESDListName[i]); | |
548 | } | |
549 | else if(fObj->InheritsFrom("TClonesArray")){ | |
550 | ((TClonesArray*)fObj)->SetName(fESDListName[i]); | |
551 | } | |
552 | } | |
553 | } | |
554 | else{ | |
555 | printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__); | |
556 | } | |
af885e0f | 557 | } |
558 | ||
559 | void AliESDEvent::CreateStdContent() | |
560 | { | |
561 | // create the standard AOD content and set pointers | |
562 | ||
563 | // create standard objects and add them to the TList of objects | |
564 | AddObject(new AliESDRun()); | |
565 | AddObject(new AliESDHeader()); | |
566 | AddObject(new AliESDZDC()); | |
567 | AddObject(new AliESDFMD()); | |
568 | AddObject(new AliESDVZERO()); | |
569 | AddObject(new AliESDTZERO()); | |
570 | AddObject(new AliESDVertex()); | |
571 | AddObject(new AliESDVertex()); | |
572 | AddObject(new AliMultiplicity()); | |
573 | AddObject(new AliESDCaloTrigger()); | |
574 | AddObject(new AliESDCaloTrigger()); | |
575 | AddObject(new TClonesArray("AliESDtrack",0)); | |
576 | AddObject(new TClonesArray("AliESDMuonTrack",0)); | |
577 | AddObject(new TClonesArray("AliESDPmdTrack",0)); | |
578 | AddObject(new TClonesArray("AliESDTrdTrack",0)); | |
579 | AddObject(new TClonesArray("AliESDv0",0)); | |
580 | AddObject(new TClonesArray("AliESDcascade",0)); | |
581 | AddObject(new TClonesArray("AliESDkink",0)); | |
582 | AddObject(new TClonesArray("AliESDCaloCluster",0)); | |
583 | AddObject(new TClonesArray("AliRawDataErrorLog",0)); | |
584 | ||
585 | // check the order of the indices against enum... | |
586 | ||
af885e0f | 587 | // set names |
588 | SetStdNames(); | |
60e8f114 | 589 | // read back pointers |
590 | GetStdContent(); | |
591 | ||
592 | ||
af885e0f | 593 | |
594 | } | |
595 | ||
001b9beb | 596 | TObject* AliESDEvent::FindListObject(const char *name){ |
597 | if(fESDObjects)return fESDObjects->FindObject(name); | |
598 | return 0; | |
599 | } | |
600 | ||
af885e0f | 601 | void AliESDEvent::ReadFromTree(TTree *tree){ |
602 | ||
603 | ||
001b9beb | 604 | // if we find the "ESD" branch on the tree we do have the old structure |
af885e0f | 605 | if(tree->GetBranch("ESD")){ |
b93c2026 | 606 | char ** address = (char **)(tree->GetBranch("ESD")->GetAddress()); |
607 | if (!address) { | |
608 | printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__); | |
609 | tree->SetBranchAddress("ESD",&fESDOld); | |
610 | } else { | |
611 | printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__); | |
612 | printf("%s %d Branch already connected. Using existing branch address. \n",(char*)__FILE__,__LINE__); | |
613 | fESDOld = (AliESD*) (*address); | |
614 | } | |
615 | ||
616 | ||
617 | CreateStdContent(); // create for copy | |
618 | // when reading back we are not owner of the list | |
619 | // must not delete it | |
620 | fESDObjects->SetOwner(kFALSE); | |
621 | return; | |
af885e0f | 622 | } |
623 | ||
624 | fESDOld = 0; | |
625 | ||
626 | ||
627 | // Try to find AliESDEvent | |
628 | AliESDEvent *esdEvent = 0; | |
629 | esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent"); | |
bff64acf | 630 | //esdEvent = (AliESDEvent*)tree->GetUserInfo()->FindObject("AliESDEvent"); |
af885e0f | 631 | |
001b9beb | 632 | if(esdEvent){ |
941603c0 | 633 | // Check if already connected to tree |
139f2194 | 634 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
635 | if (connectedList) { | |
636 | // If connected use the connected list if objects | |
637 | fESDObjects->Delete(); | |
b5bc83df | 638 | fESDObjects = connectedList; |
639 | GetStdContent(); | |
60e8f114 | 640 | fConnected = true; |
139f2194 | 641 | return; |
642 | } | |
643 | // Connect to tree | |
001b9beb | 644 | if(fESDObjects->GetEntries()!=0){ |
645 | // this should not happen here put a warning? | |
646 | } | |
647 | // prevent a memory leak when reading back the TList | |
648 | delete fESDObjects; | |
649 | fESDObjects = 0; | |
af885e0f | 650 | // create a new TList from the UserInfo TList... |
651 | // copy constructor does not work... | |
652 | fESDObjects = (TList*)(esdEvent->GetList()->Clone()); | |
139f2194 | 653 | fESDObjects->SetOwner(kFALSE); |
af885e0f | 654 | if(fESDObjects->GetEntries()<kESDListN){ |
941603c0 | 655 | printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n", |
656 | (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN); | |
af885e0f | 657 | } |
658 | // set the branch addresses | |
659 | TIter next(fESDObjects); | |
660 | TNamed *el; | |
661 | while((el=(TNamed*)next())){ | |
662 | TString bname(el->GetName()); | |
663 | ||
664 | if(bname.CompareTo("AliESDfriend")==0) | |
665 | { | |
666 | // AliESDfriend does not have a name ... | |
af885e0f | 667 | tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el)); |
668 | } | |
669 | else{ | |
670 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
671 | } | |
672 | } | |
673 | GetStdContent(); | |
674 | // when reading back we are not owner of the list | |
675 | // must not delete it | |
676 | fESDObjects->SetOwner(kFALSE); | |
60e8f114 | 677 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
139f2194 | 678 | // we are not owner of the list objects |
679 | // must not delete it | |
60e8f114 | 680 | tree->GetUserInfo()->Add(fESDObjects); |
681 | fConnected = true; | |
af885e0f | 682 | }// no esdEvent |
683 | else { | |
001b9beb | 684 | // we can't get the list from the user data, create standard content |
685 | // and set it by hand (no ESDfriend at the moment | |
af885e0f | 686 | CreateStdContent(); |
687 | TIter next(fESDObjects); | |
688 | TNamed *el; | |
689 | while((el=(TNamed*)next())){ | |
690 | TString bname(el->GetName()); | |
691 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
692 | } | |
693 | GetStdContent(); | |
694 | // when reading back we are not owner of the list | |
695 | // must not delete it | |
696 | fESDObjects->SetOwner(kFALSE); | |
697 | } | |
698 | ||
699 | ||
700 | ||
701 | } | |
702 | ||
703 | ||
704 | void AliESDEvent::CopyFromOldESD() | |
705 | { | |
706 | // Method which copies over everthing from the old esd structure to the | |
707 | // new | |
708 | ||
709 | if(fESDOld){ | |
710 | ResetStdContent(); | |
711 | // Run | |
712 | SetRunNumber(fESDOld->GetRunNumber()); | |
713 | SetPeriodNumber(fESDOld->GetPeriodNumber()); | |
714 | SetMagneticField(fESDRun->GetMagneticField()); | |
715 | ||
716 | // leave out diamond ... | |
717 | // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);} | |
718 | ||
719 | // header | |
720 | SetTriggerMask(fESDOld->GetTriggerMask()); | |
721 | SetOrbitNumber(fESDOld->GetOrbitNumber()); | |
722 | SetTimeStamp(fESDOld->GetTimeStamp()); | |
723 | SetEventType(fESDOld->GetEventType()); | |
724 | SetEventNumberInFile(fESDOld->GetEventNumberInFile()); | |
725 | SetBunchCrossNumber(fESDOld->GetBunchCrossNumber()); | |
726 | SetTriggerCluster(fESDOld->GetTriggerCluster()); | |
727 | ||
728 | // ZDC | |
729 | ||
730 | SetZDC(fESDOld->GetZDCN1Energy(), | |
731 | fESDOld->GetZDCP1Energy(), | |
732 | fESDOld->GetZDCEMEnergy(), | |
733 | fESDOld->GetZDCN2Energy(), | |
734 | fESDOld->GetZDCP2Energy(), | |
735 | fESDOld->GetZDCParticipants()); | |
736 | ||
737 | // FMD | |
738 | ||
739 | SetFMDData(fESDOld->GetFMDData()); | |
740 | ||
741 | // T0 | |
742 | ||
743 | SetT0zVertex(fESDOld->GetT0zVertex()); | |
744 | SetT0(fESDOld->GetT0()); | |
745 | // leave amps out | |
746 | ||
747 | // VZERO | |
748 | SetVZEROData(fESDOld->GetVZEROData()); | |
749 | ||
750 | SetVertex(fESDOld->GetVertex()); | |
751 | ||
752 | SetPrimaryVertex(fESDOld->GetPrimaryVertex()); | |
753 | ||
754 | SetMultiplicity(fESDOld->GetMultiplicity()); | |
755 | ||
756 | for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){ | |
757 | AddTrack(fESDOld->GetTrack(i)); | |
758 | } | |
759 | ||
760 | for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){ | |
761 | AddMuonTrack(fESDOld->GetMuonTrack(i)); | |
762 | } | |
763 | ||
764 | for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){ | |
765 | AddPmdTrack(fESDOld->GetPmdTrack(i)); | |
766 | } | |
767 | ||
768 | for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){ | |
769 | AddTrdTrack(fESDOld->GetTrdTrack(i)); | |
770 | } | |
771 | ||
772 | for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){ | |
773 | AddV0(fESDOld->GetV0(i)); | |
774 | } | |
775 | ||
776 | for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){ | |
777 | AddCascade(fESDOld->GetCascade(i)); | |
778 | } | |
779 | ||
780 | for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){ | |
781 | AddKink(fESDOld->GetKink(i)); | |
782 | } | |
783 | ||
784 | ||
785 | for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){ | |
786 | AddCaloCluster(fESDOld->GetCaloCluster(i)); | |
787 | } | |
788 | }// if fesdold | |
789 | } | |
790 | ||
791 | ||
792 |