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