]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRecCpvManager.cxx
Fixes for Coverity defects
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecCpvManager.cxx
index 8a59b994f2a55fba8ab2071e539388f2cec5ae45..7aea3603f1f5e86c4e2541bcea27d744e3d5e85f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
 
 //_________________________________________________________________________
 // Class for the management by the CPV reconstruction.
-//                  
+////                  
 //*-- Author   : Boris Polichtchouk (IHEP, Protvino) 6 Mar 2001
 //
 // --- ROOT system ---
 
-// --- Standard library ---
+#include <TMath.h>
 
-#include <iostream.h>
+// --- Standard library ---
 
 // --- AliRoot header files ---
 
 #include "AliPHOSRecCpvManager.h"
-#include "AliPHOS.h"
-#include "AliRun.h"
-#include "AliPHOSGetter.h"
+#include "AliPHOSGeometry.h" 
 
 ClassImp(AliPHOSRecCpvManager) 
 
 //____________________________________________________________________________
-
-  AliPHOSRecCpvManager::AliPHOSRecCpvManager()
+AliPHOSRecCpvManager::AliPHOSRecCpvManager() :
+  fOneGamChisqCut(3.),
+  fOneGamInitialStep(0.00005),
+  fOneGamChisqMin(1.),
+  fOneGamStepMin(0.0005),
+  fOneGamNumOfIterations(50),
+  fTwoGamInitialStep(0.00005),
+  fTwoGamChisqMin(1.),
+  fTwoGamEmin(0.1),
+  fTwoGamStepMin(0.00005),
+  fTwoGamNumOfIterations(50),  
+  fThr0(0.),
+  fSqdCut(0.) 
 {
-
-  fOneGamChisqCut = 3.; // If Chi2/dof > fOneGamChisqCut, split point.
-
-  fOneGamInitialStep = 0.00005;
-  fOneGamChisqMin = 1.;
-  fOneGamStepMin = 0.0005;
-  fOneGamNumOfIterations = 50;
-
-  fTwoGamInitialStep = 0.00005;
-  fTwoGamChisqMin = 1.;
-  fTwoGamEmin = 0.1;
-  fTwoGamStepMin = 0.00005;
-  fTwoGamNumOfIterations = 50;  
-
-//    fThr0 = 0.0285; // Min. energy of rec. point. If E<fThr0, point deleted.
-//    fSqdCut = 3.; // Min. distance (in cm) between two rec points.
-
-  fThr0 = 0.; 
-  fSqdCut = 0.; 
-  
+  // Put a comment here
   SetTitle("Cpv Reconstruction Manager");
 }
 
-AliPHOSRecCpvManager::~AliPHOSRecCpvManager(void) {}
+AliPHOSRecCpvManager::~AliPHOSRecCpvManager(void) 
+{
+  // Put a comment here
+}
 
-Float_t AliPHOSRecCpvManager::Dispersion(Float_t Etot, Float_t Ai, Float_t Ei)
+Float_t AliPHOSRecCpvManager::Dispersion(Float_t etot, Float_t ai) const
 {
   //"Dispresion" of energy deposition in the cell.
-  // Etot is the total shower energy, Ai is the
+  // etot is the total shower energy, ai is the
   // calculated cell response,
-  // Ei is the measured cell response.
+  // ei is the measured cell response.
 
-  const Float_t Const = 1.5;
-  return Const*Ai*(1.-Ai/Etot);
+  const Float_t kConst = 1.5;
+  return kConst*ai*(1.-ai/etot);
 }
 
-Float_t AliPHOSRecCpvManager::OneGamChi2(Float_t Ai, Float_t Ei, Float_t Etot, Float_t& Gi)
+Float_t AliPHOSRecCpvManager::OneGamChi2(Float_t ai, Float_t ei, Float_t etot, Float_t& Gi) const
 {
   //"Chi2" for one cell.
-  // Etot is the total "shower" energy, Ai is the
+  // etot is the total "shower" energy, ai is the
   // calculated cell response,
-  // Ei is the measured cell response.
+  // ei is the measured cell response.
 
-  const Float_t Const = 1.5;
+  const Float_t kConst = 1.5;
 
-  Float_t da = Ai - Ei;
-  Float_t D = Const*Ai*(1.-Ai/Etot);
+  Float_t da = ai - ei;
+  Float_t d = kConst*ai*(1.-ai/etot);
 
-  Float_t dd = da/D;
-  Gi = dd*(2.- dd*Const*(1.-2.*Ai/Etot));
+  Float_t dd = da/d;
+  Gi = dd*(2.- dd*kConst*(1.-2.*ai/etot));
 
-  cout<<" OneGamChi2 (Ai,Ei,Etot,&Gi,chi2) "<<Ai<<" "<<Ei<<" "<<Etot<<" "<<Gi<<" "<<da*da/D<<endl<<endl;
+  Info("OneGamChi2", " OneGamChi2 (ai,ei,etot,&Gi,chi2) %f %f %f %f %f", ai, ei, etot, Gi, da*da/d );
 
-  return da*da/D;
+  return da*da/d;
 
 }
 
-Float_t AliPHOSRecCpvManager::TwoGamChi2(Float_t Ai, Float_t Ei, Float_t Etot, Float_t& Gi)
+Float_t AliPHOSRecCpvManager::TwoGamChi2(Float_t ai, Float_t ei, Float_t etot, Float_t& gi) const 
 {
+  // Put a comment here
 
-  const Float_t Const = 1.5;
+  const Float_t kConst = 1.5;
 
-  Float_t da = Ai - Ei;
-  Float_t D = Const*Ai*(1.-Ai/Etot);
+  Float_t da = ai - ei;
+  Float_t d = kConst*ai*(1.-ai/etot);
 
-  Float_t dd = da/D;
-  Gi = dd*(2.- dd*Const*(1.-2.*Ai/Etot));
+  Float_t dd = da/d;
+  gi = dd*(2.- dd*kConst*(1.-2.*ai/etot));
 
-  return da*da/D;
+  return da*da/d;
  
 }
 
-void AliPHOSRecCpvManager::AG(Float_t Ei, Float_t Xi, Float_t Yi, Float_t& Ai, Float_t& GXi, Float_t& GYi )
+void AliPHOSRecCpvManager::AG(Float_t ei, Float_t xi, Float_t yi, Float_t& ai, Float_t& gxi, Float_t& gyi )
 {
-  //Calculates amplitude (Ai) and gradients (GXi, GYi) of CPV pad response.
-  //Integrated response (total "shower energy") is E
-  //Xi and Yi are the distances along x and y from reference point 
+  //Calculates amplitude (ai) and gradients (gxi, gyi) of CPV pad response.
+  //Integrated response (total "shower energy") is e
+  //xi and yi are the distances along x and y from reference point 
   // to the pad center.
 
-  AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
-  const AliPHOSGeometry* geom = gime->PHOSGeometry();
-  Float_t CelZ = geom->GetPadSizeZ();
-  Float_t CelY = geom->GetPadSizePhi();
+  AliPHOSGeometry * geom =  AliPHOSGeometry::GetInstance() ;
+
+  Float_t celZ = geom->GetPadSizeZ();
+  Float_t celY = geom->GetPadSizePhi();
 
-//  //    cout<<"CelZ: "<<CelZ<<" CelY: "<<CelY<<endl;
+//  //    Info("AG", "celZ: %f celY: %f", celZ, celY) ;
 
-  Float_t dx = CelZ/2.;
-  Float_t dy = CelY/2.;
+  Float_t dx = celZ/2.;
+  Float_t dy = celY/2.;
 
-//  //    Float_t x = Xi*CelZ;
-//  //    Float_t y = Yi*CelZ;
+//  //    Float_t x = xi*celZ;
+//  //    Float_t y = yi*celZ;
 
-  Float_t x = Xi*CelZ;
-  Float_t y = Yi*CelY;
+  Float_t x = xi*celZ;
+  Float_t y = yi*celY;
 
-  Float_t E = Ei;
+  Float_t e = ei;
 
-  Float_t A = Fcml(x+dx,y+dy) - Fcml(x+dx,y-dy) - Fcml(x-dx,y+dy) + Fcml(x-dx,y-dy);
-  Ai = A*E;
+  Float_t a = Fcml(x+dx,y+dy) - Fcml(x+dx,y-dy) - Fcml(x-dx,y+dy) + Fcml(x-dx,y-dy);
+  ai = a*e;
 
 
-  Float_t Gx = GradX(x+dx,y+dy) - GradX(x+dx,y-dy) - GradX(x-dx,y+dy) + GradX(x-dx,y-dy);
-  GXi = Gx*E*E;
+  Float_t gx = GradX(x+dx,y+dy) - GradX(x+dx,y-dy) - GradX(x-dx,y+dy) + GradX(x-dx,y-dy);
+  gxi = gx*e*e;
 
-  Float_t Gy = GradY(x+dx,y+dy) - GradY(x+dx,y-dy) - GradY(x-dx,y+dy) + GradY(x-dx,y-dy);
-  GYi = Gy*E*E;
+  Float_t gy = GradY(x+dx,y+dy) - GradY(x+dx,y-dy) - GradY(x-dx,y+dy) + GradY(x-dx,y-dy);
+  gyi = gy*e*e;
 
 }
 
@@ -151,56 +146,67 @@ Float_t AliPHOSRecCpvManager::Fcml(Float_t x, Float_t y)
 {
   //Cumulative function
 
-  const Float_t A = 1.0;
-  const Float_t b = 0.70;
+  const Float_t ka = 1.0;
+  const Float_t kb = 0.70;
 
-  Float_t Fff  = TMath::ATan(x*y/(  b*TMath::Sqrt(  (b*b) + x*x+y*y)))
-    - TMath::ATan(x*y/(3*b*TMath::Sqrt((3*b)*(3*b) + x*x+y*y)))
-    + TMath::ATan(x*y/(5*b*TMath::Sqrt((5*b)*(5*b) + x*x+y*y))) 
-    - TMath::ATan(x*y/(7*b*TMath::Sqrt((7*b)*(7*b) + x*x+y*y)))
-    + TMath::ATan(x*y/(9*b*TMath::Sqrt((9*b)*(9*b) + x*x+y*y))); 
+  Float_t fff  = TMath::ATan(x*y/(  kb*TMath::Sqrt(  (kb*kb) + x*x+y*y)))
+    - TMath::ATan(x*y/(3*kb*TMath::Sqrt((3*kb)*(3*kb) + x*x+y*y)))
+    + TMath::ATan(x*y/(5*kb*TMath::Sqrt((5*kb)*(5*kb) + x*x+y*y))) 
+    - TMath::ATan(x*y/(7*kb*TMath::Sqrt((7*kb)*(7*kb) + x*x+y*y)))
+    + TMath::ATan(x*y/(9*kb*TMath::Sqrt((9*kb)*(9*kb) + x*x+y*y))); 
   
-  Float_t Fcml = A*Fff/6.2831853071796;
-//    cout<<" Fcml: "<<Fcml<<endl;
-  return Fcml;
+  Float_t fcml = ka*fff/TMath::TwoPi();
+//    Info("Fcml", "fcml: %f", fcml) ;
+  return fcml;
 
 }
 
 
 Float_t AliPHOSRecCpvManager::GradX(Float_t x, Float_t y)
 {
+  // Put a comment here
 
-  const Float_t A = 1.0;
-  const Float_t b = 0.70;
+  const Float_t ka = 1.0;
+  const Float_t kb = 0.70;
 
-  Float_t skv      = b*b + x*x + y*y;
+  Float_t skv      = kb*kb + x*x + y*y;
 
-  Float_t Gradient = y*(1.-x*x/skv)*  b*TMath::Sqrt(skv)/( b*b*skv+x*x*y*y)
-    - y*(1.-x*x/skv)*3*b*TMath::Sqrt(skv)/((3*b)*(3*b)*skv+x*x*y*y)
-    + y*(1.-x*x/skv)*5*b*TMath::Sqrt(skv)/((5*b)*(5*b)*skv+x*x*y*y)
-    - y*(1.-x*x/skv)*7*b*TMath::Sqrt(skv)/((7*b)*(7*b)*skv+x*x*y*y)
-    + y*(1.-x*x/skv)*9*b*TMath::Sqrt(skv)/((9*b)*(9*b)*skv+x*x*y*y);
+  Float_t sqskv=TMath::Sqrt(skv);
+  Float_t yxskv=y*(1.-x/sqskv)*(1.+x/sqskv);
+  
+  Float_t gradient = 
+      yxskv*  kb*sqskv/( kb*kb*skv+x*x*y*y)
+    - yxskv*3*kb*sqskv/((3*kb)*(3*kb)*skv+x*x*y*y)
+    + yxskv*5*kb*sqskv/((5*kb)*(5*kb)*skv+x*x*y*y)
+    - yxskv*7*kb*sqskv/((7*kb)*(7*kb)*skv+x*x*y*y)
+    + yxskv*9*kb*sqskv/((9*kb)*(9*kb)*skv+x*x*y*y);
       
-  Float_t Grad    = A*Gradient/6.2831853071796;
-  return Grad;
+  Float_t grad    = ka*gradient/TMath::TwoPi();
+  return grad;
 }
 
 
 Float_t AliPHOSRecCpvManager::GradY(Float_t x, Float_t y)
 {
+  // Put a comment here
   
-  const Float_t A = 1.0;
-  const Float_t b = 0.70;
+  const Float_t ka = 1.0;
+  const Float_t kb = 0.70;
  
-  Float_t skv      = b*b + x*x + y*y;
-  Float_t Gradient = x*(1.-y*y/skv)*  b*TMath::Sqrt(skv)/( b*b*skv+x*x*y*y)
-    - x*(1.-y*y/skv)*3*b*TMath::Sqrt(skv)/((3*b)*(3*b)*skv+x*x*y*y)
-    + x*(1.-y*y/skv)*5*b*TMath::Sqrt(skv)/((5*b)*(5*b)*skv+x*x*y*y)
-    - x*(1.-y*y/skv)*7*b*TMath::Sqrt(skv)/((7*b)*(7*b)*skv+x*x*y*y)
-    + x*(1.-y*y/skv)*9*b*TMath::Sqrt(skv)/((9*b)*(9*b)*skv+x*x*y*y);
+  Float_t skv      = kb*kb + x*x + y*y;
+
+  Float_t sqskv=TMath::Sqrt(skv);
+  Float_t xyskv=x*(1.-y/sqskv)*(1.+y/sqskv);
+
+  Float_t gradient = 
+      xyskv*  kb*sqskv/( kb*kb*skv+x*x*y*y)
+    - xyskv*3*kb*sqskv/((3*kb)*(3*kb)*skv+x*x*y*y)
+    + xyskv*5*kb*sqskv/((5*kb)*(5*kb)*skv+x*x*y*y)
+    - xyskv*7*kb*sqskv/((7*kb)*(7*kb)*skv+x*x*y*y)
+    + xyskv*9*kb*sqskv/((9*kb)*(9*kb)*skv+x*x*y*y);
   
-  Float_t Grad    = A*Gradient/6.2831853071796;
-  return Grad;
+  Float_t grad    = ka*gradient/TMath::TwoPi();
+  return grad;
 }