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