]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSGeometry.cxx
0c01cb8a220cd2761db6570514c193d74bf4ae60
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 // Geometry class  for PHOS : singleton  
20 // The EMC modules are parametrized so that any configuration can be easily implemented 
21 // The title is used to identify the type of CPV used. So far only PPSD implemented
22 //                  
23 //*-- Author: Yves Schutz (SUBATECH)
24
25 // --- ROOT system ---
26
27 #include "TVector3.h"
28 #include "TRotation.h" 
29
30 // --- Standard library ---
31
32 #include <iostream.h>
33
34 // --- AliRoot header files ---
35
36 #include "AliPHOSGeometry.h"
37 #include "AliPHOSPpsdRecPoint.h"
38 #include "AliConst.h"
39
40 ClassImp(AliPHOSGeometry)
41
42   AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
43
44 //____________________________________________________________________________
45 AliPHOSGeometry::~AliPHOSGeometry(void)
46 {
47   // dtor
48
49   fRotMatrixArray->Delete() ; 
50   delete fRotMatrixArray ; 
51
52   delete fPHOSAngle ; 
53 }
54
55 //____________________________________________________________________________
56 Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid)
57 {
58   // Converts the absolute numbering into the following array/
59   //  relid[0] = PHOS Module number 1:fNModules 
60   //  relid[1] = 0 if PbW04
61   //           = PPSD Module number 1:fNumberOfModulesPhi*fNumberOfModulesZ*2 (2->up and bottom level)
62   //  relid[2] = Row number inside a PHOS or PPSD module
63   //  relid[3] = Column number inside a PHOS or PPSD module
64
65   Bool_t rv  = kTRUE ; 
66   Float_t id = AbsId ;
67
68   Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / ( GetNPhi() * GetNZ() ) ) ; 
69   
70   if ( phosmodulenumber >  GetNModules() ) { // its a PPSD pad
71
72     id -=  GetNPhi() * GetNZ() *  GetNModules() ; 
73     Float_t tempo = 2 *  GetNumberOfModulesPhi() * GetNumberOfModulesZ() *  GetNumberOfPadsPhi() * GetNumberOfPadsZ() ; 
74     relid[0] = (Int_t)TMath::Ceil( id / tempo ) ; 
75     id -= ( relid[0] - 1 ) * tempo ;
76     relid[1] = (Int_t)TMath::Ceil( id / ( GetNumberOfPadsPhi() * GetNumberOfPadsZ() ) ) ; 
77     id -= ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
78     relid[2] = (Int_t)TMath::Ceil( id / GetNumberOfPadsPhi() ) ;
79     relid[3] = (Int_t) ( id - ( relid[2] - 1 )  * GetNumberOfPadsPhi() ) ; 
80   } 
81   else { // its a PW04 crystal
82
83     relid[0] = phosmodulenumber ;
84     relid[1] = 0 ;
85     id -= ( phosmodulenumber - 1 ) *  GetNPhi() * GetNZ() ; 
86     relid[2] = (Int_t)TMath::Ceil( id / GetNPhi() ) ;
87     relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNPhi() ) ; 
88   } 
89   return rv ; 
90 }
91 //____________________________________________________________________________  
92 void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) 
93 {
94   // calculates the angular coverage in theta and phi of a EMC module
95
96  Double_t conv ; 
97   if ( opt == kRadian ) 
98     conv = 1. ; 
99   else if ( opt == kDegre )
100     conv = 180. / TMath::Pi() ; 
101   else {
102     cout << "<I>  AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ; 
103     conv = 1. ;
104       }
105
106   Float_t phi =  GetPHOSAngle(mod) *  (TMath::Pi() / 180.)  ;  
107   Float_t y0  =  GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
108                   + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()  ;  
109   
110   Double_t angle = TMath::ATan( GetCrystalSize(0)*GetNPhi() / (2 * y0) ) ;
111   phi = phi + 1.5 * TMath::Pi() ; // to follow the convention of the particle generator(PHOS is between 230 and 310 deg.)
112   Double_t max  = phi - angle ;
113   Double_t min   = phi + angle ;
114   pM = TMath::Max(max, min) * conv ;
115   pm = TMath::Min(max, min) * conv ; 
116   
117   angle =  TMath::ATan( GetCrystalSize(2)*GetNZ() / (2 * y0) ) ;
118   max  = TMath::Pi() / 2.  + angle ; // to follow the convention of the particle generator(PHOS is at 90 deg.)
119   min  = TMath::Pi() / 2.  - angle ;
120   tM = TMath::Max(max, min) * conv ;
121   tm = TMath::Min(max, min) * conv ; 
122  
123 }
124
125 //____________________________________________________________________________  
126 void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt) 
127 {
128   // calculates the angular coverage in theta and phi of a single crystal in a EMC module
129
130   Double_t conv ; 
131   if ( opt == kRadian ) 
132     conv = 1. ; 
133   else if ( opt == kDegre )
134     conv = 180. / TMath::Pi() ; 
135   else {
136     cout << "<I>  AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ; 
137     conv = 1. ;
138       }
139
140   Float_t y0   =  GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
141     + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()  ;  
142   theta = 2 * TMath::ATan( GetCrystalSize(2) / (2 * y0) ) * conv ;
143   phi   = 2 * TMath::ATan( GetCrystalSize(0) / (2 * y0) ) * conv ;
144 }
145  
146
147 //____________________________________________________________________________
148 void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x) 
149 {
150   // calculates the impact coordinates of a neutral particle  
151   // emitted in direction theta and phi in ALICE
152
153   // searches for the PHOS EMC module
154   ModuleNumber = 0 ; 
155   Double_t tm, tM, pm, pM ; 
156   Int_t index = 1 ; 
157   while ( ModuleNumber == 0 && index <= GetNModules() ) { 
158     EmcModuleCoverage(index, tm, tM, pm, pM) ; 
159     if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) ) 
160       ModuleNumber = index ; 
161     index++ ;    
162   }
163   if ( ModuleNumber != 0 ) {
164     Float_t phi0 =  GetPHOSAngle(ModuleNumber) *  (TMath::Pi() / 180.) + 1.5 * TMath::Pi()  ;  
165     Float_t y0  =  GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
166       + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()  ;   
167     Double_t angle = phi - phi0; 
168     x = y0 * TMath::Tan(angle) ; 
169     angle = theta - TMath::Pi() / 2 ; 
170     z = y0 * TMath::Tan(angle) ; 
171   }
172 }
173
174 //____________________________________________________________________________
175 void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & gmat)
176 {
177   // Calculates the ALICE global coordinates of a RecPoint and the error matrix
178  
179   AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;  
180   TVector3 localposition ;
181
182   tmpPHOS->GetLocalPosition(gpos) ;
183
184
185   if ( tmpPHOS->IsEmc() ) // it is a EMC crystal 
186     {  gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
187                     GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;  
188
189     }
190   else
191     { // it is a PPSD pad
192       AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
193       if (tmpPpsd->GetUp() ) // it is an upper module
194         {
195           gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() - 
196                        GetLeadToMicro2Gap() - GetLeadConverterThickness() -  
197                        GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 )  ) ; 
198         } 
199       else // it is a lower module
200         gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ; 
201     }  
202
203   Float_t phi           = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ; 
204   Double_t const kRADDEG = 180.0 / kPI ;
205   Float_t rphi          = phi / kRADDEG ; 
206   
207   TRotation rot ;
208   rot.RotateZ(-rphi) ; // a rotation around Z by angle  
209   
210   TRotation dummy = rot.Invert() ;  // to transform from original frame to rotate frame
211   gpos.Transform(rot) ; // rotate the baby 
212
213 }
214
215 //____________________________________________________________________________
216 void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos)
217 {
218   // Calculates the ALICE global coordinates of a RecPoint 
219
220   AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;  
221   TVector3 localposition ;
222   tmpPHOS->GetLocalPosition(gpos) ;
223
224
225   if ( tmpPHOS->IsEmc() ) // it is a EMC crystal 
226     {  gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
227                     GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;  
228     }
229   else
230     { // it is a PPSD pad
231       AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
232       if (tmpPpsd->GetUp() ) // it is an upper module
233         {
234           gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() - 
235                        GetLeadToMicro2Gap() - GetLeadConverterThickness() -  
236                        GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 )  ) ; 
237         } 
238       else // it is a lower module
239         gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ; 
240     }  
241
242   Float_t phi           = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ; 
243   Double_t const kRADDEG = 180.0 / kPI ;
244   Float_t rphi          = phi / kRADDEG ; 
245   
246   TRotation rot ;
247   rot.RotateZ(-rphi) ; // a rotation around Z by angle  
248   
249   TRotation dummy = rot.Invert() ;  // to transform from original frame to rotate frame
250   gpos.Transform(rot) ; // rotate the baby 
251 }
252
253 //____________________________________________________________________________
254 void AliPHOSGeometry::Init(void)
255 {
256   // Initializes the PHOS parameters
257   
258   fRotMatrixArray = new TObjArray(fNModules) ; 
259
260   cout << "PHOS geometry setup: parameters for option " << fName << " " << fTitle << endl ;
261   if ( ((strcmp( fName, "default" )) == 0)  || ((strcmp( fName, "GPS2" )) == 0) ) {
262     fInit     = kTRUE ; 
263     this->InitPHOS() ; 
264     this->InitPPSD() ;
265     this->SetPHOSAngles() ; 
266   }
267  else {
268    fInit = kFALSE ; 
269    cout << "PHOS Geometry setup: option not defined " << fName << endl ; 
270  }
271 }
272
273 //____________________________________________________________________________
274 void AliPHOSGeometry::InitPHOS(void)
275 {
276   // Initializes the EMC parameters
277
278   fNPhi     = 64 ; 
279   fNZ       = 64 ; 
280   fNModules =  5 ; 
281
282   fPHOSAngle = new Float_t[fNModules] ;
283   Int_t index ;
284   for ( index = 0; index < fNModules; index++ )
285     fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
286   
287   fXtlSize[0] =  2.2 ;
288   fXtlSize[1] = 18.0 ;
289   fXtlSize[2] =  2.2 ;
290
291   // all these numbers coming next are subject to changes
292
293   fOuterBoxThickness[0] = 2.8 ;
294   fOuterBoxThickness[1] = 5.0 ;      
295   fOuterBoxThickness[2] = 5.0 ;
296   
297   fUpperPlateThickness  = 4.0 ;
298   
299   fSecondUpperPlateThickness = 5.0 ; 
300   
301   fCrystalSupportHeight   = 6.95 ; 
302   fCrystalWrapThickness   = 0.01 ;
303   fCrystalHolderThickness = 0.005 ;
304   fModuleBoxThickness     = 2.0 ; 
305   fIPtoOuterCoverDistance = 447.0 ;      
306   fIPtoCrystalSurface     = 460.0 ;  
307   
308   fPinDiodeSize[0] = 1.71 ;   //Values given by Odd Harald feb 2000  
309   fPinDiodeSize[1] = 0.0280 ; // 0.0280 is the depth of active layer in the silicon     
310   fPinDiodeSize[2] = 1.61 ;    
311   
312   fUpperCoolingPlateThickness   = 0.06 ; 
313   fSupportPlateThickness        = 10.0 ;
314   fLowerThermoPlateThickness    =  3.0 ; 
315   fLowerTextolitPlateThickness  =  1.0 ;
316   fGapBetweenCrystals           = 0.03 ;
317   
318   fTextolitBoxThickness[0] = 1.5 ;  
319   fTextolitBoxThickness[1] = 0.0 ;   
320   fTextolitBoxThickness[2] = 3.0 ; 
321   
322   fAirThickness[0] =  1.56   ;
323   fAirThickness[1] = 20.5175 ;  
324   fAirThickness[2] =  2.48   ;  
325   
326   Float_t xtalModulePhiSize =  fNPhi * ( fXtlSize[0] + 2 * fGapBetweenCrystals ) ; 
327   Float_t xtalModuleZSize   =  fNZ * ( fXtlSize[2] + 2 * fGapBetweenCrystals ) ;
328   
329   // The next dimensions are calculated from the above parameters
330   
331   fOuterBoxSize[0] =  xtalModulePhiSize + 2 * ( fAirThickness[0] + fModuleBoxThickness
332                                                 + fTextolitBoxThickness[0] + fOuterBoxThickness[0] ) ; 
333   fOuterBoxSize[1] = ( fXtlSize[1] + fCrystalSupportHeight + fCrystalWrapThickness + fCrystalHolderThickness )
334     + 2 * (fAirThickness[1] +  fModuleBoxThickness + fTextolitBoxThickness[1] + fOuterBoxThickness[1] ) ;
335   fOuterBoxSize[2] =  xtalModuleZSize +  2 * ( fAirThickness[2] + fModuleBoxThickness 
336                                                + fTextolitBoxThickness[2] + fOuterBoxThickness[2] ) ; 
337   
338   fTextolitBoxSize[0]  = fOuterBoxSize[0] - 2 * fOuterBoxThickness[0] ;
339   fTextolitBoxSize[1]  = fOuterBoxSize[1] -  fOuterBoxThickness[1] - fUpperPlateThickness ;
340   fTextolitBoxSize[2]  = fOuterBoxSize[2] - 2 * fOuterBoxThickness[2] ;
341   
342   fAirFilledBoxSize[0] =  fTextolitBoxSize[0] - 2 * fTextolitBoxThickness[0] ; 
343   fAirFilledBoxSize[1] =  fTextolitBoxSize[1] - fSecondUpperPlateThickness ; 
344   fAirFilledBoxSize[2] =  fTextolitBoxSize[2] - 2 * fTextolitBoxThickness[2] ; 
345   
346 }
347
348 //____________________________________________________________________________
349 void AliPHOSGeometry::InitPPSD(void)
350 {
351   // Initializes the PPSD parameters
352     
353   fAnodeThickness           = 0.0009 ; 
354   fAvalancheGap             = 0.01 ; 
355   fCathodeThickness         = 0.0009 ;
356   fCompositeThickness       = 0.3 ; 
357   fConversionGap            = 0.6 ; 
358   fLeadConverterThickness   = 0.56 ; 
359   fLeadToMicro2Gap          = 0.1 ; 
360   fLidThickness             = 0.2 ; 
361   fMicro1ToLeadGap          = 0.1 ; 
362   fMicromegasWallThickness  = 0.6 ; 
363   fNumberOfModulesPhi       = 4 ; 
364   fNumberOfModulesZ         = 4 ; 
365   fNumberOfPadsPhi          = 24 ; 
366   fNumberOfPadsZ            = 24 ;   
367   fPCThickness              = 0.1 ; 
368   fPhiDisplacement          = 0.8 ;  
369   fZDisplacement            = 0.8 ;  
370
371   fMicromegas1Thickness   = fLidThickness + 2 * fCompositeThickness + fCathodeThickness + fPCThickness 
372                               + fAnodeThickness + fConversionGap + fAvalancheGap ; 
373   fMicromegas2Thickness   = fMicromegas1Thickness ; 
374
375
376   fPPSDModuleSize[0] = 38.0 ; 
377   fPPSDModuleSize[1] = fMicromegas1Thickness ; 
378   fPPSDModuleSize[2] = 38.0 ; 
379  
380   fPPSDBoxSize[0] = fNumberOfModulesPhi * fPPSDModuleSize[0] + 2 * fPhiDisplacement ;  
381   fPPSDBoxSize[1] = fMicromegas2Thickness + fMicromegas2Thickness + fLeadConverterThickness + fMicro1ToLeadGap + fLeadToMicro2Gap ;    
382   fPPSDBoxSize[2] = fNumberOfModulesZ *  fPPSDModuleSize[2] + 2 * fZDisplacement ;
383
384   fIPtoTopLidDistance     = fIPtoOuterCoverDistance -  fPPSDBoxSize[1] - 1. ;  
385   
386 }
387
388 //____________________________________________________________________________
389 AliPHOSGeometry *  AliPHOSGeometry::GetInstance() 
390
391   // Returns the pointer of the unique instance
392   
393   return (AliPHOSGeometry *) fgGeom ; 
394 }
395
396 //____________________________________________________________________________
397 AliPHOSGeometry *  AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title) 
398 {
399   // Returns the pointer of the unique instance
400
401   AliPHOSGeometry * rv = 0  ; 
402   if ( fgGeom == 0 ) {
403     fgGeom = new AliPHOSGeometry(name, title) ; 
404     rv = (AliPHOSGeometry * ) fgGeom ; 
405   }
406   else {
407     if ( strcmp(fgGeom->GetName(), name) != 0 ) {
408       cout << "AliPHOSGeometry <E> : current geometry is " << fgGeom->GetName() << endl
409            << "                      you cannot call     " << name << endl ; 
410     }
411     else
412       rv = (AliPHOSGeometry *) fgGeom ; 
413   } 
414   return rv ; 
415 }
416
417 //____________________________________________________________________________
418 Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t &  AbsId)
419 {
420   // Converts the relative numbering into the absolute numbering
421   //  AbsId = 1:fNModules * fNPhi * fNZ  -> PbWO4
422   //  AbsId = 1:fNModules * 2 * (fNumberOfModulesPhi * fNumberOfModulesZ) * fNumberOfPadsPhi * fNumberOfPadsZ -> PPSD
423
424   Bool_t rv = kTRUE ; 
425  
426   if ( relid[1] > 0 ) { // its a PPSD pad
427
428     AbsId =    GetNPhi() * GetNZ() *  GetNModules()                          // the offset to separate emcal crystals from PPSD pads
429       + ( relid[0] - 1 ) * GetNumberOfModulesPhi() * GetNumberOfModulesZ()   // the pads offset of PHOS modules 
430                          * GetNumberOfPadsPhi() * GetNumberOfPadsZ() * 2
431       + ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ()         // the pads offset of PPSD modules 
432       + ( relid[2] - 1 ) * GetNumberOfPadsPhi()                              // the pads offset of a PPSD row
433       + relid[3] ;                                                           // the column number
434   } 
435   else {
436     if ( relid[1] == 0 ) { // its a Phos crystal
437       AbsId =  ( relid[0] - 1 ) *  GetNPhi() * GetNZ() // the offset of PHOS modules
438         + ( relid[2] - 1 ) * GetNPhi()                 // the offset of a xtal row
439         + relid[3] ;                                   // the column number
440     }
441   }
442
443   return rv ; 
444 }
445
446 //____________________________________________________________________________
447
448 void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) 
449 {
450   // Converts the absolute numbering into the global ALICE coordinates
451   
452    if (id > 0) { 
453
454   Int_t relid[4] ;
455  
456   AbsToRelNumbering(id , relid) ;
457
458   Int_t phosmodule = relid[0] ; 
459
460   Float_t y0 = 0 ; 
461
462   if ( relid[1] == 0 ) // it is a PbW04 crystal 
463   {  y0 =  -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
464       + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness())  ;  
465   }
466   if ( relid[1] > 0 ) { // its a PPSD pad
467     if ( relid[1] >  GetNumberOfModulesPhi() *  GetNumberOfModulesZ() ) // its an bottom module
468      {
469        y0 = -( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0)  ;
470      } 
471     else // its an upper module
472       y0 = -( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() - GetLeadToMicro2Gap()
473         -  GetLeadConverterThickness() -  GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0) ; 
474   }
475
476   Float_t x, z ; 
477   RelPosInModule(relid, x, z) ; 
478
479   pos.SetX(x) ;
480   pos.SetZ(z) ;
481   pos.SetY( TMath::Sqrt(x*x + z*z + y0*y0) ) ; 
482
483
484
485    Float_t phi           = GetPHOSAngle( phosmodule) ; 
486    Double_t const kRADDEG = 180.0 / kPI ;
487    Float_t rphi          = phi / kRADDEG ; 
488
489    TRotation rot ;
490    rot.RotateZ(-rphi) ; // a rotation around Z by angle  
491   
492    TRotation dummy = rot.Invert() ;  // to transform from original frame to rotate frame
493   
494    pos.Transform(rot) ; // rotate the baby 
495   }
496   else {
497  pos.SetX(0.);
498  pos.SetY(0.);
499  pos.SetZ(0.);
500        }
501
502
503 //____________________________________________________________________________
504 void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) 
505 {
506   // Converts the relative numbering into the local PHOS-module (x, z) coordinates
507   
508   Int_t ppsdmodule  ; 
509   Int_t row        = relid[2] ; //offset along z axiz
510   Int_t column     = relid[3] ; //offset along x axiz
511
512   Float_t padsizeZ = GetPPSDModuleSize(2)/ GetNumberOfPadsZ();
513   Float_t padsizeX = GetPPSDModuleSize(0)/ GetNumberOfPadsPhi();
514
515   if ( relid[1] == 0 ) { // its a PbW04 crystal 
516     x = -( GetNPhi()/2. - row   + 0.5 ) *  GetCrystalSize(0) ; // position ox Xtal with respect
517     z = ( GetNZ() /2. - column + 0.5 ) *  GetCrystalSize(2) ; // of center of PHOS module  
518    }  
519    else  {    
520     if ( relid[1] >  GetNumberOfModulesPhi() *  GetNumberOfModulesZ() )
521        ppsdmodule =  relid[1]-GetNumberOfModulesPhi() *  GetNumberOfModulesZ(); 
522     else ppsdmodule =  relid[1] ;
523     Int_t modrow = 1+(Int_t)TMath::Ceil( (Float_t)ppsdmodule / GetNumberOfModulesPhi()-1. ) ; 
524     Int_t modcol = ppsdmodule -  ( modrow - 1 ) * GetNumberOfModulesPhi() ;     
525     Float_t x0 = (  GetNumberOfModulesPhi() / 2.  - modrow  + 0.5 ) * GetPPSDModuleSize(0) ;
526     Float_t z0 = (  GetNumberOfModulesZ() / 2.  - modcol  + 0.5 ) * GetPPSDModuleSize(2)  ;     
527     x = - ( GetNumberOfPadsPhi()/2. - row - 0.5 ) * padsizeX + x0 ; // position of pad  with respect
528     z = ( GetNumberOfPadsZ()/2.   - column - 0.5 ) * padsizeZ - z0 ; // of center of PHOS module  
529          }
530 }
531
532 //____________________________________________________________________________
533 void AliPHOSGeometry::SetPHOSAngles() 
534
535   // Calculates the position in ALICE of the PHOS modules
536   
537   Double_t const kRADDEG = 180.0 / kPI ;
538   Float_t pphi =  TMath::ATan( fOuterBoxSize[0]  / ( 2.0 * fIPtoOuterCoverDistance ) ) ;
539   pphi *= kRADDEG ;
540   
541   for( Int_t i = 1; i <= fNModules ; i++ ) {
542     Float_t angle = pphi * 2 * ( i - fNModules / 2.0 - 0.5 ) ;
543     fPHOSAngle[i-1] = -  angle ;
544   } 
545 }
546
547 //____________________________________________________________________________
548 void AliPHOSGeometry::SetLeadConverterThickness(Float_t e) 
549 {
550   // should ultimately disappear 
551   
552   cout << " AliPHOSGeometry WARNING : You have changed LeadConverterThickness from " 
553        << fLeadConverterThickness << " to " << e << endl ;
554
555   fLeadConverterThickness = e ; 
556 }