]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSGeometry.cxx
new format for raw data
[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
a3dfe79c 20// PHOS consists of the electromagnetic calorimeter (EMCA)
21// and a charged particle veto either in the Subatech's version (PPSD)
22// or in the IHEP's one (CPV).
23// The EMCA/PPSD/CPV modules are parametrized so that any configuration
24// can be easily implemented
25// The title is used to identify the version of CPV used.
b2a60966 26//
05d33a3d 27// -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH)
d15a28e7 28
29// --- ROOT system ---
30
31#include "TVector3.h"
32#include "TRotation.h"
e957fea8 33#include "TParticle.h"
d15a28e7 34
35// --- Standard library ---
36
d15a28e7 37// --- AliRoot header files ---
351dd634 38#include "AliLog.h"
d15a28e7 39#include "AliPHOSGeometry.h"
468794ea 40#include "AliPHOSEMCAGeometry.h"
710f859a 41#include "AliPHOSRecPoint.h"
d15a28e7 42
925e6570 43ClassImp(AliPHOSGeometry)
d15a28e7 44
a4e98857 45// these initialisations are needed for a singleton
05d33a3d 46AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
47Bool_t AliPHOSGeometry::fgInit = kFALSE ;
9ec91567 48
e957fea8 49//____________________________________________________________________________
50AliPHOSGeometry::AliPHOSGeometry() {
51 // default ctor
52 // must be kept public for root persistency purposes, but should never be called by the outside world
53 fPHOSAngle = 0 ;
54 fGeometryEMCA = 0 ;
55 fGeometrySUPP = 0 ;
56 fGeometryCPV = 0 ;
57 fgGeom = 0 ;
58 fRotMatrixArray = 0 ;
59}
60
d15a28e7 61//____________________________________________________________________________
62AliPHOSGeometry::~AliPHOSGeometry(void)
63{
b2a60966 64 // dtor
65
52a36ffd 66 if (fRotMatrixArray) fRotMatrixArray->Delete() ;
67 if (fRotMatrixArray) delete fRotMatrixArray ;
fa0bc588 68 if (fPHOSAngle ) delete[] fPHOSAngle ;
52a36ffd 69}
52a36ffd 70//____________________________________________________________________________
71
72void AliPHOSGeometry::Init(void)
73{
a4e98857 74 // Initializes the PHOS parameters :
75 // IHEP is the Protvino CPV (cathode pad chambers)
710f859a 76
809cd394 77 TString test(GetName()) ;
22b8277f 78 if (test != "IHEP" ) {
351dd634 79 AliFatal(Form("%s is not a known geometry (choose among IHEP)",
80 test.Data() )) ;
809cd394 81 }
82
710f859a 83 fgInit = kTRUE ;
05d33a3d 84
85698486 85 fNModules = 5;
86 fAngle = 20;
05d33a3d 87
710f859a 88 fGeometryEMCA = new AliPHOSEMCAGeometry();
89
90 fGeometryCPV = new AliPHOSCPVGeometry ();
91
92 fGeometrySUPP = new AliPHOSSupportGeometry();
93
94 fPHOSAngle = new Float_t[fNModules] ;
95
96 Float_t * emcParams = fGeometryEMCA->GetEMCParams() ;
97
581e32d4 98 fPHOSParams[0] = TMath::Max((Double_t)fGeometryCPV->GetCPVBoxSize(0)/2.,
a83b6179 99 (Double_t)(emcParams[0] - (emcParams[1]-emcParams[0])*
100 fGeometryCPV->GetCPVBoxSize(1)/2/emcParams[3]));
710f859a 101 fPHOSParams[1] = emcParams[1] ;
581e32d4 102 fPHOSParams[2] = TMath::Max((Double_t)emcParams[2], (Double_t)fGeometryCPV->GetCPVBoxSize(2)/2.);
710f859a 103 fPHOSParams[3] = emcParams[3] + fGeometryCPV->GetCPVBoxSize(1)/2. ;
104
105 fIPtoUpperCPVsurface = fGeometryEMCA->GetIPtoOuterCoverDistance() - fGeometryCPV->GetCPVBoxSize(1) ;
106
107 Int_t index ;
108 for ( index = 0; index < fNModules; index++ )
52a36ffd 109 fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
710f859a 110
710f859a 111 fRotMatrixArray = new TObjArray(fNModules) ;
05d33a3d 112
85698486 113 // Geometry parameters are calculated
114
115 SetPHOSAngles();
116 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
117 Float_t r = GetIPtoOuterCoverDistance() + fPHOSParams[3] - GetCPVBoxSize(1) ;
118 for (Int_t iModule=0; iModule<fNModules; iModule++) {
119 fModuleCenter[iModule][0] = r * TMath::Sin(fPHOSAngle[iModule] / kRADDEG );
120 fModuleCenter[iModule][1] =-r * TMath::Cos(fPHOSAngle[iModule] / kRADDEG );
121 fModuleCenter[iModule][2] = 0.;
122
123 fModuleAngle[iModule][0][0] = 90;
124 fModuleAngle[iModule][0][1] = fPHOSAngle[iModule];
125 fModuleAngle[iModule][1][0] = 0;
126 fModuleAngle[iModule][1][1] = 0;
127 fModuleAngle[iModule][2][0] = 90;
128 fModuleAngle[iModule][2][1] = 270 + fPHOSAngle[iModule];
05d33a3d 129 }
130
52a36ffd 131}
132
133//____________________________________________________________________________
134AliPHOSGeometry * AliPHOSGeometry::GetInstance()
135{
a4e98857 136 // Returns the pointer of the unique instance; singleton specific
137
809cd394 138 return static_cast<AliPHOSGeometry *>( fgGeom ) ;
52a36ffd 139}
140
141//____________________________________________________________________________
142AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title)
143{
144 // Returns the pointer of the unique instance
a4e98857 145 // Creates it with the specified options (name, title) if it does not exist yet
146
52a36ffd 147 AliPHOSGeometry * rv = 0 ;
148 if ( fgGeom == 0 ) {
149 if ( strcmp(name,"") == 0 )
150 rv = 0 ;
151 else {
152 fgGeom = new AliPHOSGeometry(name, title) ;
153 if ( fgInit )
154 rv = (AliPHOSGeometry * ) fgGeom ;
155 else {
156 rv = 0 ;
157 delete fgGeom ;
158 fgGeom = 0 ;
159 }
160 }
161 }
162 else {
21cd0c07 163 if ( strcmp(fgGeom->GetName(), name) != 0 )
351dd634 164 ::Error("GetInstance", "Current geometry is %s. You cannot call %s",
165 fgGeom->GetName(), name) ;
52a36ffd 166 else
167 rv = (AliPHOSGeometry *) fgGeom ;
168 }
169 return rv ;
170}
4697edca 171
52a36ffd 172//____________________________________________________________________________
173void AliPHOSGeometry::SetPHOSAngles()
174{
a4e98857 175 // Calculates the position of the PHOS modules in ALICE global coordinate system
52a36ffd 176
a8c47ab6 177 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
710f859a 178 Float_t pphi = 2 * TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ;
52a36ffd 179 pphi *= kRADDEG ;
710f859a 180 if (pphi > fAngle){
351dd634 181 AliError(Form("PHOS modules overlap!\n pphi = %f fAngle = %f",
182 pphi, fAngle));
710f859a 183
184 }
ed4205d8 185 pphi = fAngle;
52a36ffd 186
187 for( Int_t i = 1; i <= fNModules ; i++ ) {
ed4205d8 188 Float_t angle = pphi * ( i - fNModules / 2.0 - 0.5 ) ;
52a36ffd 189 fPHOSAngle[i-1] = - angle ;
190 }
d15a28e7 191}
192
193//____________________________________________________________________________
fc7e2f43 194Bool_t AliPHOSGeometry::AbsToRelNumbering(Int_t AbsId, Int_t * relid) const
d15a28e7 195{
b2a60966 196 // Converts the absolute numbering into the following array/
197 // relid[0] = PHOS Module number 1:fNModules
198 // relid[1] = 0 if PbW04
710f859a 199 // = -1 if CPV
200 // relid[2] = Row number inside a PHOS module
201 // relid[3] = Column number inside a PHOS module
d15a28e7 202
203 Bool_t rv = kTRUE ;
92862013 204 Float_t id = AbsId ;
d15a28e7 205
710f859a 206 Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / GetNCristalsInModule() ) ;
d15a28e7 207
710f859a 208 if ( phosmodulenumber > GetNModules() ) { // it is a CPV pad
209
210 id -= GetNPhi() * GetNZ() * GetNModules() ;
211 Float_t nCPV = GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() ;
212 relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ;
213 relid[1] = -1 ;
214 id -= ( relid[0] - 1 ) * nCPV ;
215 relid[2] = (Int_t) TMath::Ceil( id / GetNumberOfCPVPadsZ() ) ;
216 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() ) ;
d15a28e7 217 }
710f859a 218 else { // it is a PW04 crystal
d15a28e7 219
92862013 220 relid[0] = phosmodulenumber ;
221 relid[1] = 0 ;
222 id -= ( phosmodulenumber - 1 ) * GetNPhi() * GetNZ() ;
710f859a 223 relid[2] = (Int_t)TMath::Ceil( id / GetNZ() ) ;
224 relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNZ() ) ;
d15a28e7 225 }
226 return rv ;
227}
52a36ffd 228
9f616d61 229//____________________________________________________________________________
fc7e2f43 230void AliPHOSGeometry::EmcModuleCoverage(Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) const
9f616d61 231{
a4e98857 232 // calculates the angular coverage in theta and phi of one EMC (=PHOS) module
9f616d61 233
234 Double_t conv ;
cf0c2bc1 235 if ( opt == Radian() )
9f616d61 236 conv = 1. ;
cf0c2bc1 237 else if ( opt == Degre() )
9f616d61 238 conv = 180. / TMath::Pi() ;
239 else {
351dd634 240 AliWarning(Form("%s unknown option; result in radian", opt)) ;
9f616d61 241 conv = 1. ;
242 }
243
710f859a 244 Float_t phi = GetPHOSAngle(mod) * (TMath::Pi() / 180.) ;
245 Float_t y0 = GetIPtoCrystalSurface() ;
88cb7938 246 Float_t * strip = fGeometryEMCA->GetStripHalfSize() ;
247 Float_t x0 = fGeometryEMCA->GetNStripX()*strip[0] ;
248 Float_t z0 = fGeometryEMCA->GetNStripZ()*strip[2] ;
249 Double_t angle = TMath::ATan( x0 / y0 ) ;
710f859a 250 phi = phi + 1.5 * TMath::Pi() ; // to follow the convention of the particle generator(PHOS is between 220 and 320 deg.)
92862013 251 Double_t max = phi - angle ;
252 Double_t min = phi + angle ;
253 pM = TMath::Max(max, min) * conv ;
254 pm = TMath::Min(max, min) * conv ;
9f616d61 255
88cb7938 256 angle = TMath::ATan( z0 / y0 ) ;
92862013 257 max = TMath::Pi() / 2. + angle ; // to follow the convention of the particle generator(PHOS is at 90 deg.)
258 min = TMath::Pi() / 2. - angle ;
259 tM = TMath::Max(max, min) * conv ;
260 tm = TMath::Min(max, min) * conv ;
9f616d61 261
262}
263
264//____________________________________________________________________________
7b7c1533 265void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt) const
9f616d61 266{
a4e98857 267 // calculates the angular coverage in theta and phi of a single crystal in a EMC(=PHOS) module
9f616d61 268
269 Double_t conv ;
cf0c2bc1 270 if ( opt == Radian() )
9f616d61 271 conv = 1. ;
cf0c2bc1 272 else if ( opt == Degre() )
9f616d61 273 conv = 180. / TMath::Pi() ;
274 else {
351dd634 275 AliWarning(Form("%s unknown option; result in radian", opt)) ;
9f616d61 276 conv = 1. ;
277 }
278
710f859a 279 Float_t y0 = GetIPtoCrystalSurface() ;
92862013 280 theta = 2 * TMath::ATan( GetCrystalSize(2) / (2 * y0) ) * conv ;
281 phi = 2 * TMath::ATan( GetCrystalSize(0) / (2 * y0) ) * conv ;
9f616d61 282}
283
284
285//____________________________________________________________________________
e8d02863 286void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrixF & /*gmat*/) const
d15a28e7 287{
a4e98857 288 // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system
b2a60966 289
d15a28e7 290 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
92862013 291 TVector3 localposition ;
d15a28e7 292
293 tmpPHOS->GetLocalPosition(gpos) ;
294
295
296 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
710f859a 297 { gpos.SetY( - GetIPtoCrystalSurface()) ;
d15a28e7 298
299 }
300 else
710f859a 301 { // it is a CPV
302 gpos.SetY(- GetIPtoUpperCPVsurface() ) ;
d15a28e7 303 }
304
92862013 305 Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
a8c47ab6 306 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
92862013 307 Float_t rphi = phi / kRADDEG ;
d15a28e7 308
92862013 309 TRotation rot ;
310 rot.RotateZ(-rphi) ; // a rotation around Z by angle
d15a28e7 311
92862013 312 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
313 gpos.Transform(rot) ; // rotate the baby
6ad0bfa0 314
d15a28e7 315}
316
317//____________________________________________________________________________
5cda30f6 318void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) const
d15a28e7 319{
a4e98857 320 // Calculates the coordinates of a RecPoint in the ALICE global coordinate system
b2a60966 321
d15a28e7 322 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
92862013 323 TVector3 localposition ;
d15a28e7 324 tmpPHOS->GetLocalPosition(gpos) ;
325
326
327 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
710f859a 328 { gpos.SetY( - GetIPtoCrystalSurface() ) ;
d15a28e7 329 }
330 else
710f859a 331 { // it is a CPV
332 gpos.SetY(- GetIPtoUpperCPVsurface() ) ;
d15a28e7 333 }
334
92862013 335 Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
a8c47ab6 336 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
92862013 337 Float_t rphi = phi / kRADDEG ;
d15a28e7 338
92862013 339 TRotation rot ;
340 rot.RotateZ(-rphi) ; // a rotation around Z by angle
d15a28e7 341
92862013 342 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
343 gpos.Transform(rot) ; // rotate the baby
d15a28e7 344}
345
346//____________________________________________________________________________
aa35fc01 347void AliPHOSGeometry::ImpactOnEmc(Double_t theta, Double_t phi, Int_t & moduleNumber, Double_t & z, Double_t & x) const
d15a28e7 348{
a4e98857 349 // calculates the impact coordinates on PHOS of a neutral particle
350 // emitted in the direction theta and phi in the ALICE global coordinate system
d15a28e7 351
52a36ffd 352 // searches for the PHOS EMC module
aa35fc01 353
354 moduleNumber = 0 ;
52a36ffd 355 Double_t tm, tM, pm, pM ;
356 Int_t index = 1 ;
aa35fc01 357 while ( moduleNumber == 0 && index <= GetNModules() ) {
52a36ffd 358 EmcModuleCoverage(index, tm, tM, pm, pM) ;
88cb7938 359 if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) )
aa35fc01 360 moduleNumber = index ;
52a36ffd 361 index++ ;
d15a28e7 362 }
aa35fc01 363 if ( moduleNumber != 0 ) {
364 Float_t phi0 = GetPHOSAngle(moduleNumber) * (TMath::Pi() / 180.) + 1.5 * TMath::Pi() ;
710f859a 365 Float_t y0 = GetIPtoCrystalSurface() ;
88cb7938 366 Double_t angle = phi - phi0;
52a36ffd 367 x = y0 * TMath::Tan(angle) ;
368 angle = theta - TMath::Pi() / 2 ;
369 z = y0 * TMath::Tan(angle) ;
d15a28e7 370 }
d15a28e7 371}
372
aa35fc01 373//____________________________________________________________________________
7b51037f 374void AliPHOSGeometry::ImpactOnEmc(const TVector3& vec, Int_t & moduleNumber, Double_t & z, Double_t & x) const
aa35fc01 375{
376 // calculates the impact coordinates on PHOS of a neutral particle
377 // emitted in the direction theta and phi in the ALICE global coordinate system
378 // searches for the PHOS EMC module
379
7b51037f 380 Double_t theta = vec.Theta() ;
381 Double_t phi = vec.Phi() ;
382
383 ImpactOnEmc(theta, phi, moduleNumber, z, x) ;
aa35fc01 384}
385
386//____________________________________________________________________________
7b51037f 387void AliPHOSGeometry::ImpactOnEmc(const TParticle& p, Int_t & moduleNumber, Double_t & z, Double_t & x) const
aa35fc01 388{
389 // calculates the impact coordinates on PHOS of a neutral particle
390 // emitted in the direction theta and phi in the ALICE global coordinate system
391
392 // searches for the PHOS EMC module
393 Double_t theta = p.Theta() ;
394 Double_t phi = p.Phi() ;
395
396 ImpactOnEmc(theta, phi, moduleNumber, z, x) ;
397}
398
e957fea8 399//____________________________________________________________________________
1c9d8212 400Bool_t AliPHOSGeometry::Impact(const TParticle * particle) const
401{
e957fea8 402 // Tells if a particle enters PHOS
403 Bool_t in=kFALSE;
404 Int_t moduleNumber=0;
1c9d8212 405 Double_t z,x;
e957fea8 406 ImpactOnEmc(particle->Theta(),particle->Phi(),moduleNumber,z,x);
407 if(moduleNumber)
408 in=kTRUE;
409 else
410 in=kFALSE;
411 return in;
1c9d8212 412}
413
d15a28e7 414//____________________________________________________________________________
7b7c1533 415Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId) const
d15a28e7 416{
b2a60966 417 // Converts the relative numbering into the absolute numbering
ed4205d8 418 // EMCA crystals:
419 // AbsId = from 1 to fNModules * fNPhi * fNZ
ed4205d8 420 // CPV pad:
421 // AbsId = from N(total PHOS crystals) + 1
422 // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ
d15a28e7 423
424 Bool_t rv = kTRUE ;
710f859a 425
426 if ( relid[1] == 0 ) { // it is a Phos crystal
52a36ffd 427 AbsId =
710f859a 428 ( relid[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules
429 + ( relid[2] - 1 ) * GetNZ() // the offset along phi
430 + relid[3] ; // the offset along z
d15a28e7 431 }
710f859a 432 else { // it is a CPV pad
433 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads
434 + ( relid[0] - 1 ) * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of PHOS modules
435 + ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() // the pads offset of a CPV row
52a36ffd 436 + relid[3] ; // the column number
437 }
438
d15a28e7 439 return rv ;
440}
441
442//____________________________________________________________________________
443
fc7e2f43 444void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const
d15a28e7 445{
a4e98857 446 // Converts the absolute numbering into the global ALICE coordinate system
b2a60966 447
ed4205d8 448
449 Int_t relid[4] ;
450
451 AbsToRelNumbering(id , relid) ;
452
453 Int_t phosmodule = relid[0] ;
454
455 Float_t y0 = 0 ;
456
710f859a 457 if ( relid[1] == 0 ) // it is a PbW04 crystal
458 y0 = - GetIPtoCrystalSurface() ;
459 else
460 y0 = - GetIPtoUpperCPVsurface() ;
461
ed4205d8 462 Float_t x, z ;
463 RelPosInModule(relid, x, z) ;
464
465 pos.SetX(x) ;
466 pos.SetZ(z) ;
710f859a 467 pos.SetY(y0) ;
ed4205d8 468
469 Float_t phi = GetPHOSAngle( phosmodule) ;
a8c47ab6 470 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
ed4205d8 471 Float_t rphi = phi / kRADDEG ;
472
473 TRotation rot ;
474 rot.RotateZ(-rphi) ; // a rotation around Z by angle
475
476 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
477
478 pos.Transform(rot) ; // rotate the baby
d15a28e7 479}
480
481//____________________________________________________________________________
5d0435dd 482void AliPHOSGeometry::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & AbsId) const
842988a5 483{
484 // converts local PHOS-module (x, z) coordinates to absId
485 Int_t relid[4] ;
486 relid[0] = module ;
487 relid[1] = 0 ;
488 relid[2] = static_cast<Int_t>(TMath::Ceil( x/ GetCellStep() + GetNPhi() / 2.) );
489 relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ GetCellStep() + GetNZ() / 2.) ) ;
490
491 RelToAbsNumbering(relid,AbsId) ;
492}
493
494//____________________________________________________________________________
7b7c1533 495void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const
d15a28e7 496{
b2a60966 497 // Converts the relative numbering into the local PHOS-module (x, z) coordinates
52a36ffd 498 // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000)
b2a60966 499
786222b3 500 Int_t row = relid[2] ; //offset along x axis
501 Int_t column = relid[3] ; //offset along z axis
d15a28e7 502
ed4205d8 503
66c3e8ff 504 if ( relid[1] == 0 ) { // its a PbW04 crystal
505 x = - ( GetNPhi()/2. - row + 0.5 ) * GetCellStep() ; // position of Xtal with respect
4a76d472 506 z = - ( GetNZ() /2. - column + 0.5 ) * GetCellStep() ; // of center of PHOS module
52a36ffd 507 }
508 else {
710f859a 509 x = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect
4a76d472 510 z = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module
52a36ffd 511 }
2f3366b6 512}
aa0b9641 513
514//____________________________________________________________________________
515
7b51037f 516void AliPHOSGeometry::GetModuleCenter(TVector3& center,
517 const char *det,
518 Int_t module) const
aa0b9641 519{
bfc17d18 520 // Returns a position of the center of the CPV or EMC module
1504ac47 521 Float_t rDet = 0.;
e77bb310 522 if (strcmp(det,"CPV") == 0) rDet = GetIPtoCPVDistance ();
523 else if (strcmp(det,"EMC") == 0) rDet = GetIPtoCrystalSurface();
351dd634 524 else
525 AliFatal(Form("Wrong detector name %s",det));
bfc17d18 526
395f4eea 527 Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
528 angle *= TMath::Pi()/180;
529 angle += 3*TMath::Pi()/2.;
7b51037f 530 center.SetXYZ(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.);
aa0b9641 531}
532
533//____________________________________________________________________________
534
7b51037f 535void AliPHOSGeometry::Global2Local(TVector3& localPosition,
536 const TVector3& globalPosition,
537 Int_t module) const
aa0b9641 538{
bfc17d18 539 // Transforms a global position of the rec.point to the local coordinate system
395f4eea 540 Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
541 angle *= TMath::Pi()/180;
542 angle += 3*TMath::Pi()/2.;
7b51037f 543 localPosition = globalPosition;
544 localPosition.RotateZ(-angle);
aa0b9641 545}