coverity fix
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisHadEt.cxx
index 62f5dcc..e0cc8ef 100644 (file)
 using namespace std;
 
 ClassImp(AliAnalysisHadEt);
-//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
-Float_t AliAnalysisHadEt::fgPionMass = 0.13957;
-Float_t AliAnalysisHadEt::fgKaonMass = 0.493677;
-Float_t AliAnalysisHadEt::fgProtonMass = 0.938272;
-Float_t AliAnalysisHadEt::fgElectronMass = 0.000510999;
-Int_t AliAnalysisHadEt::fgPiPlusCode = 211;
-Int_t AliAnalysisHadEt::fgPiMinusCode = -211;
-Int_t AliAnalysisHadEt::fgKPlusCode = 321;
-Int_t AliAnalysisHadEt::fgKMinusCode = -321;
-Int_t AliAnalysisHadEt::fgProtonCode = 2212;
-Int_t AliAnalysisHadEt::fgAntiProtonCode = -2212;
-Int_t AliAnalysisHadEt::fgLambdaCode = 3122;
-Int_t AliAnalysisHadEt::fgAntiLambdaCode = -3122;
-Int_t AliAnalysisHadEt::fgK0SCode = 310;
-Int_t AliAnalysisHadEt::fgOmegaCode = 3334;
-Int_t AliAnalysisHadEt::fgAntiOmegaCode = -3334;
-Int_t AliAnalysisHadEt::fgXi0Code = 3322;
-Int_t AliAnalysisHadEt::fgAntiXi0Code = -3322;
-Int_t AliAnalysisHadEt::fgXiCode = 3312;
-Int_t AliAnalysisHadEt::fgAntiXiCode = -3312;
-Int_t AliAnalysisHadEt::fgSigmaCode = 3112;
-Int_t AliAnalysisHadEt::fgAntiSigmaCode = -3112;
-Int_t AliAnalysisHadEt::fgK0LCode = 130;
-Int_t AliAnalysisHadEt::fgNeutronCode = 2112;
-Int_t AliAnalysisHadEt::fgAntiNeutronCode = -2112;
-Int_t AliAnalysisHadEt::fgEPlusCode = -11;
-Int_t AliAnalysisHadEt::fgEMinusCode = 11;
-Int_t AliAnalysisHadEt::fgGammaCode = 22;
-Int_t AliAnalysisHadEt::fgPi0Code = 111;
-Int_t AliAnalysisHadEt::fgEtaCode = 221;
-Int_t AliAnalysisHadEt::fgOmega0Code = 223;
 
 
-// Int_t AliAnalysisHadEt::fgnumOfEtaBins = 46;
-// 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};
-//reduction in the number of bins
 Int_t AliAnalysisHadEt::fgnumOfEtaBins = 16;
 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};
 Int_t AliAnalysisHadEt::fgNumOfPtBins = 111;
@@ -75,36 +41,40 @@ Float_t AliAnalysisHadEt::fgPtAxis[117]=
   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,
    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,
    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,
-  20.0,25.0,30.0,35.0,40.0, 45.0, 50.0}; 
+  20.0,25.0,30.0,35.0,40.0, 45.0, 50.0};
+Float_t AliAnalysisHadEt::fgResAxis[81] = {-0.150,-0.140,-0.130,-0.120,-0.110,-0.100,-0.090,-0.080,-0.070,-0.060,
+                                          -0.050,-0.045,-0.040,-0.035,-0.030,-0.025,-0.024,-0.023,-0.022,-0.021,
+                                          -0.020,-0.019,-0.018,-0.017,-0.016,-0.015,-0.014,-0.013,-0.012,-0.011,
+                                          -0.010,-0.009,-0.008,-0.007,-0.006,-0.005,-0.004,-0.003,-0.002,-0.001,
+                                          -0.000,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,
+                                          0.010,0.011,0.012,0.013,0.014,0.015,0.016,0.017,0.018,0.019,
+                                          0.020,0.021,0.022,0.023,0.024,0.025,0.030,0.035,0.040,0.045,
+                                          0.050,0.060,0.070,0.080,0.090,0.100,0.110,0.120,0.130,0.140,
+                                          0.150,};
+// 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};
+Int_t AliAnalysisHadEt::fgNumOfResBins = 80;
 
-Float_t AliAnalysisHadEt::fgPtTPCCutOff = 0.15;
-Float_t AliAnalysisHadEt::fgPtITSCutOff = 0.10;
 
-AliAnalysisHadEt::AliAnalysisHadEt() :
-        fHistogramNameSuffix("")
-       ,fCuts(0)
-       ,fSumEt(0)
-       ,fSumEtAcc(0)
-       ,fTotEt(0)
-       ,fTotEtAcc(0)
-       ,fTotNeutralEt(0)
-       ,fTotNeutralEtAcc(0)
-       ,fTotChargedEt(0)
-       ,fTotChargedEtAcc(0)
-       ,fMultiplicity(0)
-       ,fChargedMultiplicity(0)
-       ,fNeutralMultiplicity(0)
-        ,fEsdtrackCutsITSTPC(0)
-        ,fEsdtrackCutsTPC(0)
-       ,fEsdtrackCutsITS(0)
-        ,fhistoList(0)
+AliAnalysisHadEt::AliAnalysisHadEt() : AliAnalysisEtCommon()
+                                    ,fSumEt(0)
+                                    ,fSumEtAcc(0)
+                                    ,fTotEt(0)
+                                    ,fTotEtAcc(0)
+                                    ,fTotNeutralEt(0)
+                                    ,fTotNeutralEtAcc(0)
+                                    ,fTotChargedEt(0)
+                                    ,fTotChargedEtAcc(0)
+                                    ,fMultiplicity(0)
+                                    ,fChargedMultiplicity(0)
+                                    ,fNeutralMultiplicity(0)
+                                    ,fhistoList(0)
+                                    ,fGoodEvent(0)
 {//default constructor
 
 }
 
 AliAnalysisHadEt::~AliAnalysisHadEt()
 {//destructor
-  delete fCuts;
   delete fEsdtrackCutsITSTPC;
   delete fEsdtrackCutsITS;
   delete fEsdtrackCutsTPC;
@@ -112,30 +82,20 @@ AliAnalysisHadEt::~AliAnalysisHadEt()
 
 Int_t AliAnalysisHadEt::AnalyseEvent(AliVEvent *event)
 { //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.
-  cout << "This event has " << event->GetNumberOfTracks() << " tracks" << endl;
+  AliAnalysisEtCommon::AnalyseEvent(event);
   ResetEventValues();
   return 0;
 }
 
-void AliAnalysisHadEt::FillOutputList()
-{//fill the output histogram list with histograms in all AliAnalysisHadEt's
-}
 
 void AliAnalysisHadEt::Init()
 {// clear variables, set up cuts and PDG info
-
-}
-
-void AliAnalysisHadEt::CreateHistograms()
-{//creates histograms included in all AliAnalysisHadEt's
-}
-
-void AliAnalysisHadEt::FillHistograms()
-{//Fills histograms filled for all AliAnalysisHadEt's
+  AliAnalysisEtCommon::Init();
 }
 
 void AliAnalysisHadEt::ResetEventValues()
 {//Resets event values of et to zero
+  AliAnalysisEtCommon::ResetEventValues();
   fTotEt = 0;
   fTotEtAcc = 0;
   fTotNeutralEt = 0;
@@ -146,19 +106,7 @@ void AliAnalysisHadEt::ResetEventValues()
   fChargedMultiplicity = 0;
   fNeutralMultiplicity = 0;
   
-  if (!fCuts) { // some Init's needed
-    cout << __FILE__ << ":" << __LINE__ << " : Init " << endl;
-    if (!fCuts) {
-      cout << " setting up Cuts " << endl;
-      fCuts = new AliAnalysisEtCuts();
-    }
-  }
 }
-
-void AliAnalysisHadEt::SetParticleCodes()
-{  //the codes are defined in $ROOTSYS/etc/pdg_table.txt
-}
-
 void AliAnalysisHadEt::CreateEtaPtHisto2D(TString name, TString title)
 {     //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
   TString *histoname   = new TString();
@@ -177,6 +125,42 @@ void AliAnalysisHadEt::CreateEtaPtHisto2D(TString name, TString title)
   delete histotitle;
     
 }
+void AliAnalysisHadEt::CreateResolutionPtHisto2D(TString name, TString title, TString xtitle, TString ytitle)
+{     //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
+  TString *histoname   = new TString();
+  TString *histotitle   = new TString();
+
+  histoname->Append(name);
+  histotitle->Append(title);
+
+  //TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgNumOfResBins, fgResAxis);
+  TH2F *histo = new TH2F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis, fgNumOfResBins, fgResAxis);
+  histo->SetYTitle(ytitle);
+  histo->SetXTitle(xtitle);
+  histo->SetZTitle("Number of entries");
+  histo->Sumw2();
+  fhistoList->Add(histo);
+  delete histoname;
+  delete histotitle;
+    
+}
+void AliAnalysisHadEt::CreatePtHisto1D(TString name, TString title, TString xtitle, TString ytitle)
+{     //creates a 2-d histogram in eta and phi and adds it to the list of histograms to be saved
+  TString *histoname   = new TString();
+  TString *histotitle   = new TString();
+
+  histoname->Append(name);
+  histotitle->Append(title);
+
+  TH1F *histo = new TH1F(histoname->Data(),histotitle->Data(),fgNumOfPtBins, fgPtAxis);
+  histo->SetYTitle(ytitle);
+  histo->SetXTitle(xtitle);
+  histo->Sumw2();
+  fhistoList->Add(histo);
+  delete histoname;
+  delete histotitle;
+    
+}
 
 void AliAnalysisHadEt::CreateHisto1D(TString name, TString title, TString xtitle, TString ytitle,Int_t xbins, Float_t xlow,Float_t xhigh)
 {     //creates a 1d histogram of the given dimensions and adds it to the list of histograms to be saved
@@ -300,23 +284,28 @@ Float_t AliAnalysisHadEt::Et(TParticle *part, float mass){//function to calculat
   return 0.0;
 }
 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
-  if(pid==fgPiPlusCode || pid==fgPiMinusCode){//Nothing special for pions
+  if(pid==AliAnalysisEtCommon::fgPiPlusCode || pid==AliAnalysisEtCommon::fgPiMinusCode){//Nothing special for pions
     return TMath::Sqrt(p*p + fgPionMass*fgPionMass) * TMath::Sin(theta);
   }
-  if(pid==fgKPlusCode || pid==fgKMinusCode){//Nothing special for kaons
-    return TMath::Sqrt(p*p + fgKaonMass*fgKaonMass) * TMath::Sin(theta);
+  if(pid==AliAnalysisEtCommon::fgKPlusCode || pid==AliAnalysisEtCommon::fgKMinusCode){//Nothing special for kaons
+    return TMath::Sqrt(p*p + AliAnalysisEtCommon::fgKaonMass*AliAnalysisEtCommon::fgKaonMass) * TMath::Sin(theta);
   }
-  if(pid==fgEPlusCode || pid==fgEMinusCode){//Nothing special for electrons
-    return TMath::Sqrt(p*p + fgElectronMass*fgElectronMass) * TMath::Sin(theta);
+  if(pid==AliAnalysisEtCommon::fgEPlusCode || pid==AliAnalysisEtCommon::fgEMinusCode){//Nothing special for electrons
+    return TMath::Sqrt(p*p + AliAnalysisEtCommon::fgElectronMass*AliAnalysisEtCommon::fgElectronMass) * TMath::Sin(theta);
   }
-  if(pid==fgProtonCode || pid==fgAntiProtonCode){//But for protons we must be careful...
+  if(pid==AliAnalysisEtCommon::fgProtonCode || pid==AliAnalysisEtCommon::fgAntiProtonCode){//But for protons we must be careful...
     if(charge<0.0){//antiprotns: kinetic energy plus twice the rest mass
-      return (TMath::Sqrt(p*p + fgProtonMass*fgProtonMass) + fgProtonMass) * TMath::Sin(theta);
+      return (TMath::Sqrt(p*p + AliAnalysisEtCommon::fgProtonMass*AliAnalysisEtCommon::fgProtonMass) + AliAnalysisEtCommon::fgProtonMass) * TMath::Sin(theta);
     }
     if(charge>0.0){//antiprotns: kinetic energy only
-      return (TMath::Sqrt(p*p + fgProtonMass*fgProtonMass) - fgProtonMass) * TMath::Sin(theta);
+      return (TMath::Sqrt(p*p + AliAnalysisEtCommon::fgProtonMass*AliAnalysisEtCommon::fgProtonMass) - AliAnalysisEtCommon::fgProtonMass) * TMath::Sin(theta);
     }
   }
-  cerr<<"Uh-oh!  Et not set properly!"<<endl;
+  //cerr<<"Uh-oh!  Et not set properly!"<<endl;
   return 0.0;
 }
+
+Float_t AliAnalysisHadEt::TrueP(float pTrec) const {
+  if(pTrec>1.0) return pTrec;
+  return pTrec/(1-599.334*pTrec+7285.15*pTrec*pTrec)+pTrec;
+}