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