]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSGeometry.cxx
Partial redesign of identification bits and coding rule corrections
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.cxx
index 56db326d6c555971a5238393618498fb4abace97..c4ec62590fa4096a656822b20a604f7075f84e07 100644 (file)
@@ -35,7 +35,6 @@
 
 // --- Standard library ---
 
-#include <iostream.h>
 #include <stdlib.h>
 
 // --- AliRoot header files ---
@@ -51,6 +50,19 @@ ClassImp(AliPHOSGeometry) ;
 AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
 Bool_t            AliPHOSGeometry::fgInit = kFALSE ;
 
+//____________________________________________________________________________
+AliPHOSGeometry::AliPHOSGeometry(void)
+{
+  // 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)
 {
@@ -58,7 +70,7 @@ AliPHOSGeometry::~AliPHOSGeometry(void)
 
   if (fRotMatrixArray) fRotMatrixArray->Delete() ; 
   if (fRotMatrixArray) delete fRotMatrixArray ; 
-  if (fPHOSAngle     ) delete fPHOSAngle ; 
+  if (fPHOSAngle     ) delete[] fPHOSAngle ; 
 }
 //____________________________________________________________________________
 
@@ -67,8 +79,13 @@ void AliPHOSGeometry::Init(void)
   // Initializes the PHOS parameters :
   //  IHEP is the Protvino CPV (cathode pad chambers)
   //  GPS2 is the Subatech Pre-Shower (two micromegas sandwiching a passive lead converter)
-  //  MIXT 4 PHOS modules withe the IHEP CPV qnd one PHOS module with the Subatche Pre-Shower
+  //  MIXT 4 PHOS modules withe the IHEP CPV and one PHOS module with the Subatech Pre-Shower
   
+  TString test(GetName()) ; 
+  if (test != "IHEP" && test != "GPS2" && test != "MIXT") {
+    Fatal("Init", "%s is not a known geometry (choose among IHEP, GPS2 and MIXT)", test.Data() ) ; 
+  }
+
   fgInit     = kTRUE ; 
   
   fNModules     = 5;
@@ -100,25 +117,14 @@ void AliPHOSGeometry::Init(void)
   this->SetPHOSAngles() ; 
   fRotMatrixArray = new TObjArray(fNModules) ; 
   
-  // post the geometry into the appropriate folder
-  TFolder * folder = (TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/Geometry/PHOS"); 
-  if ( !folder ) {
-    cerr << "ERROR: AliPHOSGeometry::Init -> No WhiteBoard/Geometry/PHOS found !" << endl ; 
-    abort();
-  } else {
-    folder->SetOwner() ;
-    folder->Add(this) ; 
-  }
-  
 }
 
-
 //____________________________________________________________________________
 AliPHOSGeometry *  AliPHOSGeometry::GetInstance() 
 { 
   // Returns the pointer of the unique instance; singleton specific
   
-  return (AliPHOSGeometry *) fgGeom ; 
+  return static_cast<AliPHOSGeometry *>( fgGeom ) ; 
 }
 
 //____________________________________________________________________________
@@ -143,10 +149,8 @@ AliPHOSGeometry *  AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t
     }
   }
   else {
-    if ( strcmp(fgGeom->GetName(), name) != 0 ) {
-      cout << "AliPHOSGeometry <E> : current geometry is " << fgGeom->GetName() << endl
-          << "                      you cannot call     " << name << endl ; 
-    }
+    if ( strcmp(fgGeom->GetName(), name) != 0 ) 
+      ::Error("GetInstance", "Current geometry is %s. You cannot call %s", fgGeom->GetName(), name) ; 
     else
       rv = (AliPHOSGeometry *) fgGeom ; 
   } 
@@ -162,8 +166,7 @@ void AliPHOSGeometry::SetPHOSAngles()
   Float_t pphi =  2 * TMath::ATan( GetOuterBoxSize(0)  / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ;
   pphi *= kRADDEG ;
   if (pphi > fAngle){ 
-    cout << "AliPHOSGeometry: PHOS modules overlap!\n";
-    cout <<  "pphi = " << pphi << " fAngle  " << fAngle << endl ;
+    Error("SetPHOSAngles", "PHOS modules overlap!\n pphi = %f fAngle = %f", pphi, fAngle);
 
   }
   pphi = fAngle;
@@ -221,23 +224,22 @@ void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t
   else if ( opt == Degre() )
     conv = 180. / TMath::Pi() ; 
   else {
-    cout << "<I>  AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ; 
+    Warning("EmcModuleCoverage", "%s unknown option; result in radian", opt) ; 
     conv = 1. ;
       }
 
   Float_t phi = GetPHOSAngle(mod) *  (TMath::Pi() / 180.)  ;  
   Float_t y0  = GetIPtoCrystalSurface() ; 
-  Float_t * strip = fGeometryEMCA->GetStripHalfSize() ;
-  Float_t x0  = fGeometryEMCA->GetNStripX()*strip[0] ;
-  Float_t z0  = fGeometryEMCA->GetNStripZ()*strip[2] ;
-  Double_t angle = TMath::ATan( x0 / y0 ) ;
+  Float_t x0  = GetCellStep()*GetNPhi() ;
+  Float_t z0  = GetCellStep()*GetNZ();
+  Double_t angle = TMath::ATan( x0 / y0 / 2 ) ;
   phi = phi + 1.5 * TMath::Pi() ; // to follow the convention of the particle generator(PHOS is between 220 and 320 deg.)
   Double_t max  = phi - angle ;
   Double_t min   = phi + angle ;
   pM = TMath::Max(max, min) * conv ;
   pm = TMath::Min(max, min) * conv ; 
   
-  angle =  TMath::ATan( z0 /  y0 ) ;
+  angle =  TMath::ATan( z0 /  y0  / 2 ) ;
   max  = TMath::Pi() / 2.  + angle ; // to follow the convention of the particle generator(PHOS is at 90 deg.)
   min  = TMath::Pi() / 2.  - angle ;
   tM = TMath::Max(max, min) * conv ;
@@ -256,7 +258,7 @@ void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t
   else if ( opt == Degre() )
     conv = 180. / TMath::Pi() ; 
   else {
-    cout << "<I>  AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ; 
+    Warning("EmcXtalCoverage", "%s unknown option; result in radian", opt) ;  
     conv = 1. ;
       }
 
@@ -353,6 +355,20 @@ void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_
   }
 }
 
+//____________________________________________________________________________
+Bool_t  AliPHOSGeometry::Impact(const TParticle * particle) const 
+{
+  // Check if a particle being propagates from IP along the straight line impacts EMC
+
+  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;
+}
+
 //____________________________________________________________________________
 Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t &  AbsId) const
 {
@@ -382,7 +398,24 @@ Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t &  AbsId) c
 }
 
 //____________________________________________________________________________
+void AliPHOSGeometry::RelPosToAbsId(const Int_t module , const Double_t x, const Double_t z, Int_t & AbsId)const{
+  // Converts local PHOS-module (x, z) coordinates to absId 
 
+  if(!module){
+    AbsId = 0 ;
+    return ;
+  }
+  
+  Int_t relid[4] ;
+  relid[0] = module ;
+  relid[1] = 0 ;
+  relid[2] = static_cast<Int_t>(TMath::Ceil(GetNPhi()/2.+ x/GetCellStep()));
+  relid[3] = static_cast<Int_t>(TMath::Ceil(GetNZ()/2.  - z/GetCellStep())) ;
+
+  RelToAbsNumbering(relid,AbsId) ;
+
+}
+//____________________________________________________________________________
 void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) const
 {
   // Converts the absolute numbering into the global ALICE coordinate system
@@ -426,13 +459,13 @@ void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t &
   // Converts the relative numbering into the local PHOS-module (x, z) coordinates
   // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000)
   
-  Int_t row        = relid[2] ; //offset along x axiz
-  Int_t column     = relid[3] ; //offset along z axiz
+  Int_t row        = relid[2] ; //offset along x axis
+  Int_t column     = relid[3] ; //offset along z axis
 
   
-  if ( relid[1] == 0 ) { // its a PbW04 crystal 
-    x = - ( GetNPhi()/2. - row    + 0.5 ) *  GetCrystalSize(0) ; // position ox Xtal with respect
-    z =   ( GetNZ()  /2. - column + 0.5 ) *  GetCrystalSize(2) ; // of center of PHOS module  
+  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  
   }  
   else  {    
     x = - ( GetNumberOfCPVPadsPhi()/2. - row    - 0.5 ) * GetPadSizePhi()  ; // position of pad  with respect