]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSGeometry.cxx
Added track cut method, warning for q<0, profiles for qmax vs pad row and qtot vs...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.cxx
index fb46effd17728590ee29719c4728320b3e6c61fe..33a8d95f01bb690b4c8ec3873e29ffe110e92c78 100644 (file)
 // can be easily implemented 
 // The title is used to identify the version of CPV used.
 //                  
-//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH)
+// -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH)
 
 // --- ROOT system ---
 
 #include "TVector3.h"
 #include "TRotation.h" 
-#include "TFolder.h" 
-#include "TROOT.h" 
+#include "TParticle.h"
 
 // --- Standard library ---
 
-#include <stdlib.h>
-
 // --- AliRoot header files ---
-
+#include "AliLog.h"
 #include "AliPHOSGeometry.h"
 #include "AliPHOSEMCAGeometry.h" 
 #include "AliPHOSRecPoint.h"
-#include "AliConst.h"
 
-ClassImp(AliPHOSGeometry) ;
+ClassImp(AliPHOSGeometry)
 
 // these initialisations are needed for a singleton
-AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
-Bool_t            AliPHOSGeometry::fgInit = kFALSE ;
+AliPHOSGeometry  * AliPHOSGeometry::fgGeom = 0 ;
+Bool_t             AliPHOSGeometry::fgInit = kFALSE ;
+
+//____________________________________________________________________________
+AliPHOSGeometry::AliPHOSGeometry() : 
+                   fNModules(0),
+                   fAngle(0.f),
+                   fPHOSAngle(0),
+                   fIPtoUpperCPVsurface(0),
+                   fRotMatrixArray(0),
+                   fGeometryEMCA(0),
+                   fGeometryCPV(0),
+                   fGeometrySUPP(0)
+{
+    // default ctor 
+    // must be kept public for root persistency purposes, but should never be called by the outside world
+    fgGeom          = 0 ;
+}  
 
 //____________________________________________________________________________
-AliPHOSGeometry::AliPHOSGeometry(void)
+AliPHOSGeometry::AliPHOSGeometry(const AliPHOSGeometry & rhs)
+                   : AliGeometry(rhs),
+                     fNModules(rhs.fNModules),
+                     fAngle(rhs.fAngle),
+                     fPHOSAngle(0),
+                     fIPtoUpperCPVsurface(rhs.fIPtoUpperCPVsurface),
+                     fRotMatrixArray(0),
+                     fGeometryEMCA(0),
+                     fGeometryCPV(0),
+                     fGeometrySUPP(0)
 {
-  // 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;
+  Fatal("cpy ctor", "not implemented") ; 
 }
+
+AliPHOSGeometry::AliPHOSGeometry(const Text_t* name, const Text_t* title) 
+                 : AliGeometry(name, title),
+                   fNModules(0),
+                   fAngle(0.f),
+                   fPHOSAngle(0),
+                   fIPtoUpperCPVsurface(0),
+                   fRotMatrixArray(0),
+                   fGeometryEMCA(0),
+                   fGeometryCPV(0),
+                   fGeometrySUPP(0)
+{ 
+  // ctor only for internal usage (singleton)
+  Init() ; 
+}
+
+
 //____________________________________________________________________________
 AliPHOSGeometry::~AliPHOSGeometry(void)
 {
@@ -78,19 +108,18 @@ 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 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() ) ; 
+  if (test != "IHEP" ) {
+    AliFatal(Form("%s is not a known geometry (choose among IHEP)", 
+                 test.Data() )) ; 
   }
 
   fgInit     = kTRUE ; 
-  
+
   fNModules     = 5;
   fAngle        = 20;
-  
+
   fGeometryEMCA = new AliPHOSEMCAGeometry();
   
   fGeometryCPV  = new AliPHOSCPVGeometry ();
@@ -102,8 +131,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. ;
@@ -114,9 +143,26 @@ void AliPHOSGeometry::Init(void)
   for ( index = 0; index < fNModules; index++ )
     fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
   
-  this->SetPHOSAngles() ; 
   fRotMatrixArray = new TObjArray(fNModules) ; 
-  
+
+  // Geometry parameters are calculated
+
+  SetPHOSAngles();
+  Double_t const kRADDEG = 180.0 / TMath::Pi() ;
+  Float_t r = GetIPtoOuterCoverDistance() + fPHOSParams[3] - GetCPVBoxSize(1) ;
+  for (Int_t iModule=0; iModule<fNModules; iModule++) {
+    fModuleCenter[iModule][0] = r * TMath::Sin(fPHOSAngle[iModule] / kRADDEG );
+    fModuleCenter[iModule][1] =-r * TMath::Cos(fPHOSAngle[iModule] / kRADDEG );
+    fModuleCenter[iModule][2] = 0.;
+    
+    fModuleAngle[iModule][0][0] =  90;
+    fModuleAngle[iModule][0][1] =   fPHOSAngle[iModule];
+    fModuleAngle[iModule][1][0] =   0;
+    fModuleAngle[iModule][1][1] =   0;
+    fModuleAngle[iModule][2][0] =  90;
+    fModuleAngle[iModule][2][1] = 270 + fPHOSAngle[iModule];
+  }
+
 }
 
 //____________________________________________________________________________
@@ -150,7 +196,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 ; 
   } 
@@ -162,11 +209,12 @@ 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){ 
-    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;
@@ -178,7 +226,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 
@@ -214,7 +262,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
 
@@ -224,22 +272,23 @@ void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t
   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. ;
       }
 
   Float_t phi = GetPHOSAngle(mod) *  (TMath::Pi() / 180.)  ;  
   Float_t y0  = GetIPtoCrystalSurface() ; 
-  Float_t x0  = GetCellStep()*GetNPhi() ;
-  Float_t z0  = GetCellStep()*GetNZ();
-  Double_t angle = TMath::ATan( x0 / y0 / 2 ) ;
+  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 ) ;
   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  / 2 ) ;
+  angle =  TMath::ATan( z0 /  y0 ) ;
   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 ;
@@ -258,7 +307,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. ;
       }
 
@@ -269,7 +318,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, TMatrixF & /*gmat*/) const
 {
   // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system
  
@@ -289,7 +338,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 ;
@@ -319,7 +368,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 ;
@@ -330,30 +379,26 @@ 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
 
-  //Convert phi to range 0-2pi if nesassary
-  Double_t phiin2pi = phi ;
-  while(phiin2pi<0)
-    phiin2pi+=6.2831853072 ;
-
   // 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) && (phiin2pi >= pm && phiin2pi <= pM ) ) 
-      ModuleNumber = index ; 
+    if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) ) 
+      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 = phiin2pi - phi0; 
+    Double_t angle = phi - phi0; 
     x = y0 * TMath::Tan(angle) ; 
     angle = theta - TMath::Pi() / 2 ; 
     z = y0 * TMath::Tan(angle) ; 
@@ -361,16 +406,43 @@ void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_
 }
 
 //____________________________________________________________________________
-Bool_t  AliPHOSGeometry::Impact(const TParticle * particle) const 
+void AliPHOSGeometry::ImpactOnEmc(const TVector3& vec, Int_t & moduleNumber, Double_t & z, Double_t & x) const
 {
-  // Check if a particle being propagates from IP along the straight line impacts EMC
+  // 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 = vec.Theta() ; 
+  Double_t phi   = vec.Phi() ; 
+
+  ImpactOnEmc(theta, phi, moduleNumber, z, x) ;
+}
+
+//____________________________________________________________________________
+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
+
+  // 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 
+{
+  // 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;
+  if(moduleNumber) 
+    in=kTRUE;
+  else 
+    in=kFALSE;
   return in;
 }
 
@@ -403,25 +475,8 @@ 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
+void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const
 {
   // Converts the absolute numbering into the global ALICE coordinate system
   
@@ -447,7 +502,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 ;
@@ -458,6 +513,19 @@ void AliPHOSGeometry::RelPosInAlice(const 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 
 {
@@ -470,10 +538,43 @@ 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  
   }
 }
+
+//____________________________________________________________________________
+
+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 = 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.;
+  center.SetXYZ(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.);
+}
+
+//____________________________________________________________________________
+
+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.;
+  localPosition = globalPosition;
+  localPosition.RotateZ(-angle);
+}