]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGeometry.h
New detector numbering scheme (common for DAQ/HLT/Offline). All the subdetectors...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.h
1 #ifndef ALIEMCALGEOMETRY_H
2 #define ALIEMCALGEOMETRY_H
3 /* Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //_________________________________________________________________________
9 // Geometry class  for EMCAL : singleton
10 // EMCAL consists of a layers of scintillator, and lead.
11 //                  
12 //*-- Author: Sahal Yacoob (LBL / UCT)
13 //*--   and : Yves Schutz (Subatech)
14 //*--   and : Aleksei Pavlinov (WSU) - shashlyk staff
15 //*--   and : Gustavo Conesa: Add TRU mapping. TRU parameters still not fixed.
16
17 // --- ROOT system ---
18 class TString ;
19 class TObjArray;
20 class TVector3;
21 class TGeoMatrix;
22 class TParticle ; 
23 class AliEMCALShishKebabTrd1Module;
24 class AliEMCALRecPoint;
25 class TClonesArray ;
26
27 // --- AliRoot header files ---
28 #include "AliGeometry.h"
29 #include "AliEMCALAlignData.h"
30 #include "TArrayD.h"
31
32 class AliEMCALGeometry : public AliGeometry {
33 public:
34   AliEMCALGeometry(const AliEMCALGeometry& geom):AliGeometry(geom) {
35     // cpy ctor requested by Coding Convention but not yet needed
36     Fatal("Cpy ctor", "Not implemented");
37   };
38   virtual ~AliEMCALGeometry(void); 
39
40   static AliEMCALGeometry * GetInstance(const Text_t* name,
41                                         const Text_t* title="") ; 
42   static AliEMCALGeometry * GetInstance() ;
43   AliEMCALGeometry & operator = (const AliEMCALGeometry  & /*rvalue*/) const {
44     // assignement operator requested by coding convention but not needed
45     Fatal("operator =", "not implemented");
46     return *(GetInstance()); 
47   };
48   
49   void FillTRU(const TClonesArray * digits, TClonesArray * amptru, TClonesArray * timeRtru)  ; //Fills Trigger Unit matrices with digit amplitudes and time
50   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
51   
52   // Have to call GetTransformationForSM() before calculation global charachteristics 
53   void GetGlobal(const Double_t *loc, Double_t *glob, int ind) const;
54   void GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const;
55   void GetGlobal(Int_t absId, Double_t glob[3]) const;
56   void GetGlobal(Int_t absId, TVector3 &vglob) const;
57   // for a given tower index it returns eta and phi of center of that tower.
58   void EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const;
59
60   //  virtual void GetGlobal(const AliEMCALRecPoint *rp, TVector3 &vglob) const;
61
62   virtual void GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const;
63   // Bool_t AreInSameTower(Int_t id1, Int_t id2) const ;  
64
65   virtual void GetGlobal(const AliRecPoint *, TVector3 &, TMatrixF &) const {}
66
67   virtual Bool_t Impact(const TParticle *) const {return kTRUE;}
68
69   Bool_t IsInEMCAL(Double_t x, Double_t y, Double_t z) const;
70   // General
71   Bool_t  IsInitialized(void) const { return fgInit ; }
72   // Return EMCAL geometrical parameters
73   // geometry
74   Char_t* GetNameOfEMCALEnvelope() const {return "XEN1";}
75   Float_t GetAlFrontThickness() const { return fAlFrontThick;}
76   Float_t GetArm1PhiMin() const { return fArm1PhiMin ; }
77   Float_t GetArm1PhiMax() const { return fArm1PhiMax ; }
78   Float_t GetArm1EtaMin() const { return fArm1EtaMin;}
79   Float_t GetArm1EtaMax() const { return fArm1EtaMax;}
80   Float_t GetIPDistance() const { return fIPDistance;}   
81   Float_t GetIP2ECASection() const { return ( GetIPDistance() + GetAlFrontThickness() + GetGap2Active() ) ; }   
82   Float_t GetEnvelop(Int_t index) const { return fEnvelop[index] ; }  
83   Float_t GetShellThickness() const { return fShellThickness ; }
84   Float_t GetZLength() const { return fZLength ; } 
85   Float_t GetGap2Active() const {return  fGap2Active ;}
86   Float_t GetDeltaEta() const {return (fArm1EtaMax-fArm1EtaMin)/
87                                        ((Float_t)fNZ);}
88   Float_t GetDeltaPhi() const {return (fArm1PhiMax-fArm1PhiMin)/
89                                        ((Float_t)fNPhi);}
90   Int_t   GetNECLayers() const {return fNECLayers ;}
91   Int_t   GetNZ() const {return fNZ ;}
92   Int_t   GetNEta() const {return fNZ ;}
93   Int_t   GetNPhi() const {return fNPhi ;}
94   Int_t   GetNTowers() const {return fNPhi * fNZ ;}
95   Float_t GetECPbRadThick()const {return fECPbRadThickness;}
96   Float_t GetECScintThick() const {return fECScintThick;}
97   Float_t GetSampling() const {return fSampling ; } 
98   //  Bool_t IsInECA(Int_t index) const { if ( (index > 0 && (index <= GetNZ() * GetNPhi()))) return kTRUE; else return kFALSE ;}
99
100   Int_t   GetNumberOfSuperModules() const {return fNumberOfSuperModules;}
101   Float_t GetfPhiGapForSuperModules() const {return fPhiGapForSM;}
102   Float_t GetPhiModuleSize() const  {return fPhiModuleSize;}
103   Float_t GetEtaModuleSize() const  {return fEtaModuleSize;}
104   Float_t GetFrontSteelStrip() const {return fFrontSteelStrip;}
105   Float_t GetLateralSteelStrip() const {return fLateralSteelStrip;}
106   Float_t GetPassiveScintThick() const {return fPassiveScintThick;}
107   Float_t GetPhiTileSize() const {return fPhiTileSize;}
108   Float_t GetEtaTileSize() const {return fEtaTileSize;}
109   Int_t   GetNPhiSuperModule() const {return fNPhiSuperModule;}
110   Int_t   GetNPHIdiv() const {return fNPHIdiv ;}
111   Int_t   GetNETAdiv() const {return fNETAdiv ;}
112   Int_t   GetNCells()  const {return fNCells;}
113
114   Int_t   GetNTRU() const    {return fNTRU ; }  
115   Int_t   GetNTRUEta() const {return fNTRUEta ; }  
116   Int_t   GetNTRUPhi() const {return fNTRUPhi ; }  
117
118   Float_t GetSteelFrontThickness() const { return fSteelFrontThick;}
119   Float_t GetLongModuleSize() const {return fLongModuleSize;}
120
121   Float_t GetTrd1Angle() const {return fTrd1Angle;}
122   Float_t Get2Trd1Dx2()  const {return f2Trd1Dx2;}
123   Float_t GetTrd2AngleY()const {return fTrd2AngleY;}
124   Float_t Get2Trd2Dy2()  const {return f2Trd2Dy2;}
125   Float_t GetTubsR()     const {return fTubsR;}
126   Float_t GetTubsTurnAngle() const {return fTubsTurnAngle;}
127
128   // TRD1 staff
129   void    CreateListOfTrd1Modules();
130   TList  *GetShishKebabTrd1Modules() const {return fShishKebabTrd1Modules;}
131   AliEMCALShishKebabTrd1Module *GetShishKebabModule(Int_t neta);
132
133   void     GetTransformationForSM();
134   Float_t *GetSuperModulesPars() {return fParSM;}
135   TGeoMatrix *GetTransformationForSM(int i) {
136   if(i>=0 && i<GetNumberOfSuperModules()) return fMatrixOfSM[i]; 
137                                         else return 0;}
138   // abs id <-> indexes; Shish-kebab case, only TRD1 now.
139   // EMCAL -> Super Module -> module -> tower(or cell) - logic tree of EMCAL
140   // May 31, 2006; ALICE numbering scheme: 
141   // see ALICE-INT-2003-038: ALICE Coordinate System and Software Numbering Convention
142   // All indexes are stared from zero now.
143   Int_t   GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const;
144   Bool_t  CheckAbsCellId(Int_t absId) const;
145   Bool_t  GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nTower, Int_t &nIphi, Int_t &nIeta) const;
146   // Local coordinate of Super Module 
147   void    GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t &iphim, Int_t &ietam) const;
148   void    GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
149                                       Int_t &iphi, Int_t &ieta) const ;
150   Int_t   GetSuperModuleNumber(Int_t absId)  const; 
151   // Methods for AliEMCALRecPoint - Feb 19, 2006
152   Bool_t   RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const;
153   Bool_t   RelPosCellInSModule(Int_t absId, Double_t loc[3]) const;
154   Bool_t   RelPosCellInSModule(Int_t absId, TVector3 &vloc) const;
155   // ---
156   Float_t AngleFromEta(Float_t eta) const { // returns theta in radians for a given pseudorapidity
157     return 2.0*TMath::ATan(TMath::Exp(-eta));
158   }
159   Float_t ZFromEtaR(Float_t r,Float_t eta) const { // returns z in for a given
160     // pseudorapidity and r=sqrt(x*x+y*y).
161     return r/TMath::Tan(AngleFromEta(eta));
162   }
163   void SetNZ(Int_t nz) { fNZ= nz ; printf("SetNZ: Number of modules in Z set to %d", fNZ) ; }
164   void SetNPhi(Int_t nphi) { fNPhi= nphi ; printf("SetNPhi: Number of modules in Phi set to %d", fNPhi) ; }
165
166   void SetNTRU(Int_t ntru)    {fNTRU    = ntru; printf("SetNTRU: Number of TRUs per SuperModule set to %d", fNTRU) ; }
167   void SetNTRUEta(Int_t ntru) {fNTRUEta = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Etaset to %d", fNTRUEta) ;}
168   void SetNTRUPhi(Int_t ntru) {fNTRUPhi = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Phi set to %d", fNTRUPhi) ;}
169
170   void SetSampling(Float_t samp) { fSampling = samp; printf("SetSampling: Sampling factor set to %f", fSampling) ; }
171
172   Int_t GetNCellsInSupMod() const {return fNCellsInSupMod;}
173   Int_t GetNCellsInTower() const {return fNCellsInTower; }
174
175   AliEMCALGeometry(); // default ctor only for internal usage (singleton)
176
177 protected:
178   AliEMCALGeometry(const Text_t* name, const Text_t* title);// ctor only for internal usage (singleton)
179
180   AliEMCALGeometry(const Text_t* name, const Text_t* title, AliEMCALAlignData* alignData) :
181     AliGeometry(name, title) {// Align data in action
182     fgAlignData = alignData;
183     Init();
184     CreateListOfTrd1Modules();
185   };
186
187   void Init(void);                      // initializes the parameters of EMCAL
188   void CheckAdditionalOptions();        //
189   void DefineSamplingFraction();        // Jun 5, 2006
190   
191 private:
192   static AliEMCALGeometry * fgGeom;     // pointer to the unique instance of the singleton
193   static Bool_t fgInit;                 // Tells if geometry has been succesfully set up.
194   static AliEMCALAlignData *fgAlignData;// Alignment data, to be replaced by AliAlignData soon
195
196   TString fGeoName;                     //geometry name
197
198   TObjArray *fArrayOpts;                //! array of geometry options
199
200   Float_t fAlFrontThick;                // Thickness of the front Al face of the support box  
201   Float_t fECPbRadThickness;            // cm, Thickness of the Pb radiators
202   Float_t fECScintThick;                // cm, Thickness of the scintillators
203   Int_t   fNECLayers;                   // number of scintillator layers
204   
205   Float_t fArm1PhiMin;                  // Minimum angular position of EMCAL in Phi (degrees)
206   Float_t fArm1PhiMax;                  // Maximum angular position of EMCAL in Phi (degrees)
207   Float_t fArm1EtaMin;                  // Minimum pseudorapidity position of EMCAL in Eta
208   Float_t fArm1EtaMax;                  // Maximum pseudorapidity position of EMCAL in Eta
209   
210   // Geometry Parameters
211   Float_t fEnvelop[3];                  // the GEANT TUB for the detector 
212   Float_t fIPDistance;                  // Radial Distance of the inner surface of the EMCAL
213   Float_t fShellThickness;              // Total thickness in (x,y) direction
214   Float_t fZLength;                     // Total length in z direction
215   Float_t fGap2Active;                  // Gap between the envelop and the active material
216   Int_t   fNZ;                          // Number of Towers in the Z direction
217   Int_t   fNPhi;                        // Number of Towers in the PHI direction
218   Float_t fSampling;                    // Sampling factor
219
220   // Shish-kebab option - 23-aug-04 by PAI; COMPACT, TWIST, TRD1 and TRD2
221   Int_t   fNumberOfSuperModules;         // default is 12 = 6 * 2 
222   Float_t fSteelFrontThick;              // Thickness of the front stell face of the support box - 9-sep-04
223   Float_t fFrontSteelStrip;              // 13-may-05
224   Float_t fLateralSteelStrip;            // 13-may-05
225   Float_t fPassiveScintThick;            // 13-may-05
226   Float_t fPhiModuleSize;                // Phi -> X 
227   Float_t fEtaModuleSize;                // Eta -> Y
228   Float_t fPhiTileSize;                  // Size of phi tile
229   Float_t fEtaTileSize;                  // Size of eta tile
230   Float_t fLongModuleSize;               // Size of long module
231   Int_t   fNPhiSuperModule;              // 6 - number supermodule in phi direction
232   Int_t   fNPHIdiv;                      // number phi divizion of module
233   Int_t   fNETAdiv;                      // number eta divizion of module
234   //
235   Int_t   fNCells;                       // number of cells in calo
236   Int_t   fNCellsInSupMod;               // number cell in super module
237   Int_t   fNCellsInTower;                // number cell in tower(or module)
238   //TRU parameters
239   Int_t   fNTRU ;                        //! Number of TRUs per module
240   Int_t   fNTRUEta ;                     //! Number of cell rows per Z in one TRU
241   Int_t   fNTRUPhi ;                     //! Number of cell rows per Phi in one TRU
242   // TRD1 options - 30-sep-04
243   Float_t fTrd1Angle;                    // angle in x-z plane (in degree) 
244   Float_t f2Trd1Dx2;                     // 2*dx2 for TRD1
245   Float_t fPhiGapForSM;                  // Gap betweeen supermodules in phi direction
246   Int_t   fKey110DEG;                    // for calculation abs cell id; 19-oct-05 
247   // TRD2 options - 27-jan-07
248   Float_t fTrd2AngleY;                   // angle in y-z plane (in degree) 
249   Float_t f2Trd2Dy2;                     // 2*dy2 for TRD2
250   Float_t fEmptySpace;                   // 2mm om fred drawing
251   // Super module as TUBS
252   Float_t fTubsR;                        // radius of tubs 
253   Float_t fTubsTurnAngle;                // turn angle of tubs in degree
254   // Local Coordinates of SM
255   TArrayD  fEtaCentersOfCells;           // size fNEta*fNETAdiv (for TRD1 only) (eta or z in SM)
256   TArrayD  fXCentersOfCells;             // size fNEta*fNETAdiv (for TRD1 only) (       x in SM)
257   TArrayD  fPhiCentersOfCells;           // size fNPhi*fNPHIdiv (for TRD1 only) (phi or y in SM)
258   // Move from AliEMCALv0 - Feb 19, 2006
259   TList *fShishKebabTrd1Modules; //! list of modules
260   // Local coordinates of SM for TRD1
261   Float_t     fParSM[3];       // SM sizes as in GEANT (TRD1)
262   TGeoMatrix* fMatrixOfSM[12]; //![fNumberOfSuperModules]; get from gGeoManager;
263
264   char *fAdditionalOpts[4];  //! some additional options for the geometry type and name
265   int  fNAdditionalOpts;  //! size of additional options parameter
266
267   ClassDef(AliEMCALGeometry, 10) // EMCAL geometry class 
268   };
269
270 #endif // AliEMCALGEOMETRY_H