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){
55 //______________________________________________________________________
56 void AliEMCALGeometry::Init(void){
57 // Initializes the EMCAL parameters
59 fgInit = kFALSE; // Assume failer untill proven otherwise.
61 TString name(GetName()) ;
63 if( name != "EMCALArch1a" &&
64 name != "EMCALArch1b" &&
65 name != "EMCALArch2a" &&
66 name != "EMCALArch2b" &&
67 name != "EMCALArch1aN" ){
68 Fatal("Init", "%s is not a known geometry (choose among EMCALArch1a, EMCALArch1b, EMCALArch2a and EMCALArch2b, EMCALArch1aN)", name.Data()) ;
71 if ( name == "EMCALArch1a" ||
72 name == "EMCALArch1b" ||
73 name == "EMCALArch1aN") {
77 if ( name == "EMCALArch2a" ||
78 name == "EMCALArch2b" ) {
82 if ( name == "EMCALArch1a" ||
83 name == "EMCALArch2a" ) {
88 if ( name == "EMCALArch1b" ||
89 name == "EMCALArch2b" ) {
94 if ( name == "EMCALArch1aN") {
101 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
102 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
103 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
104 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
106 fAlFrontThick = 3.18; // cm, Thickness of front Al layer
107 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
108 fPbRadThickness = 0.5; // cm, Thickness of the Pb radiators.
109 fPreShowerSintThick = 0.6; // cm, Thickness of the sintilator for the preshower part of the calorimeter
110 fFullShowerSintThick = 0.5; // cm, Thickness of the sintilator for the dull shower part of the calorimeter
111 fCuRadThickness = 0.0; // cm, Thickness of the Cu radiators.
113 if (name == "EMCALArch1aN") {
114 fAlFrontThick = 3.0; // cm, Thickness of front Al layer
115 fGap2Active = 1.0; // cm, Gap between Al and 1st Scintillator
116 fPbRadThickness = 0.6; // cm, Thickness of the Pb radiators.
117 fPreShowerSintThick = 0.5; // cm, Thickness of the sintilator for the preshower part of the calorimeter
118 fFullShowerSintThick = 0.4; // cm, Thickness of the sintilator for the full shower part of the calorimeter
119 fCuRadThickness = 1.0; // cm, Thickness of the Cu radiators.
122 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
123 fShellThickness = fAlFrontThick + fGap2Active + 2.*(GetPreSintThick() + GetPbRadThick()) + // pre shower
124 (fNECLayers-1)*(GetFullSintThick()+ GetPbRadThick()) + // E cal -1 because the last element is a scintillator
125 fNHCLayers*(GetFullSintThick()+ GetCuRadThick()) + // H cal
126 GetFullSintThick() ; // last scintillator
127 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
128 fEnvelop[0] = fIPDistance; // mother volume inner radius
129 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
130 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
134 //______________________________________________________________________
135 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
136 // Returns the pointer of the unique instance
138 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
141 //______________________________________________________________________
142 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
143 const Text_t* title){
144 // Returns the pointer of the unique instance
146 AliEMCALGeometry * rv = 0;
148 if ( strcmp(name,"") == 0 ) rv = 0;
150 fgGeom = new AliEMCALGeometry(name, title);
151 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
157 } // end if strcmp(name,"")
159 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
160 TString message("\n") ;
161 message += "current geometry is " ;
162 message += fgGeom->GetName() ;
163 message += "\n you cannot call " ;
165 ::Info("GetGeometry", message.Data() ) ;
167 rv = (AliEMCALGeometry *) fgGeom;
173 //______________________________________________________________________
174 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi,Int_t ipre) const {
175 // Returns the tower index number from the based on the Z and Phi
176 // index numbers. There are 2 times the number of towers to separate
177 // out the full towers from the pre-showers.
179 // Int_t ieta // index allong z axis [1-fNZ]
180 // Int_t iphi // index allong phi axis [1-fNPhi]
181 // Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
185 // Int_t the absoulute tower index. [1-2*fNZ*fNPhi]
188 if((ieta<=0 || ieta>GetNEta()) || (iphi<=0 || iphi>GetNPhi()) ||
189 (ipre<0 || ipre>1) ){
190 TString message ("\n") ;
191 message += "inputs out of range ieta= " ;
194 message += GetNEta() ;
195 message += "] iphi= " ;
198 message += GetNPhi() ;
199 message += "] ipre= " ;
201 message += "[0,1]. returning -1" ;
202 Warning("TowerIndex", message.Data() ) ;
205 index = iphi + GetNPhi()*(ieta-1) + ipre*(GetNPhi()*GetNEta());
209 //______________________________________________________________________
210 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
212 // given the tower index number it returns the based on the Z and Phi
213 // index numbers and if it is for the full tower or the pre-tower number.
214 // There are 2 times the number of towers to separate
215 // out the full towsers from the pre-towsers.
217 // Int_t index // Tower index number [1-2*fNZ*fNPhi]
219 // Int_t ieta // index allong z axis [1-fNZ]
220 // Int_t iphi // index allong phi axis [1-fNPhi]
221 // Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
226 itowers = GetNEta()*GetNPhi();
227 if(index<1 || index>2*itowers){
228 TString message("\n") ;
229 message += "index= " ;
231 message += " is out of range [1-" ;
232 message += 2*itowers ;
233 message += "], returning -1 for all." ;
234 Warning("TowerIndex", message.Data() ) ;
235 ieta = -1; iphi = -1; ipre = -1;
239 if(index>itowers){ // pre shower indexs
241 index = index - itowers;
243 ieta = 1+ (Int_t)((index-1)/GetNPhi());
244 iphi = index - GetNPhi()*(ieta-1);
248 //______________________________________________________________________
249 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
250 // given the tower index number it returns the based on the eta and phi
253 // Int_t index // Tower index number [1-2*fNZ*fNPhi]
255 // Float_t eta // eta of center of tower in pseudorapidity
256 // Float_t phi // phi of center of tower in degrees
259 Int_t ieta,iphi,ipre;
260 Double_t deta,dphi,phid;
262 TowerIndexes(index,ieta,iphi,ipre);
263 deta = (GetArm1EtaMax()-GetArm1EtaMin())/((Float_t)GetNEta());
264 eta = GetArm1EtaMin() + (((Float_t)ieta)-0.5)*deta;
265 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/((Float_t)GetNPhi()); // in degrees.
266 phid = GetArm1PhiMin() + dphi*((Float_t)iphi -0.5);//iphi range [1-fNphi].
270 //______________________________________________________________________
271 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
272 // returns the tower index number based on the eta and phi of the tower.
274 // Float_t eta // eta of center of tower in pseudorapidity
275 // Float_t phi // phi of center of tower in degrees
279 // Int_t index // Tower index number [1-fNZ*fNPhi]
282 ieta = 1 + (Int_t)(((Float_t)GetNEta())*(eta-GetArm1EtaMin())/
283 (GetArm1EtaMax() - GetArm1EtaMin()));
284 if(ieta<=0 || ieta>GetNEta()){
285 TString message("\n") ;
286 message += "ieta = " ;
290 message += " is outside of EMCAL. etamin=" ;
291 message += GetArm1EtaMin() ;
292 message += " to etamax=" ;
293 message += GetArm1EtaMax();
294 message += " returning -1";
295 Warning("TowerIndexFromEtaPhi", message.Data() ) ;
298 iphi = 1 + (Int_t)(((Float_t)GetNPhi())*(phi-GetArm1PhiMin())/
299 ((Float_t)(GetArm1PhiMax() - GetArm1PhiMin())));
300 if(iphi<=0 || iphi>GetNPhi()){
301 TString message("\n") ;
306 message += " is outside of EMCAL." ;
307 message += " Phimin=" ;
308 message += GetArm1PhiMin() ;
309 message += " PhiMax=" ;
310 message += GetArm1PhiMax() ;
311 message += " returning -1" ;
312 Warning("TowerIndexFromEtaPhi", message.Data() ) ;
315 return TowerIndex(ieta,iphi,0);
318 //______________________________________________________________________
319 Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
320 // returns the pretower index number based on the eta and phi of the tower.
322 // Float_t eta // eta of center of tower in pseudorapidity
323 // Float_t phi // phi of center of tower in degrees
327 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
329 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
332 //______________________________________________________________________
333 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
334 // Converts the absolute numbering into the following array/
335 // relid[0] = EMCAL Arm number 1:1
336 // relid[1] = 0 Not in Pre Shower layers
337 // = -1 In Pre Shower
338 // relid[2] = Row number inside EMCAL
339 // relid[3] = Column number inside EMCAL
341 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
343 // Int_t *relid // array of 5. Discribed above.
345 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
347 TowerIndexes(index,ieta,iphi,ipre);
358 //______________________________________________________________________
359 void AliEMCALGeometry::PosInAlice(const Int_t *relid,Float_t &theta,
360 Float_t &phi) const {
361 // Converts the relative numbering into the local EMCAL-module (x, z)
363 Int_t ieta = relid[2]; // offset along x axis
364 Int_t iphi = relid[3]; // offset along z axis
365 Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
369 if(ipre==-1) ipre = 1;
370 index = TowerIndex(ieta,iphi,ipre);
371 EtaPhiFromIndex(index,eta,phi);
372 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
377 //______________________________________________________________________
378 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
379 // given the tower relative number it returns the X, Y and Z
383 // Float_t x // x of center of tower in cm
384 // Float_t y // y of center of tower in cm
385 // Float_t z // z of centre of tower in cm
389 Float_t eta,theta, phi,cyl_radius,kDeg2Rad;
391 Int_t ieta = relid[2]; // offset along x axis
392 Int_t iphi = relid[3]; // offset along z axis
393 Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
397 if(ipre==-1) ipre = 1;
398 index = TowerIndex(ieta,iphi,ipre);
399 EtaPhiFromIndex(index,eta,phi);
400 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
402 kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ;
404 cyl_radius = GetIP2PreShower() ;
406 cyl_radius = GetIP2Tower() ;
408 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
409 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
410 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
415 //______________________________________________________________________
417 Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
418 // Returns kTRUE if the two towers are neighbours or not, including
419 // diagonals. Both indexes are required to be either towers or preshower.
421 // Int_t index1 // index of tower 1
422 // Int_t index2 // index of tower 2
426 // Boot_t kTRUE if the towers are neighbours otherwise false.
428 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
430 TowerIndexes(index1,ieta1,iphi1,ipre1);
431 TowerIndexes(index2,ieta2,iphi2,ipre2);
432 if(ipre1!=ipre2) return anb;
433 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))