]>
Commit | Line | Data |
---|---|---|
31fd97b2 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | ||
3 | #include <Riostream.h> | |
4 | #include "TFile.h" | |
5 | #include "TTree.h" | |
6 | ||
7 | #include "AliAODEvent.h" | |
8 | #include "AliAODHeader.h" | |
9 | #include "AliAODVertex.h" | |
10 | #include "AliAODTrack.h" | |
11 | #include "AliAODCluster.h" | |
12 | ||
13 | #endif | |
14 | ||
e2a21448 | 15 | void ReadAOD(const char *fileName = "AliAOD.root") { |
16 | ||
17 | // open input file and get the TTree | |
18 | TFile inFile(fileName, "READ"); | |
19 | TTree *aodTree = (TTree*)inFile.Get("AOD"); | |
20 | ||
31fd97b2 | 21 | AliAODEvent *aod = (AliAODEvent*)aodTree->GetUserInfo()->FindObject("AliAODEvent"); |
e2a21448 | 22 | TIter next(aod->GetList()); |
41390678 | 23 | TObject *el; |
31fd97b2 | 24 | while((el=(TNamed*)next())) |
e2a21448 | 25 | aodTree->SetBranchAddress(el->GetName(),aod->GetList()->GetObjectRef(el)); |
26 | ||
27 | // loop over events | |
28 | Int_t nEvents = aodTree->GetEntries(); | |
29 | for (Int_t nEv = 0; nEv < nEvents; nEv++) { | |
30 | cout << "Event: " << nEv+1 << "/" << nEvents << endl; | |
31 | ||
32 | // read events | |
33 | aodTree->GetEvent(nEv); | |
34 | ||
35 | // set pointers | |
36 | aod->GetStdContent(); | |
37 | ||
38 | //print event info | |
39 | aod->GetHeader()->Print(); | |
40 | ||
41 | // loop over tracks | |
42 | Int_t nTracks = aod->GetNTracks(); | |
43 | for (Int_t nTr = 0; nTr < nTracks; nTr++) { | |
44 | ||
31fd97b2 | 45 | AliAODTrack *tr = aod->GetTrack(nTr); |
46 | ||
e2a21448 | 47 | // print track info |
31fd97b2 | 48 | cout << nTr+1 << "/" << nTracks << ": track pt: " << tr->Pt(); |
49 | if (tr->GetProdVertex()) { | |
50 | cout << ", vertex z of this track: " << tr->GetProdVertex()->GetZ(); | |
51 | } | |
52 | cout << endl; | |
e2a21448 | 53 | } |
54 | ||
55 | // loop over vertices | |
56 | Int_t nVtxs = aod->GetNVertices(); | |
57 | for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) { | |
58 | ||
59 | // print track info | |
60 | cout << nVtx+1 << "/" << nVtxs << ": vertex z position: " << aod->GetVertex(nVtx)->GetZ() << endl; | |
61 | } | |
62 | } | |
63 | ||
64 | return; | |
65 | } |