Read AOD according to new functionality (Markus)
[u/mrichter/AliRoot.git] / STEER / ReadAOD.C
CommitLineData
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 15void ReadAOD(const char *fileName = "AliAOD.root") {
16
17 // open input file and get the TTree
18 TFile inFile(fileName, "READ");
e2a21448 19
2c3dd3b0 20 TTree *aodTree = (TTree*)inFile.Get("aodTree");
21 AliAODEvent *ev = new AliAODEvent();
22 ev->ReadFromTree(aodTree);
e2a21448 23
24 // loop over events
25 Int_t nEvents = aodTree->GetEntries();
26 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
27 cout << "Event: " << nEv+1 << "/" << nEvents << endl;
28
29 // read events
30 aodTree->GetEvent(nEv);
31
e2a21448 32 //print event info
2c3dd3b0 33 ev->GetHeader()->Print();
e2a21448 34
35 // loop over tracks
2c3dd3b0 36 Int_t nTracks = ev->GetNTracks();
e2a21448 37 for (Int_t nTr = 0; nTr < nTracks; nTr++) {
38
2c3dd3b0 39 AliAODTrack *tr = ev->GetTrack(nTr);
31fd97b2 40
e2a21448 41 // print track info
31fd97b2 42 cout << nTr+1 << "/" << nTracks << ": track pt: " << tr->Pt();
43 if (tr->GetProdVertex()) {
44 cout << ", vertex z of this track: " << tr->GetProdVertex()->GetZ();
45 }
46 cout << endl;
e2a21448 47 }
48
49 // loop over vertices
2c3dd3b0 50 Int_t nVtxs = ev->GetNVertices();
e2a21448 51 for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
52
53 // print track info
2c3dd3b0 54 cout << nVtx+1 << "/" << nVtxs << ": vertex z position: " << ev->GetVertex(nVtx)->GetZ() << endl;
e2a21448 55 }
56 }
57
58 return;
59}