]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSGeometry.cxx
Z-axis direction is restored
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.cxx
index bde9dd2639d4e7d4be4fe05792bb76442bfd54b2..57e01b4b4efd62e7412dd2d9a1e1075a7ce9afe3 100644 (file)
 
 #include "TVector3.h"
 #include "TRotation.h" 
-#include "TFolder.h" 
-#include "TROOT.h" 
+#include "TParticle.h"
 
 // --- Standard library ---
 
-#include <stdlib.h>
-
 // --- AliRoot header files ---
 
 #include "AliPHOSGeometry.h"
 #include "AliPHOSEMCAGeometry.h" 
 #include "AliPHOSRecPoint.h"
-#include "AliConst.h"
 
 ClassImp(AliPHOSGeometry) ;
 
@@ -50,6 +46,18 @@ ClassImp(AliPHOSGeometry) ;
 AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
 Bool_t            AliPHOSGeometry::fgInit = kFALSE ;
 
+//____________________________________________________________________________
+AliPHOSGeometry::AliPHOSGeometry() {
+    // default ctor 
+    // must be kept public for root persistency purposes, but should never be called by the outside world
+    fPHOSAngle      = 0 ;
+    fGeometryEMCA   = 0 ;
+    fGeometrySUPP   = 0 ;
+    fGeometryCPV    = 0 ;
+    fgGeom          = 0 ;
+    fRotMatrixArray = 0 ;  
+}  
+
 //____________________________________________________________________________
 AliPHOSGeometry::~AliPHOSGeometry(void)
 {
@@ -87,8 +95,8 @@ void AliPHOSGeometry::Init(void)
   Float_t * emcParams = fGeometryEMCA->GetEMCParams() ;
   
   fPHOSParams[0] =  TMath::Max((Double_t)fGeometryCPV->GetCPVBoxSize(0)/2., 
-                              (Double_t)(emcParams[0]*(fGeometryCPV->GetCPVBoxSize(1)+emcParams[3]) - 
-                               emcParams[1]* fGeometryCPV->GetCPVBoxSize(1))/emcParams[3] ) ;
+                              (Double_t)(emcParams[0] - (emcParams[1]-emcParams[0])*
+                                         fGeometryCPV->GetCPVBoxSize(1)/2/emcParams[3]));
   fPHOSParams[1] = emcParams[1] ;
   fPHOSParams[2] = TMath::Max((Double_t)emcParams[2], (Double_t)fGeometryCPV->GetCPVBoxSize(2)/2.);
   fPHOSParams[3] = emcParams[3] + fGeometryCPV->GetCPVBoxSize(1)/2. ;
@@ -147,7 +155,7 @@ void AliPHOSGeometry::SetPHOSAngles()
 { 
   // Calculates the position of the PHOS modules in ALICE global coordinate system
   
-  Double_t const kRADDEG = 180.0 / kPI ;
+  Double_t const kRADDEG = 180.0 / TMath::Pi() ;
   Float_t pphi =  2 * TMath::ATan( GetOuterBoxSize(0)  / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ;
   pphi *= kRADDEG ;
   if (pphi > fAngle){ 
@@ -163,7 +171,7 @@ void AliPHOSGeometry::SetPHOSAngles()
 }
 
 //____________________________________________________________________________
-Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid) const
+Bool_t AliPHOSGeometry::AbsToRelNumbering(Int_t AbsId, Int_t * relid) const
 {
   // Converts the absolute numbering into the following array/
   //  relid[0] = PHOS Module number 1:fNModules 
@@ -199,7 +207,7 @@ Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid) cons
 }
 
 //____________________________________________________________________________  
-void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) const 
+void AliPHOSGeometry::EmcModuleCoverage(Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) const 
 {
   // calculates the angular coverage in theta and phi of one EMC (=PHOS) module
 
@@ -255,7 +263,7 @@ void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t
  
 
 //____________________________________________________________________________
-void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & gmat) const
+void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & /*gmat*/) const
 {
   // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system
  
@@ -275,7 +283,7 @@ void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TM
     }  
 
   Float_t phi           = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ; 
-  Double_t const kRADDEG = 180.0 / kPI ;
+  Double_t const kRADDEG = 180.0 / TMath::Pi() ;
   Float_t rphi          = phi / kRADDEG ; 
   
   TRotation rot ;
@@ -305,7 +313,7 @@ void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) co
     }  
 
   Float_t phi           = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ; 
-  Double_t const kRADDEG = 180.0 / kPI ;
+  Double_t const kRADDEG = 180.0 / TMath::Pi() ;
   Float_t rphi          = phi / kRADDEG ; 
   
   TRotation rot ;
@@ -316,23 +324,24 @@ void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) co
 }
 
 //____________________________________________________________________________
-void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x) const
+void AliPHOSGeometry::ImpactOnEmc(Double_t theta, Double_t phi, 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
-  ModuleNumber = 0 ; 
+
+  moduleNumber = 0 ; 
   Double_t tm, tM, pm, pM ; 
   Int_t index = 1 ; 
-  while ( ModuleNumber == 0 && index <= GetNModules() ) { 
+  while ( moduleNumber == 0 && index <= GetNModules() ) { 
     EmcModuleCoverage(index, tm, tM, pm, pM) ; 
     if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) ) 
-      ModuleNumber = index ; 
+      moduleNumber = index ; 
     index++ ;    
   }
-  if ( ModuleNumber != 0 ) {
-    Float_t phi0 =  GetPHOSAngle(ModuleNumber) *  (TMath::Pi() / 180.) + 1.5 * TMath::Pi()  ;  
+  if ( moduleNumber != 0 ) {
+    Float_t phi0 =  GetPHOSAngle(moduleNumber) *  (TMath::Pi() / 180.) + 1.5 * TMath::Pi()  ;  
     Float_t y0  =  GetIPtoCrystalSurface()  ;   
     Double_t angle = phi - phi0; 
     x = y0 * TMath::Tan(angle) ; 
@@ -341,15 +350,45 @@ void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_
   }
 }
 
+//____________________________________________________________________________
+void AliPHOSGeometry::ImpactOnEmc(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) ;
+}
+
+//____________________________________________________________________________
+void AliPHOSGeometry::ImpactOnEmc(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
+
+  // searches for the PHOS EMC module
+  Double_t theta = p.Theta() ; 
+  Double_t phi   = p.Phi() ; 
+
+  ImpactOnEmc(theta, phi, moduleNumber, z, x) ;
+}
+
+//____________________________________________________________________________
 Bool_t  AliPHOSGeometry::Impact(const TParticle * particle) const 
 {
-  Bool_t In=kFALSE;
-  Int_t ModuleNumber=0;
+  // Tells if a particle enters PHOS
+  Bool_t in=kFALSE;
+  Int_t moduleNumber=0;
   Double_t z,x;
-  ImpactOnEmc(particle->Theta(),particle->Phi(),ModuleNumber,z,x);
-  if(ModuleNumber) In=kTRUE;
-  else In=kFALSE;
-  return In;
+  ImpactOnEmc(particle->Theta(),particle->Phi(),moduleNumber,z,x);
+  if(moduleNumber) 
+    in=kTRUE;
+  else 
+    in=kFALSE;
+  return in;
 }
 
 //____________________________________________________________________________
@@ -382,7 +421,7 @@ Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t &  AbsId) c
 
 //____________________________________________________________________________
 
-void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) const
+void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const
 {
   // Converts the absolute numbering into the global ALICE coordinate system
   
@@ -408,7 +447,7 @@ void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) const
     pos.SetY(y0) ;
     
     Float_t phi           = GetPHOSAngle( phosmodule) ; 
-    Double_t const kRADDEG = 180.0 / kPI ;
+    Double_t const kRADDEG = 180.0 / TMath::Pi() ;
     Float_t rphi          = phi / kRADDEG ; 
     
     TRotation rot ;
@@ -431,10 +470,10 @@ void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t &
   
   if ( relid[1] == 0 ) { // its a PbW04 crystal
     x = - ( GetNPhi()/2. - row    + 0.5 ) *  GetCellStep() ; // position of Xtal with respect
-    z =   ( GetNZ()  /2. - column + 0.5 ) *  GetCellStep() ; // of center of PHOS module  
+    z = - ( GetNZ()  /2. - column + 0.5 ) *  GetCellStep() ; // of center of PHOS module  
   }  
   else  {    
     x = - ( GetNumberOfCPVPadsPhi()/2. - row    - 0.5 ) * GetPadSizePhi()  ; // position of pad  with respect
-    z =   ( GetNumberOfCPVPadsZ()  /2. - column - 0.5 ) * GetPadSizeZ()  ; // of center of PHOS module  
+    z = - ( GetNumberOfCPVPadsZ()  /2. - column - 0.5 ) * GetPadSizeZ()  ; // of center of PHOS module  
   }
 }