]>
Commit | Line | Data |
---|---|---|
6bc5f287 | 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> | |
500d54ab | 9 | #include <TChain.h> |
6bc5f287 | 10 | |
bd23a74c | 11 | #include "AliESDEvent.h" |
6bc5f287 | 12 | #include "AliESDfriend.h" |
500d54ab | 13 | #include "AliTrackPointArray.h" |
6bc5f287 | 14 | #endif |
15 | ||
16 | void ReadESDfriend(Bool_t readFriend=kTRUE) { | |
500d54ab | 17 | Char_t *name[]={ |
18 | //Put here the names of the ESD files to be chained | |
19 | "AliESDs.root" | |
20 | }; | |
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]); | |
24 | ||
bd23a74c | 25 | AliESDEvent *ev= new AliESDEvent(); |
1ada4d26 | 26 | if(readFriend)esdTree->SetBranchStatus("ESDfriend*",1); |
bd23a74c | 27 | ev->ReadFromTree(esdTree); |
6bc5f287 | 28 | |
500d54ab | 29 | // Attach the branch with ESD friends |
6bc5f287 | 30 | AliESDfriend *evf=0; |
31 | if (readFriend) { | |
1ada4d26 | 32 | evf = (AliESDfriend*)ev->FindListObject("AliESDfriend"); |
33 | if(!evf){ | |
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); | |
37 | } | |
6bc5f287 | 38 | } |
39 | ||
40 | Int_t nev=esdTree->GetEntries(); | |
41 | for (Int_t i=0; i<nev; i++) { | |
6bc5f287 | 42 | esdTree->GetEntry(i); |
1ada4d26 | 43 | if(ev->GetAliESDOld())ev->CopyFromOldESD(); |
bd23a74c | 44 | |
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. | |
50 | if (ntr > 0) { | |
51 | ev->SetESDfriend(evf); //Attach the friend to the ESD | |
1ada4d26 | 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"; | |
8af90484 | 61 | for (Int_t k=0; k<6; k++) printf(" Bit %d: %d\n",k,(map&(1<<k))==(1<<k)) <<' '; |
1ada4d26 | 62 | |
63 | // Example: track points associated with the track number 0. | |
64 | const AliTrackPointArray *pa=t->GetTrackPointArray(); | |
65 | if (pa != 0) { | |
66 | n=pa->GetNPoints(); | |
67 | const Float_t *x=pa->GetX(); | |
68 | cout<<" Number of track points: "<<n<<endl; | |
69 | if (n>7) | |
9fd6b54e | 70 | cout<<" X coordinate of the 7th track point: "<<x[7]<<endl; |
1ada4d26 | 71 | } |
72 | ||
9fd6b54e | 73 | } |
bd23a74c | 74 | |
6bc5f287 | 75 | } |
bd23a74c | 76 | delete ev; |
6bc5f287 | 77 | delete esdTree; |
78 | } |