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 physics analysis of data.
21 // It also ensures the backward compatibility with the old ESD format.
23 AliESDEvent *ev= new AliESDEvent();
24 ev->ReadFromTree(esdTree);
26 for (Int_t i=0; i<nev; i++) {
28 if(ev->GetAliESDOld())ev->CopyFromOldESD();
30 // The AliESDInputHAndler does this automatically for you
32 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
33 //-----------------------------------------------------------------
36 #include "TRefArray.h"
39 #include "AliESDEvent.h"
40 #include "AliESDfriend.h"
41 #include "AliESDVZERO.h"
42 #include "AliESDFMD.h"
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"
57 #include "AliESDCaloCells.h"
59 #include "AliESDFMD.h"
60 #include "AliESDVZERO.h"
61 #include "AliMultiplicity.h"
62 #include "AliRawDataErrorLog.h"
69 // here we define the names, some classes are no TNamed, therefore the classnames
71 const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
93 "AliRawDataErrorLogs"};
94 //______________________________________________________________________________
95 AliESDEvent::AliESDEvent():
97 fESDObjects(new TList()),
118 fEMCALCells(0), fPHOSCells(0),
124 fFirstEMCALCluster(-1),
126 fFirstPHOSCluster(-1)
129 //______________________________________________________________________________
130 AliESDEvent::AliESDEvent(const AliESDEvent& esd):
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)),
139 fTPCVertex(new AliESDVertex(*esd.fTPCVertex)),
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)),
153 fEMCALCells(new AliESDCaloCells(*esd.fEMCALCells)),
154 fPHOSCells(new AliESDCaloCells(*esd.fPHOSCells)),
155 fErrorLogs(new TClonesArray(*esd.fErrorLogs)),
156 fESDOld(new AliESD(*esd.fESDOld)),
157 fESDFriendOld(new AliESDfriend(*esd.fESDFriendOld)),
158 fConnected(esd.fConnected),
159 fEMCALClusters(esd.fEMCALClusters),
160 fFirstEMCALCluster(esd.fFirstEMCALCluster),
161 fPHOSClusters(esd.fPHOSClusters),
162 fFirstPHOSCluster(esd.fFirstPHOSCluster)
165 // CKB init in the constructor list and only add here ...
170 AddObject(fESDVZERO);
171 AddObject(fESDTZERO);
172 AddObject(fTPCVertex);
173 AddObject(fSPDVertex);
174 AddObject(fPrimaryVertex);
176 AddObject(fPHOSTrigger);
177 AddObject(fEMCALTrigger);
179 AddObject(fMuonTracks);
180 AddObject(fPmdTracks);
181 AddObject(fTrdTracks);
183 AddObject(fCascades);
185 AddObject(fCaloClusters);
186 AddObject(fEMCALCells);
187 AddObject(fPHOSCells);
188 AddObject(fErrorLogs);
194 //______________________________________________________________________________
195 AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
197 // Assignment operator
199 if(&source == this) return *this;
200 AliVEvent::operator=(source);
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);
208 fTPCVertex = new AliESDVertex(*source.fTPCVertex);
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);
222 fEMCALCells = new AliESDCaloCells(*source.fEMCALCells);
223 fPHOSCells = new AliESDCaloCells(*source.fPHOSCells);
224 fErrorLogs = new TClonesArray(*source.fErrorLogs);
225 fESDOld = new AliESD(*source.fESDOld);
226 fESDFriendOld = new AliESDfriend(*source.fESDFriendOld);
228 // or AddObject( fESDZDC = new AliESDZDC(*source.fESDZDC));
230 fESDObjects = new TList();
235 AddObject(fESDVZERO);
236 AddObject(fESDTZERO);
237 AddObject(fTPCVertex);
238 AddObject(fSPDVertex);
239 AddObject(fPrimaryVertex);
241 AddObject(fPHOSTrigger);
242 AddObject(fEMCALTrigger);
244 AddObject(fMuonTracks);
245 AddObject(fPmdTracks);
246 AddObject(fTrdTracks);
248 AddObject(fCascades);
250 AddObject(fCaloClusters);
251 AddObject(fEMCALCells);
252 AddObject(fPHOSCells);
253 AddObject(fErrorLogs);
255 fConnected = source.fConnected;
256 fEMCALClusters = source.fEMCALClusters;
257 fFirstEMCALCluster = source.fFirstEMCALCluster;
258 fPHOSClusters = source.fPHOSClusters;
259 fFirstPHOSCluster = source.fFirstPHOSCluster;
268 //______________________________________________________________________________
269 AliESDEvent::~AliESDEvent()
272 // Standard destructor
275 // everthing on the list gets deleted automatically
278 if(fESDObjects&&!fConnected)
287 //______________________________________________________________________________
288 void AliESDEvent::Reset()
292 // Reset the standard contents
294 if(fESDOld)fESDOld->Reset();
295 // reset for the friends...
297 fESDFriendOld->~AliESDfriend();
298 new (fESDFriendOld) AliESDfriend();
300 // for new data we have to fetch the Pointer from the list
301 AliESDfriend *fr = (AliESDfriend*)FindListObject("AliESDfriend");
303 // delete the content
305 // make a new valid ESDfriend at the same place
306 new (fr) AliESDfriend();
309 // call reset for user supplied data?
312 void AliESDEvent::ResetStdContent()
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
320 // reset by callin d'to /c'tor keep the pointer
321 fESDVZERO->~AliESDVZERO();
322 new (fESDVZERO) AliESDVZERO();
324 if(fESDTZERO) fESDTZERO->Reset();
325 // CKB no clear/reset implemented
327 fTPCVertex->~AliESDVertex();
328 new (fTPCVertex) AliESDVertex();
329 fTPCVertex->SetName(fgkESDListName[kTPCVertex]);
332 fSPDVertex->~AliESDVertex();
333 new (fSPDVertex) AliESDVertex();
334 fSPDVertex->SetName(fgkESDListName[kSPDVertex]);
337 fPrimaryVertex->~AliESDVertex();
338 new (fPrimaryVertex) AliESDVertex();
339 fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]);
342 fSPDMult->~AliMultiplicity();
343 new (fSPDMult) AliMultiplicity();
345 if(fPHOSTrigger)fPHOSTrigger->Reset();
346 if(fEMCALTrigger)fEMCALTrigger->Reset();
347 if(fTracks)fTracks->Delete();
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();
354 if(fCaloClusters)fCaloClusters->Delete();
355 if(fPHOSCells)fPHOSCells->DeleteContainer();
356 if(fEMCALCells)fEMCALCells->DeleteContainer();
357 if(fErrorLogs) fErrorLogs->Delete();
359 // don't reset fconnected fConnected and the list
362 fFirstEMCALCluster=-1;
364 fFirstPHOSCluster=-1;
368 Int_t AliESDEvent::AddV0(const AliESDv0 *v) {
372 TClonesArray &fv = *fV0s;
373 Int_t idx=fV0s->GetEntriesFast();
374 new(fv[idx]) AliESDv0(*v);
378 //______________________________________________________________________________
379 void AliESDEvent::Print(Option_t *) const
382 // Print header information of the event
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(),
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());
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");
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"));
422 void AliESDEvent::SetESDfriend(const AliESDfriend *ev) {
424 // Attaches the complementary info to the ESD
428 // to be sure that we set the tracks also
429 // in case of old esds
430 // if(fESDOld)CopyFromOldESD();
432 Int_t ntrk=ev->GetNumberOfTracks();
434 for (Int_t i=0; i<ntrk; i++) {
435 const AliESDfriendTrack *f=ev->GetTrack(i);
436 GetTrack(i)->SetFriendTrack(f);
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;
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;
460 AliESDv0 *v0=GetV0(rm);
461 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
464 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
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);
473 Int_t csIdxP=cs->GetPindex();
474 Int_t csIdxN=cs->GetNindex();
477 if (idxN==csIdxN) return kFALSE;
479 if (csIdxP==lastIdxP)
480 if (csIdxN==lastIdxN) used++;
483 //Replace the removed V0 with the last V0
484 TClonesArray &a=*fV0s;
485 delete a.RemoveAt(rm);
487 if (rm==last) return kTRUE;
489 //v0 is pointing to the last V0 candidate...
490 new (a[rm]) AliESDv0(*v0);
491 delete a.RemoveAt(last);
493 if (!used) return kTRUE;
496 // Remap the indices of the daughters of reconstructed decays
497 for (Int_t n=0; n<ncs; n++) {
498 AliESDcascade *cs=GetCascade(n);
501 Int_t csIdxP=cs->GetPindex();
502 Int_t csIdxN=cs->GetNindex();
504 if (csIdxP==lastIdxP)
505 if (csIdxN==lastIdxN) {
506 cs->AliESDv0::SetIndex(1,idxP);
507 cs->AliESDv0::SetIndex(0,idxN);
509 if (!used) return kTRUE;
516 Bool_t AliESDEvent::RemoveTrack(Int_t rm) {
517 // ---------------------------------------------------------
518 // Remove a track and references to it from ESD,
519 // if this track does not come from a reconstructed decay
520 // ---------------------------------------------------------
521 Int_t last=GetNumberOfTracks()-1;
522 if ((rm<0)||(rm>last)) return kFALSE;
526 // Check if this track comes from a reconstructed decay
527 Int_t nv0=GetNumberOfV0s();
528 for (Int_t n=0; n<nv0; n++) {
529 AliESDv0 *v0=GetV0(n);
531 Int_t idx=v0->GetNindex();
532 if (rm==idx) return kFALSE;
533 if (idx==last) used++;
536 if (rm==idx) return kFALSE;
537 if (idx==last) used++;
540 Int_t ncs=GetNumberOfCascades();
541 for (Int_t n=0; n<ncs; n++) {
542 AliESDcascade *cs=GetCascade(n);
544 Int_t idx=cs->GetIndex();
545 if (rm==idx) return kFALSE;
546 if (idx==last) used++;
549 Int_t nkn=GetNumberOfKinks();
550 for (Int_t n=0; n<nkn; n++) {
551 AliESDkink *kn=GetKink(n);
553 Int_t idx=kn->GetIndex(0);
554 if (rm==idx) return kFALSE;
555 if (idx==last) used++;
558 if (rm==idx) return kFALSE;
559 if (idx==last) used++;
563 //Replace the removed track with the last track
564 TClonesArray &a=*fTracks;
565 delete a.RemoveAt(rm);
567 if (rm==last) return kTRUE;
569 AliESDtrack *t=GetTrack(last);
571 new (a[rm]) AliESDtrack(*t);
572 delete a.RemoveAt(last);
574 if (!used) return kTRUE;
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) {
583 if (!used) return kTRUE;
585 if (v0->GetIndex(1)==last) {
588 if (!used) return kTRUE;
592 for (Int_t n=0; n<ncs; n++) {
593 AliESDcascade *cs=GetCascade(n);
594 if (cs->GetIndex()==last) {
597 if (!used) return kTRUE;
601 for (Int_t n=0; n<nkn; n++) {
602 AliESDkink *kn=GetKink(n);
603 if (kn->GetIndex(0)==last) {
606 if (!used) return kTRUE;
608 if (kn->GetIndex(1)==last) {
611 if (!used) return kTRUE;
619 Bool_t AliESDEvent::Clean(Float_t *cleanPars) {
621 // Remove the data which are not needed for the physics analysis.
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
629 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
631 // an attempt to remove this V0 candidate from ESD is made.
633 // The V0 candidate gets removed if it does not belong to any
634 // recosntructed cascade decay
636 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
638 // 2) Cleaning the tracks
639 // ----------------------
640 // If track's transverse parameter is larger than cleanPars[2]
642 // track's longitudinal parameter is larger than cleanPars[3]
643 // an attempt to remove this track from ESD is made.
645 // The track gets removed if it does not come
646 // from a reconstructed decay
650 Float_t dcaMax=cleanPars[0];
651 Float_t cspMin=cleanPars[1];
653 Int_t nV0s=GetNumberOfV0s();
654 for (Int_t i=nV0s-1; i>=0; i--) {
655 AliESDv0 *v0=GetV0(i);
657 Float_t dca=v0->GetDcaV0Daughters();
658 Float_t csp=v0->GetV0CosineOfPointingAngle();
659 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
661 if (RemoveV0(i)) rc=kTRUE;
666 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
668 const AliESDVertex *vertex=GetPrimaryVertexSPD();
669 Bool_t vtxOK=vertex->GetStatus();
671 Int_t nTracks=GetNumberOfTracks();
672 for (Int_t i=nTracks-1; i>=0; i--) {
673 AliESDtrack *track=GetTrack(i);
674 Float_t xy,z; track->GetImpactParameters(xy,z);
675 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
676 if (RemoveTrack(i)) rc=kTRUE;
683 Int_t AliESDEvent::AddTrack(const AliESDtrack *t)
686 TClonesArray &ftr = *fTracks;
687 AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t);
688 track->SetID(fTracks->GetEntriesFast()-1);
689 return track->GetID();
692 void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t)
694 TClonesArray &fmu = *fMuonTracks;
695 new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t);
698 void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t)
700 TClonesArray &fpmd = *fPmdTracks;
701 new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t);
704 void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t)
706 TClonesArray &ftrd = *fTrdTracks;
707 new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t);
713 Int_t AliESDEvent::AddKink(const AliESDkink *c)
716 TClonesArray &fk = *fKinks;
717 AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c);
718 kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps..
719 return fKinks->GetEntriesFast()-1;
723 void AliESDEvent::AddCascade(const AliESDcascade *c)
725 TClonesArray &fc = *fCascades;
726 new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c);
730 Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c)
733 TClonesArray &fc = *fCaloClusters;
734 AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c);
735 clus->SetID(fCaloClusters->GetEntriesFast()-1);
736 return fCaloClusters->GetEntriesFast()-1;
740 void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) {
741 TClonesArray &errlogs = *fErrorLogs;
742 new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log);
745 void AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex)
747 // Set the TPC vertex
748 // use already allocated space
750 *fTPCVertex = *vertex;
751 fTPCVertex->SetName(fgkESDListName[kTPCVertex]);
755 void AliESDEvent::SetPrimaryVertexSPD(const AliESDVertex *vertex)
757 // Set the SPD vertex
758 // use already allocated space
760 *fSPDVertex = *vertex;
761 fSPDVertex->SetName(fgkESDListName[kSPDVertex]);
765 void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex)
767 // Set the primary vertex
768 // use already allocated space
770 *fPrimaryVertex = *vertex;
771 fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]);
775 void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul)
777 // Set the SPD Multiplicity
784 void AliESDEvent::SetFMDData(AliESDFMD * obj)
786 // use already allocated space
792 void AliESDEvent::SetVZEROData(AliESDVZERO * obj)
794 // use already allocated space
799 void AliESDEvent::GetESDfriend(AliESDfriend *ev) const
802 // Extracts the complementary info from the ESD
806 Int_t ntrk=GetNumberOfTracks();
808 for (Int_t i=0; i<ntrk; i++) {
809 AliESDtrack *t=GetTrack(i);
810 const AliESDfriendTrack *f=t->GetFriendTrack();
813 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
819 void AliESDEvent::AddObject(TObject* obj)
821 // Add an object to the list of object.
822 // Please be aware that in order to increase performance you should
823 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
824 fESDObjects->SetOwner(kTRUE);
825 fESDObjects->AddLast(obj);
829 void AliESDEvent::GetStdContent()
831 // set pointers for standard content
832 // get by name much safer and not a big overhead since not called very often
834 fESDRun = (AliESDRun*)fESDObjects->FindObject(fgkESDListName[kESDRun]);
835 fHeader = (AliESDHeader*)fESDObjects->FindObject(fgkESDListName[kHeader]);
836 fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fgkESDListName[kESDZDC]);
837 fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fgkESDListName[kESDFMD]);
838 fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fgkESDListName[kESDVZERO]);
839 fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fgkESDListName[kESDTZERO]);
840 fTPCVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kTPCVertex]);
841 fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kSPDVertex]);
842 fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kPrimaryVertex]);
843 fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fgkESDListName[kSPDMult]);
844 fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kPHOSTrigger]);
845 fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kEMCALTrigger]);
846 fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]);
847 fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]);
848 fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]);
849 fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]);
850 fV0s = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kV0s]);
851 fCascades = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCascades]);
852 fKinks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kKinks]);
853 fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCaloClusters]);
854 fEMCALCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kEMCALCells]);
855 fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]);
856 fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]);
860 void AliESDEvent::SetStdNames(){
861 // Set the names of the standard contents
863 if(fESDObjects->GetEntries()==kESDListN){
864 for(int i = 0;i < fESDObjects->GetEntries();i++){
865 TObject *fObj = fESDObjects->At(i);
866 if(fObj->InheritsFrom("TNamed")){
867 ((TNamed*)fObj)->SetName(fgkESDListName[i]);
869 else if(fObj->InheritsFrom("TClonesArray")){
870 ((TClonesArray*)fObj)->SetName(fgkESDListName[i]);
875 printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
879 void AliESDEvent::CreateStdContent()
881 // create the standard AOD content and set pointers
883 // create standard objects and add them to the TList of objects
884 AddObject(new AliESDRun());
885 AddObject(new AliESDHeader());
886 AddObject(new AliESDZDC());
887 AddObject(new AliESDFMD());
888 AddObject(new AliESDVZERO());
889 AddObject(new AliESDTZERO());
890 AddObject(new AliESDVertex());
891 AddObject(new AliESDVertex());
892 AddObject(new AliESDVertex());
893 AddObject(new AliMultiplicity());
894 AddObject(new AliESDCaloTrigger());
895 AddObject(new AliESDCaloTrigger());
896 AddObject(new TClonesArray("AliESDtrack",0));
897 AddObject(new TClonesArray("AliESDMuonTrack",0));
898 AddObject(new TClonesArray("AliESDPmdTrack",0));
899 AddObject(new TClonesArray("AliESDTrdTrack",0));
900 AddObject(new TClonesArray("AliESDv0",0));
901 AddObject(new TClonesArray("AliESDcascade",0));
902 AddObject(new TClonesArray("AliESDkink",0));
903 AddObject(new TClonesArray("AliESDCaloCluster",0));
904 AddObject(new AliESDCaloCells());
905 AddObject(new AliESDCaloCells());
906 AddObject(new TClonesArray("AliRawDataErrorLog",0));
908 // check the order of the indices against enum...
912 // read back pointers
916 TObject* AliESDEvent::FindListObject(const char *name){
918 return fESDObjects->FindObject(name);
923 Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
925 // fills the provided TRefArray with all found phos clusters
929 AliESDCaloCluster *cl = 0;
930 for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
932 if ( (cl = GetCaloCluster(i)) ) {
935 AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
939 return clusters->GetEntriesFast();
942 Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
944 // fills the provided TRefArray with all found emcal clusters
948 AliESDCaloCluster *cl = 0;
949 for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
951 if ( (cl = GetCaloCluster(i)) ) {
954 AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
958 return clusters->GetEntriesFast();
961 const void AliESDEvent::WriteToTree(TTree* tree) const {
962 // Book the branches as in TTree::Branch(TCollection*)
963 // but add a "." at the end of top level branches which are
964 // not a TClonesArray
968 TIter next(fESDObjects);
969 const Int_t splitlevel = 99; // default value in TTree::Branch()
970 const Int_t bufsize = 32000; // default value in TTree::Branch()
973 while ((obj = next())) {
974 branchname.Form("%s", obj->GetName());
975 if ((splitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) {
978 tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),
979 bufsize, splitlevel - 1);
985 void AliESDEvent::ReadFromTree(TTree *tree){
988 Printf("%s %d AliESDEvent::ReadFromTree() Zero Pointer to Tree \n",(char*)__FILE__,__LINE__);
992 if(!tree->GetTree())tree->LoadTree(0);
994 // if we find the "ESD" branch on the tree we do have the old structure
995 if(tree->GetBranch("ESD")) {
996 char ** address = (char **)(tree->GetBranch("ESD")->GetAddress());
997 // do we have the friend branch
998 TBranch * esdFB = tree->GetBranch("ESDfriend.");
999 char ** addressF = 0;
1000 if(esdFB)addressF = (char **)(esdFB->GetAddress());
1002 printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__);
1003 tree->SetBranchAddress("ESD", &fESDOld);
1005 tree->SetBranchAddress("ESDfriend.",&fESDFriendOld);
1008 printf("%s %d AliESDEvent::ReadFromTree() Reading old Tree \n",(char*)__FILE__,__LINE__);
1009 printf("%s %d Branch already connected. Using existing branch address. \n",(char*)__FILE__,__LINE__);
1010 fESDOld = (AliESD*) (*address);
1011 // addressF can still be 0, since branch needs to switched on
1012 if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF);
1015 // have already connected the old ESD structure... ?
1016 // reuse also the pointer of the AlliESDEvent
1017 // otherwise create new ones
1018 TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
1021 // If connected use the connected list of objects
1022 if(fESDObjects!= connectedList){
1023 // protect when called twice
1024 fESDObjects->Delete();
1025 fESDObjects = connectedList;
1030 // The pointer to the friend changes when called twice via InitIO
1031 // since AliESDEvent is deleted
1032 TObject* oldf = FindListObject("AliESDfriend");
1035 newf = (TObject*)*addressF;
1037 if(newf!=0&&oldf!=newf){
1038 // remove the old reference
1039 // Should we also delete it? Or is this handled in TTree I/O
1040 // since it is created by the first SetBranchAddress
1041 fESDObjects->Remove(oldf);
1043 fESDObjects->Add(newf);
1050 CreateStdContent(); // create for copy
1051 // if we have the esdfriend add it, so we always can access it via the userinfo
1052 if(fESDFriendOld)AddObject(fESDFriendOld);
1053 // we are not owner of the list objects
1054 // must not delete it
1055 fESDObjects->SetOwner(kFALSE);
1056 fESDObjects->SetName("ESDObjectsConnectedToTree");
1057 tree->GetUserInfo()->Add(fESDObjects);
1064 // Try to find AliESDEvent
1065 AliESDEvent *esdEvent = 0;
1066 esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent");
1068 // Check if already connected to tree
1069 TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
1070 if (connectedList) {
1071 // If connected use the connected list if objects
1072 fESDObjects->Delete();
1073 fESDObjects = connectedList;
1079 // prevent a memory leak when reading back the TList
1082 // create a new TList from the UserInfo TList...
1083 // copy constructor does not work...
1084 fESDObjects = (TList*)(esdEvent->GetList()->Clone());
1085 fESDObjects->SetOwner(kFALSE);
1086 if(fESDObjects->GetEntries()<kESDListN){
1087 printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
1088 (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN);
1090 // set the branch addresses
1091 TIter next(fESDObjects);
1093 while((el=(TNamed*)next())){
1094 TString bname(el->GetName());
1095 if(bname.CompareTo("AliESDfriend")==0)
1097 // AliESDfriend does not have a name ...
1098 tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el));
1101 // check if branch exists under this Name
1102 TBranch *br = tree->GetBranch(bname.Data());
1104 tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
1107 br = tree->GetBranch(Form("%s.",bname.Data()));
1109 tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el));
1112 printf("%s %d AliESDEvent::ReadFromTree() No Branch found with Name %s or %s. \n",
1113 (char*)__FILE__,__LINE__,bname.Data(),bname.Data());
1120 // when reading back we are not owner of the list
1121 // must not delete it
1122 fESDObjects->SetOwner(kFALSE);
1123 fESDObjects->SetName("ESDObjectsConnectedToTree");
1124 // we are not owner of the list objects
1125 // must not delete it
1126 tree->GetUserInfo()->Add(fESDObjects);
1130 // we can't get the list from the user data, create standard content
1131 // and set it by hand (no ESDfriend at the moment
1133 TIter next(fESDObjects);
1135 while((el=(TNamed*)next())){
1136 TString bname(el->GetName());
1137 tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
1140 // when reading back we are not owner of the list
1141 // must not delete it
1142 fESDObjects->SetOwner(kFALSE);
1147 void AliESDEvent::CopyFromOldESD()
1149 // Method which copies over everthing from the old esd structure to the
1154 SetRunNumber(fESDOld->GetRunNumber());
1155 SetPeriodNumber(fESDOld->GetPeriodNumber());
1156 SetMagneticField(fESDOld->GetMagneticField());
1158 // leave out diamond ...
1159 // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);}
1162 SetTriggerMask(fESDOld->GetTriggerMask());
1163 SetOrbitNumber(fESDOld->GetOrbitNumber());
1164 SetTimeStamp(fESDOld->GetTimeStamp());
1165 SetEventType(fESDOld->GetEventType());
1166 SetEventNumberInFile(fESDOld->GetEventNumberInFile());
1167 SetBunchCrossNumber(fESDOld->GetBunchCrossNumber());
1168 SetTriggerCluster(fESDOld->GetTriggerCluster());
1172 SetZDC(fESDOld->GetZDCN1Energy(),
1173 fESDOld->GetZDCP1Energy(),
1174 fESDOld->GetZDCEMEnergy(),
1176 fESDOld->GetZDCN2Energy(),
1177 fESDOld->GetZDCP2Energy(),
1178 fESDOld->GetZDCParticipants());
1182 if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData());
1186 SetT0zVertex(fESDOld->GetT0zVertex());
1187 SetT0(fESDOld->GetT0());
1191 if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData());
1193 if(fESDOld->GetVertex())SetPrimaryVertexSPD(fESDOld->GetVertex());
1195 if(fESDOld->GetPrimaryVertex())SetPrimaryVertex(fESDOld->GetPrimaryVertex());
1197 if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity());
1199 for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){
1200 AddTrack(fESDOld->GetTrack(i));
1203 for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){
1204 AddMuonTrack(fESDOld->GetMuonTrack(i));
1207 for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){
1208 AddPmdTrack(fESDOld->GetPmdTrack(i));
1211 for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){
1212 AddTrdTrack(fESDOld->GetTrdTrack(i));
1215 for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){
1216 AddV0(fESDOld->GetV0(i));
1219 for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){
1220 AddCascade(fESDOld->GetCascade(i));
1223 for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){
1224 AddKink(fESDOld->GetKink(i));
1228 for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){
1229 AddCaloCluster(fESDOld->GetCaloCluster(i));