]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALGeometry.h
new file to test SDigits
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.h
index 83085db08e9a6bc5136f225bee317e289f612ae7..e37eab1f005cf34caa53c44029efd22393eab662 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef ALIEMCALGEOMETRY_H
 #define ALIEMCALGEOMETRY_H
-/* Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
 /* $Id$ */
 //                  
 //*-- Author: Sahal Yacoob (LBL / UCT)
 //*--   and : Yves Schutz (Subatech)
-//*--   and : Aleksei Pavlinov (WSU) - shashlyk staff
+//*--   and : Alexei Pavlinov (WSU) - shashlyk staff
 //*--   and : Gustavo Conesa: Add TRU mapping. TRU parameters still not fixed.
+//*--   and : Magali Estienne : analysis access adaptations
+//*--   and : Adapted for DCAL, M.L. Wang CCNU & Subatech Oct-18-2012
 
 // --- ROOT system ---
-class TString ;
-class TObjArray;
-class TVector3;
-class TGeoMatrix;
-class TParticle ; 
-class AliEMCALGeometry;
-class AliEMCALShishKebabTrd1Module;
-class AliEMCALRecPoint;
-class TClonesArray ;
+#include <TNamed.h>
+#include <TMath.h>
+#include <TArrayD.h>
+#include <TVector3.h>
+#include <TGeoMatrix.h> 
+class TBrowser ;
+class TParticle ;
 
 // --- AliRoot header files ---
-#include <TArrayD.h>
-#include <TMath.h>
+#include "AliEMCALEMCGeometry.h"
+#include "AliEMCALGeoParams.h"
+class AliEMCALShishKebabTrd1Module;
+class AliLog;
 
-#include "AliGeometry.h"
+class AliEMCALGeometry : public TNamed {
 
-class AliEMCALGeometry : public AliGeometry {
-public:
-  AliEMCALGeometry(const AliEMCALGeometry& geom);
-  virtual ~AliEMCALGeometry(void); 
+public: 
+  enum fEMCSMType { kEMCAL_Standard = 0, kEMCAL_Half = 1, kEMCAL_3rd = 2, kDCAL_Standard = 3, kDCAL_Ext= 4 }; // possible SM Type
 
-  static AliEMCALGeometry * GetInstance(const Text_t* name,
-                                       const Text_t* title="") ; 
+  AliEMCALGeometry();
+  AliEMCALGeometry(const Text_t* name, const Text_t* title="",
+                   const Text_t* mcname="", const Text_t* mctitle="");
+  AliEMCALGeometry(const AliEMCALGeometry & geom);
+  
+  virtual ~AliEMCALGeometry(void); 
+  AliEMCALGeometry & operator = (const AliEMCALGeometry  & rvalue);
+  
+  static AliEMCALGeometry * GetInstance(const Text_t* name,      const Text_t* title="",
+                                        const Text_t* mcname="TGeant3", const Text_t* mctitle="") ; 
   static AliEMCALGeometry * GetInstance();
-  AliEMCALGeometry & operator = (const AliEMCALGeometry  & /*rvalue*/) {
-    // assignement operator requested by coding convention but not needed
-    Fatal("operator =", "not implemented");
-    return *this;
-  };
-  static Char_t* GetDefaulGeometryName() {return fgDefaultGeometryName;}
-  void PrintGeometry();                                           //*MENU*  
-  void PrintCellIndexes(Int_t absId=0, int pri=0, char *tit="");  //*MENU*
+
+
+  //////////
+  // General
+  //
+  static Bool_t  IsInitialized(void)            {return AliEMCALEMCGeometry::fgInit; }
+  static const Char_t* GetDefaultGeometryName() {return AliEMCALEMCGeometry::fgkDefaultGeometryName;}
+  
+  /////////////
+  // TRD1 stuff
+  void    CreateListOfTrd1Modules();
+  TList  *GetShishKebabTrd1Modules() const {return fShishKebabTrd1Modules;}
+  AliEMCALShishKebabTrd1Module *GetShishKebabModule(Int_t neta) const;
+
+  void PrintGeometryGeoUtils();   // *MENU*  
+  void PrintCellIndexes(Int_t absId=0, int pri=0, const char *tit="") const ;  //*MENU*
+  void PrintLocalTrd1(Int_t pri=0) const;  // *MENU*
   virtual void Browse(TBrowser* b);
   virtual Bool_t  IsFolder() const;
 
-  void GetCellPhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &ietaSM, Int_t &iphiSM) const ; // Tranforms Eta-Phi Cell index in TRU into Eta-Phi index in Super Module
+  virtual Bool_t Impact(const TParticle *particle) const;
+  void ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi, Int_t & absId, TVector3 & vimpact) const;
+  Bool_t IsInEMCAL(Double_t x, Double_t y, Double_t z) const;
+  Bool_t IsInDCAL(Double_t x, Double_t y, Double_t z) const;
+  Int_t  IsInEMCALOrDCAL(Double_t x, Double_t y, Double_t z) const;
+
+  //////////////////////////////////////
+  // Return EMCAL geometrical parameters
+  //
+  
+  AliEMCALEMCGeometry* GetEMCGeometry()       const { return fEMCGeometry                            ; }
+  //
+  const Char_t*  GetNameOfEMCALEnvelope(void) const { return fEMCGeometry->GetNameOfEMCALEnvelope()  ; }
+  Float_t  GetArm1PhiMin(void)                const { return fEMCGeometry->GetArm1PhiMin()           ; }
+  Float_t  GetArm1PhiMax(void)                const { return fEMCGeometry->GetArm1PhiMax()           ; }
+  Float_t  GetArm1EtaMin(void)                const { return fEMCGeometry->GetArm1EtaMin()           ; }
+  Float_t  GetArm1EtaMax(void)                const { return fEMCGeometry->GetArm1EtaMax()           ; }
+  Float_t  GetIPDistance(void)                const { return fEMCGeometry->GetIPDistance()           ; }   
+  Float_t  GetEnvelop(Int_t index)            const { return fEMCGeometry->GetEnvelop(index)         ; }  
+  Float_t  GetShellThickness(void)            const { return fEMCGeometry->GetShellThickness()       ; }
+  Float_t  GetZLength(void)                   const { return fEMCGeometry->GetZLength()              ; } 
+  Float_t  GetDCALInnerEdge(void)             const { return fEMCGeometry->GetDCALInnerEdge()        ; }
+  Float_t  GetDCALPhiMin(void)                const { return fEMCGeometry->GetDCALPhiMin()           ; }
+  Float_t  GetDCALPhiMax(void)                const { return fEMCGeometry->GetDCALPhiMax()           ; }
+  Float_t  GetEMCALPhiMax(void)               const { return fEMCGeometry->GetEMCALPhiMax()          ; }
+  Int_t    GetNECLayers(void)                 const { return fEMCGeometry->GetNECLayers()            ; }
+  Float_t  GetDCALInnerExtandedEta(void)      const { return fEMCGeometry->GetDCALInnerExtandedEta() ; }
+  Int_t    GetNZ(void)                        const { return fEMCGeometry->GetNZ()                   ; }
+  Int_t    GetNEta(void)                      const { return fEMCGeometry->GetNEta()                 ; }
+  Int_t    GetNPhi(void)                      const { return fEMCGeometry->GetNPhi()                 ; }
+  Float_t  GetECPbRadThick(void)              const { return fEMCGeometry->GetECPbRadThick()         ; }
+  Float_t  GetECScintThick(void)              const { return fEMCGeometry->GetECScintThick()         ; }
+  Float_t  GetSampling(void)                  const { return fEMCGeometry->GetSampling()             ; } 
+  Int_t    GetNumberOfSuperModules(void)      const { return fEMCGeometry->GetNumberOfSuperModules() ; }
+  Float_t  GetPhiGapForSuperModules(void)     const { return fEMCGeometry->GetPhiGapForSuperModules(); }
+  Float_t  GetPhiModuleSize(void)             const { return fEMCGeometry->GetPhiModuleSize()        ; }
+  Float_t  GetEtaModuleSize(void)             const { return fEMCGeometry->GetEtaModuleSize()        ; }
+  Float_t  GetFrontSteelStrip(void)           const { return fEMCGeometry->GetFrontSteelStrip()      ; }
+  Float_t  GetLateralSteelStrip(void)         const { return fEMCGeometry->GetLateralSteelStrip()    ; }
+  Float_t  GetPassiveScintThick(void)         const { return fEMCGeometry->GetPassiveScintThick()    ; }
+  Float_t  GetPhiTileSize(void)               const { return fEMCGeometry->GetPhiTileSize()          ; }
+  Float_t  GetEtaTileSize(void)               const { return fEMCGeometry->GetEtaTileSize()          ; }
+  Float_t  GetPhiSuperModule(void)            const { return fEMCGeometry->GetPhiSuperModule()       ; }
+  Int_t    GetNPhiSuperModule(void)           const { return fEMCGeometry->GetNPhiSuperModule()      ; }
+  Int_t    GetNPHIdiv(void)                   const { return fEMCGeometry->GetNPHIdiv()              ; }
+  Int_t    GetNETAdiv(void)                   const { return fEMCGeometry->GetNETAdiv()              ; }
+  Int_t    GetNCells(void)                    const { return fEMCGeometry->GetNCells()               ; }
+  Float_t  GetLongModuleSize(void)            const { return fEMCGeometry->GetLongModuleSize()       ; }
+  Float_t  GetTrd1Angle(void)                 const { return fEMCGeometry->GetTrd1Angle()            ; }
+  Float_t  Get2Trd1Dx2(void)                  const { return fEMCGeometry->Get2Trd1Dx2()             ; }
+  Float_t  GetTrd1AlFrontThick()              const { return fEMCGeometry->GetTrd1AlFrontThick()     ; }
+  Float_t  GetTrd1BondPaperThick()            const { return fEMCGeometry->GetTrd1BondPaperThick()   ; }
+  // --
+  Int_t    GetNCellsInSupMod(void)            const { return fEMCGeometry->GetNCellsInSupMod()       ; }
+  Int_t    GetNCellsInModule(void)            const { return fEMCGeometry->GetNCellsInModule()       ; }
+  Int_t    GetKey110DEG(void)                 const { return fEMCGeometry->GetKey110DEG()            ; }
+  Int_t    GetnSupModInDCAL(void)             const { return fEMCGeometry->GetnSupModInDCAL()        ; }
+  Int_t    GetILOSS(void)                     const { return fEMCGeometry->GetILOSS()                ; }
+  Int_t    GetIHADR(void)                     const { return fEMCGeometry->GetIHADR()                ; }  
+  // --
+  Float_t  GetDeltaEta(void)                  const { return fEMCGeometry->GetDeltaEta()             ; }
+  Float_t  GetDeltaPhi(void)                  const { return fEMCGeometry->GetDeltaPhi()             ; }
+  Int_t    GetNTowers(void)                   const { return fEMCGeometry->GetNTowers()              ; }
+  //
+  Double_t GetPhiCenterOfSM(Int_t nsupmod)    const { return fEMCGeometry->GetPhiCenterOfSM(nsupmod) ; }
+  Double_t GetPhiCenterOfSMSec(Int_t nsupmod) const { return fEMCGeometry->GetPhiCenterOfSMSec(nsupmod) ; }
+  Float_t  GetSuperModulesPar(Int_t ipar)     const { return fEMCGeometry->GetSuperModulesPar(ipar)  ; }
+  //
+  Int_t    GetSMType(Int_t nSupMod)           const { if( nSupMod > fEMCGeometry->GetNumberOfSuperModules() ) return -1;
+                                                      return fEMCSMSystem[nSupMod]                  ; }
+  Bool_t   IsDCALSM(Int_t nSupMod) const;
+  Bool_t   IsDCALExtSM(Int_t nSupMod) const;
+  Bool_t   GetPhiBoundariesOfSM(Int_t nSupMod, Double_t &phiMin, Double_t &phiMax)    const 
+    { return fEMCGeometry->GetPhiBoundariesOfSM(nSupMod, phiMin, phiMax)   ; }
+  Bool_t   GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const 
+    { return fEMCGeometry->GetPhiBoundariesOfSMGap(nPhiSec, phiMin, phiMax); }
+  //
+  // especially for SM in extension, where center of SM != center of the SM-section.
+  // Used in AliEMCALv0 to calculate position.
+  
+  //////////////////////////////////////////////////
+  // Obsolete methods to be thrown out when feasible
+  Float_t GetGap2Active(void)                 const { return fEMCGeometry->GetGap2Active()           ; }
+  Float_t GetSteelFrontThickness(void)        const { return fEMCGeometry->GetSteelFrontThickness()  ; }
+  Float_t GetTrd2AngleY(void)                 const { return fEMCGeometry->GetTrd2AngleY()           ; }
+  Float_t Get2Trd2Dy2(void)                   const { return fEMCGeometry->Get2Trd2Dy2()             ; }
+  Float_t GetTubsR(void)                      const { return fEMCGeometry->GetTubsR()                ; }
+  Float_t GetTubsTurnAngle(void)              const { return fEMCGeometry->GetTubsTurnAngle()        ; }
+  //Float_t GetAlFrontThickness(void)           const { return fEMCGeometry->GetAlFrontThickness()     ; }
+  //Float_t GetIP2ECASection(void)              const { return fEMCGeometry->GetIP2ECASection()        ; }   
+  //////////////////////////////////////////////////
+  
+  ///////////////////////////////
+  //Geometry data member setters
+  //
+  void SetNZ(Int_t nz)           { fEMCGeometry->SetNZ(nz)         ; }
+  void SetNPhi(Int_t nphi)       { fEMCGeometry->SetNPhi(nphi)     ; }
+  //Trigger
+  void SetNTRUEta(Int_t ntru)    { fEMCGeometry->SetNTRUEta(ntru)  ; }
+  void SetNTRUPhi(Int_t ntru)    { fEMCGeometry->SetNTRUPhi(ntru)  ; }
+  //
+  void SetSampling(Float_t samp) { fEMCGeometry->SetSampling(samp) ; }
+  //
+  void PrintGeometry()           { fEMCGeometry->PrintGeometry()   ; }  //*MENU*  
   
-  // Have to call GetTransformationForSM() before calculation global charachteristics 
+  //////////////////////////
+  // Global geometry methods
+  //
   void GetGlobal(const Double_t *loc, Double_t *glob, int ind) const;
   void GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const;
   void GetGlobal(Int_t absId, Double_t glob[3]) const;
   void GetGlobal(Int_t absId, TVector3 &vglob) const;
-  // for a given tower index absId returns eta and phi of gravity center of tower.
-  void EtaPhiFromIndex(Int_t absId, Double_t &eta, Double_t &phi) const;
-  void EtaPhiFromIndex(Int_t absId, Float_t &eta, Float_t &phi) const;
-  // 
-  Bool_t GetPhiBoundariesOfSM   (Int_t nSupMod, Double_t &phiMin, Double_t &phiMax) const;
-  Bool_t GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const;
-  Bool_t SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const;
-
-  Bool_t GetAbsCellIdFromEtaPhi(Double_t eta,Double_t phi, Int_t &absId) const;
-
-  //  virtual void GetGlobal(const AliEMCALRecPoint *rp, TVector3 &vglob) const;
-
-  virtual void GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const;
-  // Bool_t AreInSameTower(Int_t id1, Int_t id2) const ;  
-
-  virtual void GetGlobal(const AliRecPoint *, TVector3 &, TMatrixF &) const {}
-
-  virtual Bool_t Impact(const TParticle *) const {return kTRUE;}
-
-  Bool_t IsInEMCAL(Double_t x, Double_t y, Double_t z) const;
-  // General
-  Bool_t  IsInitialized(void) const { return fgInit ; }
-  // Return EMCAL geometrical parameters
-  // geometry
-  Char_t* GetNameOfEMCALEnvelope() const {return "XEN1";}
-  Float_t GetAlFrontThickness() const { return fAlFrontThick;}
-  Float_t GetArm1PhiMin() const { return fArm1PhiMin ; }
-  Float_t GetArm1PhiMax() const { return fArm1PhiMax ; }
-  Float_t GetArm1EtaMin() const { return fArm1EtaMin;}
-  Float_t GetArm1EtaMax() const { return fArm1EtaMax;}
-  Float_t GetIPDistance() const { return fIPDistance;}   
-  Float_t GetIP2ECASection() const { return ( GetIPDistance() + GetAlFrontThickness() + GetGap2Active() ) ; }   
-  Float_t GetEnvelop(Int_t index) const { return fEnvelop[index] ; }  
-  Float_t GetShellThickness() const { return fShellThickness ; }
-  Float_t GetZLength() const { return fZLength ; } 
-  Float_t GetGap2Active() const {return  fGap2Active ;}
-  Float_t GetDeltaEta() const {return (fArm1EtaMax-fArm1EtaMin)/
-                                      ((Float_t)fNZ);}
-  Float_t GetDeltaPhi() const {return (fArm1PhiMax-fArm1PhiMin)/
-                                      ((Float_t)fNPhi);}
-  Int_t   GetNECLayers() const {return fNECLayers ;}
-  Int_t   GetNZ() const {return fNZ ;}
-  Int_t   GetNEta() const {return fNZ ;}
-  Int_t   GetNPhi() const {return fNPhi ;}
-  Int_t   GetNTowers() const {return fNPhi * fNZ ;}
-  Float_t GetECPbRadThick()const {return fECPbRadThickness;}
-  Float_t GetECScintThick() const {return fECScintThick;}
-  Float_t GetSampling() const {return fSampling ; } 
-  //  Bool_t IsInECA(Int_t index) const { if ( (index > 0 && (index <= GetNZ() * GetNPhi()))) return kTRUE; else return kFALSE ;}
-
-  Int_t   GetNumberOfSuperModules() const {return fNumberOfSuperModules;}
-  Float_t GetfPhiGapForSuperModules() const {return fPhiGapForSM;}
-  Float_t GetPhiModuleSize() const  {return fPhiModuleSize;}
-  Float_t GetEtaModuleSize() const  {return fEtaModuleSize;}
-  Float_t GetFrontSteelStrip() const {return fFrontSteelStrip;}
-  Float_t GetLateralSteelStrip() const {return fLateralSteelStrip;}
-  Float_t GetPassiveScintThick() const {return fPassiveScintThick;}
-  Float_t GetPhiTileSize() const {return fPhiTileSize;}
-  Float_t GetEtaTileSize() const {return fEtaTileSize;}
-  Int_t   GetNPhiSuperModule() const {return fNPhiSuperModule;}
-  Int_t   GetNPHIdiv() const {return fNPHIdiv ;}
-  Int_t   GetNETAdiv() const {return fNETAdiv ;}
-  Int_t   GetNCells()  const {return fNCells;}
-
-  Int_t   GetNTRU() const    {return fNTRUEta*fNTRUPhi ; }  
-  Int_t   GetNTRUEta() const {return fNTRUEta ; }  
-  Int_t   GetNTRUPhi() const {return fNTRUPhi ; }  
-
-  Int_t   GetNCellsInTRU() const    {return fNCellsInTRUEta*fNCellsInTRUPhi; }  
-  Int_t   GetNCellsInTRUEta() const {return fNCellsInTRUEta ; }  
-  Int_t   GetNCellsInTRUPhi() const {return fNCellsInTRUPhi ; }  
-
-  Float_t GetSteelFrontThickness() const { return fSteelFrontThick;}
-  Float_t GetLongModuleSize() const {return fLongModuleSize;}
-
-  Float_t GetTrd1Angle() const {return fTrd1Angle;}
-  Float_t Get2Trd1Dx2()  const {return f2Trd1Dx2;}
-  Float_t GetTrd2AngleY()const {return fTrd2AngleY;}
-  Float_t Get2Trd2Dy2()  const {return f2Trd2Dy2;}
-  Float_t GetTubsR()     const {return fTubsR;}
-  Float_t GetTubsTurnAngle() const {return fTubsTurnAngle;}
-
-  // TRD1 staff
-  void    CreateListOfTrd1Modules();
-  TList  *GetShishKebabTrd1Modules() const {return fShishKebabTrd1Modules;}
-  AliEMCALShishKebabTrd1Module *GetShishKebabModule(Int_t neta);
 
-  void     GetTransformationForSM();
-  Float_t *GetSuperModulesPars() {return fParSM;}
-  TGeoMatrix *GetTransformationForSM(int i) {
-  if(i>=0 && i<GetNumberOfSuperModules()) return fMatrixOfSM[i]; 
-                                        else return 0;}
+  ////////////////////////////////////////
   // May 31, 2006; ALICE numbering scheme: 
   // see ALICE-INT-2003-038: ALICE Coordinate System and Software Numbering Convention
   // All indexes are stared from zero now.
@@ -168,148 +200,176 @@ public:
   //
   //  iphi    - phi index of tower(cell) in SM  
   //  ieta    - eta index of tower(cell) in SM  
+  //
+  // for a given tower index absId returns eta and phi of gravity center of tower.
+  void    EtaPhiFromIndex(Int_t absId, Double_t &eta, Double_t &phi) const;
+  void    EtaPhiFromIndex(Int_t absId, Float_t  &eta, Float_t  &phi) const;
+
+  Bool_t  GetAbsCellIdFromEtaPhi(Double_t eta,Double_t phi, Int_t &absId) const;
+  Bool_t  SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const;
   Int_t   GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const;
   Bool_t  CheckAbsCellId(Int_t absId) const;
-  Bool_t  GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, Int_t &nIeta) const;
+  Bool_t  GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, 
+                      Int_t &nIeta) const;
   // Local coordinate of Super Module 
-  void    GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t &iphim, Int_t &ietam) const;
+  void    GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t &iphim, 
+                                       Int_t &ietam) const;
   void    GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta,
                                       Int_t &iphi, Int_t &ieta) const ;
   Int_t   GetSuperModuleNumber(Int_t absId)  const;
   Int_t   GetNumberOfModuleInPhiDirection(Int_t nSupMod)  const
-  {
-    // inline function
-    if(fKey110DEG == 1 && nSupMod>=10) return fNPhi/2;
-    else                               return fNPhi;
-  }
+  { 
+    if(     GetSMType(nSupMod) == kEMCAL_Half) return fNPhi/2;
+    else if(GetSMType(nSupMod) == kEMCAL_3rd)  return fNPhi/3;
+    else if(GetSMType(nSupMod) == kDCAL_Ext)   return fNPhi/3;
+    else                                       return fNPhi;
+  } 
   // From cell indexes to abs cell id
   void    GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta, 
-         Int_t &iphim, Int_t &ietam, Int_t &nModule) const;
+                                             Int_t &iphim, Int_t &ietam, Int_t &nModule) const;
   Int_t   GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const;
+
   // Methods for AliEMCALRecPoint - Feb 19, 2006
-  Bool_t   RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const;
-  Bool_t   RelPosCellInSModule(Int_t absId, Double_t loc[3]) const;
-  Bool_t   RelPosCellInSModule(Int_t absId, TVector3 &vloc) const;
-  // ---
-  Float_t AngleFromEta(Float_t eta) const { // returns theta in radians for a given pseudorapidity
+  Bool_t  RelPosCellInSModule(Int_t absId, 
+                              Double_t &xr, Double_t &yr, Double_t &zr) const;
+  Bool_t  RelPosCellInSModule(Int_t absId, Double_t distEff,
+                              Double_t &xr, Double_t &yr, Double_t &zr) const;
+  Bool_t  RelPosCellInSModule(Int_t absId, Double_t loc[3]) const;
+  Bool_t  RelPosCellInSModule(Int_t absId, TVector3 &vloc)  const;
+
+  Int_t  * GetEMCSystem()            const { return fEMCSMSystem          ; }     //EMC System, SM type list
+  // Local Coordinates of SM
+  TArrayD  GetCentersOfCellsEtaDir() const { return fCentersOfCellsEtaDir ; }     // size fNEta*fNETAdiv (for TRD1 only) (eta or z in SM, in cm)
+  TArrayD  GetCentersOfCellsXDir()   const { return fCentersOfCellsXDir   ; }     // size fNEta*fNETAdiv (for TRD1 only) (       x in SM, in cm)
+  TArrayD  GetCentersOfCellsPhiDir() const { return fCentersOfCellsPhiDir ; }     // size fNPhi*fNPHIdiv (for TRD1 only) (phi or y in SM, in cm)
+  //
+  TArrayD  GetEtaCentersOfCells()    const { return fEtaCentersOfCells    ; }     // [fNEta*fNETAdiv*fNPhi*fNPHIdiv], positive direction (eta>0); eta depend from phi position; 
+  TArrayD  GetPhiCentersOfCells()    const { return fPhiCentersOfCells    ; }     // [fNPhi*fNPHIdiv] from center of SM (-10. < phi < +10.)
+
+  
+  // For gamma(Jet) trigger simulations *FIXME OLD TO BE REMOVED with AliEMCALTrigger*
+  Int_t    GetNTRU()             const { return fEMCGeometry->GetNTRU()             ; }  
+  Int_t    GetNTRUEta()          const { return fEMCGeometry->GetNTRUEta()          ; }  
+  Int_t    GetNTRUPhi()          const { return fEMCGeometry->GetNTRUPhi()          ; }
+  Int_t    GetNEtaSubOfTRU()     const { return fEMCGeometry->GetNEtaSubOfTRU()     ; }
+  Int_t    GetNModulesInTRU()    const { return fEMCGeometry->GetNModulesInTRU()    ; }
+  Int_t    GetNModulesInTRUEta() const { return fEMCGeometry->GetNModulesInTRUEta() ; }  
+  Int_t    GetNModulesInTRUPhi() const { return fEMCGeometry->GetNModulesInTRUPhi() ; }
+  Int_t    GetNTotalTRU()        const {return  fEMCGeometry->GetNTotalTRU()        ; }
+  // *MEFIX OLD TO BE REMOVED*
+
+  //
+  // Tranforms Eta-Phi Module index in TRU into Eta-Phi index in Super Module
+  void     GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, 
+                                                     Int_t &ietaSM, Int_t &iphiSM) const;
+  Int_t   GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const ;
+
+       
+  void     BuildFastOR2DMap();
+  Bool_t   GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const;
+  Bool_t                    GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const; 
+  Bool_t                    GetAbsFastORIndexFromPositionInSM( const Int_t  iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const; 
+  Bool_t                    GetAbsFastORIndexFromPositionInEMCAL(                const Int_t iEta, const Int_t iPhi, Int_t& id) const;
+  Bool_t             GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const;
+  Bool_t   GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const;
+  Bool_t    GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const;
+  Bool_t GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const;
+  Bool_t          GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const;
+  Bool_t          GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const;
+  Bool_t              GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const;
+  Int_t               GetTRUIndexFromSTUIndex(const Int_t id) const;
+  Bool_t           GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const;
+  Int_t            GetTRUIndexFromOnlineIndex(const Int_t id) const;
+  Bool_t           GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const;
+  Int_t            GetOnlineIndexFromTRUIndex(const Int_t id) const;
+  Bool_t            GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const;
+       
+  ///////////////////
+  // useful utilities
+  //
+  Float_t AngleFromEta(Float_t eta)        const { // returns theta in radians for a given pseudorapidity
     return 2.0*TMath::ATan(TMath::Exp(-eta));
   }
   Float_t ZFromEtaR(Float_t r,Float_t eta) const { // returns z in for a given
     // pseudorapidity and r=sqrt(x*x+y*y).
     return r/TMath::Tan(AngleFromEta(eta));
   }
-  void SetNZ(Int_t nz) { fNZ= nz ; printf("SetNZ: Number of modules in Z set to %d", fNZ) ; }
-  void SetNPhi(Int_t nphi) { fNPhi= nphi ; printf("SetNPhi: Number of modules in Phi set to %d", fNPhi) ; }
-
-  void SetNTRUEta(Int_t ntru) {fNTRUEta = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Etaset to %d", fNTRUEta) ;}
-  void SetNTRUPhi(Int_t ntru) {fNTRUPhi = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Phi set to %d", fNTRUPhi) ;}
-
-  void SetSampling(Float_t samp) { fSampling = samp; printf("SetSampling: Sampling factor set to %f", fSampling) ; }
-
-  Int_t GetNCellsInSupMod() const {return fNCellsInSupMod;}
-  Int_t GetNCellsInModule()  const {return fNCellsInModule; }
-  Int_t GetKey110DEG()      const {return fKey110DEG;}
-  Int_t GetILOSS() const {return fILOSS;}
-  Int_t GetIHADR() const {return fIHADR;}
-
-  AliEMCALGeometry(); // default ctor only for internal usage (singleton)
 
+  //Method to set shift-rotational matrixes from ESDHeader
+  void SetMisalMatrix(const TGeoHMatrix * m, Int_t smod);
+       
+  //Alternate geometry that allows to calculate tower position for different particles and different alignments
+  void RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth,
+                                const Float_t misaligTransShifts[15], const Float_t misaligRotShifts[15],Float_t global[3]) const;
+  
+  //Returns shift-rotational matrixes for different volumes
+  const TGeoHMatrix * GetMatrixForSuperModule(Int_t smod)const ;
+       
 protected:
-  AliEMCALGeometry(const Text_t* name, const Text_t* title);// ctor only for internal usage (singleton)
 
-  void Init(void);                             // initializes the parameters of EMCAL
-  void CheckAdditionalOptions();        //
-  void DefineSamplingFraction();        // Jun 5, 2006
+  void Init(void);                          // initializes the parameters of EMCAL
   
+  AliEMCALEMCGeometry * fEMCGeometry;// Geometry object for Electromagnetic calorimeter
+
+  TString  fGeoName;                 // geometry name
+  Int_t    *fEMCSMSystem;                 // geometry structure
+  Int_t    fKey110DEG;               // for calculation abs cell id; 19-oct-05 
+  Int_t    fnSupModInDCAL;           // for calculation abs cell id; 06-nov-12
+  Int_t    fNCellsInSupMod;          // number cell in super module
+  Int_t    fNETAdiv;                 // number eta divizion of module
+  Int_t    fNPHIdiv;                 // number phi divizion of module
+  Int_t    fNCellsInModule;          // number cell in module
+  TArrayD  fPhiBoundariesOfSM;       // phi boundaries of SM in rad; size is fNumberOfSuperModules;
+  TArrayD  fPhiCentersOfSM;          // phi of centers of SM; size is fNumberOfSuperModules/2
+  TArrayD  fPhiCentersOfSMSec;       // phi of centers of section where SM lies; size is fNumberOfSuperModules/2
+  // Local Coordinates of SM
+  TArrayD  fPhiCentersOfCells;       // [fNPhi*fNPHIdiv] from center of SM (-10. < phi < +10.)
+  TArrayD  fCentersOfCellsEtaDir;    // size fNEta*fNETAdiv (for TRD1 only) (eta or z in SM, in cm)
+  TArrayD  fCentersOfCellsPhiDir;    // size fNPhi*fNPHIdiv (for TRD1 only) (phi or y in SM, in cm)
+  TArrayD  fEtaCentersOfCells;       // [fNEta*fNETAdiv*fNPhi*fNPHIdiv], positive direction (eta>0); eta depend from phi position; 
+  Int_t    fNCells;                  // number of cells in calo
+  Int_t    fNPhi;                    // Number of Towers in the PHI direction
+  TArrayD  fCentersOfCellsXDir;      // size fNEta*fNETAdiv (for TRD1 only) (       x in SM, in cm)
+  Float_t  fEnvelop[3];              // the GEANT TUB for the detector 
+  Float_t  fArm1EtaMin;              // Minimum pseudorapidity position of EMCAL in Eta
+  Float_t  fArm1EtaMax;              // Maximum pseudorapidity position of EMCAL in Eta
+  Float_t  fArm1PhiMin;              // Minimum angular position of EMCAL in Phi (degrees)
+  Float_t  fArm1PhiMax;              // Maximum angular position of EMCAL in Phi (degrees)
+  Float_t  fEtaMaxOfTRD1;            // Max eta in case of TRD1 geometry (see AliEMCALShishKebabTrd1Module)
+  Float_t  fDCALPhiMin;              // Minimum angular position of DCAL in Phi (degrees)
+  Float_t  fDCALPhiMax;              // Maximum angular position of DCAL in Phi (degrees)
+  Float_t  fEMCALPhiMax;             // Maximum angular position of EMCAL in Phi (degrees)
+  Float_t  fDCALStandardPhiMax;      // special edge for the case that DCAL contian extension
+  Float_t  fDCALInnerExtandedEta;    // DCAL inner edge in Eta (with some extension)
+  TList   *fShishKebabTrd1Modules;   // list of modules
+  Float_t  fParSM[3];                // SM sizes as in GEANT (TRD1)
+  Float_t  fPhiModuleSize;           // Phi -> X 
+  Float_t  fEtaModuleSize;           // Eta -> Y 
+  Float_t  fPhiTileSize;             // Size of phi tile
+  Float_t  fEtaTileSize;             // Size of eta tile
+  Int_t    fNZ;                      // Number of Towers in the Z direction
+  Float_t  fIPDistance;                           // Radial Distance of the inner surface of the EMCAL
+  Float_t  fLongModuleSize;          // Size of long module
+  // Geometry Parameters
+  Float_t  fShellThickness;             // Total thickness in (x,y) direction
+  Float_t  fZLength;                        // Total length in z direction
+  Float_t  fSampling;                       // Sampling factor
+
+  Int_t    fFastOR2DMap[48][124];    // FastOR 2D Map over full EMCal
+       
+  TGeoHMatrix* fkSModuleMatrix[AliEMCALGeoParams::fgkEMCALModules] ; //Orientations of EMCAL super modules
+  Bool_t   fUseExternalMatrices;      // Use the matrices set in fkSModuleMatrix and not those in the geoManager
+       
 private:
-  static AliEMCALGeometry * fgGeom;    // pointer to the unique instance of the singleton
-  static Bool_t  fgInit;               // Tells if geometry has been succesfully set up.
-  static Char_t* fgDefaultGeometryName; // Default name of geometry
-
-  TString fGeoName;                     //geometry name
-
-  TObjArray *fArrayOpts;                //! array of geometry options
-
-  Float_t fAlFrontThick;               // Thickness of the front Al face of the support box  
-  Float_t fECPbRadThickness;           // cm, Thickness of the Pb radiators
-  Float_t fECScintThick;               // cm, Thickness of the scintillators
-  Int_t   fNECLayers;                  // number of scintillator layers
   
-  Float_t fArm1PhiMin;                         // Minimum angular position of EMCAL in Phi (degrees)
-  Float_t fArm1PhiMax;                 // Maximum angular position of EMCAL in Phi (degrees)
-  Float_t fArm1EtaMin;                 // Minimum pseudorapidity position of EMCAL in Eta
-  Float_t fArm1EtaMax;                         // Maximum pseudorapidity position of EMCAL in Eta
+  static AliEMCALGeometry *fgGeom;                    // Pointer to the unique instance of the singleton
+  static Bool_t            fgInit;                    // Tells if geometry has been succesfully set up.
+  static const Char_t     *fgkDefaultGeometryName; // Default name of geometry
   
-  // Geometry Parameters
-  Float_t fEnvelop[3];                 // the GEANT TUB for the detector 
-  Float_t fIPDistance;                 // Radial Distance of the inner surface of the EMCAL
-  Float_t fShellThickness;             // Total thickness in (x,y) direction
-  Float_t fZLength;                    // Total length in z direction
-  Float_t fGap2Active;                 // Gap between the envelop and the active material
-  Int_t   fNZ;                         // Number of Towers in the Z direction
-  Int_t   fNPhi;                       // Number of Towers in the PHI direction
-  Float_t fSampling;                   // Sampling factor
-
-  // Shish-kebab option - 23-aug-04 by PAI; COMPACT, TWIST, TRD1 and TRD2
-  Int_t   fNumberOfSuperModules;         // default is 12 = 6 * 2 
-  Float_t fSteelFrontThick;             // Thickness of the front stell face of the support box - 9-sep-04
-  Float_t fFrontSteelStrip;              // 13-may-05
-  Float_t fLateralSteelStrip;            // 13-may-05
-  Float_t fPassiveScintThick;            // 13-may-05
-  Float_t fPhiModuleSize;                // Phi -> X 
-  Float_t fEtaModuleSize;                // Eta -> Y
-  Float_t fPhiTileSize;                  // Size of phi tile
-  Float_t fEtaTileSize;                  // Size of eta tile
-  Float_t fLongModuleSize;               // Size of long module
-  Int_t   fNPhiSuperModule;              // 6 - number supermodule in phi direction
-  Int_t   fNPHIdiv;                      // number phi divizion of module
-  Int_t   fNETAdiv;                      // number eta divizion of module
-  //
-  Int_t   fNCells;                       // number of cells in calo
-  Int_t   fNCellsInSupMod;               // number cell in super module
-  Int_t   fNCellsInModule;               // number cell in module)
-  //TRU parameters
-  Int_t   fNTRUEta ;                     // Number of TRUs per module in eta
-  Int_t   fNTRUPhi ;                     // Number of TRUs per module in phi
-  Int_t   fNCellsInTRUEta;               // Number of cells per TRU in eta 
-  Int_t   fNCellsInTRUPhi;               // Number of cells per TRU in phi 
-
-  // TRD1 options - 30-sep-04
-  Float_t fTrd1Angle;                    // angle in x-z plane (in degree) 
-  Float_t f2Trd1Dx2;                     // 2*dx2 for TRD1
-  Float_t fPhiGapForSM;                  // Gap betweeen supermodules in phi direction
-  Int_t   fKey110DEG;                    // for calculation abs cell id; 19-oct-05 
-  TArrayD fPhiBoundariesOfSM;            // phi boundaries of SM in rad; size is fNumberOfSuperModules;
-  TArrayD fPhiCentersOfSM;                // phi of centers of SMl size is fNumberOfSuperModules/2
-  Float_t fEtaMaxOfTRD1;                 // max eta in case of TRD1 geometry (see AliEMCALShishKebabTrd1Module)
-  // TRD2 options - 27-jan-07
-  Float_t fTrd2AngleY;                   // angle in y-z plane (in degree) 
-  Float_t f2Trd2Dy2;                     // 2*dy2 for TRD2
-  Float_t fEmptySpace;                   // 2mm om fred drawing
-  // Super module as TUBS
-  Float_t fTubsR;                        // radius of tubs 
-  Float_t fTubsTurnAngle;                // turn angle of tubs in degree
-  // Local Coordinates of SM
-  TArrayD  fCentersOfCellsEtaDir;        // size fNEta*fNETAdiv (for TRD1 only) (eta or z in SM, in cm)
-  TArrayD  fCentersOfCellsXDir;          // size fNEta*fNETAdiv (for TRD1 only) (       x in SM, in cm)
-  TArrayD  fCentersOfCellsPhiDir;        // size fNPhi*fNPHIdiv (for TRD1 only) (phi or y in SM, in cm)
-  //
-  TArrayD  fEtaCentersOfCells;           // [fNEta*fNETAdiv*fNPhi*fNPHIdiv], positive direction (eta>0); eta depend from phi position; 
-  TArrayD  fPhiCentersOfCells;           // [fNPhi*fNPHIdiv] from center of SM (-10. < phi < +10.)
-  // Move from AliEMCALv0 - Feb 19, 2006
-  TList *fShishKebabTrd1Modules; //! list of modules
-  // Local coordinates of SM for TRD1
-  Float_t     fParSM[3];       // SM sizes as in GEANT (TRD1)
-  TGeoMatrix* fMatrixOfSM[12]; //![fNumberOfSuperModules]; get from gGeoManager;
-
-  char *fAdditionalOpts[6];  //! some additional options for the geometry type and name
-  int  fNAdditionalOpts;     //! size of additional options parameter
+  
+  ClassDef(AliEMCALGeometry,17)       // EMCAL geometry class 
 
-  // Options for Geant (MIP business) - will call in AliEMCAL
-  Int_t fILOSS;
-  Int_t fIHADR;
+} ;
 
-  ClassDef(AliEMCALGeometry, 12) // EMCAL geometry class 
-};
+#endif // AliEMCALGEOUTILS_H
 
-#endif // AliEMCALGEOMETRY_H