]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/totEt/AliAnalysisHadEt.cxx
coverity fix
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisHadEt.cxx
CommitLineData
cf6522d1 1//Created by Christine Nattrass, Rebecca Scott, Irakli Martashvili
641e1e0c 2//University of Tennessee at Knoxville
cf6522d1 3//
4// This class is designed for the analysis of the hadronic component of
5// transverse energy. It is used by AliAnalysisTaskHadEt.
6// This gets information about the hadronic component of the transverse energy
7// from tracks reconstructed in an event
8// it has daughters, AliAnalysisHadEtMonteCarlo and
9// AliAnalysisHadEtReconstructed which loop over either Monte Carlo data or
10// real data to get Et
3ce6b879 11
641e1e0c 12#include "AliAnalysisHadEt.h"
13#include "TMath.h"
14#include "TList.h"
15#include "TH1F.h"
16#include "TH2F.h"
17#include <iostream>
18#include "AliAnalysisEtCuts.h"
020abff0 19#include "AliMCEvent.h"
641e1e0c 20#include "AliVEvent.h"
020abff0 21#include "AliStack.h"
22#include "AliESDtrackCuts.h"
23#include "TDatabasePDG.h"
24#include "TParticle.h"
25#include "Rtypes.h"
4b40b2b1 26#include "AliPDG.h"
641e1e0c 27
28using namespace std;
29
30ClassImp(AliAnalysisHadEt);
31
32
4b40b2b1 33Int_t AliAnalysisHadEt::fgnumOfEtaBins = 16;
34Float_t AliAnalysisHadEt::fgEtaAxis[17]={-0.78, -0.7, -0.58, -0.46, -0.34, -0.22, -0.12, -0.06, -0.0, 0.06, 0.12, 0.22, 0.34, 0.46, 0.58, 0.7, 0.78};
020abff0 35Int_t AliAnalysisHadEt::fgNumOfPtBins = 111;
36Float_t AliAnalysisHadEt::fgPtAxis[117]=
641e1e0c 37 {0.0,0.01,0.02,0.03,0.04, 0.05, 0.06,0.07,0.08,0.09, 0.10,0.11, .12,0.13, .14,0.15, .16,0.17, .18,0.19,
38 0.2, .22, .24, .26, .28, 0.30, 0.32, .34, .36, .38, 0.40, .42, .44, .46, .48,
39 0.5, .52, .54, .56, .58, 0.60, 0.62, .64, .66, .68, 0.70, .72, .74, .76, .78,
40 .80, .82, .84, .86, .88, 0.90, 0.92, .94, .96, .98, 1.00,1.05, 1.1,1.15, 1.2,
41 1.25, 1.3,1.35,1.40,1.45, 1.50, 1.55, 1.6,1.65, 1.7, 1.75, 1.8,1.85, 1.9,1.95,
42 2.0, 2.2, 2.4, 2.6, 2.8, 3.00, 3.20, 3.4, 3.6, 3.8, 4.00, 4.2, 4.4, 4.6, 4.8,
43 5.0, 5.5, 6.0, 6.5, 7.0, 7.50, 8.00, 8.5, 9.0, 9.5, 10.0,12.0,14.0,16.0,18.0,
66e4ff36 44 20.0,25.0,30.0,35.0,40.0, 45.0, 50.0};
45Float_t AliAnalysisHadEt::fgResAxis[81] = {-0.150,-0.140,-0.130,-0.120,-0.110,-0.100,-0.090,-0.080,-0.070,-0.060,
46 -0.050,-0.045,-0.040,-0.035,-0.030,-0.025,-0.024,-0.023,-0.022,-0.021,
47 -0.020,-0.019,-0.018,-0.017,-0.016,-0.015,-0.014,-0.013,-0.012,-0.011,
48 -0.010,-0.009,-0.008,-0.007,-0.006,-0.005,-0.004,-0.003,-0.002,-0.001,
49 -0.000,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,
50 0.010,0.011,0.012,0.013,0.014,0.015,0.016,0.017,0.018,0.019,
51 0.020,0.021,0.022,0.023,0.024,0.025,0.030,0.035,0.040,0.045,
52 0.050,0.060,0.070,0.080,0.090,0.100,0.110,0.120,0.130,0.140,
53 0.150,};
54// Float_t AliAnalysisHadEt::fgResAxis[31] = {-0.15,-0.14,-0.13,-0.12,-0.11,-0.1,-0.09,-0.08,-0.07,-0.06,-0.05,-0.04,-0.03,-0.02,-0.01,0.0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.15};
55Int_t AliAnalysisHadEt::fgNumOfResBins = 80;
641e1e0c 56
d6214a64 57
7d2d1773 58AliAnalysisHadEt::AliAnalysisHadEt() : AliAnalysisEtCommon()
7d2d1773 59 ,fSumEt(0)
60 ,fSumEtAcc(0)
61 ,fTotEt(0)
62 ,fTotEtAcc(0)
63 ,fTotNeutralEt(0)
64 ,fTotNeutralEtAcc(0)
65 ,fTotChargedEt(0)
66 ,fTotChargedEtAcc(0)
67 ,fMultiplicity(0)
68 ,fChargedMultiplicity(0)
69 ,fNeutralMultiplicity(0)
70 ,fhistoList(0)
66e4ff36 71 ,fGoodEvent(0)
020abff0 72{//default constructor
641e1e0c 73
74}
75
76AliAnalysisHadEt::~AliAnalysisHadEt()
020abff0 77{//destructor
951efd81 78 delete fEsdtrackCutsITSTPC;
79 delete fEsdtrackCutsITS;
80 delete fEsdtrackCutsTPC;
641e1e0c 81}
82
83Int_t AliAnalysisHadEt::AnalyseEvent(AliVEvent *event)
020abff0 84{ //this line is basically here to eliminate a compiler warning that event is not used. Making it a virtual function did not work with the plugin.
7d2d1773 85 AliAnalysisEtCommon::AnalyseEvent(event);
0065531a 86 ResetEventValues();
641e1e0c 87 return 0;
88}
89
641e1e0c 90
91void AliAnalysisHadEt::Init()
0065531a 92{// clear variables, set up cuts and PDG info
7d2d1773 93 AliAnalysisEtCommon::Init();
641e1e0c 94}
95
96void AliAnalysisHadEt::ResetEventValues()
020abff0 97{//Resets event values of et to zero
7d2d1773 98 AliAnalysisEtCommon::ResetEventValues();
0065531a 99 fTotEt = 0;
100 fTotEtAcc = 0;
101 fTotNeutralEt = 0;
102 fTotNeutralEtAcc = 0;
103 fTotChargedEt = 0;
104 fTotChargedEtAcc = 0;
105 fMultiplicity = 0;
106 fChargedMultiplicity = 0;
107 fNeutralMultiplicity = 0;
108
4998becf 109}
641e1e0c 110void AliAnalysisHadEt::CreateEtaPtHisto2D(TString name, TString title)
020abff0 111{ //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
641e1e0c 112 TString *histoname = new TString();
113 TString *histotitle = new TString();
114
115 histoname->Append(name);
116 histotitle->Append(title);
641e1e0c 117
020abff0 118 TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgnumOfEtaBins, fgEtaAxis);
641e1e0c 119 histo->SetYTitle("#eta");
120 histo->SetXTitle("p_{T}");
121 histo->SetZTitle("E_{T}");
122 histo->Sumw2();
020abff0 123 fhistoList->Add(histo);
641e1e0c 124 delete histoname;
125 delete histotitle;
126
66e4ff36 127}
128void AliAnalysisHadEt::CreateResolutionPtHisto2D(TString name, TString title, TString xtitle, TString ytitle)
129{ //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
130 TString *histoname = new TString();
131 TString *histotitle = new TString();
132
133 histoname->Append(name);
134 histotitle->Append(title);
135
136 //TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgNumOfResBins, fgResAxis);
137 TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgNumOfResBins, fgResAxis);
138 histo->SetYTitle(ytitle);
139 histo->SetXTitle(xtitle);
140 histo->SetZTitle("Number of entries");
141 histo->Sumw2();
142 fhistoList->Add(histo);
143 delete histoname;
144 delete histotitle;
145
146}
147void AliAnalysisHadEt::CreatePtHisto1D(TString name, TString title, TString xtitle, TString ytitle)
148{ //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
149 TString *histoname = new TString();
150 TString *histotitle = new TString();
151
152 histoname->Append(name);
153 histotitle->Append(title);
154
155 TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis);
156 histo->SetYTitle(ytitle);
157 histo->SetXTitle(xtitle);
158 histo->Sumw2();
159 fhistoList->Add(histo);
160 delete histoname;
161 delete histotitle;
162
641e1e0c 163}
164
165void AliAnalysisHadEt::CreateHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Float_t xlow,Float_t xhigh)
020abff0 166{ //creates a 1d histogram of the given dimensions and adds it to the list of histograms to be saved
641e1e0c 167 TString *histoname = new TString();
168 TString *histotitle = new TString();
641e1e0c 169 histoname->Append(name);
170 histotitle->Append(title);
641e1e0c 171 TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh);
172 histo->SetYTitle(ytitle);
173 histo->SetXTitle(xtitle);
174 histo->Sumw2();
020abff0 175 fhistoList->Add(histo);
641e1e0c 176 delete histoname;
177 delete histotitle;
641e1e0c 178}
179void AliAnalysisHadEt::CreateIntHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Int_t xlow,Int_t xhigh)
020abff0 180{ //creates a 1d integer histogram and adds it to the list of histograms to be saved
641e1e0c 181 TString *histoname = new TString();
182 TString *histotitle = new TString();
641e1e0c 183 histoname->Append(name);
184 histotitle->Append(title);
641e1e0c 185 TH1I *histo = new TH1I(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh);
186 histo->SetYTitle(ytitle);
187 histo->SetXTitle(xtitle);
188 histo->Sumw2();
020abff0 189 fhistoList->Add(histo);
641e1e0c 190 delete histoname;
191 delete histotitle;
192
193}
194void AliAnalysisHadEt::CreateHisto2D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Float_t xlow,Float_t xhigh,Int_t ybins,Float_t ylow,Float_t yhigh)
020abff0 195{ //creates a 2d histogram and adds it to the list of histograms to be saved
641e1e0c 196 TString *histoname = new TString();
197 TString *histotitle = new TString();
641e1e0c 198 histoname->Append(name);
199 histotitle->Append(title);
641e1e0c 200 TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh,ybins,ylow,yhigh);
201 histo->SetYTitle(ytitle);
202 histo->SetXTitle(xtitle);
203 histo->Sumw2();
020abff0 204 fhistoList->Add(histo);
641e1e0c 205 delete histoname;
206 delete histotitle;
207
208}
209void AliAnalysisHadEt::CreateIntHisto2D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Int_t xlow,Int_t xhigh,Int_t ybins,Int_t ylow,Int_t yhigh)
020abff0 210{ //creates a 2-d integer histogram and adds it to the list of histograms to be saved
641e1e0c 211 TString *histoname = new TString();
212 TString *histotitle = new TString();
641e1e0c 213 histoname->Append(name);
214 histotitle->Append(title);
641e1e0c 215 TH2I *histo = new TH2I(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh,ybins,ylow,yhigh);
216 histo->SetYTitle(ytitle);
217 histo->SetXTitle(xtitle);
218 histo->Sumw2();
020abff0 219 fhistoList->Add(histo);
641e1e0c 220 delete histoname;
221 delete histotitle;
222
223}
224
225void AliAnalysisHadEt::CreateEtaHisto1D(TString name, TString title)
020abff0 226{ //creates 1d histogram in eta and adds it to the list of histograms to be saved
641e1e0c 227 TString *histoname = new TString();
228 TString *histotitle = new TString();
641e1e0c 229 histoname->Append(name);
230 histotitle->Append(title);
020abff0 231 TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),fgnumOfEtaBins, fgEtaAxis);
641e1e0c 232 histo->SetYTitle("E_{T}");
233 histo->SetXTitle("#eta");
234 histo->Sumw2();
020abff0 235 fhistoList->Add(histo);
641e1e0c 236 delete histoname;
237 delete histotitle;
641e1e0c 238}
239void AliAnalysisHadEt::FillHisto1D(TString histname, Float_t x, Float_t weight)
020abff0 240{//fills a 1d histogram with the name histoname with the value x and the weight "weight"
641e1e0c 241 TH1F *histo;
242 TString *name = new TString();
641e1e0c 243 name->Append(histname);
020abff0 244 histo = (TH1F *)fhistoList->FindObject(name->Data());
641e1e0c 245 if(histo){
246 histo->Fill((Double_t)x, weight);
247 }
248 else{cerr<<"CorrelationMaker::FillHisto1D: no histogram "<< name->Data()<<endl;}
249 delete name;
250}
251void AliAnalysisHadEt::FillHisto2D(TString histname, Float_t x, Float_t y, Float_t weight)
020abff0 252{//fills a 2d histogram with the name histoname with the value x and the weight "weight"
641e1e0c 253 TH2F *histo;
254 TString *name = new TString();
641e1e0c 255 name->Append(histname);
020abff0 256 histo = (TH2F *)fhistoList->FindObject(name->Data());
641e1e0c 257 if(histo){
258 histo->Fill((Double_t)x,(Double_t)y, weight);
259 }
260 else{cerr<<"CorrelationMaker::FillHisto2D: no histogram "<< name->Data()<<endl;}
261 delete name;
262}
263
264
020abff0 265Float_t AliAnalysisHadEt::Et(TParticle *part, float mass){//function to calculate et in the same way as it would be calculated in a calorimeter
266 if(mass+1000<0.01){//if no mass given return default. The default argument is -1000
641e1e0c 267 if(TMath::Abs(part->GetPDG(0)->PdgCode())==2212 || TMath::Abs(part->GetPDG(0)->PdgCode())==2112){
268 if(part->GetPDG(0)->PdgCode()==-2212 || part->GetPDG(0)->PdgCode()==-2112){//antiproton or antineutron
269 //for antinucleons we specifically want to return the kinetic energy plus twice the rest mass
270 return (part->Energy()+part->GetMass())*TMath::Sin(part->Theta());
271 }
0e866ddc 272 if(part->GetPDG(0)->PdgCode()==2212 || part->GetPDG(0)->PdgCode()==2112){//proton or neutron
641e1e0c 273 //for nucleons we specifically want to return the kinetic energy only
274 return (part->Energy()-part->GetMass())*TMath::Sin(part->Theta());
275 }
276 }
277 else{//otherwise go to the default
278 return part->Energy()*TMath::Sin(part->Theta());
279 }
280 }
281 else{//otherwise use the mass that was given
282 return (TMath::Sqrt(TMath::Power(part->P(),2.0)+TMath::Power(mass,2.0)))*TMath::Sin(part->Theta());
283 }
284 return 0.0;
285}
464aa50c 286Float_t AliAnalysisHadEt::Et(Float_t p, Float_t theta, Int_t pid, Short_t charge) const {//function to calculate et in the same way as it would be calculated in a calorimeter
7d2d1773 287 if(pid==AliAnalysisEtCommon::fgPiPlusCode || pid==AliAnalysisEtCommon::fgPiMinusCode){//Nothing special for pions
4b40b2b1 288 return TMath::Sqrt(p*p + fgPionMass*fgPionMass) * TMath::Sin(theta);
3ce6b879 289 }
7d2d1773 290 if(pid==AliAnalysisEtCommon::fgKPlusCode || pid==AliAnalysisEtCommon::fgKMinusCode){//Nothing special for kaons
291 return TMath::Sqrt(p*p + AliAnalysisEtCommon::fgKaonMass*AliAnalysisEtCommon::fgKaonMass) * TMath::Sin(theta);
3ce6b879 292 }
7d2d1773 293 if(pid==AliAnalysisEtCommon::fgEPlusCode || pid==AliAnalysisEtCommon::fgEMinusCode){//Nothing special for electrons
294 return TMath::Sqrt(p*p + AliAnalysisEtCommon::fgElectronMass*AliAnalysisEtCommon::fgElectronMass) * TMath::Sin(theta);
3ce6b879 295 }
7d2d1773 296 if(pid==AliAnalysisEtCommon::fgProtonCode || pid==AliAnalysisEtCommon::fgAntiProtonCode){//But for protons we must be careful...
3ce6b879 297 if(charge<0.0){//antiprotns: kinetic energy plus twice the rest mass
7d2d1773 298 return (TMath::Sqrt(p*p + AliAnalysisEtCommon::fgProtonMass*AliAnalysisEtCommon::fgProtonMass) + AliAnalysisEtCommon::fgProtonMass) * TMath::Sin(theta);
3ce6b879 299 }
300 if(charge>0.0){//antiprotns: kinetic energy only
7d2d1773 301 return (TMath::Sqrt(p*p + AliAnalysisEtCommon::fgProtonMass*AliAnalysisEtCommon::fgProtonMass) - AliAnalysisEtCommon::fgProtonMass) * TMath::Sin(theta);
3ce6b879 302 }
303 }
66e4ff36 304 //cerr<<"Uh-oh! Et not set properly!"<<endl;
3ce6b879 305 return 0.0;
306}
7d2d1773 307
d263b18f 308Float_t AliAnalysisHadEt::TrueP(float pTrec) const {
66e4ff36 309 if(pTrec>1.0) return pTrec;
310 return pTrec/(1-599.334*pTrec+7285.15*pTrec*pTrec)+pTrec;
311}