Remove DIR PHOS/reconstruction
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeometry.h
CommitLineData
49cd54c0 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
16//_________________________________________________________________________
17// Geometry class for PHOS version SUBATECH
18//*-- Author : Y. Schutz SUBATECH
19//////////////////////////////////////////////////////////////////////////////
d15a28e7 20
21// --- ROOT system ---
22
49cd54c0 23#include "TVector3.h"
24#include "TRotation.h"
25
26// --- Standard library ---
27
28#include <iostream.h>
29#include "assert.h"
d15a28e7 30
31// --- AliRoot header files ---
32
49cd54c0 33#include "AliPHOSGeometry.h"
34#include "AliPHOSPpsdRecPoint.h"
35#include "AliConst.h"
36
37ClassImp(AliPHOSGeometry)
38
39 AliPHOSGeometry * AliPHOSGeometry::fGeom = 0 ;
40
41//____________________________________________________________________________
42AliPHOSGeometry::~AliPHOSGeometry(void)
43{
44 fRotMatrixArray->Delete() ;
45 delete fRotMatrixArray ;
46}
47
48//____________________________________________________________________________
49Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * RelId)
50{
51 // RelId[0] = PHOS Module number 1:fNModules
52 // RelId[1] = 0 if PbW04
53 // = PPSD Module number 1:fNumberOfModulesPhi*fNumberOfModulesZ*2 (2->up and bottom level)
54 // RelId[2] = Row number inside a PHOS or PPSD module
55 // RelId[3] = Column number inside a PHOS or PPSD module
56
57 Bool_t rv = kTRUE ;
58 Float_t Id = AbsId ;
59
60 Int_t PHOSModuleNumber = (Int_t)TMath:: Ceil( Id / ( GetNPhi() * GetNZ() ) ) ;
61
62 if ( PHOSModuleNumber > GetNModules() ) { // its a PPSD pad
63
64 Id -= GetNPhi() * GetNZ() * GetNModules() ;
65 Float_t tempo = 2 * GetNumberOfModulesPhi() * GetNumberOfModulesZ() * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
66 RelId[0] = (Int_t)TMath::Ceil( Id / tempo ) ;
67 Id -= ( RelId[0] - 1 ) * tempo ;
68 RelId[1] = (Int_t)TMath::Ceil( Id / ( GetNumberOfPadsPhi() * GetNumberOfPadsZ() ) ) ;
69 Id -= ( RelId[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() ;
70 RelId[2] = (Int_t)TMath::Ceil( Id / GetNumberOfPadsPhi() ) ;
71 RelId[3] = (Int_t) ( Id - ( RelId[2] - 1 ) * GetNumberOfPadsPhi() ) ;
72 }
73 else { // its a PW04 crystal
74
75 RelId[0] = PHOSModuleNumber ;
76 RelId[1] = 0 ;
77 Id -= ( PHOSModuleNumber - 1 ) * GetNPhi() * GetNZ() ;
78 RelId[2] = (Int_t)TMath::Ceil( Id / GetNPhi() ) ;
79 RelId[3] = (Int_t)( Id - ( RelId[2] - 1 ) * GetNPhi() ) ;
80 }
81 return rv ;
82}
83
84//____________________________________________________________________________
85void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & gmat)
86{
87
88 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
89 TVector3 LocalPosition ;
90
91 tmpPHOS->GetLocalPosition(gpos) ;
92
93
94 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
95 { gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
96 GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
97
98 }
99 else
100 { // it is a PPSD pad
101 AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
102 if (tmpPpsd->GetUp() ) // it is an upper module
103 {
104 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() -
105 GetLeadToMicro2Gap() - GetLeadConverterThickness() -
106 GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 ) ) ;
107 }
108 else // it is a lower module
109 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
110 }
111
112 Float_t Phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
113 Double_t const RADDEG = 180.0 / kPI ;
114 Float_t rPhi = Phi / RADDEG ;
115
116 TRotation Rot ;
117 Rot.RotateZ(-rPhi) ; // a rotation around Z by angle
118
119 TRotation dummy = Rot.Invert() ; // to transform from original frame to rotate frame
120 gpos.Transform(Rot) ; // rotate the baby
121}
122
123//____________________________________________________________________________
124void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos)
125{
126 AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ;
127 TVector3 LocalPosition ;
128 tmpPHOS->GetLocalPosition(gpos) ;
129
130
131 if ( tmpPHOS->IsEmc() ) // it is a EMC crystal
132 { gpos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness() +
133 GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
134 }
135 else
136 { // it is a PPSD pad
137 AliPHOSPpsdRecPoint * tmpPpsd = (AliPHOSPpsdRecPoint *) RecPoint ;
138 if (tmpPpsd->GetUp() ) // it is an upper module
139 {
140 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() -
141 GetLeadToMicro2Gap() - GetLeadConverterThickness() -
142 GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0 ) ) ;
143 }
144 else // it is a lower module
145 gpos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
146 }
147
148 Float_t Phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ;
149 Double_t const RADDEG = 180.0 / kPI ;
150 Float_t rPhi = Phi / RADDEG ;
151
152 TRotation Rot ;
153 Rot.RotateZ(-rPhi) ; // a rotation around Z by angle
154
155 TRotation dummy = Rot.Invert() ; // to transform from original frame to rotate frame
156 gpos.Transform(Rot) ; // rotate the baby
157}
158
159//____________________________________________________________________________
160void AliPHOSGeometry::Init(void)
161{
162 fRotMatrixArray = new TObjArray(fNModules) ;
163
164 cout << "PHOS geometry setup: parameters for option " << fName << " " << fTitle << endl ;
165 if ( ((strcmp( fName, "default" )) == 0) || ((strcmp( fName, "GPS2" )) == 0) ) {
166 fInit = kTRUE ;
167 this->InitPHOS() ;
168 this->InitPPSD() ;
169 this->SetPHOSAngles() ;
170 }
171 else {
172 fInit = kFALSE ;
173 cout << "PHOS Geometry setup: option not defined " << fName << endl ;
174 }
175}
176
177//____________________________________________________________________________
178void AliPHOSGeometry::InitPHOS(void)
179{
180 // PHOS
181
182 fNPhi = 64 ;
183 fNZ = 64 ;
184 fNModules = 5 ;
185
186 fPHOSAngle[0] = 0.0 ; // Module position angles are set in CreateGeometry()
187 fPHOSAngle[1] = 0.0 ;
188 fPHOSAngle[2] = 0.0 ;
189 fPHOSAngle[3] = 0.0 ;
190
191 fXtlSize[0] = 2.2 ;
192 fXtlSize[1] = 18.0 ;
193 fXtlSize[2] = 2.2 ;
194
195 // all these numbers coming next are subject to changes
196
197 fOuterBoxThickness[0] = 2.8 ;
198 fOuterBoxThickness[1] = 5.0 ;
199 fOuterBoxThickness[2] = 5.0 ;
200
201 fUpperPlateThickness = 4.0 ;
202
203 fSecondUpperPlateThickness = 5.0 ;
204
205 fCrystalSupportHeight = 6.95 ;
206 fCrystalWrapThickness = 0.01 ;
207 fCrystalHolderThickness = 0.005 ;
208 fModuleBoxThickness = 2.0 ;
209 fIPtoOuterCoverDistance = 447.0 ;
210 fIPtoCrystalSurface = 460.0 ;
211
212 fPinDiodeSize[0] = 1.0 ;
213 fPinDiodeSize[1] = 0.1 ;
214 fPinDiodeSize[2] = 1.0 ;
215
216 fUpperCoolingPlateThickness = 0.06 ;
217 fSupportPlateThickness = 10.0 ;
218 fLowerThermoPlateThickness = 3.0 ;
219 fLowerTextolitPlateThickness = 1.0 ;
220 fGapBetweenCrystals = 0.03 ;
221
222 fTextolitBoxThickness[0] = 1.5 ;
223 fTextolitBoxThickness[1] = 0.0 ;
224 fTextolitBoxThickness[2] = 3.0 ;
225
226 fAirThickness[0] = 1.56 ;
227 fAirThickness[1] = 20.5175 ;
228 fAirThickness[2] = 2.48 ;
229
230 Float_t XtalModulePhiSize = fNPhi * ( fXtlSize[0] + 2 * fGapBetweenCrystals ) ;
231 Float_t XtalModuleZSize = fNZ * ( fXtlSize[2] + 2 * fGapBetweenCrystals ) ;
232
233 // The next dimensions are calculated from the above parameters
234
235 fOuterBoxSize[0] = XtalModulePhiSize + 2 * ( fAirThickness[0] + fModuleBoxThickness
236 + fTextolitBoxThickness[0] + fOuterBoxThickness[0] ) ;
237 fOuterBoxSize[1] = ( fXtlSize[1] + fCrystalSupportHeight + fCrystalWrapThickness + fCrystalHolderThickness )
238 + 2 * (fAirThickness[1] + fModuleBoxThickness + fTextolitBoxThickness[1] + fOuterBoxThickness[1] ) ;
239 fOuterBoxSize[2] = XtalModuleZSize + 2 * ( fAirThickness[2] + fModuleBoxThickness
240 + fTextolitBoxThickness[2] + fOuterBoxThickness[2] ) ;
241
242 fTextolitBoxSize[0] = fOuterBoxSize[0] - 2 * fOuterBoxThickness[0] ;
243 fTextolitBoxSize[1] = fOuterBoxSize[1] - fOuterBoxThickness[1] - fUpperPlateThickness ;
244 fTextolitBoxSize[2] = fOuterBoxSize[2] - 2 * fOuterBoxThickness[2] ;
245
246 fAirFilledBoxSize[0] = fTextolitBoxSize[0] - 2 * fTextolitBoxThickness[0] ;
247 fAirFilledBoxSize[1] = fTextolitBoxSize[1] - fSecondUpperPlateThickness ;
248 fAirFilledBoxSize[2] = fTextolitBoxSize[2] - 2 * fTextolitBoxThickness[2] ;
249
250}
251
252//____________________________________________________________________________
253void AliPHOSGeometry::InitPPSD(void)
254{
255 // PPSD
256
257 fAnodeThickness = 0.0009 ;
258 fAvalancheGap = 0.01 ;
259 fCathodeThickness = 0.0009 ;
260 fCompositeThickness = 0.3 ;
261 fConversionGap = 0.3 ;
262 fLeadConverterThickness = 0.56 ;
263 fLeadToMicro2Gap = 0.1 ;
264 fLidThickness = 0.2 ;
265 fMicro1ToLeadGap = 0.1 ;
266 fMicromegasWallThickness = 0.6 ;
267 fNumberOfModulesPhi = 4 ;
268 fNumberOfModulesZ = 4 ;
269 fNumberOfPadsPhi = 24 ;
270 fNumberOfPadsZ = 24 ;
271 fPCThickness = 0.1 ;
272 fPhiDisplacement = 0.8 ;
273 fZDisplacement = 0.8 ;
274
275 fMicromegas1Thickness = fLidThickness + 2 * fCompositeThickness + fCathodeThickness + fPCThickness
276 + fAnodeThickness + fConversionGap + fAvalancheGap ;
277 fMicromegas2Thickness = fMicromegas1Thickness ;
278
279
280 fPPSDModuleSize[0] = 38.0 ;
281 fPPSDModuleSize[1] = fMicromegas1Thickness ;
282 fPPSDModuleSize[2] = 38.0 ;
d15a28e7 283
49cd54c0 284 fPPSDBoxSize[0] = fNumberOfModulesPhi * fPPSDModuleSize[0] + 2 * fPhiDisplacement ;
285 fPPSDBoxSize[1] = fMicromegas2Thickness + fMicromegas2Thickness + fLeadConverterThickness + fMicro1ToLeadGap + fLeadToMicro2Gap ;
286 fPPSDBoxSize[2] = fNumberOfModulesZ * fPPSDModuleSize[2] + 2 * fZDisplacement ;
287
288 fIPtoTopLidDistance = fIPtoOuterCoverDistance - fPPSDBoxSize[1] - 1. ;
289
290}
291
292//____________________________________________________________________________
293AliPHOSGeometry * AliPHOSGeometry::GetInstance()
294{
295 assert(fGeom!=0) ;
296 return (AliPHOSGeometry *) fGeom ;
297}
298
299//____________________________________________________________________________
300AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title)
301{
302 AliPHOSGeometry * rv = 0 ;
303 if ( fGeom == 0 ) {
304 fGeom = new AliPHOSGeometry(name, title) ;
305 rv = (AliPHOSGeometry * ) fGeom ;
306 }
307 else {
308 if ( strcmp(fGeom->GetName(), name) != 0 ) {
309 cout << "AliPHOSGeometry <E> : current geometry is " << fGeom->GetName() << endl
310 << " you cannot call " << name << endl ;
311 }
312 else
313 rv = (AliPHOSGeometry *) fGeom ;
314 }
315 return rv ;
316}
317
318//____________________________________________________________________________
319Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * RelId, Int_t & AbsId)
320{
321
322 // AbsId = 1:fNModules * fNPhi * fNZ -> PbWO4
323 // AbsId = 1:fNModules * 2 * (fNumberOfModulesPhi * fNumberOfModulesZ) * fNumberOfPadsPhi * fNumberOfPadsZ -> PPSD
324
325 Bool_t rv = kTRUE ;
326
327 if ( RelId[1] > 0 ) { // its a PPSD pad
328
329 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate emcal crystals from PPSD pads
330 + ( RelId[0] - 1 ) * GetNumberOfModulesPhi() * GetNumberOfModulesZ() // the pads offset of PHOS modules
331 * GetNumberOfPadsPhi() * GetNumberOfPadsZ() * 2
332 + ( RelId[1] - 1 ) * GetNumberOfPadsPhi() * GetNumberOfPadsZ() // the pads offset of PPSD modules
333 + ( RelId[2] - 1 ) * GetNumberOfPadsPhi() // the pads offset of a PPSD row
334 + RelId[3] ; // the column number
335 }
336 else {
337 if ( RelId[1] == 0 ) { // its a Phos crystal
338 AbsId = ( RelId[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules
339 + ( RelId[2] - 1 ) * GetNPhi() // the offset of a xtal row
340 + RelId[3] ; // the column number
341 }
342 }
343
344 return rv ;
345}
346
347//____________________________________________________________________________
348
349void AliPHOSGeometry::RelPosInAlice(const Int_t Id, TVector3 & pos )
350{
351 if (Id > 0) {
352
353 Int_t RelId[4] ;
354
355 AbsToRelNumbering(Id , RelId) ;
356
357 Int_t PHOSModule = RelId[0] ;
358
359
360 if ( RelId[1] == 0 ) // it is a PbW04 crystal
361 { pos.SetY( -(GetIPtoOuterCoverDistance() + GetUpperPlateThickness()
362 + GetSecondUpperPlateThickness() + GetUpperCoolingPlateThickness()) ) ;
363 }
364 if ( RelId[1] > 0 ) { // its a PPSD pad
365 if ( RelId[1] > GetNumberOfModulesPhi() * GetNumberOfModulesZ() ) // its an bottom module
366 {
367 pos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() / 2.0) ) ;
368 }
369 else // its an upper module
370 pos.SetY(-( GetIPtoOuterCoverDistance() - GetMicromegas2Thickness() - GetLeadToMicro2Gap()
371 - GetLeadConverterThickness() - GetMicro1ToLeadGap() - GetMicromegas1Thickness() / 2.0) ) ;
372 }
373
374 Float_t x, z ;
375 RelPosInModule(RelId, x, z) ;
376
377 pos.SetX(x);
378 pos.SetZ(z);
379
380
381 Float_t Phi = GetPHOSAngle( PHOSModule) ;
382 Double_t const RADDEG = 180.0 / kPI ;
383 Float_t rPhi = Phi / RADDEG ;
384
385 TRotation Rot ;
386 Rot.RotateZ(-rPhi) ; // a rotation around Z by angle
387
388 TRotation dummy = Rot.Invert() ; // to transform from original frame to rotate frame
389
390 pos.Transform(Rot) ; // rotate the baby
391 }
392 else {
393 pos.SetX(0.);
394 pos.SetY(0.);
395 pos.SetZ(0.);
396 }
397}
398
399//____________________________________________________________________________
400void AliPHOSGeometry::RelPosInModule(const Int_t * RelId, Float_t & x, Float_t & z)
401{
402 Int_t PPSDModule ;
403 Int_t Row = RelId[2] ; //offset along z axiz
404 Int_t Column = RelId[3] ; //offset along x axiz
405
406 Float_t PadSizeZ = GetPPSDModuleSize(2)/ GetNumberOfPadsZ();
407 Float_t PadSizeX = GetPPSDModuleSize(0)/ GetNumberOfPadsPhi();
408
409 if ( RelId[1] == 0 ) { // its a PbW04 crystal
410 x = -( GetNPhi()/2. - Row + 0.5 ) * GetCrystalSize(0) ; // position ox Xtal with respect
411 z = -( GetNZ() /2. - Column + 0.5 ) * GetCrystalSize(2) ; // of center of PHOS module
412 }
413 else {
414 if ( RelId[1] > GetNumberOfModulesPhi() * GetNumberOfModulesZ() )
415 PPSDModule = RelId[1]-GetNumberOfModulesPhi() * GetNumberOfModulesZ();
416 else PPSDModule = RelId[1] ;
417 Int_t ModRow = 1+(Int_t)TMath::Ceil( (Float_t)PPSDModule / GetNumberOfModulesPhi()-1. ) ;
418 Int_t ModCol = PPSDModule - ( ModRow-1 ) * GetNumberOfModulesPhi() ;
419 Float_t x0 = ( GetNumberOfModulesPhi() / 2. - ModRow + 0.5 ) * GetPPSDModuleSize(0) ;
420 Float_t z0 = ( GetNumberOfModulesZ() / 2. - ModCol + 0.5 ) * GetPPSDModuleSize(2) ;
421 x = - ( GetNumberOfPadsPhi()/2. - Row - 0.5 ) * PadSizeX + x0 ; // position of pad with respect
422 z = - ( GetNumberOfPadsZ()/2. - Column - 0.5 ) * PadSizeZ + z0 ; // of center of PHOS module
423 }
424}
425
426//____________________________________________________________________________
427void AliPHOSGeometry:: SetPHOSAngles()
428{
429 Double_t const RADDEG = 180.0 / kPI ;
430 Float_t PPHI = TMath::ATan( fOuterBoxSize[0] / ( 2.0 * fIPtoOuterCoverDistance ) ) ;
431 PPHI *= RADDEG ;
432
433 for( Int_t i = 1; i <= fNModules ; i++ ) {
434 Float_t angle = PPHI * 2 * ( i - fNModules / 2.0 - 0.5 ) ;
435 fPHOSAngle[i-1] = - angle ;
436 }
437}
438