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