]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/macros/TestAOD.C
Merge branch 'master' into TPCdev
[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
77e93dc2 31Bool_t kPrintCaloCells = kTRUE;
32Bool_t kPrintCaloClusters = kTRUE;
33
34
1610de71 35void TestAOD() {
36
77e93dc2 37 TFile* f = new TFile("AliAOD.root");
1610de71 38 TTree* aodTree = (TTree*)f->Get("aodTree");
39
40 AliAODEvent* aod = new AliAODEvent();
41 aod->ReadFromTree(aodTree);
42
43 Int_t nEvt = aodTree->GetEntries();
44
45 for(Int_t iev = 0; iev < nEvt; iev++) {
46 cout << "Event: " << iev+1 << "/" << nEvt << endl;
47 aodTree->GetEvent(iev);
48
1610de71 49 //get reconstructed vertex position
50 Double_t vertex_position[3] = { aod->GetPrimaryVertex()->GetX(),
51 aod->GetPrimaryVertex()->GetY(),
52 aod->GetPrimaryVertex()->GetZ()};
53
77e93dc2 54 //------------------------------------------------------
55 // Clusters loop
56 //------------------------------------------------------
57 if(kPrintCaloClusters)
58 {
59 TRefArray* caloClusters = new TRefArray();
60 aod->GetEMCALClusters(caloClusters);
61
62 Int_t nclus = caloClusters->GetEntries();
63 for (Int_t icl = 0; icl < nclus; icl++)
64 {
65
66 AliAODCaloCluster* clus = (AliAODCaloCluster*)caloClusters->At(icl);
67 Float_t energy = clus->E();
68 Float_t time = clus->GetTOF()*1.e9;
69 TLorentzVector p;
70 clus->GetMomentum(p,vertex_position);
71 Int_t nMatched = clus->GetNTracksMatched();
72
73 cout << "Cluster: " << icl+1 << "/" << nclus << " - Energy: " << energy << "; Time "<<time
74 <<"; Phi: " << p.Phi() << "; Eta: " << p.Eta() << "; #Matches: " << nMatched << endl;
75
76 }
77 }
78
79 //------------------------------------------------------
80 // Cells loop
81 //------------------------------------------------------
82
83 if(kPrintCaloCells)
84 {
85 AliVCaloCells &cells= *(aod->GetEMCALCells());
1610de71 86
77e93dc2 87 Int_t nTotalCells = cells.GetNumberOfCells() ;
88 //Int_t type = cells.GetType();
89 for (Int_t icell= 0; icell < nTotalCells; icell++) {
90 cout<<"Cell : "<<icell<<"/"<<nTotalCells<<" - ID: "<<cells.GetCellNumber(icell)<<"; Amplitude: "<<cells.GetAmplitude(icell)<<"; Time: "<<cells.GetTime(icell)*1e9;
91 cout << "; MC label "<<cells.GetMCLabel(icell)<<"; Embeded E fraction "<<cells.GetEFraction(icell);
92 cout<<endl;
93 }// cell loop
1610de71 94 }
77e93dc2 95
1610de71 96
97 }
98
99
100
101}