]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALGeometry.cxx
Modifiactions by M. Horner.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.cxx
CommitLineData
2012850d 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/* $Id$*/
17
18//_________________________________________________________________________
19// Geometry class for EMCAL : singleton
b13bbe81 20// EMCAL consists of layers of scintillator and lead
ffa6d63b 21// Places the the Barrel Geometry of The EMCAL at Midrapidity
22// between 0 and 120 degrees of Phi and
23// -0.7 to 0.7 in eta
24// Number of Modules and Layers may be controlled by
25// the name of the instance defined
26// EMCALArch2x has more modules along both phi and eta
27// EMCALArchxa has less Layers in the Radial Direction
b13bbe81 28//*-- Author: Sahal Yacoob (LBL / UCT)
29// and : Yves Schutz (SUBATECH)
30// and : Jennifer Klay (LBL)
2012850d 31
32// --- ROOT system ---
33
34// --- Standard library ---
bba4716c 35#include <stdlib.h>
2012850d 36
37// --- AliRoot header files ---
116cbefd 38#include <TError.h>
ca8f5bd0 39#include <TMath.h>
116cbefd 40#include <TVector3.h>
173558f2 41
ca8f5bd0 42// -- ALICE Headers.
2012850d 43#include "AliConst.h"
173558f2 44
ca8f5bd0 45// --- EMCAL headers
46#include "AliEMCALGeometry.h"
2012850d 47
b13bbe81 48ClassImp(AliEMCALGeometry);
2012850d 49
b13bbe81 50AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
51Bool_t AliEMCALGeometry::fgInit = kFALSE;
2012850d 52
b13bbe81 53//______________________________________________________________________
54AliEMCALGeometry::~AliEMCALGeometry(void){
55 // dtor
2012850d 56}
b13bbe81 57
395c7ba2 58//______________________________________________________________________
59const Bool_t AliEMCALGeometry::AreInSameTower(Int_t id1, Int_t id2) const {
60 Int_t idmax = TMath::Max(id1, id2) ;
61 Int_t idmin = TMath::Min(id1, id2) ;
62 if ( ((idmax - GetNZ() * GetNPhi()) == idmin ) ||
63 ((idmax - 2 * GetNZ() * GetNPhi()) == idmin ) )
64 return kTRUE ;
65 else
66 return kFALSE ;
67}
05a92d59 68
395c7ba2 69//______________________________________________________________________
70void AliEMCALGeometry::Init(void){
71 // Initializes the EMCAL parameters
72 // naming convention : GUV_L_WX_N_YZ_M gives the composition of a tower
73 // UV inform about the compsition of the pre-shower section:
74 // thickness in mm of Pb radiator (U) and of scintillator (V), and number of scintillator layers (L)
75 // WX inform about the composition of the EM calorimeter section:
76 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
77 // YZ inform about the composition of the hadron calorimeter section:
78 // thickness in mm of Cu radiator (Y) and of scintillator (Z), and number of scintillator layers (M)
79 // Valid geometries are G56_2_55_19_104_14
80 // G56_2_55_19 or EMCAL_5655_21
81 // G65_2_64_19 or EMCAL_6564_21
82
83 fgInit = kFALSE; // Assume failer untill proven otherwise.
84 TString name(GetName()) ;
85
86 if ( name == "G56_2_55_19_104_14" ) {
87 fPRPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the preshower section
88 fPRScintThick = 0.6; // cm, Thickness of the sintilator for the preshower section of the tower
89 fNPRLayers = 2; // number of scintillator layers in the preshower section
90
91 fECPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the EM calorimeter section
92 fECScintThick = 0.5; // cm, Thickness of the sintilator for the EM alorimeter section of the tower
93 fNECLayers = 19; // number of scintillator layers in the EM calorimeter section
94
95 fHCCuRadThickness = 1.0; // cm, Thickness of the Cu radiators.
96 fHCScintThick = 0.4; // cm, Thickness of the sintilator for the hadronic alorimeter section of the tower
97 fNHCLayers = 14; // number of scintillator layers in the hadronic calorimeter section
98
444f2901 99 fSampling = 11.3 ;
395c7ba2 100 fSummationFraction = 0.8 ;
101
102 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
103 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
104 }
105 else if ( name == "G56_2_55_19" || name == "EMCAL_5655_21" ) {
106 fPRPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the preshower section
107 fPRScintThick = 0.6; // cm, Thickness of the sintilator for the preshower section of the tower
108 fNPRLayers = 2; // number of scintillator layers in the preshower section
109
110 fECPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the EM calorimeter section
111 fECScintThick = 0.5; // cm, Thickness of the sintilator for the EM alorimeter section of the tower
112 fNECLayers = 19; // number of scintillator layers in the EM calorimeter section
113
114 fHCCuRadThickness = 0.0; // cm, Thickness of the Cu radiators.
115 fHCScintThick = 0.0; // cm, Thickness of the sintilator for the hadronic alorimeter section of the tower
116 fNHCLayers = 0; // number of scintillator layers in the hadronic calorimeter section
117
1f9dd834 118 fSampling = 11.3 ;
395c7ba2 119 fSummationFraction = 0.8 ;
120
121 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
122 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
123 }
124 else if ( name == "G65_2_64_19" || name == "EMCAL_6564_21" ) {
125 fPRPbRadThickness = 0.6; // cm, Thickness of the Pb radiators for the preshower section
126 fPRScintThick = 0.5; // cm, Thickness of the sintilator for the preshower section of the tower
127 fNPRLayers = 2; // number of scintillator layers in the preshower section
128
129 fECPbRadThickness = 0.6; // cm, Thickness of the Pb radiators for the EM calorimeter section
130 fECScintThick = 0.4; // cm, Thickness of the sintilator for the EM alorimeter section of the tower
131 fNECLayers = 19; // number of scintillator layers in the EM calorimeter section
132
133 fHCCuRadThickness = 0.0; // cm, Thickness of the Cu radiators.
134 fHCScintThick = 0.0; // cm, Thickness of the sintilator for the hadronic alorimeter section of the tower
135 fNHCLayers = 0; // number of scintillator layers in the hadronic calorimeter section
136
1f9dd834 137 fSampling = 16. ;
395c7ba2 138 fSummationFraction = 0.8 ;
139
140 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
141 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
142 }
143 else
144 Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
05a92d59 145
395c7ba2 146 // if( name != "EMCALArch1a" &&
147// name != "EMCALArch1b" &&
148// name != "EMCALArch2a" &&
149// name != "EMCALArch2b" &&
150// name != "EMCALArch1aN" ){
151// Fatal("Init", "%s is not a known geometry (choose among EMCALArch1a, EMCALArch1b, EMCALArch2a and EMCALArch2b, EMCALArch1aN)", name.Data()) ;
152// } // end if
153// //
154// if ( name == "EMCALArch1a" ||
155// name == "EMCALArch1b" ||
156// name == "EMCALArch1aN") {
157// fNZ = 96;
158// fNPhi = 144;
159// } // end if
160// if ( name == "EMCALArch2a" ||
161// name == "EMCALArch2b" ) {
162// fNZ = 112;
163// fNPhi = 168;
164// } // end if
165// if ( name == "EMCALArch1a" ||
166// name == "EMCALArch2a" ) {
167// fNPRLayers = 2;
168// fNECLayers = 19;
169// fNHCLayers = 0;
170// } // end if
171// if ( name == "EMCALArch1b" ||
172// name == "EMCALArch2b" ) {
173// fNPRLayers = 2;
174// fNECLayers = 23;
175// fNHCLayers = 0;
176// } // end if
177// if ( name == "EMCALArch1aN") {
178// fNPRLayers = 2;
179// fNECLayers = 19;
180// fNHCLayers = 14;
181// }
182
183 // geometry
184 fNZ = 96; // granularity along Z (eta)
185 fNPhi = 144; // granularity in phi (azimuth)
186 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
187 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
188 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
189 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
190
191 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
192 fShellThickness = fAlFrontThick + fGap2Active + 2.*(GetPRScintThick() + GetPRPbRadThick()) + // pre shower
193 (fNECLayers-1)*(GetECScintThick()+ GetECPbRadThick()) + // E cal -1 because the last element is a scintillator
194 fNHCLayers*(GetHCScintThick()+ GetHCCuRadThick()) + // H cal
195 GetHCScintThick() ; // last scintillator
196 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
197 fEnvelop[0] = fIPDistance; // mother volume inner radius
198 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
199 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
200
201 fgInit = kTRUE;
202
203 Info("Init", "geometry of EMCAL named %s is as follows:", name.Data());
204 printf( "Tower geometry pre-shower: %d x (%f mm Pb, %f mm Sc) \n", GetNPRLayers(), GetPRPbRadThick(), GetPRScintThick() ) ;
205 printf( " ECAL : %d x (%f mm Pb, %f mm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
206 if ( GetNHCLayers() > 0 )
207 printf( " HCAL : %d x (%f mm Pb, %f mm Sc) \n", GetNHCLayers(), GetHCCuRadThick(), GetHCScintThick() ) ;
208 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
209 printf("Layout: phi = (%f, %f), eta = (%f, %f), y = %f\n",
210 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() ) ;
2012850d 211}
173558f2 212
b13bbe81 213//______________________________________________________________________
214AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 215 // Returns the pointer of the unique instance
216
217 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
2012850d 218}
173558f2 219
b13bbe81 220//______________________________________________________________________
221AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
222 const Text_t* title){
223 // Returns the pointer of the unique instance
224
225 AliEMCALGeometry * rv = 0;
226 if ( fgGeom == 0 ) {
227 if ( strcmp(name,"") == 0 ) rv = 0;
228 else {
229 fgGeom = new AliEMCALGeometry(name, title);
230 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
231 else {
232 rv = 0;
233 delete fgGeom;
234 fgGeom = 0;
235 } // end if fgInit
236 } // end if strcmp(name,"")
237 }else{
238 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
9859bfc0 239 TString message("\n") ;
240 message += "current geometry is " ;
241 message += fgGeom->GetName() ;
242 message += "\n you cannot call " ;
243 message += name ;
244 ::Info("GetGeometry", message.Data() ) ;
b13bbe81 245 }else{
9859bfc0 246 rv = (AliEMCALGeometry *) fgGeom;
b13bbe81 247 } // end if
248 } // end if fgGeom
249 return rv;
2012850d 250}
173558f2 251
ca8f5bd0 252//______________________________________________________________________
395c7ba2 253Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
254 // Returns the tower index number from the based on the Z and Phi
255 // index numbers. There are 2 times the number of towers to separate
256 // out the full towers from the pre-showers.
257 // Inputs:
258 // Int_t ieta // index allong z axis [1-fNZ]
259 // Int_t iphi // index allong phi axis [1-fNPhi]
260 // Int_t where // 1 = PRE section, 0 = EC section, 2 = HC section
261 // Outputs:
262 // none.
263 // Returned
264 // Int_t index // Tower index number
265
266 if ( (ieta <= 0 || ieta>GetNEta()) ||
267 (iphi <= 0 || iphi>GetNPhi()))
268 Fatal("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
269
270 return ( (iphi - 1)*GetNEta() + ieta );
ca8f5bd0 271}
173558f2 272
ca8f5bd0 273//______________________________________________________________________
e908f07f 274void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
a34b7b9f 275 Int_t &ipre) const {
395c7ba2 276 // Inputs:
277 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
278 // Outputs:
279 // Int_t ieta // index allong z axis [1-fNZ]
280 // Int_t iphi // index allong phi axis [1-fNPhi]
281 // Int_t ipre // 0 = ECAL section, 1 = Pre-shower section, 2 = HCAL section
282 // Returned
283 // none.
284
285
286 Int_t nindex = 0, itowers = GetNEta() * GetNPhi();
287
288 if ( IsInPRE(index) ) { // PRE index
289 nindex = index - itowers;
290 ipre = 1 ;
291 }
292 else if ( IsInECAL(index) ) { // ECAL index
293 nindex = index ;
294 ipre = 0 ;
295 }
296 else if ( IsInHCAL(index) ) { // HCAL index
297 nindex = index - 2*itowers;
298 ipre = 2 ;
299 }
300 else
301 Fatal("TowerIndexes", "Unexpected Id number!") ;
302
303 if (nindex%GetNZ())
304 iphi = nindex / GetNZ() + 1 ;
305 else
306 iphi = nindex / GetNZ() ;
307 ieta = nindex - (iphi - 1) * GetNZ() ;
308
309 if (gDebug==2)
310 Info("TowerIndexes", "index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
311 return;
312
ca8f5bd0 313}
173558f2 314
ca8f5bd0 315//______________________________________________________________________
a34b7b9f 316void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
ca8f5bd0 317 // given the tower index number it returns the based on the eta and phi
318 // of the tower.
319 // Inputs:
395c7ba2 320 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
ca8f5bd0 321 // Outputs:
322 // Float_t eta // eta of center of tower in pseudorapidity
323 // Float_t phi // phi of center of tower in degrees
324 // Returned
325 // none.
395c7ba2 326 Int_t ieta, iphi, ipre ;
327 Float_t deta, dphi ;
ca8f5bd0 328
e908f07f 329 TowerIndexes(index,ieta,iphi,ipre);
395c7ba2 330
331 if (gDebug == 2)
332 Info("EtaPhiFromIndex","index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
333
334 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
335 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
336
337 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
338 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
ca8f5bd0 339}
173558f2 340
ca8f5bd0 341//______________________________________________________________________
a34b7b9f 342Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 343 // returns the tower index number based on the eta and phi of the tower.
344 // Inputs:
345 // Float_t eta // eta of center of tower in pseudorapidity
346 // Float_t phi // phi of center of tower in degrees
347 // Outputs:
348 // none.
349 // Returned
350 // Int_t index // Tower index number [1-fNZ*fNPhi]
395c7ba2 351
e908f07f 352 Int_t ieta,iphi;
ca8f5bd0 353
395c7ba2 354 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
355
356 if( ieta <= 0 || ieta > GetNEta() ) {
357 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
358 return -1 ;
359 }
360
361 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
362
363 if( iphi <= 0 || iphi > GetNPhi() ) {
364 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
365 return -1 ;
366 }
367
368 return TowerIndex(ieta,iphi);
ca8f5bd0 369}
173558f2 370
ca8f5bd0 371//______________________________________________________________________
a34b7b9f 372Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 373 // returns the pretower index number based on the eta and phi of the tower.
374 // Inputs:
375 // Float_t eta // eta of center of tower in pseudorapidity
376 // Float_t phi // phi of center of tower in degrees
377 // Outputs:
378 // none.
379 // Returned
380 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
381
e908f07f 382 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
ca8f5bd0 383}
173558f2 384
ca8f5bd0 385//______________________________________________________________________
a34b7b9f 386Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
ca8f5bd0 387 // Converts the absolute numbering into the following array/
5a9318ff 388 // relid[0] = EMCAL Arm number 1:1
395c7ba2 389 // relid[1] = 0 ECAL section ; = 1 PRE section; = 2 HCA section
ca8f5bd0 390 // relid[2] = Row number inside EMCAL
391 // relid[3] = Column number inside EMCAL
392 // Input:
393 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
394 // Outputs:
395 // Int_t *relid // array of 5. Discribed above.
396 Bool_t rv = kTRUE ;
e908f07f 397 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
ca8f5bd0 398
e908f07f 399 TowerIndexes(index,ieta,iphi,ipre);
ca8f5bd0 400 relid[0] = 1;
395c7ba2 401 relid[1] = ipre;
e908f07f 402 relid[2] = ieta;
ca8f5bd0 403 relid[3] = iphi;
404
405 return rv;
406}
173558f2 407
ca8f5bd0 408//______________________________________________________________________
395c7ba2 409void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
410{
411 // Converts the relative numbering into the local EMCAL-module (x, z)
412 // coordinates
413 Int_t sect = relid[1]; // PRE/ECAL/HCAL section 1/0/2
414 Int_t ieta = relid[2]; // offset along x axis
415 Int_t iphi = relid[3]; // offset along z axis
416 Int_t index;
417 Float_t eta;
418
419 index = TowerIndex(ieta,iphi);
420 EtaPhiFromIndex(index,eta,phi);
421 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
422
423 // correct for distance to IP different in PRE/ECAL/HCAL
424 Float_t d = 0. ;
425 if (sect == 1)
426 d = GetIP2PRESection() - GetIPDistance() ;
427 else if (sect == 0)
428 d = GetIP2ECALSection() - GetIPDistance() ;
429 else if (sect == 2)
430 d = GetIP2HCALSection() - GetIPDistance() ;
431 else
432 Fatal("PosInAlice", "Unexpected tower section!") ;
433
434 Float_t correction = 1 + d/GetIPDistance() ;
435 Float_t tantheta = TMath::Tan(theta) * correction ;
436 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
437 if (theta < 0 )
438 theta += 180. ;
439
440 return;
441}
ca8f5bd0 442
395c7ba2 443//______________________________________________________________________
444void AliEMCALGeometry::PosInAlice(const Int_t absid, Float_t &theta, Float_t &phi) const
445{
446 // Converts the relative numbering into the local EMCAL-module (x, z)
447 // coordinates
448
449 Int_t relid[4] ;
450 AbsToRelNumbering(absid, relid) ;
451 Int_t ieta = relid[2]; // offset along x axis
452 Int_t iphi = relid[3]; // offset along z axis
453 Int_t index;
454 Float_t eta;
455
456 index = TowerIndex(ieta,iphi);
457 EtaPhiFromIndex(index,eta,phi);
458 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
459
460 // correct for distance to IP different in PRE/ECAL/HCAL
461 Float_t d = 0. ;
462 if (IsInPRE(absid))
463 d = GetIP2PRESection() - GetIPDistance() ;
464 else if (IsInECAL(absid))
465 d = GetIP2ECALSection() - GetIPDistance() ;
466 else if (IsInHCAL(absid))
467 d = GetIP2HCALSection() - GetIPDistance() ;
468 else
469 Fatal("PosInAlice", "Unexpected id # %d!", absid) ;
470
471 Float_t correction = 1 + d/GetIPDistance() ;
472 Float_t tantheta = TMath::Tan(theta) * correction ;
473 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
474 if (theta < 0 )
475 theta += 180. ;
476
477 return;
ca8f5bd0 478}
6119e5db 479
480//______________________________________________________________________
481void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
482 // given the tower relative number it returns the X, Y and Z
483 // of the tower.
484
485 // Outputs:
486 // Float_t x // x of center of tower in cm
487 // Float_t y // y of center of tower in cm
488 // Float_t z // z of centre of tower in cm
489 // Returned
490 // none.
491
395c7ba2 492 Float_t eta,theta, phi,cyl_radius=0. ;
6119e5db 493
494 Int_t ieta = relid[2]; // offset along x axis
495 Int_t iphi = relid[3]; // offset along z axis
395c7ba2 496 Int_t ipre = relid[1]; // indicates 0 ECAL section, 1 PRE section, 2 HCAL section.
6119e5db 497 Int_t index;
498
395c7ba2 499 index = TowerIndex(ieta,iphi);
6119e5db 500 EtaPhiFromIndex(index,eta,phi);
501 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
6119e5db 502
395c7ba2 503 if ( ipre == 0 )
504 cyl_radius = GetIP2ECALSection() ;
505 else if ( ipre == 1 )
506 cyl_radius = GetIP2PRESection() ;
507 else if ( ipre == 2 )
508 cyl_radius = GetIP2HCALSection() ;
a97849a9 509 else
395c7ba2 510 Fatal("XYZFromIndex", "Unexpected Tower section # %d", ipre) ;
a97849a9 511
395c7ba2 512 Double_t kDeg2Rad = TMath::DegToRad() ;
6119e5db 513 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
f6eaf97a 514 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
6119e5db 515 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
516
517 return;
518}
519
395c7ba2 520//______________________________________________________________________
521void AliEMCALGeometry::XYZFromIndex(const Int_t absid, TVector3 &v) const {
522 // given the tower relative number it returns the X, Y and Z
523 // of the tower.
524
525 // Outputs:
526 // Float_t x // x of center of tower in cm
527 // Float_t y // y of center of tower in cm
528 // Float_t z // z of centre of tower in cm
529 // Returned
530 // none.
531
532 Float_t theta, phi,cyl_radius=0. ;
533
534 PosInAlice(absid, theta, phi) ;
535
536 if ( IsInECAL(absid) )
537 cyl_radius = GetIP2ECALSection() ;
538 else if ( IsInPRE(absid) )
539 cyl_radius = GetIP2PRESection() ;
540 else if ( IsInHCAL(absid) )
541 cyl_radius = GetIP2HCALSection() ;
542 else
543 Fatal("XYZFromIndex", "Unexpected Tower section") ;
544
545 Double_t kDeg2Rad = TMath::DegToRad() ;
546 v.SetX(cyl_radius * TMath::Cos(phi * kDeg2Rad ) );
547 v.SetY(cyl_radius * TMath::Sin(phi * kDeg2Rad ) );
548 v.SetZ(cyl_radius / TMath::Tan(theta * kDeg2Rad ) ) ;
549
550 return;
551}
552
ca8f5bd0 553//______________________________________________________________________
554/*
a34b7b9f 555Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
ca8f5bd0 556 // Returns kTRUE if the two towers are neighbours or not, including
557 // diagonals. Both indexes are required to be either towers or preshower.
558 // Inputs:
559 // Int_t index1 // index of tower 1
560 // Int_t index2 // index of tower 2
561 // Outputs:
562 // none.
563 // Returned
564 // Boot_t kTRUE if the towers are neighbours otherwise false.
565 Boot_t anb = kFALSE;
e908f07f 566 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
ca8f5bd0 567
e908f07f 568 TowerIndexes(index1,ieta1,iphi1,ipre1);
569 TowerIndexes(index2,ieta2,iphi2,ipre2);
ca8f5bd0 570 if(ipre1!=ipre2) return anb;
e908f07f 571 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))
ca8f5bd0 572 anb = kTRUE;
573 return anb;
574}
575 */