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