]>
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"); | |
5a76a0b3 | 19 | if (!inFile.IsOpen()) return; |
e2a21448 | 20 | |
2c3dd3b0 | 21 | TTree *aodTree = (TTree*)inFile.Get("aodTree"); |
5a76a0b3 | 22 | |
2c3dd3b0 | 23 | AliAODEvent *ev = new AliAODEvent(); |
24 | ev->ReadFromTree(aodTree); | |
e2a21448 | 25 | |
26 | // loop over events | |
27 | Int_t nEvents = aodTree->GetEntries(); | |
28 | for (Int_t nEv = 0; nEv < nEvents; nEv++) { | |
29 | cout << "Event: " << nEv+1 << "/" << nEvents << endl; | |
30 | ||
31 | // read events | |
32 | aodTree->GetEvent(nEv); | |
5a76a0b3 | 33 | |
e2a21448 | 34 | //print event info |
2c3dd3b0 | 35 | ev->GetHeader()->Print(); |
e2a21448 | 36 | |
37 | // loop over tracks | |
2c3dd3b0 | 38 | Int_t nTracks = ev->GetNTracks(); |
e2a21448 | 39 | for (Int_t nTr = 0; nTr < nTracks; nTr++) { |
40 | ||
2c3dd3b0 | 41 | AliAODTrack *tr = ev->GetTrack(nTr); |
31fd97b2 | 42 | |
e2a21448 | 43 | // print track info |
31fd97b2 | 44 | cout << nTr+1 << "/" << nTracks << ": track pt: " << tr->Pt(); |
45 | if (tr->GetProdVertex()) { | |
46 | cout << ", vertex z of this track: " << tr->GetProdVertex()->GetZ(); | |
47 | } | |
48 | cout << endl; | |
e2a21448 | 49 | } |
50 | ||
51 | // loop over vertices | |
2c3dd3b0 | 52 | Int_t nVtxs = ev->GetNVertices(); |
e2a21448 | 53 | for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) { |
54 | ||
55 | // print track info | |
2c3dd3b0 | 56 | cout << nVtx+1 << "/" << nVtxs << ": vertex z position: " << ev->GetVertex(nVtx)->GetZ() << endl; |
e2a21448 | 57 | } |
58 | } | |
59 | ||
60 | return; | |
61 | } |