]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPIDv1.cxx
Fixing coverity bugs
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPIDv1.cxx
index 5816f07b7aab3d59bf4bfa833f4c29774948c647..fda233fdc6f77570a66bae4f77f0114715a0d18c 100644 (file)
 #include "TPrincipal.h"
 #include "TFile.h" 
 #include "TSystem.h"
-#include "TVector3.h"
 
 // --- AliRoot header files ---
              //#include "AliLog.h"
@@ -161,7 +160,7 @@ AliPHOSPIDv1::AliPHOSPIDv1() :
   fPPhoton(0),
   fPPi0(0),
   fParameters(0),
-  fVtx(0.), 
+  fVtx(0.,0.,0.), 
   fTFphoton(0),
   fTFpiong(0),
   fTFkaong(0),
@@ -196,7 +195,7 @@ AliPHOSPIDv1::AliPHOSPIDv1(const AliPHOSPIDv1 & pid ) :
   fPPhoton(0),
   fPPi0(0),
   fParameters(0),
-  fVtx(0.), 
+  fVtx(0.,0.,0.), 
   fTFphoton(0),
   fTFpiong(0),
   fTFkaong(0),
@@ -231,7 +230,7 @@ AliPHOSPIDv1::AliPHOSPIDv1(AliPHOSGeometry *geom):
   fPPhoton(0),
   fPPi0(0),
   fParameters(0),
-  fVtx(0.), 
+  fVtx(0.,0.,0.), 
   fTFphoton(0),
   fTFpiong(0),
   fTFkaong(0),
@@ -474,7 +473,7 @@ void AliPHOSPIDv1::InitParameters()
   fERecWeight ->SetParameters(fERecWeightPar[0],fERecWeightPar[1] ,fERecWeightPar[2] ,fERecWeightPar[3]) ; 
 
 
-  for (Int_t i =0; i<  AliPID::kSPECIESN ; i++)
+  for (Int_t i =0; i<  AliPID::kSPECIESCN ; i++)
     fInitPID[i] = 1.;
  
 }
@@ -591,22 +590,6 @@ Float_t  AliPHOSPIDv1::GetParameterCalibration(Int_t i) const
   return param;
 }
 
-//____________________________________________________________________________
-Float_t  AliPHOSPIDv1::GetCalibratedEnergy(Float_t e) const
-{
-//      It calibrates Energy depending on the recpoint energy.
-//      The energy of the reconstructed cluster is corrected with 
-//      the formula A + B* E  + C* E^2, whose parameters where obtained 
-//      through the study of the reconstructed energy distribution of 
-//      monoenergetic photons.
-  Float_t p[]={0.,0.,0.};
-  for (Int_t i=0; i<3; i++) p[i] = GetParameterCalibration(i);
-  Float_t enerec = p[0] +  p[1]*e + p[2]*e*e;
-  return enerec ;
-
-}
-
 //____________________________________________________________________________
 Float_t  AliPHOSPIDv1::GetParameterCpv2Emc(Int_t i, TString axis) const 
 {
@@ -738,36 +721,6 @@ Float_t  AliPHOSPIDv1::GetParameterToCalculateEllipse(TString particle, TString
   
   return par;
 }
-
-
-//DP____________________________________________________________________________
-//Float_t  AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSCpvRecPoint * cpv, Option_t *  axis)const
-//{
-//  // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
-//  
-//  const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; 
-//  TVector3 vecEmc ;
-//  TVector3 vecCpv ;
-//  if(cpv){
-//    emc->GetLocalPosition(vecEmc) ;
-//    cpv->GetLocalPosition(vecCpv) ; 
-//    
-//    if(emc->GetPHOSMod() == cpv->GetPHOSMod()){      
-//      // Correct to difference in CPV and EMC position due to different distance to center.
-//      // we assume, that particle moves from center
-//      Float_t dCPV = geom->GetIPtoOuterCoverDistance();
-//      Float_t dEMC = geom->GetIPtoCrystalSurface() ;
-//      dEMC         = dEMC / dCPV ;
-//      vecCpv = dEMC * vecCpv  - vecEmc ; 
-//      if (axis == "X") return vecCpv.X();
-//      if (axis == "Y") return vecCpv.Y();
-//      if (axis == "Z") return vecCpv.Z();
-//      if (axis == "R") return vecCpv.Mag();
-//    }
-//    return 100000000 ;
-//  }
-//  return 100000000 ;
-//}
 //____________________________________________________________________________
 Int_t  AliPHOSPIDv1::GetCPVBit(AliPHOSTrackSegment * ts, Int_t effPur, Float_t e) const
 {
@@ -833,8 +786,7 @@ Int_t  AliPHOSPIDv1::GetHardPhotonBit(AliPHOSEmcRecPoint * emc) const
     TMath::Exp(-TMath::Power(e-GetParameterPhotonBoundary(1),2)/2.0/
                TMath::Power(GetParameterPhotonBoundary(2),2)) +
     GetParameterPhotonBoundary(3);
-  AliDebug(1, Form("GetHardPhotonBit","E=%f, m2x=%f, boundary=%f",
-                      e,m2x,m2xBoundary));
+  AliDebug(1, Form("E=%f, m2x=%f, boundary=%f", e,m2x,m2xBoundary));
   if (m2x < m2xBoundary)
     return 1;// A hard photon
   else
@@ -992,7 +944,7 @@ void  AliPHOSPIDv1::MakePID()
 {
   // construct the PID weight from a Bayesian Method
   
-  const Int_t kSPECIES = AliPID::kSPECIESN ;
+  const Int_t kSPECIES = AliPID::kSPECIESCN ;
  
   Int_t nparticles = fRecParticles->GetEntriesFast() ;
 
@@ -1010,8 +962,8 @@ void  AliPHOSPIDv1::MakePID()
   Double_t * sw  [kSPECIES] ;
   //Info("MakePID","Begin MakePID"); 
   
-  for (Int_t i =0; i< kSPECIES; i++){
-    stof[i] = new Double_t[nparticles] ;
+         for (Int_t i =0; i< kSPECIES; i++){
+           stof[i] = new Double_t[nparticles] ;
     sdp [i] = new Double_t[nparticles] ;
     scpv[i] = new Double_t[nparticles] ;
     sw  [i] = new Double_t[nparticles] ;
@@ -1034,7 +986,7 @@ void  AliPHOSPIDv1::MakePID()
 ////     track = ts->GetTrackIndex() ; //TPC tracks ?
     
     if (!emc) {
-      AliFatal(Form("-> emc(%d) = %d", ts->GetEmcIndex(), emc )) ;
+      AliFatal(Form("-> emc(%d)", ts->GetEmcIndex())) ;
     }
 
 
@@ -1043,10 +995,13 @@ void  AliPHOSPIDv1::MakePID()
     //    Info("MakePID", "TOF");
     Float_t  en   = emc->GetEnergy();    
     Double_t time = emc->GetTime() ;
-    //    cout<<">>>>>>>Energy "<<en<<"Time "<<time<<endl;
+    //      cout<<">>>>>>>Energy "<<en<<"Time "<<time<<endl;
    
     // now get the signals probability
     // s(pid) in the Bayesian formulation
+
+    //Initialize anused species
+    for(Int_t iii=0; iii<kSPECIES; iii++)stof[iii][index]=0. ;
     
     stof[AliPID::kPhoton][index]   = 1.; 
     stof[AliPID::kElectron][index] = 1.;
@@ -1105,6 +1060,8 @@ void  AliPHOSPIDv1::MakePID()
     //DP: still to be done 
 
     //dispersion is not well defined if the cluster is only in few crystals
+    //Initialize anused species
+    for(Int_t iii=0; iii<kSPECIES; iii++)sdp[iii][index]=0. ;
     
     sdp[AliPID::kPhoton][index]   = 1. ;
     sdp[AliPID::kElectron][index] = 1. ;
@@ -1169,6 +1126,8 @@ void  AliPHOSPIDv1::MakePID()
       }
     //    else
     //      cout<<">>>>>>>>>>>CHARGED>>>>>>>>>>>"<<endl;
+    //Initialize anused species
+    for(Int_t iii=0; iii<kSPECIES; iii++)scpv[iii][index]=0. ;
     
     scpv[AliPID::kPion][index]     =  pcpvcharged  ; 
     scpv[AliPID::kKaon][index]     =  pcpvcharged  ; 
@@ -1216,6 +1175,8 @@ void  AliPHOSPIDv1::MakePID()
     }
 
     //Weight to apply to hadrons due to energy reconstruction
+    //Initialize anused species
+    for(Int_t iii=0; iii<kSPECIES; iii++)sw[iii][index]=1. ;
 
     Float_t weight = fERecWeight ->Eval(en) ;
  
@@ -1363,12 +1324,12 @@ void  AliPHOSPIDv1::MakeRecParticles()
     // Choose the cluster energy range
     
     if (!emc) {
-      AliFatal(Form("-> emc(%d) = %d", ts->GetEmcIndex(), emc )) ;
+      AliFatal(Form("-> emc(%d)", ts->GetEmcIndex())) ;
     }
 
     Float_t e = emc->GetEnergy() ;   
     
-    Float_t  lambda[2] ;
+    Float_t  lambda[2]={0.,0.} ;
     emc->GetElipsAxis(lambda) ;
  
     if((lambda[0]>0.01) && (lambda[1]>0.01)){
@@ -1442,10 +1403,9 @@ void  AliPHOSPIDv1::MakeRecParticles()
       rp->SetPIDBit(14) ; 
 
     //Set momentum, energy and other parameters 
-    Float_t  encal = GetCalibratedEnergy(e);
     TVector3 dir   = GetMomentumDirection(emc,cpv) ; 
-    dir.SetMag(encal) ;
-    rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),encal) ;
+    dir.SetMag(e) ;
+    rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),e) ;
     rp->SetCalcMass(0);
     rp->Name(); //If photon sets the particle pdg name to gamma
     rp->SetProductionVertex(fVtx.X(),fVtx.Y(),fVtx.Z(),0);
@@ -1455,8 +1415,8 @@ void  AliPHOSPIDv1::MakeRecParticles()
     rp->SetLastDaughter(-1);
     rp->SetPolarisation(0,0,0);
     //Set the position in global coordinate system from the RecPoint
-    AliPHOSTrackSegment * ts  = static_cast<AliPHOSTrackSegment *>(fTrackSegments->At(rp->GetPHOSTSIndex()));
-    AliPHOSEmcRecPoint  * erp = static_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(ts->GetEmcIndex()));
+    AliPHOSTrackSegment * ts1  = static_cast<AliPHOSTrackSegment *>(fTrackSegments->At(rp->GetPHOSTSIndex()));
+    AliPHOSEmcRecPoint  * erp = static_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(ts1->GetEmcIndex()));
     TVector3 pos ; 
     fGeom->GetGlobalPHOS(erp, pos) ; 
     rp->SetPos(pos);
@@ -1566,7 +1526,7 @@ void  AliPHOSPIDv1::SetParameters()
           &(*fParameters)(i,0), &(*fParameters)(i,1), 
           &(*fParameters)(i,2), &(*fParameters)(i,3));
     i++;
-    AliDebug(1, Form("SetParameters", "line %d: %s",i,string));
+    AliDebug(1, Form("Line %d: %s",i,string));
   }
   fclose(fd);
 }
@@ -1681,10 +1641,10 @@ void AliPHOSPIDv1::GetVertex(void)
 //_______________________________________________________________________
 void AliPHOSPIDv1::SetInitPID(const Double_t *p) {
   // Sets values for the initial population of each particle type 
-  for (Int_t i=0; i<AliPID::kSPECIESN; i++) fInitPID[i] = p[i];
+  for (Int_t i=0; i<AliPID::kSPECIESCN; i++) fInitPID[i] = p[i];
 }
 //_______________________________________________________________________
 void AliPHOSPIDv1::GetInitPID(Double_t *p) const {
   // Gets values for the initial population of each particle type 
-  for (Int_t i=0; i<AliPID::kSPECIESN; i++) p[i] = fInitPID[i];
+  for (Int_t i=0; i<AliPID::kSPECIESCN; i++) p[i] = fInitPID[i];
 }