]>
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()); | |
38f940fb | 398 | if(fPHOSCells)printf(" PHOSCells %d\n", fPHOSCells->GetNumberOfCells()); |
399 | else printf(" PHOSCells not in the Event\n"); | |
400 | if(fEMCALCells)printf(" EMCALCells %d\n", fEMCALCells->GetNumberOfCells()); | |
401 | else printf(" EMCALCells not in the Event\n"); | |
af885e0f | 402 | printf(" CaloClusters %d\n", GetNumberOfCaloClusters()); |
403 | printf(" phos %d\n", GetNumberOfPHOSClusters()); | |
404 | printf(" emcal %d\n", GetNumberOfEMCALClusters()); | |
405 | printf(" FMD %s\n", (fESDFMD ? "yes" : "no")); | |
406 | printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no")); | |
024c7734 | 407 | |
408 | return; | |
af885e0f | 409 | } |
410 | ||
411 | void AliESDEvent::SetESDfriend(const AliESDfriend *ev) { | |
412 | // | |
413 | // Attaches the complementary info to the ESD | |
414 | // | |
415 | if (!ev) return; | |
416 | ||
5300bdab | 417 | // to be sure that we set the tracks also |
418 | // in case of old esds | |
60e8f114 | 419 | // if(fESDOld)CopyFromOldESD(); |
5300bdab | 420 | |
af885e0f | 421 | Int_t ntrk=ev->GetNumberOfTracks(); |
422 | ||
423 | for (Int_t i=0; i<ntrk; i++) { | |
424 | const AliESDfriendTrack *f=ev->GetTrack(i); | |
425 | GetTrack(i)->SetFriendTrack(f); | |
426 | } | |
427 | } | |
428 | ||
a023d8d8 | 429 | Bool_t AliESDEvent::RemoveKink(Int_t rm) { |
430 | // --------------------------------------------------------- | |
431 | // Remove a kink candidate and references to it from ESD, | |
432 | // if this candidate does not come from a reconstructed decay | |
433 | // Not yet implemented... | |
434 | // --------------------------------------------------------- | |
435 | Int_t last=GetNumberOfKinks()-1; | |
436 | if ((rm<0)||(rm>last)) return kFALSE; | |
437 | ||
438 | return kTRUE; | |
439 | } | |
440 | ||
441 | Bool_t AliESDEvent::RemoveV0(Int_t rm) { | |
442 | // --------------------------------------------------------- | |
443 | // Remove a V0 candidate and references to it from ESD, | |
444 | // if this candidate does not come from a reconstructed decay | |
445 | // --------------------------------------------------------- | |
446 | Int_t last=GetNumberOfV0s()-1; | |
447 | if ((rm<0)||(rm>last)) return kFALSE; | |
448 | ||
449 | AliESDv0 *v0=GetV0(rm); | |
450 | Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex(); | |
451 | ||
452 | v0=GetV0(last); | |
453 | Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex(); | |
454 | ||
455 | Int_t used=0; | |
456 | ||
457 | // Check if this V0 comes from a reconstructed decay | |
458 | Int_t ncs=GetNumberOfCascades(); | |
459 | for (Int_t n=0; n<ncs; n++) { | |
460 | AliESDcascade *cs=GetCascade(n); | |
461 | ||
462 | Int_t csIdxP=cs->GetPindex(); | |
463 | Int_t csIdxN=cs->GetNindex(); | |
464 | ||
465 | if (idxP==csIdxP) | |
466 | if (idxN==csIdxN) return kFALSE; | |
467 | ||
468 | if (csIdxP==lastIdxP) | |
469 | if (csIdxN==lastIdxN) used++; | |
470 | } | |
471 | ||
472 | //Replace the removed V0 with the last V0 | |
473 | TClonesArray &a=*fV0s; | |
474 | delete a.RemoveAt(rm); | |
475 | ||
476 | if (rm==last) return kTRUE; | |
477 | ||
478 | //v0 is pointing to the last V0 candidate... | |
479 | new (a[rm]) AliESDv0(*v0); | |
480 | delete a.RemoveAt(last); | |
481 | ||
482 | if (!used) return kTRUE; | |
483 | ||
484 | ||
485 | // Remap the indices of the daughters of reconstructed decays | |
486 | for (Int_t n=0; n<ncs; n++) { | |
487 | AliESDcascade *cs=GetCascade(n); | |
488 | ||
489 | ||
490 | Int_t csIdxP=cs->GetPindex(); | |
491 | Int_t csIdxN=cs->GetNindex(); | |
492 | ||
493 | if (csIdxP==lastIdxP) | |
494 | if (csIdxN==lastIdxN) { | |
495 | cs->AliESDv0::SetIndex(1,idxP); | |
496 | cs->AliESDv0::SetIndex(0,idxN); | |
497 | used--; | |
498 | if (!used) return kTRUE; | |
499 | } | |
500 | } | |
501 | ||
502 | return kTRUE; | |
503 | } | |
504 | ||
7f68891d | 505 | Bool_t AliESDEvent::RemoveTrack(Int_t rm) { |
d64bd07d | 506 | // --------------------------------------------------------- |
7f68891d | 507 | // Remove a track and references to it from ESD, |
508 | // if this track does not come from a reconstructed decay | |
d64bd07d | 509 | // --------------------------------------------------------- |
7f68891d | 510 | Int_t last=GetNumberOfTracks()-1; |
511 | if ((rm<0)||(rm>last)) return kFALSE; | |
512 | ||
513 | Int_t used=0; | |
d64bd07d | 514 | |
515 | // Check if this track comes from a reconstructed decay | |
7f68891d | 516 | Int_t nv0=GetNumberOfV0s(); |
517 | for (Int_t n=0; n<nv0; n++) { | |
518 | AliESDv0 *v0=GetV0(n); | |
519 | ||
520 | Int_t idx=v0->GetNindex(); | |
521 | if (rm==idx) return kFALSE; | |
522 | if (idx==last) used++; | |
523 | ||
524 | idx=v0->GetPindex(); | |
525 | if (rm==idx) return kFALSE; | |
526 | if (idx==last) used++; | |
527 | } | |
528 | ||
529 | Int_t ncs=GetNumberOfCascades(); | |
530 | for (Int_t n=0; n<ncs; n++) { | |
531 | AliESDcascade *cs=GetCascade(n); | |
d64bd07d | 532 | |
7f68891d | 533 | Int_t idx=cs->GetIndex(); |
534 | if (rm==idx) return kFALSE; | |
535 | if (idx==last) used++; | |
536 | } | |
537 | ||
538 | Int_t nkn=GetNumberOfKinks(); | |
539 | for (Int_t n=0; n<nkn; n++) { | |
540 | AliESDkink *kn=GetKink(n); | |
541 | ||
542 | Int_t idx=kn->GetIndex(0); | |
543 | if (rm==idx) return kFALSE; | |
544 | if (idx==last) used++; | |
545 | ||
546 | idx=kn->GetIndex(1); | |
547 | if (rm==idx) return kFALSE; | |
548 | if (idx==last) used++; | |
549 | } | |
d64bd07d | 550 | |
d64bd07d | 551 | |
7f68891d | 552 | //Replace the removed track with the last track |
553 | TClonesArray &a=*fTracks; | |
554 | delete a.RemoveAt(rm); | |
555 | ||
556 | if (rm==last) return kTRUE; | |
557 | ||
558 | AliESDtrack *t=GetTrack(last); | |
559 | t->SetID(rm); | |
560 | new (a[rm]) AliESDtrack(*t); | |
561 | delete a.RemoveAt(last); | |
562 | ||
563 | if (!used) return kTRUE; | |
564 | ||
565 | ||
566 | // Remap the indices of the daughters of reconstructed decays | |
567 | for (Int_t n=0; n<nv0; n++) { | |
568 | AliESDv0 *v0=GetV0(n); | |
569 | if (v0->GetIndex(0)==last) { | |
570 | v0->SetIndex(0,rm); | |
571 | used--; | |
572 | if (!used) return kTRUE; | |
573 | } | |
574 | if (v0->GetIndex(1)==last) { | |
575 | v0->SetIndex(1,rm); | |
576 | used--; | |
577 | if (!used) return kTRUE; | |
578 | } | |
579 | } | |
580 | ||
581 | for (Int_t n=0; n<ncs; n++) { | |
582 | AliESDcascade *cs=GetCascade(n); | |
583 | if (cs->GetIndex()==last) { | |
584 | cs->SetIndex(rm); | |
585 | used--; | |
586 | if (!used) return kTRUE; | |
587 | } | |
588 | } | |
589 | ||
590 | for (Int_t n=0; n<nkn; n++) { | |
591 | AliESDkink *kn=GetKink(n); | |
592 | if (kn->GetIndex(0)==last) { | |
593 | kn->SetIndex(rm,0); | |
594 | used--; | |
595 | if (!used) return kTRUE; | |
596 | } | |
597 | if (kn->GetIndex(1)==last) { | |
598 | kn->SetIndex(rm,1); | |
599 | used--; | |
600 | if (!used) return kTRUE; | |
601 | } | |
602 | } | |
d64bd07d | 603 | |
604 | return kTRUE; | |
605 | } | |
606 | ||
607 | ||
7f68891d | 608 | Bool_t AliESDEvent::Clean(Float_t *cleanPars) { |
609 | // | |
610 | // Remove the data which are not needed for the physics analysis. | |
611 | // | |
a023d8d8 | 612 | // 1) Cleaning the V0 candidates |
613 | // --------------------------- | |
614 | // If the cosine of the V0 pointing angle "csp" and | |
615 | // the DCA between the daughter tracks "dca" does not satisfy | |
616 | // the conditions | |
617 | // | |
618 | // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1]) | |
619 | // | |
620 | // an attempt to remove this V0 candidate from ESD is made. | |
621 | // | |
622 | // The V0 candidate gets removed if it does not belong to any | |
623 | // recosntructed cascade decay | |
624 | // | |
625 | // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999 | |
626 | // | |
627 | // 2) Cleaning the tracks | |
628 | // ---------------------- | |
629 | // If track's transverse parameter is larger than cleanPars[2] | |
7f68891d | 630 | // OR |
a023d8d8 | 631 | // track's longitudinal parameter is larger than cleanPars[3] |
632 | // an attempt to remove this track from ESD is made. | |
7f68891d | 633 | // |
a023d8d8 | 634 | // The track gets removed if it does not come |
635 | // from a reconstructed decay | |
7f68891d | 636 | // |
a023d8d8 | 637 | Bool_t rc=kFALSE; |
638 | ||
639 | Float_t dcaMax=cleanPars[0]; | |
640 | Float_t cspMin=cleanPars[1]; | |
641 | ||
642 | Int_t nV0s=GetNumberOfV0s(); | |
643 | for (Int_t i=nV0s-1; i>=0; i--) { | |
644 | AliESDv0 *v0=GetV0(i); | |
645 | ||
646 | Float_t dca=v0->GetDcaV0Daughters(); | |
647 | Float_t csp=v0->GetV0CosineOfPointingAngle(); | |
648 | Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin); | |
38f940fb | 649 | if (csp > cspcut){ |
650 | if (RemoveV0(i)) rc=kTRUE; | |
651 | } | |
a023d8d8 | 652 | } |
653 | ||
7f68891d | 654 | |
a023d8d8 | 655 | Float_t dmax=cleanPars[2], zmax=cleanPars[3]; |
7f68891d | 656 | |
657 | const AliESDVertex *vertex=GetVertex(); | |
a023d8d8 | 658 | Bool_t vtxOK=vertex->GetStatus(); |
7f68891d | 659 | |
660 | Int_t nTracks=GetNumberOfTracks(); | |
661 | for (Int_t i=nTracks-1; i>=0; i--) { | |
662 | AliESDtrack *track=GetTrack(i); | |
663 | Float_t xy,z; track->GetImpactParameters(xy,z); | |
664 | if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) { | |
665 | if (RemoveTrack(i)) rc=kTRUE; | |
666 | } | |
667 | } | |
668 | ||
669 | return rc; | |
670 | } | |
671 | ||
6989bff3 | 672 | Int_t AliESDEvent::AddTrack(const AliESDtrack *t) |
673 | { | |
af885e0f | 674 | // Add track |
675 | TClonesArray &ftr = *fTracks; | |
676 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t); | |
677 | track->SetID(fTracks->GetEntriesFast()-1); | |
678 | return track->GetID(); | |
679 | } | |
680 | ||
6989bff3 | 681 | void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t) |
682 | { | |
f0106218 | 683 | TClonesArray &fmu = *fMuonTracks; |
684 | new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t); | |
685 | } | |
686 | ||
6989bff3 | 687 | void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t) |
688 | { | |
f0106218 | 689 | TClonesArray &fpmd = *fPmdTracks; |
690 | new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t); | |
691 | } | |
692 | ||
6989bff3 | 693 | void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t) |
694 | { | |
f0106218 | 695 | TClonesArray &ftrd = *fTrdTracks; |
696 | new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t); | |
697 | } | |
698 | ||
699 | ||
700 | ||
701 | ||
6989bff3 | 702 | Int_t AliESDEvent::AddKink(const AliESDkink *c) |
703 | { | |
af885e0f | 704 | // Add kink |
705 | TClonesArray &fk = *fKinks; | |
706 | AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c); | |
707 | kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps.. | |
708 | return fKinks->GetEntriesFast()-1; | |
709 | } | |
710 | ||
f0106218 | 711 | |
6989bff3 | 712 | void AliESDEvent::AddCascade(const AliESDcascade *c) |
713 | { | |
f0106218 | 714 | TClonesArray &fc = *fCascades; |
715 | new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c); | |
716 | } | |
717 | ||
718 | ||
6989bff3 | 719 | Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) |
720 | { | |
af885e0f | 721 | // Add calocluster |
722 | TClonesArray &fc = *fCaloClusters; | |
723 | AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c); | |
724 | clus->SetID(fCaloClusters->GetEntriesFast()-1); | |
725 | return fCaloClusters->GetEntriesFast()-1; | |
726 | } | |
727 | ||
728 | ||
6989bff3 | 729 | void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) { |
730 | TClonesArray &errlogs = *fErrorLogs; | |
731 | new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log); | |
732 | } | |
f0106218 | 733 | |
6989bff3 | 734 | void AliESDEvent::SetVertex(const AliESDVertex *vertex) |
735 | { | |
736 | // Set the SPD vertex | |
60e8f114 | 737 | // use already allocated space |
738 | if(fSPDVertex){ | |
316c6cd9 | 739 | *fSPDVertex = *vertex; |
6989bff3 | 740 | fSPDVertex->SetName(fgkESDListName[kSPDVertex]); |
60e8f114 | 741 | } |
742 | } | |
743 | ||
6989bff3 | 744 | void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex) |
745 | { | |
746 | // Set the primary vertex | |
747 | // use already allocated space | |
60e8f114 | 748 | if(fPrimaryVertex){ |
316c6cd9 | 749 | *fPrimaryVertex = *vertex; |
6989bff3 | 750 | fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]); |
60e8f114 | 751 | } |
752 | } | |
753 | ||
6989bff3 | 754 | void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) |
755 | { | |
756 | // Set the SPD Multiplicity | |
f0106218 | 757 | if(fSPDMult){ |
316c6cd9 | 758 | *fSPDMult = *mul; |
f0106218 | 759 | } |
760 | } | |
761 | ||
762 | ||
6989bff3 | 763 | void AliESDEvent::SetFMDData(AliESDFMD * obj) |
764 | { | |
af885e0f | 765 | // use already allocated space |
766 | if(fESDFMD){ | |
316c6cd9 | 767 | *fESDFMD = *obj; |
af885e0f | 768 | } |
769 | } | |
770 | ||
6989bff3 | 771 | void AliESDEvent::SetVZEROData(AliESDVZERO * obj) |
772 | { | |
af885e0f | 773 | // use already allocated space |
774 | if(fESDVZERO) | |
6989bff3 | 775 | *fESDVZERO = *obj; |
af885e0f | 776 | } |
777 | ||
6989bff3 | 778 | void AliESDEvent::GetESDfriend(AliESDfriend *ev) const |
779 | { | |
af885e0f | 780 | // |
781 | // Extracts the complementary info from the ESD | |
782 | // | |
783 | if (!ev) return; | |
784 | ||
785 | Int_t ntrk=GetNumberOfTracks(); | |
786 | ||
787 | for (Int_t i=0; i<ntrk; i++) { | |
80799a5f | 788 | AliESDtrack *t=GetTrack(i); |
af885e0f | 789 | const AliESDfriendTrack *f=t->GetFriendTrack(); |
790 | ev->AddTrack(f); | |
80799a5f | 791 | |
792 | t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack" | |
793 | ||
af885e0f | 794 | } |
795 | } | |
796 | ||
797 | ||
798 | void AliESDEvent::AddObject(TObject* obj) | |
799 | { | |
800 | // Add an object to the list of object. | |
801 | // Please be aware that in order to increase performance you should | |
802 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
803 | fESDObjects->SetOwner(kTRUE); | |
804 | fESDObjects->AddLast(obj); | |
805 | } | |
806 | ||
807 | ||
808 | void AliESDEvent::GetStdContent() | |
809 | { | |
810 | // set pointers for standard content | |
60e8f114 | 811 | // get by name much safer and not a big overhead since not called very often |
812 | ||
6989bff3 | 813 | fESDRun = (AliESDRun*)fESDObjects->FindObject(fgkESDListName[kESDRun]); |
814 | fHeader = (AliESDHeader*)fESDObjects->FindObject(fgkESDListName[kHeader]); | |
815 | fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fgkESDListName[kESDZDC]); | |
816 | fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fgkESDListName[kESDFMD]); | |
817 | fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fgkESDListName[kESDVZERO]); | |
818 | fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fgkESDListName[kESDTZERO]); | |
819 | fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kSPDVertex]); | |
820 | fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kPrimaryVertex]); | |
821 | fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fgkESDListName[kSPDMult]); | |
822 | fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kPHOSTrigger]); | |
823 | fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kEMCALTrigger]); | |
824 | fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]); | |
825 | fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]); | |
826 | fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]); | |
827 | fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]); | |
828 | fV0s = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kV0s]); | |
829 | fCascades = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCascades]); | |
830 | fKinks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kKinks]); | |
831 | fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCaloClusters]); | |
e649177a | 832 | fEMCALCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kEMCALCells]); |
833 | fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]); | |
6989bff3 | 834 | fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]); |
af885e0f | 835 | |
836 | } | |
837 | ||
838 | void AliESDEvent::SetStdNames(){ | |
839 | // Set the names of the standard contents | |
60e8f114 | 840 | // |
841 | if(fESDObjects->GetEntries()==kESDListN){ | |
842 | for(int i = 0;i < fESDObjects->GetEntries();i++){ | |
843 | TObject *fObj = fESDObjects->At(i); | |
844 | if(fObj->InheritsFrom("TNamed")){ | |
6989bff3 | 845 | ((TNamed*)fObj)->SetName(fgkESDListName[i]); |
60e8f114 | 846 | } |
847 | else if(fObj->InheritsFrom("TClonesArray")){ | |
6989bff3 | 848 | ((TClonesArray*)fObj)->SetName(fgkESDListName[i]); |
60e8f114 | 849 | } |
850 | } | |
851 | } | |
852 | else{ | |
853 | printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__); | |
854 | } | |
af885e0f | 855 | } |
856 | ||
857 | void AliESDEvent::CreateStdContent() | |
858 | { | |
859 | // create the standard AOD content and set pointers | |
860 | ||
861 | // create standard objects and add them to the TList of objects | |
862 | AddObject(new AliESDRun()); | |
863 | AddObject(new AliESDHeader()); | |
864 | AddObject(new AliESDZDC()); | |
865 | AddObject(new AliESDFMD()); | |
866 | AddObject(new AliESDVZERO()); | |
867 | AddObject(new AliESDTZERO()); | |
868 | AddObject(new AliESDVertex()); | |
869 | AddObject(new AliESDVertex()); | |
870 | AddObject(new AliMultiplicity()); | |
871 | AddObject(new AliESDCaloTrigger()); | |
872 | AddObject(new AliESDCaloTrigger()); | |
873 | AddObject(new TClonesArray("AliESDtrack",0)); | |
874 | AddObject(new TClonesArray("AliESDMuonTrack",0)); | |
875 | AddObject(new TClonesArray("AliESDPmdTrack",0)); | |
876 | AddObject(new TClonesArray("AliESDTrdTrack",0)); | |
877 | AddObject(new TClonesArray("AliESDv0",0)); | |
878 | AddObject(new TClonesArray("AliESDcascade",0)); | |
879 | AddObject(new TClonesArray("AliESDkink",0)); | |
880 | AddObject(new TClonesArray("AliESDCaloCluster",0)); | |
e649177a | 881 | AddObject(new AliESDCaloCells()); |
882 | AddObject(new AliESDCaloCells()); | |
af885e0f | 883 | AddObject(new TClonesArray("AliRawDataErrorLog",0)); |
884 | ||
885 | // check the order of the indices against enum... | |
886 | ||
af885e0f | 887 | // set names |
888 | SetStdNames(); | |
60e8f114 | 889 | // read back pointers |
890 | GetStdContent(); | |
af885e0f | 891 | } |
892 | ||
001b9beb | 893 | TObject* AliESDEvent::FindListObject(const char *name){ |
d7749dec | 894 | if(fESDObjects){ |
895 | return fESDObjects->FindObject(name); | |
896 | } | |
001b9beb | 897 | return 0; |
898 | } | |
899 | ||
cd1d4ee0 | 900 | Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const |
901 | { | |
902 | // fills the provided TRefArray with all found phos clusters | |
e649177a | 903 | |
cd1d4ee0 | 904 | clusters->Clear(); |
e649177a | 905 | |
cd1d4ee0 | 906 | AliESDCaloCluster *cl = 0; |
907 | for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { | |
e649177a | 908 | |
909 | if ( (cl = GetCaloCluster(i)) ) { | |
cd1d4ee0 | 910 | if (cl->IsPHOS()){ |
911 | clusters->Add(cl); | |
e649177a | 912 | AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast())); |
cd1d4ee0 | 913 | } |
914 | } | |
915 | } | |
916 | return clusters->GetEntriesFast(); | |
917 | } | |
918 | ||
919 | Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const | |
920 | { | |
e649177a | 921 | // fills the provided TRefArray with all found emcal clusters |
cd1d4ee0 | 922 | |
923 | clusters->Clear(); | |
924 | ||
925 | AliESDCaloCluster *cl = 0; | |
926 | for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { | |
927 | ||
e649177a | 928 | if ( (cl = GetCaloCluster(i)) ) { |
cd1d4ee0 | 929 | if (cl->IsEMCAL()){ |
930 | clusters->Add(cl); | |
e649177a | 931 | AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast())); |
cd1d4ee0 | 932 | } |
933 | } | |
934 | } | |
935 | return clusters->GetEntriesFast(); | |
936 | } | |
937 | ||
38f940fb | 938 | const void AliESDEvent::WriteToTree(TTree* tree) const { |
939 | // Book the branches as in TTree::Branch(TCollection*) | |
940 | // but add a "." at the end of top level branches which are | |
941 | // not a TClonesArray | |
942 | ||
943 | ||
944 | TString branchname; | |
945 | TIter next(fESDObjects); | |
946 | const Int_t splitlevel = 99; // default value in TTree::Branch() | |
947 | const Int_t bufsize = 32000; // default value in TTree::Branch() | |
948 | TObject *obj = 0; | |
949 | ||
950 | while ((obj = next())) { | |
951 | branchname.Form("%s", obj->GetName()); | |
952 | if ((splitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) { | |
953 | branchname += "."; | |
954 | } | |
955 | tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj), | |
956 | bufsize, splitlevel - 1); | |
957 | } | |
958 | ||
959 | } | |
960 | ||
cd1d4ee0 | 961 | |
af885e0f | 962 | void AliESDEvent::ReadFromTree(TTree *tree){ |
024c7734 | 963 | |
6989bff3 | 964 | if(!tree){ |
965 | Printf("%s %d AliESDEvent::ReadFromTree() Zero Pointer to Tree \n",(char*)__FILE__,__LINE__); | |
966 | return; | |
967 | } | |
024c7734 | 968 | // load the TTree |
6989bff3 | 969 | if(!tree->GetTree())tree->LoadTree(0); |
024c7734 | 970 | |
001b9beb | 971 | // if we find the "ESD" branch on the tree we do have the old structure |
1bd10080 | 972 | if(tree->GetBranch("ESD")) { |
973 | char ** address = (char **)(tree->GetBranch("ESD")->GetAddress()); | |
0eb6eb59 | 974 | // do we have the friend branch |
975 | TBranch * esdFB = tree->GetBranch("ESDfriend."); | |
976 | char ** addressF = 0; | |
977 | if(esdFB)addressF = (char **)(esdFB->GetAddress()); | |
6989bff3 | 978 | if (!address) { |
979 | printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__); | |
1bd10080 | 980 | tree->SetBranchAddress("ESD", &fESDOld); |
0eb6eb59 | 981 | if(esdFB){ |
982 | tree->SetBranchAddress("ESDfriend.",&fESDFriendOld); | |
983 | } | |
6989bff3 | 984 | } else { |
985 | printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__); | |
986 | printf("%s %d Branch already connected. Using existing branch address. \n",(char*)__FILE__,__LINE__); | |
1bd10080 | 987 | fESDOld = (AliESD*) (*address); |
0eb6eb59 | 988 | // addressF can still be 0, since branch needs to switched on |
989 | if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF); | |
6989bff3 | 990 | } |
0eb6eb59 | 991 | |
6989bff3 | 992 | // have already connected the old ESD structure... ? |
993 | // reuse also the pointer of the AlliESDEvent | |
994 | // otherwise create new ones | |
6989bff3 | 995 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
996 | ||
997 | if(connectedList){ | |
998 | // If connected use the connected list of objects | |
0eb6eb59 | 999 | if(fESDObjects!= connectedList){ |
1000 | // protect when called twice | |
1001 | fESDObjects->Delete(); | |
1002 | fESDObjects = connectedList; | |
1003 | } | |
6989bff3 | 1004 | GetStdContent(); |
0eb6eb59 | 1005 | |
0eb6eb59 | 1006 | |
d7749dec | 1007 | // The pointer to the friend changes when called twice via InitIO |
1008 | // since AliESDEvent is deleted | |
0eb6eb59 | 1009 | TObject* oldf = FindListObject("AliESDfriend"); |
1010 | TObject* newf = 0; | |
1011 | if(addressF){ | |
1012 | newf = (TObject*)*addressF; | |
1013 | } | |
1014 | if(newf!=0&&oldf!=newf){ | |
1015 | // remove the old reference | |
1016 | // Should we also delete it? Or is this handled in TTree I/O | |
1017 | // since it is created by the first SetBranchAddress | |
1018 | fESDObjects->Remove(oldf); | |
1019 | // add the new one | |
1020 | fESDObjects->Add(newf); | |
1021 | } | |
1022 | ||
6989bff3 | 1023 | fConnected = true; |
b93c2026 | 1024 | return; |
6989bff3 | 1025 | } |
1026 | // else... | |
1027 | CreateStdContent(); // create for copy | |
0eb6eb59 | 1028 | // if we have the esdfriend add it, so we always can access it via the userinfo |
1029 | if(fESDFriendOld)AddObject(fESDFriendOld); | |
6989bff3 | 1030 | // we are not owner of the list objects |
1031 | // must not delete it | |
1032 | fESDObjects->SetOwner(kFALSE); | |
1033 | fESDObjects->SetName("ESDObjectsConnectedToTree"); | |
1034 | tree->GetUserInfo()->Add(fESDObjects); | |
1035 | fConnected = true; | |
1036 | return; | |
af885e0f | 1037 | } |
0eb6eb59 | 1038 | |
6989bff3 | 1039 | delete fESDOld; |
af885e0f | 1040 | fESDOld = 0; |
af885e0f | 1041 | // Try to find AliESDEvent |
1042 | AliESDEvent *esdEvent = 0; | |
1043 | esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent"); | |
001b9beb | 1044 | if(esdEvent){ |
941603c0 | 1045 | // Check if already connected to tree |
139f2194 | 1046 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
1047 | if (connectedList) { | |
1048 | // If connected use the connected list if objects | |
1049 | fESDObjects->Delete(); | |
b5bc83df | 1050 | fESDObjects = connectedList; |
1051 | GetStdContent(); | |
60e8f114 | 1052 | fConnected = true; |
139f2194 | 1053 | return; |
1054 | } | |
1055 | // Connect to tree | |
001b9beb | 1056 | // prevent a memory leak when reading back the TList |
1057 | delete fESDObjects; | |
1058 | fESDObjects = 0; | |
af885e0f | 1059 | // create a new TList from the UserInfo TList... |
1060 | // copy constructor does not work... | |
1061 | fESDObjects = (TList*)(esdEvent->GetList()->Clone()); | |
139f2194 | 1062 | fESDObjects->SetOwner(kFALSE); |
af885e0f | 1063 | if(fESDObjects->GetEntries()<kESDListN){ |
941603c0 | 1064 | printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n", |
1065 | (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN); | |
af885e0f | 1066 | } |
1067 | // set the branch addresses | |
1068 | TIter next(fESDObjects); | |
1069 | TNamed *el; | |
1070 | while((el=(TNamed*)next())){ | |
1071 | TString bname(el->GetName()); | |
af885e0f | 1072 | if(bname.CompareTo("AliESDfriend")==0) |
1073 | { | |
1074 | // AliESDfriend does not have a name ... | |
af885e0f | 1075 | tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el)); |
1076 | } | |
1077 | else{ | |
38f940fb | 1078 | // check if branch exists under this Name |
1079 | TBranch *br = tree->GetBranch(bname.Data()); | |
1080 | if(br){ | |
1081 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
1082 | } | |
1083 | else{ | |
1084 | br = tree->GetBranch(Form("%s.",bname.Data())); | |
1085 | if(br){ | |
1086 | tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el)); | |
1087 | } | |
1088 | else{ | |
1089 | printf("%s %d AliESDEvent::ReadFromTree() No Branch found with Name %s or %s. \n", | |
1090 | (char*)__FILE__,__LINE__,bname.Data(),bname.Data()); | |
1091 | } | |
1092 | ||
1093 | } | |
af885e0f | 1094 | } |
1095 | } | |
1096 | GetStdContent(); | |
1097 | // when reading back we are not owner of the list | |
1098 | // must not delete it | |
1099 | fESDObjects->SetOwner(kFALSE); | |
60e8f114 | 1100 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
139f2194 | 1101 | // we are not owner of the list objects |
1102 | // must not delete it | |
60e8f114 | 1103 | tree->GetUserInfo()->Add(fESDObjects); |
1104 | fConnected = true; | |
af885e0f | 1105 | }// no esdEvent |
1106 | else { | |
001b9beb | 1107 | // we can't get the list from the user data, create standard content |
1108 | // and set it by hand (no ESDfriend at the moment | |
af885e0f | 1109 | CreateStdContent(); |
1110 | TIter next(fESDObjects); | |
1111 | TNamed *el; | |
1112 | while((el=(TNamed*)next())){ | |
1113 | TString bname(el->GetName()); | |
1114 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
1115 | } | |
1116 | GetStdContent(); | |
1117 | // when reading back we are not owner of the list | |
1118 | // must not delete it | |
1119 | fESDObjects->SetOwner(kFALSE); | |
1120 | } | |
af885e0f | 1121 | } |
1122 | ||
1123 | ||
1124 | void AliESDEvent::CopyFromOldESD() | |
1125 | { | |
1126 | // Method which copies over everthing from the old esd structure to the | |
1127 | // new | |
af885e0f | 1128 | if(fESDOld){ |
1129 | ResetStdContent(); | |
1130 | // Run | |
1131 | SetRunNumber(fESDOld->GetRunNumber()); | |
1132 | SetPeriodNumber(fESDOld->GetPeriodNumber()); | |
6ca8842a | 1133 | SetMagneticField(fESDOld->GetMagneticField()); |
af885e0f | 1134 | |
1135 | // leave out diamond ... | |
1136 | // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);} | |
1137 | ||
1138 | // header | |
1139 | SetTriggerMask(fESDOld->GetTriggerMask()); | |
1140 | SetOrbitNumber(fESDOld->GetOrbitNumber()); | |
1141 | SetTimeStamp(fESDOld->GetTimeStamp()); | |
1142 | SetEventType(fESDOld->GetEventType()); | |
1143 | SetEventNumberInFile(fESDOld->GetEventNumberInFile()); | |
1144 | SetBunchCrossNumber(fESDOld->GetBunchCrossNumber()); | |
1145 | SetTriggerCluster(fESDOld->GetTriggerCluster()); | |
1146 | ||
1147 | // ZDC | |
1148 | ||
1149 | SetZDC(fESDOld->GetZDCN1Energy(), | |
a85132e7 | 1150 | fESDOld->GetZDCP1Energy(), |
1151 | fESDOld->GetZDCEMEnergy(), | |
1152 | 0, | |
1153 | fESDOld->GetZDCN2Energy(), | |
1154 | fESDOld->GetZDCP2Energy(), | |
1155 | fESDOld->GetZDCParticipants()); | |
af885e0f | 1156 | |
1157 | // FMD | |
1158 | ||
cb6aa27f | 1159 | if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData()); |
af885e0f | 1160 | |
1161 | // T0 | |
1162 | ||
1163 | SetT0zVertex(fESDOld->GetT0zVertex()); | |
1164 | SetT0(fESDOld->GetT0()); | |
1165 | // leave amps out | |
1166 | ||
1167 | // VZERO | |
c06eaba2 | 1168 | if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData()); |
af885e0f | 1169 | |
cb6aa27f | 1170 | if(fESDOld->GetVertex())SetVertex(fESDOld->GetVertex()); |
af885e0f | 1171 | |
cb6aa27f | 1172 | if(fESDOld->GetPrimaryVertex())SetPrimaryVertex(fESDOld->GetPrimaryVertex()); |
af885e0f | 1173 | |
cb6aa27f | 1174 | if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity()); |
1bd10080 | 1175 | |
af885e0f | 1176 | for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){ |
1177 | AddTrack(fESDOld->GetTrack(i)); | |
1178 | } | |
1179 | ||
1180 | for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){ | |
1181 | AddMuonTrack(fESDOld->GetMuonTrack(i)); | |
1182 | } | |
1183 | ||
1184 | for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){ | |
1185 | AddPmdTrack(fESDOld->GetPmdTrack(i)); | |
1186 | } | |
1187 | ||
1188 | for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){ | |
1189 | AddTrdTrack(fESDOld->GetTrdTrack(i)); | |
1190 | } | |
1191 | ||
1192 | for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){ | |
1193 | AddV0(fESDOld->GetV0(i)); | |
1194 | } | |
1195 | ||
1196 | for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){ | |
1197 | AddCascade(fESDOld->GetCascade(i)); | |
1198 | } | |
1199 | ||
1200 | for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){ | |
1201 | AddKink(fESDOld->GetKink(i)); | |
1202 | } | |
1203 | ||
1204 | ||
1205 | for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){ | |
1206 | AddCaloCluster(fESDOld->GetCaloCluster(i)); | |
1207 | } | |
1bd10080 | 1208 | |
af885e0f | 1209 | }// if fesdold |
1210 | } | |
1211 | ||
1212 | ||
1213 |