1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
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
32 // --- AliRoot header files ---
34 #include "Riostream.h"
39 #include <TObjArray.h>
40 #include <TGeoManager.h>
42 #include <TGeoMatrix.h>
44 #include <TObjString.h>
45 #include <TClonesArray.h>
48 //#include "AliConst.h"
52 #include "AliEMCALGeometry.h"
53 #include "AliEMCALShishKebabTrd1Module.h"
54 #include "AliEMCALRecPoint.h"
55 #include "AliEMCALDigit.h"
56 #include "AliEMCALHistoUtilities.h"
57 #include "AliEMCALAlignData.h"
59 ClassImp(AliEMCALGeometry)
61 // these initialisations are needed for a singleton
62 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
63 Bool_t AliEMCALGeometry::fgInit = kFALSE;
64 AliEMCALAlignData *AliEMCALGeometry::fgAlignData = 0;
66 //______________________________________________________________________
67 AliEMCALGeometry::~AliEMCALGeometry(void){
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
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
86 fNAdditionalOpts = sizeof(fAdditionalOpts) / sizeof(char*);
88 fgInit = kFALSE; // Assume failed until proven otherwise.
92 if(fGeoName.Contains("110DEG")) fKey110DEG = 1; // for GetAbsCellId
93 fShishKebabTrd1Modules = 0;
94 fTrd2AngleY = f2Trd2Dy2 = fEmptySpace = fTubsR = fTubsTurnAngle = 0;
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;
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
112 fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z);
113 fSteelFrontThick = 2.54; // 9-sep-04
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)
121 fAlFrontThick = fGap2Active = 0;
122 fNPHIdiv = fNETAdiv = 2;
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
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
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)
153 fTrd1Angle = 1.5; // 1.3 or 1.5
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
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
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
174 fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
175 fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05
176 fEtaModuleSize = fPhiModuleSize; // 20-may-05
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;
186 fPhiTileSize = fPhiModuleSize/2. - fLateralSteelStrip; // 13-may-05
187 fEtaTileSize = fEtaModuleSize/2. - fLateralSteelStrip; // 13-may-05
189 if(fGeoName.Contains("25")){
191 fECScintThick = fECPbRadThickness = 0.5;
193 if(fGeoName.Contains("WSUC")){ // 18-may-05 - about common structure
194 fShellThickness = 30.; // should be change
198 CheckAdditionalOptions();
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;
206 fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);
207 if(fGeoName.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick);
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.);
216 } else Fatal("Init", "%s is an undefined geometry!", fGeoName.Data()) ;
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;
231 fParSM[0] = GetShellThickness()/2.;
232 fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
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.
242 if(fgAlignData != NULL) {
243 // Number of modules is read from Alignment DB if exists
244 fNumberOfSuperModules = fgAlignData->GetNSuperModules();
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",
263 printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n",
265 printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n",
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 );
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");
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() );
294 //TRU parameters. These parameters values are not the final ones.
300 //______________________________________________________________________
302 void AliEMCALGeometry::CheckAdditionalOptions()
305 //Additional options that
306 //can be used to select
307 //the specific geometry of
310 fArrayOpts = new TObjArray;
311 Int_t nopt = AliEMCALHistoUtilities::ParseString(fGeoName, *fArrayOpts);
312 if(nopt==1) { // no aditional option(s)
313 fArrayOpts->Delete();
318 for(Int_t i=1; i<nopt; i++){
319 TObjString *o = (TObjString*)fArrayOpts->At(i);
321 TString addOpt = o->String();
323 for(Int_t j=0; j<fNAdditionalOpts; j++) {
324 TString opt = fAdditionalOpts[j];
325 if(addOpt.Contains(opt,TString::kIgnoreCase)) {
331 AliDebug(2,Form("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n",
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);
349 //____________________________________________________________________________
350 void AliEMCALGeometry::FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * timeRmatrix) {
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.
363 if(fNTRUEta*fNTRUPhi != fNTRU)
364 Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
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;
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;
391 new((*ampmatrix)[k]) TMatrixD(*amptrus) ;
392 new((*timeRmatrix)[k]) TMatrixD(*timeRtrus) ;
395 AliEMCALDigit * dig ;
397 //Digits loop to fill TRU matrices with amplitudes.
398 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
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
405 //Get eta and phi cell position in supermodule
406 Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ;
408 Error("FillTRU","Wrong cell id number") ;
410 GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
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)
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;
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 ;
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)) ;
430 //Calculate row and column of the cell inside the TRU with number itru
431 Int_t irow = (iphi-1) - (row-1) * nCellsPhi;
433 irow = (iphi-1) - (row-1) * nCellsPhi2;
434 Int_t icol = (ieta-1) - (col-1) * nCellsEta;
436 (*amptrus)(irow,icol) = amp ;
437 (*timeRtrus)(irow,icol) = timeR ;
442 //______________________________________________________________________
443 void AliEMCALGeometry::GetCellPhiEtaIndexInSModuleFromTRUIndex(const Int_t itru, const Int_t iphitru, const Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const
446 // This method transforms the (eta,phi) index of a cells in a
447 // TRU matrix into Super Module (eta,phi) index.
449 // Calculate in which row and column in which the TRU are
452 Int_t col = itru/ fNTRUPhi + 1;
453 Int_t row = itru - (col-1)*fNTRUPhi + 1;
455 //Calculate the (eta,phi) index in SM
456 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
457 Int_t nCellsEta = fNZ*2/fNTRUEta;
459 iphiSM = nCellsPhi*(row-1) + iphitru + 1 ;
460 ietaSM = nCellsEta*(col-1) + ietatru + 1 ;
463 //______________________________________________________________________
464 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
465 // Returns the pointer of the unique instance
467 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
471 //______________________________________________________________________
472 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
473 const Text_t* title){
474 // Returns the pointer of the unique instance
476 AliEMCALGeometry * rv = 0;
478 if ( strcmp(name,"") == 0 ) rv = 0;
480 fgGeom = new AliEMCALGeometry(name, title);
481 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
487 } // end if strcmp(name,"")
489 if ( strcmp(fgGeom->GetName(), name) != 0) {
490 printf("\ncurrent geometry is %s : ", fgGeom->GetName());
491 printf(" you cannot call %s ", name);
493 rv = (AliEMCALGeometry *) fgGeom;
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
505 // Int_t ieta // index along z axis [1-fNZ]
506 // Int_t iphi // index along phi axis [1-fNPhi]
510 // Int_t index // Tower index number
512 if ( (ieta <= 0 || ieta>GetNEta()) ||
513 (iphi <= 0 || iphi>GetNPhi())) {
514 Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
517 return ( (iphi - 1)*GetNEta() + ieta );
520 //______________________________________________________________________
521 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
523 // Int_t index // Tower index number [1-fNZ*fNPhi]
525 // Int_t ieta // index allong z axis [1-fNZ]
526 // Int_t iphi // index allong phi axis [1-fNPhi]
532 if ( IsInECA(index) ) { // ECAL index
536 Error("TowerIndexes", "Unexpected Id number!") ;
543 iphi = nindex / GetNZ() + 1 ;
545 iphi = nindex / GetNZ() ;
546 ieta = nindex - (iphi - 1) * GetNZ() ;
548 AliDebug(2,Form("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi));
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
558 // Int_t index // Tower index number [1-fNZ*fNPhi]
560 // Float_t eta // eta of center of tower in pseudorapidity
561 // Float_t phi // phi of center of tower in degrees
567 TowerIndexes(index,ieta,iphi);
569 AliDebug(2,Form("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi));
571 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
572 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
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].
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.
582 // Float_t eta // eta of center of tower in pseudorapidity
583 // Float_t phi // phi of center of tower in degrees
587 // Int_t index // Tower index number [1-fNZ*fNPhi]
591 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
593 if( ieta <= 0 || ieta > GetNEta() ) {
594 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
598 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
600 if( iphi <= 0 || iphi > GetNPhi() ) {
601 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
605 return TowerIndex(ieta,iphi);
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
614 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
616 // Int_t *relid // array of 2. Described above.
618 Int_t ieta=0,iphi=0,index=AbsId;
620 TowerIndexes(index,ieta,iphi);
627 //______________________________________________________________________
628 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
630 // Converts the relative numbering into the local EMCAL-module (x, z)
632 Int_t ieta = relid[0]; // offset along x axis
633 Int_t iphi = relid[1]; // offset along z axis
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));
642 // correct for distance to IP
643 Float_t d = GetIP2ECASection() - GetIPDistance() ;
645 Float_t correction = 1 + d/GetIPDistance() ;
646 Float_t tantheta = TMath::Tan(theta) * correction ;
647 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
654 //______________________________________________________________________
655 void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
657 // Converts the relative numbering into the local EMCAL-module (x, z)
660 AbsToRelNumbering(absid, relid) ;
661 Int_t ieta = relid[0]; // offset along x axis
662 Int_t iphi = relid[1]; // offset along z axis
666 index = TowerIndex(ieta,iphi);
667 EtaPhiFromIndex(index,eta,phi);
668 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
670 // correct for distance to IP
673 d = GetIP2ECASection() - GetIPDistance() ;
675 Error("PosInAlice", "Unexpected id # %d!", absid) ;
679 Float_t correction = 1 + d/GetIPDistance() ;
680 Float_t tantheta = TMath::Tan(theta) * correction ;
681 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
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
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
700 Float_t eta,theta, phi,cylradius=0. ;
702 Int_t ieta = relid[0]; // offset along x axis
703 Int_t iphi = relid[1]; // offset along z axis.
706 index = TowerIndex(ieta,iphi);
707 EtaPhiFromIndex(index,eta,phi);
708 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
710 cylradius = GetIP2ECASection() ;
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 ) ;
720 //______________________________________________________________________
721 void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const {
722 // given the tower relative number it returns the X, Y and Z
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
732 Float_t theta, phi,cylradius=0. ;
734 PosInAlice(absid, theta, phi) ;
736 if ( IsInECA(absid) )
737 cylradius = GetIP2ECASection() ;
739 Error("XYZFromIndex", "Unexpected Tower section") ;
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 ) ) ;
751 Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
752 // Checks whether point is inside the EMCal volume
754 // Code uses cylindrical approximation made of inner radius (for speed)
756 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
757 // are considered to inside
759 Double_t r=sqrt(x*x+y*y);
761 if ( r > fEnvelop[0] ) {
763 theta = TMath::ATan2(r,z);
768 eta = -TMath::Log(TMath::Tan(theta/2.));
769 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
772 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
773 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
781 // == Shish-kebab cases ==
783 Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const
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);
796 id = fNCellsInSupMod*(nSupMod-1);
798 id += fNCellsInTower *(nTower-1);
799 id += fNPHIdiv *(nIphi-1);
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);
814 Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind) const
816 // 17-nov-04 - analog of IsInECA
817 if(fGeoName.Contains("TRD")) {
818 if(ind<=0 || ind > fNCells) return kFALSE;
820 } else return IsInECA(ind);
823 Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta) const
827 static Int_t tmp=0, sm10=0;
828 if(absId<=0 || absId>fNCells) {
829 // Info("GetCellIndex"," wrong abs Id %i !! \n", absId);
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);
837 nSupMod = (absId-1) / fNCellsInSupMod + 1;
838 tmp = (absId-1) % fNCellsInSupMod;
841 nTower = tmp / fNCellsInTower + 1;
842 tmp = tmp % fNCellsInTower;
843 nIphi = tmp / fNPHIdiv + 1;
844 nIeta = tmp % fNPHIdiv + 1;
849 void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat) const
851 // added nSupMod; have to check - 19-oct-05 !
854 if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2;
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
861 void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
862 int &iphi, int &ieta) const
864 // added nSupMod; Nov 25, 05
865 static Int_t iphit, ietat;
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)
874 Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const
876 //return the number of the
877 //supermodule given the absolute
880 static Int_t nSupMod, nTower, nIphi, nIeta;
881 GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta);
885 // Methods for AliEMCALRecPoint - Feb 19, 2006
886 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr)
888 //Look to see what the relative
889 //position inside a given cell is
892 static Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta;
893 if(!CheckAbsCellId(absId)) return kFALSE;
895 GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta);
896 GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi, ieta);
898 xr = fXCentersOfCells->At(ieta-1);
899 zr = fEtaCentersOfCells->At(ieta-1);
901 yr = fPhiCentersOfCells->At(iphi-1);
903 // cout<<" absId "<<absId<<" iphi "<<iphi<<"ieta"<<ieta;
904 // cout<< " xr " << xr << " yr " << yr << " zr " << zr <<endl;
908 void AliEMCALGeometry::CreateListOfTrd1Modules()
910 //Generate the list of Trd1 modules
911 //which will make up the EMCAL
914 AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started "));
916 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
917 if(fShishKebabTrd1Modules == 0) {
918 fShishKebabTrd1Modules = new TList;
919 for(int iz=0; iz< GetNZ(); iz++) {
921 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
923 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
926 fShishKebabTrd1Modules->Add(mod);
929 AliDebug(2,Form(" Already exits : "));
931 AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules \n",
932 fShishKebabTrd1Modules->GetSize()));
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;
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);
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)));
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()));
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)));
970 void AliEMCALGeometry::GetTransformationForSM()
972 //Uses the geometry manager to
973 //load the transformation matrix
974 //for the supermodules
976 static Bool_t transInit=kFALSE;
977 if(transInit) return;
980 if(gGeoManager == 0) {
981 Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()");
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())) {
995 Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s",
996 GetNameOfEMCALEnvelope());
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]);
1009 void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int nsm) const
1011 //Figure out the global numbering
1012 //of a given supermodule from the
1015 // if(fMatrixOfSM[0] == 0) GetTransformationForSM();
1018 if(ind>=0 && ind < GetNumberOfSuperModules()) {
1019 fMatrixOfSM[ind]->LocalToMaster(loc, glob);
1023 void AliEMCALGeometry::GetGlobal(Int_t /* absId */, TVector3 & /* vglob */) const
1024 { // have to be defined
1027 void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int nsm) const
1029 //Figure out the global numbering
1030 //of a given supermodule from the
1031 //local numbering given a 3-vector location
1033 static Double_t tglob[3], tloc[3];
1035 GetGlobal(tloc, tglob, nsm);
1036 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
1039 void AliEMCALGeometry::GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const
1041 //Figure out the global numbering
1042 //of a given supermodule from the
1043 //local numbering for RecPoints
1045 static TVector3 vloc;
1046 static Int_t nSupMod, nTower, nIphi, nIeta;
1048 AliRecPoint *rpTmp = (AliRecPoint*)rp; // const_cast ??
1050 AliEMCALRecPoint *rpEmc = (AliEMCALRecPoint*)rpTmp;
1052 GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nTower, nIphi, nIeta);
1053 rpTmp->GetLocalPosition(vloc);
1054 GetGlobal(vloc, vglob, nSupMod);
1057 AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta=0)
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.
1065 static AliEMCALShishKebabTrd1Module* trd1=0;
1066 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
1067 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);