]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALGeometry.cxx
added the HCAL section. Revised the way fluctiations and noise are added
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.cxx
CommitLineData
2012850d 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$*/
17
18//_________________________________________________________________________
19// Geometry class for EMCAL : singleton
b13bbe81 20// EMCAL consists of layers of scintillator and lead
ffa6d63b 21// Places the the Barrel Geometry of The EMCAL at Midrapidity
22// between 0 and 120 degrees of Phi and
23// -0.7 to 0.7 in eta
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
b13bbe81 28//*-- Author: Sahal Yacoob (LBL / UCT)
29// and : Yves Schutz (SUBATECH)
30// and : Jennifer Klay (LBL)
2012850d 31
32// --- ROOT system ---
33
34// --- Standard library ---
bba4716c 35#include <stdlib.h>
2012850d 36
37// --- AliRoot header files ---
ca8f5bd0 38#include <TMath.h>
173558f2 39
ca8f5bd0 40// -- ALICE Headers.
2012850d 41#include "AliConst.h"
173558f2 42
ca8f5bd0 43// --- EMCAL headers
44#include "AliEMCALGeometry.h"
2012850d 45
b13bbe81 46ClassImp(AliEMCALGeometry);
2012850d 47
b13bbe81 48AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
49Bool_t AliEMCALGeometry::fgInit = kFALSE;
2012850d 50
b13bbe81 51//______________________________________________________________________
52AliEMCALGeometry::~AliEMCALGeometry(void){
53 // dtor
2012850d 54}
b13bbe81 55//______________________________________________________________________
56void AliEMCALGeometry::Init(void){
57 // Initializes the EMCAL parameters
58
e908f07f 59 fgInit = kFALSE; // Assume failer untill proven otherwise.
05a92d59 60
61 TString name(GetName()) ;
62
63 if( name != "EMCALArch1a" &&
64 name != "EMCALArch1b" &&
65 name != "EMCALArch2a" &&
a63e0d5e 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()) ;
b13bbe81 69 } // end if
e908f07f 70 //
05a92d59 71 if ( name == "EMCALArch1a" ||
a63e0d5e 72 name == "EMCALArch1b" ||
73 name == "EMCALArch1aN") {
a97849a9 74 fNZ = 96;
75 fNPhi = 144;
b13bbe81 76 } // end if
05a92d59 77 if ( name == "EMCALArch2a" ||
a97849a9 78 name == "EMCALArch2b" ) {
b13bbe81 79 fNZ = 112;
80 fNPhi = 168;
81 } // end if
05a92d59 82 if ( name == "EMCALArch1a" ||
83 name == "EMCALArch2a" ) {
a63e0d5e 84 fNPRLayers = 2;
85 fNECLayers = 19;
86 fNHCLayers = 0;
b13bbe81 87 } // end if
05a92d59 88 if ( name == "EMCALArch1b" ||
89 name == "EMCALArch2b" ) {
a63e0d5e 90 fNPRLayers = 2;
91 fNECLayers = 23;
92 fNHCLayers = 0;
b13bbe81 93 } // end if
a63e0d5e 94 if ( name == "EMCALArch1aN") {
95 fNPRLayers = 2;
96 fNECLayers = 19;
97 fNHCLayers = 14;
98 }
e908f07f 99
100 // geometry
6365f121 101 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
102 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
e908f07f 103 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
104 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
a63e0d5e 105
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.
112
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.
120 }
121
e908f07f 122 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
a63e0d5e 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
e908f07f 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.
e908f07f 131 fgInit = kTRUE;
2012850d 132}
173558f2 133
b13bbe81 134//______________________________________________________________________
135AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 136 // Returns the pointer of the unique instance
137
138 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
2012850d 139}
173558f2 140
b13bbe81 141//______________________________________________________________________
142AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
143 const Text_t* title){
144 // Returns the pointer of the unique instance
145
146 AliEMCALGeometry * rv = 0;
147 if ( fgGeom == 0 ) {
148 if ( strcmp(name,"") == 0 ) rv = 0;
149 else {
150 fgGeom = new AliEMCALGeometry(name, title);
151 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
152 else {
153 rv = 0;
154 delete fgGeom;
155 fgGeom = 0;
156 } // end if fgInit
157 } // end if strcmp(name,"")
158 }else{
159 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
9859bfc0 160 TString message("\n") ;
161 message += "current geometry is " ;
162 message += fgGeom->GetName() ;
163 message += "\n you cannot call " ;
164 message += name ;
165 ::Info("GetGeometry", message.Data() ) ;
b13bbe81 166 }else{
9859bfc0 167 rv = (AliEMCALGeometry *) fgGeom;
b13bbe81 168 } // end if
169 } // end if fgGeom
170 return rv;
2012850d 171}
173558f2 172
ca8f5bd0 173//______________________________________________________________________
a34b7b9f 174Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi,Int_t ipre) const {
ca8f5bd0 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
a97849a9 177 // out the full towers from the pre-showers.
ca8f5bd0 178 // Inputs:
e908f07f 179 // Int_t ieta // index allong z axis [1-fNZ]
ca8f5bd0 180 // Int_t iphi // index allong phi axis [1-fNPhi]
181 // Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
182 // Outputs:
183 // none.
184 // Returned
185 // Int_t the absoulute tower index. [1-2*fNZ*fNPhi]
186 Int_t index;
187
e908f07f 188 if((ieta<=0 || ieta>GetNEta()) || (iphi<=0 || iphi>GetNPhi()) ||
ca8f5bd0 189 (ipre<0 || ipre>1) ){
9859bfc0 190 TString message ("\n") ;
191 message += "inputs out of range ieta= " ;
192 message += ieta ;
193 message += " [1-" ;
194 message += GetNEta() ;
195 message += "] iphi= " ;
196 message += iphi ;
197 message += " [1-" ;
198 message += GetNPhi() ;
199 message += "] ipre= " ;
200 message += ipre ;
201 message += "[0,1]. returning -1" ;
202 Warning("TowerIndex", message.Data() ) ;
203 return -1;
ca8f5bd0 204 } // end if
e908f07f 205 index = iphi + GetNPhi()*(ieta-1) + ipre*(GetNPhi()*GetNEta());
ca8f5bd0 206 return index;
207}
173558f2 208
ca8f5bd0 209//______________________________________________________________________
e908f07f 210void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
a34b7b9f 211 Int_t &ipre) const {
ca8f5bd0 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.
216 // Inputs:
217 // Int_t index // Tower index number [1-2*fNZ*fNPhi]
218 // Outputs:
e908f07f 219 // Int_t ieta // index allong z axis [1-fNZ]
ca8f5bd0 220 // Int_t iphi // index allong phi axis [1-fNPhi]
221 // Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
222 // Returned
223 // none.
224 Int_t itowers;
225
e908f07f 226 itowers = GetNEta()*GetNPhi();
ca8f5bd0 227 if(index<1 || index>2*itowers){
9859bfc0 228 TString message("\n") ;
229 message += "index= " ;
230 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;
236 return ;
ca8f5bd0 237 } // end if
238 ipre = 0;
239 if(index>itowers){ // pre shower indexs
240 ipre = 1;
241 index = index - itowers;
242 } // end if
4b988fd2 243 ieta = 1+ (Int_t)((index-1)/GetNPhi());
244 iphi = index - GetNPhi()*(ieta-1);
ca8f5bd0 245 return;
246}
173558f2 247
ca8f5bd0 248//______________________________________________________________________
a34b7b9f 249void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
ca8f5bd0 250 // given the tower index number it returns the based on the eta and phi
251 // of the tower.
252 // Inputs:
253 // Int_t index // Tower index number [1-2*fNZ*fNPhi]
254 // Outputs:
255 // Float_t eta // eta of center of tower in pseudorapidity
256 // Float_t phi // phi of center of tower in degrees
257 // Returned
258 // none.
e908f07f 259 Int_t ieta,iphi,ipre;
260 Double_t deta,dphi,phid;
ca8f5bd0 261
e908f07f 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].
ca8f5bd0 267 phi = phid;
268}
173558f2 269
ca8f5bd0 270//______________________________________________________________________
a34b7b9f 271Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 272 // returns the tower index number based on the eta and phi of the tower.
273 // Inputs:
274 // Float_t eta // eta of center of tower in pseudorapidity
275 // Float_t phi // phi of center of tower in degrees
276 // Outputs:
277 // none.
278 // Returned
279 // Int_t index // Tower index number [1-fNZ*fNPhi]
e908f07f 280 Int_t ieta,iphi;
ca8f5bd0 281
e908f07f 282 ieta = 1 + (Int_t)(((Float_t)GetNEta())*(eta-GetArm1EtaMin())/
283 (GetArm1EtaMax() - GetArm1EtaMin()));
284 if(ieta<=0 || ieta>GetNEta()){
9859bfc0 285 TString message("\n") ;
286 message += "ieta = " ;
287 message += ieta ;
288 message += " eta=" ;
289 message += eta ;
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() ) ;
296 return -1;
ca8f5bd0 297 } // end if
e908f07f 298 iphi = 1 + (Int_t)(((Float_t)GetNPhi())*(phi-GetArm1PhiMin())/
299 ((Float_t)(GetArm1PhiMax() - GetArm1PhiMin())));
ca8f5bd0 300 if(iphi<=0 || iphi>GetNPhi()){
9859bfc0 301 TString message("\n") ;
302 message += "iphi=" ;
303 message += iphi ;
304 message += "phi= " ;
305 message += phi ;
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() ) ;
313 return -1;
ca8f5bd0 314 } // end if
e908f07f 315 return TowerIndex(ieta,iphi,0);
ca8f5bd0 316}
173558f2 317
ca8f5bd0 318//______________________________________________________________________
a34b7b9f 319Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 320 // returns the pretower index number based on the eta and phi of the tower.
321 // Inputs:
322 // Float_t eta // eta of center of tower in pseudorapidity
323 // Float_t phi // phi of center of tower in degrees
324 // Outputs:
325 // none.
326 // Returned
327 // Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
328
e908f07f 329 return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
ca8f5bd0 330}
173558f2 331
ca8f5bd0 332//______________________________________________________________________
a34b7b9f 333Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
ca8f5bd0 334 // Converts the absolute numbering into the following array/
5a9318ff 335 // relid[0] = EMCAL Arm number 1:1
ca8f5bd0 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
340 // Input:
341 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
342 // Outputs:
343 // Int_t *relid // array of 5. Discribed above.
344 Bool_t rv = kTRUE ;
e908f07f 345 Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
ca8f5bd0 346
e908f07f 347 TowerIndexes(index,ieta,iphi,ipre);
ca8f5bd0 348 relid[0] = 1;
349 relid[1] = 0;
5a9318ff 350 if(ipre==1)
351 relid[1] = -1;
e908f07f 352 relid[2] = ieta;
ca8f5bd0 353 relid[3] = iphi;
354
355 return rv;
356}
173558f2 357
ca8f5bd0 358//______________________________________________________________________
5a9318ff 359void AliEMCALGeometry::PosInAlice(const Int_t *relid,Float_t &theta,
a34b7b9f 360 Float_t &phi) const {
5a9318ff 361 // Converts the relative numbering into the local EMCAL-module (x, z)
ca8f5bd0 362 // coordinates
e908f07f 363 Int_t ieta = relid[2]; // offset along x axis
ca8f5bd0 364 Int_t iphi = relid[3]; // offset along z axis
5a9318ff 365 Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
ca8f5bd0 366 Int_t index;
367 Float_t eta;
368
369 if(ipre==-1) ipre = 1;
e908f07f 370 index = TowerIndex(ieta,iphi,ipre);
ca8f5bd0 371 EtaPhiFromIndex(index,eta,phi);
372 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
373
374 return;
375}
6119e5db 376
377//______________________________________________________________________
378void 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
380 // of the tower.
381
382 // Outputs:
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
386 // Returned
387 // none.
388
389 Float_t eta,theta, phi,cyl_radius,kDeg2Rad;
390
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.
394 Int_t index;
395
396
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();
6119e5db 401
402 kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ;
a97849a9 403 if ( ipre == -1 )
404 cyl_radius = GetIP2PreShower() ;
405 else
406 cyl_radius = GetIP2Tower() ;
407
6119e5db 408 x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
f6eaf97a 409 y = cyl_radius * TMath::Sin(phi * kDeg2Rad ) ;
6119e5db 410 z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
411
412 return;
413}
414
ca8f5bd0 415//______________________________________________________________________
416/*
a34b7b9f 417Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
ca8f5bd0 418 // Returns kTRUE if the two towers are neighbours or not, including
419 // diagonals. Both indexes are required to be either towers or preshower.
420 // Inputs:
421 // Int_t index1 // index of tower 1
422 // Int_t index2 // index of tower 2
423 // Outputs:
424 // none.
425 // Returned
426 // Boot_t kTRUE if the towers are neighbours otherwise false.
427 Boot_t anb = kFALSE;
e908f07f 428 Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
ca8f5bd0 429
e908f07f 430 TowerIndexes(index1,ieta1,iphi1,ipre1);
431 TowerIndexes(index2,ieta2,iphi2,ipre2);
ca8f5bd0 432 if(ipre1!=ipre2) return anb;
e908f07f 433 if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))
ca8f5bd0 434 anb = kTRUE;
435 return anb;
436}
437 */