Updated version with the Bari/Salerno model as default
[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//
27//*-- Author: Yves Schutz (SUBATECH)
d15a28e7 28
29// --- ROOT system ---
30
31#include "TVector3.h"
32#include "TRotation.h"
33
34// --- Standard library ---
35
de9ec31b 36#include <iostream.h>
d15a28e7 37
38// --- AliRoot header files ---
39
40#include "AliPHOSGeometry.h"
468794ea 41#include "AliPHOSEMCAGeometry.h"
d15a28e7 42#include "AliPHOSPpsdRecPoint.h"
43#include "AliConst.h"
44
9ec91567 45ClassImp(AliPHOSGeometry) ;
d15a28e7 46
9ec91567 47AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
282c5906 48Bool_t AliPHOSGeometry::fgInit = kFALSE ;
9ec91567 49
d15a28e7 50//____________________________________________________________________________
51AliPHOSGeometry::~AliPHOSGeometry(void)
52{
b2a60966 53 // dtor
54
52a36ffd 55 if (fRotMatrixArray) fRotMatrixArray->Delete() ;
56 if (fRotMatrixArray) delete fRotMatrixArray ;
57 if (fPHOSAngle ) delete fPHOSAngle ;
58}
59
60//____________________________________________________________________________
61
62void AliPHOSGeometry::Init(void)
63{
64 // Initializes the PHOS parameters
65
52a36ffd 66 if ( ((strcmp( fName, "default" )) == 0) ||
67 ((strcmp( fName, "GPS2" )) == 0) ||
ed4205d8 68 ((strcmp( fName, "IHEP" )) == 0) ||
69 ((strcmp( fName, "MIXT" )) == 0) ) {
52a36ffd 70 fgInit = kTRUE ;
ed4205d8 71
72 fNModules = 5;
73 fNPPSDModules = 0;
74 fAngle = 20;
75
76 fGeometryEMCA = new AliPHOSEMCAGeometry();
77 if ( ((strcmp( fName, "GPS2" )) == 0) ) {
78 fGeometryPPSD = new AliPHOSPPSDGeometry();
79 fGeometryCPV = 0;
80 fNPPSDModules = fNModules;
81 }
82 else if ( ((strcmp( fName, "IHEP" )) == 0) ) {
83 fGeometryCPV = new AliPHOSCPVGeometry ();
84 fGeometryPPSD = 0;
85 fNPPSDModules = 0;
86 }
87 else if ( ((strcmp( fName, "MIXT" )) == 0) ) {
88 fGeometryCPV = new AliPHOSCPVGeometry ();
89 fGeometryPPSD = new AliPHOSPPSDGeometry();
90 fNPPSDModules = 1;
91 }
92 fGeometrySUPP = new AliPHOSSupportGeometry();
93
52a36ffd 94 fPHOSAngle = new Float_t[fNModules] ;
95 Int_t index ;
96 for ( index = 0; index < fNModules; index++ )
97 fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
98
99 this->SetPHOSAngles() ;
100 fRotMatrixArray = new TObjArray(fNModules) ;
101 }
ed4205d8 102 else {
103 fgInit = kFALSE ;
104 cout << "PHOS Geometry setup: option not defined " << fName << endl ;
105 }
52a36ffd 106}
107
108//____________________________________________________________________________
2f04ed65 109Float_t AliPHOSGeometry::GetCPVBoxSize(Int_t index) const {
110 if (strcmp(fName,"GPS2") ==0 )
111 return fGeometryPPSD->GetCPVBoxSize(index);
112 else if (strcmp(fName,"IHEP")==0)
113 return fGeometryCPV ->GetCPVBoxSize(index);
114 else if (strcmp(fName,"MIXT")==0)
115 return TMath::Max(fGeometryCPV ->GetCPVBoxSize(index), fGeometryPPSD->GetCPVBoxSize(index));
116 else
117 return 0;
118}
119
120//____________________________________________________________________________
52a36ffd 121AliPHOSGeometry * AliPHOSGeometry::GetInstance()
122{
123 // Returns the pointer of the unique instance
124 return (AliPHOSGeometry *) fgGeom ;
125}
126
127//____________________________________________________________________________
128AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title)
129{
130 // Returns the pointer of the unique instance
131 AliPHOSGeometry * rv = 0 ;
132 if ( fgGeom == 0 ) {
133 if ( strcmp(name,"") == 0 )
134 rv = 0 ;
135 else {
136 fgGeom = new AliPHOSGeometry(name, title) ;
137 if ( fgInit )
138 rv = (AliPHOSGeometry * ) fgGeom ;
139 else {
140 rv = 0 ;
141 delete fgGeom ;
142 fgGeom = 0 ;
143 }
144 }
145 }
146 else {
147 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
148 cout << "AliPHOSGeometry <E> : current geometry is " << fgGeom->GetName() << endl
149 << " you cannot call " << name << endl ;
150 }
151 else
152 rv = (AliPHOSGeometry *) fgGeom ;
153 }
154 return rv ;
155}
4697edca 156
52a36ffd 157//____________________________________________________________________________
158void AliPHOSGeometry::SetPHOSAngles()
159{
160 // Calculates the position in ALICE of the PHOS modules
161
162 Double_t const kRADDEG = 180.0 / kPI ;
ed4205d8 163 Float_t pphi = 2 * TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoOuterCoverDistance() ) ) ;
52a36ffd 164 pphi *= kRADDEG ;
ed4205d8 165 if (pphi > fAngle) cout << "AliPHOSGeometry: PHOS modules overlap!\n";
166 pphi = fAngle;
52a36ffd 167
168 for( Int_t i = 1; i <= fNModules ; i++ ) {
ed4205d8 169 Float_t angle = pphi * ( i - fNModules / 2.0 - 0.5 ) ;
52a36ffd 170 fPHOSAngle[i-1] = - angle ;
171 }
d15a28e7 172}
173
174//____________________________________________________________________________
92862013 175Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid)
d15a28e7 176{
b2a60966 177 // Converts the absolute numbering into the following array/
178 // relid[0] = PHOS Module number 1:fNModules
179 // relid[1] = 0 if PbW04
180 // = PPSD Module number 1:fNumberOfModulesPhi*fNumberOfModulesZ*2 (2->up and bottom level)
181 // relid[2] = Row number inside a PHOS or PPSD module
182 // relid[3] = Column number inside a PHOS or PPSD module
d15a28e7 183
184 Bool_t rv = kTRUE ;
92862013 185 Float_t id = AbsId ;
d15a28e7 186
92862013 187 Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / ( GetNPhi() * GetNZ() ) ) ;
d15a28e7 188
52a36ffd 189 if ( phosmodulenumber > GetNModules() ) { // it is a PPSD or CPV pad
190
191 if ( strcmp(fName,"GPS2") == 0 ) {
192 id -= GetNPhi() * GetNZ() * GetNModules() ;
193 Float_t tempo = 2 * GetNumberOfModulesPhi() * GetNumberOfModulesZ() * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
194 relid[0] = (Int_t)TMath::Ceil( id / tempo ) ;
195 id -= ( relid[0] - 1 ) * tempo ;
196 relid[1] = (Int_t)TMath::Ceil( id / ( GetNumberOfPadsPhi() * GetNumberOfPadsZ() ) ) ;
197 id -= ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
198 relid[2] = (Int_t)TMath::Ceil( id / GetNumberOfPadsPhi() ) ;
199 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfPadsPhi() ) ;
200 }
201 else if ( strcmp(fName,"IHEP") == 0 ) {
202 id -= GetNPhi() * GetNZ() * GetNModules() ;
ed4205d8 203 Float_t nCPV = GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() ;
204 relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ;
52a36ffd 205 relid[1] = 1 ;
ed4205d8 206 id -= ( relid[0] - 1 ) * nCPV ;
207 relid[2] = (Int_t) TMath::Ceil( id / GetNumberOfCPVPadsZ() ) ;
208 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() ) ;
209 }
210 else if ( strcmp(fName,"MIXT") == 0 ) {
211 id -= GetNPhi() * GetNZ() * GetNModules() ;
212 Float_t nPPSD = 2 * GetNumberOfModulesPhi() * GetNumberOfModulesZ() * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
213 Float_t nCPV = GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() ;
214 if (id <= nCPV*GetNCPVModules()) { // this pad belons to CPV
215 relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ;
216 relid[1] = 1 ;
217 id -= ( relid[0] - 1 ) * nCPV ;
218 relid[2] = (Int_t) TMath::Ceil( id / GetNumberOfCPVPadsZ() ) ;
219 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() ) ;
220 }
221 else { // this pad belons to PPSD
222 id -= nCPV*GetNCPVModules();
223 relid[0] = (Int_t)TMath::Ceil( id / nPPSD );
224 id -= ( relid[0] - 1 ) * nPPSD ;
225 relid[0] += GetNCPVModules();
226 relid[1] = (Int_t)TMath::Ceil( id / ( GetNumberOfPadsPhi() * GetNumberOfPadsZ() ) ) ;
227 id -= ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
228 relid[2] = (Int_t)TMath::Ceil( id / GetNumberOfPadsPhi() ) ;
229 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfPadsPhi() ) ;
230 }
52a36ffd 231 }
d15a28e7 232 }
233 else { // its a PW04 crystal
234
92862013 235 relid[0] = phosmodulenumber ;
236 relid[1] = 0 ;
237 id -= ( phosmodulenumber - 1 ) * GetNPhi() * GetNZ() ;
238 relid[2] = (Int_t)TMath::Ceil( id / GetNPhi() ) ;
239 relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNPhi() ) ;
d15a28e7 240 }
241 return rv ;
242}
52a36ffd 243
9f616d61 244//____________________________________________________________________________
245void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt)
246{
247 // calculates the angular coverage in theta and phi of a EMC module
248
249 Double_t conv ;
cf0c2bc1 250 if ( opt == Radian() )
9f616d61 251 conv = 1. ;
cf0c2bc1 252 else if ( opt == Degre() )
9f616d61 253 conv = 180. / TMath::Pi() ;
254 else {
255 cout << "<I> AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ;
256 conv = 1. ;
257 }
258
259 Float_t phi = GetPHOSAngle(mod) * (TMath::Pi() / 180.) ;
92862013 260 Float_t y0 = GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
9f616d61 261 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness() ;
262
92862013 263 Double_t angle = TMath::ATan( GetCrystalSize(0)*GetNPhi() / (2 * y0) ) ;
9f616d61 264 phi = phi + 1.5 * TMath::Pi() ; // to follow the convention of the particle generator(PHOS is between 230 and 310 deg.)
92862013 265 Double_t max = phi - angle ;
266 Double_t min = phi + angle ;
267 pM = TMath::Max(max, min) * conv ;
268 pm = TMath::Min(max, min) * conv ;
9f616d61 269
92862013 270 angle = TMath::ATan( GetCrystalSize(2)*GetNZ() / (2 * y0) ) ;
271 max = TMath::Pi() / 2. + angle ; // to follow the convention of the particle generator(PHOS is at 90 deg.)
272 min = TMath::Pi() / 2. - angle ;
273 tM = TMath::Max(max, min) * conv ;
274 tm = TMath::Min(max, min) * conv ;
9f616d61 275
276}
277
278//____________________________________________________________________________
279void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt)
280{
281 // calculates the angular coverage in theta and phi of a single crystal in a EMC module
282
283 Double_t conv ;
cf0c2bc1 284 if ( opt == Radian() )
9f616d61 285 conv = 1. ;
cf0c2bc1 286 else if ( opt == Degre() )
9f616d61 287 conv = 180. / TMath::Pi() ;
288 else {
289 cout << "<I> AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ;
290 conv = 1. ;
291 }
292
92862013 293 Float_t y0 = GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
9f616d61 294 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness() ;
92862013 295 theta = 2 * TMath::ATan( GetCrystalSize(2) / (2 * y0) ) * conv ;
296 phi = 2 * TMath::ATan( GetCrystalSize(0) / (2 * y0) ) * conv ;
9f616d61 297}
298
299
300//____________________________________________________________________________
52a36ffd 301void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & gmat) const
d15a28e7 302{
b2a60966 303 // Calculates the ALICE global coordinates of a RecPoint and the error matrix
304
d15a28e7 305 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
92862013 306 TVector3 localposition ;
d15a28e7 307
308 tmpPHOS->GetLocalPosition(gpos) ;
309
310
311 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
312 { gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
313 GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
314
315 }
316 else
317 { // it is a PPSD pad
318 AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
319 if (tmpPpsd->GetUp() ) // it is an upper module
320 {
321 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() -
322 GetLeadToMicro2Gap() - GetLeadConverterThickness() -
323 GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 ) ) ;
324 }
325 else // it is a lower module
326 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
327 }
328
92862013 329 Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
330 Double_t const kRADDEG = 180.0 / kPI ;
331 Float_t rphi = phi / kRADDEG ;
d15a28e7 332
92862013 333 TRotation rot ;
334 rot.RotateZ(-rphi) ; // a rotation around Z by angle
d15a28e7 335
92862013 336 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
337 gpos.Transform(rot) ; // rotate the baby
6ad0bfa0 338
d15a28e7 339}
340
341//____________________________________________________________________________
5cda30f6 342void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) const
d15a28e7 343{
b2a60966 344 // Calculates the ALICE global coordinates of a RecPoint
345
d15a28e7 346 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
92862013 347 TVector3 localposition ;
d15a28e7 348 tmpPHOS->GetLocalPosition(gpos) ;
349
350
351 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
352 { gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
353 GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
354 }
355 else
356 { // it is a PPSD pad
357 AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
358 if (tmpPpsd->GetUp() ) // it is an upper module
359 {
360 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() -
361 GetLeadToMicro2Gap() - GetLeadConverterThickness() -
362 GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 ) ) ;
363 }
364 else // it is a lower module
365 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
366 }
367
92862013 368 Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
369 Double_t const kRADDEG = 180.0 / kPI ;
370 Float_t rphi = phi / kRADDEG ;
d15a28e7 371
92862013 372 TRotation rot ;
373 rot.RotateZ(-rphi) ; // a rotation around Z by angle
d15a28e7 374
92862013 375 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
376 gpos.Transform(rot) ; // rotate the baby
d15a28e7 377}
378
379//____________________________________________________________________________
52a36ffd 380void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x)
d15a28e7 381{
52a36ffd 382 // calculates the impact coordinates of a neutral particle
383 // emitted in direction theta and phi in ALICE
d15a28e7 384
52a36ffd 385 // searches for the PHOS EMC module
386 ModuleNumber = 0 ;
387 Double_t tm, tM, pm, pM ;
388 Int_t index = 1 ;
389 while ( ModuleNumber == 0 && index <= GetNModules() ) {
390 EmcModuleCoverage(index, tm, tM, pm, pM) ;
391 if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) )
392 ModuleNumber = index ;
393 index++ ;
d15a28e7 394 }
52a36ffd 395 if ( ModuleNumber != 0 ) {
396 Float_t phi0 = GetPHOSAngle(ModuleNumber) * (TMath::Pi() / 180.) + 1.5 * TMath::Pi() ;
397 Float_t y0 = GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
398 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness() ;
399 Double_t angle = phi - phi0;
400 x = y0 * TMath::Tan(angle) ;
401 angle = theta - TMath::Pi() / 2 ;
402 z = y0 * TMath::Tan(angle) ;
d15a28e7 403 }
d15a28e7 404}
405
406//____________________________________________________________________________
92862013 407Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId)
d15a28e7 408{
b2a60966 409 // Converts the relative numbering into the absolute numbering
ed4205d8 410 // EMCA crystals:
411 // AbsId = from 1 to fNModules * fNPhi * fNZ
412 // PPSD gas cell:
413 // AbsId = from N(total EMCA crystals) + 1
414 // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ +
415 // fNModules * 2 * (fNumberOfModulesPhi * fNumberOfModulesZ) * fNumberOfPadsPhi * fNumberOfPadsZ
416 // CPV pad:
417 // AbsId = from N(total PHOS crystals) + 1
418 // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ
d15a28e7 419
420 Bool_t rv = kTRUE ;
421
ed4205d8 422 if ( relid[1] > 0 && strcmp(fName,"GPS2")==0) { // it is a PPSD pad
423 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from PPSD pads
424 + ( relid[0] - 1 ) * GetNumberOfModulesPhi() * GetNumberOfModulesZ() // the pads offset of PPSD modules
d15a28e7 425 * GetNumberOfPadsPhi() * GetNumberOfPadsZ() * 2
ed4205d8 426 + ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() // the pads offset of PPSD modules
427 + ( relid[2] - 1 ) * GetNumberOfPadsPhi() // the pads offset of a PPSD row
428 + relid[3] ; // the column number
429 }
430
431 else if ( relid[1] > 0 && strcmp(fName,"MIXT")==0) { // it is a PPSD pad
432 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from PPSD pads
433 + GetNCPVModules() * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of CPV modules if any
434 + ( relid[0] - 1 - GetNCPVModules())
435 * GetNumberOfModulesPhi() * GetNumberOfModulesZ() // the pads offset of PPSD modules
436 * GetNumberOfPadsPhi() * GetNumberOfPadsZ() * 2
437 + ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() // the pads offset of PPSD modules
438 + ( relid[2] - 1 ) * GetNumberOfPadsPhi() // the pads offset of a PPSD row
439 + relid[3] ; // the column number
d15a28e7 440 }
52a36ffd 441
442 else if ( relid[1] == 0 ) { // it is a Phos crystal
443 AbsId =
444 ( relid[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules
445 + ( relid[2] - 1 ) * GetNPhi() // the offset of a xtal row
446 + relid[3] ; // the column number
d15a28e7 447 }
448
52a36ffd 449 else if ( relid[1] == -1 ) { // it is a CPV pad
450 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads
ed4205d8 451 + ( relid[0] - 1 ) * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of PHOS modules
452 + ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() // the pads offset of a CPV row
52a36ffd 453 + relid[3] ; // the column number
454 }
455
d15a28e7 456 return rv ;
457}
458
459//____________________________________________________________________________
460
92862013 461void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos )
d15a28e7 462{
b2a60966 463 // Converts the absolute numbering into the global ALICE coordinates
ed4205d8 464 // It works only for the GPS2 geometry
b2a60966 465
ed4205d8 466 if (id > 0 && strcmp(fName,"GPS2")==0) {
467
468 Int_t relid[4] ;
469
470 AbsToRelNumbering(id , relid) ;
471
472 Int_t phosmodule = relid[0] ;
473
474 Float_t y0 = 0 ;
475
476 if ( relid[1] == 0 ) { // it is a PbW04 crystal
477 y0 = -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
478 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ;
479 }
480 if ( relid[1] > 0 ) { // its a PPSD pad
481 if ( relid[1] > GetNumberOfModulesPhi() * GetNumberOfModulesZ() ) { // its an bottom module
482 y0 = -( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ;
483 }
484 else // its an upper module
485 y0 = -( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() - GetLeadToMicro2Gap()
486 - GetLeadConverterThickness() - GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0) ;
487 }
488
489 Float_t x, z ;
490 RelPosInModule(relid, x, z) ;
491
492 pos.SetX(x) ;
493 pos.SetZ(z) ;
494 pos.SetY( TMath::Sqrt(x*x + z*z + y0*y0) ) ;
495
496
497
498 Float_t phi = GetPHOSAngle( phosmodule) ;
499 Double_t const kRADDEG = 180.0 / kPI ;
500 Float_t rphi = phi / kRADDEG ;
501
502 TRotation rot ;
503 rot.RotateZ(-rphi) ; // a rotation around Z by angle
504
505 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
506
507 pos.Transform(rot) ; // rotate the baby
d15a28e7 508 }
509 else {
ed4205d8 510 pos.SetX(0.);
511 pos.SetY(0.);
512 pos.SetZ(0.);
513 }
d15a28e7 514}
515
516//____________________________________________________________________________
92862013 517void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z)
d15a28e7 518{
b2a60966 519 // Converts the relative numbering into the local PHOS-module (x, z) coordinates
52a36ffd 520 // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000)
ed4205d8 521
522 Bool_t padOfCPV = (strcmp(fName,"IHEP")==0) ||
523 ((strcmp(fName,"MIXT")==0) && relid[0]<=GetNCPVModules()) ;
524 Bool_t padOfPPSD = (strcmp(fName,"GPS2")==0) ||
525 ((strcmp(fName,"MIXT")==0) && relid[0]> GetNCPVModules()) ;
b2a60966 526
92862013 527 Int_t ppsdmodule ;
a3dfe79c 528 Float_t x0,z0;
52a36ffd 529 Int_t row = relid[2] ; //offset along x axiz
530 Int_t column = relid[3] ; //offset along z axiz
d15a28e7 531
ed4205d8 532 Float_t padsizeZ = 0;
533 Float_t padsizeX = 0;
534 Int_t nOfPadsPhi = 0;
535 Int_t nOfPadsZ = 0;
536 if ( padOfPPSD ) {
537 padsizeZ = GetPPSDModuleSize(2) / GetNumberOfPadsZ();
538 padsizeX = GetPPSDModuleSize(0) / GetNumberOfPadsPhi();
539 nOfPadsPhi = GetNumberOfPadsPhi();
540 nOfPadsZ = GetNumberOfPadsZ();
541 }
542 else if ( padOfCPV ) {
543 padsizeZ = GetPadSizeZ();
544 padsizeX = GetPadSizePhi();
545 nOfPadsPhi = GetNumberOfCPVPadsPhi();
546 nOfPadsZ = GetNumberOfCPVPadsZ();
547 }
548
92862013 549 if ( relid[1] == 0 ) { // its a PbW04 crystal
52a36ffd 550 x = - ( GetNPhi()/2. - row + 0.5 ) * GetCrystalSize(0) ; // position ox Xtal with respect
551 z = ( GetNZ() /2. - column + 0.5 ) * GetCrystalSize(2) ; // of center of PHOS module
552 }
553 else {
ed4205d8 554 if ( padOfPPSD ) {
555 if ( relid[1] > GetNumberOfModulesPhi() * GetNumberOfModulesZ() )
556 ppsdmodule = relid[1]-GetNumberOfModulesPhi() * GetNumberOfModulesZ();
557 else
558 ppsdmodule = relid[1] ;
559 Int_t modrow = 1+(Int_t)TMath::Ceil( (Float_t)ppsdmodule / GetNumberOfModulesPhi()-1. ) ;
560 Int_t modcol = ppsdmodule - ( modrow - 1 ) * GetNumberOfModulesPhi() ;
a3dfe79c 561 x0 = ( GetNumberOfModulesPhi() / 2. - modrow + 0.5 ) * GetPPSDModuleSize(0) ;
562 z0 = ( GetNumberOfModulesZ() / 2. - modcol + 0.5 ) * GetPPSDModuleSize(2) ;
563 } else {
564 x0 = 0;
565 z0 = 0;
566 }
ed4205d8 567 x = - ( nOfPadsPhi/2. - row - 0.5 ) * padsizeX + x0 ; // position of pad with respect
568 z = ( nOfPadsZ /2. - column - 0.5 ) * padsizeZ - z0 ; // of center of PHOS module
52a36ffd 569 }
2f3366b6 570}