]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliMuonAnalysis.cxx
redirection and C++ streams added
[u/mrichter/AliRoot.git] / ANALYSIS / AliMuonAnalysis.cxx
1 #include "AliMuonAnalysis.h"
2 //________________________________
3 ///////////////////////////////////////////////////////////
4 //
5 // class AliMuonAnalysis
6 //
7 // MUON Analysis
8 //
9 //
10 // 
11 // finck@subatech.in2p3.fr
12 //
13 ///////////////////////////////////////////////////////////
14 /*********************************************************/
15
16 #include <TString.h>
17 #include <TParticle.h>
18
19 #include <AliStack.h>
20 #include <AliAOD.h>
21 #include <AliAODParticle.h>
22 #include <AliAODParticleCut.h>
23
24 #include <AliESDtrack.h>
25 #include <AliESD.h>
26
27 #include "TFile.h"
28 #include "TH1.h"
29 #include "TH2.h"
30
31 ClassImp(AliMuonAnalysis)
32
33 AliMuonAnalysis::AliMuonAnalysis():
34  fPartCut(0x0)
35 {
36  //ctor
37 }
38
39 /*********************************************************/
40 AliMuonAnalysis::~AliMuonAnalysis()
41 {
42  //dtor
43   delete fPartCut;
44   delete fHistoFile;
45   delete fHPtMuon;
46   delete fHPtMuonPlus;
47   delete fHPtMuonMinus;
48   delete fHPMuon;
49   delete fHInvMassAll;
50   delete fHRapMuon;
51   delete fHRapResonance;
52   delete fHPtResonance;
53   delete fHInvMassAll_vs_Pt;
54 }
55 /*********************************************************/
56
57 Int_t AliMuonAnalysis::Init()
58 {
59   //Initilizes anaysis
60   Info("Init","Histo initialized for MUON Analysis");
61
62   fHistoFile         = new TFile("MUONmassPlot.root", "RECREATE");
63   fHPtMuon           = new TH1F("hPtMuon", "Muon Pt (GeV/c)", 100, 0., 20.);
64   fHPMuon            = new TH1F("hPMuon", "Muon P (GeV/c)", 100, 0., 200.);
65   fHPtMuonPlus       = new TH1F("hPtMuonPlus", "Muon+ Pt (GeV/c)", 100, 0., 20.);
66   fHPtMuonMinus      = new TH1F("hPtMuonMinus", "Muon- Pt (GeV/c)", 100, 0., 20.);
67   fHInvMassAll       = new TH1F("hInvMassAll", "Mu+Mu- invariant mass (GeV/c2)", 480, 0., 12.);
68   fHRapMuon          = new TH1F("hRapMuon"," Muon Rapidity",50,-4.5,-2);
69   fHRapResonance     = new TH1F("hRapResonance"," Resonance Rapidity",50,-4.5,-2);
70   fHPtResonance      = new TH1F("hPtResonance", "Resonance Pt (GeV/c)", 100, 0., 20.);
71   fHInvMassAll_vs_Pt = new TH2F("hInvMassAll_vs_Pt","hInvMassAll_vs_Pt",480,0.,12.,80,0.,20.);
72
73   return 0; 
74 }
75 /*********************************************************/
76
77 Int_t AliMuonAnalysis::ProcessEvent(AliAOD* aodrec, AliAOD* aodsim)
78 {
79  
80   if (aodrec) {
81     GetInvMass(aodrec);
82     //    Info("ProcessEvent","Inv Mass Rec");
83   }  
84
85   if (aodsim) {
86     //     Info("ProcessEvent","aodsim not implemented");
87   }  
88   
89   return 0;
90   
91 }
92
93 /*********************************************************/
94
95 Int_t AliMuonAnalysis::Finish()
96 {
97   //Finish analysis and writes results
98   Info("Finish","Histo writing for MUON Analysis");
99
100   fHistoFile->Write();
101   fHistoFile->Close();
102
103   return 0;
104 }
105 /*********************************************************/
106
107 void AliMuonAnalysis::GetInvMass(AliAOD* aod)
108 {
109
110   TLorentzVector lorV1, lorV2, lorVtot;
111   Float_t massMin = 9.17;
112   Float_t massMax = 9.77;
113   Int_t charge1, charge2;
114
115 //returns flow parameters: v2 and event plane
116   if (aod == 0x0) {
117      Error("AliMuonAnalysis::GetInvMass","Pointer to AOD is NULL");
118      return;
119   }
120    
121   Int_t nPart = aod->GetNumberOfParticles();
122   
123   for (Int_t iPart1 = 0; iPart1 < nPart; iPart1++)  {
124     AliAODParticle* aodPart1 =  (AliAODParticle*)aod->GetParticle(iPart1);
125
126     if (aodPart1 == 0x0) {
127       Error("AliMuonAnalysis::GetInvMass","Cannot get particle %d", iPart1);
128       continue;
129     }
130
131     lorV1 = aodPart1->FourMomentum();
132
133     fHPtMuon->Fill(lorV1.Pt());
134     fHPMuon->Fill(lorV1.P());
135
136     charge1 = TMath::Sign(1,aodPart1->GetPdgCode());
137
138     if (charge1 > 0) {
139       fHPtMuonPlus->Fill(lorV1.Pt());
140     } else {
141       fHPtMuonMinus->Fill(lorV1.Pt());
142     }
143     fHRapMuon->Fill(lorV1.Rapidity());
144     for (Int_t iPart2 = iPart1 + 1; iPart2 < nPart; iPart2++)  {
145
146       AliAODParticle* aodPart2 =  (AliAODParticle*)aod->GetParticle(iPart2);
147
148       lorV2 = aodPart2->FourMomentum();
149       charge2 = TMath::Sign(1,aodPart2->GetPdgCode());
150
151       if ((charge1 * charge2) == -1) {
152
153         lorVtot = lorV1 + lorV2;
154         Float_t invMass = lorVtot.M();
155
156         fHInvMassAll->Fill(invMass);
157         fHInvMassAll_vs_Pt->Fill(invMass,lorVtot.Pt());
158
159         if (invMass > massMin && invMass < massMax) {
160           fHRapResonance->Fill(lorVtot.Rapidity());
161           fHPtResonance->Fill(lorVtot.Pt());
162         }
163       }
164
165     }
166   }
167 }