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.
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() ) ;
215 //______________________________________________________________________
216 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
217 // Returns the pointer of the unique instance
219 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
222 //______________________________________________________________________
223 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
224 const Text_t* title){
225 // Returns the pointer of the unique instance
227 AliEMCALGeometry * rv = 0;
229 if ( strcmp(name,"") == 0 ) rv = 0;
231 fgGeom = new AliEMCALGeometry(name, title);
232 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
238 } // end if strcmp(name,"")
240 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
241 TString message("\n") ;
242 message += "current geometry is " ;
243 message += fgGeom->GetName() ;
244 message += "\n you cannot call " ;
246 ::Info("GetGeometry", message.Data() ) ;
248 rv = (AliEMCALGeometry *) fgGeom;
254 //______________________________________________________________________
255 Int_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.
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
266 // Int_t index // Tower index number
268 if ( (ieta <= 0 || ieta>GetNEta()) ||
269 (iphi <= 0 || iphi>GetNPhi()))
270 Fatal("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
272 return ( (iphi - 1)*GetNEta() + ieta );
275 //______________________________________________________________________
276 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
279 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
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
288 Int_t nindex = 0, itowers = GetNEta() * GetNPhi();
290 if ( IsInPRE(index) ) { // PRE index
291 nindex = index - itowers;
294 else if ( IsInECA(index) ) { // ECAL index
298 else if ( IsInHCA(index) ) { // HCAL index
299 nindex = index - 2*itowers;
303 Fatal("TowerIndexes", "Unexpected Id number!") ;
306 iphi = nindex / GetNZ() + 1 ;
308 iphi = nindex / GetNZ() ;
309 ieta = nindex - (iphi - 1) * GetNZ() ;
312 Info("TowerIndexes", "index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
317 //______________________________________________________________________
318 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
319 // given the tower index number it returns the based on the eta and phi
322 // Int_t index // Tower index number [1-i*fNZ*fNPhi] PRE(i=1)/ECAL(i=2)/HCAL(i=3)
324 // Float_t eta // eta of center of tower in pseudorapidity
325 // Float_t phi // phi of center of tower in degrees
328 Int_t ieta, iphi, ipre ;
331 TowerIndexes(index,ieta,iphi,ipre);
334 Info("EtaPhiFromIndex","index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
336 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
337 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
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].
343 //______________________________________________________________________
344 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
345 // returns the tower index number based on the eta and phi of the tower.
347 // Float_t eta // eta of center of tower in pseudorapidity
348 // Float_t phi // phi of center of tower in degrees
352 // Int_t index // Tower index number [1-fNZ*fNPhi]
356 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
358 if( ieta <= 0 || ieta > GetNEta() ) {
359 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
363 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
365 if( iphi <= 0 || iphi > GetNPhi() ) {
366 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
370 return TowerIndex(ieta,iphi);
373 //______________________________________________________________________
374 Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
375 // returns the pretower index number based on the eta and phi of the tower.
377 // Float_t eta // eta of center of tower in pseudorapidity
378 // Float_t phi // phi of center of tower in degrees
382 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
384 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
387 //______________________________________________________________________
388 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
389 // Converts the absolute numbering into the following array/
390 // relid[0] = EMCAL Arm number 1:1
391 // relid[1] = 0 ECAL section ; = 1 PRE section; = 2 HCA section
392 // relid[2] = Row number inside EMCAL
393 // relid[3] = Column number inside EMCAL
395 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
397 // Int_t *relid // array of 5. Discribed above.
399 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
401 TowerIndexes(index,ieta,iphi,ipre);
410 //______________________________________________________________________
411 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
413 // Converts the relative numbering into the local EMCAL-module (x, z)
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
421 index = TowerIndex(ieta,iphi);
422 EtaPhiFromIndex(index,eta,phi);
423 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
425 // correct for distance to IP different in PRE/ECAL/HCAL
428 d = GetIP2PRESection() - GetIPDistance() ;
430 d = GetIP2ECASection() - GetIPDistance() ;
432 d = GetIP2HCASection() - GetIPDistance() ;
434 Fatal("PosInAlice", "Unexpected tower section!") ;
436 Float_t correction = 1 + d/GetIPDistance() ;
437 Float_t tantheta = TMath::Tan(theta) * correction ;
438 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
445 //______________________________________________________________________
446 void AliEMCALGeometry::PosInAlice(const Int_t absid, Float_t &theta, Float_t &phi) const
448 // Converts the relative numbering into the local EMCAL-module (x, z)
452 AbsToRelNumbering(absid, relid) ;
453 Int_t ieta = relid[2]; // offset along x axis
454 Int_t iphi = relid[3]; // offset along z axis
458 index = TowerIndex(ieta,iphi);
459 EtaPhiFromIndex(index,eta,phi);
460 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
462 // correct for distance to IP different in PRE/ECAL/HCAL
465 d = GetIP2PRESection() - GetIPDistance() ;
466 else if (IsInECA(absid))
467 d = GetIP2ECASection() - GetIPDistance() ;
468 else if (IsInHCA(absid))
469 d = GetIP2HCASection() - GetIPDistance() ;
471 Fatal("PosInAlice", "Unexpected id # %d!", absid) ;
473 Float_t correction = 1 + d/GetIPDistance() ;
474 Float_t tantheta = TMath::Tan(theta) * correction ;
475 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
482 //______________________________________________________________________
483 void 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
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
494 Float_t eta,theta, phi,cyl_radius=0. ;
496 Int_t ieta = relid[2]; // offset along x axis
497 Int_t iphi = relid[3]; // offset along z axis
498 Int_t ipre = relid[1]; // indicates 0 ECAL section, 1 PRE section, 2 HCAL section.
501 index = TowerIndex(ieta,iphi);
502 EtaPhiFromIndex(index,eta,phi);
503 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
506 cyl_radius = GetIP2ECASection() ;
507 else if ( ipre == 1 )
508 cyl_radius = GetIP2PRESection() ;
509 else if ( ipre == 2 )
510 cyl_radius = GetIP2HCASection() ;
512 Fatal("XYZFromIndex", "Unexpected Tower section # %d", ipre) ;
514 Double_t kDeg2Rad = TMath::DegToRad() ;
515 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
516 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
517 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
522 //______________________________________________________________________
523 void AliEMCALGeometry::XYZFromIndex(const Int_t absid, TVector3 &v) const {
524 // given the tower relative number it returns the X, Y and Z
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
534 Float_t theta, phi,cyl_radius=0. ;
536 PosInAlice(absid, theta, phi) ;
538 if ( IsInECA(absid) )
539 cyl_radius = GetIP2ECASection() ;
540 else if ( IsInPRE(absid) )
541 cyl_radius = GetIP2PRESection() ;
542 else if ( IsInHCA(absid) )
543 cyl_radius = GetIP2HCASection() ;
545 Fatal("XYZFromIndex", "Unexpected Tower section") ;
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 ) ) ;
555 //______________________________________________________________________
557 Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
558 // Returns kTRUE if the two towers are neighbours or not, including
559 // diagonals. Both indexes are required to be either towers or preshower.
561 // Int_t index1 // index of tower 1
562 // Int_t index2 // index of tower 2
566 // Boot_t kTRUE if the towers are neighbours otherwise false.
568 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
570 TowerIndexes(index1,ieta1,iphi1,ipre1);
571 TowerIndexes(index2,ieta2,iphi2,ipre2);
572 if(ipre1!=ipre2) return anb;
573 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))