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