]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliMuonAnalysis.cxx
Avoiding some potentially slow methods
[u/mrichter/AliRoot.git] / ANALYSIS / AliMuonAnalysis.cxx
CommitLineData
beb1c41d 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
31ClassImp(AliMuonAnalysis)
32
33AliMuonAnalysis::AliMuonAnalysis():
34 fPartCut(0x0)
35{
36 //ctor
37}
38
39/*********************************************************/
40AliMuonAnalysis::~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
57Int_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
77Int_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
95Int_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
107void 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
065e0e69 131 lorV1.SetPxPyPzE(aodPart1->Px(),
132 aodPart1->Py(),
133 aodPart1->Pz(),
134 aodPart1->E());
beb1c41d 135
136 fHPtMuon->Fill(lorV1.Pt());
137 fHPMuon->Fill(lorV1.P());
138
139 charge1 = TMath::Sign(1,aodPart1->GetPdgCode());
140
141 if (charge1 > 0) {
142 fHPtMuonPlus->Fill(lorV1.Pt());
143 } else {
144 fHPtMuonMinus->Fill(lorV1.Pt());
145 }
146 fHRapMuon->Fill(lorV1.Rapidity());
147 for (Int_t iPart2 = iPart1 + 1; iPart2 < nPart; iPart2++) {
148
149 AliAODParticle* aodPart2 = (AliAODParticle*)aod->GetParticle(iPart2);
150
065e0e69 151 lorV2.SetPxPyPzE(aodPart2->Px(),
152 aodPart2->Py(),
153 aodPart2->Pz(),
154 aodPart2->E());
155
beb1c41d 156 charge2 = TMath::Sign(1,aodPart2->GetPdgCode());
157
158 if ((charge1 * charge2) == -1) {
159
065e0e69 160 lorVtot = lorV1;
161 lorVtot += lorV2;
beb1c41d 162 Float_t invMass = lorVtot.M();
163
164 fHInvMassAll->Fill(invMass);
165 fHInvMassAll_vs_Pt->Fill(invMass,lorVtot.Pt());
166
167 if (invMass > massMin && invMass < massMax) {
168 fHRapResonance->Fill(lorVtot.Rapidity());
169 fHPtResonance->Fill(lorVtot.Pt());
170 }
171 }
172
173 }
174 }
175}