]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muon/ReadSpecAOD.C
libPWGEMCAL, libPWGflowtasks and libPWGmuon converted to native cmake
[u/mrichter/AliRoot.git] / PWG / muon / ReadSpecAOD.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2
3 #include <Riostream.h>
4 #include "TSystem.h"
5 #include "TFile.h"
6 #include "TTree.h"
7 #include "TCanvas.h"
8 #include "TH1.h"
9 #include "TFile.h"
10 #include "TObject.h"
11 #include "TStyle.h"
12 #include "TROOT.h"
13
14 #include "AliAODEvent.h"
15 #include "AliAODHeader.h"
16 #include "AliAODEventInfo.h"
17 #include "AliAODVertex.h"
18 #include "AliAODTrack.h"
19 #include "AliAODCluster.h"
20 #include "AliAODDimuon.h"
21
22 #endif
23
24 void ReadSpecAOD(const char *fileName = "AliMuonAOD.root") {
25
26     gSystem->Load("libTree");
27     gSystem->Load("libGeom");
28     gSystem->Load("libSTEERBase");
29     gSystem->Load("libAOD");
30     gSystem->Load("libANALYSIS");                       
31     gSystem->Load("libPWGHFbase.so");
32
33
34
35   gStyle->SetOptStat(111111);
36   gStyle->SetFrameFillColor(10);
37   gStyle->SetCanvasColor(10);
38   gStyle->SetOptStat(0);
39   TH1F *mass=new TH1F("mass","Invariant mass",100,0.,20.);
40   TH1F *rap=new TH1F("rap","Rapidity",100,-5.,0.);
41   TH1F *cost=new TH1F("cost","Cost_CS",100,-1.,1.);
42   TH1F *pt=new TH1F("pt","Pt",100,0.,50.);
43   TH1F *ptmuon=new TH1F("ptmuon","single muon Pt",100,0.,50.);
44
45   // open input file and get the TTree
46   TFile inFile(fileName, "READ");
47   TTree *aodTree = (TTree*)inFile.Get("AOD");
48
49   AliAODEvent *aod = (AliAODEvent*)aodTree->GetUserInfo()->FindObject("AliAODEvent");
50
51   TClonesArray *Dimuons;
52   TClonesArray *tracks;
53   TClonesArray *vertices;
54   AliAODEventInfo *MuonInfos;
55   
56   aodTree->SetBranchAddress("Dimuons",&Dimuons);
57   aodTree->SetBranchAddress("tracks",&tracks);
58   aodTree->SetBranchAddress("vertices",&vertices);
59   aodTree->SetBranchAddress("MuonInfos",&MuonInfos);
60
61   // loop over events
62   Int_t nEvents = aodTree->GetEntries();
63   for (Int_t nEv = 0; nEv < nEvents; nEv++) {
64     cout << "Event: " << nEv+1 << "/" << nEvents << endl;
65     aodTree->GetEntry(nEv);
66     // loop over tracks
67     Int_t nTracks = tracks->GetEntries();
68     for (Int_t nTr = 0; nTr < nTracks; nTr++) {
69       AliAODTrack *tr = (AliAODTrack *)tracks->At(nTr);
70       ptmuon->Fill(tr->Pt());
71       // print track info
72       cout << nTr+1 << "/" << nTracks << ": track pt: " << tr->Pt();
73       if (tr->GetProdVertex()) {
74         cout << ", vertex z of this track: " << tr->GetProdVertex()->GetZ();
75       }
76       cout << endl;
77     }
78     // loop over dimuons
79     
80     Int_t nDimuons = Dimuons->GetEntries();
81     cout << nDimuons << " dimuon(s)" << endl;
82     for(Int_t nDi=0; nDi < nDimuons; nDi++){
83       AliAODDimuon *di=(AliAODDimuon*)Dimuons->At(nDi);
84        if((MuonInfos->MUON_Unlike_HPt_L0())){
85          mass->Fill(di->M());
86          pt->Fill(di->Pt());
87          rap->Fill(di->Y());
88          cost->Fill(di->CostCS());
89          cout << "Dimuon: " << nDi << " q: " << di->Charge() 
90               << " m: " << di->M() << " Y: " << di->Y() << " Pt: " << di->Pt()<< " CostCS: " << di->CostCS() << endl  ;
91        }
92     }
93 //     // loop over vertices
94 //     Int_t nVtxs = vertices->GetEntries();
95 //     for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
96 //       
97 //       // print track info
98 //       cout << nVtx+1 << "/" << nVtxs << ": vertex z position: " <<vertices->At(nVtx)->GetZ() << endl;
99 //     }
100   }
101   inFile.Close();
102   TCanvas *c1=new TCanvas();
103   c1->Show();
104   c1->Divide(2,2);
105   c1->ForceUpdate();
106   c1->cd(1);
107   mass->DrawClone();
108   c1->cd(2);
109   rap->DrawClone();
110   c1->cd(3);
111   pt->DrawClone();
112   c1->cd(4);
113   cost->DrawClone();
114   
115   TCanvas *c2 = new TCanvas();
116   c2->cd();
117   ptmuon->DrawClone();
118   return;
119 }