]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/AliAnalysisEtCommon.cxx
Transition PWG4/JetTasks -> PWGJE and PWG4/totET -> PWGLF/totET
[u/mrichter/AliRoot.git] / PWGLF / totEt / AliAnalysisEtCommon.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, AliAnalysisEtCommonMonteCarlo and 
9 // AliAnalysisEtCommonReconstructed which loop over either Monte Carlo data or 
10 // real data to get Et
11
12 #include "AliAnalysisEtCommon.h"
13 #include "TMath.h"
14 #include "TList.h"
15 #include "TH1F.h"
16 #include "TH2F.h"
17 #include "TF1.h"
18 #include <iostream>
19 #include "AliAnalysisEtCuts.h"
20 #include "AliMCEvent.h"
21 #include "AliVEvent.h"
22 #include "AliStack.h"
23 #include "AliESDtrackCuts.h"
24 #include "TDatabasePDG.h"
25 #include "TParticle.h"
26 #include "Rtypes.h"
27 #include "AliPDG.h"
28
29 using namespace std;
30
31 ClassImp(AliAnalysisEtCommon);
32 //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
33 //Cuts are defined in $ROOTSYS/etc/pdg_table.txt
34
35 Float_t AliAnalysisEtCommon::fgPionMass = 0.13957;
36 Float_t AliAnalysisEtCommon::fgKaonMass = 0.493677;
37 Float_t AliAnalysisEtCommon::fgProtonMass = 0.938272;
38 Float_t AliAnalysisEtCommon::fgElectronMass = 0.000510999;
39 Int_t AliAnalysisEtCommon::fgPiPlusCode = 211;
40 Int_t AliAnalysisEtCommon::fgPiMinusCode = -211;
41 Int_t AliAnalysisEtCommon::fgKPlusCode = 321;
42 Int_t AliAnalysisEtCommon::fgKMinusCode = -321;
43 Int_t AliAnalysisEtCommon::fgProtonCode = 2212;
44 Int_t AliAnalysisEtCommon::fgAntiProtonCode = -2212;
45 Int_t AliAnalysisEtCommon::fgLambdaCode = 3122;
46 Int_t AliAnalysisEtCommon::fgAntiLambdaCode = -3122;
47 Int_t AliAnalysisEtCommon::fgK0SCode = 310;
48 Int_t AliAnalysisEtCommon::fgOmegaCode = 3334;
49 Int_t AliAnalysisEtCommon::fgAntiOmegaCode = -3334;
50 Int_t AliAnalysisEtCommon::fgXi0Code = 3322;
51 Int_t AliAnalysisEtCommon::fgAntiXi0Code = -3322;
52 Int_t AliAnalysisEtCommon::fgXiCode = 3312;
53 Int_t AliAnalysisEtCommon::fgAntiXiCode = -3312;
54 Int_t AliAnalysisEtCommon::fgSigmaCode = 3112;
55 Int_t AliAnalysisEtCommon::fgAntiSigmaCode = -3112;
56 Int_t AliAnalysisEtCommon::fgK0LCode = 130;
57 Int_t AliAnalysisEtCommon::fgNeutronCode = 2112;
58 Int_t AliAnalysisEtCommon::fgAntiNeutronCode = -2112;
59 Int_t AliAnalysisEtCommon::fgEPlusCode = -11;
60 Int_t AliAnalysisEtCommon::fgEMinusCode = 11;
61 Int_t AliAnalysisEtCommon::fgMuPlusCode = -13;
62 Int_t AliAnalysisEtCommon::fgMuMinusCode = 13;
63 Int_t AliAnalysisEtCommon::fgGammaCode = 22;
64 Int_t AliAnalysisEtCommon::fgPi0Code = 111;
65 Int_t AliAnalysisEtCommon::fgEtaCode = 221;
66 Int_t AliAnalysisEtCommon::fgOmega0Code = 223;
67
68
69
70 Float_t AliAnalysisEtCommon::fgPtTPCCutOff = 0.15;
71 Float_t AliAnalysisEtCommon::fgPtITSCutOff = 0.10;
72
73 AliAnalysisEtCommon::AliAnalysisEtCommon() : TObject()
74                                            ,fHistogramNameSuffix("")
75                                            ,fCuts(0)
76                                            ,fDataSet(2010)
77                                            ,fV0ScaleDataSet(2010)
78                                            ,fEsdtrackCutsITSTPC(0)
79                                            ,fEsdtrackCutsTPC(0)
80                                            ,fEsdtrackCutsITS(0)
81                                            ,fK0PythiaD6T(0)
82                                            ,fLambdaPythiaD6T(0)
83                                            ,fAntiLambdaPythiaD6T(0)
84                                            ,fK0Data(0)
85                                            ,fLambdaData(0)
86                                            ,fAntiLambdaData(0)
87                                            ,fLambdaEnhancement(0)
88                                            ,fProtonEnhancement(0)
89                                            ,fCentralityMethod("V0M")
90                                            ,fNCentBins(21)
91                                            ,fCentBin(-1)
92 {//default constructor
93
94 }
95
96 AliAnalysisEtCommon::~AliAnalysisEtCommon()
97 {//destructor
98   delete fCuts;
99   delete fEsdtrackCutsITSTPC;
100   delete fEsdtrackCutsITS;
101   delete fEsdtrackCutsTPC;
102   delete fK0PythiaD6T;
103   delete fLambdaPythiaD6T;
104   delete fAntiLambdaPythiaD6T;
105   delete fK0Data;
106   delete fLambdaData;
107   delete fAntiLambdaData;
108   delete fLambdaEnhancement;
109   delete fProtonEnhancement;
110 }
111
112 Int_t AliAnalysisEtCommon::AnalyseEvent(AliVEvent */*event*/)
113 { //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.
114 //  cout << "This event has " << event->GetNumberOfTracks() << " tracks" << endl;
115   ResetEventValues();
116   return 0;
117 }
118
119
120 void AliAnalysisEtCommon::Init()
121 {// clear variables, set up cuts and PDG info
122   // LevyPt function described in LevyFitEvaluate below
123   //parameter 0 = dNdy
124   //parameter 1 = temp
125   //parameter 2 = power
126   if(fK0PythiaD6T) delete fK0PythiaD6T;
127   if(fLambdaPythiaD6T) delete fLambdaPythiaD6T;
128   if(fAntiLambdaPythiaD6T) delete fAntiLambdaPythiaD6T;
129   if(fK0Data) delete fK0Data;
130   if(fLambdaData) delete fLambdaData;
131   if(fAntiLambdaData) delete fAntiLambdaData;
132
133   fK0PythiaD6T = new TF1("K0PythiaD6T", LevyPtEvaluate, 0,50,4);
134   fLambdaPythiaD6T = new TF1("LambdaPythiaD6T", LevyPtEvaluate,0,50,4);
135   fAntiLambdaPythiaD6T = new TF1("AntiLambdaPythiaD6T", LevyPtEvaluate,0,50,4);
136   fK0Data = new TF1("K0Data", LevyPtEvaluate,0,50,4);
137   fLambdaData = new TF1("LambdaData", LevyPtEvaluate,0,50,4);
138   fAntiLambdaData = new TF1("AntiLambdaData", LevyPtEvaluate,0,50,4);
139
140   fK0PythiaD6T->FixParameter(3,0.493677);
141   fK0Data->FixParameter(3,0.493677);
142   fLambdaPythiaD6T->FixParameter(3,1.115683);
143   fAntiLambdaPythiaD6T->FixParameter(3,1.115683);
144   fLambdaData->FixParameter(3,1.115683);
145   fAntiLambdaData->FixParameter(3,1.115683);
146   if(fV0ScaleDataSet==2009){
147     //These data are from the ALICE 900 GeV p+p paper
148     //from email from Boris 10/31/10
149 //                              dN/dy                   Tlevy                   n                       <pt>     extra(%)       chi2/ndf
150 // K0S
151 // D6T-109      0.1437±0.0002    0.1497±0.0004   6.94±0.04       0.5765  14.24   162.5/24=6.8
152 // CSC-306      0.1938±0.0002    0.1363±0.0003   8.84±0.06       0.4950  16.80   1075.1/24=44.8
153 // P0-320               0.1395±0.0002    0.1440±0.0004   6.43±0.04       0.5778  14.56   387.0/24=16.1
154 // PHOJET               0.1967±0.0002    0.1292±0.0003   7.01±0.04       0.5115  16.90   1735.4/24=72.3
155
156 // Lambda
157 // D6T-109      0.0213±0.0001    0.1315±0.0011   4.60±0.05       0.7889  48.25   200.1/26=7.7
158 // CSC-306      0.0279±0.0001    0.1074±0.0007   5.71±0.07       0.6131  59.25   71.8/26=2.8
159 // P0-320               0.0161±0.0001    0.1125±0.0010   4.53±0.05       0.7126  53.61   171.1/26=6.6
160 // PHOJET               0.0190±0.0001    0.1013±0.0008   4.70±0.05       0.6469  58.14   162.2/26=6.2
161     //paper available at http://arxiv.org/pdf/1012.3257v2
162     //so that if I'm working at home and don't have library access I can read the paper...
163     //While all of these functions are labeled D6T, they are actually Perugia-0.  I did this to avoid the complication of renaming all of the variables.
164     fK0PythiaD6T->SetParameter(0,0.1395);
165     fK0PythiaD6T->SetParameter(1,0.1440);
166     fK0PythiaD6T->SetParameter(2,6.43);
167     fLambdaPythiaD6T->SetParameter(0,0.0161);
168     fLambdaPythiaD6T->SetParameter(1,0.1125);
169     fLambdaPythiaD6T->SetParameter(2,4.53);
170     fAntiLambdaPythiaD6T->SetParameter(0,0.0161);
171     fAntiLambdaPythiaD6T->SetParameter(1,0.1125);
172     fAntiLambdaPythiaD6T->SetParameter(2,4.53);
173     fK0Data->SetParameter(0,0.184);
174     fK0Data->SetParameter(1,0.168);
175     fK0Data->SetParameter(2,6.6);
176     fLambdaData->SetParameter(0,0.048);
177     fLambdaData->SetParameter(1,0.229);
178     fLambdaData->SetParameter(2,10.8);
179     fAntiLambdaData->SetParameter(0,0.047);
180     fAntiLambdaData->SetParameter(1,0.210);
181     fAntiLambdaData->SetParameter(2,9.2);
182   }
183   if(fV0ScaleDataSet==2010 ||fV0ScaleDataSet==20100 ||fV0ScaleDataSet==20111){
184     //These data are from the CMS analysis note on 7 TeV spectra
185     //http://cdsweb.cern.ch/record/1279344/files/QCD-10-007-pas.pdf
186     //Note the CMS parameterization of the Levy function differs from the ALICE parameterization by a constant.
187     //CMS does not list the overall constant in their fit, the ratios of the dN/dy(y=0) is used.
188     //While all of these functions are labeled D6T, they are actually Perugia-0.  I did this to avoid the complication of renaming all of the variables.
189     fK0PythiaD6T->SetParameter(0,0.72);//K0S in CMS analysis note Fig. 10 - Perugia 0 and D6T level comparable
190     fK0PythiaD6T->SetParameter(1,0.168);
191     fK0PythiaD6T->SetParameter(2,5.39);
192     fLambdaPythiaD6T->SetParameter(0,0.54/1.12);//from looking at the difference in lambdas in Perugia 0 and D6T in fig. 10
193     fLambdaPythiaD6T->SetParameter(1,0.163);
194     fLambdaPythiaD6T->SetParameter(2,4.64);
195     fAntiLambdaPythiaD6T->SetParameter(0,0.54/1.12);//
196     fAntiLambdaPythiaD6T->SetParameter(1,0.163);
197     fAntiLambdaPythiaD6T->SetParameter(2,4.64);
198 //     fK0PythiaD6T->SetParameter(0,0.72);
199 //     fK0PythiaD6T->SetParameter(1,0.183);
200 //     fK0PythiaD6T->SetParameter(2,5.71);
201 //     fLambdaPythiaD6T->SetParameter(0,0.54);
202 //     fLambdaPythiaD6T->SetParameter(1,0.216);
203 //     fLambdaPythiaD6T->SetParameter(2,5.11);
204 //     fAntiLambdaPythiaD6T->SetParameter(0,0.54);
205 //     fAntiLambdaPythiaD6T->SetParameter(1,0.216);
206 //     fAntiLambdaPythiaD6T->SetParameter(2,5.11);
207     fK0Data->SetParameter(0,1.0);
208     fK0Data->SetParameter(1,0.215);
209     fK0Data->SetParameter(2,6.79);
210     fLambdaData->SetParameter(0,1.0);
211     fLambdaData->SetParameter(1,0.290);
212     fLambdaData->SetParameter(2,9.28);
213     fAntiLambdaData->SetParameter(0,1.0);
214     fAntiLambdaData->SetParameter(1,0.290);
215     fAntiLambdaData->SetParameter(2,9.28);
216   }
217   if(fLambdaEnhancement) delete fLambdaEnhancement;
218   fLambdaEnhancement = new TF1("fLambdaEnhancement","([0]*pow(x,[1])*exp(-pow(x/[2],[3])))/([4]*exp(-pow([5]/x,[6]))+[7]*x)",0,50);
219    fLambdaEnhancement->SetParameter(0,0.5630487);
220    fLambdaEnhancement->SetParameter(1,1.388818);
221    fLambdaEnhancement->SetParameter(2,3.954147);
222    fLambdaEnhancement->SetParameter(3,3.443772);
223    fLambdaEnhancement->SetParameter(4,2.844288);
224    fLambdaEnhancement->SetParameter(5,2);
225    fLambdaEnhancement->SetParameter(6,0.4747893);
226    fLambdaEnhancement->SetParameter(7,-0.2250856);
227    if(fProtonEnhancement) delete fProtonEnhancement;
228    fProtonEnhancement = new TF1("fProtonEnhancement","[0]*pow(x,[1])*exp(-pow(x/[2],[3]))/([4]+[5]*x)",0,50);
229    fProtonEnhancement->SetParameter(0,0.5630487*1.6);
230    fProtonEnhancement->SetParameter(1,1.388818);
231    fProtonEnhancement->SetParameter(2,3.954147/1.5);
232    fProtonEnhancement->SetParameter(3,3.443772/2.5);
233    fProtonEnhancement->SetParameter(4,0.5);
234    fProtonEnhancement->SetParameter(5,-.03);
235 }
236
237 void AliAnalysisEtCommon::ResetEventValues()
238 {//Resets event values of et to zero
239   
240   if (!fCuts) { // some Init's needed
241     cout << __FILE__ << ":" << __LINE__ << " : Init " << endl;
242     if (!fCuts) {
243       cout << " setting up Cuts " << endl;
244       fCuts = new AliAnalysisEtCuts();
245     }
246   }
247 }
248
249 Double_t AliAnalysisEtCommon::LevyPtEvaluate(const Double_t *pt, 
250                                              const Double_t *par) 
251 {//LevyPt function for TF1's
252   
253   Double_t lMass  = par[3];
254   Double_t ldNdy  = par[0];
255   Double_t l2pi   = 2*TMath::Pi();
256   Double_t lTemp = par[1];
257   Double_t lPower = par[2];
258   
259   Double_t lBigCoef = ((lPower-1)*(lPower-2)) / (l2pi*lPower*lTemp*(lPower*lTemp+lMass*(lPower-2)));
260   Double_t lInPower = 1 + (TMath::Sqrt(pt[0]*pt[0]+lMass*lMass)-lMass) / (lPower*lTemp);
261   
262   return ldNdy * pt[0] * lBigCoef * TMath::Power(lInPower,(-1)*lPower);
263 }
264
265
266 Float_t AliAnalysisEtCommon::Et(TParticle *part, float mass){//function to calculate et in the same way as it would be calculated in a calorimeter
267   if(mass+1000<0.01){//if no mass given return default.  The default argument is -1000
268     if(TMath::Abs(part->GetPDG(0)->PdgCode())==2212 || TMath::Abs(part->GetPDG(0)->PdgCode())==2112){
269       if(part->GetPDG(0)->PdgCode()==-2212 || part->GetPDG(0)->PdgCode()==-2112){//antiproton or antineutron
270         //for antinucleons we specifically want to return the kinetic energy plus twice the rest mass
271         return (part->Energy()+part->GetMass())*TMath::Sin(part->Theta());
272       }
273       if(part->GetPDG(0)->PdgCode()==2212 || part->GetPDG(0)->PdgCode()==2112){//proton or neutron
274         //for nucleons we specifically want to return the kinetic energy only
275         return (part->Energy()-part->GetMass())*TMath::Sin(part->Theta());
276       }
277     }
278     else{//otherwise go to the default
279       return part->Energy()*TMath::Sin(part->Theta());
280     }
281   }
282   else{//otherwise use the mass that was given
283     return (TMath::Sqrt(TMath::Power(part->P(),2.0)+TMath::Power(mass,2.0)))*TMath::Sin(part->Theta());
284   }
285   return 0.0;
286 }
287 Float_t AliAnalysisEtCommon::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
288   if(pid==fgPiPlusCode || pid==fgPiMinusCode){//Nothing special for pions
289     return TMath::Sqrt(p*p + fgPionMass*fgPionMass) * TMath::Sin(theta);
290   }
291   if(pid==fgKPlusCode || pid==fgKMinusCode){//Nothing special for kaons
292     return TMath::Sqrt(p*p + fgKaonMass*fgKaonMass) * TMath::Sin(theta);
293   }
294   if(pid==fgEPlusCode || pid==fgEMinusCode){//Nothing special for electrons
295     return TMath::Sqrt(p*p + fgElectronMass*fgElectronMass) * TMath::Sin(theta);
296   }
297   if(pid==fgProtonCode || pid==fgAntiProtonCode){//But for protons we must be careful...
298     if(charge<0.0){//antiprotns: kinetic energy plus twice the rest mass
299       return (TMath::Sqrt(p*p + fgProtonMass*fgProtonMass) + fgProtonMass) * TMath::Sin(theta);
300     }
301     if(charge>0.0){//antiprotns: kinetic energy only
302       return (TMath::Sqrt(p*p + fgProtonMass*fgProtonMass) - fgProtonMass) * TMath::Sin(theta);
303     }
304   }
305   cerr<<"Uh-oh!  Et not set properly!"<<endl;
306   return 0.0;
307 }
308
309 Float_t AliAnalysisEtCommon::K0Weight(Float_t pt){
310   Float_t data = fK0Data->Eval(pt);
311   Float_t mc = fK0PythiaD6T->Eval(pt);
312   return data/mc;
313 }
314 Float_t AliAnalysisEtCommon::LambdaWeight(Float_t pt){
315   Float_t data = fLambdaData->Eval(pt);
316   Float_t mc = fLambdaPythiaD6T->Eval(pt);
317   return data/mc;
318 }
319 Float_t AliAnalysisEtCommon::AntiLambdaWeight(Float_t pt){
320   Float_t data = fAntiLambdaData->Eval(pt);
321   Float_t mc = fAntiLambdaPythiaD6T->Eval(pt);
322   return data/mc;
323 }
324
325 Float_t AliAnalysisEtCommon::LambdaBaryonEnhancement(Float_t pt){
326   if(pt<0.8) return 1.0;
327   return fLambdaEnhancement->Eval(pt);
328 };//Function which gives the factor to reweigh a lambda or antilambda so it roughly matches baryon enhancement seen at RHIC
329 Float_t AliAnalysisEtCommon::ProtonBaryonEnhancement(Float_t pt){
330   if(pt<0.8) return 1.0;
331   return fProtonEnhancement->Eval(pt);
332 }//Function which gives the factor to reweigh a lambda or antilambda so it roughly matches baryon enhancement seen at RHIC