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 EMCAL : singleton
20 // EMCAL consists of layers of scintillator and lead
21 // Places the the Barrel Geometry of The EMCAL at Midrapidity
22 // between 0 and 120 degrees of Phi and
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
28 //*-- Author: Sahal Yacoob (LBL / UCT)
29 // and : Yves Schutz (SUBATECH)
30 // and : Jennifer Klay (LBL)
32 // --- AliRoot header files ---
37 //#include "AliConst.h"
40 #include "AliEMCALGeometry.h"
42 ClassImp(AliEMCALGeometry);
44 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
45 Bool_t AliEMCALGeometry::fgInit = kFALSE;
47 //______________________________________________________________________
48 AliEMCALGeometry::~AliEMCALGeometry(void){
52 //______________________________________________________________________
53 Bool_t AliEMCALGeometry::AreInSameTower(Int_t id1, Int_t id2) const {
54 // Find out whether two hits are in the same tower
55 Int_t idmax = TMath::Max(id1, id2) ;
56 Int_t idmin = TMath::Min(id1, id2) ;
57 if ( ((idmax - GetNZ() * GetNPhi()) == idmin ) ||
58 ((idmax - 2 * GetNZ() * GetNPhi()) == idmin ) )
64 //______________________________________________________________________
65 void AliEMCALGeometry::Init(void){
66 // Initializes the EMCAL parameters
67 // naming convention : GUV_WX_N_ gives the composition of a tower
68 // WX inform about the composition of the EM calorimeter section:
69 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
70 // New geometry: EMCAL_55_25
72 fgInit = kFALSE; // Assume failed until proven otherwise.
73 TString name(GetName()) ;
74 if (name == "EMCAL_55_25") {
75 fECPbRadThickness = 0.5; // cm, Thickness of the Pb radiators
76 fECScintThick = 0.5; // cm, Thickness of the scintillator
77 fNECLayers = 25; // number of scintillator layers
81 fAlFrontThick = 3.5; // cm, Thickness of front Al layer
82 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
84 else if( name == "G56_2_55_19" || name == "EMCAL_5655_21" || name == "G56_2_55_19_104_14"|| name == "G65_2_64_19" || name == "EMCAL_6564_21"){
85 Fatal("Init", "%s is an old geometry! Please update your Config file", name.Data()) ;
88 Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
91 fNZ = 114; // granularity along Z (eta)
92 fNPhi = 168; // granularity in phi (azimuth)
93 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
94 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
95 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
96 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
98 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
100 //There is always one more scintillator than radiator layer because of the first block of aluminium
101 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
103 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
104 fEnvelop[0] = fIPDistance; // mother volume inner radius
105 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
106 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
111 printf("Init: geometry of EMCAL named %s is as follows:", name.Data());
112 printf( " ECAL : %d x (%f mm Pb, %f mm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
113 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
114 printf("Layout: phi = (%f, %f), eta = (%f, %f), y = %f\n",
115 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() ) ;
119 //______________________________________________________________________
120 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
121 // Returns the pointer of the unique instance
123 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
126 //______________________________________________________________________
127 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
128 const Text_t* title){
129 // Returns the pointer of the unique instance
131 AliEMCALGeometry * rv = 0;
133 if ( strcmp(name,"") == 0 ) rv = 0;
135 fgGeom = new AliEMCALGeometry(name, title);
136 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
142 } // end if strcmp(name,"")
144 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
145 printf("\ncurrent geometry is ") ;
146 printf(fgGeom->GetName());
147 printf("\n you cannot call ");
150 rv = (AliEMCALGeometry *) fgGeom;
156 //______________________________________________________________________
157 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
158 // Returns the tower index number from the based on the Z and Phi
161 // Int_t ieta // index along z axis [1-fNZ]
162 // Int_t iphi // index along phi axis [1-fNPhi]
166 // Int_t index // Tower index number
168 if ( (ieta <= 0 || ieta>GetNEta()) ||
169 (iphi <= 0 || iphi>GetNPhi()))
170 Fatal("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
172 return ( (iphi - 1)*GetNEta() + ieta );
175 //______________________________________________________________________
176 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
178 // Int_t index // Tower index number [1-fNZ*fNPhi]
180 // Int_t ieta // index allong z axis [1-fNZ]
181 // Int_t iphi // index allong phi axis [1-fNPhi]
187 if ( IsInECA(index) ) { // ECAL index
191 Fatal("TowerIndexes", "Unexpected Id number!") ;
194 iphi = nindex / GetNZ() + 1 ;
196 iphi = nindex / GetNZ() ;
197 ieta = nindex - (iphi - 1) * GetNZ() ;
200 printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
205 //______________________________________________________________________
206 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
207 // given the tower index number it returns the based on the eta and phi
210 // Int_t index // Tower index number [1-fNZ*fNPhi]
212 // Float_t eta // eta of center of tower in pseudorapidity
213 // Float_t phi // phi of center of tower in degrees
219 TowerIndexes(index,ieta,iphi);
222 printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
224 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
225 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
227 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
228 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
231 //______________________________________________________________________
232 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
233 // returns the tower index number based on the eta and phi of the tower.
235 // Float_t eta // eta of center of tower in pseudorapidity
236 // Float_t phi // phi of center of tower in degrees
240 // Int_t index // Tower index number [1-fNZ*fNPhi]
244 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
246 if( ieta <= 0 || ieta > GetNEta() ) {
247 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
251 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
253 if( iphi <= 0 || iphi > GetNPhi() ) {
254 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
258 return TowerIndex(ieta,iphi);
261 //______________________________________________________________________
262 Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
263 // returns the pretower index number based on the eta and phi of the tower.
265 // Float_t eta // eta of center of tower in pseudorapidity
266 // Float_t phi // phi of center of tower in degrees
270 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
272 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
275 //______________________________________________________________________
276 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
277 // Converts the absolute numbering into the following array/
278 // relid[0] = EMCAL Arm number 1:1
279 // relid[1] = Row number inside EMCAL
280 // relid[2] = Column number inside EMCAL
282 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
284 // Int_t *relid // array of 3. Discribed above.
286 Int_t ieta=0,iphi=0,index=AbsId;
288 TowerIndexes(index,ieta,iphi);
296 //______________________________________________________________________
297 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
299 // Converts the relative numbering into the local EMCAL-module (x, z)
301 Int_t ieta = relid[1]; // offset along x axis
302 Int_t iphi = relid[2]; // offset along z axis
306 index = TowerIndex(ieta,iphi);
307 EtaPhiFromIndex(index,eta,phi);
308 //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
309 theta = 2.0*TMath::ATan(TMath::Exp(-eta));
311 // correct for distance to IP
312 Float_t d = GetIP2ECASection() - GetIPDistance() ;
314 Float_t correction = 1 + d/GetIPDistance() ;
315 Float_t tantheta = TMath::Tan(theta) * correction ;
316 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
323 //______________________________________________________________________
324 void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
326 // Converts the relative numbering into the local EMCAL-module (x, z)
330 AbsToRelNumbering(absid, relid) ;
331 Int_t ieta = relid[1]; // offset along x axis
332 Int_t iphi = relid[2]; // offset along z axis
336 index = TowerIndex(ieta,iphi);
337 EtaPhiFromIndex(index,eta,phi);
338 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
340 // correct for distance to IP
343 d = GetIP2ECASection() - GetIPDistance() ;
345 Fatal("PosInAlice", "Unexpected id # %d!", absid) ;
347 Float_t correction = 1 + d/GetIPDistance() ;
348 Float_t tantheta = TMath::Tan(theta) * correction ;
349 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
356 //______________________________________________________________________
357 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
358 // given the tower relative number it returns the X, Y and Z
362 // Float_t x // x of center of tower in cm
363 // Float_t y // y of center of tower in cm
364 // Float_t z // z of centre of tower in cm
368 Float_t eta,theta, phi,cylradius=0. ;
370 Int_t ieta = relid[1]; // offset along x axis
371 Int_t iphi = relid[2]; // offset along z axis.
374 index = TowerIndex(ieta,iphi);
375 EtaPhiFromIndex(index,eta,phi);
376 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
378 cylradius = GetIP2ECASection() ;
380 Double_t kDeg2Rad = TMath::DegToRad() ;
381 x = cylradius * TMath::Cos(phi * kDeg2Rad ) ;
382 y = cylradius * TMath::Sin(phi * kDeg2Rad ) ;
383 z = cylradius / TMath::Tan(theta * kDeg2Rad ) ;
388 //______________________________________________________________________
389 void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const {
390 // given the tower relative number it returns the X, Y and Z
394 // Float_t x // x of center of tower in cm
395 // Float_t y // y of center of tower in cm
396 // Float_t z // z of centre of tower in cm
400 Float_t theta, phi,cylradius=0. ;
402 PosInAlice(absid, theta, phi) ;
404 if ( IsInECA(absid) )
405 cylradius = GetIP2ECASection() ;
407 Fatal("XYZFromIndex", "Unexpected Tower section") ;
409 Double_t kDeg2Rad = TMath::DegToRad() ;
410 v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) );
411 v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) );
412 v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ;
417 //______________________________________________________________________
419 Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
420 // Returns kTRUE if the two towers are neighbours or not, including
421 // diagonals. Both indexes are required to be either towers or preshower.
423 // Int_t index1 // index of tower 1
424 // Int_t index2 // index of tower 2
428 // Boot_t kTRUE if the towers are neighbours otherwise false.
430 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0;
432 TowerIndexes(index1,ieta1,iphi1);
433 TowerIndexes(index2,ieta2,iphi2);
434 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))