1 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * Author: The ALICE Off-line Project. *
9 * Contributors are mentioned in the code where appropriate. *
13 * Permission to use, copy, modify and distribute this software and its *
15 * documentation strictly for non-commercial purposes is hereby granted *
17 * without fee, provided that the above copyright notice appears in all *
19 * copies and that both the copyright notice and this permission notice *
21 * appear in the supporting documentation. The authors make no claims *
23 * about the suitability of this software for any purpose. It is *
25 * provided "as is" without express or implied warranty. *
27 **************************************************************************/
35 //_________________________________________________________________________
37 // Geometry class for EMCAL : singleton
39 // EMCAL consists of layers of scintillator and lead
41 // Places the the Barrel Geometry of The EMCAL at Midrapidity
43 // between 0 and 120 degrees of Phi and
47 // Number of Modules and Layers may be controlled by
49 // the name of the instance defined
51 // EMCALArch2x has more modules along both phi and eta
53 // EMCALArchxa has less Layers in the Radial Direction
55 //*-- Author: Sahal Yacoob (LBL / UCT)
57 // and : Yves Schutz (SUBATECH)
59 // and : Jennifer Klay (LBL)
63 // --- ROOT system ---
67 // --- Standard library ---
75 // --- AliRoot header files ---
85 #include "AliEMCALGeometry.h"
89 ClassImp(AliEMCALGeometry);
93 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
95 Bool_t AliEMCALGeometry::fgInit = kFALSE;
99 //______________________________________________________________________
101 AliEMCALGeometry::~AliEMCALGeometry(void){
107 //______________________________________________________________________
109 void AliEMCALGeometry::Init(void){
111 // Initializes the EMCAL parameters
115 fgInit = kFALSE; // Assume failer untill proven otherwise.
119 TString name(GetName()) ;
123 if( name != "EMCALArch1a" &&
125 name != "EMCALArch1b" &&
127 name != "EMCALArch2a" &&
129 name != "EMCALArch2b" ){
131 cerr << "ERROR: " << ClassName() << "::Init -> " << name.Data()
133 << " is not a known geometry (choose among EMCALArch1a, EMCALArch1b, EMCALArch2a and EMCALArch2b)"
143 if ( name == "EMCALArch1a" ||
145 name == "EMCALArch1b" ) {
153 if ( name == "EMCALArch2a" ||
155 name, "EMCALArch2b" ) {
163 if ( name == "EMCALArch1a" ||
165 name == "EMCALArch2a" ) {
171 if ( name == "EMCALArch1b" ||
173 name == "EMCALArch2b" ) {
183 fAirGap = 5.0; // cm, air gap between EMCAL mother volume and
187 fAlFrontThick = 3.18; // cm, Thickness of front Al layer
189 fPbRadThickness = 0.5; // cm, Thickness of theh Pb radiators.
191 fPreShowerSintThick = 0.6; // cm, Thickness of the sintilator for the
193 // preshower part of the calorimeter
195 fFullShowerSintThick = 0.5; // cm, Thickness of the sintilator for the
197 // full shower part of the calorimeter
199 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
201 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
203 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
205 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
207 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
209 fShellThickness = GetAlFrontThickness() + 2.*GetPreSintThick() +
211 (fNLayers-2)*GetFullSintThick()+(fNLayers-1)*GetPbRadThick();
213 //below; cm, Z lenght of the EMCAL.
215 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax);
217 fEnvelop[0] = fIPDistance; // mother volume inner radius
219 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
221 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
223 fGap2Active = 1.0; // cm, Gap between
229 //______________________________________________________________________
231 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
233 // Returns the pointer of the unique instance
237 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
241 //______________________________________________________________________
243 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
245 const Text_t* title){
247 // Returns the pointer of the unique instance
251 AliEMCALGeometry * rv = 0;
255 if ( strcmp(name,"") == 0 ) rv = 0;
259 fgGeom = new AliEMCALGeometry(name, title);
261 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
273 } // end if strcmp(name,"")
277 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
279 cout << "AliEMCALGeometry <E> : current geometry is "
281 << fgGeom->GetName() << endl
283 << " you cannot call " << name
289 rv = (AliEMCALGeometry *) fgGeom;
299 //______________________________________________________________________
301 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi,Int_t ipre) const {
303 // Returns the tower index number from the based on the Z and Phi
305 // index numbers. There are 2 times the number of towers to separate
307 // out the full towsers from the pre-towsers.
311 // Int_t ieta // index allong z axis [1-fNZ]
313 // Int_t iphi // index allong phi axis [1-fNPhi]
315 // Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
323 // Int_t the absoulute tower index. [1-2*fNZ*fNPhi]
329 if((ieta<=0 || ieta>GetNEta()) || (iphi<=0 || iphi>GetNPhi()) ||
331 (ipre<0 || ipre>1) ){
333 cout << "inputs out of range ieta=" << ieta << " [1-" << GetNEta();
335 cout << "] iphi=" << iphi << " [1-" << GetNPhi() << "] ipre=";
337 cout << ipre << "[0,1]. returning -1" << endl;
343 index = iphi + GetNPhi()*(ieta-1) + ipre*(GetNPhi()*GetNEta());
349 //______________________________________________________________________
351 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
355 // given the tower index number it returns the based on the Z and Phi
357 // index numbers and if it is for the full tower or the pre-tower number.
359 // There are 2 times the number of towers to separate
361 // out the full towsers from the pre-towsers.
365 // Int_t index // Tower index number [1-2*fNZ*fNPhi]
369 // Int_t ieta // index allong z axis [1-fNZ]
371 // Int_t iphi // index allong phi axis [1-fNPhi]
373 // Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
383 itowers = GetNEta()*GetNPhi();
385 if(index<1 || index>2*itowers){
387 cout << "index=" << index <<" is out of range [1-";
389 cout << 2*itowers << "], returning -1 for all." << endl;
391 ieta = -1; iphi = -1; ipre = -1;
399 if(index>itowers){ // pre shower indexs
403 index = index - itowers;
407 ieta = 1+ (Int_t)((index-1)/GetNPhi());
409 iphi = index - GetNPhi()*(ieta-1);
415 //______________________________________________________________________
417 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
419 // given the tower index number it returns the based on the eta and phi
425 // Int_t index // Tower index number [1-2*fNZ*fNPhi]
429 // Float_t eta // eta of center of tower in pseudorapidity
431 // Float_t phi // phi of center of tower in degrees
437 Int_t ieta,iphi,ipre;
439 Double_t deta,dphi,phid;
443 TowerIndexes(index,ieta,iphi,ipre);
445 deta = (GetArm1EtaMax()-GetArm1EtaMin())/((Float_t)GetNEta());
447 eta = GetArm1EtaMin() + (((Float_t)ieta)-0.5)*deta;
449 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/((Float_t)GetNPhi()); // in degrees.
451 phid = GetArm1PhiMin() + dphi*((Float_t)iphi -0.5);//iphi range [1-fNphi].
457 //______________________________________________________________________
459 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
461 // returns the tower index number based on the eta and phi of the tower.
465 // Float_t eta // eta of center of tower in pseudorapidity
467 // Float_t phi // phi of center of tower in degrees
475 // Int_t index // Tower index number [1-fNZ*fNPhi]
481 ieta = 1 + (Int_t)(((Float_t)GetNEta())*(eta-GetArm1EtaMin())/
483 (GetArm1EtaMax() - GetArm1EtaMin()));
485 if(ieta<=0 || ieta>GetNEta()){
487 cout << "TowerIndexFromEtaPhi:";
489 cout << "ieta = "<< ieta << " eta=" << eta << " is outside of EMCAL. etamin=";
491 cout << GetArm1EtaMin() << " to etamax=" << GetArm1EtaMax();
493 cout << " returning -1" << endl;
499 iphi = 1 + (Int_t)(((Float_t)GetNPhi())*(phi-GetArm1PhiMin())/
501 ((Float_t)(GetArm1PhiMax() - GetArm1PhiMin())));
503 if(iphi<=0 || iphi>GetNPhi()){
505 cout << "TowerIndexFromEtaPhi:";
507 cout << "iphi=" << iphi << " phi=" << phi << " is outside of EMCAL.";
509 cout << " Phimin=" << GetArm1PhiMin() << " PhiMax=" << GetArm1PhiMax();
511 cout << " returning -1" << endl;
517 return TowerIndex(ieta,iphi,0);
521 //______________________________________________________________________
523 Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
525 // returns the pretower index number based on the eta and phi of the tower.
529 // Float_t eta // eta of center of tower in pseudorapidity
531 // Float_t phi // phi of center of tower in degrees
539 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
543 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
547 //______________________________________________________________________
549 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
551 // Converts the absolute numbering into the following array/
553 // relid[0] = EMCAL Arm number 1:1
555 // relid[1] = 0 Not in Pre Shower layers
557 // = -1 In Pre Shower
559 // relid[2] = Row number inside EMCAL
561 // relid[3] = Column number inside EMCAL
565 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
569 // Int_t *relid // array of 5. Discribed above.
573 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
577 TowerIndexes(index,ieta,iphi,ipre);
597 //______________________________________________________________________
599 void AliEMCALGeometry::PosInAlice(const Int_t *relid,Float_t &theta,
601 Float_t &phi) const {
603 // Converts the relative numbering into the local EMCAL-module (x, z)
607 Int_t ieta = relid[2]; // offset along x axis
609 Int_t iphi = relid[3]; // offset along z axis
611 Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
619 if(ipre==-1) ipre = 1;
621 index = TowerIndex(ieta,iphi,ipre);
623 EtaPhiFromIndex(index,eta,phi);
625 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
635 //______________________________________________________________________
637 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
639 // given the tower relative number it returns the X, Y and Z
647 // Float_t x // x of center of tower in cm
649 // Float_t y // y of center of tower in cm
651 // Float_t z // z of centre of tower in cm
659 Float_t eta,theta, phi,cyl_radius,kDeg2Rad;
663 Int_t ieta = relid[2]; // offset along x axis
665 Int_t iphi = relid[3]; // offset along z axis
667 Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
675 if(ipre==-1) ipre = 1;
677 index = TowerIndex(ieta,iphi,ipre);
679 EtaPhiFromIndex(index,eta,phi);
681 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
689 kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ;
691 cyl_radius = GetIPDistance()+ GetAirGap() ;
693 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
695 y = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
697 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
707 //______________________________________________________________________
711 Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
713 // Returns kTRUE if the two towers are neighbours or not, including
715 // diagonals. Both indexes are required to be either towers or preshower.
719 // Int_t index1 // index of tower 1
721 // Int_t index2 // index of tower 2
729 // Boot_t kTRUE if the towers are neighbours otherwise false.
733 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
737 TowerIndexes(index1,ieta1,iphi1,ipre1);
739 TowerIndexes(index2,ieta2,iphi2,ipre2);
741 if(ipre1!=ipre2) return anb;
743 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))