]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSGeometry.h
Minor protection in GetPHOSMod()
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.h
1 #ifndef ALIPHOSGEOMETRY_H
2 #define ALIPHOSGEOMETRY_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //_________________________________________________________________________
9 // Geometry class  for PHOS : singleton  
10 // The EMC modules are parametrized so that any configuration can be easily implemented 
11 // The title is used to identify the type of CPV used. PPSD and CPV are implemented
12 //                  
13 //*-- Author: Yves Schutz (SUBATECH)
14
15 #include <assert.h> 
16
17 // --- ROOT system ---
18
19 #include "TNamed.h"
20 #include "TString.h"
21 #include "TObjArray.h"
22 #include "TVector3.h" 
23
24 // --- AliRoot header files ---
25
26 #include "AliGeometry.h"
27 #include "AliEMCAGeometry.h"
28 #include "AliCPVBaseGeometry.h"
29 #include "AliCPVGeometry.h"
30 #include "AliPPSDGeometry.h"
31 #include "AliPHOSRecPoint.h"
32
33
34 class AliPHOSGeometry : public AliGeometry {
35
36 public: 
37
38   AliPHOSGeometry() {
39     // default ctor 
40     // must be kept public for root persistency purposes, but should never be called by the outside world
41     fPHOSAngle = 0 ; 
42   } ;  
43
44   AliPHOSGeometry(const AliPHOSGeometry & geom) {
45     // cpy ctor requested by Coding Convention but not yet needed
46     assert(0==1) ;
47   } 
48   
49   virtual ~AliPHOSGeometry(void) ; 
50   static AliPHOSGeometry * GetInstance(const Text_t* name, const Text_t* title="") ; 
51   static AliPHOSGeometry * GetInstance() ; 
52   virtual void  GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & gmat) const ;
53   virtual void  GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) const ;
54
55   AliPHOSGeometry & operator = (const AliPHOSGeometry  & rvalue) const {
56     // assignement operator requested by coding convention but not needed
57     assert(0==1) ;
58     return *(GetInstance()) ; 
59   }
60  
61   // General
62
63   static TString Degre(void) {
64     // a global for degree (deg)
65     return TString("deg") ; 
66   }
67
68   static TString Radian(void) { 
69     // a global for radian (rad)
70     return TString("rad") ; 
71   }
72
73   Bool_t AbsToRelNumbering(const Int_t AbsId, Int_t * RelId) ; // converts the absolute PHOS numbering to a relative 
74
75   void EmcModuleCoverage(const Int_t m, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt = Radian() );
76                                                          // calculates the angular coverage in theta and phi of a EMC module
77   void EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt = Radian() ) ; 
78                                                          // calculates the angular coverage in theta and phi of a 
79                                                          // single crystal in a EMC module
80
81   void ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & x, Double_t & z) ; 
82                                                          // calculates the impact coordinates of a neutral particle  
83                                                          // emitted in direction theta and phi in ALICE
84  
85   void   RelPosInModule(const Int_t * RelId, Float_t & y, Float_t & z) ; // gets the position of element (pad or Xtal) relative to 
86                                                                          // center of PHOS module  
87   void   RelPosInAlice(const Int_t AbsId, TVector3 &  pos) ;             // gets the position of element (pad or Xtal) relative to 
88                                                                          // Alice
89   Bool_t RelToAbsNumbering(const Int_t * RelId, Int_t & AbsId) ;         // converts the absolute PHOS numbering to a relative 
90
91   Bool_t  IsInitialized(void)                  const { return fgInit ; }  
92                                                                        
93   // Return general PHOS parameters
94
95   Int_t   GetNModules(void)                    const { return fNModules ; }
96   Float_t GetPHOSAngle(Int_t index)            const { return fPHOSAngle[index-1] ; }
97
98   // Return EMCA geometrical parameters
99
100   Float_t GetOuterBoxSize(Int_t index)         const { return fGeometryEMCA->GetOuterBoxSize(index);            }
101   Float_t GetAirFilledBoxSize(Int_t index)     const { return fGeometryEMCA->GetAirFilledBoxSize(index) ;       }
102   Float_t GetCrystalHolderThickness(void)      const { return fGeometryEMCA->GetCrystalHolderThickness() ;      }
103   Float_t GetCrystalSize(Int_t index)          const { return fGeometryEMCA->GetCrystalSize(index) ;            }
104   Float_t GetCrystalSupportHeight(void)        const { return fGeometryEMCA->GetCrystalSupportHeight() ;        }
105   Float_t GetCrystalWrapThickness(void)        const { return fGeometryEMCA->GetCrystalWrapThickness() ;        }
106   Float_t GetGapBetweenCrystals(void)          const { return fGeometryEMCA->GetGapBetweenCrystals() ;          }
107   Float_t GetIPtoCrystalSurface(void)          const { return fGeometryEMCA->GetIPtoCrystalSurface() ;          }
108   Float_t GetIPtoOuterCoverDistance(void)      const { return fGeometryEMCA->GetIPtoOuterCoverDistance() ;      }
109   Float_t GetLowerThermoPlateThickness(void)   const { return fGeometryEMCA->GetLowerThermoPlateThickness() ;   }
110   Float_t GetLowerTextolitPlateThickness(void) const { return fGeometryEMCA->GetLowerTextolitPlateThickness() ; }
111   Float_t GetModuleBoxThickness(void)          const { return fGeometryEMCA->GetModuleBoxThickness() ;          }
112   Int_t   GetNPhi(void)                        const { return fGeometryEMCA->GetNPhi() ;                        }
113   Int_t   GetNZ(void)                          const { return fGeometryEMCA->GetNZ() ;                          }
114   Float_t GetOuterBoxThickness(Int_t index)    const { return fGeometryEMCA->GetOuterBoxThickness(index) ;      }
115   Float_t GetPinDiodeSize(Int_t index)         const { return fGeometryEMCA->GetPinDiodeSize(index) ;           }
116   Float_t GetSecondUpperPlateThickness(void)   const { return fGeometryEMCA->GetSecondUpperPlateThickness() ;   }
117   Float_t GetSupportPlateThickness(void)       const { return fGeometryEMCA->GetSupportPlateThickness() ;       }
118   Float_t GetTextolitBoxSize(Int_t index)      const { return fGeometryEMCA->GetTextolitBoxSize(index) ;        }
119   Float_t GetTextolitBoxThickness(Int_t index) const { return fGeometryEMCA->GetTextolitBoxThickness(index);    }
120   Float_t GetUpperPlateThickness(void)         const { return fGeometryEMCA->GetUpperPlateThickness() ;         }
121   Float_t GetUpperCoolingPlateThickness(void)  const { return fGeometryEMCA->GetUpperCoolingPlateThickness() ;  }
122
123   // Return PPSD geometrical parameters
124
125   Float_t GetAnodeThickness(void)              const { return ((AliPPSDGeometry*) fGeometryCPV)->GetAnodeThickness();         }
126   Float_t GetAvalancheGap(void)                const { return ((AliPPSDGeometry*) fGeometryCPV)->GetAvalancheGap();           }
127   Float_t GetCathodeThickness(void)            const { return ((AliPPSDGeometry*) fGeometryCPV)->GetCathodeThickness();       }
128   Float_t GetCompositeThickness(void)          const { return ((AliPPSDGeometry*) fGeometryCPV)->GetCompositeThickness();     }
129   Float_t GetConversionGap(void)               const { return ((AliPPSDGeometry*) fGeometryCPV)->GetConversionGap();          }
130   Float_t GetLeadConverterThickness(void)      const { return ((AliPPSDGeometry*) fGeometryCPV)->GetLeadConverterThickness(); }
131   Float_t GetLeadToMicro2Gap(void)             const { return ((AliPPSDGeometry*) fGeometryCPV)->GetLeadToMicro2Gap();        }
132   Float_t GetLidThickness(void)                const { return ((AliPPSDGeometry*) fGeometryCPV)->GetLidThickness();           }
133   Float_t GetMicromegas1Thickness(void)        const { return ((AliPPSDGeometry*) fGeometryCPV)->GetMicromegas1Thickness();   }
134   Float_t GetMicromegas2Thickness(void)        const { return ((AliPPSDGeometry*) fGeometryCPV)->GetMicromegas2Thickness();   }
135   Float_t GetMicromegasWallThickness(void)     const { return ((AliPPSDGeometry*) fGeometryCPV)->GetMicromegasWallThickness();}
136   Float_t GetMicro1ToLeadGap(void)             const { return ((AliPPSDGeometry*) fGeometryCPV)->GetMicro1ToLeadGap();        }
137   Float_t GetPCThickness(void)                 const { return ((AliPPSDGeometry*) fGeometryCPV)->GetPCThickness();            }
138   Float_t GetPhiDisplacement(void)             const { return ((AliPPSDGeometry*) fGeometryCPV)->GetPhiDisplacement();        }
139   Float_t GetPPSDModuleSize(Int_t index)       const { return ((AliPPSDGeometry*) fGeometryCPV)->GetPPSDModuleSize(index);    }
140   Float_t GetZDisplacement(void)               const { return ((AliPPSDGeometry*) fGeometryCPV)->GetZDisplacement();          }
141
142   // Return CPV geometrical parameters
143
144   Bool_t  IsLeadConverterExists(void)          const { return ((AliCPVGeometry*) fGeometryCPV)->IsLeadConverterExists();      }
145   Float_t GetCPVActiveSize(Int_t index)        const { return ((AliCPVGeometry*) fGeometryCPV)->GetCPVActiveSize(index);         }
146   Int_t   GetNumberOfCPVChipsPhi(void)         const { return ((AliCPVGeometry*) fGeometryCPV)->GetNumberOfCPVChipsPhi();     }
147   Int_t   GetNumberOfCPVChipsZ(void)           const { return ((AliCPVGeometry*) fGeometryCPV)->GetNumberOfCPVChipsZ();       }
148   Float_t GetGassiplexChipSize(Int_t index)    const { return ((AliCPVGeometry*) fGeometryCPV)->GetGassiplexChipSize(index);  }
149   Float_t GetCPVGasThickness(void)             const { return ((AliCPVGeometry*) fGeometryCPV)->GetCPVGasThickness();         }
150   Float_t GetCPVTextoliteThickness(void)       const { return ((AliCPVGeometry*) fGeometryCPV)->GetCPVTextoliteThickness();   }
151   Float_t GetCPVCuNiFoilThickness(void)        const { return ((AliCPVGeometry*) fGeometryCPV)->GetCPVCuNiFoilThickness();    }
152   Float_t GetFTPosition(Int_t index)           const { return ((AliCPVGeometry*) fGeometryCPV)->GetFTPosition(index);         }
153   Float_t GetCPVFrameSize(Int_t index)         const { return ((AliCPVGeometry*) fGeometryCPV)->GetCPVFrameSize(index);       }
154
155   // Common PPSD and CPV parameters
156
157   Int_t   GetNumberOfCPVLayers(void)  const {
158     if      (strcmp(fName,"GPS2")==0) return 2;
159     else if (strcmp(fName,"IHEP")==0) return ((AliCPVGeometry*) fGeometryCPV)->GetNumberOfCPVLayers();
160     else                              return 0;
161   }
162
163   Float_t GetCPVBoxSize(Int_t index)  const { 
164     if      (strcmp(fName,"GPS2")==0) return ((AliPPSDGeometry*) fGeometryCPV)->GetCPVBoxSize(index);
165     else if (strcmp(fName,"IHEP")==0) return ((AliCPVGeometry* ) fGeometryCPV)->GetCPVBoxSize(index);
166     else                              return 0;
167   }
168
169   Int_t   GetNumberOfModulesPhi(void) const {
170     if      (strcmp(fName,"GPS2")==0) return ((AliPPSDGeometry*) fGeometryCPV)->GetNumberOfModulesPhi();
171     else if (strcmp(fName,"IHEP")==0) return 1;
172     else                              return 0;
173   }
174
175   Int_t   GetNumberOfModulesZ(void)   const {
176     if      (strcmp(fName,"GPS2")==0) return ((AliPPSDGeometry*) fGeometryCPV)->GetNumberOfModulesZ();
177     else if (strcmp(fName,"IHEP")==0) return 1;
178     else                              return 0;
179   }
180
181   Int_t   GetNumberOfPadsPhi(void)    const { 
182     if      (strcmp(fName,"GPS2")==0) return ((AliPPSDGeometry*) fGeometryCPV)->GetNumberOfPadsPhi();
183     else if (strcmp(fName,"IHEP")==0) return ((AliCPVGeometry* ) fGeometryCPV)->GetNumberOfCPVPadsPhi();
184     else                              return 0;
185   }
186
187   Int_t   GetNumberOfPadsZ(void)      const { 
188     if      (strcmp(fName,"GPS2")==0) return ((AliPPSDGeometry*) fGeometryCPV)->GetNumberOfPadsZ();
189     else if (strcmp(fName,"IHEP")==0) return ((AliCPVGeometry* ) fGeometryCPV)->GetNumberOfCPVPadsZ();
190     else                              return 0;
191   }
192
193   Float_t GetPadSizePhi(void)         const {
194     if      (strcmp(fName,"GPS2")==0) return GetPPSDModuleSize(0) / GetNumberOfPadsPhi();
195     else if (strcmp(fName,"IHEP")==0) return ((AliCPVGeometry*) fGeometryCPV)->GetCPVPadSizePhi();
196     else                              return 0;
197   }
198
199   Float_t GetPadSizeZ(void)           const {
200     if      (strcmp(fName,"GPS2")==0) return GetPPSDModuleSize(2) / GetNumberOfPadsZ();
201     else if (strcmp(fName,"IHEP")==0) return ((AliCPVGeometry*) fGeometryCPV)->GetCPVPadSizeZ();
202     else                              return 0;
203   }
204
205   // Mixed EMCA and PPSD parameters
206
207   Float_t GetIPtoPpsdUp(void)                  const {
208     return (GetIPtoOuterCoverDistance() - GetCPVBoxSize(1) + GetPPSDModuleSize(1)/2 ); } 
209   Float_t GetIPtoTopLidDistance(void)          const { 
210     return  GetIPtoOuterCoverDistance() - GetCPVBoxSize(1) - 1. ; } 
211   Float_t GetIPtoPpsdLow(void)                 const { 
212     return (GetIPtoOuterCoverDistance() - GetPPSDModuleSize(1)/2 ); } 
213
214   // Mixed EMCA and CPV parameters
215
216   Float_t GetIPtoCPVDistance(void)             const {
217     return  GetIPtoOuterCoverDistance() - GetCPVBoxSize(1) - 1.0; }
218
219
220 protected:
221
222   AliPHOSGeometry(const Text_t* name, const Text_t* title="") : AliGeometry(name, title) { 
223     // ctor only for internal usage (singleton)
224     Init() ; 
225   }
226   void Init(void) ;            // steering method for PHOS and PPSD/CPV
227
228 private:
229
230   Int_t                fNModules ;       // Number of modules constituing PHOS
231   Float_t             *fPHOSAngle ;      //[fNModules] Position angles of modules
232   TObjArray           *fRotMatrixArray ; // Liste of rotation matrices (one per phos module)
233   AliEMCAGeometry     *fGeometryEMCA ;   // Geometry object for Electromagnetic calorimeter
234   AliCPVBaseGeometry  *fGeometryCPV ;    // Geometry object for CPV (either GPS2 or IHEP)
235
236   void                 SetPHOSAngles(); // calculates the PHOS modules PHI angle
237
238   static AliPHOSGeometry * fgGeom ; // pointer to the unique instance of the singleton 
239   static Bool_t fgInit ;            // Tells if geometry has been succesfully set up 
240
241   ClassDef(AliPHOSGeometry,1)       // PHOS geometry class 
242
243 } ;
244
245 #endif // AliPHOSGEOMETRY_H