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