]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALGeometry.cxx
Moved the EMCAL back to 60 < phi < 180
[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)
7b9182d8 186 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
187 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
395c7ba2 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
88cb7938 203 if (gDebug) {
204 Info("Init", "geometry of EMCAL named %s is as follows:", name.Data());
205 printf( "Tower geometry pre-shower: %d x (%f mm Pb, %f mm Sc) \n", GetNPRLayers(), GetPRPbRadThick(), GetPRScintThick() ) ;
206 printf( " ECAL : %d x (%f mm Pb, %f mm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
207 if ( GetNHCLayers() > 0 )
208 printf( " HCAL : %d x (%f mm Pb, %f mm Sc) \n", GetNHCLayers(), GetHCCuRadThick(), GetHCScintThick() ) ;
209 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
210 printf("Layout: phi = (%f, %f), eta = (%f, %f), y = %f\n",
211 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() ) ;
212 }
2012850d 213}
173558f2 214
b13bbe81 215//______________________________________________________________________
216AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 217 // Returns the pointer of the unique instance
218
219 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
2012850d 220}
173558f2 221
b13bbe81 222//______________________________________________________________________
223AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
224 const Text_t* title){
225 // Returns the pointer of the unique instance
226
227 AliEMCALGeometry * rv = 0;
228 if ( fgGeom == 0 ) {
229 if ( strcmp(name,"") == 0 ) rv = 0;
230 else {
231 fgGeom = new AliEMCALGeometry(name, title);
232 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
233 else {
234 rv = 0;
235 delete fgGeom;
236 fgGeom = 0;
237 } // end if fgInit
238 } // end if strcmp(name,"")
239 }else{
240 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
9859bfc0 241 TString message("\n") ;
242 message += "current geometry is " ;
243 message += fgGeom->GetName() ;
244 message += "\n you cannot call " ;
245 message += name ;
246 ::Info("GetGeometry", message.Data() ) ;
b13bbe81 247 }else{
9859bfc0 248 rv = (AliEMCALGeometry *) fgGeom;
b13bbe81 249 } // end if
250 } // end if fgGeom
251 return rv;
2012850d 252}
173558f2 253
ca8f5bd0 254//______________________________________________________________________
395c7ba2 255Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
256 // Returns the tower index number from the based on the Z and Phi
257 // index numbers. There are 2 times the number of towers to separate
258 // out the full towers from the pre-showers.
259 // Inputs:
260 // Int_t ieta // index allong z axis [1-fNZ]
261 // Int_t iphi // index allong phi axis [1-fNPhi]
262 // Int_t where // 1 = PRE section, 0 = EC section, 2 = HC section
263 // Outputs:
264 // none.
265 // Returned
266 // Int_t index // Tower index number
267
268 if ( (ieta <= 0 || ieta>GetNEta()) ||
269 (iphi <= 0 || iphi>GetNPhi()))
270 Fatal("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
271
272 return ( (iphi - 1)*GetNEta() + ieta );
ca8f5bd0 273}
173558f2 274
ca8f5bd0 275//______________________________________________________________________
e908f07f 276void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
a34b7b9f 277 Int_t &ipre) const {
395c7ba2 278 // Inputs:
279 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
280 // Outputs:
281 // Int_t ieta // index allong z axis [1-fNZ]
282 // Int_t iphi // index allong phi axis [1-fNPhi]
283 // Int_t ipre // 0 = ECAL section, 1 = Pre-shower section, 2 = HCAL section
284 // Returned
285 // none.
286
287
288 Int_t nindex = 0, itowers = GetNEta() * GetNPhi();
289
290 if ( IsInPRE(index) ) { // PRE index
291 nindex = index - itowers;
292 ipre = 1 ;
293 }
88cb7938 294 else if ( IsInECA(index) ) { // ECAL index
395c7ba2 295 nindex = index ;
296 ipre = 0 ;
297 }
88cb7938 298 else if ( IsInHCA(index) ) { // HCAL index
395c7ba2 299 nindex = index - 2*itowers;
300 ipre = 2 ;
301 }
302 else
303 Fatal("TowerIndexes", "Unexpected Id number!") ;
304
305 if (nindex%GetNZ())
306 iphi = nindex / GetNZ() + 1 ;
307 else
308 iphi = nindex / GetNZ() ;
309 ieta = nindex - (iphi - 1) * GetNZ() ;
310
311 if (gDebug==2)
312 Info("TowerIndexes", "index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
313 return;
314
ca8f5bd0 315}
173558f2 316
ca8f5bd0 317//______________________________________________________________________
a34b7b9f 318void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
ca8f5bd0 319 // given the tower index number it returns the based on the eta and phi
320 // of the tower.
321 // Inputs:
395c7ba2 322 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
ca8f5bd0 323 // Outputs:
324 // Float_t eta // eta of center of tower in pseudorapidity
325 // Float_t phi // phi of center of tower in degrees
326 // Returned
327 // none.
395c7ba2 328 Int_t ieta, iphi, ipre ;
329 Float_t deta, dphi ;
ca8f5bd0 330
e908f07f 331 TowerIndexes(index,ieta,iphi,ipre);
395c7ba2 332
333 if (gDebug == 2)
334 Info("EtaPhiFromIndex","index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
335
336 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
337 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
338
339 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
340 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
ca8f5bd0 341}
173558f2 342
ca8f5bd0 343//______________________________________________________________________
a34b7b9f 344Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 345 // returns the tower index number based on the eta and phi of the tower.
346 // Inputs:
347 // Float_t eta // eta of center of tower in pseudorapidity
348 // Float_t phi // phi of center of tower in degrees
349 // Outputs:
350 // none.
351 // Returned
352 // Int_t index // Tower index number [1-fNZ*fNPhi]
395c7ba2 353
e908f07f 354 Int_t ieta,iphi;
ca8f5bd0 355
395c7ba2 356 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
357
358 if( ieta <= 0 || ieta > GetNEta() ) {
359 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
360 return -1 ;
361 }
362
363 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
364
365 if( iphi <= 0 || iphi > GetNPhi() ) {
366 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
367 return -1 ;
368 }
369
370 return TowerIndex(ieta,iphi);
ca8f5bd0 371}
173558f2 372
ca8f5bd0 373//______________________________________________________________________
a34b7b9f 374Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 375 // returns the pretower index number based on the eta and phi of the tower.
376 // Inputs:
377 // Float_t eta // eta of center of tower in pseudorapidity
378 // Float_t phi // phi of center of tower in degrees
379 // Outputs:
380 // none.
381 // Returned
382 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
383
e908f07f 384 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
ca8f5bd0 385}
173558f2 386
ca8f5bd0 387//______________________________________________________________________
a34b7b9f 388Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
ca8f5bd0 389 // Converts the absolute numbering into the following array/
5a9318ff 390 // relid[0] = EMCAL Arm number 1:1
395c7ba2 391 // relid[1] = 0 ECAL section ; = 1 PRE section; = 2 HCA section
ca8f5bd0 392 // relid[2] = Row number inside EMCAL
393 // relid[3] = Column number inside EMCAL
394 // Input:
395 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
396 // Outputs:
397 // Int_t *relid // array of 5. Discribed above.
398 Bool_t rv = kTRUE ;
e908f07f 399 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
ca8f5bd0 400
e908f07f 401 TowerIndexes(index,ieta,iphi,ipre);
ca8f5bd0 402 relid[0] = 1;
395c7ba2 403 relid[1] = ipre;
e908f07f 404 relid[2] = ieta;
ca8f5bd0 405 relid[3] = iphi;
406
407 return rv;
408}
173558f2 409
ca8f5bd0 410//______________________________________________________________________
395c7ba2 411void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
412{
413 // Converts the relative numbering into the local EMCAL-module (x, z)
414 // coordinates
415 Int_t sect = relid[1]; // PRE/ECAL/HCAL section 1/0/2
416 Int_t ieta = relid[2]; // offset along x axis
417 Int_t iphi = relid[3]; // offset along z axis
418 Int_t index;
419 Float_t eta;
420
421 index = TowerIndex(ieta,iphi);
422 EtaPhiFromIndex(index,eta,phi);
423 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
424
425 // correct for distance to IP different in PRE/ECAL/HCAL
426 Float_t d = 0. ;
427 if (sect == 1)
428 d = GetIP2PRESection() - GetIPDistance() ;
429 else if (sect == 0)
88cb7938 430 d = GetIP2ECASection() - GetIPDistance() ;
395c7ba2 431 else if (sect == 2)
88cb7938 432 d = GetIP2HCASection() - GetIPDistance() ;
395c7ba2 433 else
434 Fatal("PosInAlice", "Unexpected tower section!") ;
435
436 Float_t correction = 1 + d/GetIPDistance() ;
437 Float_t tantheta = TMath::Tan(theta) * correction ;
438 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
439 if (theta < 0 )
440 theta += 180. ;
441
442 return;
443}
ca8f5bd0 444
395c7ba2 445//______________________________________________________________________
446void AliEMCALGeometry::PosInAlice(const Int_t absid, Float_t &theta, Float_t &phi) const
447{
448 // Converts the relative numbering into the local EMCAL-module (x, z)
449 // coordinates
450
451 Int_t relid[4] ;
452 AbsToRelNumbering(absid, relid) ;
453 Int_t ieta = relid[2]; // offset along x axis
454 Int_t iphi = relid[3]; // offset along z axis
455 Int_t index;
456 Float_t eta;
457
458 index = TowerIndex(ieta,iphi);
459 EtaPhiFromIndex(index,eta,phi);
460 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
461
462 // correct for distance to IP different in PRE/ECAL/HCAL
463 Float_t d = 0. ;
464 if (IsInPRE(absid))
465 d = GetIP2PRESection() - GetIPDistance() ;
88cb7938 466 else if (IsInECA(absid))
467 d = GetIP2ECASection() - GetIPDistance() ;
468 else if (IsInHCA(absid))
469 d = GetIP2HCASection() - GetIPDistance() ;
395c7ba2 470 else
471 Fatal("PosInAlice", "Unexpected id # %d!", absid) ;
472
473 Float_t correction = 1 + d/GetIPDistance() ;
474 Float_t tantheta = TMath::Tan(theta) * correction ;
475 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
476 if (theta < 0 )
477 theta += 180. ;
478
479 return;
ca8f5bd0 480}
6119e5db 481
482//______________________________________________________________________
483void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
484 // given the tower relative number it returns the X, Y and Z
485 // of the tower.
486
487 // Outputs:
488 // Float_t x // x of center of tower in cm
489 // Float_t y // y of center of tower in cm
490 // Float_t z // z of centre of tower in cm
491 // Returned
492 // none.
493
395c7ba2 494 Float_t eta,theta, phi,cyl_radius=0. ;
6119e5db 495
496 Int_t ieta = relid[2]; // offset along x axis
497 Int_t iphi = relid[3]; // offset along z axis
395c7ba2 498 Int_t ipre = relid[1]; // indicates 0 ECAL section, 1 PRE section, 2 HCAL section.
6119e5db 499 Int_t index;
500
395c7ba2 501 index = TowerIndex(ieta,iphi);
6119e5db 502 EtaPhiFromIndex(index,eta,phi);
503 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
6119e5db 504
395c7ba2 505 if ( ipre == 0 )
88cb7938 506 cyl_radius = GetIP2ECASection() ;
395c7ba2 507 else if ( ipre == 1 )
508 cyl_radius = GetIP2PRESection() ;
509 else if ( ipre == 2 )
88cb7938 510 cyl_radius = GetIP2HCASection() ;
a97849a9 511 else
395c7ba2 512 Fatal("XYZFromIndex", "Unexpected Tower section # %d", ipre) ;
a97849a9 513
395c7ba2 514 Double_t kDeg2Rad = TMath::DegToRad() ;
6119e5db 515 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
f6eaf97a 516 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
6119e5db 517 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
518
519 return;
520}
521
395c7ba2 522//______________________________________________________________________
523void AliEMCALGeometry::XYZFromIndex(const Int_t absid, TVector3 &v) const {
524 // given the tower relative number it returns the X, Y and Z
525 // of the tower.
526
527 // Outputs:
528 // Float_t x // x of center of tower in cm
529 // Float_t y // y of center of tower in cm
530 // Float_t z // z of centre of tower in cm
531 // Returned
532 // none.
533
534 Float_t theta, phi,cyl_radius=0. ;
535
536 PosInAlice(absid, theta, phi) ;
537
88cb7938 538 if ( IsInECA(absid) )
539 cyl_radius = GetIP2ECASection() ;
395c7ba2 540 else if ( IsInPRE(absid) )
541 cyl_radius = GetIP2PRESection() ;
88cb7938 542 else if ( IsInHCA(absid) )
543 cyl_radius = GetIP2HCASection() ;
395c7ba2 544 else
545 Fatal("XYZFromIndex", "Unexpected Tower section") ;
546
547 Double_t kDeg2Rad = TMath::DegToRad() ;
548 v.SetX(cyl_radius * TMath::Cos(phi * kDeg2Rad ) );
549 v.SetY(cyl_radius * TMath::Sin(phi * kDeg2Rad ) );
550 v.SetZ(cyl_radius / TMath::Tan(theta * kDeg2Rad ) ) ;
551
552 return;
553}
554
ca8f5bd0 555//______________________________________________________________________
556/*
a34b7b9f 557Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
ca8f5bd0 558 // Returns kTRUE if the two towers are neighbours or not, including
559 // diagonals. Both indexes are required to be either towers or preshower.
560 // Inputs:
561 // Int_t index1 // index of tower 1
562 // Int_t index2 // index of tower 2
563 // Outputs:
564 // none.
565 // Returned
566 // Boot_t kTRUE if the towers are neighbours otherwise false.
567 Boot_t anb = kFALSE;
e908f07f 568 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
ca8f5bd0 569
e908f07f 570 TowerIndexes(index1,ieta1,iphi1,ipre1);
571 TowerIndexes(index2,ieta2,iphi2,ipre2);
ca8f5bd0 572 if(ipre1!=ipre2) return anb;
e908f07f 573 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))
ca8f5bd0 574 anb = kTRUE;
575 return anb;
576}
577 */