]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/totEt/AliAnalysisHadEt.cxx
Adding common base class for AliAnalysisEt and AliAnalysisHadEt so we are not repeati...
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisHadEt.cxx
1 //Created by Christine Nattrass, Rebecca Scott, Irakli Martashvili
2 //University of Tennessee at Knoxville
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
11
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"
19 #include "AliMCEvent.h"
20 #include "AliVEvent.h"
21 #include "AliStack.h"
22 #include "AliESDtrackCuts.h"
23 #include "TDatabasePDG.h"
24 #include "TParticle.h"
25 #include "Rtypes.h"
26 #include "AliPDG.h"
27
28 using namespace std;
29
30 ClassImp(AliAnalysisHadEt);
31
32
33 Int_t AliAnalysisHadEt::fgnumOfEtaBins = 16;
34 Float_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};
35 Int_t AliAnalysisHadEt::fgNumOfPtBins = 111;
36 Float_t AliAnalysisHadEt::fgPtAxis[117]=
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,
44   20.0,25.0,30.0,35.0,40.0, 45.0, 50.0}; 
45
46
47 AliAnalysisHadEt::AliAnalysisHadEt() : AliAnalysisEtCommon()
48                                      ,fHistogramNameSuffix("")
49                                      ,fSumEt(0)
50                                      ,fSumEtAcc(0)
51                                      ,fTotEt(0)
52                                      ,fTotEtAcc(0)
53                                      ,fTotNeutralEt(0)
54                                      ,fTotNeutralEtAcc(0)
55                                      ,fTotChargedEt(0)
56                                      ,fTotChargedEtAcc(0)
57                                      ,fMultiplicity(0)
58                                      ,fChargedMultiplicity(0)
59                                      ,fNeutralMultiplicity(0)
60                                      ,fhistoList(0)
61 {//default constructor
62
63 }
64
65 AliAnalysisHadEt::~AliAnalysisHadEt()
66 {//destructor
67   delete fEsdtrackCutsITSTPC;
68   delete fEsdtrackCutsITS;
69   delete fEsdtrackCutsTPC;
70 }
71
72 Int_t AliAnalysisHadEt::AnalyseEvent(AliVEvent *event)
73 { //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.
74   AliAnalysisEtCommon::AnalyseEvent(event);
75   ResetEventValues();
76   return 0;
77 }
78
79
80 void AliAnalysisHadEt::Init()
81 {// clear variables, set up cuts and PDG info
82   AliAnalysisEtCommon::Init();
83 }
84
85 void AliAnalysisHadEt::ResetEventValues()
86 {//Resets event values of et to zero
87   AliAnalysisEtCommon::ResetEventValues();
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;
97   
98 }
99 void AliAnalysisHadEt::CreateEtaPtHisto2D(TString name, TString title)
100 {     //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
101   TString *histoname   = new TString();
102   TString *histotitle   = new TString();
103
104   histoname->Append(name);
105   histotitle->Append(title);
106
107   TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgnumOfEtaBins, fgEtaAxis);
108   histo->SetYTitle("#eta");
109   histo->SetXTitle("p_{T}");
110   histo->SetZTitle("E_{T}");
111   histo->Sumw2();
112   fhistoList->Add(histo);
113   delete histoname;
114   delete histotitle;
115     
116 }
117
118 void AliAnalysisHadEt::CreateHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Float_t xlow,Float_t xhigh)
119 {     //creates a 1d histogram of the given dimensions and adds it to the list of histograms to be saved
120   TString *histoname   = new TString();
121   TString *histotitle   = new TString();
122   histoname->Append(name);
123   histotitle->Append(title);
124   TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh);
125   histo->SetYTitle(ytitle);
126   histo->SetXTitle(xtitle);
127   histo->Sumw2();
128   fhistoList->Add(histo);
129   delete histoname;
130   delete histotitle;
131 }
132 void AliAnalysisHadEt::CreateIntHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Int_t xlow,Int_t xhigh)
133 {     //creates a 1d integer histogram and adds it to the list of histograms to be saved
134   TString *histoname   = new TString();
135   TString *histotitle   = new TString();
136   histoname->Append(name);
137   histotitle->Append(title);
138   TH1I *histo = new TH1I(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh);
139   histo->SetYTitle(ytitle);
140   histo->SetXTitle(xtitle);
141   histo->Sumw2();
142   fhistoList->Add(histo);
143   delete histoname;
144   delete histotitle;
145     
146 }
147 void 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)
148 {     //creates a 2d histogram and adds it to the list of histograms to be saved
149   TString *histoname   = new TString();
150   TString *histotitle   = new TString();
151   histoname->Append(name);
152   histotitle->Append(title);
153   TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh,ybins,ylow,yhigh);
154   histo->SetYTitle(ytitle);
155   histo->SetXTitle(xtitle);
156   histo->Sumw2();
157   fhistoList->Add(histo);
158   delete histoname;
159   delete histotitle;
160     
161 }
162 void 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)
163 {     //creates a 2-d integer histogram and adds it to the list of histograms to be saved
164   TString *histoname   = new TString();
165   TString *histotitle   = new TString();
166   histoname->Append(name);
167   histotitle->Append(title);
168   TH2I *histo = new TH2I(histoname->Data(),histotitle->Data(),xbins,xlow,xhigh,ybins,ylow,yhigh);
169   histo->SetYTitle(ytitle);
170   histo->SetXTitle(xtitle);
171   histo->Sumw2();
172   fhistoList->Add(histo);
173   delete histoname;
174   delete histotitle;
175     
176 }
177
178 void AliAnalysisHadEt::CreateEtaHisto1D(TString name, TString title)
179 {     //creates 1d histogram in eta and adds it to the list of histograms to be saved
180   TString *histoname   = new TString();
181   TString *histotitle   = new TString();
182   histoname->Append(name);
183   histotitle->Append(title);
184   TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),fgnumOfEtaBins, fgEtaAxis);
185   histo->SetYTitle("E_{T}");
186   histo->SetXTitle("#eta");
187   histo->Sumw2();
188   fhistoList->Add(histo);
189   delete histoname;
190   delete histotitle;
191 }
192 void AliAnalysisHadEt::FillHisto1D(TString histname, Float_t x, Float_t weight)
193 {//fills a 1d histogram with the name histoname with the value x and the weight "weight"
194   TH1F     *histo; 
195   TString  *name   = new TString();
196   name->Append(histname);       
197   histo = (TH1F *)fhistoList->FindObject(name->Data()); 
198   if(histo){
199     histo->Fill((Double_t)x, weight);
200   }
201   else{cerr<<"CorrelationMaker::FillHisto1D: no histogram "<< name->Data()<<endl;}
202   delete name;
203 }
204 void AliAnalysisHadEt::FillHisto2D(TString histname, Float_t x, Float_t y, Float_t weight)
205 {//fills a 2d histogram with the name histoname with the value x and the weight "weight"
206   TH2F     *histo; 
207   TString  *name   = new TString();
208   name->Append(histname);       
209   histo = (TH2F *)fhistoList->FindObject(name->Data()); 
210   if(histo){
211     histo->Fill((Double_t)x,(Double_t)y, weight);
212   }
213   else{cerr<<"CorrelationMaker::FillHisto2D: no histogram "<< name->Data()<<endl;}
214   delete name;
215 }
216
217
218 Float_t AliAnalysisHadEt::Et(TParticle *part, float mass){//function to calculate et in the same way as it would be calculated in a calorimeter
219   if(mass+1000<0.01){//if no mass given return default.  The default argument is -1000
220     if(TMath::Abs(part->GetPDG(0)->PdgCode())==2212 || TMath::Abs(part->GetPDG(0)->PdgCode())==2112){
221       if(part->GetPDG(0)->PdgCode()==-2212 || part->GetPDG(0)->PdgCode()==-2112){//antiproton or antineutron
222         //for antinucleons we specifically want to return the kinetic energy plus twice the rest mass
223         return (part->Energy()+part->GetMass())*TMath::Sin(part->Theta());
224       }
225       if(part->GetPDG(0)->PdgCode()==2212 || part->GetPDG(0)->PdgCode()==2112){//proton or neutron
226         //for nucleons we specifically want to return the kinetic energy only
227         return (part->Energy()-part->GetMass())*TMath::Sin(part->Theta());
228       }
229     }
230     else{//otherwise go to the default
231       return part->Energy()*TMath::Sin(part->Theta());
232     }
233   }
234   else{//otherwise use the mass that was given
235     return (TMath::Sqrt(TMath::Power(part->P(),2.0)+TMath::Power(mass,2.0)))*TMath::Sin(part->Theta());
236   }
237   return 0.0;
238 }
239 Float_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
240   if(pid==AliAnalysisEtCommon::fgPiPlusCode || pid==AliAnalysisEtCommon::fgPiMinusCode){//Nothing special for pions
241     return TMath::Sqrt(p*p + fgPionMass*fgPionMass) * TMath::Sin(theta);
242   }
243   if(pid==AliAnalysisEtCommon::fgKPlusCode || pid==AliAnalysisEtCommon::fgKMinusCode){//Nothing special for kaons
244     return TMath::Sqrt(p*p + AliAnalysisEtCommon::fgKaonMass*AliAnalysisEtCommon::fgKaonMass) * TMath::Sin(theta);
245   }
246   if(pid==AliAnalysisEtCommon::fgEPlusCode || pid==AliAnalysisEtCommon::fgEMinusCode){//Nothing special for electrons
247     return TMath::Sqrt(p*p + AliAnalysisEtCommon::fgElectronMass*AliAnalysisEtCommon::fgElectronMass) * TMath::Sin(theta);
248   }
249   if(pid==AliAnalysisEtCommon::fgProtonCode || pid==AliAnalysisEtCommon::fgAntiProtonCode){//But for protons we must be careful...
250     if(charge<0.0){//antiprotns: kinetic energy plus twice the rest mass
251       return (TMath::Sqrt(p*p + AliAnalysisEtCommon::fgProtonMass*AliAnalysisEtCommon::fgProtonMass) + AliAnalysisEtCommon::fgProtonMass) * TMath::Sin(theta);
252     }
253     if(charge>0.0){//antiprotns: kinetic energy only
254       return (TMath::Sqrt(p*p + AliAnalysisEtCommon::fgProtonMass*AliAnalysisEtCommon::fgProtonMass) - AliAnalysisEtCommon::fgProtonMass) * TMath::Sin(theta);
255     }
256   }
257   cerr<<"Uh-oh!  Et not set properly!"<<endl;
258   return 0.0;
259 }
260