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