Coding conventions and fixes (M.Masera,D.Elia)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.cxx
CommitLineData
e52475ed 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
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>
e52475ed 34#include "Riostream.h"
35
ca8f5bd0 36#include <TMath.h>
116cbefd 37#include <TVector3.h>
e52475ed 38#include <TArrayD.h>
c63c3c5d 39#include <TObjArray.h>
e52475ed 40#include <TGeoManager.h>
41#include <TGeoNode.h>
42#include <TGeoMatrix.h>
f0377b23 43#include <TMatrixD.h>
d434833b 44#include <TObjString.h>
f0377b23 45#include <TClonesArray.h>
173558f2 46
ca8f5bd0 47// -- ALICE Headers.
d64c959b 48//#include "AliConst.h"
173558f2 49
ca8f5bd0 50// --- EMCAL headers
51#include "AliEMCALGeometry.h"
e52475ed 52#include "AliEMCALShishKebabTrd1Module.h"
e52475ed 53#include "AliEMCALRecPoint.h"
f0377b23 54#include "AliEMCALDigit.h"
d434833b 55#include "AliEMCALHistoUtilities.h"
56#include "AliEMCALAlignData.h"
2012850d 57
925e6570 58ClassImp(AliEMCALGeometry)
2012850d 59
d434833b 60// these initialisations are needed for a singleton
61AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
62Bool_t AliEMCALGeometry::fgInit = kFALSE;
63AliEMCALAlignData *AliEMCALGeometry::fgAlignData = 0;
64
b13bbe81 65//______________________________________________________________________
66AliEMCALGeometry::~AliEMCALGeometry(void){
67 // dtor
2012850d 68}
395c7ba2 69//______________________________________________________________________
70void AliEMCALGeometry::Init(void){
71 // Initializes the EMCAL parameters
fdebddeb 72 // naming convention : GUV_WX_N_ gives the composition of a tower
395c7ba2 73 // WX inform about the composition of the EM calorimeter section:
fdebddeb 74 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
75 // New geometry: EMCAL_55_25
1963b290 76 // 24-aug-04 for shish-kebab
77 // SHISH_25 or SHISH_62
c63c3c5d 78 // 11-oct-05 - correction for pre final design
79 // Feb 06,2006 - decrease the weight of EMCAL
fc575e27 80
81 fAdditionalOpts[0] = "nl="; // number of sampling layers
82 fAdditionalOpts[1] = "pbTh="; // cm, Thickness of the Pb
83 fAdditionalOpts[2] = "scTh="; // cm, Thickness of the Sc
84
85 fNAdditionalOpts = sizeof(fAdditionalOpts) / sizeof(char*);
86
fdebddeb 87 fgInit = kFALSE; // Assume failed until proven otherwise.
fc575e27 88 fGeoName = GetName();
89 fGeoName.ToUpper();
d87bd045 90 fKey110DEG = 0;
fc575e27 91 if(fGeoName.Contains("110DEG")) fKey110DEG = 1; // for GetAbsCellId
e52475ed 92 fShishKebabTrd1Modules = 0;
93 fTrd2AngleY = f2Trd2Dy2 = fEmptySpace = fTubsR = fTubsTurnAngle = 0;
1963b290 94
95 fNZ = 114; // granularity along Z (eta)
96 fNPhi = 168; // granularity in phi (azimuth)
97 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
98 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
99 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
100 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
101 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
905263da 102 fPhiGapForSM = 0.; // cm, only for final TRD1 geometry
e52475ed 103 for(int i=0; i<12; i++) fMatrixOfSM[i] = 0;
1963b290 104
105 // geometry
fc575e27 106 if(fGeoName.Contains("SHISH")){ // Only shahslyk now
905263da 107 // 7-sep-05; integration issue
108 fArm1PhiMin = 80.0; // 60 -> 80
c01485dd 109 fArm1PhiMax = 180.0; // 180 -> 190
905263da 110
111 fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z);
1963b290 112 fSteelFrontThick = 2.54; // 9-sep-04
113 fIPDistance = 460.0;
114 fFrontSteelStrip = fPassiveScintThick = 0.0; // 13-may-05
115 fLateralSteelStrip = 0.025; // before MAY 2005
116 fPhiModuleSize = fEtaModuleSize = 11.4;
117 fPhiTileSize = fEtaTileSize = 5.52; // (11.4-5.52*2)/2. = 0.18 cm (wall thickness)
118 fNPhi = 14;
119 fNZ = 30;
120 fAlFrontThick = fGap2Active = 0;
121 fNPHIdiv = fNETAdiv = 2;
122
123 fNECLayers = 62;
124 fECScintThick = fECPbRadThickness = 0.2;
125 fSampling = 1.; // 30-aug-04 - should be calculated
fc575e27 126 if(fGeoName.Contains("TWIST")) { // all about EMCAL module
1963b290 127 fNZ = 27; // 16-sep-04
fc575e27 128 } else if(fGeoName.Contains("TRD")) {
1963b290 129 fIPDistance = 428.0; // 11-may-05
130 fSteelFrontThick = 0.0; // 3.17 -> 0.0; 28-mar-05 : no stell plate
131 fNPhi = 12;
132 fSampling = 12.327;
133 fPhiModuleSize = fEtaModuleSize = 12.26;
134 fNZ = 26; // 11-oct-04
135 fTrd1Angle = 1.3; // in degree
136// 18-nov-04; 1./0.08112=12.327
137// http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
fc575e27 138 if(fGeoName.Contains("TRD1")) { // 30-jan-05
1963b290 139 // for final design
905263da 140 fPhiGapForSM = 2.; // cm, only for final TRD1 geometry
fc575e27 141 if(fGeoName.Contains("MAY05") || fGeoName.Contains("WSUC") || fGeoName.Contains("FINAL")){
1963b290 142 fNumberOfSuperModules = 12; // 20-may-05
fc575e27 143 if(fGeoName.Contains("WSUC")) fNumberOfSuperModules = 1; // 27-may-05
1963b290 144 fNECLayers = 77; // (13-may-05 from V.Petrov)
145 fPhiModuleSize = 12.5; // 20-may-05 - rectangular shape
146 fEtaModuleSize = 11.9;
147 fECScintThick = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov)
148 fFrontSteelStrip = 0.025;// 0.025cm = 0.25mm (13-may-05 from V.Petrov)
149 fLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025
150 fPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov)
151 fNZ = 24;
152 fTrd1Angle = 1.5; // 1.3 or 1.5
905263da 153
fc575e27 154 if(fGeoName.Contains("FINAL")) { // 9-sep-05
905263da 155 fNumberOfSuperModules = 10;
fc575e27 156 if(fGeoName.Contains("110DEG")) {
d87bd045 157 fNumberOfSuperModules = 12;// last two modules have size 10 degree in phi (180<phi<190)
158 fArm1PhiMax = 200.0; // for XEN1 and turn angle of super modules
159 }
905263da 160 fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption
161 fEtaModuleSize = fPhiModuleSize;
fc575e27 162 if(fGeoName.Contains("HUGE")) fNECLayers *= 3; // 28-oct-05 for analysing leakage
905263da 163 }
1963b290 164 }
fc575e27 165 } else if(fGeoName.Contains("TRD2")) { // 30-jan-05
1963b290 166 fSteelFrontThick = 0.0; // 11-mar-05
167 fIPDistance+= fSteelFrontThick; // 1-feb-05 - compensate absence of steel plate
168 fTrd1Angle = 1.64; // 1.3->1.64
169 fTrd2AngleY = fTrd1Angle; // symmetric case now
170 fEmptySpace = 0.2; // 2 mm
171 fTubsR = fIPDistance; // 31-jan-05 - as for Fred case
172
173 fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
174 fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05
175 fEtaModuleSize = fPhiModuleSize; // 20-may-05
176 fTubsTurnAngle = 3.;
177 }
178 fNPHIdiv = fNETAdiv = 2; // 13-oct-04 - division again
fc575e27 179 if(fGeoName.Contains("3X3")) { // 23-nov-04
1963b290 180 fNPHIdiv = fNETAdiv = 3;
fc575e27 181 } else if(fGeoName.Contains("4X4")) {
1963b290 182 fNPHIdiv = fNETAdiv = 4;
183 }
184 }
185 fPhiTileSize = fPhiModuleSize/2. - fLateralSteelStrip; // 13-may-05
186 fEtaTileSize = fEtaModuleSize/2. - fLateralSteelStrip; // 13-may-05
187
fc575e27 188 if(fGeoName.Contains("25")){
1963b290 189 fNECLayers = 25;
190 fECScintThick = fECPbRadThickness = 0.5;
191 }
fc575e27 192 if(fGeoName.Contains("WSUC")){ // 18-may-05 - about common structure
1963b290 193 fShellThickness = 30.; // should be change
194 fNPhi = fNZ = 4;
195 }
c63c3c5d 196
fc575e27 197 CheckAdditionalOptions();
c63c3c5d 198
1963b290 199 // constant for transition absid <--> indexes
200 fNCellsInTower = fNPHIdiv*fNETAdiv;
201 fNCellsInSupMod = fNCellsInTower*fNPhi*fNZ;
202 fNCells = fNCellsInSupMod*fNumberOfSuperModules;
fc575e27 203 if(fGeoName.Contains("110DEG")) fNCells -= fNCellsInSupMod;
1963b290 204
205 fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);
fc575e27 206 if(fGeoName.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick);
1963b290 207
208 // 30-sep-04
fc575e27 209 if(fGeoName.Contains("TRD")) {
1963b290 210 f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
fc575e27 211 if(fGeoName.Contains("TRD2")) { // 27-jan-05
1963b290 212 f2Trd2Dy2 = fPhiModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
213 }
214 }
fc575e27 215 } else Fatal("Init", "%s is an undefined geometry!", fGeoName.Data()) ;
fdebddeb 216
1963b290 217 fNPhiSuperModule = fNumberOfSuperModules/2;
218 if(fNPhiSuperModule<1) fNPhiSuperModule = 1;
fdebddeb 219 //There is always one more scintillator than radiator layer because of the first block of aluminium
220 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
fc575e27 221 if(fGeoName.Contains("SHISH")) {
1963b290 222 fShellThickness = fSteelFrontThick + fLongModuleSize;
fc575e27 223 if(fGeoName.Contains("TWIST")) { // 13-sep-04
1963b290 224 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + fPhiModuleSize*fEtaModuleSize);
225 fShellThickness += fSteelFrontThick;
fc575e27 226 } else if(fGeoName.Contains("TRD")) { // 1-oct-04
1963b290 227 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
228 fShellThickness += fSteelFrontThick;
e52475ed 229 // Local coordinates
230 fParSM[0] = GetShellThickness()/2.;
231 fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
232 fParSM[2] = 350./2.;
1963b290 233 }
234 }
fdebddeb 235
395c7ba2 236 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
237 fEnvelop[0] = fIPDistance; // mother volume inner radius
238 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
239 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
240
d434833b 241 if(fgAlignData != NULL) {
242 // Number of modules is read from Alignment DB if exists
243 fNumberOfSuperModules = fgAlignData->GetNSuperModules();
244 }
245
395c7ba2 246 fgInit = kTRUE;
247
1963b290 248 if (kTRUE) {
fc575e27 249 printf("Init: geometry of EMCAL named %s is as follows:\n", fGeoName.Data());
e52475ed 250 printf( " ECAL : %d x (%f cm Pb, %f cm Sc) \n",
251 GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
252 printf(" fSampling %5.2f \n", fSampling );
fc575e27 253 if(fGeoName.Contains("SHISH")){
1963b290 254 printf(" fIPDistance %6.3f cm \n", fIPDistance);
255 if(fSteelFrontThick>0.)
256 printf(" fSteelFrontThick %6.3f cm \n", fSteelFrontThick);
257 printf(" fNPhi %i | fNZ %i \n", fNPhi, fNZ);
d87bd045 258 printf(" fNCellsInTower %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInTower, fNCellsInSupMod, fNCells);
fc575e27 259 if(fGeoName.Contains("MAY05")){
1963b290 260 printf(" fFrontSteelStrip %6.4f cm (thickness of front steel strip)\n",
261 fFrontSteelStrip);
262 printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n",
263 fLateralSteelStrip);
264 printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n",
265 fPassiveScintThick);
266 }
c63c3c5d 267 printf(" X:Y module size %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
268 printf(" X:Y tile size %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
269 printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
270 printf(" fLongModuleSize %6.3f cm \n", fLongModuleSize);
1963b290 271 printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
272 }
fc575e27 273 if(fGeoName.Contains("TRD")) {
1963b290 274 printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
275 printf(" f2Trd1Dx2 %7.4f\n", f2Trd1Dx2);
fc575e27 276 if(fGeoName.Contains("TRD2")) {
1963b290 277 printf(" fTrd2AngleY %7.4f\n", fTrd2AngleY);
278 printf(" f2Trd2Dy2 %7.4f\n", f2Trd2Dy2);
905263da 279 printf(" fTubsR %7.2f cm\n", fTubsR);
1963b290 280 printf(" fTubsTurnAngle %7.4f\n", fTubsTurnAngle);
905263da 281 printf(" fEmptySpace %7.4f cm\n", fEmptySpace);
fc575e27 282 } else if(fGeoName.Contains("TRD1") && fGeoName.Contains("FINAL")){
e52475ed 283 printf("SM dimensions(TRD1) : dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
284 fParSM[0],fParSM[1],fParSM[2]);
905263da 285 printf(" fPhiGapForSM %7.4f cm \n", fPhiGapForSM);
fc575e27 286 if(fGeoName.Contains("110DEG"))printf(" Last two modules have size 10 degree in phi (180<phi<190)\n");
1963b290 287 }
288 }
88cb7938 289 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
1963b290 290 printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f\n",
291 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
88cb7938 292 }
f0377b23 293 //TRU parameters. These parameters values are not the final ones.
294 fNTRU = 3 ;
295 fNTRUEta = 3 ;
296 fNTRUPhi = 1 ;
2012850d 297}
173558f2 298
b13bbe81 299//______________________________________________________________________
c63c3c5d 300
fc575e27 301void AliEMCALGeometry::CheckAdditionalOptions()
302{
303 // Feb 06,2006
304 //Additional options that
305 //can be used to select
306 //the specific geometry of
307 //EMCAL to run
308
c63c3c5d 309 fArrayOpts = new TObjArray;
fc575e27 310 Int_t nopt = AliEMCALHistoUtilities::ParseString(fGeoName, *fArrayOpts);
c63c3c5d 311 if(nopt==1) { // no aditional option(s)
312 fArrayOpts->Delete();
313 delete fArrayOpts;
314 fArrayOpts = 0;
315 return;
316 }
317 for(Int_t i=1; i<nopt; i++){
318 TObjString *o = (TObjString*)fArrayOpts->At(i);
319
320 TString addOpt = o->String();
321 Int_t indj=-1;
fc575e27 322 for(Int_t j=0; j<fNAdditionalOpts; j++) {
323 TString opt = fAdditionalOpts[j];
c63c3c5d 324 if(addOpt.Contains(opt,TString::kIgnoreCase)) {
325 indj = j;
326 break;
327 }
328 }
329 if(indj<0) {
330 printf("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n",
331 addOpt.Data());
332 assert(0);
333 } else {
334 printf("<I> option |%s| is valid : number %i : |%s|\n",
fc575e27 335 addOpt.Data(), indj, fAdditionalOpts[indj]);
c63c3c5d 336 if (addOpt.Contains("NL=",TString::kIgnoreCase)) {// number of sampling layers
337 sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
338 printf(" fNECLayers %i (new) \n", fNECLayers);
339 } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb
340 sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
341 } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc
342 sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
343 }
344 }
345 }
346}
347
f0377b23 348//____________________________________________________________________________
356fd0a9 349void AliEMCALGeometry::FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * timeRmatrix) {
f0377b23 350
351
356fd0a9 352// Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
353// Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
354// TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta.
355// Last 2 modules are half size in Phi, I considered that the number of TRU
356// is maintained for the last modules but decision not taken. If different,
357// then this must be changed.
358
f0377b23 359
360 //Check data members
361
362 if(fNTRUEta*fNTRUPhi != fNTRU)
363 Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
364
356fd0a9 365 //Initilize and declare variables
f0377b23 366 //List of TRU matrices initialized to 0.
356fd0a9 367 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
368 Int_t nCellsPhi2 = fNPhi/fNTRUPhi; //HalfSize modules
369 Int_t nCellsEta = fNZ*2/fNTRUEta;
f0377b23 370 Int_t id = -1;
371 Float_t amp = -1;
356fd0a9 372 Float_t timeR = -1;
f0377b23 373 Int_t iSupMod = -1;
374 Int_t nTower = -1;
375 Int_t nIphi = -1;
376 Int_t nIeta = -1;
377 Int_t iphi = -1;
378 Int_t ieta = -1;
356fd0a9 379
380 //List of TRU matrices initialized to 0.
381 for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){
382 TMatrixD * amptrus = new TMatrixD(nCellsPhi,nCellsEta) ;
383 TMatrixD * timeRtrus = new TMatrixD(nCellsPhi,nCellsEta) ;
384 for(Int_t i = 0; i < nCellsPhi; i++){
385 for(Int_t j = 0; j < nCellsEta; j++){
386 (*amptrus)(i,j) = 0.0;
387 (*timeRtrus)(i,j) = 0.0;
388 }
389 }
390 new((*ampmatrix)[k]) TMatrixD(*amptrus) ;
391 new((*timeRmatrix)[k]) TMatrixD(*timeRtrus) ;
392 }
393
394 AliEMCALDigit * dig ;
f0377b23 395
396 //Digits loop to fill TRU matrices with amplitudes.
f0377b23 397 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
398
399 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
356fd0a9 400 amp = dig->GetAmp() ; // Energy of the digit (arbitrary units)
401 id = dig->GetId() ; // Id label of the cell
402 timeR = dig->GetTimeR() ; // Earliest time of the digit
f0377b23 403
404 //Get eta and phi cell position in supermodule
405 Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ;
406 if(!bCell)
407 Error("FillTRU","Wrong cell id number") ;
408
409 GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
410
411 //Check to which TRU in the supermodule belongs the cell.
412 //Supermodules are divided in a TRU matrix of dimension
413 //(fNTRUPhi,fNTRUEta).
414 //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
415
416 //First calculate the row and column in the supermodule
417 //of the TRU to which the cell belongs.
f0377b23 418 Int_t col = (ieta-1)/nCellsEta+1;
419 Int_t row = (iphi-1)/nCellsPhi+1;
356fd0a9 420 if(iSupMod > 10)
421 row = (iphi-1)/nCellsPhi2+1;
422 //Calculate label number of the TRU
423 Int_t itru = (row-1) + (col-1)*fNTRUPhi + (iSupMod-1)*fNTRU ;
f0377b23 424
425 //Fill TRU matrix with cell values
356fd0a9 426 TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
427 TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
f0377b23 428
356fd0a9 429 //Calculate row and column of the cell inside the TRU with number itru
430 Int_t irow = (iphi-1) - (row-1) * nCellsPhi;
431 if(iSupMod > 10)
432 irow = (iphi-1) - (row-1) * nCellsPhi2;
f0377b23 433 Int_t icol = (ieta-1) - (col-1) * nCellsEta;
434
356fd0a9 435 (*amptrus)(irow,icol) = amp ;
436 (*timeRtrus)(irow,icol) = timeR ;
f0377b23 437
438 }
f0377b23 439}
440
356fd0a9 441//______________________________________________________________________
442void AliEMCALGeometry::GetCellPhiEtaIndexInSModuleFromTRUIndex(const Int_t itru, const Int_t iphitru, const Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const
443{
444
445 // This method transforms the (eta,phi) index of a cells in a
446 // TRU matrix into Super Module (eta,phi) index.
447
448 // Calculate in which row and column in which the TRU are
449 // ordered in the SM
450
451 Int_t col = itru/ fNTRUPhi + 1;
452 Int_t row = itru - (col-1)*fNTRUPhi + 1;
453
454 //Calculate the (eta,phi) index in SM
455 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
456 Int_t nCellsEta = fNZ*2/fNTRUEta;
457
458 iphiSM = nCellsPhi*(row-1) + iphitru + 1 ;
459 ietaSM = nCellsEta*(col-1) + ietatru + 1 ;
460}
f0377b23 461
c63c3c5d 462//______________________________________________________________________
b13bbe81 463AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 464 // Returns the pointer of the unique instance
465
e52475ed 466 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
467 return rv;
2012850d 468}
173558f2 469
b13bbe81 470//______________________________________________________________________
471AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
472 const Text_t* title){
473 // Returns the pointer of the unique instance
474
475 AliEMCALGeometry * rv = 0;
476 if ( fgGeom == 0 ) {
477 if ( strcmp(name,"") == 0 ) rv = 0;
478 else {
479 fgGeom = new AliEMCALGeometry(name, title);
480 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
481 else {
482 rv = 0;
483 delete fgGeom;
484 fgGeom = 0;
485 } // end if fgInit
486 } // end if strcmp(name,"")
487 }else{
488 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
fdebddeb 489 printf("\ncurrent geometry is ") ;
490 printf(fgGeom->GetName());
491 printf("\n you cannot call ");
492 printf(name);
b13bbe81 493 }else{
9859bfc0 494 rv = (AliEMCALGeometry *) fgGeom;
e52475ed 495 } // end
b13bbe81 496 } // end if fgGeom
497 return rv;
2012850d 498}
173558f2 499
c63c3c5d 500// These methods are obsolete but use in AliEMCALRecPoint - keep it now
ca8f5bd0 501//______________________________________________________________________
395c7ba2 502Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
503 // Returns the tower index number from the based on the Z and Phi
fdebddeb 504 // index numbers.
395c7ba2 505 // Inputs:
fdebddeb 506 // Int_t ieta // index along z axis [1-fNZ]
507 // Int_t iphi // index along phi axis [1-fNPhi]
395c7ba2 508 // Outputs:
509 // none.
510 // Returned
511 // Int_t index // Tower index number
512
513 if ( (ieta <= 0 || ieta>GetNEta()) ||
f1da4a27 514 (iphi <= 0 || iphi>GetNPhi())) {
515 Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
516 return -1;
517 }
395c7ba2 518 return ( (iphi - 1)*GetNEta() + ieta );
ca8f5bd0 519}
173558f2 520
ca8f5bd0 521//______________________________________________________________________
fdebddeb 522void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
395c7ba2 523 // Inputs:
fdebddeb 524 // Int_t index // Tower index number [1-fNZ*fNPhi]
395c7ba2 525 // Outputs:
526 // Int_t ieta // index allong z axis [1-fNZ]
527 // Int_t iphi // index allong phi axis [1-fNPhi]
395c7ba2 528 // Returned
529 // none.
395c7ba2 530
fdebddeb 531 Int_t nindex = 0;
395c7ba2 532
fdebddeb 533 if ( IsInECA(index) ) { // ECAL index
395c7ba2 534 nindex = index ;
395c7ba2 535 }
f1da4a27 536 else {
537 Error("TowerIndexes", "Unexpected Id number!") ;
538 ieta = -1;
539 iphi = -1;
540 return;
541 }
542
395c7ba2 543 if (nindex%GetNZ())
544 iphi = nindex / GetNZ() + 1 ;
545 else
546 iphi = nindex / GetNZ() ;
547 ieta = nindex - (iphi - 1) * GetNZ() ;
548
549 if (gDebug==2)
fdebddeb 550 printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
395c7ba2 551 return;
552
ca8f5bd0 553}
173558f2 554
ca8f5bd0 555//______________________________________________________________________
a34b7b9f 556void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
ca8f5bd0 557 // given the tower index number it returns the based on the eta and phi
558 // of the tower.
559 // Inputs:
fdebddeb 560 // Int_t index // Tower index number [1-fNZ*fNPhi]
ca8f5bd0 561 // Outputs:
562 // Float_t eta // eta of center of tower in pseudorapidity
563 // Float_t phi // phi of center of tower in degrees
564 // Returned
565 // none.
fdebddeb 566 Int_t ieta, iphi;
395c7ba2 567 Float_t deta, dphi ;
ca8f5bd0 568
fdebddeb 569 TowerIndexes(index,ieta,iphi);
395c7ba2 570
571 if (gDebug == 2)
fdebddeb 572 printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
395c7ba2 573
574 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
575 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
576
577 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
578 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
ca8f5bd0 579}
173558f2 580
ca8f5bd0 581//______________________________________________________________________
a34b7b9f 582Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
ca8f5bd0 583 // returns the tower index number based on the eta and phi of the tower.
584 // Inputs:
585 // Float_t eta // eta of center of tower in pseudorapidity
586 // Float_t phi // phi of center of tower in degrees
587 // Outputs:
588 // none.
589 // Returned
590 // Int_t index // Tower index number [1-fNZ*fNPhi]
395c7ba2 591
e908f07f 592 Int_t ieta,iphi;
ca8f5bd0 593
395c7ba2 594 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
595
596 if( ieta <= 0 || ieta > GetNEta() ) {
597 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
598 return -1 ;
599 }
600
601 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
602
603 if( iphi <= 0 || iphi > GetNPhi() ) {
604 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
605 return -1 ;
606 }
607
608 return TowerIndex(ieta,iphi);
ca8f5bd0 609}
173558f2 610
ca8f5bd0 611//______________________________________________________________________
a34b7b9f 612Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
ca8f5bd0 613 // Converts the absolute numbering into the following array/
2608a1fc 614 // relid[0] = Row number inside EMCAL
615 // relid[1] = Column number inside EMCAL
ca8f5bd0 616 // Input:
617 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
618 // Outputs:
2608a1fc 619 // Int_t *relid // array of 2. Described above.
ca8f5bd0 620 Bool_t rv = kTRUE ;
fdebddeb 621 Int_t ieta=0,iphi=0,index=AbsId;
ca8f5bd0 622
fdebddeb 623 TowerIndexes(index,ieta,iphi);
2608a1fc 624 relid[0] = ieta;
625 relid[1] = iphi;
ca8f5bd0 626
627 return rv;
628}
173558f2 629
ca8f5bd0 630//______________________________________________________________________
395c7ba2 631void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
632{
633 // Converts the relative numbering into the local EMCAL-module (x, z)
634 // coordinates
2608a1fc 635 Int_t ieta = relid[0]; // offset along x axis
636 Int_t iphi = relid[1]; // offset along z axis
395c7ba2 637 Int_t index;
638 Float_t eta;
639
640 index = TowerIndex(ieta,iphi);
641 EtaPhiFromIndex(index,eta,phi);
fdebddeb 642 //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
643 theta = 2.0*TMath::ATan(TMath::Exp(-eta));
395c7ba2 644
fdebddeb 645 // correct for distance to IP
646 Float_t d = GetIP2ECASection() - GetIPDistance() ;
395c7ba2 647
648 Float_t correction = 1 + d/GetIPDistance() ;
649 Float_t tantheta = TMath::Tan(theta) * correction ;
650 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
651 if (theta < 0 )
652 theta += 180. ;
653
654 return;
655}
ca8f5bd0 656
395c7ba2 657//______________________________________________________________________
09884213 658void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
395c7ba2 659{
660 // Converts the relative numbering into the local EMCAL-module (x, z)
661 // coordinates
2608a1fc 662 Int_t relid[2] ;
395c7ba2 663 AbsToRelNumbering(absid, relid) ;
2608a1fc 664 Int_t ieta = relid[0]; // offset along x axis
665 Int_t iphi = relid[1]; // offset along z axis
395c7ba2 666 Int_t index;
667 Float_t eta;
668
669 index = TowerIndex(ieta,iphi);
670 EtaPhiFromIndex(index,eta,phi);
671 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
672
fdebddeb 673 // correct for distance to IP
395c7ba2 674 Float_t d = 0. ;
fdebddeb 675 if (IsInECA(absid))
88cb7938 676 d = GetIP2ECASection() - GetIPDistance() ;
f1da4a27 677 else {
678 Error("PosInAlice", "Unexpected id # %d!", absid) ;
679 return;
680 }
395c7ba2 681
682 Float_t correction = 1 + d/GetIPDistance() ;
683 Float_t tantheta = TMath::Tan(theta) * correction ;
684 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
685 if (theta < 0 )
686 theta += 180. ;
687
688 return;
ca8f5bd0 689}
6119e5db 690
691//______________________________________________________________________
692void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
693 // given the tower relative number it returns the X, Y and Z
694 // of the tower.
695
696 // Outputs:
697 // Float_t x // x of center of tower in cm
698 // Float_t y // y of center of tower in cm
699 // Float_t z // z of centre of tower in cm
700 // Returned
701 // none.
702
fdebddeb 703 Float_t eta,theta, phi,cylradius=0. ;
6119e5db 704
2608a1fc 705 Int_t ieta = relid[0]; // offset along x axis
706 Int_t iphi = relid[1]; // offset along z axis.
6119e5db 707 Int_t index;
708
395c7ba2 709 index = TowerIndex(ieta,iphi);
6119e5db 710 EtaPhiFromIndex(index,eta,phi);
711 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
6119e5db 712
fdebddeb 713 cylradius = GetIP2ECASection() ;
a97849a9 714
395c7ba2 715 Double_t kDeg2Rad = TMath::DegToRad() ;
fdebddeb 716 x = cylradius * TMath::Cos(phi * kDeg2Rad ) ;
717 y = cylradius * TMath::Sin(phi * kDeg2Rad ) ;
718 z = cylradius / TMath::Tan(theta * kDeg2Rad ) ;
6119e5db 719
720 return;
721}
722
ca8f5bd0 723//______________________________________________________________________
09884213 724void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const {
395c7ba2 725 // given the tower relative number it returns the X, Y and Z
726 // of the tower.
727
728 // Outputs:
729 // Float_t x // x of center of tower in cm
730 // Float_t y // y of center of tower in cm
731 // Float_t z // z of centre of tower in cm
732 // Returned
733 // none.
734
fdebddeb 735 Float_t theta, phi,cylradius=0. ;
395c7ba2 736
737 PosInAlice(absid, theta, phi) ;
738
88cb7938 739 if ( IsInECA(absid) )
fdebddeb 740 cylradius = GetIP2ECASection() ;
f1da4a27 741 else {
742 Error("XYZFromIndex", "Unexpected Tower section") ;
743 return;
744 }
395c7ba2 745
746 Double_t kDeg2Rad = TMath::DegToRad() ;
fdebddeb 747 v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) );
748 v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) );
749 v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ;
395c7ba2 750
751 return;
752}
ab37d09c 753
754Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
755 // Checks whether point is inside the EMCal volume
756 //
757 // Code uses cylindrical approximation made of inner radius (for speed)
758 //
759 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
760 // are considered to inside
761
762 Double_t r=sqrt(x*x+y*y);
763
764 if ( r > fEnvelop[0] ) {
765 Double_t theta;
766 theta = TMath::ATan2(r,z);
767 Double_t eta;
768 if(theta == 0)
769 eta = 9999;
770 else
771 eta = -TMath::Log(TMath::Tan(theta/2.));
772 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
773 return 0;
774
775 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
776 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
777 return 1;
778 }
779 return 0;
780}
c63c3c5d 781// ==
1963b290 782
783//
784// == Shish-kebab cases ==
785//
e52475ed 786Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const
d87bd045 787{ // 27-aug-04;
788 // corr. 21-sep-04;
789 // 13-oct-05; 110 degree case
790 // 1 <= nSupMod <= fNumberOfSuperModules
791 // 1 <= nTower <= fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
792 // 1 <= nIphi <= fNPHIdiv
793 // 1 <= nIeta <= fNETAdiv
794 // 1 <= absid <= fNCells
795 static Int_t id=0; // have to change from 1 to fNCells
796 if(fKey110DEG == 1 && nSupMod > 10) { // 110 degree case; last two supermodules
797 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-11);
798 } else {
799 id = fNCellsInSupMod*(nSupMod-1);
800 }
1963b290 801 id += fNCellsInTower *(nTower-1);
802 id += fNPHIdiv *(nIphi-1);
803 id += nIeta;
804 if(id<=0 || id > fNCells) {
500aeccc 805// printf(" wrong numerations !!\n");
806// printf(" id %6i(will be force to -1)\n", id);
807// printf(" fNCells %6i\n", fNCells);
808// printf(" nSupMod %6i\n", nSupMod);
809// printf(" nTower %6i\n", nTower);
810// printf(" nIphi %6i\n", nIphi);
811// printf(" nIeta %6i\n", nIeta);
d87bd045 812 id = -TMath::Abs(id);
1963b290 813 }
814 return id;
815}
816
e52475ed 817Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind) const
fc575e27 818{
819 // 17-nov-04 - analog of IsInECA
820 if(fGeoName.Contains("TRD")) {
1963b290 821 if(ind<=0 || ind > fNCells) return kFALSE;
822 else return kTRUE;
823 } else return IsInECA(ind);
824}
825
e52475ed 826Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta) const
fc575e27 827{
828 // 21-sep-04
d87bd045 829 // 19-oct-05;
830 static Int_t tmp=0, sm10=0;
1963b290 831 if(absId<=0 || absId>fNCells) {
500aeccc 832// Info("GetCellIndex"," wrong abs Id %i !! \n", absId);
1963b290 833 return kFALSE;
834 }
d87bd045 835 sm10 = fNCellsInSupMod*10;
836 if(fKey110DEG == 1 && absId > sm10) { // 110 degree case; last two supermodules
837 nSupMod = (absId-1-sm10) / (fNCellsInSupMod/2) + 11;
838 tmp = (absId-1-sm10) % (fNCellsInSupMod/2);
839 } else {
840 nSupMod = (absId-1) / fNCellsInSupMod + 1;
841 tmp = (absId-1) % fNCellsInSupMod;
842 }
1963b290 843
844 nTower = tmp / fNCellsInTower + 1;
845 tmp = tmp % fNCellsInTower;
d87bd045 846 nIphi = tmp / fNPHIdiv + 1;
847 nIeta = tmp % fNPHIdiv + 1;
1963b290 848
849 return kTRUE;
850}
851
e52475ed 852void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat) const
fc575e27 853{
854 // added nSupMod; have to check - 19-oct-05 !
d87bd045 855 static Int_t nphi;
856
857 if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2;
858 else nphi = fNPhi;
859
860 ietat = (nTower-1)/nphi + 1; // have to change from 1 to fNZ
d87bd045 861 iphit = (nTower-1)%nphi + 1; // have to change from 1 to fNPhi
862}
863
eb0b1051 864void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
e52475ed 865int &iphi, int &ieta) const
fc575e27 866{
867 // added nSupMod; Nov 25, 05
c01485dd 868 static Int_t iphit, ietat;
869
870 GetTowerPhiEtaIndexInSModule(nSupMod,nTower, iphit, ietat);
871 // have to change from 1 to fNZ*fNETAdiv
872 ieta = (ietat-1)*fNETAdiv + (3-nIeta); // x(module) = -z(SM)
873 // iphi - have to change from 1 to fNPhi*fNPHIdiv
874 iphi = (iphit-1)*fNPHIdiv + nIphi; // y(module) = y(SM)
1963b290 875}
e52475ed 876
877Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const
878{
fc575e27 879 //return the number of the
880 //supermodule given the absolute
881 //ALICE numbering
882
e52475ed 883 static Int_t nSupMod, nTower, nIphi, nIeta;
884 GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta);
885 return nSupMod;
886}
887
888// Methods for AliEMCALRecPoint - Feb 19, 2006
889Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr)
890{
fc575e27 891 //Look to see what the relative
892 //position inside a given cell is
893 //for a recpoint.
894
e52475ed 895 static Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta;
896 if(!CheckAbsCellId(absId)) return kFALSE;
897
898 GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta);
899 GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi, ieta);
900
901 xr = fXCentersOfCells->At(ieta-1);
902 zr = fEtaCentersOfCells->At(ieta-1);
903
904 yr = fPhiCentersOfCells->At(iphi-1);
905
906 // cout<<" absId "<<absId<<" iphi "<<iphi<<"ieta"<<ieta;
907 // cout<< " xr " << xr << " yr " << yr << " zr " << zr <<endl;
908 return kTRUE;
909}
910
911void AliEMCALGeometry::CreateListOfTrd1Modules()
912{
fc575e27 913 //Generate the list of Trd1 modules
914 //which will make up the EMCAL
915 //geometry
916
e52475ed 917 cout<< endl<< " AliEMCALGeometry::CreateListOfTrd1Modules() started " << endl;
918 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
919 if(fShishKebabTrd1Modules == 0) {
920 fShishKebabTrd1Modules = new TList;
921 for(int iz=0; iz< GetNZ(); iz++) {
922 if(iz==0) {
923 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
924 } else {
925 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
926 mod = mTmp;
927 }
928 fShishKebabTrd1Modules->Add(mod);
929 }
930 } else {
931 cout<<" Already exits : ";
932 }
933 cout<<" fShishKebabTrd1Modules "<< fShishKebabTrd1Modules << " has "
934 << fShishKebabTrd1Modules->GetSize() << " modules" <<endl << endl;
935 // Feb 20,2006;
936 // define grid for cells in eta(z) and x directions in local coordinates system of SM
937 fEtaCentersOfCells = new TArrayD(fNZ *fNETAdiv);
938 fXCentersOfCells = new TArrayD(fNZ *fNETAdiv);
939 printf(" Cells grid in eta directions : size %i\n", fEtaCentersOfCells->GetSize());
940 Int_t iphi=0, ieta=0, nTower=0;
941 Double_t xr, zr;
942 for(Int_t it=0; it<fNZ; it++) { // array index
943 AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
944 nTower = fNPhi*it + 1;
945 for(Int_t ic=0; ic<fNETAdiv; ic++) { // array index
946 trd1->GetCenterOfCellInLocalCoordinateofSM(ic+1, xr, zr);
947 GetCellPhiEtaIndexInSModule(1, nTower, 1, ic+1, iphi, ieta); // don't depend from phi
948 fXCentersOfCells->AddAt(float(xr) - fParSM[0],ieta-1);
949 fEtaCentersOfCells->AddAt(float(zr) - fParSM[2],ieta-1);
950 }
951 }
952 for(Int_t i=0; i<fEtaCentersOfCells->GetSize(); i++) {
953 printf(" ind %2.2i : z %8.3f : x %8.3f", i+1, fEtaCentersOfCells->At(i),fXCentersOfCells->At(i));
954 if(i%2 != 0) printf("\n");
955 }
956 printf("\n");
957 // define grid for cells in phi(y) direction in local coordinates system of SM
958 fPhiCentersOfCells = new TArrayD(fNPhi*fNPHIdiv);
959 printf(" Cells grid in phi directions : size %i\n", fPhiCentersOfCells->GetSize());
960 Int_t ind=0;
961 for(Int_t it=0; it<fNPhi; it++) { // array index
962 Float_t ytLeftCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // module
963 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // array index
964 Float_t ytLeftCenterCell = ytLeftCenterModule + fPhiTileSize *(2*ic-1)/2.; // tower(cell)
965 fPhiCentersOfCells->AddAt(ytLeftCenterCell,ind);
a5890048 966 printf(" ind %2.2i : y %8.3f ", ind, fPhiCentersOfCells->At(ind)); ind++;
e52475ed 967 if(ic == fNPHIdiv-1) printf("\n");
968 }
969 }
970 printf("\n");
971}
972
973void AliEMCALGeometry::GetTransformationForSM()
974{
fc575e27 975 //Uses the geometry manager to
976 //load the transformation matrix
977 //for the supermodules
978
e52475ed 979 static Bool_t transInit=kFALSE;
980 if(transInit) return;
981
982 int i=0;
983 if(gGeoManager == 0) {
984 Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()");
985 assert(0);
986 }
987 TGeoNode *tn = gGeoManager->GetTopNode();
fc575e27 988 TGeoNode *node=0, *xen1 = 0;
e52475ed 989 for(i=0; i<tn->GetNdaughters(); i++) {
990 node = tn->GetDaughter(i);
991 TString ns(node->GetName());
992 if(ns.Contains(GetNameOfEMCALEnvelope())) {
fc575e27 993 xen1 = node;
e52475ed 994 break;
995 }
996 }
fc575e27 997 if(!xen1) {
e52475ed 998 Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s",
999 GetNameOfEMCALEnvelope());
1000 assert(0);
1001 }
fc575e27 1002 printf(" i %i : EMCAL Envelope is %s : #SM %i \n", i, xen1->GetName(), xen1->GetNdaughters());
1003 for(i=0; i<xen1->GetNdaughters(); i++) {
1004 TGeoNodeMatrix *sm = (TGeoNodeMatrix*)xen1->GetDaughter(i);
e52475ed 1005 fMatrixOfSM[i] = sm->GetMatrix();
64942713 1006 //Compiler doesn't like this syntax...
1007 // printf(" %i : matrix %x \n", i, fMatrixOfSM[i]);
e52475ed 1008 }
1009 transInit = kTRUE;
1010}
1011
1012void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int nsm) const
1013{
fc575e27 1014 //Figure out the global numbering
1015 //of a given supermodule from the
1016 //local numbering
1017
e52475ed 1018 // if(fMatrixOfSM[0] == 0) GetTransformationForSM();
1019 static int ind;
1020 ind = nsm-1;
1021 if(ind>=0 && ind < GetNumberOfSuperModules()) {
1022 fMatrixOfSM[ind]->LocalToMaster(loc, glob);
1023 }
1024}
1025
21cf2b24 1026void AliEMCALGeometry::GetGlobal(Int_t /* absId */, TVector3 & /* vglob */) const
e52475ed 1027{ // have to be defined
1028}
1029
1030void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int nsm) const
1031{
fc575e27 1032 //Figure out the global numbering
1033 //of a given supermodule from the
1034 //local numbering given a 3-vector location
1035
e52475ed 1036 static Double_t tglob[3], tloc[3];
1037 vloc.GetXYZ(tloc);
1038 GetGlobal(tloc, tglob, nsm);
1039 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
1040}
1041
1042void AliEMCALGeometry::GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const
1043{
fc575e27 1044 //Figure out the global numbering
1045 //of a given supermodule from the
1046 //local numbering for RecPoints
1047
e52475ed 1048 static TVector3 vloc;
1049 static Int_t nSupMod, nTower, nIphi, nIeta;
1050
1051 AliRecPoint *rpTmp = (AliRecPoint*)rp; // const_cast ??
1052 if(!rpTmp) return;
1053 AliEMCALRecPoint *rpEmc = (AliEMCALRecPoint*)rpTmp;
1054
1055 GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nTower, nIphi, nIeta);
1056 rpTmp->GetLocalPosition(vloc);
1057 GetGlobal(vloc, vglob, nSupMod);
1058}
1059
fc575e27 1060AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta=0)
1061{
1062 //This method was too long to be
1063 //included in the header file - the
1064 //rule checker complained about it's
1065 //length, so we move it here. It returns the
1066 //shishkebabmodule at a given eta index point.
1067
1068 static AliEMCALShishKebabTrd1Module* trd1=0;
1069 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
1070 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);
1071 } else trd1 = 0;
1072 return trd1;
1073}