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 //*-- Author: Sahal Yacoob (LBL / UCT)
27 // and : Yves Schutz (SUBATECH)
28 // and : Jennifer Klay (LBL)
30 // --- AliRoot header files ---
35 //#include "AliConst.h"
38 #include "AliEMCALGeometry.h"
40 ClassImp(AliEMCALGeometry);
42 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
43 Bool_t AliEMCALGeometry::fgInit = kFALSE;
45 //______________________________________________________________________
46 AliEMCALGeometry::~AliEMCALGeometry(void){
50 //______________________________________________________________________
51 Bool_t AliEMCALGeometry::AreInSameTower(Int_t id1, Int_t id2) const {
52 // Find out whether two hits are in the same tower
53 Int_t idmax = TMath::Max(id1, id2) ;
54 Int_t idmin = TMath::Min(id1, id2) ;
55 if ( ((idmax - GetNZ() * GetNPhi()) == idmin ) ||
56 ((idmax - 2 * GetNZ() * GetNPhi()) == idmin ) )
62 //______________________________________________________________________
63 void AliEMCALGeometry::Init(void){
64 // Initializes the EMCAL parameters
65 // naming convention : GUV_WX_N_ gives the composition of a tower
66 // WX inform about the composition of the EM calorimeter section:
67 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
68 // New geometry: EMCAL_55_25
70 fgInit = kFALSE; // Assume failed until proven otherwise.
71 TString name(GetName()) ;
72 if (name == "EMCAL_55_25") {
73 fECPbRadThickness = 0.5; // cm, Thickness of the Pb radiators
74 fECScintThick = 0.5; // cm, Thickness of the scintillator
75 fNECLayers = 25; // number of scintillator layers
79 fAlFrontThick = 3.5; // cm, Thickness of front Al layer
80 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
82 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"){
83 Fatal("Init", "%s is an old geometry! Please update your Config file", name.Data()) ;
86 Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
89 fNZ = 114; // granularity along Z (eta)
90 fNPhi = 168; // granularity in phi (azimuth)
91 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
92 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
93 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
94 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
96 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
98 //There is always one more scintillator than radiator layer because of the first block of aluminium
99 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
101 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
102 fEnvelop[0] = fIPDistance; // mother volume inner radius
103 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
104 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
109 printf("Init: geometry of EMCAL named %s is as follows:", name.Data());
110 printf( " ECAL : %d x (%f mm Pb, %f mm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
111 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
112 printf("Layout: phi = (%f, %f), eta = (%f, %f), y = %f\n",
113 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() ) ;
117 //______________________________________________________________________
118 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
119 // Returns the pointer of the unique instance
121 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
124 //______________________________________________________________________
125 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
126 const Text_t* title){
127 // Returns the pointer of the unique instance
129 AliEMCALGeometry * rv = 0;
131 if ( strcmp(name,"") == 0 ) rv = 0;
133 fgGeom = new AliEMCALGeometry(name, title);
134 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
140 } // end if strcmp(name,"")
142 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
143 printf("\ncurrent geometry is ") ;
144 printf(fgGeom->GetName());
145 printf("\n you cannot call ");
148 rv = (AliEMCALGeometry *) fgGeom;
154 //______________________________________________________________________
155 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
156 // Returns the tower index number from the based on the Z and Phi
159 // Int_t ieta // index along z axis [1-fNZ]
160 // Int_t iphi // index along phi axis [1-fNPhi]
164 // Int_t index // Tower index number
166 if ( (ieta <= 0 || ieta>GetNEta()) ||
167 (iphi <= 0 || iphi>GetNPhi())) {
168 Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
171 return ( (iphi - 1)*GetNEta() + ieta );
174 //______________________________________________________________________
175 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
177 // Int_t index // Tower index number [1-fNZ*fNPhi]
179 // Int_t ieta // index allong z axis [1-fNZ]
180 // Int_t iphi // index allong phi axis [1-fNPhi]
186 if ( IsInECA(index) ) { // ECAL index
190 Error("TowerIndexes", "Unexpected Id number!") ;
197 iphi = nindex / GetNZ() + 1 ;
199 iphi = nindex / GetNZ() ;
200 ieta = nindex - (iphi - 1) * GetNZ() ;
203 printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
208 //______________________________________________________________________
209 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
210 // given the tower index number it returns the based on the eta and phi
213 // Int_t index // Tower index number [1-fNZ*fNPhi]
215 // Float_t eta // eta of center of tower in pseudorapidity
216 // Float_t phi // phi of center of tower in degrees
222 TowerIndexes(index,ieta,iphi);
225 printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
227 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
228 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
230 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
231 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
234 //______________________________________________________________________
235 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
236 // returns the tower index number based on the eta and phi of the tower.
238 // Float_t eta // eta of center of tower in pseudorapidity
239 // Float_t phi // phi of center of tower in degrees
243 // Int_t index // Tower index number [1-fNZ*fNPhi]
247 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
249 if( ieta <= 0 || ieta > GetNEta() ) {
250 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
254 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
256 if( iphi <= 0 || iphi > GetNPhi() ) {
257 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
261 return TowerIndex(ieta,iphi);
264 //______________________________________________________________________
265 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
266 // Converts the absolute numbering into the following array/
267 // relid[0] = Row number inside EMCAL
268 // relid[1] = Column number inside EMCAL
270 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
272 // Int_t *relid // array of 2. Described above.
274 Int_t ieta=0,iphi=0,index=AbsId;
276 TowerIndexes(index,ieta,iphi);
283 //______________________________________________________________________
284 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
286 // Converts the relative numbering into the local EMCAL-module (x, z)
288 Int_t ieta = relid[0]; // offset along x axis
289 Int_t iphi = relid[1]; // offset along z axis
293 index = TowerIndex(ieta,iphi);
294 EtaPhiFromIndex(index,eta,phi);
295 //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
296 theta = 2.0*TMath::ATan(TMath::Exp(-eta));
298 // correct for distance to IP
299 Float_t d = GetIP2ECASection() - GetIPDistance() ;
301 Float_t correction = 1 + d/GetIPDistance() ;
302 Float_t tantheta = TMath::Tan(theta) * correction ;
303 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
310 //______________________________________________________________________
311 void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
313 // Converts the relative numbering into the local EMCAL-module (x, z)
316 AbsToRelNumbering(absid, relid) ;
317 Int_t ieta = relid[0]; // offset along x axis
318 Int_t iphi = relid[1]; // offset along z axis
322 index = TowerIndex(ieta,iphi);
323 EtaPhiFromIndex(index,eta,phi);
324 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
326 // correct for distance to IP
329 d = GetIP2ECASection() - GetIPDistance() ;
331 Error("PosInAlice", "Unexpected id # %d!", absid) ;
335 Float_t correction = 1 + d/GetIPDistance() ;
336 Float_t tantheta = TMath::Tan(theta) * correction ;
337 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
344 //______________________________________________________________________
345 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
346 // given the tower relative number it returns the X, Y and Z
350 // Float_t x // x of center of tower in cm
351 // Float_t y // y of center of tower in cm
352 // Float_t z // z of centre of tower in cm
356 Float_t eta,theta, phi,cylradius=0. ;
358 Int_t ieta = relid[0]; // offset along x axis
359 Int_t iphi = relid[1]; // offset along z axis.
362 index = TowerIndex(ieta,iphi);
363 EtaPhiFromIndex(index,eta,phi);
364 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
366 cylradius = GetIP2ECASection() ;
368 Double_t kDeg2Rad = TMath::DegToRad() ;
369 x = cylradius * TMath::Cos(phi * kDeg2Rad ) ;
370 y = cylradius * TMath::Sin(phi * kDeg2Rad ) ;
371 z = cylradius / TMath::Tan(theta * kDeg2Rad ) ;
376 //______________________________________________________________________
377 void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const {
378 // given the tower relative number it returns the X, Y and Z
382 // Float_t x // x of center of tower in cm
383 // Float_t y // y of center of tower in cm
384 // Float_t z // z of centre of tower in cm
388 Float_t theta, phi,cylradius=0. ;
390 PosInAlice(absid, theta, phi) ;
392 if ( IsInECA(absid) )
393 cylradius = GetIP2ECASection() ;
395 Error("XYZFromIndex", "Unexpected Tower section") ;
399 Double_t kDeg2Rad = TMath::DegToRad() ;
400 v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) );
401 v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) );
402 v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ;