suggestion by Chiara to add TestPreprocessor macro to svn
[u/mrichter/AliRoot.git] / EMCAL / macros / TestAOD.C
CommitLineData
1610de71 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
3//Root include files
4#include <Riostream.h>
5#include <TFile.h>
6#include <TChain.h>
7#include <TParticle.h>
8#include <TNtuple.h>
9#include <TCanvas.h>
10#include <TObjArray.h>
11#include <TSystem.h>
12#include <TString.h>
13#include <TH1F.h>
14#include <TVector.h>
15#include <TParticle.h>
16#include <TRefArray.h>
17#include <TArrayS.h>
18
19//AliRoot include files
20#include "AliRunLoader.h"
21#include "AliStack.h"
22#include "AliAODEvent.h"
23#include "AliAODVertex.h"
24#include "AliAODCaloCluster.h"
25#include "AliAODCaloCells.h"
26#include "AliPID.h"
27#include "AliLog.h"
28
29#endif
30
31void TestAOD() {
32
33 TFile* f = new TFile("aod.root");
34 TTree* aodTree = (TTree*)f->Get("aodTree");
35
36 AliAODEvent* aod = new AliAODEvent();
37 aod->ReadFromTree(aodTree);
38
39 Int_t nEvt = aodTree->GetEntries();
40
41 for(Int_t iev = 0; iev < nEvt; iev++) {
42 cout << "Event: " << iev+1 << "/" << nEvt << endl;
43 aodTree->GetEvent(iev);
44
45 TRefArray* caloClusters = new TRefArray();
46 aod->GetEMCALClusters(caloClusters);
47
48 //get reconstructed vertex position
49 Double_t vertex_position[3] = { aod->GetPrimaryVertex()->GetX(),
50 aod->GetPrimaryVertex()->GetY(),
51 aod->GetPrimaryVertex()->GetZ()};
52
53 Int_t nclus = caloClusters->GetEntries();
54 for (Int_t icl = 0; icl < nclus; icl++) {
55
56 AliAODCaloCluster* clus = (AliAODCaloCluster*)caloClusters->At(icl);
57 Float_t energy = clus->E();
58 TLorentzVector p;
59 clus->GetMomentum(p,vertex_position);
60 Int_t nMatched = clus->GetNTracksMatched();
61
62 cout << "Cluster: " << icl+1 << "/" << nclus << " Energy: " << energy << " Phi: " << p.Phi() << " Eta: " << p.Eta() << " #Matches: " << nMatched << endl;
63
64
65
66 }
67
68
69 }
70
71
72
73}