]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALGeometry.cxx
Move to new mapping
[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
d87bd045 22// between 80 and 180(or 190) degrees of Phi and
ffa6d63b 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
b13bbe81 26//*-- Author: Sahal Yacoob (LBL / UCT)
27// and : Yves Schutz (SUBATECH)
28// and : Jennifer Klay (LBL)
1963b290 29// SHASHLYK : Aleksei Pavlinov (WSU)
c63c3c5d 30// SuperModules -> module(or tower) -> cell
2012850d 31
2012850d 32// --- AliRoot header files ---
1ceeec56 33#include <assert.h>
ca8f5bd0 34#include <TMath.h>
116cbefd 35#include <TVector3.h>
c63c3c5d 36#include <TRegexp.h>
37#include <TObjArray.h>
38#include <TObjString.h>
173558f2 39
ca8f5bd0 40// -- ALICE Headers.
d64c959b 41//#include "AliConst.h"
173558f2 42
ca8f5bd0 43// --- EMCAL headers
44#include "AliEMCALGeometry.h"
2012850d 45
925e6570 46ClassImp(AliEMCALGeometry)
2012850d 47
b13bbe81 48AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
49Bool_t AliEMCALGeometry::fgInit = kFALSE;
1963b290 50TString name; // contains name of geometry
2012850d 51
c63c3c5d 52char *additionalOpts[]={"nl=", // number of sampling layers
53 "pbTh=", // cm, Thickness of the Pb
54 "scTh=" // cm, Thickness of the Sc
55};
56int nAdditionalOpts = sizeof(additionalOpts) / sizeof(char*);
57
b13bbe81 58//______________________________________________________________________
59AliEMCALGeometry::~AliEMCALGeometry(void){
60 // dtor
2012850d 61}
b13bbe81 62
395c7ba2 63//______________________________________________________________________
09884213 64Bool_t AliEMCALGeometry::AreInSameTower(Int_t id1, Int_t id2) const {
c63c3c5d 65 // Find out whether two hits are in the same tower - have to be change
395c7ba2 66 Int_t idmax = TMath::Max(id1, id2) ;
67 Int_t idmin = TMath::Min(id1, id2) ;
68 if ( ((idmax - GetNZ() * GetNPhi()) == idmin ) ||
69 ((idmax - 2 * GetNZ() * GetNPhi()) == idmin ) )
70 return kTRUE ;
71 else
72 return kFALSE ;
73}
05a92d59 74
395c7ba2 75//______________________________________________________________________
76void AliEMCALGeometry::Init(void){
77 // Initializes the EMCAL parameters
fdebddeb 78 // naming convention : GUV_WX_N_ gives the composition of a tower
395c7ba2 79 // WX inform about the composition of the EM calorimeter section:
fdebddeb 80 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
81 // New geometry: EMCAL_55_25
1963b290 82 // 24-aug-04 for shish-kebab
83 // SHISH_25 or SHISH_62
c63c3c5d 84 // 11-oct-05 - correction for pre final design
85 // Feb 06,2006 - decrease the weight of EMCAL
fdebddeb 86 fgInit = kFALSE; // Assume failed until proven otherwise.
1963b290 87 name = GetName();
d87bd045 88 name.ToUpper();
89 fKey110DEG = 0;
90 if(name.Contains("110DEG")) fKey110DEG = 1; // for GetAbsCellId
1963b290 91
92 fNZ = 114; // granularity along Z (eta)
93 fNPhi = 168; // granularity in phi (azimuth)
94 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
95 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
96 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
97 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
98 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
905263da 99 fPhiGapForSM = 0.; // cm, only for final TRD1 geometry
1963b290 100
101 // geometry
c63c3c5d 102 if(name.Contains("SHISH")){ // Only shahslyk now
905263da 103 // 7-sep-05; integration issue
104 fArm1PhiMin = 80.0; // 60 -> 80
c01485dd 105 fArm1PhiMax = 180.0; // 180 -> 190
905263da 106
107 fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z);
1963b290 108 fSteelFrontThick = 2.54; // 9-sep-04
109 fIPDistance = 460.0;
110 fFrontSteelStrip = fPassiveScintThick = 0.0; // 13-may-05
111 fLateralSteelStrip = 0.025; // before MAY 2005
112 fPhiModuleSize = fEtaModuleSize = 11.4;
113 fPhiTileSize = fEtaTileSize = 5.52; // (11.4-5.52*2)/2. = 0.18 cm (wall thickness)
114 fNPhi = 14;
115 fNZ = 30;
116 fAlFrontThick = fGap2Active = 0;
117 fNPHIdiv = fNETAdiv = 2;
118
119 fNECLayers = 62;
120 fECScintThick = fECPbRadThickness = 0.2;
121 fSampling = 1.; // 30-aug-04 - should be calculated
122 if(name.Contains("TWIST")) { // all about EMCAL module
123 fNZ = 27; // 16-sep-04
124 } else if(name.Contains("TRD")) {
125 fIPDistance = 428.0; // 11-may-05
126 fSteelFrontThick = 0.0; // 3.17 -> 0.0; 28-mar-05 : no stell plate
127 fNPhi = 12;
128 fSampling = 12.327;
129 fPhiModuleSize = fEtaModuleSize = 12.26;
130 fNZ = 26; // 11-oct-04
131 fTrd1Angle = 1.3; // in degree
132// 18-nov-04; 1./0.08112=12.327
133// http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
134 if(name.Contains("TRD1")) { // 30-jan-05
135 // for final design
905263da 136 fPhiGapForSM = 2.; // cm, only for final TRD1 geometry
137 if(name.Contains("MAY05") || name.Contains("WSUC") || name.Contains("FINAL")){
1963b290 138 fNumberOfSuperModules = 12; // 20-may-05
139 if(name.Contains("WSUC")) fNumberOfSuperModules = 1; // 27-may-05
140 fNECLayers = 77; // (13-may-05 from V.Petrov)
141 fPhiModuleSize = 12.5; // 20-may-05 - rectangular shape
142 fEtaModuleSize = 11.9;
143 fECScintThick = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov)
144 fFrontSteelStrip = 0.025;// 0.025cm = 0.25mm (13-may-05 from V.Petrov)
145 fLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025
146 fPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov)
147 fNZ = 24;
148 fTrd1Angle = 1.5; // 1.3 or 1.5
905263da 149
150 if(name.Contains("FINAL")) { // 9-sep-05
151 fNumberOfSuperModules = 10;
d87bd045 152 if(name.Contains("110DEG")) {
153 fNumberOfSuperModules = 12;// last two modules have size 10 degree in phi (180<phi<190)
154 fArm1PhiMax = 200.0; // for XEN1 and turn angle of super modules
155 }
905263da 156 fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption
157 fEtaModuleSize = fPhiModuleSize;
c01485dd 158 if(name.Contains("HUGE")) fNECLayers *= 3; // 28-oct-05 for analysing leakage
905263da 159 }
1963b290 160 }
161 } else if(name.Contains("TRD2")) { // 30-jan-05
162 fSteelFrontThick = 0.0; // 11-mar-05
163 fIPDistance+= fSteelFrontThick; // 1-feb-05 - compensate absence of steel plate
164 fTrd1Angle = 1.64; // 1.3->1.64
165 fTrd2AngleY = fTrd1Angle; // symmetric case now
166 fEmptySpace = 0.2; // 2 mm
167 fTubsR = fIPDistance; // 31-jan-05 - as for Fred case
168
169 fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
170 fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05
171 fEtaModuleSize = fPhiModuleSize; // 20-may-05
172 fTubsTurnAngle = 3.;
173 }
174 fNPHIdiv = fNETAdiv = 2; // 13-oct-04 - division again
175 if(name.Contains("3X3")) { // 23-nov-04
176 fNPHIdiv = fNETAdiv = 3;
177 } else if(name.Contains("4X4")) {
178 fNPHIdiv = fNETAdiv = 4;
179 }
180 }
181 fPhiTileSize = fPhiModuleSize/2. - fLateralSteelStrip; // 13-may-05
182 fEtaTileSize = fEtaModuleSize/2. - fLateralSteelStrip; // 13-may-05
183
184 if(name.Contains("25")){
185 fNECLayers = 25;
186 fECScintThick = fECPbRadThickness = 0.5;
187 }
188 if(name.Contains("WSUC")){ // 18-may-05 - about common structure
189 fShellThickness = 30.; // should be change
190 fNPhi = fNZ = 4;
191 }
c63c3c5d 192
193 CheckAditionalOptions();
194
1963b290 195 // constant for transition absid <--> indexes
196 fNCellsInTower = fNPHIdiv*fNETAdiv;
197 fNCellsInSupMod = fNCellsInTower*fNPhi*fNZ;
198 fNCells = fNCellsInSupMod*fNumberOfSuperModules;
d87bd045 199 if(name.Contains("110DEG")) fNCells -= fNCellsInSupMod;
1963b290 200
201 fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);
202 if(name.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick);
203
204 // 30-sep-04
205 if(name.Contains("TRD")) {
206 f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
207 if(name.Contains("TRD2")) { // 27-jan-05
208 f2Trd2Dy2 = fPhiModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
209 }
210 }
c63c3c5d 211 } else Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
fdebddeb 212
1963b290 213 fNPhiSuperModule = fNumberOfSuperModules/2;
214 if(fNPhiSuperModule<1) fNPhiSuperModule = 1;
fdebddeb 215 //There is always one more scintillator than radiator layer because of the first block of aluminium
216 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
1963b290 217 if(name.Contains("SHISH")) {
218 fShellThickness = fSteelFrontThick + fLongModuleSize;
219 if(name.Contains("TWIST")) { // 13-sep-04
220 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + fPhiModuleSize*fEtaModuleSize);
221 fShellThickness += fSteelFrontThick;
222 } else if(name.Contains("TRD")) { // 1-oct-04
223 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
224 fShellThickness += fSteelFrontThick;
225 }
226 }
fdebddeb 227
395c7ba2 228 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
229 fEnvelop[0] = fIPDistance; // mother volume inner radius
230 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
231 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
232
233 fgInit = kTRUE;
234
1963b290 235 if (kTRUE) {
236 printf("Init: geometry of EMCAL named %s is as follows:\n", name.Data());
905263da 237 printf( " ECAL : %d x (%f cm Pb, %f cm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
1963b290 238 if(name.Contains("SHISH")){
239 printf(" fIPDistance %6.3f cm \n", fIPDistance);
240 if(fSteelFrontThick>0.)
241 printf(" fSteelFrontThick %6.3f cm \n", fSteelFrontThick);
242 printf(" fNPhi %i | fNZ %i \n", fNPhi, fNZ);
d87bd045 243 printf(" fNCellsInTower %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInTower, fNCellsInSupMod, fNCells);
1963b290 244 if(name.Contains("MAY05")){
245 printf(" fFrontSteelStrip %6.4f cm (thickness of front steel strip)\n",
246 fFrontSteelStrip);
247 printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n",
248 fLateralSteelStrip);
249 printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n",
250 fPassiveScintThick);
251 }
c63c3c5d 252 printf(" X:Y module size %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
253 printf(" X:Y tile size %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
254 printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
255 printf(" fLongModuleSize %6.3f cm \n", fLongModuleSize);
1963b290 256 printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
257 }
258 if(name.Contains("TRD")) {
259 printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
260 printf(" f2Trd1Dx2 %7.4f\n", f2Trd1Dx2);
261 if(name.Contains("TRD2")) {
262 printf(" fTrd2AngleY %7.4f\n", fTrd2AngleY);
263 printf(" f2Trd2Dy2 %7.4f\n", f2Trd2Dy2);
905263da 264 printf(" fTubsR %7.2f cm\n", fTubsR);
1963b290 265 printf(" fTubsTurnAngle %7.4f\n", fTubsTurnAngle);
905263da 266 printf(" fEmptySpace %7.4f cm\n", fEmptySpace);
267 } else if(name.Contains("TRD1") && name.Contains("FINAL")){
268 printf(" fPhiGapForSM %7.4f cm \n", fPhiGapForSM);
d87bd045 269 if(name.Contains("110DEG"))printf(" Last two modules have size 10 degree in phi (180<phi<190)\n");
1963b290 270 }
271 }
88cb7938 272 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
1963b290 273 printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f\n",
274 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
88cb7938 275 }
2012850d 276}
173558f2 277
c63c3c5d 278//______________________________________________________________________
279
280void AliEMCALGeometry::CheckAditionalOptions()
281{ // Feb 06,2006
282 fArrayOpts = new TObjArray;
283 Int_t nopt = ParseString(name, *fArrayOpts);
284 if(nopt==1) { // no aditional option(s)
285 fArrayOpts->Delete();
286 delete fArrayOpts;
287 fArrayOpts = 0;
288 return;
289 }
290 for(Int_t i=1; i<nopt; i++){
291 TObjString *o = (TObjString*)fArrayOpts->At(i);
292
293 TString addOpt = o->String();
294 Int_t indj=-1;
295 for(Int_t j=0; j<nAdditionalOpts; j++) {
296 TString opt = additionalOpts[j];
297 if(addOpt.Contains(opt,TString::kIgnoreCase)) {
298 indj = j;
299 break;
300 }
301 }
302 if(indj<0) {
303 printf("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n",
304 addOpt.Data());
305 assert(0);
306 } else {
307 printf("<I> option |%s| is valid : number %i : |%s|\n",
308 addOpt.Data(), indj, additionalOpts[indj]);
309 if (addOpt.Contains("NL=",TString::kIgnoreCase)) {// number of sampling layers
310 sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
311 printf(" fNECLayers %i (new) \n", fNECLayers);
312 } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb
313 sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
314 } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc
315 sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
316 }
317 }
318 }
319}
320
b13bbe81 321//______________________________________________________________________
322AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 323 // Returns the pointer of the unique instance
324
325 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
2012850d 326}
173558f2 327
b13bbe81 328//______________________________________________________________________
329AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
330 const Text_t* title){
331 // Returns the pointer of the unique instance
332
333 AliEMCALGeometry * rv = 0;
334 if ( fgGeom == 0 ) {
335 if ( strcmp(name,"") == 0 ) rv = 0;
336 else {
337 fgGeom = new AliEMCALGeometry(name, title);
338 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
339 else {
340 rv = 0;
341 delete fgGeom;
342 fgGeom = 0;
343 } // end if fgInit
344 } // end if strcmp(name,"")
345 }else{
346 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
fdebddeb 347 printf("\ncurrent geometry is ") ;
348 printf(fgGeom->GetName());
349 printf("\n you cannot call ");
350 printf(name);
b13bbe81 351 }else{
9859bfc0 352 rv = (AliEMCALGeometry *) fgGeom;
b13bbe81 353 } // end if
354 } // end if fgGeom
355 return rv;
2012850d 356}
173558f2 357
c63c3c5d 358// These methods are obsolete but use in AliEMCALRecPoint - keep it now
ca8f5bd0 359//______________________________________________________________________
395c7ba2 360Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
361 // Returns the tower index number from the based on the Z and Phi
fdebddeb 362 // index numbers.
395c7ba2 363 // Inputs:
fdebddeb 364 // Int_t ieta // index along z axis [1-fNZ]
365 // Int_t iphi // index along phi axis [1-fNPhi]
395c7ba2 366 // Outputs:
367 // none.
368 // Returned
369 // Int_t index // Tower index number
370
371 if ( (ieta <= 0 || ieta>GetNEta()) ||
f1da4a27 372 (iphi <= 0 || iphi>GetNPhi())) {
373 Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
374 return -1;
375 }
395c7ba2 376 return ( (iphi - 1)*GetNEta() + ieta );
ca8f5bd0 377}
173558f2 378
ca8f5bd0 379//______________________________________________________________________
fdebddeb 380void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
395c7ba2 381 // Inputs:
fdebddeb 382 // Int_t index // Tower index number [1-fNZ*fNPhi]
395c7ba2 383 // Outputs:
384 // Int_t ieta // index allong z axis [1-fNZ]
385 // Int_t iphi // index allong phi axis [1-fNPhi]
395c7ba2 386 // Returned
387 // none.
395c7ba2 388
fdebddeb 389 Int_t nindex = 0;
395c7ba2 390
fdebddeb 391 if ( IsInECA(index) ) { // ECAL index
395c7ba2 392 nindex = index ;
395c7ba2 393 }
f1da4a27 394 else {
395 Error("TowerIndexes", "Unexpected Id number!") ;
396 ieta = -1;
397 iphi = -1;
398 return;
399 }
400
395c7ba2 401 if (nindex%GetNZ())
402 iphi = nindex / GetNZ() + 1 ;
403 else
404 iphi = nindex / GetNZ() ;
405 ieta = nindex - (iphi - 1) * GetNZ() ;
406
407 if (gDebug==2)
fdebddeb 408 printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
395c7ba2 409 return;
410
ca8f5bd0 411}
173558f2 412
ca8f5bd0 413//______________________________________________________________________
a34b7b9f 414void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
ca8f5bd0 415 // given the tower index number it returns the based on the eta and phi
416 // of the tower.
417 // Inputs:
fdebddeb 418 // Int_t index // Tower index number [1-fNZ*fNPhi]
ca8f5bd0 419 // Outputs:
420 // Float_t eta // eta of center of tower in pseudorapidity
421 // Float_t phi // phi of center of tower in degrees
422 // Returned
423 // none.
fdebddeb 424 Int_t ieta, iphi;
395c7ba2 425 Float_t deta, dphi ;
ca8f5bd0 426
fdebddeb 427 TowerIndexes(index,ieta,iphi);
395c7ba2 428
429 if (gDebug == 2)
fdebddeb 430 printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
395c7ba2 431
432 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
433 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
434
435 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
436 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
ca8f5bd0 437}
173558f2 438
ca8f5bd0 439//______________________________________________________________________
a34b7b9f 440Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 441 // returns the tower index number based on the eta and phi of the tower.
442 // Inputs:
443 // Float_t eta // eta of center of tower in pseudorapidity
444 // Float_t phi // phi of center of tower in degrees
445 // Outputs:
446 // none.
447 // Returned
448 // Int_t index // Tower index number [1-fNZ*fNPhi]
395c7ba2 449
e908f07f 450 Int_t ieta,iphi;
ca8f5bd0 451
395c7ba2 452 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
453
454 if( ieta <= 0 || ieta > GetNEta() ) {
455 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
456 return -1 ;
457 }
458
459 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
460
461 if( iphi <= 0 || iphi > GetNPhi() ) {
462 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
463 return -1 ;
464 }
465
466 return TowerIndex(ieta,iphi);
ca8f5bd0 467}
173558f2 468
ca8f5bd0 469//______________________________________________________________________
a34b7b9f 470Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
ca8f5bd0 471 // Converts the absolute numbering into the following array/
2608a1fc 472 // relid[0] = Row number inside EMCAL
473 // relid[1] = Column number inside EMCAL
ca8f5bd0 474 // Input:
475 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
476 // Outputs:
2608a1fc 477 // Int_t *relid // array of 2. Described above.
ca8f5bd0 478 Bool_t rv = kTRUE ;
fdebddeb 479 Int_t ieta=0,iphi=0,index=AbsId;
ca8f5bd0 480
fdebddeb 481 TowerIndexes(index,ieta,iphi);
2608a1fc 482 relid[0] = ieta;
483 relid[1] = iphi;
ca8f5bd0 484
485 return rv;
486}
173558f2 487
ca8f5bd0 488//______________________________________________________________________
395c7ba2 489void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
490{
491 // Converts the relative numbering into the local EMCAL-module (x, z)
492 // coordinates
2608a1fc 493 Int_t ieta = relid[0]; // offset along x axis
494 Int_t iphi = relid[1]; // offset along z axis
395c7ba2 495 Int_t index;
496 Float_t eta;
497
498 index = TowerIndex(ieta,iphi);
499 EtaPhiFromIndex(index,eta,phi);
fdebddeb 500 //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
501 theta = 2.0*TMath::ATan(TMath::Exp(-eta));
395c7ba2 502
fdebddeb 503 // correct for distance to IP
504 Float_t d = GetIP2ECASection() - GetIPDistance() ;
395c7ba2 505
506 Float_t correction = 1 + d/GetIPDistance() ;
507 Float_t tantheta = TMath::Tan(theta) * correction ;
508 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
509 if (theta < 0 )
510 theta += 180. ;
511
512 return;
513}
ca8f5bd0 514
395c7ba2 515//______________________________________________________________________
09884213 516void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
395c7ba2 517{
518 // Converts the relative numbering into the local EMCAL-module (x, z)
519 // coordinates
2608a1fc 520 Int_t relid[2] ;
395c7ba2 521 AbsToRelNumbering(absid, relid) ;
2608a1fc 522 Int_t ieta = relid[0]; // offset along x axis
523 Int_t iphi = relid[1]; // offset along z axis
395c7ba2 524 Int_t index;
525 Float_t eta;
526
527 index = TowerIndex(ieta,iphi);
528 EtaPhiFromIndex(index,eta,phi);
529 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
530
fdebddeb 531 // correct for distance to IP
395c7ba2 532 Float_t d = 0. ;
fdebddeb 533 if (IsInECA(absid))
88cb7938 534 d = GetIP2ECASection() - GetIPDistance() ;
f1da4a27 535 else {
536 Error("PosInAlice", "Unexpected id # %d!", absid) ;
537 return;
538 }
395c7ba2 539
540 Float_t correction = 1 + d/GetIPDistance() ;
541 Float_t tantheta = TMath::Tan(theta) * correction ;
542 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
543 if (theta < 0 )
544 theta += 180. ;
545
546 return;
ca8f5bd0 547}
6119e5db 548
549//______________________________________________________________________
550void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
551 // given the tower relative number it returns the X, Y and Z
552 // of the tower.
553
554 // Outputs:
555 // Float_t x // x of center of tower in cm
556 // Float_t y // y of center of tower in cm
557 // Float_t z // z of centre of tower in cm
558 // Returned
559 // none.
560
fdebddeb 561 Float_t eta,theta, phi,cylradius=0. ;
6119e5db 562
2608a1fc 563 Int_t ieta = relid[0]; // offset along x axis
564 Int_t iphi = relid[1]; // offset along z axis.
6119e5db 565 Int_t index;
566
395c7ba2 567 index = TowerIndex(ieta,iphi);
6119e5db 568 EtaPhiFromIndex(index,eta,phi);
569 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
6119e5db 570
fdebddeb 571 cylradius = GetIP2ECASection() ;
a97849a9 572
395c7ba2 573 Double_t kDeg2Rad = TMath::DegToRad() ;
fdebddeb 574 x = cylradius * TMath::Cos(phi * kDeg2Rad ) ;
575 y = cylradius * TMath::Sin(phi * kDeg2Rad ) ;
576 z = cylradius / TMath::Tan(theta * kDeg2Rad ) ;
6119e5db 577
578 return;
579}
580
395c7ba2 581//______________________________________________________________________
09884213 582void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const {
395c7ba2 583 // given the tower relative number it returns the X, Y and Z
584 // of the tower.
585
586 // Outputs:
587 // Float_t x // x of center of tower in cm
588 // Float_t y // y of center of tower in cm
589 // Float_t z // z of centre of tower in cm
590 // Returned
591 // none.
592
fdebddeb 593 Float_t theta, phi,cylradius=0. ;
395c7ba2 594
595 PosInAlice(absid, theta, phi) ;
596
88cb7938 597 if ( IsInECA(absid) )
fdebddeb 598 cylradius = GetIP2ECASection() ;
f1da4a27 599 else {
600 Error("XYZFromIndex", "Unexpected Tower section") ;
601 return;
602 }
395c7ba2 603
604 Double_t kDeg2Rad = TMath::DegToRad() ;
fdebddeb 605 v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) );
606 v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) );
607 v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ;
395c7ba2 608
609 return;
610}
ab37d09c 611
612Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
613 // Checks whether point is inside the EMCal volume
614 //
615 // Code uses cylindrical approximation made of inner radius (for speed)
616 //
617 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
618 // are considered to inside
619
620 Double_t r=sqrt(x*x+y*y);
621
622 if ( r > fEnvelop[0] ) {
623 Double_t theta;
624 theta = TMath::ATan2(r,z);
625 Double_t eta;
626 if(theta == 0)
627 eta = 9999;
628 else
629 eta = -TMath::Log(TMath::Tan(theta/2.));
630 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
631 return 0;
632
633 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
634 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
635 return 1;
636 }
637 return 0;
638}
c63c3c5d 639// ==
1963b290 640
641//
642// == Shish-kebab cases ==
643//
eb0b1051 644Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta)
d87bd045 645{ // 27-aug-04;
646 // corr. 21-sep-04;
647 // 13-oct-05; 110 degree case
648 // 1 <= nSupMod <= fNumberOfSuperModules
649 // 1 <= nTower <= fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
650 // 1 <= nIphi <= fNPHIdiv
651 // 1 <= nIeta <= fNETAdiv
652 // 1 <= absid <= fNCells
653 static Int_t id=0; // have to change from 1 to fNCells
654 if(fKey110DEG == 1 && nSupMod > 10) { // 110 degree case; last two supermodules
655 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-11);
656 } else {
657 id = fNCellsInSupMod*(nSupMod-1);
658 }
1963b290 659 id += fNCellsInTower *(nTower-1);
660 id += fNPHIdiv *(nIphi-1);
661 id += nIeta;
662 if(id<=0 || id > fNCells) {
500aeccc 663// printf(" wrong numerations !!\n");
664// printf(" id %6i(will be force to -1)\n", id);
665// printf(" fNCells %6i\n", fNCells);
666// printf(" nSupMod %6i\n", nSupMod);
667// printf(" nTower %6i\n", nTower);
668// printf(" nIphi %6i\n", nIphi);
669// printf(" nIeta %6i\n", nIeta);
d87bd045 670 id = -TMath::Abs(id);
1963b290 671 }
672 return id;
673}
674
675Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind)
676{ // 17-niv-04 - analog of IsInECA
677 if(name.Contains("TRD")) {
678 if(ind<=0 || ind > fNCells) return kFALSE;
679 else return kTRUE;
680 } else return IsInECA(ind);
681}
682
eb0b1051 683Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta)
1963b290 684{ // 21-sep-04
d87bd045 685 // 19-oct-05;
686 static Int_t tmp=0, sm10=0;
1963b290 687 if(absId<=0 || absId>fNCells) {
500aeccc 688// Info("GetCellIndex"," wrong abs Id %i !! \n", absId);
1963b290 689 return kFALSE;
690 }
d87bd045 691 sm10 = fNCellsInSupMod*10;
692 if(fKey110DEG == 1 && absId > sm10) { // 110 degree case; last two supermodules
693 nSupMod = (absId-1-sm10) / (fNCellsInSupMod/2) + 11;
694 tmp = (absId-1-sm10) % (fNCellsInSupMod/2);
695 } else {
696 nSupMod = (absId-1) / fNCellsInSupMod + 1;
697 tmp = (absId-1) % fNCellsInSupMod;
698 }
1963b290 699
700 nTower = tmp / fNCellsInTower + 1;
701 tmp = tmp % fNCellsInTower;
d87bd045 702 nIphi = tmp / fNPHIdiv + 1;
703 nIeta = tmp % fNPHIdiv + 1;
1963b290 704
705 return kTRUE;
706}
707
eb0b1051 708void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat)
d87bd045 709{ // added nSupMod; have to check - 19-oct-05 !
710 static Int_t nphi;
711
712 if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2;
713 else nphi = fNPhi;
714
715 ietat = (nTower-1)/nphi + 1; // have to change from 1 to fNZ
d87bd045 716 iphit = (nTower-1)%nphi + 1; // have to change from 1 to fNPhi
717}
718
eb0b1051 719void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
1963b290 720int &iphi, int &ieta)
c01485dd 721{ // added nSupMod; Nov 25, 05
722 static Int_t iphit, ietat;
723
724 GetTowerPhiEtaIndexInSModule(nSupMod,nTower, iphit, ietat);
725 // have to change from 1 to fNZ*fNETAdiv
726 ieta = (ietat-1)*fNETAdiv + (3-nIeta); // x(module) = -z(SM)
727 // iphi - have to change from 1 to fNPhi*fNPHIdiv
728 iphi = (iphit-1)*fNPHIdiv + nIphi; // y(module) = y(SM)
1963b290 729}
c63c3c5d 730// Service routine
731int AliEMCALGeometry::ParseString(const TString &topt, TObjArray &Opt)
732{ // Feb 06, 2006
733 Ssiz_t begin, index, end, end2;
734 begin = index = end = end2 = 0;
735 TRegexp separator("[^ ;,\\t\\s/]+");
736 while ( (begin < topt.Length()) && (index != kNPOS) ) {
737 // loop over given options
738 index = topt.Index(separator,&end,begin);
739 if (index >= 0 && end >= 1) {
740 TString substring(topt(index,end));
741 Opt.Add(new TObjString(substring.Data()));
742 }
743 begin += end+1;
744 }
745 return Opt.GetEntries();
746}