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"
40 #include <TObjArray.h>
41 #include <TObjString.h>
42 #include <TGeoManager.h>
44 #include <TGeoMatrix.h>
46 #include <TClonesArray.h>
49 //#include "AliConst.h"
52 #include "AliEMCALGeometry.h"
53 #include "AliEMCALShishKebabTrd1Module.h"
54 //#include "AliRecPoint.h"
55 #include "AliEMCALRecPoint.h"
56 #include "AliEMCALDigit.h"
58 ClassImp(AliEMCALGeometry)
60 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
61 Bool_t AliEMCALGeometry::fgInit = kFALSE;
62 TString name; // contains name of geometry
64 char *additionalOpts[]={"nl=", // number of sampling layers
65 "pbTh=", // cm, Thickness of the Pb
66 "scTh=" // cm, Thickness of the Sc
68 int nAdditionalOpts = sizeof(additionalOpts) / sizeof(char*);
70 //______________________________________________________________________
71 AliEMCALGeometry::~AliEMCALGeometry(void){
74 //______________________________________________________________________
75 void AliEMCALGeometry::Init(void){
76 // Initializes the EMCAL parameters
77 // naming convention : GUV_WX_N_ gives the composition of a tower
78 // WX inform about the composition of the EM calorimeter section:
79 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
80 // New geometry: EMCAL_55_25
81 // 24-aug-04 for shish-kebab
82 // SHISH_25 or SHISH_62
83 // 11-oct-05 - correction for pre final design
84 // Feb 06,2006 - decrease the weight of EMCAL
85 fgInit = kFALSE; // Assume failed until proven otherwise.
89 if(name.Contains("110DEG")) fKey110DEG = 1; // for GetAbsCellId
90 fShishKebabTrd1Modules = 0;
91 fTrd2AngleY = f2Trd2Dy2 = fEmptySpace = fTubsR = fTubsTurnAngle = 0;
93 fNZ = 114; // granularity along Z (eta)
94 fNPhi = 168; // granularity in phi (azimuth)
95 fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
96 fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
97 fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
98 fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
99 fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
100 fPhiGapForSM = 0.; // cm, only for final TRD1 geometry
101 for(int i=0; i<12; i++) fMatrixOfSM[i] = 0;
104 if(name.Contains("SHISH")){ // Only shahslyk now
105 // 7-sep-05; integration issue
106 fArm1PhiMin = 80.0; // 60 -> 80
107 fArm1PhiMax = 180.0; // 180 -> 190
109 fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z);
110 fSteelFrontThick = 2.54; // 9-sep-04
112 fFrontSteelStrip = fPassiveScintThick = 0.0; // 13-may-05
113 fLateralSteelStrip = 0.025; // before MAY 2005
114 fPhiModuleSize = fEtaModuleSize = 11.4;
115 fPhiTileSize = fEtaTileSize = 5.52; // (11.4-5.52*2)/2. = 0.18 cm (wall thickness)
118 fAlFrontThick = fGap2Active = 0;
119 fNPHIdiv = fNETAdiv = 2;
122 fECScintThick = fECPbRadThickness = 0.2;
123 fSampling = 1.; // 30-aug-04 - should be calculated
124 if(name.Contains("TWIST")) { // all about EMCAL module
125 fNZ = 27; // 16-sep-04
126 } else if(name.Contains("TRD")) {
127 fIPDistance = 428.0; // 11-may-05
128 fSteelFrontThick = 0.0; // 3.17 -> 0.0; 28-mar-05 : no stell plate
131 fPhiModuleSize = fEtaModuleSize = 12.26;
132 fNZ = 26; // 11-oct-04
133 fTrd1Angle = 1.3; // in degree
134 // 18-nov-04; 1./0.08112=12.327
135 // http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
136 if(name.Contains("TRD1")) { // 30-jan-05
138 fPhiGapForSM = 2.; // cm, only for final TRD1 geometry
139 if(name.Contains("MAY05") || name.Contains("WSUC") || name.Contains("FINAL")){
140 fNumberOfSuperModules = 12; // 20-may-05
141 if(name.Contains("WSUC")) fNumberOfSuperModules = 1; // 27-may-05
142 fNECLayers = 77; // (13-may-05 from V.Petrov)
143 fPhiModuleSize = 12.5; // 20-may-05 - rectangular shape
144 fEtaModuleSize = 11.9;
145 fECScintThick = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov)
146 fFrontSteelStrip = 0.025;// 0.025cm = 0.25mm (13-may-05 from V.Petrov)
147 fLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025
148 fPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov)
150 fTrd1Angle = 1.5; // 1.3 or 1.5
152 if(name.Contains("FINAL")) { // 9-sep-05
153 fNumberOfSuperModules = 10;
154 if(name.Contains("110DEG")) {
155 fNumberOfSuperModules = 12;// last two modules have size 10 degree in phi (180<phi<190)
156 fArm1PhiMax = 200.0; // for XEN1 and turn angle of super modules
158 fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption
159 fEtaModuleSize = fPhiModuleSize;
160 if(name.Contains("HUGE")) fNECLayers *= 3; // 28-oct-05 for analysing leakage
163 } else if(name.Contains("TRD2")) { // 30-jan-05
164 fSteelFrontThick = 0.0; // 11-mar-05
165 fIPDistance+= fSteelFrontThick; // 1-feb-05 - compensate absence of steel plate
166 fTrd1Angle = 1.64; // 1.3->1.64
167 fTrd2AngleY = fTrd1Angle; // symmetric case now
168 fEmptySpace = 0.2; // 2 mm
169 fTubsR = fIPDistance; // 31-jan-05 - as for Fred case
171 fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
172 fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05
173 fEtaModuleSize = fPhiModuleSize; // 20-may-05
176 fNPHIdiv = fNETAdiv = 2; // 13-oct-04 - division again
177 if(name.Contains("3X3")) { // 23-nov-04
178 fNPHIdiv = fNETAdiv = 3;
179 } else if(name.Contains("4X4")) {
180 fNPHIdiv = fNETAdiv = 4;
183 fPhiTileSize = fPhiModuleSize/2. - fLateralSteelStrip; // 13-may-05
184 fEtaTileSize = fEtaModuleSize/2. - fLateralSteelStrip; // 13-may-05
186 if(name.Contains("25")){
188 fECScintThick = fECPbRadThickness = 0.5;
190 if(name.Contains("WSUC")){ // 18-may-05 - about common structure
191 fShellThickness = 30.; // should be change
195 CheckAditionalOptions();
197 // constant for transition absid <--> indexes
198 fNCellsInTower = fNPHIdiv*fNETAdiv;
199 fNCellsInSupMod = fNCellsInTower*fNPhi*fNZ;
200 fNCells = fNCellsInSupMod*fNumberOfSuperModules;
201 if(name.Contains("110DEG")) fNCells -= fNCellsInSupMod;
203 fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);
204 if(name.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick);
207 if(name.Contains("TRD")) {
208 f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
209 if(name.Contains("TRD2")) { // 27-jan-05
210 f2Trd2Dy2 = fPhiModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
213 } else Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
215 fNPhiSuperModule = fNumberOfSuperModules/2;
216 if(fNPhiSuperModule<1) fNPhiSuperModule = 1;
217 //There is always one more scintillator than radiator layer because of the first block of aluminium
218 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
219 if(name.Contains("SHISH")) {
220 fShellThickness = fSteelFrontThick + fLongModuleSize;
221 if(name.Contains("TWIST")) { // 13-sep-04
222 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + fPhiModuleSize*fEtaModuleSize);
223 fShellThickness += fSteelFrontThick;
224 } else if(name.Contains("TRD")) { // 1-oct-04
225 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
226 fShellThickness += fSteelFrontThick;
228 fParSM[0] = GetShellThickness()/2.;
229 fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
234 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
235 fEnvelop[0] = fIPDistance; // mother volume inner radius
236 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
237 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
242 printf("Init: geometry of EMCAL named %s is as follows:\n", name.Data());
243 printf( " ECAL : %d x (%f cm Pb, %f cm Sc) \n",
244 GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
245 printf(" fSampling %5.2f \n", fSampling );
246 if(name.Contains("SHISH")){
247 printf(" fIPDistance %6.3f cm \n", fIPDistance);
248 if(fSteelFrontThick>0.)
249 printf(" fSteelFrontThick %6.3f cm \n", fSteelFrontThick);
250 printf(" fNPhi %i | fNZ %i \n", fNPhi, fNZ);
251 printf(" fNCellsInTower %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInTower, fNCellsInSupMod, fNCells);
252 if(name.Contains("MAY05")){
253 printf(" fFrontSteelStrip %6.4f cm (thickness of front steel strip)\n",
255 printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n",
257 printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n",
260 printf(" X:Y module size %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
261 printf(" X:Y tile size %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
262 printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
263 printf(" fLongModuleSize %6.3f cm \n", fLongModuleSize);
264 printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
266 if(name.Contains("TRD")) {
267 printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
268 printf(" f2Trd1Dx2 %7.4f\n", f2Trd1Dx2);
269 if(name.Contains("TRD2")) {
270 printf(" fTrd2AngleY %7.4f\n", fTrd2AngleY);
271 printf(" f2Trd2Dy2 %7.4f\n", f2Trd2Dy2);
272 printf(" fTubsR %7.2f cm\n", fTubsR);
273 printf(" fTubsTurnAngle %7.4f\n", fTubsTurnAngle);
274 printf(" fEmptySpace %7.4f cm\n", fEmptySpace);
275 } else if(name.Contains("TRD1") && name.Contains("FINAL")){
276 printf("SM dimensions(TRD1) : dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n",
277 fParSM[0],fParSM[1],fParSM[2]);
278 printf(" fPhiGapForSM %7.4f cm \n", fPhiGapForSM);
279 if(name.Contains("110DEG"))printf(" Last two modules have size 10 degree in phi (180<phi<190)\n");
282 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
283 printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f\n",
284 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
286 //TRU parameters. These parameters values are not the final ones.
292 //______________________________________________________________________
294 void AliEMCALGeometry::CheckAditionalOptions()
296 fArrayOpts = new TObjArray;
297 Int_t nopt = ParseString(name, *fArrayOpts);
298 if(nopt==1) { // no aditional option(s)
299 fArrayOpts->Delete();
304 for(Int_t i=1; i<nopt; i++){
305 TObjString *o = (TObjString*)fArrayOpts->At(i);
307 TString addOpt = o->String();
309 for(Int_t j=0; j<nAdditionalOpts; j++) {
310 TString opt = additionalOpts[j];
311 if(addOpt.Contains(opt,TString::kIgnoreCase)) {
317 printf("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n",
321 printf("<I> option |%s| is valid : number %i : |%s|\n",
322 addOpt.Data(), indj, additionalOpts[indj]);
323 if (addOpt.Contains("NL=",TString::kIgnoreCase)) {// number of sampling layers
324 sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
325 printf(" fNECLayers %i (new) \n", fNECLayers);
326 } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb
327 sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
328 } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc
329 sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
335 //____________________________________________________________________________
336 TClonesArray * AliEMCALGeometry::FillTRU(const TClonesArray * digits) {
339 //Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
340 //Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
341 //TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta. For the
342 //moment the TRU of the 2 smaller supermodules are considered to be equal
347 if(fNTRUEta*fNTRUPhi != fNTRU)
348 Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
350 //Initilize variables
351 //List of TRU matrices initialized to 0.
352 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
353 Int_t nCellsEta = fNZ*2/fNTRUEta;
354 TClonesArray * matrix = new TClonesArray("TMatrixD",1000);
356 for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){
357 TMatrixD * trus = new TMatrixD(nCellsPhi,nCellsEta) ;
358 for(Int_t i = 0; i < nCellsPhi; i++)
359 for(Int_t j = 0; j < nCellsEta; j++)
362 new((*matrix)[k]) TMatrixD(*trus) ;
365 AliEMCALDigit * dig ;
377 //Digits loop to fill TRU matrices with amplitudes.
379 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
381 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
382 amp = dig->GetAmp() ; //Energy of the digit (arbitrary units)
383 id = dig->GetId() ; //Id label of the cell
384 //cout<<"idig "<<idig<<" Amp "<<amp<<" Id "<<id<<endl;
386 //Get eta and phi cell position in supermodule
387 Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ;
389 Error("FillTRU","Wrong cell id number") ;
391 GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
393 //Check to which TRU in the supermodule belongs the cell.
394 //Supermodules are divided in a TRU matrix of dimension
395 //(fNTRUPhi,fNTRUEta).
396 //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
398 //First calculate the row and column in the supermodule
399 //of the TRU to which the cell belongs.
401 Int_t col = (ieta-1)/nCellsEta+1;
402 Int_t row = (iphi-1)/nCellsPhi+1;
403 Int_t itru = col*row + (iSupMod-1)*fNTRU - 1; //Label number of the TRU
404 // Info("FillTRU","SM %d, cell: phi %d, eta %d",iSupMod,iphi,ieta);
405 // Info("FillTRU","SM TRU: SMrow %d, SMcol %d, SMtru %d,",row,col,itru);
408 //Fill TRU matrix with cell values
410 TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(itru)) ;
412 //Calculate row and column of the cell inside the TRU with number itru
414 Int_t irow = (iphi-1) - (row-1) * nCellsPhi;
415 Int_t icol = (ieta-1) - (col-1) * nCellsEta;
417 (*trus)(irow,icol) = amp ;
420 // Info("FillTRU","TRU: row %d, col %d",irow,icol);
427 //______________________________________________________________________
428 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
429 // Returns the pointer of the unique instance
431 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
435 //______________________________________________________________________
436 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
437 const Text_t* title){
438 // Returns the pointer of the unique instance
440 AliEMCALGeometry * rv = 0;
442 if ( strcmp(name,"") == 0 ) rv = 0;
444 fgGeom = new AliEMCALGeometry(name, title);
445 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
451 } // end if strcmp(name,"")
453 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
454 printf("\ncurrent geometry is ") ;
455 printf(fgGeom->GetName());
456 printf("\n you cannot call ");
459 rv = (AliEMCALGeometry *) fgGeom;
465 // These methods are obsolete but use in AliEMCALRecPoint - keep it now
466 //______________________________________________________________________
467 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
468 // Returns the tower index number from the based on the Z and Phi
471 // Int_t ieta // index along z axis [1-fNZ]
472 // Int_t iphi // index along phi axis [1-fNPhi]
476 // Int_t index // Tower index number
478 if ( (ieta <= 0 || ieta>GetNEta()) ||
479 (iphi <= 0 || iphi>GetNPhi())) {
480 Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
483 return ( (iphi - 1)*GetNEta() + ieta );
486 //______________________________________________________________________
487 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
489 // Int_t index // Tower index number [1-fNZ*fNPhi]
491 // Int_t ieta // index allong z axis [1-fNZ]
492 // Int_t iphi // index allong phi axis [1-fNPhi]
498 if ( IsInECA(index) ) { // ECAL index
502 Error("TowerIndexes", "Unexpected Id number!") ;
509 iphi = nindex / GetNZ() + 1 ;
511 iphi = nindex / GetNZ() ;
512 ieta = nindex - (iphi - 1) * GetNZ() ;
515 printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
520 //______________________________________________________________________
521 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
522 // given the tower index number it returns the based on the eta and phi
525 // Int_t index // Tower index number [1-fNZ*fNPhi]
527 // Float_t eta // eta of center of tower in pseudorapidity
528 // Float_t phi // phi of center of tower in degrees
534 TowerIndexes(index,ieta,iphi);
537 printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
539 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
540 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
542 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
543 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
546 //______________________________________________________________________
547 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
548 // returns the tower index number based on the eta and phi of the tower.
550 // Float_t eta // eta of center of tower in pseudorapidity
551 // Float_t phi // phi of center of tower in degrees
555 // Int_t index // Tower index number [1-fNZ*fNPhi]
559 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
561 if( ieta <= 0 || ieta > GetNEta() ) {
562 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
566 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
568 if( iphi <= 0 || iphi > GetNPhi() ) {
569 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
573 return TowerIndex(ieta,iphi);
576 //______________________________________________________________________
577 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
578 // Converts the absolute numbering into the following array/
579 // relid[0] = Row number inside EMCAL
580 // relid[1] = Column number inside EMCAL
582 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
584 // Int_t *relid // array of 2. Described above.
586 Int_t ieta=0,iphi=0,index=AbsId;
588 TowerIndexes(index,ieta,iphi);
595 //______________________________________________________________________
596 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
598 // Converts the relative numbering into the local EMCAL-module (x, z)
600 Int_t ieta = relid[0]; // offset along x axis
601 Int_t iphi = relid[1]; // offset along z axis
605 index = TowerIndex(ieta,iphi);
606 EtaPhiFromIndex(index,eta,phi);
607 //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
608 theta = 2.0*TMath::ATan(TMath::Exp(-eta));
610 // correct for distance to IP
611 Float_t d = GetIP2ECASection() - GetIPDistance() ;
613 Float_t correction = 1 + d/GetIPDistance() ;
614 Float_t tantheta = TMath::Tan(theta) * correction ;
615 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
622 //______________________________________________________________________
623 void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
625 // Converts the relative numbering into the local EMCAL-module (x, z)
628 AbsToRelNumbering(absid, relid) ;
629 Int_t ieta = relid[0]; // offset along x axis
630 Int_t iphi = relid[1]; // offset along z axis
634 index = TowerIndex(ieta,iphi);
635 EtaPhiFromIndex(index,eta,phi);
636 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
638 // correct for distance to IP
641 d = GetIP2ECASection() - GetIPDistance() ;
643 Error("PosInAlice", "Unexpected id # %d!", absid) ;
647 Float_t correction = 1 + d/GetIPDistance() ;
648 Float_t tantheta = TMath::Tan(theta) * correction ;
649 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
656 //______________________________________________________________________
657 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
658 // given the tower relative number it returns the X, Y and Z
662 // Float_t x // x of center of tower in cm
663 // Float_t y // y of center of tower in cm
664 // Float_t z // z of centre of tower in cm
668 Float_t eta,theta, phi,cylradius=0. ;
670 Int_t ieta = relid[0]; // offset along x axis
671 Int_t iphi = relid[1]; // offset along z axis.
674 index = TowerIndex(ieta,iphi);
675 EtaPhiFromIndex(index,eta,phi);
676 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
678 cylradius = GetIP2ECASection() ;
680 Double_t kDeg2Rad = TMath::DegToRad() ;
681 x = cylradius * TMath::Cos(phi * kDeg2Rad ) ;
682 y = cylradius * TMath::Sin(phi * kDeg2Rad ) ;
683 z = cylradius / TMath::Tan(theta * kDeg2Rad ) ;
688 //______________________________________________________________________
689 void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) 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 theta, phi,cylradius=0. ;
702 PosInAlice(absid, theta, phi) ;
704 if ( IsInECA(absid) )
705 cylradius = GetIP2ECASection() ;
707 Error("XYZFromIndex", "Unexpected Tower section") ;
711 Double_t kDeg2Rad = TMath::DegToRad() ;
712 v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) );
713 v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) );
714 v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ;
719 Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
720 // Checks whether point is inside the EMCal volume
722 // Code uses cylindrical approximation made of inner radius (for speed)
724 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
725 // are considered to inside
727 Double_t r=sqrt(x*x+y*y);
729 if ( r > fEnvelop[0] ) {
731 theta = TMath::ATan2(r,z);
736 eta = -TMath::Log(TMath::Tan(theta/2.));
737 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
740 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
741 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
749 // == Shish-kebab cases ==
751 Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const
754 // 13-oct-05; 110 degree case
755 // 1 <= nSupMod <= fNumberOfSuperModules
756 // 1 <= nTower <= fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
757 // 1 <= nIphi <= fNPHIdiv
758 // 1 <= nIeta <= fNETAdiv
759 // 1 <= absid <= fNCells
760 static Int_t id=0; // have to change from 1 to fNCells
761 if(fKey110DEG == 1 && nSupMod > 10) { // 110 degree case; last two supermodules
762 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-11);
764 id = fNCellsInSupMod*(nSupMod-1);
766 id += fNCellsInTower *(nTower-1);
767 id += fNPHIdiv *(nIphi-1);
769 if(id<=0 || id > fNCells) {
770 // printf(" wrong numerations !!\n");
771 // printf(" id %6i(will be force to -1)\n", id);
772 // printf(" fNCells %6i\n", fNCells);
773 // printf(" nSupMod %6i\n", nSupMod);
774 // printf(" nTower %6i\n", nTower);
775 // printf(" nIphi %6i\n", nIphi);
776 // printf(" nIeta %6i\n", nIeta);
777 id = -TMath::Abs(id);
782 Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind) const
783 { // 17-niv-04 - analog of IsInECA
784 if(name.Contains("TRD")) {
785 if(ind<=0 || ind > fNCells) return kFALSE;
787 } else return IsInECA(ind);
790 Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta) const
793 static Int_t tmp=0, sm10=0;
794 if(absId<=0 || absId>fNCells) {
795 // Info("GetCellIndex"," wrong abs Id %i !! \n", absId);
798 sm10 = fNCellsInSupMod*10;
799 if(fKey110DEG == 1 && absId > sm10) { // 110 degree case; last two supermodules
800 nSupMod = (absId-1-sm10) / (fNCellsInSupMod/2) + 11;
801 tmp = (absId-1-sm10) % (fNCellsInSupMod/2);
803 nSupMod = (absId-1) / fNCellsInSupMod + 1;
804 tmp = (absId-1) % fNCellsInSupMod;
807 nTower = tmp / fNCellsInTower + 1;
808 tmp = tmp % fNCellsInTower;
809 nIphi = tmp / fNPHIdiv + 1;
810 nIeta = tmp % fNPHIdiv + 1;
815 void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat) const
816 { // added nSupMod; have to check - 19-oct-05 !
819 if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2;
822 ietat = (nTower-1)/nphi + 1; // have to change from 1 to fNZ
823 iphit = (nTower-1)%nphi + 1; // have to change from 1 to fNPhi
826 void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
827 int &iphi, int &ieta) const
828 { // added nSupMod; Nov 25, 05
829 static Int_t iphit, ietat;
831 GetTowerPhiEtaIndexInSModule(nSupMod,nTower, iphit, ietat);
832 // have to change from 1 to fNZ*fNETAdiv
833 ieta = (ietat-1)*fNETAdiv + (3-nIeta); // x(module) = -z(SM)
834 // iphi - have to change from 1 to fNPhi*fNPHIdiv
835 iphi = (iphit-1)*fNPHIdiv + nIphi; // y(module) = y(SM)
838 Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const
840 static Int_t nSupMod, nTower, nIphi, nIeta;
841 GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta);
845 // Methods for AliEMCALRecPoint - Feb 19, 2006
846 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr)
848 static Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta;
849 if(!CheckAbsCellId(absId)) return kFALSE;
851 GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta);
852 GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi, ieta);
854 xr = fXCentersOfCells->At(ieta-1);
855 zr = fEtaCentersOfCells->At(ieta-1);
857 yr = fPhiCentersOfCells->At(iphi-1);
859 // cout<<" absId "<<absId<<" iphi "<<iphi<<"ieta"<<ieta;
860 // cout<< " xr " << xr << " yr " << yr << " zr " << zr <<endl;
864 void AliEMCALGeometry::CreateListOfTrd1Modules()
866 cout<< endl<< " AliEMCALGeometry::CreateListOfTrd1Modules() started " << endl;
867 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
868 if(fShishKebabTrd1Modules == 0) {
869 fShishKebabTrd1Modules = new TList;
870 for(int iz=0; iz< GetNZ(); iz++) {
872 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
874 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
877 fShishKebabTrd1Modules->Add(mod);
880 cout<<" Already exits : ";
882 cout<<" fShishKebabTrd1Modules "<< fShishKebabTrd1Modules << " has "
883 << fShishKebabTrd1Modules->GetSize() << " modules" <<endl << endl;
885 // define grid for cells in eta(z) and x directions in local coordinates system of SM
886 fEtaCentersOfCells = new TArrayD(fNZ *fNETAdiv);
887 fXCentersOfCells = new TArrayD(fNZ *fNETAdiv);
888 printf(" Cells grid in eta directions : size %i\n", fEtaCentersOfCells->GetSize());
889 Int_t iphi=0, ieta=0, nTower=0;
891 for(Int_t it=0; it<fNZ; it++) { // array index
892 AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
893 nTower = fNPhi*it + 1;
894 for(Int_t ic=0; ic<fNETAdiv; ic++) { // array index
895 trd1->GetCenterOfCellInLocalCoordinateofSM(ic+1, xr, zr);
896 GetCellPhiEtaIndexInSModule(1, nTower, 1, ic+1, iphi, ieta); // don't depend from phi
897 fXCentersOfCells->AddAt(float(xr) - fParSM[0],ieta-1);
898 fEtaCentersOfCells->AddAt(float(zr) - fParSM[2],ieta-1);
901 for(Int_t i=0; i<fEtaCentersOfCells->GetSize(); i++) {
902 printf(" ind %2.2i : z %8.3f : x %8.3f", i+1, fEtaCentersOfCells->At(i),fXCentersOfCells->At(i));
903 if(i%2 != 0) printf("\n");
906 // define grid for cells in phi(y) direction in local coordinates system of SM
907 fPhiCentersOfCells = new TArrayD(fNPhi*fNPHIdiv);
908 printf(" Cells grid in phi directions : size %i\n", fPhiCentersOfCells->GetSize());
910 for(Int_t it=0; it<fNPhi; it++) { // array index
911 Float_t ytLeftCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // module
912 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // array index
913 Float_t ytLeftCenterCell = ytLeftCenterModule + fPhiTileSize *(2*ic-1)/2.; // tower(cell)
914 fPhiCentersOfCells->AddAt(ytLeftCenterCell,ind);
915 printf(" ind %2.2i : y %8.3f ", ind, fPhiCentersOfCells->At(ind++));
916 if(ic == fNPHIdiv-1) printf("\n");
922 void AliEMCALGeometry::GetTransformationForSM()
924 static Bool_t transInit=kFALSE;
925 if(transInit) return;
928 if(gGeoManager == 0) {
929 Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()");
932 TGeoNode *tn = gGeoManager->GetTopNode();
933 TGeoNode *node=0, *XEN1 = 0;
934 for(i=0; i<tn->GetNdaughters(); i++) {
935 node = tn->GetDaughter(i);
936 TString ns(node->GetName());
937 if(ns.Contains(GetNameOfEMCALEnvelope())) {
943 Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s",
944 GetNameOfEMCALEnvelope());
947 printf(" i %i : EMCAL Envelope is %s : #SM %i \n", i, XEN1->GetName(), XEN1->GetNdaughters());
948 for(i=0; i<XEN1->GetNdaughters(); i++) {
949 TGeoNodeMatrix *sm = (TGeoNodeMatrix*)XEN1->GetDaughter(i);
950 fMatrixOfSM[i] = sm->GetMatrix();
951 printf(" %i : matrix %x \n", i, fMatrixOfSM[i]);
956 void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int nsm) const
958 // if(fMatrixOfSM[0] == 0) GetTransformationForSM();
961 if(ind>=0 && ind < GetNumberOfSuperModules()) {
962 fMatrixOfSM[ind]->LocalToMaster(loc, glob);
966 void AliEMCALGeometry::GetGlobal(const Int_t absId, TVector3 &vglob) const
967 { // have to be defined
970 void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int nsm) const
972 static Double_t tglob[3], tloc[3];
974 GetGlobal(tloc, tglob, nsm);
975 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
978 void AliEMCALGeometry::GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const
980 static TVector3 vloc;
981 static Int_t nSupMod, nTower, nIphi, nIeta;
983 AliRecPoint *rpTmp = (AliRecPoint*)rp; // const_cast ??
985 AliEMCALRecPoint *rpEmc = (AliEMCALRecPoint*)rpTmp;
987 GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nTower, nIphi, nIeta);
988 rpTmp->GetLocalPosition(vloc);
989 GetGlobal(vloc, vglob, nSupMod);
993 int AliEMCALGeometry::ParseString(const TString &topt, TObjArray &Opt)
995 Ssiz_t begin, index, end, end2;
996 begin = index = end = end2 = 0;
997 TRegexp separator("[^ ;,\\t\\s/]+");
998 while ( (begin < topt.Length()) && (index != kNPOS) ) {
999 // loop over given options
1000 index = topt.Index(separator,&end,begin);
1001 if (index >= 0 && end >= 1) {
1002 TString substring(topt(index,end));
1003 Opt.Add(new TObjString(substring.Data()));
1007 return Opt.GetEntries();