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 ---
44 #include "AliEMCALGeometry.h"
46 ClassImp(AliEMCALGeometry);
48 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
49 Bool_t AliEMCALGeometry::fgInit = kFALSE;
51 //______________________________________________________________________
52 AliEMCALGeometry::~AliEMCALGeometry(void){
56 //______________________________________________________________________
57 const Bool_t AliEMCALGeometry::AreInSameTower(Int_t id1, Int_t id2) const {
58 Int_t idmax = TMath::Max(id1, id2) ;
59 Int_t idmin = TMath::Min(id1, id2) ;
60 if ( ((idmax - GetNZ() * GetNPhi()) == idmin ) ||
61 ((idmax - 2 * GetNZ() * GetNPhi()) == idmin ) )
67 //______________________________________________________________________
68 void AliEMCALGeometry::Init(void){
69 // Initializes the EMCAL parameters
70 // naming convention : GUV_L_WX_N_YZ_M gives the composition of a tower
71 // UV inform about the compsition of the pre-shower section:
72 // thickness in mm of Pb radiator (U) and of scintillator (V), and number of scintillator layers (L)
73 // WX inform about the composition of the EM calorimeter section:
74 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
75 // YZ inform about the composition of the hadron calorimeter section:
76 // thickness in mm of Cu radiator (Y) and of scintillator (Z), and number of scintillator layers (M)
77 // Valid geometries are G56_2_55_19_104_14
78 // G56_2_55_19 or EMCAL_5655_21
79 // G65_2_64_19 or EMCAL_6564_21
81 fgInit = kFALSE; // Assume failer untill proven otherwise.
82 TString name(GetName()) ;
84 if ( name == "G56_2_55_19_104_14" ) {
85 fPRPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the preshower section
86 fPRScintThick = 0.6; // cm, Thickness of the sintilator for the preshower section of the tower
87 fNPRLayers = 2; // number of scintillator layers in the preshower section
89 fECPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the EM calorimeter section
90 fECScintThick = 0.5; // cm, Thickness of the sintilator for the EM alorimeter section of the tower
91 fNECLayers = 19; // number of scintillator layers in the EM calorimeter section
93 fHCCuRadThickness = 1.0; // cm, Thickness of the Cu radiators.
94 fHCScintThick = 0.4; // cm, Thickness of the sintilator for the hadronic alorimeter section of the tower
95 fNHCLayers = 14; // number of scintillator layers in the hadronic calorimeter section
98 fSummationFraction = 0.8 ;
100 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
101 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
103 else if ( name == "G56_2_55_19" || name == "EMCAL_5655_21" ) {
104 fPRPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the preshower section
105 fPRScintThick = 0.6; // cm, Thickness of the sintilator for the preshower section of the tower
106 fNPRLayers = 2; // number of scintillator layers in the preshower section
108 fECPbRadThickness = 0.5; // cm, Thickness of the Pb radiators for the EM calorimeter section
109 fECScintThick = 0.5; // cm, Thickness of the sintilator for the EM alorimeter section of the tower
110 fNECLayers = 19; // number of scintillator layers in the EM calorimeter section
112 fHCCuRadThickness = 0.0; // cm, Thickness of the Cu radiators.
113 fHCScintThick = 0.0; // cm, Thickness of the sintilator for the hadronic alorimeter section of the tower
114 fNHCLayers = 0; // number of scintillator layers in the hadronic calorimeter section
117 fSummationFraction = 0.8 ;
119 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
120 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
122 else if ( name == "G65_2_64_19" || name == "EMCAL_6564_21" ) {
123 fPRPbRadThickness = 0.6; // cm, Thickness of the Pb radiators for the preshower section
124 fPRScintThick = 0.5; // cm, Thickness of the sintilator for the preshower section of the tower
125 fNPRLayers = 2; // number of scintillator layers in the preshower section
127 fECPbRadThickness = 0.6; // cm, Thickness of the Pb radiators for the EM calorimeter section
128 fECScintThick = 0.4; // cm, Thickness of the sintilator for the EM alorimeter section of the tower
129 fNECLayers = 19; // number of scintillator layers in the EM calorimeter section
131 fHCCuRadThickness = 0.0; // cm, Thickness of the Cu radiators.
132 fHCScintThick = 0.0; // cm, Thickness of the sintilator for the hadronic alorimeter section of the tower
133 fNHCLayers = 0; // number of scintillator layers in the hadronic calorimeter section
136 fSummationFraction = 0.8 ;
138 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
139 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
142 Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
144 // if( name != "EMCALArch1a" &&
145 // name != "EMCALArch1b" &&
146 // name != "EMCALArch2a" &&
147 // name != "EMCALArch2b" &&
148 // name != "EMCALArch1aN" ){
149 // Fatal("Init", "%s is not a known geometry (choose among EMCALArch1a, EMCALArch1b, EMCALArch2a and EMCALArch2b, EMCALArch1aN)", name.Data()) ;
152 // if ( name == "EMCALArch1a" ||
153 // name == "EMCALArch1b" ||
154 // name == "EMCALArch1aN") {
158 // if ( name == "EMCALArch2a" ||
159 // name == "EMCALArch2b" ) {
163 // if ( name == "EMCALArch1a" ||
164 // name == "EMCALArch2a" ) {
169 // if ( name == "EMCALArch1b" ||
170 // name == "EMCALArch2b" ) {
175 // if ( name == "EMCALArch1aN") {
182 fNZ = 96; // granularity along Z (eta)
183 fNPhi = 144; // granularity in phi (azimuth)
184 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
185 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
186 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
187 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
189 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
190 fShellThickness = fAlFrontThick + fGap2Active + 2.*(GetPRScintThick() + GetPRPbRadThick()) + // pre shower
191 (fNECLayers-1)*(GetECScintThick()+ GetECPbRadThick()) + // E cal -1 because the last element is a scintillator
192 fNHCLayers*(GetHCScintThick()+ GetHCCuRadThick()) + // H cal
193 GetHCScintThick() ; // last scintillator
194 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
195 fEnvelop[0] = fIPDistance; // mother volume inner radius
196 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
197 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
201 Info("Init", "geometry of EMCAL named %s is as follows:", name.Data());
202 printf( "Tower geometry pre-shower: %d x (%f mm Pb, %f mm Sc) \n", GetNPRLayers(), GetPRPbRadThick(), GetPRScintThick() ) ;
203 printf( " ECAL : %d x (%f mm Pb, %f mm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
204 if ( GetNHCLayers() > 0 )
205 printf( " HCAL : %d x (%f mm Pb, %f mm Sc) \n", GetNHCLayers(), GetHCCuRadThick(), GetHCScintThick() ) ;
206 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
207 printf("Layout: phi = (%f, %f), eta = (%f, %f), y = %f\n",
208 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() ) ;
211 //______________________________________________________________________
212 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
213 // Returns the pointer of the unique instance
215 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
218 //______________________________________________________________________
219 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
220 const Text_t* title){
221 // Returns the pointer of the unique instance
223 AliEMCALGeometry * rv = 0;
225 if ( strcmp(name,"") == 0 ) rv = 0;
227 fgGeom = new AliEMCALGeometry(name, title);
228 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
234 } // end if strcmp(name,"")
236 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
237 TString message("\n") ;
238 message += "current geometry is " ;
239 message += fgGeom->GetName() ;
240 message += "\n you cannot call " ;
242 ::Info("GetGeometry", message.Data() ) ;
244 rv = (AliEMCALGeometry *) fgGeom;
250 //______________________________________________________________________
251 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
252 // Returns the tower index number from the based on the Z and Phi
253 // index numbers. There are 2 times the number of towers to separate
254 // out the full towers from the pre-showers.
256 // Int_t ieta // index allong z axis [1-fNZ]
257 // Int_t iphi // index allong phi axis [1-fNPhi]
258 // Int_t where // 1 = PRE section, 0 = EC section, 2 = HC section
262 // Int_t index // Tower index number
264 if ( (ieta <= 0 || ieta>GetNEta()) ||
265 (iphi <= 0 || iphi>GetNPhi()))
266 Fatal("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
268 return ( (iphi - 1)*GetNEta() + ieta );
271 //______________________________________________________________________
272 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
275 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
277 // Int_t ieta // index allong z axis [1-fNZ]
278 // Int_t iphi // index allong phi axis [1-fNPhi]
279 // Int_t ipre // 0 = ECAL section, 1 = Pre-shower section, 2 = HCAL section
284 Int_t nindex = 0, itowers = GetNEta() * GetNPhi();
286 if ( IsInPRE(index) ) { // PRE index
287 nindex = index - itowers;
290 else if ( IsInECAL(index) ) { // ECAL index
294 else if ( IsInHCAL(index) ) { // HCAL index
295 nindex = index - 2*itowers;
299 Fatal("TowerIndexes", "Unexpected Id number!") ;
302 iphi = nindex / GetNZ() + 1 ;
304 iphi = nindex / GetNZ() ;
305 ieta = nindex - (iphi - 1) * GetNZ() ;
308 Info("TowerIndexes", "index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
313 //______________________________________________________________________
314 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
315 // given the tower index number it returns the based on the eta and phi
318 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
320 // Float_t eta // eta of center of tower in pseudorapidity
321 // Float_t phi // phi of center of tower in degrees
324 Int_t ieta, iphi, ipre ;
327 TowerIndexes(index,ieta,iphi,ipre);
330 Info("EtaPhiFromIndex","index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
332 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
333 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
335 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
336 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
339 //______________________________________________________________________
340 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
341 // returns the tower index number based on the eta and phi of the tower.
343 // Float_t eta // eta of center of tower in pseudorapidity
344 // Float_t phi // phi of center of tower in degrees
348 // Int_t index // Tower index number [1-fNZ*fNPhi]
352 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
354 if( ieta <= 0 || ieta > GetNEta() ) {
355 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
359 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
361 if( iphi <= 0 || iphi > GetNPhi() ) {
362 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
366 return TowerIndex(ieta,iphi);
369 //______________________________________________________________________
370 Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
371 // returns the pretower index number based on the eta and phi of the tower.
373 // Float_t eta // eta of center of tower in pseudorapidity
374 // Float_t phi // phi of center of tower in degrees
378 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
380 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
383 //______________________________________________________________________
384 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
385 // Converts the absolute numbering into the following array/
386 // relid[0] = EMCAL Arm number 1:1
387 // relid[1] = 0 ECAL section ; = 1 PRE section; = 2 HCA section
388 // relid[2] = Row number inside EMCAL
389 // relid[3] = Column number inside EMCAL
391 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
393 // Int_t *relid // array of 5. Discribed above.
395 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
397 TowerIndexes(index,ieta,iphi,ipre);
406 //______________________________________________________________________
407 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
409 // Converts the relative numbering into the local EMCAL-module (x, z)
411 Int_t sect = relid[1]; // PRE/ECAL/HCAL section 1/0/2
412 Int_t ieta = relid[2]; // offset along x axis
413 Int_t iphi = relid[3]; // offset along z axis
417 index = TowerIndex(ieta,iphi);
418 EtaPhiFromIndex(index,eta,phi);
419 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
421 // correct for distance to IP different in PRE/ECAL/HCAL
424 d = GetIP2PRESection() - GetIPDistance() ;
426 d = GetIP2ECALSection() - GetIPDistance() ;
428 d = GetIP2HCALSection() - GetIPDistance() ;
430 Fatal("PosInAlice", "Unexpected tower section!") ;
432 Float_t correction = 1 + d/GetIPDistance() ;
433 Float_t tantheta = TMath::Tan(theta) * correction ;
434 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
441 //______________________________________________________________________
442 void AliEMCALGeometry::PosInAlice(const Int_t absid, Float_t &theta, Float_t &phi) const
444 // Converts the relative numbering into the local EMCAL-module (x, z)
448 AbsToRelNumbering(absid, relid) ;
449 Int_t ieta = relid[2]; // offset along x axis
450 Int_t iphi = relid[3]; // offset along z axis
454 index = TowerIndex(ieta,iphi);
455 EtaPhiFromIndex(index,eta,phi);
456 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
458 // correct for distance to IP different in PRE/ECAL/HCAL
461 d = GetIP2PRESection() - GetIPDistance() ;
462 else if (IsInECAL(absid))
463 d = GetIP2ECALSection() - GetIPDistance() ;
464 else if (IsInHCAL(absid))
465 d = GetIP2HCALSection() - GetIPDistance() ;
467 Fatal("PosInAlice", "Unexpected id # %d!", absid) ;
469 Float_t correction = 1 + d/GetIPDistance() ;
470 Float_t tantheta = TMath::Tan(theta) * correction ;
471 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
478 //______________________________________________________________________
479 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
480 // given the tower relative number it returns the X, Y and Z
484 // Float_t x // x of center of tower in cm
485 // Float_t y // y of center of tower in cm
486 // Float_t z // z of centre of tower in cm
490 Float_t eta,theta, phi,cyl_radius=0. ;
492 Int_t ieta = relid[2]; // offset along x axis
493 Int_t iphi = relid[3]; // offset along z axis
494 Int_t ipre = relid[1]; // indicates 0 ECAL section, 1 PRE section, 2 HCAL section.
497 index = TowerIndex(ieta,iphi);
498 EtaPhiFromIndex(index,eta,phi);
499 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
502 cyl_radius = GetIP2ECALSection() ;
503 else if ( ipre == 1 )
504 cyl_radius = GetIP2PRESection() ;
505 else if ( ipre == 2 )
506 cyl_radius = GetIP2HCALSection() ;
508 Fatal("XYZFromIndex", "Unexpected Tower section # %d", ipre) ;
510 Double_t kDeg2Rad = TMath::DegToRad() ;
511 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
512 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
513 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
518 //______________________________________________________________________
519 void AliEMCALGeometry::XYZFromIndex(const Int_t absid, TVector3 &v) const {
520 // given the tower relative number it returns the X, Y and Z
524 // Float_t x // x of center of tower in cm
525 // Float_t y // y of center of tower in cm
526 // Float_t z // z of centre of tower in cm
530 Float_t theta, phi,cyl_radius=0. ;
532 PosInAlice(absid, theta, phi) ;
534 if ( IsInECAL(absid) )
535 cyl_radius = GetIP2ECALSection() ;
536 else if ( IsInPRE(absid) )
537 cyl_radius = GetIP2PRESection() ;
538 else if ( IsInHCAL(absid) )
539 cyl_radius = GetIP2HCALSection() ;
541 Fatal("XYZFromIndex", "Unexpected Tower section") ;
543 Double_t kDeg2Rad = TMath::DegToRad() ;
544 v.SetX(cyl_radius * TMath::Cos(phi * kDeg2Rad ) );
545 v.SetY(cyl_radius * TMath::Sin(phi * kDeg2Rad ) );
546 v.SetZ(cyl_radius / TMath::Tan(theta * kDeg2Rad ) ) ;
551 //______________________________________________________________________
553 Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
554 // Returns kTRUE if the two towers are neighbours or not, including
555 // diagonals. Both indexes are required to be either towers or preshower.
557 // Int_t index1 // index of tower 1
558 // Int_t index2 // index of tower 2
562 // Boot_t kTRUE if the towers are neighbours otherwise false.
564 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
566 TowerIndexes(index1,ieta1,iphi1,ipre1);
567 TowerIndexes(index2,ieta2,iphi2,ipre2);
568 if(ipre1!=ipre2) return anb;
569 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))