1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------
19 // Implementation of the AliESDEvent class
20 // This is the class to deal with during the phisical analysis of data.
21 // It also ensures the backward compatibility with the old ESD format.
23 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
24 //-----------------------------------------------------------------
27 #include "TRefArray.h"
30 #include "AliESDEvent.h"
31 #include "AliESDfriend.h"
32 #include "AliESDVZERO.h"
33 #include "AliESDHLTtrack.h"
34 #include "AliESDFMD.h"
36 #include "AliESDMuonTrack.h"
37 #include "AliESDPmdTrack.h"
38 #include "AliESDTrdTrack.h"
39 #include "AliESDVertex.h"
40 #include "AliESDcascade.h"
41 #include "AliESDPmdTrack.h"
42 #include "AliESDTrdTrack.h"
43 #include "AliESDVertex.h"
44 #include "AliESDcascade.h"
45 #include "AliESDkink.h"
46 #include "AliESDtrack.h"
47 #include "AliESDHLTtrack.h"
48 #include "AliESDCaloCluster.h"
50 #include "AliESDFMD.h"
51 #include "AliESDVZERO.h"
52 #include "AliMultiplicity.h"
53 #include "AliRawDataErrorLog.h"
60 // here we define the names, some classes are no TNamed, therefore the classnames
62 const char* AliESDEvent::fESDListName[kESDListN] = {"AliESDRun",
81 "AliRawDataErrorLogs"};
82 //______________________________________________________________________________
83 AliESDEvent::AliESDEvent():
85 fESDObjects(new TList()),
109 fFirstEMCALCluster(-1),
111 fFirstPHOSCluster(-1)
114 //______________________________________________________________________________
115 AliESDEvent::AliESDEvent(const AliESDEvent& esd):
117 fESDObjects(new TList()),
118 fESDRun(new AliESDRun(*esd.fESDRun)),
119 fHeader(new AliESDHeader(*esd.fHeader)),
120 fESDZDC(new AliESDZDC(*esd.fESDZDC)),
121 fESDFMD(new AliESDFMD(*esd.fESDFMD)),
122 fESDVZERO(new AliESDVZERO(*esd.fESDVZERO)),
123 fESDTZERO(new AliESDTZERO(*esd.fESDTZERO)),
124 fSPDVertex(new AliESDVertex(*esd.fSPDVertex)),
125 fPrimaryVertex(new AliESDVertex(*esd.fPrimaryVertex)),
126 fSPDMult(new AliMultiplicity(*esd.fSPDMult)),
127 fPHOSTrigger(new AliESDCaloTrigger(*esd.fPHOSTrigger)),
128 fEMCALTrigger(new AliESDCaloTrigger(*esd.fEMCALTrigger)),
129 fTracks(new TClonesArray(*esd.fTracks)),
130 fMuonTracks(new TClonesArray(*esd.fMuonTracks)),
131 fPmdTracks(new TClonesArray(*esd.fPmdTracks)),
132 fTrdTracks(new TClonesArray(*esd.fTrdTracks)),
133 fV0s(new TClonesArray(*esd.fV0s)),
134 fCascades(new TClonesArray(*esd.fCascades)),
135 fKinks(new TClonesArray(*esd.fKinks)),
136 fCaloClusters(new TClonesArray(*esd.fCaloClusters)),
137 fErrorLogs(new TClonesArray(*esd.fErrorLogs)),
138 fESDOld(new AliESD(*esd.fESDOld)),
139 fConnected(esd.fConnected),
140 fEMCALClusters(esd.fEMCALClusters),
141 fFirstEMCALCluster(esd.fFirstEMCALCluster),
142 fPHOSClusters(esd.fPHOSClusters),
143 fFirstPHOSCluster(esd.fFirstPHOSCluster)
146 // CKB init in the constructor list and only add here ...
151 AddObject(fESDVZERO);
152 AddObject(fESDTZERO);
153 AddObject(fSPDVertex);
154 AddObject(fPrimaryVertex);
156 AddObject(fPHOSTrigger);
157 AddObject(fEMCALTrigger);
159 AddObject(fMuonTracks);
160 AddObject(fPmdTracks);
161 AddObject(fTrdTracks);
163 AddObject(fCascades);
165 AddObject(fCaloClusters);
166 AddObject(fErrorLogs);
172 //______________________________________________________________________________
173 AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
175 // Assignment operator
177 if(&source == this) return *this;
178 AliVEvent::operator=(source);
180 fESDRun = new AliESDRun(*source.fESDRun);
181 fHeader = new AliESDHeader(*source.fHeader);
182 fESDZDC = new AliESDZDC(*source.fESDZDC);
183 fESDFMD = new AliESDFMD(*source.fESDFMD);
184 fESDVZERO = new AliESDVZERO(*source.fESDVZERO);
185 fESDTZERO = new AliESDTZERO(*source.fESDTZERO);
186 fSPDVertex = new AliESDVertex(*source.fSPDVertex);
187 fPrimaryVertex = new AliESDVertex(*source.fPrimaryVertex);
188 fSPDMult = new AliMultiplicity(*source.fSPDMult);
189 fPHOSTrigger = new AliESDCaloTrigger(*source.fPHOSTrigger);
190 fEMCALTrigger = new AliESDCaloTrigger(*source.fEMCALTrigger);
191 fTracks = new TClonesArray(*source.fTracks);
192 fMuonTracks = new TClonesArray(*source.fMuonTracks);
193 fPmdTracks = new TClonesArray(*source.fPmdTracks);
194 fTrdTracks = new TClonesArray(*source.fTrdTracks);
195 fV0s = new TClonesArray(*source.fV0s);
196 fCascades = new TClonesArray(*source.fCascades);
197 fKinks = new TClonesArray(*source.fKinks);
198 fCaloClusters = new TClonesArray(*source.fCaloClusters);
199 fErrorLogs = new TClonesArray(*source.fErrorLogs);
200 fESDOld = new AliESD(*source.fESDOld);
202 // or AddObject( fESDZDC = new AliESDZDC(*source.fESDZDC));
204 fESDObjects = new TList();
209 AddObject(fESDVZERO);
210 AddObject(fESDTZERO);
211 AddObject(fSPDVertex);
212 AddObject(fPrimaryVertex);
214 AddObject(fPHOSTrigger);
215 AddObject(fEMCALTrigger);
217 AddObject(fMuonTracks);
218 AddObject(fPmdTracks);
219 AddObject(fTrdTracks);
221 AddObject(fCascades);
223 AddObject(fCaloClusters);
224 AddObject(fErrorLogs);
226 fConnected = source.fConnected;
227 fEMCALClusters = source.fEMCALClusters;
228 fFirstEMCALCluster = source.fFirstEMCALCluster;
229 fPHOSClusters = source.fPHOSClusters;
230 fFirstPHOSCluster = source.fFirstPHOSCluster;
239 //______________________________________________________________________________
240 AliESDEvent::~AliESDEvent()
243 // Standard destructor
246 // everthing on the list gets deleted automatically
249 if(fESDObjects&&!fConnected)
258 //______________________________________________________________________________
259 void AliESDEvent::Reset()
263 // Reset the standard contents
266 if(fESDOld)fESDOld->Reset();
267 // call reset for user supplied data?
270 void AliESDEvent::ResetStdContent()
272 // Reset the standard contents
273 if(fESDRun) fESDRun->Reset();
274 if(fHeader) fHeader->Reset();
275 if(fESDZDC) fESDZDC->Reset();
276 if(fESDFMD) fESDFMD->Clear(); // why clear.... need consistend names
277 // if(fESDVZERO) fESDVZERO->; // NOT IMPLEMENTED
278 // if(fESDVZERO) new (fESDVZERO) AliESDVZERO();
279 if(fESDTZERO) fESDTZERO->Reset();
280 // CKB no clear/reset implemented
282 fSPDVertex->~AliESDVertex();
283 new (fSPDVertex) AliESDVertex();
284 fSPDVertex->SetName(fESDListName[kSPDVertex]);
287 fPrimaryVertex->~AliESDVertex();
288 new (fPrimaryVertex) AliESDVertex();
289 fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]);
292 fSPDMult->~AliMultiplicity();
293 new (fSPDMult) AliMultiplicity();
295 if(fPHOSTrigger)fPHOSTrigger->Reset();
296 if(fEMCALTrigger)fEMCALTrigger->Reset();
297 if(fTracks)fTracks->Delete();
298 if(fMuonTracks)fMuonTracks->Clear();
299 if(fPmdTracks)fPmdTracks->Clear();
300 if(fTrdTracks)fTrdTracks->Clear();
301 if(fV0s)fV0s->Clear();
302 if(fCascades)fCascades->Clear();
303 if(fKinks)fKinks->Clear();
304 if(fCaloClusters)fCaloClusters->Delete();
305 if(fErrorLogs) fErrorLogs->Delete();
307 // don't reset fconnected fConnected ;
310 fFirstEMCALCluster=-1;
312 fFirstPHOSCluster=-1;
316 Int_t AliESDEvent::AddV0(const AliESDv0 *v) {
320 TClonesArray &fv = *fV0s;
321 Int_t idx=fV0s->GetEntriesFast();
322 new(fv[idx]) AliESDv0(*v);
326 //______________________________________________________________________________
327 void AliESDEvent::Print(Option_t *) const
330 // Print header information of the event
332 printf("ESD run information\n");
333 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
334 GetEventNumberInFile(),
335 GetBunchCrossNumber(),
340 GetMagneticField() );
341 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
342 fPrimaryVertex->GetXv(), fPrimaryVertex->GetXRes(),
343 fPrimaryVertex->GetYv(), fPrimaryVertex->GetYRes(),
344 fPrimaryVertex->GetZv(), fPrimaryVertex->GetZRes());
345 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
346 GetDiamondX(),GetDiamondY());
347 printf("SPD Multiplicity. Number of tracklets %d \n",
348 fSPDMult->GetNumberOfTracklets());
349 printf("Number of tracks: \n");
350 printf(" charged %d\n", GetNumberOfTracks());
351 printf(" muon %d\n", GetNumberOfMuonTracks());
352 printf(" pmd %d\n", GetNumberOfPmdTracks());
353 printf(" trd %d\n", GetNumberOfTrdTracks());
354 printf(" v0 %d\n", GetNumberOfV0s());
355 printf(" cascades %d\n", GetNumberOfCascades());
356 printf(" kinks %d\n", GetNumberOfKinks());
357 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
358 printf(" phos %d\n", GetNumberOfPHOSClusters());
359 printf(" emcal %d\n", GetNumberOfEMCALClusters());
360 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
361 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
366 void AliESDEvent::SetESDfriend(const AliESDfriend *ev) {
368 // Attaches the complementary info to the ESD
372 // to be sure that we set the tracks also
373 // in case of old esds
374 // if(fESDOld)CopyFromOldESD();
376 Int_t ntrk=ev->GetNumberOfTracks();
378 for (Int_t i=0; i<ntrk; i++) {
379 const AliESDfriendTrack *f=ev->GetTrack(i);
380 GetTrack(i)->SetFriendTrack(f);
384 Bool_t AliESDEvent::RemoveTrack(Int_t rm) {
385 // ---------------------------------------------------------
386 // Remove a track and references to it from ESD,
387 // if this track does not come from a reconstructed decay
388 // ---------------------------------------------------------
389 Int_t last=GetNumberOfTracks()-1;
390 if ((rm<0)||(rm>last)) return kFALSE;
394 // Check if this track comes from a reconstructed decay
395 Int_t nv0=GetNumberOfV0s();
396 for (Int_t n=0; n<nv0; n++) {
397 AliESDv0 *v0=GetV0(n);
399 Int_t idx=v0->GetNindex();
400 if (rm==idx) return kFALSE;
401 if (idx==last) used++;
404 if (rm==idx) return kFALSE;
405 if (idx==last) used++;
408 Int_t ncs=GetNumberOfCascades();
409 for (Int_t n=0; n<ncs; n++) {
410 AliESDcascade *cs=GetCascade(n);
412 Int_t idx=cs->GetIndex();
413 if (rm==idx) return kFALSE;
414 if (idx==last) used++;
417 Int_t nkn=GetNumberOfKinks();
418 for (Int_t n=0; n<nkn; n++) {
419 AliESDkink *kn=GetKink(n);
421 Int_t idx=kn->GetIndex(0);
422 if (rm==idx) return kFALSE;
423 if (idx==last) used++;
426 if (rm==idx) return kFALSE;
427 if (idx==last) used++;
431 //Replace the removed track with the last track
432 TClonesArray &a=*fTracks;
433 delete a.RemoveAt(rm);
435 if (rm==last) return kTRUE;
437 AliESDtrack *t=GetTrack(last);
439 new (a[rm]) AliESDtrack(*t);
440 delete a.RemoveAt(last);
442 if (!used) return kTRUE;
445 // Remap the indices of the daughters of reconstructed decays
446 for (Int_t n=0; n<nv0; n++) {
447 AliESDv0 *v0=GetV0(n);
448 if (v0->GetIndex(0)==last) {
451 if (!used) return kTRUE;
453 if (v0->GetIndex(1)==last) {
456 if (!used) return kTRUE;
460 for (Int_t n=0; n<ncs; n++) {
461 AliESDcascade *cs=GetCascade(n);
462 if (cs->GetIndex()==last) {
465 if (!used) return kTRUE;
469 for (Int_t n=0; n<nkn; n++) {
470 AliESDkink *kn=GetKink(n);
471 if (kn->GetIndex(0)==last) {
474 if (!used) return kTRUE;
476 if (kn->GetIndex(1)==last) {
479 if (!used) return kTRUE;
487 Bool_t AliESDEvent::Clean(Float_t *cleanPars) {
489 // Remove the data which are not needed for the physics analysis.
491 // If track's transverse parameter is larger than fDmax
493 // track's longitudinal parameter is larger than fZmax
494 // an attempt to remove this track from ESD is made.
496 // The track gets removed if it does not come
497 // from a reconstructed decay
500 Float_t dmax=cleanPars[0], zmax=cleanPars[1];
502 const AliESDVertex *vertex=GetVertex();
503 Bool_t vtxOK=vertex->GetStatus(), rc=kFALSE;
505 Int_t nTracks=GetNumberOfTracks();
506 for (Int_t i=nTracks-1; i>=0; i--) {
507 AliESDtrack *track=GetTrack(i);
508 Float_t xy,z; track->GetImpactParameters(xy,z);
509 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
510 if (RemoveTrack(i)) rc=kTRUE;
517 Int_t AliESDEvent::AddTrack(const AliESDtrack *t) {
519 TClonesArray &ftr = *fTracks;
520 AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t);
521 track->SetID(fTracks->GetEntriesFast()-1);
522 return track->GetID();
525 void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t) {
526 TClonesArray &fmu = *fMuonTracks;
527 new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t);
530 void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t) {
531 TClonesArray &fpmd = *fPmdTracks;
532 new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t);
535 void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t) {
536 TClonesArray &ftrd = *fTrdTracks;
537 new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t);
543 Int_t AliESDEvent::AddKink(const AliESDkink *c) {
545 TClonesArray &fk = *fKinks;
546 AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c);
547 kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps..
548 return fKinks->GetEntriesFast()-1;
552 void AliESDEvent::AddCascade(const AliESDcascade *c) {
553 TClonesArray &fc = *fCascades;
554 new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c);
558 Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) {
560 TClonesArray &fc = *fCaloClusters;
561 AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c);
562 clus->SetID(fCaloClusters->GetEntriesFast()-1);
563 return fCaloClusters->GetEntriesFast()-1;
567 void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) {
568 TClonesArray &errlogs = *fErrorLogs;
569 new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log);
572 void AliESDEvent::SetVertex(const AliESDVertex *vertex) {
573 // use already allocated space
575 *fSPDVertex = *vertex;
576 fSPDVertex->SetName(fESDListName[kSPDVertex]);
580 void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex) {
582 *fPrimaryVertex = *vertex;
583 fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]);
587 void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) {
594 void AliESDEvent::SetFMDData(AliESDFMD * obj) {
595 // use already allocated space
601 void AliESDEvent::SetVZEROData(AliESDVZERO * obj){
602 // use already allocated space
604 new(fESDVZERO) AliESDVZERO(*obj);
607 void AliESDEvent::GetESDfriend(AliESDfriend *ev) const {
609 // Extracts the complementary info from the ESD
613 Int_t ntrk=GetNumberOfTracks();
615 for (Int_t i=0; i<ntrk; i++) {
616 AliESDtrack *t=GetTrack(i);
617 const AliESDfriendTrack *f=t->GetFriendTrack();
620 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
626 void AliESDEvent::AddObject(TObject* obj)
628 // Add an object to the list of object.
629 // Please be aware that in order to increase performance you should
630 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
631 fESDObjects->SetOwner(kTRUE);
632 fESDObjects->AddLast(obj);
636 void AliESDEvent::GetStdContent()
638 // set pointers for standard content
639 // get by name much safer and not a big overhead since not called very often
641 fESDRun = (AliESDRun*)fESDObjects->FindObject(fESDListName[kESDRun]);
642 fHeader = (AliESDHeader*)fESDObjects->FindObject(fESDListName[kHeader]);
643 fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fESDListName[kESDZDC]);
644 fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fESDListName[kESDFMD]);
645 fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fESDListName[kESDVZERO]);
646 fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fESDListName[kESDTZERO]);
647 fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fESDListName[kSPDVertex]);
648 fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fESDListName[kPrimaryVertex]);
649 fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fESDListName[kSPDMult]);
650 fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fESDListName[kPHOSTrigger]);
651 fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fESDListName[kEMCALTrigger]);
652 fTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kTracks]);
653 fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kMuonTracks]);
654 fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kPmdTracks]);
655 fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kTrdTracks]);
656 fV0s = (TClonesArray*)fESDObjects->FindObject(fESDListName[kV0s]);
657 fCascades = (TClonesArray*)fESDObjects->FindObject(fESDListName[kCascades]);
658 fKinks = (TClonesArray*)fESDObjects->FindObject(fESDListName[kKinks]);
659 fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fESDListName[kCaloClusters]);
660 fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fESDListName[kErrorLogs]);
664 void AliESDEvent::SetStdNames(){
665 // Set the names of the standard contents
667 if(fESDObjects->GetEntries()==kESDListN){
668 for(int i = 0;i < fESDObjects->GetEntries();i++){
669 TObject *fObj = fESDObjects->At(i);
670 if(fObj->InheritsFrom("TNamed")){
671 ((TNamed*)fObj)->SetName(fESDListName[i]);
673 else if(fObj->InheritsFrom("TClonesArray")){
674 ((TClonesArray*)fObj)->SetName(fESDListName[i]);
679 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
683 void AliESDEvent::CreateStdContent()
685 // create the standard AOD content and set pointers
687 // create standard objects and add them to the TList of objects
688 AddObject(new AliESDRun());
689 AddObject(new AliESDHeader());
690 AddObject(new AliESDZDC());
691 AddObject(new AliESDFMD());
692 AddObject(new AliESDVZERO());
693 AddObject(new AliESDTZERO());
694 AddObject(new AliESDVertex());
695 AddObject(new AliESDVertex());
696 AddObject(new AliMultiplicity());
697 AddObject(new AliESDCaloTrigger());
698 AddObject(new AliESDCaloTrigger());
699 AddObject(new TClonesArray("AliESDtrack",0));
700 AddObject(new TClonesArray("AliESDMuonTrack",0));
701 AddObject(new TClonesArray("AliESDPmdTrack",0));
702 AddObject(new TClonesArray("AliESDTrdTrack",0));
703 AddObject(new TClonesArray("AliESDv0",0));
704 AddObject(new TClonesArray("AliESDcascade",0));
705 AddObject(new TClonesArray("AliESDkink",0));
706 AddObject(new TClonesArray("AliESDCaloCluster",0));
707 AddObject(new TClonesArray("AliRawDataErrorLog",0));
709 // check the order of the indices against enum...
713 // read back pointers
717 TObject* AliESDEvent::FindListObject(const char *name){
718 if(fESDObjects)return fESDObjects->FindObject(name);
722 Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
724 // fills the provided TRefArray with all found phos clusters
728 AliESDCaloCluster *cl = 0;
729 for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
731 if ( cl = GetCaloCluster(i)) {
734 printf("IsPHOS %d Size: %d \n",i,clusters->GetEntriesFast());
738 return clusters->GetEntriesFast();
741 Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
743 // fills the provided TRefArray with all found phos clusters
747 AliESDCaloCluster *cl = 0;
748 for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
750 if ( cl = GetCaloCluster(i)) {
753 printf("IsEMCAL %d Size: %d \n",i,clusters->GetEntriesFast());
757 return clusters->GetEntriesFast();
761 void AliESDEvent::ReadFromTree(TTree *tree){
766 // if we find the "ESD" branch on the tree we do have the old structure
767 if(tree->GetBranch("ESD")){
768 char ** address = (char **)(tree->GetBranch("ESD")->GetAddress());
770 printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__);
771 tree->SetBranchAddress("ESD",&fESDOld);
773 printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__);
774 printf("%s %d Branch already connected. Using existing branch address. \n",(char*)__FILE__,__LINE__);
775 fESDOld = (AliESD*) (*address);
779 CreateStdContent(); // create for copy
780 // when reading back we are not owner of the list
781 // must not delete it
782 fESDObjects->SetOwner(kFALSE);
789 // Try to find AliESDEvent
790 AliESDEvent *esdEvent = 0;
791 esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent");
792 //esdEvent = (AliESDEvent*)tree->GetUserInfo()->FindObject("AliESDEvent");
795 // Check if already connected to tree
796 TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
798 // If connected use the connected list if objects
799 fESDObjects->Delete();
800 fESDObjects = connectedList;
806 if(fESDObjects->GetEntries()!=0){
807 // this should not happen here put a warning?
809 // prevent a memory leak when reading back the TList
812 // create a new TList from the UserInfo TList...
813 // copy constructor does not work...
814 fESDObjects = (TList*)(esdEvent->GetList()->Clone());
815 fESDObjects->SetOwner(kFALSE);
816 if(fESDObjects->GetEntries()<kESDListN){
817 printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
818 (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN);
820 // set the branch addresses
821 TIter next(fESDObjects);
823 while((el=(TNamed*)next())){
824 TString bname(el->GetName());
826 if(bname.CompareTo("AliESDfriend")==0)
828 // AliESDfriend does not have a name ...
829 tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el));
832 tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
836 // when reading back we are not owner of the list
837 // must not delete it
838 fESDObjects->SetOwner(kFALSE);
839 fESDObjects->SetName("ESDObjectsConnectedToTree");
840 // we are not owner of the list objects
841 // must not delete it
842 tree->GetUserInfo()->Add(fESDObjects);
846 // we can't get the list from the user data, create standard content
847 // and set it by hand (no ESDfriend at the moment
849 TIter next(fESDObjects);
851 while((el=(TNamed*)next())){
852 TString bname(el->GetName());
853 tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
856 // when reading back we are not owner of the list
857 // must not delete it
858 fESDObjects->SetOwner(kFALSE);
866 void AliESDEvent::CopyFromOldESD()
868 // Method which copies over everthing from the old esd structure to the
874 SetRunNumber(fESDOld->GetRunNumber());
875 SetPeriodNumber(fESDOld->GetPeriodNumber());
876 SetMagneticField(fESDRun->GetMagneticField());
878 // leave out diamond ...
879 // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);}
882 SetTriggerMask(fESDOld->GetTriggerMask());
883 SetOrbitNumber(fESDOld->GetOrbitNumber());
884 SetTimeStamp(fESDOld->GetTimeStamp());
885 SetEventType(fESDOld->GetEventType());
886 SetEventNumberInFile(fESDOld->GetEventNumberInFile());
887 SetBunchCrossNumber(fESDOld->GetBunchCrossNumber());
888 SetTriggerCluster(fESDOld->GetTriggerCluster());
892 SetZDC(fESDOld->GetZDCN1Energy(),
893 fESDOld->GetZDCP1Energy(),
894 fESDOld->GetZDCEMEnergy(),
895 fESDOld->GetZDCN2Energy(),
896 fESDOld->GetZDCP2Energy(),
897 fESDOld->GetZDCParticipants());
901 if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData());
905 SetT0zVertex(fESDOld->GetT0zVertex());
906 SetT0(fESDOld->GetT0());
910 if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData());
912 if(fESDOld->GetVertex())SetVertex(fESDOld->GetVertex());
914 if(fESDOld->GetPrimaryVertex())SetPrimaryVertex(fESDOld->GetPrimaryVertex());
916 if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity());
918 for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){
919 AddTrack(fESDOld->GetTrack(i));
922 for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){
923 AddMuonTrack(fESDOld->GetMuonTrack(i));
926 for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){
927 AddPmdTrack(fESDOld->GetPmdTrack(i));
930 for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){
931 AddTrdTrack(fESDOld->GetTrdTrack(i));
934 for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){
935 AddV0(fESDOld->GetV0(i));
938 for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){
939 AddCascade(fESDOld->GetCascade(i));
942 for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){
943 AddKink(fESDOld->GetKink(i));
947 for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){
948 AddCaloCluster(fESDOld->GetCaloCluster(i));