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 // --- ROOT system ---
34 // --- Standard library ---
37 // --- AliRoot header files ---
46 #include "AliEMCALGeometry.h"
48 ClassImp(AliEMCALGeometry);
50 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
51 Bool_t AliEMCALGeometry::fgInit = kFALSE;
53 //______________________________________________________________________
54 AliEMCALGeometry::~AliEMCALGeometry(void){
58 //______________________________________________________________________
59 const 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 ) )
69 //______________________________________________________________________
70 void 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
83 fgInit = kFALSE; // Assume failer untill proven otherwise.
84 TString name(GetName()) ;
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
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
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
100 fSummationFraction = 0.8 ;
102 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
103 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
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
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
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
119 fSummationFraction = 0.8 ;
121 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
122 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
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
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
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
138 fSummationFraction = 0.8 ;
140 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
141 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
144 Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
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()) ;
154 // if ( name == "EMCALArch1a" ||
155 // name == "EMCALArch1b" ||
156 // name == "EMCALArch1aN") {
160 // if ( name == "EMCALArch2a" ||
161 // name == "EMCALArch2b" ) {
165 // if ( name == "EMCALArch1a" ||
166 // name == "EMCALArch2a" ) {
171 // if ( name == "EMCALArch1b" ||
172 // name == "EMCALArch2b" ) {
177 // if ( name == "EMCALArch1aN") {
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
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.
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() ) ;
213 //______________________________________________________________________
214 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
215 // Returns the pointer of the unique instance
217 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
220 //______________________________________________________________________
221 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
222 const Text_t* title){
223 // Returns the pointer of the unique instance
225 AliEMCALGeometry * rv = 0;
227 if ( strcmp(name,"") == 0 ) rv = 0;
229 fgGeom = new AliEMCALGeometry(name, title);
230 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
236 } // end if strcmp(name,"")
238 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
239 TString message("\n") ;
240 message += "current geometry is " ;
241 message += fgGeom->GetName() ;
242 message += "\n you cannot call " ;
244 ::Info("GetGeometry", message.Data() ) ;
246 rv = (AliEMCALGeometry *) fgGeom;
252 //______________________________________________________________________
253 Int_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.
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
264 // Int_t index // Tower index number
266 if ( (ieta <= 0 || ieta>GetNEta()) ||
267 (iphi <= 0 || iphi>GetNPhi()))
268 Fatal("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
270 return ( (iphi - 1)*GetNEta() + ieta );
273 //______________________________________________________________________
274 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
277 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
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
286 Int_t nindex = 0, itowers = GetNEta() * GetNPhi();
288 if ( IsInPRE(index) ) { // PRE index
289 nindex = index - itowers;
292 else if ( IsInECAL(index) ) { // ECAL index
296 else if ( IsInHCAL(index) ) { // HCAL index
297 nindex = index - 2*itowers;
301 Fatal("TowerIndexes", "Unexpected Id number!") ;
304 iphi = nindex / GetNZ() + 1 ;
306 iphi = nindex / GetNZ() ;
307 ieta = nindex - (iphi - 1) * GetNZ() ;
310 Info("TowerIndexes", "index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
315 //______________________________________________________________________
316 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
317 // given the tower index number it returns the based on the eta and phi
320 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
322 // Float_t eta // eta of center of tower in pseudorapidity
323 // Float_t phi // phi of center of tower in degrees
326 Int_t ieta, iphi, ipre ;
329 TowerIndexes(index,ieta,iphi,ipre);
332 Info("EtaPhiFromIndex","index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
334 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
335 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
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].
341 //______________________________________________________________________
342 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
343 // returns the tower index number based on the eta and phi of the tower.
345 // Float_t eta // eta of center of tower in pseudorapidity
346 // Float_t phi // phi of center of tower in degrees
350 // Int_t index // Tower index number [1-fNZ*fNPhi]
354 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
356 if( ieta <= 0 || ieta > GetNEta() ) {
357 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
361 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
363 if( iphi <= 0 || iphi > GetNPhi() ) {
364 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
368 return TowerIndex(ieta,iphi);
371 //______________________________________________________________________
372 Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
373 // returns the pretower index number based on the eta and phi of the tower.
375 // Float_t eta // eta of center of tower in pseudorapidity
376 // Float_t phi // phi of center of tower in degrees
380 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
382 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
385 //______________________________________________________________________
386 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
387 // Converts the absolute numbering into the following array/
388 // relid[0] = EMCAL Arm number 1:1
389 // relid[1] = 0 ECAL section ; = 1 PRE section; = 2 HCA section
390 // relid[2] = Row number inside EMCAL
391 // relid[3] = Column number inside EMCAL
393 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
395 // Int_t *relid // array of 5. Discribed above.
397 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
399 TowerIndexes(index,ieta,iphi,ipre);
408 //______________________________________________________________________
409 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
411 // Converts the relative numbering into the local EMCAL-module (x, z)
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
419 index = TowerIndex(ieta,iphi);
420 EtaPhiFromIndex(index,eta,phi);
421 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
423 // correct for distance to IP different in PRE/ECAL/HCAL
426 d = GetIP2PRESection() - GetIPDistance() ;
428 d = GetIP2ECALSection() - GetIPDistance() ;
430 d = GetIP2HCALSection() - GetIPDistance() ;
432 Fatal("PosInAlice", "Unexpected tower section!") ;
434 Float_t correction = 1 + d/GetIPDistance() ;
435 Float_t tantheta = TMath::Tan(theta) * correction ;
436 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
443 //______________________________________________________________________
444 void AliEMCALGeometry::PosInAlice(const Int_t absid, Float_t &theta, Float_t &phi) const
446 // Converts the relative numbering into the local EMCAL-module (x, z)
450 AbsToRelNumbering(absid, relid) ;
451 Int_t ieta = relid[2]; // offset along x axis
452 Int_t iphi = relid[3]; // offset along z axis
456 index = TowerIndex(ieta,iphi);
457 EtaPhiFromIndex(index,eta,phi);
458 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
460 // correct for distance to IP different in PRE/ECAL/HCAL
463 d = GetIP2PRESection() - GetIPDistance() ;
464 else if (IsInECAL(absid))
465 d = GetIP2ECALSection() - GetIPDistance() ;
466 else if (IsInHCAL(absid))
467 d = GetIP2HCALSection() - GetIPDistance() ;
469 Fatal("PosInAlice", "Unexpected id # %d!", absid) ;
471 Float_t correction = 1 + d/GetIPDistance() ;
472 Float_t tantheta = TMath::Tan(theta) * correction ;
473 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
480 //______________________________________________________________________
481 void 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
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
492 Float_t eta,theta, phi,cyl_radius=0. ;
494 Int_t ieta = relid[2]; // offset along x axis
495 Int_t iphi = relid[3]; // offset along z axis
496 Int_t ipre = relid[1]; // indicates 0 ECAL section, 1 PRE section, 2 HCAL section.
499 index = TowerIndex(ieta,iphi);
500 EtaPhiFromIndex(index,eta,phi);
501 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
504 cyl_radius = GetIP2ECALSection() ;
505 else if ( ipre == 1 )
506 cyl_radius = GetIP2PRESection() ;
507 else if ( ipre == 2 )
508 cyl_radius = GetIP2HCALSection() ;
510 Fatal("XYZFromIndex", "Unexpected Tower section # %d", ipre) ;
512 Double_t kDeg2Rad = TMath::DegToRad() ;
513 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
514 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
515 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
520 //______________________________________________________________________
521 void AliEMCALGeometry::XYZFromIndex(const Int_t absid, TVector3 &v) const {
522 // given the tower relative number it returns the X, Y and Z
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
532 Float_t theta, phi,cyl_radius=0. ;
534 PosInAlice(absid, theta, phi) ;
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() ;
543 Fatal("XYZFromIndex", "Unexpected Tower section") ;
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 ) ) ;
553 //______________________________________________________________________
555 Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
556 // Returns kTRUE if the two towers are neighbours or not, including
557 // diagonals. Both indexes are required to be either towers or preshower.
559 // Int_t index1 // index of tower 1
560 // Int_t index2 // index of tower 2
564 // Boot_t kTRUE if the towers are neighbours otherwise false.
566 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
568 TowerIndexes(index1,ieta1,iphi1,ipre1);
569 TowerIndexes(index2,ieta2,iphi2,ipre2);
570 if(ipre1!=ipre2) return anb;
571 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))