1 //********************************************************************
2 // Example of accessing the information stored in ESD friends
3 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
4 //********************************************************************
6 #if !defined( __CINT__) || defined(__MAKECINT__)
11 #include "AliESDEvent.h"
12 #include "AliESDfriend.h"
13 #include "AliTrackPointArray.h"
16 void ReadESDfriend(Bool_t readFriend=kTRUE) {
18 //Put here the names of the ESD files to be chained
21 Int_t n=sizeof(name)/sizeof(Char_t *);
22 TChain *esdTree=new TChain("esdTree");
23 for (Int_t i=0; i<n; i++) esdTree->AddFile(name[i]);
25 AliESDEvent *ev= new AliESDEvent();
26 if(readFriend)esdTree->SetBranchStatus("ESDfriend*",1);
27 ev->ReadFromTree(esdTree);
29 // Attach the branch with ESD friends
32 evf = (AliESDfriend*)ev->FindListObject("AliESDfriend");
34 // works for both, we just want to avoid setting the branch adress twice
35 // in case of the new ESD
36 esdTree->SetBranchAddress("ESDfriend.",&evf);
40 Int_t nev=esdTree->GetEntries();
41 for (Int_t i=0; i<nev; i++) {
43 if(ev->GetAliESDOld())ev->CopyFromOldESD();
45 cout<<endl<<"Event number: "<<i<<endl;
46 Int_t ntr=ev->GetNumberOfTracks();
47 cout<<"Number of tracks: "<<ntr<<endl;
48 // Now the attached information can be accessed via pointer to ESD.
49 // Example: indices of the TPC clusters associated with the track number 0.
51 ev->SetESDfriend(evf); //Attach the friend to the ESD
52 const AliESDtrack *t=ev->GetTrack(0);
53 Int_t idx[AliESDfriendTrack::kMaxTPCcluster];
54 n=t->GetTPCclusters(idx);
55 cout<<"Number of friend tracks: "<<evf->GetNumberOfTracks() <<endl;
56 cout<<"Track number 0"<<endl;
57 cout<<" Number of TPC clusters: "<<n<<endl;
58 cout<<" Index of the 1st TPC cluster: " <<idx[1]<<endl;
59 UChar_t map=t->GetITSClusterMap();
60 cout<<" ITS cluster map (from SPDs to SSDs):\n";
61 for (Int_t k=0; k<6; k++) printf(" Bit %d: %d\n",k,(map&(1<<k))==(1<<k)) <<' ';
63 // Example: track points associated with the track number 0.
64 const AliTrackPointArray *pa=t->GetTrackPointArray();
67 const Float_t *x=pa->GetX();
68 cout<<" Number of track points: "<<n<<endl;
70 cout<<" X coordinate of the 7th track point: "<<x[7]<<endl;