fixed compilation warning
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.cxx
CommitLineData
e5a93224 1/**************************************************************************
2012850d 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
1d46d1f6 26// EMCAL geometry tree:
2bb3725c 27// EMCAL -> superModule -> module -> tower(cell)
1d46d1f6 28// Indexes
2bb3725c 29// absId -> nSupMod -> nModule -> (nIphi,nIeta)
1d46d1f6 30//
b13bbe81 31//*-- Author: Sahal Yacoob (LBL / UCT)
32// and : Yves Schutz (SUBATECH)
33// and : Jennifer Klay (LBL)
85327f24 34// SHASHLYK : Aleksei Pavlinov (WSU)
1d46d1f6 35//
090026bf 36
1ceeec56 37#include <assert.h>
e52475ed 38
090026bf 39// --- AliRoot header files ---
40#include <Riostream.h>
41#include <TBrowser.h>
42#include <TClonesArray.h>
e52475ed 43#include <TGeoManager.h>
e52475ed 44#include <TGeoMatrix.h>
090026bf 45#include <TGeoNode.h>
f0377b23 46#include <TMatrixD.h>
090026bf 47#include <TObjArray.h>
d434833b 48#include <TObjString.h>
090026bf 49#include <TVector3.h>
173558f2 50
ca8f5bd0 51// -- ALICE Headers.
e5a93224 52#include "AliLog.h"
173558f2 53
ca8f5bd0 54// --- EMCAL headers
55#include "AliEMCALGeometry.h"
e52475ed 56#include "AliEMCALShishKebabTrd1Module.h"
e52475ed 57#include "AliEMCALRecPoint.h"
f0377b23 58#include "AliEMCALDigit.h"
d434833b 59#include "AliEMCALHistoUtilities.h"
2012850d 60
925e6570 61ClassImp(AliEMCALGeometry)
2012850d 62
d434833b 63// these initialisations are needed for a singleton
64AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
65Bool_t AliEMCALGeometry::fgInit = kFALSE;
89557f6d 66Char_t* AliEMCALGeometry::fgDefaultGeometryName = "SHISH_77_TRD1_2X2_FINAL_110DEG";
67//
68// Usage:
69// You can create the AliEMCALGeometry object independently from anything.
70// You have to use just the correct name of geometry. If name is empty string the
71// default name of geometry will be used.
72//
73// AliEMCALGeometry* g = AliEMCALGeometry::GetInstance(name,title); // first time
74// ..
75// g = AliEMCALGeometry::GetInstance(); // after first time
76//
dc7da436 77
9cff4509 78AliEMCALGeometry::AliEMCALGeometry()
79 : AliGeometry(),
80 fGeoName(0),fArrayOpts(0),fAlFrontThick(0.),fECPbRadThickness(0.),fECScintThick(0.),
81 fNECLayers(0),fArm1PhiMin(0.),fArm1PhiMax(0.),fArm1EtaMin(0.),fArm1EtaMax(0.),fIPDistance(0.),
82 fShellThickness(0.),fZLength(0.),fGap2Active(0.),fNZ(0),fNPhi(0),fSampling(0.),fNumberOfSuperModules(0),
83 fSteelFrontThick(0.),fFrontSteelStrip(0.),fLateralSteelStrip(0.),fPassiveScintThick(0.),fPhiModuleSize(0.),
84 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fLongModuleSize(0.),fNPhiSuperModule(0),fNPHIdiv(0),fNETAdiv(0),
2bb3725c 85 fNCells(0),fNCellsInSupMod(0),fNCellsInModule(0),fNTRU(0),fNTRUEta(0),fNTRUPhi(0),fTrd1Angle(0.),f2Trd1Dx2(0.),
1d46d1f6 86 fPhiGapForSM(0.),fKey110DEG(0),fPhiBoundariesOfSM(0), fPhiCentersOfSM(0),fEtaMaxOfTRD1(0),
87 fTrd2AngleY(0.),f2Trd2Dy2(0.),fEmptySpace(0.),fTubsR(0.),fTubsTurnAngle(0.),fCentersOfCellsEtaDir(0),
88 fCentersOfCellsXDir(0),fCentersOfCellsPhiDir(0),fEtaCentersOfCells(0),fPhiCentersOfCells(0),
89557f6d 89 fShishKebabTrd1Modules(0), fNAdditionalOpts(0),
90 fILOSS(-1), fIHADR(-1)
dc7da436 91{
92 // default ctor only for internal usage (singleton)
93 // must be kept public for root persistency purposes, but should never be called by the outside world
94 // CreateListOfTrd1Modules();
95 AliDebug(2, "AliEMCALGeometry : default ctor ");
96}
97//______________________________________________________________________
9cff4509 98AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title)
99 : AliGeometry(name, title),
100 fGeoName(0),fArrayOpts(0),fAlFrontThick(0.),fECPbRadThickness(0.),fECScintThick(0.),
101 fNECLayers(0),fArm1PhiMin(0.),fArm1PhiMax(0.),fArm1EtaMin(0.),fArm1EtaMax(0.),fIPDistance(0.),
102 fShellThickness(0.),fZLength(0.),fGap2Active(0.),fNZ(0),fNPhi(0),fSampling(0.),fNumberOfSuperModules(0),
103 fSteelFrontThick(0.),fFrontSteelStrip(0.),fLateralSteelStrip(0.),fPassiveScintThick(0.),fPhiModuleSize(0.),
104 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fLongModuleSize(0.),fNPhiSuperModule(0),fNPHIdiv(0),fNETAdiv(0),
2bb3725c 105 fNCells(0),fNCellsInSupMod(0),fNCellsInModule(0),fNTRU(0),fNTRUEta(0),fNTRUPhi(0),fTrd1Angle(0.),f2Trd1Dx2(0.),
1d46d1f6 106 fPhiGapForSM(0.),fKey110DEG(0),fPhiBoundariesOfSM(0), fPhiCentersOfSM(0), fEtaMaxOfTRD1(0),
107 fTrd2AngleY(0.),f2Trd2Dy2(0.),fEmptySpace(0.),fTubsR(0.),fTubsTurnAngle(0.),fCentersOfCellsEtaDir(0),
108 fCentersOfCellsXDir(0),fCentersOfCellsPhiDir(0),fEtaCentersOfCells(0),fPhiCentersOfCells(0),
89557f6d 109 fShishKebabTrd1Modules(0),fNAdditionalOpts(0),
110 fILOSS(-1), fIHADR(-1)
9cff4509 111{
112 // ctor only for internal usage (singleton)
dc7da436 113 AliDebug(2, Form("AliEMCALGeometry(%s,%s) ", name,title));
1d46d1f6 114
dc7da436 115 Init();
1d46d1f6 116
dc7da436 117 CreateListOfTrd1Modules();
1d46d1f6 118
119 if (AliDebugLevel()>=2) {
120 PrintGeometry();
121 }
122
dc7da436 123}
0a4cb131 124//______________________________________________________________________
9cff4509 125AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry& geom)
126 : AliGeometry(geom),
127 fGeoName(geom.fGeoName),
128 fArrayOpts(geom.fArrayOpts),
129 fAlFrontThick(geom.fAlFrontThick),
130 fECPbRadThickness(geom.fECPbRadThickness),
131 fECScintThick(geom.fECScintThick),
132 fNECLayers(geom.fNECLayers),
133 fArm1PhiMin(geom.fArm1PhiMin),
134 fArm1PhiMax(geom.fArm1PhiMax),
135 fArm1EtaMin(geom.fArm1EtaMin),
136 fArm1EtaMax(geom.fArm1EtaMax),
137 fIPDistance(geom.fIPDistance),
138 fShellThickness(geom.fShellThickness),
139 fZLength(geom.fZLength),
140 fGap2Active(geom.fGap2Active),
141 fNZ(geom.fNZ),
142 fNPhi(geom.fNPhi),
143 fSampling(geom.fSampling),
144 fNumberOfSuperModules(geom.fNumberOfSuperModules),
145 fSteelFrontThick(geom.fSteelFrontThick),
146 fFrontSteelStrip(geom.fFrontSteelStrip),
147 fLateralSteelStrip(geom.fLateralSteelStrip),
148 fPassiveScintThick(geom.fPassiveScintThick),
149 fPhiModuleSize(geom.fPhiModuleSize),
150 fEtaModuleSize(geom.fEtaModuleSize),
151 fPhiTileSize(geom.fPhiTileSize),
152 fEtaTileSize(geom.fEtaTileSize),
153 fLongModuleSize(geom.fLongModuleSize),
154 fNPhiSuperModule(geom.fNPhiSuperModule),
155 fNPHIdiv(geom.fNPHIdiv),
156 fNETAdiv(geom.fNETAdiv),
157 fNCells(geom.fNCells),
158 fNCellsInSupMod(geom.fNCellsInSupMod),
2bb3725c 159 fNCellsInModule(geom.fNCellsInModule),
9cff4509 160 fNTRU(geom.fNTRU),
161 fNTRUEta(geom.fNTRUEta),
162 fNTRUPhi(geom.fNTRUPhi),
163 fTrd1Angle(geom.fTrd1Angle),
164 f2Trd1Dx2(geom.f2Trd1Dx2),
165 fPhiGapForSM(geom.fPhiGapForSM),
166 fKey110DEG(geom.fKey110DEG),
1d46d1f6 167 fPhiBoundariesOfSM(geom.fPhiBoundariesOfSM),
168 fPhiCentersOfSM(geom.fPhiCentersOfSM),
169 fEtaMaxOfTRD1(geom.fEtaMaxOfTRD1),
9cff4509 170 fTrd2AngleY(geom.fTrd2AngleY),
171 f2Trd2Dy2(geom.f2Trd2Dy2),
172 fEmptySpace(geom.fEmptySpace),
173 fTubsR(geom.fTubsR),
174 fTubsTurnAngle(geom.fTubsTurnAngle),
1d46d1f6 175 fCentersOfCellsEtaDir(geom.fCentersOfCellsEtaDir),
176 fCentersOfCellsXDir(geom.fCentersOfCellsXDir),
177 fCentersOfCellsPhiDir(geom.fCentersOfCellsPhiDir),
9cff4509 178 fEtaCentersOfCells(geom.fEtaCentersOfCells),
9cff4509 179 fPhiCentersOfCells(geom.fPhiCentersOfCells),
180 fShishKebabTrd1Modules(geom.fShishKebabTrd1Modules),
89557f6d 181 fNAdditionalOpts(geom.fNAdditionalOpts),
182 fILOSS(geom.fILOSS), fIHADR(geom.fIHADR)
9cff4509 183{
0a4cb131 184 //copy ctor
0a4cb131 185}
186
b13bbe81 187//______________________________________________________________________
188AliEMCALGeometry::~AliEMCALGeometry(void){
189 // dtor
2012850d 190}
395c7ba2 191//______________________________________________________________________
192void AliEMCALGeometry::Init(void){
193 // Initializes the EMCAL parameters
fdebddeb 194 // naming convention : GUV_WX_N_ gives the composition of a tower
395c7ba2 195 // WX inform about the composition of the EM calorimeter section:
fdebddeb 196 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
197 // New geometry: EMCAL_55_25
1963b290 198 // 24-aug-04 for shish-kebab
199 // SHISH_25 or SHISH_62
c63c3c5d 200 // 11-oct-05 - correction for pre final design
201 // Feb 06,2006 - decrease the weight of EMCAL
1d46d1f6 202 //
203 // Oct 30,2006 - SHISH_TRD1_CURRENT_1X1, SHISH_TRD1_CURRENT_2X2 or SHISH_TRD1_CURRENT_3X3;
204 //
fc575e27 205
89557f6d 206 fAdditionalOpts[0] = "nl="; // number of sampling layers (fNECLayers)
207 fAdditionalOpts[1] = "pbTh="; // cm, Thickness of the Pb (fECPbRadThick)
208 fAdditionalOpts[2] = "scTh="; // cm, Thickness of the Sc (fECScintThick)
209 fAdditionalOpts[3] = "latSS="; // cm, Thickness of lateral steel strip (fLateralSteelStrip)
210 fAdditionalOpts[4] = "allILOSS="; // = 0,1,2,3,4 (4 - energy loss without fluctuation)
211 fAdditionalOpts[5] = "allIHADR="; // = 0,1,2 (0 - no hadronic interaction)
fc575e27 212
213 fNAdditionalOpts = sizeof(fAdditionalOpts) / sizeof(char*);
214
fdebddeb 215 fgInit = kFALSE; // Assume failed until proven otherwise.
fc575e27 216 fGeoName = GetName();
217 fGeoName.ToUpper();
d87bd045 218 fKey110DEG = 0;
1d46d1f6 219 if(fGeoName.Contains("110DEG") || fGeoName.Contains("CURRENT")) fKey110DEG = 1; // for GetAbsCellId
e52475ed 220 fShishKebabTrd1Modules = 0;
221 fTrd2AngleY = f2Trd2Dy2 = fEmptySpace = fTubsR = fTubsTurnAngle = 0;
1963b290 222
223 fNZ = 114; // granularity along Z (eta)
224 fNPhi = 168; // granularity in phi (azimuth)
1d46d1f6 225 fArm1PhiMin = 80.0; // degrees, Starting EMCAL Phi position
226 fArm1PhiMax = 190.0; // degrees, Ending EMCAL Phi position
1963b290 227 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
228 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
229 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
905263da 230 fPhiGapForSM = 0.; // cm, only for final TRD1 geometry
e52475ed 231 for(int i=0; i<12; i++) fMatrixOfSM[i] = 0;
1963b290 232
233 // geometry
fc575e27 234 if(fGeoName.Contains("SHISH")){ // Only shahslyk now
905263da 235 // 7-sep-05; integration issue
236 fArm1PhiMin = 80.0; // 60 -> 80
c01485dd 237 fArm1PhiMax = 180.0; // 180 -> 190
905263da 238
239 fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z);
1963b290 240 fSteelFrontThick = 2.54; // 9-sep-04
241 fIPDistance = 460.0;
242 fFrontSteelStrip = fPassiveScintThick = 0.0; // 13-may-05
243 fLateralSteelStrip = 0.025; // before MAY 2005
244 fPhiModuleSize = fEtaModuleSize = 11.4;
245 fPhiTileSize = fEtaTileSize = 5.52; // (11.4-5.52*2)/2. = 0.18 cm (wall thickness)
246 fNPhi = 14;
247 fNZ = 30;
248 fAlFrontThick = fGap2Active = 0;
249 fNPHIdiv = fNETAdiv = 2;
250
251 fNECLayers = 62;
252 fECScintThick = fECPbRadThickness = 0.2;
253 fSampling = 1.; // 30-aug-04 - should be calculated
fc575e27 254 if(fGeoName.Contains("TWIST")) { // all about EMCAL module
1963b290 255 fNZ = 27; // 16-sep-04
fc575e27 256 } else if(fGeoName.Contains("TRD")) {
1963b290 257 fIPDistance = 428.0; // 11-may-05
258 fSteelFrontThick = 0.0; // 3.17 -> 0.0; 28-mar-05 : no stell plate
259 fNPhi = 12;
260 fSampling = 12.327;
261 fPhiModuleSize = fEtaModuleSize = 12.26;
262 fNZ = 26; // 11-oct-04
263 fTrd1Angle = 1.3; // in degree
264// 18-nov-04; 1./0.08112=12.327
265// http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
fc575e27 266 if(fGeoName.Contains("TRD1")) { // 30-jan-05
1963b290 267 // for final design
905263da 268 fPhiGapForSM = 2.; // cm, only for final TRD1 geometry
1d46d1f6 269 if(fGeoName.Contains("MAY05") || fGeoName.Contains("WSUC") || fGeoName.Contains("FINAL") || fGeoName.Contains("CURRENT")){
1963b290 270 fNumberOfSuperModules = 12; // 20-may-05
fc575e27 271 if(fGeoName.Contains("WSUC")) fNumberOfSuperModules = 1; // 27-may-05
1963b290 272 fNECLayers = 77; // (13-may-05 from V.Petrov)
273 fPhiModuleSize = 12.5; // 20-may-05 - rectangular shape
274 fEtaModuleSize = 11.9;
275 fECScintThick = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov)
276 fFrontSteelStrip = 0.025;// 0.025cm = 0.25mm (13-may-05 from V.Petrov)
277 fLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025
278 fPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov)
279 fNZ = 24;
280 fTrd1Angle = 1.5; // 1.3 or 1.5
905263da 281
1d46d1f6 282 if(fGeoName.Contains("FINAL") || fGeoName.Contains("CURRENT")) { // 9-sep-05
905263da 283 fNumberOfSuperModules = 10;
1d46d1f6 284 if(GetKey110DEG()) {
d87bd045 285 fNumberOfSuperModules = 12;// last two modules have size 10 degree in phi (180<phi<190)
1d46d1f6 286 fArm1PhiMax = 200.0; // for XEN1 and turn angle of super modules
287 }
288 if(fGeoName.Contains("FINAL")) {
289 fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption
290 } else if(fGeoName.Contains("CURRENT")) {
291 fECScintThick = 0.176; // 10% of weight reduction
292 fECPbRadThickness = 0.144; //
293 fLateralSteelStrip = 0.015; // 0.015cm = 0.15mm (Oct 30, from Fred)
294 fPhiModuleSize = 12.00;
295 fPhiGapForSM = (12.26 - fPhiModuleSize)*fNPhi; // have to check
d87bd045 296 }
905263da 297 fEtaModuleSize = fPhiModuleSize;
fc575e27 298 if(fGeoName.Contains("HUGE")) fNECLayers *= 3; // 28-oct-05 for analysing leakage
905263da 299 }
1963b290 300 }
fc575e27 301 } else if(fGeoName.Contains("TRD2")) { // 30-jan-05
1963b290 302 fSteelFrontThick = 0.0; // 11-mar-05
303 fIPDistance+= fSteelFrontThick; // 1-feb-05 - compensate absence of steel plate
304 fTrd1Angle = 1.64; // 1.3->1.64
305 fTrd2AngleY = fTrd1Angle; // symmetric case now
306 fEmptySpace = 0.2; // 2 mm
307 fTubsR = fIPDistance; // 31-jan-05 - as for Fred case
308
309 fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
310 fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05
311 fEtaModuleSize = fPhiModuleSize; // 20-may-05
312 fTubsTurnAngle = 3.;
313 }
314 fNPHIdiv = fNETAdiv = 2; // 13-oct-04 - division again
fc575e27 315 if(fGeoName.Contains("3X3")) { // 23-nov-04
1963b290 316 fNPHIdiv = fNETAdiv = 3;
fc575e27 317 } else if(fGeoName.Contains("4X4")) {
1963b290 318 fNPHIdiv = fNETAdiv = 4;
d25f2c54 319 } else if(fGeoName.Contains("1X1")) {
320 fNPHIdiv = fNETAdiv = 1;
1963b290 321 }
322 }
fc575e27 323 if(fGeoName.Contains("25")){
1963b290 324 fNECLayers = 25;
325 fECScintThick = fECPbRadThickness = 0.5;
326 }
fc575e27 327 if(fGeoName.Contains("WSUC")){ // 18-may-05 - about common structure
1963b290 328 fShellThickness = 30.; // should be change
329 fNPhi = fNZ = 4;
330 }
c63c3c5d 331
fc575e27 332 CheckAdditionalOptions();
25b033cf 333 DefineSamplingFraction();
c63c3c5d 334
1d46d1f6 335 fPhiTileSize = fPhiModuleSize/double(fNPHIdiv) - fLateralSteelStrip; // 13-may-05
336 fEtaTileSize = fEtaModuleSize/double(fNETAdiv) - fLateralSteelStrip; // 13-may-05
31b39a2e 337
1963b290 338 // constant for transition absid <--> indexes
2bb3725c 339 fNCellsInModule = fNPHIdiv*fNETAdiv;
340 fNCellsInSupMod = fNCellsInModule*fNPhi*fNZ;
1963b290 341 fNCells = fNCellsInSupMod*fNumberOfSuperModules;
1d46d1f6 342 if(GetKey110DEG()) fNCells -= fNCellsInSupMod;
1963b290 343
344 fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);
fc575e27 345 if(fGeoName.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick);
1963b290 346
347 // 30-sep-04
fc575e27 348 if(fGeoName.Contains("TRD")) {
1963b290 349 f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
fc575e27 350 if(fGeoName.Contains("TRD2")) { // 27-jan-05
1963b290 351 f2Trd2Dy2 = fPhiModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
352 }
353 }
fc575e27 354 } else Fatal("Init", "%s is an undefined geometry!", fGeoName.Data()) ;
fdebddeb 355
1963b290 356 fNPhiSuperModule = fNumberOfSuperModules/2;
357 if(fNPhiSuperModule<1) fNPhiSuperModule = 1;
1d46d1f6 358
fdebddeb 359 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
fc575e27 360 if(fGeoName.Contains("SHISH")) {
1963b290 361 fShellThickness = fSteelFrontThick + fLongModuleSize;
fc575e27 362 if(fGeoName.Contains("TWIST")) { // 13-sep-04
1963b290 363 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + fPhiModuleSize*fEtaModuleSize);
364 fShellThickness += fSteelFrontThick;
fc575e27 365 } else if(fGeoName.Contains("TRD")) { // 1-oct-04
1963b290 366 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
367 fShellThickness += fSteelFrontThick;
e52475ed 368 // Local coordinates
369 fParSM[0] = GetShellThickness()/2.;
370 fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
371 fParSM[2] = 350./2.;
1963b290 372 }
373 }
fdebddeb 374
395c7ba2 375 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
376 fEnvelop[0] = fIPDistance; // mother volume inner radius
377 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
378 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
9cff4509 379
380 fNumberOfSuperModules = 12;
1d46d1f6 381
382 // SM phi boundaries - (0,1),(2,3) .. (10,11) - has the same boundaries; Nov 7, 2006
383 fPhiBoundariesOfSM.Set(fNumberOfSuperModules);
384 fPhiCentersOfSM.Set(fNumberOfSuperModules/2);
385 fPhiBoundariesOfSM[0] = TMath::PiOver2() - TMath::ATan2(fParSM[1] , fIPDistance); // 1th and 2th modules)
386 fPhiBoundariesOfSM[1] = TMath::PiOver2() + TMath::ATan2(fParSM[1] , fIPDistance);
387 fPhiCentersOfSM[0] = TMath::PiOver2();
388 for(int i=1; i<=4; i++) { // from 2th ro 9th
389 fPhiBoundariesOfSM[2*i] = fPhiBoundariesOfSM[0] + 20.*TMath::DegToRad()*i;
390 fPhiBoundariesOfSM[2*i+1] = fPhiBoundariesOfSM[1] + 20.*TMath::DegToRad()*i;
391 fPhiCentersOfSM[i] = fPhiCentersOfSM[0] + 20.*TMath::DegToRad()*i;
392 }
393 fPhiBoundariesOfSM[11] = 190.*TMath::DegToRad();
394 fPhiBoundariesOfSM[10] = fPhiBoundariesOfSM[11] - TMath::ATan2((fParSM[1]) , fIPDistance);
395 fPhiCentersOfSM[5] = (fPhiBoundariesOfSM[10]+fPhiBoundariesOfSM[11])/2.;
396
f0377b23 397 //TRU parameters. These parameters values are not the final ones.
398 fNTRU = 3 ;
399 fNTRUEta = 3 ;
400 fNTRUPhi = 1 ;
1d46d1f6 401
89557f6d 402 // Define TGeoMatrix of SM - Jan 19, 2007 (just fro TRD1)
403 if(fGeoName.Contains("TRD1")) { // copy code from AliEMCALv0::CreateSmod()
404 int nphism = GetNumberOfSuperModules()/2;
405 double dphi = (GetArm1PhiMax() - GetArm1PhiMin())/nphism;
406 double rpos = (GetEnvelop(0) + GetEnvelop(1))/2.;
407 double phi, phiRad, xpos, ypos, zpos;
408 for(int i=0; i<nphism; i++){
409 phi = GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 90, 110, 130, 150, 170, 190
410 phiRad = phi*TMath::Pi()/180.;
411 xpos = rpos * TMath::Cos(phiRad);
412 ypos = rpos * TMath::Sin(phiRad);
413 zpos = fParSM[2];
414 if(i==5) {
415 xpos += (fParSM[1]/2. * TMath::Sin(phiRad));
416 ypos -= (fParSM[1]/2. * TMath::Cos(phiRad));
417 }
418 // pozitive z
419 int ind = 2*i;
420 TGeoRotation *geoRot0 = new TGeoRotation("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
421 fMatrixOfSM[ind] = new TGeoCombiTrans(Form("EmcalSM%2.2i",ind),
422 xpos,ypos, zpos, geoRot0);
423 // negaive z
424 ind++;
425 double phiy = 90. + phi + 180.;
426 if(phiy>=360.) phiy -= 360.;
427 TGeoRotation *geoRot1 = new TGeoRotation("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
428 fMatrixOfSM[ind] = new TGeoCombiTrans(Form("EmcalSM%2.2i",ind),
429 xpos,ypos,-zpos, geoRot1);
430 } // for
431 }
432 fgInit = kTRUE;
433 AliInfo(" is ended");
2012850d 434}
173558f2 435
1d46d1f6 436void AliEMCALGeometry::PrintGeometry()
437{
438 // Separate routine is callable from broswer; Nov 7,2006
89557f6d 439 printf("\nInit: geometry of EMCAL named %s :\n", fGeoName.Data());
440 if(fArrayOpts) {
441 for(Int_t i=0; i<fArrayOpts->GetEntries(); i++){
442 TObjString *o = (TObjString*)fArrayOpts->At(i);
443 printf(" %i : %s \n", i, o->String().Data());
444 }
445 }
1d46d1f6 446 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
447 printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f -> for EMCAL envelope only\n",
448 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
c63c3c5d 449
1d46d1f6 450 printf( " ECAL : %d x (%f cm Pb, %f cm Sc) \n",
451 GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
452 printf(" fSampling %5.2f \n", fSampling );
453 if(fGeoName.Contains("SHISH")){
454 printf(" fIPDistance %6.3f cm \n", fIPDistance);
455 if(fSteelFrontThick>0.)
456 printf(" fSteelFrontThick %6.3f cm \n", fSteelFrontThick);
457 printf(" fNPhi %i | fNZ %i \n", fNPhi, fNZ);
2bb3725c 458 printf(" fNCellsInModule %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInModule, fNCellsInSupMod, fNCells);
1d46d1f6 459 if(fGeoName.Contains("MAY05")){
460 printf(" fFrontSteelStrip %6.4f cm (thickness of front steel strip)\n",
461 fFrontSteelStrip);
462 printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n",
463 fLateralSteelStrip);
464 printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n",
465 fPassiveScintThick);
466 }
467 printf(" X:Y module size %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
468 printf(" X:Y tile size %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
469 printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
470 printf(" fLongModuleSize %6.3f cm \n", fLongModuleSize);
471 printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
472 }
89557f6d 473 printf(" fILOSS %i : fIHADR %i \n", fILOSS, fIHADR);
1d46d1f6 474 if(fGeoName.Contains("TRD")) {
475 printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
476 printf(" f2Trd1Dx2 %7.4f\n", f2Trd1Dx2);
477 if(fGeoName.Contains("TRD2")) {
478 printf(" fTrd2AngleY %7.4f\n", fTrd2AngleY);
479 printf(" f2Trd2Dy2 %7.4f\n", f2Trd2Dy2);
480 printf(" fTubsR %7.2f cm\n", fTubsR);
481 printf(" fTubsTurnAngle %7.4f\n", fTubsTurnAngle);
482 printf(" fEmptySpace %7.4f cm\n", fEmptySpace);
483 } else if(fGeoName.Contains("TRD1")){
484 printf("SM dimensions(TRD1) : dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
485 fParSM[0],fParSM[1],fParSM[2]);
486 printf(" fPhiGapForSM %7.4f cm (%7.4f <- phi size in degree)\n",
487 fPhiGapForSM, TMath::ATan2(fPhiGapForSM,fIPDistance)*TMath::RadToDeg());
488 if(GetKey110DEG()) printf(" Last two modules have size 10 degree in phi (180<phi<190)\n");
489 printf(" phi SM boundaries \n");
490 for(int i=0; i<fPhiBoundariesOfSM.GetSize()/2.; i++) {
491 printf(" %i : %7.5f(%7.2f) -> %7.5f(%7.2f) : center %7.5f(%7.2f) \n", i,
492 fPhiBoundariesOfSM[2*i], fPhiBoundariesOfSM[2*i]*TMath::RadToDeg(),
493 fPhiBoundariesOfSM[2*i+1], fPhiBoundariesOfSM[2*i+1]*TMath::RadToDeg(),
494 fPhiCentersOfSM[i], fPhiCentersOfSM[i]*TMath::RadToDeg());
495 }
496 printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
497 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1);
498
499 printf("\n Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize());
500 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
501 printf(" ind %2.2i : z %8.3f : x %8.3f \n", i,
502 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i));
503 int ind=0; // Nov 21,2006
504 for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
505 ind = iphi*fCentersOfCellsEtaDir.GetSize() + i;
506 printf("%6.4f ", fEtaCentersOfCells[ind]);
507 if((iphi+1)%12 == 0) printf("\n");
508 }
509 printf("\n");
89557f6d 510
511 }
512 printf(" Matrix transformation\n");
513 for(Int_t i=0; i<12; i++) {
514 TGeoMatrix *m = fMatrixOfSM[i];
515 if(m==0) continue;
516 const double *xyz = m->GetTranslation();
517 printf(" %2.2i %s %s x %7.2f y %7.2f z %7.2f\n",
518 i, m->GetName(), m->ClassName(), xyz[0],xyz[1],xyz[2]);
1d46d1f6 519 }
520
521 printf("\n Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize());
522 for(Int_t i=0; i<fCentersOfCellsPhiDir.GetSize(); i++) {
523 double phi=fPhiCentersOfCells.At(i);
524 printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i),
525 phi, phi*TMath::RadToDeg());
526 }
527 }
528 }
89557f6d 529 cout<<endl;
1d46d1f6 530}
531
532void AliEMCALGeometry::PrintCellIndexes(Int_t absId, int pri, char *tit)
533{
534 // Service methods
2bb3725c 535 Int_t nSupMod, nModule, nIphi, nIeta;
1d46d1f6 536 Int_t iphi, ieta;
537 TVector3 vg;
538
2bb3725c 539 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
540 printf(" %s | absId : %i -> nSupMod %i nModule %i nIphi %i nIeta %i \n", tit, absId, nSupMod, nModule, nIphi, nIeta);
1d46d1f6 541 if(pri>0) {
2bb3725c 542 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
1d46d1f6 543 printf(" local SM index : iphi %i : ieta %i \n", iphi,ieta);
544 GetGlobal(absId, vg);
545 printf(" vglob : mag %7.2f : perp %7.2f : z %7.2f : eta %6.4f : phi %6.4f(%6.2f) \n",
546 vg.Mag(), vg.Perp(), vg.Z(), vg.Eta(), vg.Phi(), vg.Phi()*TMath::RadToDeg());
547 }
548}
549
550//______________________________________________________________________
fc575e27 551void AliEMCALGeometry::CheckAdditionalOptions()
552{
553 // Feb 06,2006
89557f6d 554 // Additional options that
555 // can be used to select
556 // the specific geometry of
557 // EMCAL to run
558 // Dec 27,2006
559 // adeed allILOSS= and allIHADR= for MIP investigation
c63c3c5d 560 fArrayOpts = new TObjArray;
fc575e27 561 Int_t nopt = AliEMCALHistoUtilities::ParseString(fGeoName, *fArrayOpts);
c63c3c5d 562 if(nopt==1) { // no aditional option(s)
563 fArrayOpts->Delete();
564 delete fArrayOpts;
565 fArrayOpts = 0;
566 return;
567 }
568 for(Int_t i=1; i<nopt; i++){
569 TObjString *o = (TObjString*)fArrayOpts->At(i);
570
571 TString addOpt = o->String();
572 Int_t indj=-1;
fc575e27 573 for(Int_t j=0; j<fNAdditionalOpts; j++) {
574 TString opt = fAdditionalOpts[j];
c63c3c5d 575 if(addOpt.Contains(opt,TString::kIgnoreCase)) {
576 indj = j;
577 break;
578 }
579 }
580 if(indj<0) {
e5a93224 581 AliDebug(2,Form("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n",
582 addOpt.Data()));
c63c3c5d 583 assert(0);
584 } else {
e5a93224 585 AliDebug(2,Form("<I> option |%s| is valid : number %i : |%s|\n",
586 addOpt.Data(), indj, fAdditionalOpts[indj]));
c63c3c5d 587 if (addOpt.Contains("NL=",TString::kIgnoreCase)) {// number of sampling layers
588 sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
e5a93224 589 AliDebug(2,Form(" fNECLayers %i (new) \n", fNECLayers));
b44d5aa4 590 } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb(fECPbRadThicknes)
c63c3c5d 591 sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
b44d5aa4 592 } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc(fECScintThick)
c63c3c5d 593 sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
b44d5aa4 594 } else if(addOpt.Contains("LATSS=",TString::kIgnoreCase)) {// Thickness of lateral steel strip (fLateralSteelStrip)
595 sscanf(addOpt.Data(),"LATSS=%f", &fLateralSteelStrip);
596 AliDebug(2,Form(" fLateralSteelStrip %f (new) \n", fLateralSteelStrip));
89557f6d 597 } else if(addOpt.Contains("ILOSS=",TString::kIgnoreCase)) {// As in Geant
598 sscanf(addOpt.Data(),"ALLILOSS=%i", &fILOSS);
599 AliDebug(2,Form(" fILOSS %i \n", fILOSS));
600 } else if(addOpt.Contains("IHADR=",TString::kIgnoreCase)) {// As in Geant
601 sscanf(addOpt.Data(),"ALLIHADR=%i", &fIHADR);
602 AliDebug(2,Form(" fIHADR %i \n", fIHADR));
c63c3c5d 603 }
604 }
605 }
606}
607
25b033cf 608void AliEMCALGeometry::DefineSamplingFraction()
609{
610 // Jun 05,2006
611 // Look http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
612 // Keep for compatibilty
613 //
614 if(fNECLayers == 69) { // 10% layer reduction
615 fSampling = 12.55;
616 } else if(fNECLayers == 61) { // 20% layer reduction
617 fSampling = 12.80;
618 } else if(fNECLayers == 77) {
619 if (fECScintThick>0.175 && fECScintThick<0.177) { // 10% Pb thicknes reduction
620 fSampling = 10.5; // fECScintThick = 0.176, fECPbRadThickness=0.144;
621 } else if(fECScintThick>0.191 && fECScintThick<0.193) { // 20% Pb thicknes reduction
622 fSampling = 8.93; // fECScintThick = 0.192, fECPbRadThickness=0.128;
623 }
624 }
625}
626
f0377b23 627//____________________________________________________________________________
356fd0a9 628void AliEMCALGeometry::FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * timeRmatrix) {
f0377b23 629
630
356fd0a9 631// Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
632// Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
633// TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta.
634// Last 2 modules are half size in Phi, I considered that the number of TRU
635// is maintained for the last modules but decision not taken. If different,
636// then this must be changed.
637
f0377b23 638
639 //Check data members
640
641 if(fNTRUEta*fNTRUPhi != fNTRU)
642 Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
643
356fd0a9 644 //Initilize and declare variables
f0377b23 645 //List of TRU matrices initialized to 0.
356fd0a9 646 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
647 Int_t nCellsPhi2 = fNPhi/fNTRUPhi; //HalfSize modules
648 Int_t nCellsEta = fNZ*2/fNTRUEta;
f0377b23 649 Int_t id = -1;
650 Float_t amp = -1;
356fd0a9 651 Float_t timeR = -1;
f0377b23 652 Int_t iSupMod = -1;
2bb3725c 653 Int_t nModule = -1;
f0377b23 654 Int_t nIphi = -1;
655 Int_t nIeta = -1;
656 Int_t iphi = -1;
657 Int_t ieta = -1;
356fd0a9 658
659 //List of TRU matrices initialized to 0.
660 for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){
661 TMatrixD * amptrus = new TMatrixD(nCellsPhi,nCellsEta) ;
662 TMatrixD * timeRtrus = new TMatrixD(nCellsPhi,nCellsEta) ;
663 for(Int_t i = 0; i < nCellsPhi; i++){
664 for(Int_t j = 0; j < nCellsEta; j++){
665 (*amptrus)(i,j) = 0.0;
666 (*timeRtrus)(i,j) = 0.0;
667 }
668 }
669 new((*ampmatrix)[k]) TMatrixD(*amptrus) ;
670 new((*timeRmatrix)[k]) TMatrixD(*timeRtrus) ;
671 }
672
673 AliEMCALDigit * dig ;
f0377b23 674
675 //Digits loop to fill TRU matrices with amplitudes.
f0377b23 676 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
677
678 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
356fd0a9 679 amp = dig->GetAmp() ; // Energy of the digit (arbitrary units)
680 id = dig->GetId() ; // Id label of the cell
681 timeR = dig->GetTimeR() ; // Earliest time of the digit
f0377b23 682
683 //Get eta and phi cell position in supermodule
2bb3725c 684 Bool_t bCell = GetCellIndex(id, iSupMod, nModule, nIphi, nIeta) ;
f0377b23 685 if(!bCell)
686 Error("FillTRU","Wrong cell id number") ;
687
2bb3725c 688 GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
f0377b23 689
690 //Check to which TRU in the supermodule belongs the cell.
691 //Supermodules are divided in a TRU matrix of dimension
692 //(fNTRUPhi,fNTRUEta).
693 //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
694
695 //First calculate the row and column in the supermodule
696 //of the TRU to which the cell belongs.
33d0b833 697 Int_t col = ieta/nCellsEta;
698 Int_t row = iphi/nCellsPhi;
699 if(iSupMod > 9)
700 row = iphi/nCellsPhi2;
356fd0a9 701 //Calculate label number of the TRU
33d0b833 702 Int_t itru = row + col*fNTRUPhi + iSupMod*fNTRU ;
f0377b23 703
704 //Fill TRU matrix with cell values
356fd0a9 705 TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
706 TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
f0377b23 707
356fd0a9 708 //Calculate row and column of the cell inside the TRU with number itru
33d0b833 709 Int_t irow = iphi - row * nCellsPhi;
710 if(iSupMod > 9)
711 irow = iphi - row * nCellsPhi2;
712 Int_t icol = ieta - col * nCellsEta;
f0377b23 713
356fd0a9 714 (*amptrus)(irow,icol) = amp ;
715 (*timeRtrus)(irow,icol) = timeR ;
f0377b23 716
717 }
f0377b23 718}
719
356fd0a9 720//______________________________________________________________________
721void AliEMCALGeometry::GetCellPhiEtaIndexInSModuleFromTRUIndex(const Int_t itru, const Int_t iphitru, const Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const
722{
723
33d0b833 724 // This method transforms the (eta,phi) index of cells in a
356fd0a9 725 // TRU matrix into Super Module (eta,phi) index.
726
33d0b833 727 // Calculate in which row and column where the TRU are
356fd0a9 728 // ordered in the SM
729
33d0b833 730 Int_t col = itru/ fNTRUPhi ;
731 Int_t row = itru - col*fNTRUPhi ;
356fd0a9 732
733 //Calculate the (eta,phi) index in SM
734 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
735 Int_t nCellsEta = fNZ*2/fNTRUEta;
736
33d0b833 737 iphiSM = nCellsPhi*row + iphitru ;
738 ietaSM = nCellsEta*col + ietatru ;
356fd0a9 739}
f0377b23 740
b13bbe81 741//______________________________________________________________________
742AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 743 // Returns the pointer of the unique instance
744
e52475ed 745 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
746 return rv;
2012850d 747}
173558f2 748
b13bbe81 749//______________________________________________________________________
750AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
751 const Text_t* title){
752 // Returns the pointer of the unique instance
753
754 AliEMCALGeometry * rv = 0;
755 if ( fgGeom == 0 ) {
89557f6d 756 if ( strcmp(name,"") == 0 ) { // get default geometry
757 fgGeom = new AliEMCALGeometry(fgDefaultGeometryName, title);
758 } else {
759 fgGeom = new AliEMCALGeometry(name, title);
760 } // end if strcmp(name,"")
761 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
762 else {
763 rv = 0;
764 delete fgGeom;
765 fgGeom = 0;
766 } // end if fgInit
b13bbe81 767 }else{
e5a93224 768 if ( strcmp(fgGeom->GetName(), name) != 0) {
769 printf("\ncurrent geometry is %s : ", fgGeom->GetName());
770 printf(" you cannot call %s ", name);
b13bbe81 771 }else{
9859bfc0 772 rv = (AliEMCALGeometry *) fgGeom;
e52475ed 773 } // end
b13bbe81 774 } // end if fgGeom
775 return rv;
2012850d 776}
173558f2 777
ab37d09c 778Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
dc7da436 779 // Checks whether point is inside the EMCal volume, used in AliEMCALv*.cxx
ab37d09c 780 //
781 // Code uses cylindrical approximation made of inner radius (for speed)
782 //
783 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
784 // are considered to inside
785
786 Double_t r=sqrt(x*x+y*y);
787
788 if ( r > fEnvelop[0] ) {
789 Double_t theta;
790 theta = TMath::ATan2(r,z);
791 Double_t eta;
792 if(theta == 0)
793 eta = 9999;
794 else
795 eta = -TMath::Log(TMath::Tan(theta/2.));
796 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
797 return 0;
798
799 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
800 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
801 return 1;
802 }
803 return 0;
804}
c63c3c5d 805// ==
1963b290 806
807//
808// == Shish-kebab cases ==
809//
2bb3725c 810Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const
dc7da436 811{
812 // 27-aug-04;
d87bd045 813 // corr. 21-sep-04;
814 // 13-oct-05; 110 degree case
dc7da436 815 // May 31, 2006; ALICE numbering scheme:
816 // 0 <= nSupMod < fNumberOfSuperModules
2bb3725c 817 // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
dc7da436 818 // 0 <= nIphi < fNPHIdiv
819 // 0 <= nIeta < fNETAdiv
820 // 0 <= absid < fNCells
821 static Int_t id=0; // have to change from 0 to fNCells-1
822 if(fKey110DEG == 1 && nSupMod >= 10) { // 110 degree case; last two supermodules
823 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-10);
d87bd045 824 } else {
dc7da436 825 id = fNCellsInSupMod*nSupMod;
d87bd045 826 }
2bb3725c 827 id += fNCellsInModule *nModule;
dc7da436 828 id += fNPHIdiv *nIphi;
1963b290 829 id += nIeta;
dc7da436 830 if(id<0 || id >= fNCells) {
500aeccc 831// printf(" wrong numerations !!\n");
832// printf(" id %6i(will be force to -1)\n", id);
833// printf(" fNCells %6i\n", fNCells);
834// printf(" nSupMod %6i\n", nSupMod);
2bb3725c 835// printf(" nModule %6i\n", nModule);
500aeccc 836// printf(" nIphi %6i\n", nIphi);
837// printf(" nIeta %6i\n", nIeta);
dc7da436 838 id = -TMath::Abs(id); // if negative something wrong
1963b290 839 }
840 return id;
841}
842
dc7da436 843Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t absId) const
fc575e27 844{
dc7da436 845 // May 31, 2006; only trd1 now
846 if(absId<0 || absId >= fNCells) return kFALSE;
847 else return kTRUE;
1963b290 848}
849
2bb3725c 850Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const
fc575e27 851{
dc7da436 852 // 21-sep-04; 19-oct-05;
853 // May 31, 2006; ALICE numbering scheme:
4bba84bd 854 //
855 // In:
856 // absId - cell is as in Geant, 0<= absId < fNCells;
857 // Out:
858 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
2bb3725c 859 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
4bba84bd 860 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
861 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
862 //
d87bd045 863 static Int_t tmp=0, sm10=0;
dc7da436 864 if(!CheckAbsCellId(absId)) return kFALSE;
865
d87bd045 866 sm10 = fNCellsInSupMod*10;
dc7da436 867 if(fKey110DEG == 1 && absId >= sm10) { // 110 degree case; last two supermodules
868 nSupMod = (absId-sm10) / (fNCellsInSupMod/2) + 10;
869 tmp = (absId-sm10) % (fNCellsInSupMod/2);
d87bd045 870 } else {
dc7da436 871 nSupMod = absId / fNCellsInSupMod;
872 tmp = absId % fNCellsInSupMod;
d87bd045 873 }
1963b290 874
2bb3725c 875 nModule = tmp / fNCellsInModule;
876 tmp = tmp % fNCellsInModule;
dc7da436 877 nIphi = tmp / fNPHIdiv;
878 nIeta = tmp % fNPHIdiv;
1963b290 879
880 return kTRUE;
881}
882
2bb3725c 883void AliEMCALGeometry::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, int &iphim, int &ietam) const
fc575e27 884{
1d46d1f6 885 // added nSupMod; - 19-oct-05 !
dc7da436 886 // Alice numbering scheme - Jun 01,2006
1d46d1f6 887 // ietam, iphi - indexes of module in two dimensional grid of SM
888 // ietam - have to change from 0 to fNZ-1
889 // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1)
d87bd045 890 static Int_t nphi;
891
dc7da436 892 if(fKey110DEG == 1 && nSupMod>=10) nphi = fNPhi/2;
d87bd045 893 else nphi = fNPhi;
894
2bb3725c 895 ietam = nModule/nphi;
896 iphim = nModule%nphi;
d87bd045 897}
898
2bb3725c 899void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta,
e52475ed 900int &iphi, int &ieta) const
fc575e27 901{
1d46d1f6 902 //
903 // Added nSupMod; Nov 25, 05
904 // Alice numbering scheme - Jun 01,2006
4bba84bd 905 // IN:
906 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
2bb3725c 907 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
4bba84bd 908 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
909 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
910 //
911 // OUT:
1d46d1f6 912 // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM
913 // ieta - have to change from 0 to (fNZ*fNETAdiv-1)
914 // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1)
915 //
dc7da436 916 static Int_t iphim, ietam;
917
2bb3725c 918 GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam);
1d46d1f6 919 // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM)
920 ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM)
dc7da436 921 iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM)
1d46d1f6 922
923 if(iphi<0 || ieta<0)
2bb3725c 924 AliDebug(1,Form(" nSupMod %i nModule %i nIphi %i nIeta %i => ieta %i iphi %i\n",
925 nSupMod, nModule, nIphi, nIeta, ieta, iphi));
1963b290 926}
e52475ed 927
928Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const
929{
1d46d1f6 930 // Return the number of the supermodule given the absolute
931 // ALICE numbering id
fc575e27 932
2bb3725c 933 static Int_t nSupMod, nModule, nIphi, nIeta;
934 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
e52475ed 935 return nSupMod;
936}
937
1d46d1f6 938void AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
2bb3725c 939 Int_t &iphim, Int_t &ietam, Int_t &nModule) const
1d46d1f6 940{
2bb3725c 941 // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
1d46d1f6 942 static Int_t nphi;
943 nphi = GetNumberOfModuleInPhiDirection(nSupMod);
944
945 ietam = ieta/fNETAdiv;
946 iphim = iphi/fNPHIdiv;
2bb3725c 947 nModule = ietam * nphi + iphim;
1d46d1f6 948}
949
950Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
951{
952 // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId
2bb3725c 953 static Int_t ietam, iphim, nModule;
1d46d1f6 954 static Int_t nIeta, nIphi; // cell indexes in module
955
2bb3725c 956 GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule);
1d46d1f6 957
958 nIeta = ieta%fNETAdiv;
959 nIeta = fNETAdiv - 1 - nIeta;
960 nIphi = iphi%fNPHIdiv;
961
2bb3725c 962 return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
1d46d1f6 963}
964
965
e52475ed 966// Methods for AliEMCALRecPoint - Feb 19, 2006
14e75ea7 967Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const
e52475ed 968{
1933eff2 969 // Look to see what the relative
970 // position inside a given cell is
971 // for a recpoint.
972 // Alice numbering scheme - Jun 08, 2006
4bba84bd 973 // In:
974 // absId - cell is as in Geant, 0<= absId < fNCells;
975 // OUT:
976 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
fc575e27 977
d25f2c54 978 // Shift index taking into account the difference between standard SM
979 // and SM of half size in phi direction
980 const Int_t phiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
2bb3725c 981 static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta;
e52475ed 982 if(!CheckAbsCellId(absId)) return kFALSE;
983
2bb3725c 984 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
985 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
e52475ed 986
1d46d1f6 987 xr = fCentersOfCellsXDir.At(ieta);
988 zr = fCentersOfCellsEtaDir.At(ieta);
e52475ed 989
1933eff2 990 if(nSupMod<10) {
1d46d1f6 991 yr = fCentersOfCellsPhiDir.At(iphi);
1933eff2 992 } else {
1d46d1f6 993 yr = fCentersOfCellsPhiDir.At(iphi + phiIndexShift);
1933eff2 994 }
d25f2c54 995 AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
e52475ed 996
e52475ed 997 return kTRUE;
998}
999
14e75ea7 1000Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const
1001{
1002 // Alice numbering scheme - Jun 03, 2006
1003 loc[0] = loc[1] = loc[2]=0.0;
1004 if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) {
1005 return kTRUE;
1006 }
1007 return kFALSE;
1008}
1009
1010Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, TVector3 &vloc) const
1011{
1012 static Double_t loc[3];
1013 if(RelPosCellInSModule(absId,loc)) {
1014 vloc.SetXYZ(loc[0], loc[1], loc[2]);
1015 return kTRUE;
1016 } else {
1017 vloc.SetXYZ(0,0,0);
1018 return kFALSE;
1019 }
1020 // Alice numbering scheme - Jun 03, 2006
1021}
1022
e52475ed 1023void AliEMCALGeometry::CreateListOfTrd1Modules()
1024{
1d46d1f6 1025 // Generate the list of Trd1 modules
1026 // which will make up the EMCAL
1027 // geometry
fc575e27 1028
e5a93224 1029 AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started "));
1030
e52475ed 1031 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
1032 if(fShishKebabTrd1Modules == 0) {
1033 fShishKebabTrd1Modules = new TList;
1d46d1f6 1034 fShishKebabTrd1Modules->SetName("ListOfTRD1");
e52475ed 1035 for(int iz=0; iz< GetNZ(); iz++) {
1036 if(iz==0) {
1037 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
1038 } else {
1039 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
1040 mod = mTmp;
1041 }
1042 fShishKebabTrd1Modules->Add(mod);
1043 }
1044 } else {
e5a93224 1045 AliDebug(2,Form(" Already exits : "));
e52475ed 1046 }
1d46d1f6 1047 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1);
1048 fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0);
1049
1050 AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
1051 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1));
e52475ed 1052 // Feb 20,2006;
dc7da436 1053 // Jun 01, 2006 - ALICE numbering scheme
e52475ed 1054 // define grid for cells in eta(z) and x directions in local coordinates system of SM
1d46d1f6 1055 // Works just for 2x2 case only -- ?? start here
1056 //
1057 //
1058 // Define grid for cells in phi(y) direction in local coordinates system of SM
1059 // as for 2X2 as for 3X3 - Nov 8,2006
1060 //
1061 AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize()));
1062 Int_t ind=0; // this is phi index
85327f24 1063 Int_t ieta=0, nModule=0, iphiTemp;
1d46d1f6 1064 Double_t xr, zr, theta, phi, eta, r, x,y;
1065 TVector3 vglob;
85327f24 1066 Double_t ytCenterModule=0.0, ytCenterCell=0.0;
1d46d1f6 1067
1068 fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv);
1069 fPhiCentersOfCells.Set(fNPhi*fNPHIdiv);
1070
1071 Double_t R0 = GetIPDistance() + GetLongModuleSize()/2.;
1072 for(Int_t it=0; it<fNPhi; it++) { // cycle on modules
1073 ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module
1074 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module
1075 if(fNPHIdiv==2) {
1076 ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.;
1077 } else if(fNPHIdiv==3){
1078 ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1);
d25f2c54 1079 } else if(fNPHIdiv==1){
1080 ytCenterCell = ytCenterModule;
1d46d1f6 1081 }
1082 fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind);
1083 // Define grid on phi direction
1084 // Grid is not the same for different eta bin;
1085 // Effect is small but is still here
1086 phi = TMath::ATan2(ytCenterCell, R0);
1087 fPhiCentersOfCells.AddAt(phi, ind);
1088
1089 AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind)));
1090 ind++;
1091 }
1092 }
1093
1094 fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv);
1095 fCentersOfCellsXDir.Set(fNZ *fNETAdiv);
1096 fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv);
1097 AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()));
1098 for(Int_t it=0; it<fNZ; it++) {
e52475ed 1099 AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
2bb3725c 1100 nModule = fNPhi*it;
1d46d1f6 1101 for(Int_t ic=0; ic<fNETAdiv; ic++) {
1102 if(fNPHIdiv==2) {
d25f2c54 1103 trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2
2bb3725c 1104 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
1d46d1f6 1105 } if(fNPHIdiv==3) {
1106 trd1->GetCenterOfCellInLocalCoordinateofSM_3X3(ic, xr, zr); // case of 3X3
2bb3725c 1107 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
d25f2c54 1108 } if(fNPHIdiv==1) {
1109 trd1->GetCenterOfCellInLocalCoordinateofSM_1X1(xr, zr); // case of 1X1
2bb3725c 1110 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
1d46d1f6 1111 }
d25f2c54 1112 fCentersOfCellsXDir.AddAt(float(xr) - fParSM[0],ieta);
1113 fCentersOfCellsEtaDir.AddAt(float(zr) - fParSM[2],ieta);
1d46d1f6 1114 // Define grid on eta direction for each bin in phi
1115 for(int iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
1116 x = xr + trd1->GetRadius();
1117 y = fCentersOfCellsPhiDir[iphi];
1118 r = TMath::Sqrt(x*x + y*y + zr*zr);
1119 theta = TMath::ACos(zr/r);
1120 eta = AliEMCALShishKebabTrd1Module::ThetaToEta(theta);
1121 // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi;
1122 ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta;
1123 fEtaCentersOfCells.AddAt(eta, ind);
1124 }
1125 //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta);
e52475ed 1126 }
1127 }
1d46d1f6 1128 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
e5a93224 1129 AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1,
1d46d1f6 1130 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)));
e52475ed 1131 }
e5a93224 1132
e52475ed 1133}
1134
1135void AliEMCALGeometry::GetTransformationForSM()
1136{
fc575e27 1137 //Uses the geometry manager to
1138 //load the transformation matrix
1139 //for the supermodules
89557f6d 1140 // Unused after 19 Jan, 2007 - keep for compatibility;
fc575e27 1141
89557f6d 1142 return;
e52475ed 1143 static Bool_t transInit=kFALSE;
1144 if(transInit) return;
1145
1146 int i=0;
1147 if(gGeoManager == 0) {
1148 Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()");
1149 assert(0);
1150 }
1151 TGeoNode *tn = gGeoManager->GetTopNode();
fc575e27 1152 TGeoNode *node=0, *xen1 = 0;
e52475ed 1153 for(i=0; i<tn->GetNdaughters(); i++) {
1154 node = tn->GetDaughter(i);
1155 TString ns(node->GetName());
1156 if(ns.Contains(GetNameOfEMCALEnvelope())) {
fc575e27 1157 xen1 = node;
e52475ed 1158 break;
1159 }
1160 }
fc575e27 1161 if(!xen1) {
e52475ed 1162 Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s",
1163 GetNameOfEMCALEnvelope());
1164 assert(0);
1165 }
fc575e27 1166 printf(" i %i : EMCAL Envelope is %s : #SM %i \n", i, xen1->GetName(), xen1->GetNdaughters());
1167 for(i=0; i<xen1->GetNdaughters(); i++) {
1168 TGeoNodeMatrix *sm = (TGeoNodeMatrix*)xen1->GetDaughter(i);
e52475ed 1169 fMatrixOfSM[i] = sm->GetMatrix();
64942713 1170 //Compiler doesn't like this syntax...
1171 // printf(" %i : matrix %x \n", i, fMatrixOfSM[i]);
e52475ed 1172 }
1173 transInit = kTRUE;
1174}
1175
14e75ea7 1176void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
e52475ed 1177{
14e75ea7 1178 // Figure out the global numbering
1179 // of a given supermodule from the
1180 // local numbering
1181 // Alice numbering - Jun 03,2006
e52475ed 1182 // if(fMatrixOfSM[0] == 0) GetTransformationForSM();
14e75ea7 1183
e52475ed 1184 if(ind>=0 && ind < GetNumberOfSuperModules()) {
1185 fMatrixOfSM[ind]->LocalToMaster(loc, glob);
1186 }
1187}
1188
25b033cf 1189void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const
1190{
1191 //Figure out the global numbering
1192 //of a given supermodule from the
1193 //local numbering given a 3-vector location
1194
1195 static Double_t tglob[3], tloc[3];
1196 vloc.GetXYZ(tloc);
1197 GetGlobal(tloc, tglob, ind);
1198 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
1199}
1200
14e75ea7 1201void AliEMCALGeometry::GetGlobal(Int_t absId , double glob[3]) const
1202{
1203 // Alice numbering scheme - Jun 03, 2006
1204 static Int_t nSupMod, nModule, nIphi, nIeta;
1205 static double loc[3];
1206
1207 glob[0]=glob[1]=glob[2]=0.0; // bad case
1208 if(RelPosCellInSModule(absId, loc)) {
1209 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
1210 fMatrixOfSM[nSupMod]->LocalToMaster(loc, glob);
1211 }
e52475ed 1212}
1213
14e75ea7 1214void AliEMCALGeometry::GetGlobal(Int_t absId , TVector3 &vglob) const
1215{
1216 // Alice numbering scheme - Jun 03, 2006
1217 static Double_t glob[3];
1218
1219 GetGlobal(absId, glob);
1220 vglob.SetXYZ(glob[0], glob[1], glob[2]);
1221
1222}
1223
e52475ed 1224void AliEMCALGeometry::GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const
1225{
664bfd66 1226 // Figure out the global numbering
1227 // of a given supermodule from the
1228 // local numbering for RecPoints
fc575e27 1229
e52475ed 1230 static TVector3 vloc;
14e75ea7 1231 static Int_t nSupMod, nModule, nIphi, nIeta;
e52475ed 1232
1233 AliRecPoint *rpTmp = (AliRecPoint*)rp; // const_cast ??
1234 if(!rpTmp) return;
1235 AliEMCALRecPoint *rpEmc = (AliEMCALRecPoint*)rpTmp;
1236
14e75ea7 1237 GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nModule, nIphi, nIeta);
e52475ed 1238 rpTmp->GetLocalPosition(vloc);
1239 GetGlobal(vloc, vglob, nSupMod);
1240}
1241
1d46d1f6 1242void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Double_t &eta,Double_t &phi) const
664bfd66 1243{
1d46d1f6 1244 // Nov 16, 2006- float to double
1245 // version for TRD1 only
664bfd66 1246 static TVector3 vglob;
1247 GetGlobal(absId, vglob);
1248 eta = vglob.Eta();
1249 phi = vglob.Phi();
1250}
1251
1d46d1f6 1252void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const
1253{
1254 // Nov 16,2006 - should be discard in future
1255 static TVector3 vglob;
1256 GetGlobal(absId, vglob);
1257 eta = float(vglob.Eta());
1258 phi = float(vglob.Phi());
1259}
1260
1261Bool_t AliEMCALGeometry::GetPhiBoundariesOfSM(Int_t nSupMod, Double_t &phiMin, Double_t &phiMax) const
1262{
1263 // 0<= nSupMod <=11; phi in rad
1264 static int i;
1265 if(nSupMod<0 || nSupMod >11) return kFALSE;
1266 i = nSupMod/2;
1267 phiMin = fPhiBoundariesOfSM[2*i];
1268 phiMax = fPhiBoundariesOfSM[2*i+1];
1269 return kTRUE;
1270}
1271
1272Bool_t AliEMCALGeometry::GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const
1273{
1274 // 0<= nPhiSec <=4; phi in rad
1275 // 0; gap boundaries between 0th&2th | 1th&3th SM
1276 // 1; gap boundaries between 2th&4th | 3th&5th SM
1277 // 2; gap boundaries between 4th&6th | 5th&7th SM
1278 // 3; gap boundaries between 6th&8th | 7th&9th SM
1279 // 4; gap boundaries between 8th&10th | 9th&11th SM
1280 if(nPhiSec<0 || nPhiSec >4) return kFALSE;
1281 phiMin = fPhiBoundariesOfSM[2*nPhiSec+1];
1282 phiMax = fPhiBoundariesOfSM[2*nPhiSec+2];
1283 return kTRUE;
1284}
1285
1286Bool_t AliEMCALGeometry::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const
1287{
1288 // Return false if phi belongs a phi cracks between SM
1289
1290 static Int_t i;
1291
1292 if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE;
1293
1294 phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
1295 for(i=0; i<6; i++) {
1296 if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) {
1297 nSupMod = 2*i;
1298 if(eta < 0.0) nSupMod++;
d25f2c54 1299 AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i));
1d46d1f6 1300 return kTRUE;
1301 }
1302 }
1d46d1f6 1303 return kFALSE;
1304}
1305
1306Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const
1307{
1308 // Nov 17,2006
1309 // stay here - phi problem as usual
1310 static Int_t nSupMod, i, ieta, iphi, etaShift, nphi;
1311 static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc;
1312 absId = nSupMod = - 1;
1313 if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
1314 // phi index first
1315 phi = TVector2::Phi_0_2pi(phi);
1316 phiLoc = phi - fPhiCentersOfSM[nSupMod/2];
1317 nphi = fPhiCentersOfCells.GetSize();
1318 if(nSupMod>=10) {
1319 phiLoc = phi - 190.*TMath::DegToRad();
1320 nphi /= 2;
1321 }
1322
1323 dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc);
1324 iphi = 0;
1325 for(i=1; i<nphi; i++) {
1326 d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc);
1327 if(d < dmin) {
1328 dmin = d;
1329 iphi = i;
1330 }
1331 // printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]);
1332 }
1333 // odd SM are turned with respect of even SM - reverse indexes
1334 AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc));
1335 // eta index
1336 absEta = TMath::Abs(eta);
1337 etaShift = iphi*fCentersOfCellsEtaDir.GetSize();
1338 dmin = TMath::Abs(fEtaCentersOfCells[etaShift]-absEta);
1339 ieta = 0;
1340 for(i=1; i<fCentersOfCellsEtaDir.GetSize(); i++) {
1341 d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta);
1342 if(d < dmin) {
1343 dmin = d;
1344 ieta = i;
1345 }
1346 }
1347 AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod));
1348
1349 if(eta<0) iphi = (nphi-1) - iphi;
1350 absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
1351
1352 return kTRUE;
1353 }
1354 return kFALSE;
1355}
1356
1357AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta)
fc575e27 1358{
1359 //This method was too long to be
1360 //included in the header file - the
1361 //rule checker complained about it's
1362 //length, so we move it here. It returns the
1363 //shishkebabmodule at a given eta index point.
1364
1365 static AliEMCALShishKebabTrd1Module* trd1=0;
1366 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
1367 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);
1368 } else trd1 = 0;
1369 return trd1;
1370}
1d46d1f6 1371
1372void AliEMCALGeometry::Browse(TBrowser* b)
1373{
1374 if(fShishKebabTrd1Modules) b->Add(fShishKebabTrd1Modules);
89557f6d 1375 for(int i=0; i<fNumberOfSuperModules; i++) {
1376 if(fMatrixOfSM[i]) b->Add(fMatrixOfSM[i]);
1377 }
1d46d1f6 1378}
1379
1380Bool_t AliEMCALGeometry::IsFolder() const
1381{
1382 if(fShishKebabTrd1Modules) return kTRUE;
1383 else return kFALSE;
1384}