]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/ReadESDfriend.C
Corrected call to the static method AliBitPacking::UnpackWord
[u/mrichter/AliRoot.git] / STEER / ReadESDfriend.C
1 //********************************************************************
2 //  Example of accessing the information stored in ESD friends
3 //      Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
4 //********************************************************************
5
6 #if !defined( __CINT__) || defined(__MAKECINT__)
7   #include <Riostream.h>
8   #include <TFile.h>
9   #include <TTree.h>
10
11   #include "AliESD.h"
12   #include "AliESDfriend.h"
13 #endif
14
15 void ReadESDfriend(Bool_t readFriend=kTRUE) {
16    TFile f("AliESDs.root");
17    TTree *esdTree=(TTree*)f.Get("esdTree");
18    AliESD *ev=0;
19    esdTree->SetBranchAddress("ESD",&ev);
20
21    // Attach the tree with ESD friends
22    AliESDfriend *evf=0;
23    if (readFriend) {
24       esdTree->AddFriend("esdFriendTree","AliESDfriends.root");
25       esdTree->SetBranchAddress("ESDfriend",&evf);
26    }
27
28    Int_t nev=esdTree->GetEntries();
29    for (Int_t i=0; i<nev; i++) {
30        cout<<"Event number: "<<i<<endl;
31        esdTree->GetEntry(i);
32         
33        ev->SetESDfriend(evf); //Attach the friend to the ESD
34
35     // Now the attached information can be accessed via pointer to ESD.
36     // Example: indices of the TPC clusters associated with the track number 0.
37        const AliESDtrack *t=ev->GetTrack(0);
38        Int_t idx[AliESDfriendTrack::kMaxTPCcluster], n=t->GetTPCclusters(idx);
39        cout<<"Number of TPC clusters: "<<n<<endl;
40        cout<<"Index of the 7th TPC cluster: "<<idx[7]<<endl<<endl; 
41    }
42
43    delete esdTree;
44 }