]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/totEt/AliAnalysisHadEt.cxx
Changing particle codes and masses to static variables, fixing a bug in the backgroun...
[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);
4b40b2b1 31//These are from the PDG database but by making them static the code is a bit more efficient and has no problems running with the plugin
32Float_t AliAnalysisHadEt::fgPionMass = 0.13957;
33Float_t AliAnalysisHadEt::fgKaonMass = 0.493677;
34Float_t AliAnalysisHadEt::fgProtonMass = 0.938272;
35Float_t AliAnalysisHadEt::fgElectronMass = 0.000510999;
36Int_t AliAnalysisHadEt::fgPiPlusCode = 211;
37Int_t AliAnalysisHadEt::fgPiMinusCode = -211;
38Int_t AliAnalysisHadEt::fgKPlusCode = 321;
39Int_t AliAnalysisHadEt::fgKMinusCode = -321;
40Int_t AliAnalysisHadEt::fgProtonCode = 2212;
41Int_t AliAnalysisHadEt::fgAntiProtonCode = -2212;
42Int_t AliAnalysisHadEt::fgLambdaCode = 3122;
43Int_t AliAnalysisHadEt::fgAntiLambdaCode = -3122;
44Int_t AliAnalysisHadEt::fgK0SCode = 310;
45Int_t AliAnalysisHadEt::fgOmegaCode = 3334;
46Int_t AliAnalysisHadEt::fgAntiOmegaCode = -3334;
47Int_t AliAnalysisHadEt::fgXi0Code = 3322;
48Int_t AliAnalysisHadEt::fgAntiXi0Code = -3322;
49Int_t AliAnalysisHadEt::fgXiCode = 3312;
50Int_t AliAnalysisHadEt::fgAntiXiCode = -3312;
51Int_t AliAnalysisHadEt::fgSigmaCode = 3112;
52Int_t AliAnalysisHadEt::fgAntiSigmaCode = -3112;
53Int_t AliAnalysisHadEt::fgK0LCode = 130;
54Int_t AliAnalysisHadEt::fgNeutronCode = 2112;
55Int_t AliAnalysisHadEt::fgAntiNeutronCode = -2112;
56Int_t AliAnalysisHadEt::fgEPlusCode = -11;
57Int_t AliAnalysisHadEt::fgEMinusCode = 11;
58Int_t AliAnalysisHadEt::fgGammaCode = 22;
59Int_t AliAnalysisHadEt::fgPi0Code = 111;
60Int_t AliAnalysisHadEt::fgEtaCode = 221;
61Int_t AliAnalysisHadEt::fgOmega0Code = 223;
641e1e0c 62
63
4b40b2b1 64// Int_t AliAnalysisHadEt::fgnumOfEtaBins = 46;
65// Float_t AliAnalysisHadEt::fgEtaAxis[47]={-0.78, -0.74, -0.7, -0.66, -0.62, -0.58, -0.54, -0.5, -0.46, -0.42, -0.38, -0.34, -0.3, -0.26, -0.22, -0.18, -0.14, -0.12, -0.1, -0.08, -0.06, -0.04, -0.02, -0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.18, 0.22, 0.26, 0.3, 0.34, 0.38, 0.42, 0.46, 0.5, 0.54, 0.58, 0.62, 0.66, 0.7, 0.74, 0.78};
66//reduction in the number of bins
67Int_t AliAnalysisHadEt::fgnumOfEtaBins = 16;
68Float_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 69Int_t AliAnalysisHadEt::fgNumOfPtBins = 111;
70Float_t AliAnalysisHadEt::fgPtAxis[117]=
641e1e0c 71 {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,
72 0.2, .22, .24, .26, .28, 0.30, 0.32, .34, .36, .38, 0.40, .42, .44, .46, .48,
73 0.5, .52, .54, .56, .58, 0.60, 0.62, .64, .66, .68, 0.70, .72, .74, .76, .78,
74 .80, .82, .84, .86, .88, 0.90, 0.92, .94, .96, .98, 1.00,1.05, 1.1,1.15, 1.2,
75 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,
76 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,
77 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,
78 20.0,25.0,30.0,35.0,40.0, 45.0, 50.0};
79
d6214a64 80Float_t AliAnalysisHadEt::fgPtTPCCutOff = 0.15;
81Float_t AliAnalysisHadEt::fgPtITSCutOff = 0.10;
82
641e1e0c 83AliAnalysisHadEt::AliAnalysisHadEt() :
84 fHistogramNameSuffix("")
4998becf 85 ,fCuts(0)
641e1e0c 86 ,fSumEt(0)
87 ,fSumEtAcc(0)
88 ,fTotEt(0)
89 ,fTotEtAcc(0)
90 ,fTotNeutralEt(0)
91 ,fTotNeutralEtAcc(0)
92 ,fTotChargedEt(0)
93 ,fTotChargedEtAcc(0)
94 ,fMultiplicity(0)
95 ,fChargedMultiplicity(0)
96 ,fNeutralMultiplicity(0)
cf6522d1 97 ,fEsdtrackCutsITSTPC(0)
98 ,fEsdtrackCutsTPC(0)
99 ,fEsdtrackCutsITS(0)
020abff0 100 ,fhistoList(0)
101{//default constructor
641e1e0c 102
103}
104
105AliAnalysisHadEt::~AliAnalysisHadEt()
020abff0 106{//destructor
951efd81 107 delete fCuts;
951efd81 108 delete fEsdtrackCutsITSTPC;
109 delete fEsdtrackCutsITS;
110 delete fEsdtrackCutsTPC;
641e1e0c 111}
112
113Int_t AliAnalysisHadEt::AnalyseEvent(AliVEvent *event)
020abff0 114{ //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.
0065531a 115 cout << "This event has " << event->GetNumberOfTracks() << " tracks" << endl;
116 ResetEventValues();
641e1e0c 117 return 0;
118}
119
120void AliAnalysisHadEt::FillOutputList()
020abff0 121{//fill the output histogram list with histograms in all AliAnalysisHadEt's
641e1e0c 122}
123
124void AliAnalysisHadEt::Init()
0065531a 125{// clear variables, set up cuts and PDG info
3ce6b879 126
641e1e0c 127}
128
129void AliAnalysisHadEt::CreateHistograms()
020abff0 130{//creates histograms included in all AliAnalysisHadEt's
641e1e0c 131}
132
133void AliAnalysisHadEt::FillHistograms()
020abff0 134{//Fills histograms filled for all AliAnalysisHadEt's
641e1e0c 135}
136
137void AliAnalysisHadEt::ResetEventValues()
020abff0 138{//Resets event values of et to zero
0065531a 139 fTotEt = 0;
140 fTotEtAcc = 0;
141 fTotNeutralEt = 0;
142 fTotNeutralEtAcc = 0;
143 fTotChargedEt = 0;
144 fTotChargedEtAcc = 0;
145 fMultiplicity = 0;
146 fChargedMultiplicity = 0;
147 fNeutralMultiplicity = 0;
148
4b40b2b1 149 if (!fCuts) { // some Init's needed
0065531a 150 cout << __FILE__ << ":" << __LINE__ << " : Init " << endl;
151 if (!fCuts) {
152 cout << " setting up Cuts " << endl;
153 fCuts = new AliAnalysisEtCuts();
154 }
0065531a 155 }
641e1e0c 156}
4998becf 157
158void AliAnalysisHadEt::SetParticleCodes()
159{ //the codes are defined in $ROOTSYS/etc/pdg_table.txt
4998becf 160}
161
641e1e0c 162void AliAnalysisHadEt::CreateEtaPtHisto2D(TString name, TString title)
020abff0 163{ //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
641e1e0c 164 TString *histoname = new TString();
165 TString *histotitle = new TString();
166
167 histoname->Append(name);
168 histotitle->Append(title);
641e1e0c 169
020abff0 170 TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgnumOfEtaBins, fgEtaAxis);
641e1e0c 171 histo->SetYTitle("#eta");
172 histo->SetXTitle("p_{T}");
173 histo->SetZTitle("E_{T}");
174 histo->Sumw2();
020abff0 175 fhistoList->Add(histo);
641e1e0c 176 delete histoname;
177 delete histotitle;
178
179}
180
181void AliAnalysisHadEt::CreateHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Float_t xlow,Float_t xhigh)
020abff0 182{ //creates a 1d histogram of the given dimensions and adds it to the list of histograms to be saved
641e1e0c 183 TString *histoname = new TString();
184 TString *histotitle = new TString();
641e1e0c 185 histoname->Append(name);
186 histotitle->Append(title);
641e1e0c 187 TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh);
188 histo->SetYTitle(ytitle);
189 histo->SetXTitle(xtitle);
190 histo->Sumw2();
020abff0 191 fhistoList->Add(histo);
641e1e0c 192 delete histoname;
193 delete histotitle;
641e1e0c 194}
195void AliAnalysisHadEt::CreateIntHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Int_t xlow,Int_t xhigh)
020abff0 196{ //creates a 1d integer histogram and adds it to the list of histograms to be saved
641e1e0c 197 TString *histoname = new TString();
198 TString *histotitle = new TString();
641e1e0c 199 histoname->Append(name);
200 histotitle->Append(title);
641e1e0c 201 TH1I *histo = new TH1I(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh);
202 histo->SetYTitle(ytitle);
203 histo->SetXTitle(xtitle);
204 histo->Sumw2();
020abff0 205 fhistoList->Add(histo);
641e1e0c 206 delete histoname;
207 delete histotitle;
208
209}
210void 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 211{ //creates a 2d histogram and adds it to the list of histograms to be saved
641e1e0c 212 TString *histoname = new TString();
213 TString *histotitle = new TString();
641e1e0c 214 histoname->Append(name);
215 histotitle->Append(title);
641e1e0c 216 TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh,ybins,ylow,yhigh);
217 histo->SetYTitle(ytitle);
218 histo->SetXTitle(xtitle);
219 histo->Sumw2();
020abff0 220 fhistoList->Add(histo);
641e1e0c 221 delete histoname;
222 delete histotitle;
223
224}
225void 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 226{ //creates a 2-d integer histogram 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);
641e1e0c 231 TH2I *histo = new TH2I(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh,ybins,ylow,yhigh);
232 histo->SetYTitle(ytitle);
233 histo->SetXTitle(xtitle);
234 histo->Sumw2();
020abff0 235 fhistoList->Add(histo);
641e1e0c 236 delete histoname;
237 delete histotitle;
238
239}
240
241void AliAnalysisHadEt::CreateEtaHisto1D(TString name, TString title)
020abff0 242{ //creates 1d histogram in eta and adds it to the list of histograms to be saved
641e1e0c 243 TString *histoname = new TString();
244 TString *histotitle = new TString();
641e1e0c 245 histoname->Append(name);
246 histotitle->Append(title);
020abff0 247 TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),fgnumOfEtaBins, fgEtaAxis);
641e1e0c 248 histo->SetYTitle("E_{T}");
249 histo->SetXTitle("#eta");
250 histo->Sumw2();
020abff0 251 fhistoList->Add(histo);
641e1e0c 252 delete histoname;
253 delete histotitle;
641e1e0c 254}
255void AliAnalysisHadEt::FillHisto1D(TString histname, Float_t x, Float_t weight)
020abff0 256{//fills a 1d histogram with the name histoname with the value x and the weight "weight"
641e1e0c 257 TH1F *histo;
258 TString *name = new TString();
641e1e0c 259 name->Append(histname);
020abff0 260 histo = (TH1F *)fhistoList->FindObject(name->Data());
641e1e0c 261 if(histo){
262 histo->Fill((Double_t)x, weight);
263 }
264 else{cerr<<"CorrelationMaker::FillHisto1D: no histogram "<< name->Data()<<endl;}
265 delete name;
266}
267void AliAnalysisHadEt::FillHisto2D(TString histname, Float_t x, Float_t y, Float_t weight)
020abff0 268{//fills a 2d histogram with the name histoname with the value x and the weight "weight"
641e1e0c 269 TH2F *histo;
270 TString *name = new TString();
641e1e0c 271 name->Append(histname);
020abff0 272 histo = (TH2F *)fhistoList->FindObject(name->Data());
641e1e0c 273 if(histo){
274 histo->Fill((Double_t)x,(Double_t)y, weight);
275 }
276 else{cerr<<"CorrelationMaker::FillHisto2D: no histogram "<< name->Data()<<endl;}
277 delete name;
278}
279
280
020abff0 281Float_t AliAnalysisHadEt::Et(TParticle *part, float mass){//function to calculate et in the same way as it would be calculated in a calorimeter
282 if(mass+1000<0.01){//if no mass given return default. The default argument is -1000
641e1e0c 283 if(TMath::Abs(part->GetPDG(0)->PdgCode())==2212 || TMath::Abs(part->GetPDG(0)->PdgCode())==2112){
284 if(part->GetPDG(0)->PdgCode()==-2212 || part->GetPDG(0)->PdgCode()==-2112){//antiproton or antineutron
285 //for antinucleons we specifically want to return the kinetic energy plus twice the rest mass
286 return (part->Energy()+part->GetMass())*TMath::Sin(part->Theta());
287 }
288 if(part->GetPDG(0)->PdgCode()==2212 || part->GetPDG(0)->PdgCode()==2112){//antiproton or antineutron
289 //for nucleons we specifically want to return the kinetic energy only
290 return (part->Energy()-part->GetMass())*TMath::Sin(part->Theta());
291 }
292 }
293 else{//otherwise go to the default
294 return part->Energy()*TMath::Sin(part->Theta());
295 }
296 }
297 else{//otherwise use the mass that was given
298 return (TMath::Sqrt(TMath::Power(part->P(),2.0)+TMath::Power(mass,2.0)))*TMath::Sin(part->Theta());
299 }
300 return 0.0;
301}
464aa50c 302Float_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
4b40b2b1 303 if(pid==fgPiPlusCode || pid==fgPiMinusCode){//Nothing special for pions
304 return TMath::Sqrt(p*p + fgPionMass*fgPionMass) * TMath::Sin(theta);
3ce6b879 305 }
4b40b2b1 306 if(pid==fgKPlusCode || pid==fgKMinusCode){//Nothing special for kaons
307 return TMath::Sqrt(p*p + fgKaonMass*fgKaonMass) * TMath::Sin(theta);
3ce6b879 308 }
4b40b2b1 309 if(pid==fgEPlusCode || pid==fgEMinusCode){//Nothing special for electrons
310 return TMath::Sqrt(p*p + fgElectronMass*fgElectronMass) * TMath::Sin(theta);
3ce6b879 311 }
4b40b2b1 312 if(pid==fgProtonCode || pid==fgAntiProtonCode){//But for protons we must be careful...
3ce6b879 313 if(charge<0.0){//antiprotns: kinetic energy plus twice the rest mass
4b40b2b1 314 return (TMath::Sqrt(p*p + fgProtonMass*fgProtonMass) + fgProtonMass) * TMath::Sin(theta);
3ce6b879 315 }
316 if(charge>0.0){//antiprotns: kinetic energy only
4b40b2b1 317 return (TMath::Sqrt(p*p + fgProtonMass*fgProtonMass) - fgProtonMass) * TMath::Sin(theta);
3ce6b879 318 }
319 }
320 cerr<<"Uh-oh! Et not set properly!"<<endl;
321 return 0.0;
322}