1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
19 // Geometry class for PHOS : singleton
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.
27 //*-- Author: Yves Schutz (SUBATECH)
29 // --- ROOT system ---
32 #include "TRotation.h"
34 // --- Standard library ---
38 // --- AliRoot header files ---
40 #include "AliPHOSGeometry.h"
41 #include "AliPHOSPpsdRecPoint.h"
44 ClassImp(AliPHOSGeometry) ;
46 AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
47 Bool_t AliPHOSGeometry::fgInit = kFALSE ;
49 //____________________________________________________________________________
50 AliPHOSGeometry::~AliPHOSGeometry(void)
54 if (fRotMatrixArray) fRotMatrixArray->Delete() ;
55 if (fRotMatrixArray) delete fRotMatrixArray ;
56 if (fPHOSAngle ) delete fPHOSAngle ;
57 // if (fGeometryEMCA ) detete fGeometryEMCA;
58 // if (fGeometryCPV ) detete fGeometryCPV ;
61 //____________________________________________________________________________
63 void AliPHOSGeometry::Init(void)
65 // Initializes the PHOS parameters
67 if ( ((strcmp( fName, "default" )) == 0) ||
68 ((strcmp( fName, "GPS2" )) == 0) ||
69 ((strcmp( fName, "IHEP" )) == 0) ) {
71 fGeometryEMCA = new AliPHOSEMCAGeometry();
72 if ( ((strcmp( fName, "GPS2" )) == 0) ) fGeometryCPV = new AliPHOSPPSDGeometry();
73 if ( ((strcmp( fName, "IHEP" )) == 0) ) fGeometryCPV = new AliPHOSCPVGeometry ();
74 fGeometrySUPP = new AliPHOSSupportGeometry();
76 fPHOSAngle = new Float_t[fNModules] ;
78 for ( index = 0; index < fNModules; index++ )
79 fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
81 this->SetPHOSAngles() ;
82 fRotMatrixArray = new TObjArray(fNModules) ;
86 cout << "PHOS Geometry setup: option not defined " << fName << endl ;
90 //____________________________________________________________________________
91 AliPHOSGeometry * AliPHOSGeometry::GetInstance()
93 // Returns the pointer of the unique instance
94 return (AliPHOSGeometry *) fgGeom ;
97 //____________________________________________________________________________
98 AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title)
100 // Returns the pointer of the unique instance
101 AliPHOSGeometry * rv = 0 ;
103 if ( strcmp(name,"") == 0 )
106 fgGeom = new AliPHOSGeometry(name, title) ;
108 rv = (AliPHOSGeometry * ) fgGeom ;
117 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
118 cout << "AliPHOSGeometry <E> : current geometry is " << fgGeom->GetName() << endl
119 << " you cannot call " << name << endl ;
122 rv = (AliPHOSGeometry *) fgGeom ;
127 //____________________________________________________________________________
128 void AliPHOSGeometry::SetPHOSAngles()
130 // Calculates the position in ALICE of the PHOS modules
132 Double_t const kRADDEG = 180.0 / kPI ;
133 Float_t pphi = TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoOuterCoverDistance() ) ) ;
136 for( Int_t i = 1; i <= fNModules ; i++ ) {
137 Float_t angle = pphi * 2 * ( i - fNModules / 2.0 - 0.5 ) ;
138 fPHOSAngle[i-1] = - angle ;
142 //____________________________________________________________________________
143 Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid)
145 // Converts the absolute numbering into the following array/
146 // relid[0] = PHOS Module number 1:fNModules
147 // relid[1] = 0 if PbW04
148 // = PPSD Module number 1:fNumberOfModulesPhi*fNumberOfModulesZ*2 (2->up and bottom level)
149 // relid[2] = Row number inside a PHOS or PPSD module
150 // relid[3] = Column number inside a PHOS or PPSD module
155 Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / ( GetNPhi() * GetNZ() ) ) ;
157 if ( phosmodulenumber > GetNModules() ) { // it is a PPSD or CPV pad
159 if ( strcmp(fName,"GPS2") == 0 ) {
160 id -= GetNPhi() * GetNZ() * GetNModules() ;
161 Float_t tempo = 2 * GetNumberOfModulesPhi() * GetNumberOfModulesZ() * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
162 relid[0] = (Int_t)TMath::Ceil( id / tempo ) ;
163 id -= ( relid[0] - 1 ) * tempo ;
164 relid[1] = (Int_t)TMath::Ceil( id / ( GetNumberOfPadsPhi() * GetNumberOfPadsZ() ) ) ;
165 id -= ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
166 relid[2] = (Int_t)TMath::Ceil( id / GetNumberOfPadsPhi() ) ;
167 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfPadsPhi() ) ;
169 else if ( strcmp(fName,"IHEP") == 0 ) {
170 id -= GetNPhi() * GetNZ() * GetNModules() ;
171 relid[0] = (Int_t) TMath::Ceil( id / ( GetNumberOfPadsPhi() * GetNumberOfPadsZ() ) ) ;
173 id -= ( relid[0] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
174 relid[2] = (Int_t) TMath::Ceil( id / GetNumberOfPadsZ() ) ;
175 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfPadsZ() ) ;
178 else { // its a PW04 crystal
180 relid[0] = phosmodulenumber ;
182 id -= ( phosmodulenumber - 1 ) * GetNPhi() * GetNZ() ;
183 relid[2] = (Int_t)TMath::Ceil( id / GetNPhi() ) ;
184 relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNPhi() ) ;
189 //____________________________________________________________________________
190 void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt)
192 // calculates the angular coverage in theta and phi of a EMC module
195 if ( opt == Radian() )
197 else if ( opt == Degre() )
198 conv = 180. / TMath::Pi() ;
200 cout << "<I> AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ;
204 Float_t phi = GetPHOSAngle(mod) * (TMath::Pi() / 180.) ;
205 Float_t y0 = GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
206 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness() ;
208 Double_t angle = TMath::ATan( GetCrystalSize(0)*GetNPhi() / (2 * y0) ) ;
209 phi = phi + 1.5 * TMath::Pi() ; // to follow the convention of the particle generator(PHOS is between 230 and 310 deg.)
210 Double_t max = phi - angle ;
211 Double_t min = phi + angle ;
212 pM = TMath::Max(max, min) * conv ;
213 pm = TMath::Min(max, min) * conv ;
215 angle = TMath::ATan( GetCrystalSize(2)*GetNZ() / (2 * y0) ) ;
216 max = TMath::Pi() / 2. + angle ; // to follow the convention of the particle generator(PHOS is at 90 deg.)
217 min = TMath::Pi() / 2. - angle ;
218 tM = TMath::Max(max, min) * conv ;
219 tm = TMath::Min(max, min) * conv ;
223 //____________________________________________________________________________
224 void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt)
226 // calculates the angular coverage in theta and phi of a single crystal in a EMC module
229 if ( opt == Radian() )
231 else if ( opt == Degre() )
232 conv = 180. / TMath::Pi() ;
234 cout << "<I> AliPHOSGeometry::EmcXtalCoverage : " << opt << " unknown option; result in radian " << endl ;
238 Float_t y0 = GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
239 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness() ;
240 theta = 2 * TMath::ATan( GetCrystalSize(2) / (2 * y0) ) * conv ;
241 phi = 2 * TMath::ATan( GetCrystalSize(0) / (2 * y0) ) * conv ;
245 //____________________________________________________________________________
246 void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & gmat) const
248 // Calculates the ALICE global coordinates of a RecPoint and the error matrix
250 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
251 TVector3 localposition ;
253 tmpPHOS->GetLocalPosition(gpos) ;
256 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
257 { gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
258 GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
262 { // it is a PPSD pad
263 AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
264 if (tmpPpsd->GetUp() ) // it is an upper module
266 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() -
267 GetLeadToMicro2Gap() - GetLeadConverterThickness() -
268 GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 ) ) ;
270 else // it is a lower module
271 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
274 Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
275 Double_t const kRADDEG = 180.0 / kPI ;
276 Float_t rphi = phi / kRADDEG ;
279 rot.RotateZ(-rphi) ; // a rotation around Z by angle
281 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
282 gpos.Transform(rot) ; // rotate the baby
286 //____________________________________________________________________________
287 void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) const
289 // Calculates the ALICE global coordinates of a RecPoint
291 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
292 TVector3 localposition ;
293 tmpPHOS->GetLocalPosition(gpos) ;
296 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
297 { gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
298 GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
301 { // it is a PPSD pad
302 AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
303 if (tmpPpsd->GetUp() ) // it is an upper module
305 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() -
306 GetLeadToMicro2Gap() - GetLeadConverterThickness() -
307 GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 ) ) ;
309 else // it is a lower module
310 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
313 Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
314 Double_t const kRADDEG = 180.0 / kPI ;
315 Float_t rphi = phi / kRADDEG ;
318 rot.RotateZ(-rphi) ; // a rotation around Z by angle
320 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
321 gpos.Transform(rot) ; // rotate the baby
324 //____________________________________________________________________________
325 void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x)
327 // calculates the impact coordinates of a neutral particle
328 // emitted in direction theta and phi in ALICE
330 // searches for the PHOS EMC module
332 Double_t tm, tM, pm, pM ;
334 while ( ModuleNumber == 0 && index <= GetNModules() ) {
335 EmcModuleCoverage(index, tm, tM, pm, pM) ;
336 if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) )
337 ModuleNumber = index ;
340 if ( ModuleNumber != 0 ) {
341 Float_t phi0 = GetPHOSAngle(ModuleNumber) * (TMath::Pi() / 180.) + 1.5 * TMath::Pi() ;
342 Float_t y0 = GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
343 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness() ;
344 Double_t angle = phi - phi0;
345 x = y0 * TMath::Tan(angle) ;
346 angle = theta - TMath::Pi() / 2 ;
347 z = y0 * TMath::Tan(angle) ;
351 //____________________________________________________________________________
352 Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId)
354 // Converts the relative numbering into the absolute numbering
355 // AbsId = 1 to fNModules * fNPhi * fNZ -> PbWO4
356 // AbsId = N(total PHOS crystals) +
357 // 1 to fNModules * 2 * (fNumberOfModulesPhi * fNumberOfModulesZ) * fNumberOfPadsPhi * fNumberOfPadsZ -> PPSD
358 // AbsId = N(total PHOS crystals) +
359 // 1:fNModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ -> CPV
363 if ( relid[1] > 0 ) { // it is a PPSD pad
364 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from PPSD pads
365 + ( relid[0] - 1 ) * GetNumberOfModulesPhi() * GetNumberOfModulesZ() // the pads offset of PHOS modules
366 * GetNumberOfPadsPhi() * GetNumberOfPadsZ() * 2
367 + ( relid[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() // the pads offset of PPSD modules
368 + ( relid[2] - 1 ) * GetNumberOfPadsPhi() // the pads offset of a PPSD row
369 + relid[3] ; // the column number
372 else if ( relid[1] == 0 ) { // it is a Phos crystal
374 ( relid[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules
375 + ( relid[2] - 1 ) * GetNPhi() // the offset of a xtal row
376 + relid[3] ; // the column number
379 else if ( relid[1] == -1 ) { // it is a CPV pad
380 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads
381 + ( relid[0] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() // the pads offset of PHOS modules
382 + ( relid[2] - 1 ) * GetNumberOfPadsZ() // the pads offset of a CPV row
383 + relid[3] ; // the column number
389 //____________________________________________________________________________
391 void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos )
393 // Converts the absolute numbering into the global ALICE coordinates
399 AbsToRelNumbering(id , relid) ;
401 Int_t phosmodule = relid[0] ;
405 if ( relid[1] == 0 ) // it is a PbW04 crystal
406 { y0 = -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
407 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ;
409 if ( relid[1] > 0 ) { // its a PPSD pad
410 if ( relid[1] > GetNumberOfModulesPhi() * GetNumberOfModulesZ() ) // its an bottom module
412 y0 = -( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ;
414 else // its an upper module
415 y0 = -( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() - GetLeadToMicro2Gap()
416 - GetLeadConverterThickness() - GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0) ;
420 RelPosInModule(relid, x, z) ;
424 pos.SetY( TMath::Sqrt(x*x + z*z + y0*y0) ) ;
428 Float_t phi = GetPHOSAngle( phosmodule) ;
429 Double_t const kRADDEG = 180.0 / kPI ;
430 Float_t rphi = phi / kRADDEG ;
433 rot.RotateZ(-rphi) ; // a rotation around Z by angle
435 TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame
437 pos.Transform(rot) ; // rotate the baby
446 //____________________________________________________________________________
447 void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z)
449 // Converts the relative numbering into the local PHOS-module (x, z) coordinates
450 // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000)
454 Int_t row = relid[2] ; //offset along x axiz
455 Int_t column = relid[3] ; //offset along z axiz
457 Float_t padsizeZ = GetPadSizeZ();
458 Float_t padsizeX = GetPadSizePhi();
460 if ( relid[1] == 0 ) { // its a PbW04 crystal
461 x = - ( GetNPhi()/2. - row + 0.5 ) * GetCrystalSize(0) ; // position ox Xtal with respect
462 z = ( GetNZ() /2. - column + 0.5 ) * GetCrystalSize(2) ; // of center of PHOS module
465 if ( relid[1] > GetNumberOfModulesPhi() * GetNumberOfModulesZ() )
466 ppsdmodule = relid[1]-GetNumberOfModulesPhi() * GetNumberOfModulesZ();
468 ppsdmodule = relid[1] ;
469 Int_t modrow = 1+(Int_t)TMath::Ceil( (Float_t)ppsdmodule / GetNumberOfModulesPhi()-1. ) ;
470 Int_t modcol = ppsdmodule - ( modrow - 1 ) * GetNumberOfModulesPhi() ;
471 if ( ((strcmp( fName, "GPS2" )) == 0) ) {
472 x0 = ( GetNumberOfModulesPhi() / 2. - modrow + 0.5 ) * GetPPSDModuleSize(0) ;
473 z0 = ( GetNumberOfModulesZ() / 2. - modcol + 0.5 ) * GetPPSDModuleSize(2) ;
478 x = - ( GetNumberOfPadsPhi()/2. - row - 0.5 ) * padsizeX + x0 ; // position of pad with respect
479 z = ( GetNumberOfPadsZ() /2. - column - 0.5 ) * padsizeZ - z0 ; // of center of PHOS module