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