]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSGeometry.cxx
Fix compiler problems
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.cxx
index 4922da71e137d0e65748863986ad33547c22b4a6..bfd942387e140fe445d9af0ee1e5f9a81fbb83fa 100644 (file)
 // --- Standard library ---
 
 // --- AliRoot header files ---
-
+#include "AliLog.h"
 #include "AliPHOSGeometry.h"
 #include "AliPHOSEMCAGeometry.h" 
 #include "AliPHOSRecPoint.h"
 
-ClassImp(AliPHOSGeometry) ;
+ClassImp(AliPHOSGeometry)
 
 // these initialisations are needed for a singleton
 AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
@@ -76,7 +76,8 @@ void AliPHOSGeometry::Init(void)
   
   TString test(GetName()) ; 
   if (test != "IHEP" ) {
-    Fatal("Init", "%s is not a known geometry (choose among IHEP)", test.Data() ) ; 
+    AliFatal(Form("%s is not a known geometry (choose among IHEP)", 
+                 test.Data() )) ; 
   }
 
   fgInit     = kTRUE ; 
@@ -143,7 +144,8 @@ AliPHOSGeometry *  AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t
   }
   else {
     if ( strcmp(fgGeom->GetName(), name) != 0 ) 
-      ::Error("GetInstance", "Current geometry is %s. You cannot call %s", fgGeom->GetName(), name) ; 
+      ::Error("GetInstance", "Current geometry is %s. You cannot call %s", 
+                     fgGeom->GetName(), name) ; 
     else
       rv = (AliPHOSGeometry *) fgGeom ; 
   } 
@@ -159,7 +161,8 @@ void AliPHOSGeometry::SetPHOSAngles()
   Float_t pphi =  2 * TMath::ATan( GetOuterBoxSize(0)  / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ;
   pphi *= kRADDEG ;
   if (pphi > fAngle){ 
-    Error("SetPHOSAngles", "PHOS modules overlap!\n pphi = %f fAngle = %f", pphi, fAngle);
+    AliError(Form("PHOS modules overlap!\n pphi = %f fAngle = %f", 
+                 pphi, fAngle));
 
   }
   pphi = fAngle;
@@ -217,7 +220,7 @@ void AliPHOSGeometry::EmcModuleCoverage(Int_t mod, Double_t & tm, Double_t & tM,
   else if ( opt == Degre() )
     conv = 180. / TMath::Pi() ; 
   else {
-    Warning("EmcModuleCoverage", "%s unknown option; result in radian", opt) ; 
+    AliWarning(Form("%s unknown option; result in radian", opt)) ; 
     conv = 1. ;
       }
 
@@ -252,7 +255,7 @@ void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t
   else if ( opt == Degre() )
     conv = 180. / TMath::Pi() ; 
   else {
-    Warning("EmcXtalCoverage", "%s unknown option; result in radian", opt) ;  
+    AliWarning(Form("%s unknown option; result in radian", opt)) ;  
     conv = 1. ;
       }
 
@@ -351,20 +354,20 @@ void AliPHOSGeometry::ImpactOnEmc(Double_t theta, Double_t phi, Int_t & moduleNu
 }
 
 //____________________________________________________________________________
-void AliPHOSGeometry::ImpactOnEmc(TVector3 vec, Int_t & moduleNumber, Double_t & z, Double_t & x) const
+void AliPHOSGeometry::ImpactOnEmc(const TVector3& vec, Int_t & moduleNumber, Double_t & z, Double_t & x) const
 {
   // calculates the impact coordinates on PHOS of a neutral particle  
   // emitted in the direction theta and phi in the ALICE global coordinate system
   // searches for the PHOS EMC module
 
-  TParticle p ; 
-  p.SetMomentum(vec.X(), vec.Y(), vec.Z(), 0.) ; 
-  
-  ImpactOnEmc(p, moduleNumber, z, x) ;
+  Double_t theta = vec.Theta() ; 
+  Double_t phi   = vec.Phi() ; 
+
+  ImpactOnEmc(theta, phi, moduleNumber, z, x) ;
 }
 
 //____________________________________________________________________________
-void AliPHOSGeometry::ImpactOnEmc(TParticle p, Int_t & moduleNumber, Double_t & z, Double_t & x) const
+void AliPHOSGeometry::ImpactOnEmc(const TParticle& p, Int_t & moduleNumber, Double_t & z, Double_t & x) const
 {
   // calculates the impact coordinates on PHOS of a neutral particle  
   // emitted in the direction theta and phi in the ALICE global coordinate system
@@ -458,6 +461,19 @@ void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const
     pos.Transform(rot) ; // rotate the baby 
 } 
 
+//____________________________________________________________________________
+void AliPHOSGeometry::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & AbsId) const
+{
+  // converts local PHOS-module (x, z) coordinates to absId 
+  Int_t relid[4] ;
+  relid[0] = module ;
+  relid[1] = 0 ;
+  relid[2] = static_cast<Int_t>(TMath::Ceil( x/ GetCellStep() + GetNPhi() / 2.) );
+  relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ GetCellStep() + GetNZ()   / 2.) ) ;
+  
+  RelToAbsNumbering(relid,AbsId) ;
+}
+
 //____________________________________________________________________________
 void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const 
 {
@@ -480,28 +496,33 @@ void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t &
 
 //____________________________________________________________________________
 
-TVector3 AliPHOSGeometry::GetModuleCenter(char *det, Int_t module) const
+void AliPHOSGeometry::GetModuleCenter(TVector3& center, 
+                                     const char *det,
+                                     Int_t module) const
 {
   // Returns a position of the center of the CPV or EMC module
-  Float_t rDet ;
-  if      (det == "CPV") rDet  = GetIPtoCPVDistance   ();
-  else if (det == "EMC") rDet  = GetIPtoCrystalSurface();
-  else Fatal("GetModuleCenter","Wrong detector name %s",det);
+  Float_t rDet = 0.;
+  if      (strcmp(det,"CPV") == 0) rDet  = GetIPtoCPVDistance   ();
+  else if (strcmp(det,"EMC") == 0) rDet  = GetIPtoCrystalSurface();
+  else 
+    AliFatal(Form("Wrong detector name %s",det));
 
   Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
   angle *= TMath::Pi()/180;
   angle += 3*TMath::Pi()/2.;
-  return TVector3(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.);
+  center.SetXYZ(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.);
 }
 
 //____________________________________________________________________________
 
-TVector3 AliPHOSGeometry::Global2Local(TVector3 globalPosition, Int_t module) const
+void AliPHOSGeometry::Global2Local(TVector3& localPosition,
+                                  const TVector3& globalPosition,
+                                  Int_t module) const
 {
   // Transforms a global position of the rec.point to the local coordinate system
   Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
   angle *= TMath::Pi()/180;
   angle += 3*TMath::Pi()/2.;
-  globalPosition.RotateZ(-angle);
-  return TVector3(globalPosition.Y(),globalPosition.X(),globalPosition.Z());
+  localPosition = globalPosition;
+  localPosition.RotateZ(-angle);
 }