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 ---
37 #include <TObjArray.h>
38 #include <TObjString.h>
41 #include <TClonesArray.h>
44 //#include "AliConst.h"
47 #include "AliEMCALGeometry.h"
48 #include "AliEMCALDigit.h"
50 ClassImp(AliEMCALGeometry)
52 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
53 Bool_t AliEMCALGeometry::fgInit = kFALSE;
54 TString name; // contains name of geometry
56 char *additionalOpts[]={"nl=", // number of sampling layers
57 "pbTh=", // cm, Thickness of the Pb
58 "scTh=" // cm, Thickness of the Sc
60 int nAdditionalOpts = sizeof(additionalOpts) / sizeof(char*);
62 //______________________________________________________________________
63 AliEMCALGeometry::~AliEMCALGeometry(void){
67 //______________________________________________________________________
68 Bool_t AliEMCALGeometry::AreInSameTower(Int_t id1, Int_t id2) const {
69 // Find out whether two hits are in the same tower - have to be change
70 Int_t idmax = TMath::Max(id1, id2) ;
71 Int_t idmin = TMath::Min(id1, id2) ;
72 if ( ((idmax - GetNZ() * GetNPhi()) == idmin ) ||
73 ((idmax - 2 * GetNZ() * GetNPhi()) == idmin ) )
79 //______________________________________________________________________
80 void AliEMCALGeometry::Init(void){
81 // Initializes the EMCAL parameters
82 // naming convention : GUV_WX_N_ gives the composition of a tower
83 // WX inform about the composition of the EM calorimeter section:
84 // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N)
85 // New geometry: EMCAL_55_25
86 // 24-aug-04 for shish-kebab
87 // SHISH_25 or SHISH_62
88 // 11-oct-05 - correction for pre final design
89 // Feb 06,2006 - decrease the weight of EMCAL
90 fgInit = kFALSE; // Assume failed until proven otherwise.
94 if(name.Contains("110DEG")) fKey110DEG = 1; // for GetAbsCellId
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
106 if(name.Contains("SHISH")){ // Only shahslyk now
107 // 7-sep-05; integration issue
108 fArm1PhiMin = 80.0; // 60 -> 80
109 fArm1PhiMax = 180.0; // 180 -> 190
111 fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z);
112 fSteelFrontThick = 2.54; // 9-sep-04
114 fFrontSteelStrip = fPassiveScintThick = 0.0; // 13-may-05
115 fLateralSteelStrip = 0.025; // before MAY 2005
116 fPhiModuleSize = fEtaModuleSize = 11.4;
117 fPhiTileSize = fEtaTileSize = 5.52; // (11.4-5.52*2)/2. = 0.18 cm (wall thickness)
120 fAlFrontThick = fGap2Active = 0;
121 fNPHIdiv = fNETAdiv = 2;
124 fECScintThick = fECPbRadThickness = 0.2;
125 fSampling = 1.; // 30-aug-04 - should be calculated
126 if(name.Contains("TWIST")) { // all about EMCAL module
127 fNZ = 27; // 16-sep-04
128 } else if(name.Contains("TRD")) {
129 fIPDistance = 428.0; // 11-may-05
130 fSteelFrontThick = 0.0; // 3.17 -> 0.0; 28-mar-05 : no stell plate
133 fPhiModuleSize = fEtaModuleSize = 12.26;
134 fNZ = 26; // 11-oct-04
135 fTrd1Angle = 1.3; // in degree
136 // 18-nov-04; 1./0.08112=12.327
137 // http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
138 if(name.Contains("TRD1")) { // 30-jan-05
140 fPhiGapForSM = 2.; // cm, only for final TRD1 geometry
141 if(name.Contains("MAY05") || name.Contains("WSUC") || name.Contains("FINAL")){
142 fNumberOfSuperModules = 12; // 20-may-05
143 if(name.Contains("WSUC")) fNumberOfSuperModules = 1; // 27-may-05
144 fNECLayers = 77; // (13-may-05 from V.Petrov)
145 fPhiModuleSize = 12.5; // 20-may-05 - rectangular shape
146 fEtaModuleSize = 11.9;
147 fECScintThick = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov)
148 fFrontSteelStrip = 0.025;// 0.025cm = 0.25mm (13-may-05 from V.Petrov)
149 fLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025
150 fPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov)
152 fTrd1Angle = 1.5; // 1.3 or 1.5
154 if(name.Contains("FINAL")) { // 9-sep-05
155 fNumberOfSuperModules = 10;
156 if(name.Contains("110DEG")) {
157 fNumberOfSuperModules = 12;// last two modules have size 10 degree in phi (180<phi<190)
158 fArm1PhiMax = 200.0; // for XEN1 and turn angle of super modules
160 fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption
161 fEtaModuleSize = fPhiModuleSize;
162 if(name.Contains("HUGE")) fNECLayers *= 3; // 28-oct-05 for analysing leakage
165 } else if(name.Contains("TRD2")) { // 30-jan-05
166 fSteelFrontThick = 0.0; // 11-mar-05
167 fIPDistance+= fSteelFrontThick; // 1-feb-05 - compensate absence of steel plate
168 fTrd1Angle = 1.64; // 1.3->1.64
169 fTrd2AngleY = fTrd1Angle; // symmetric case now
170 fEmptySpace = 0.2; // 2 mm
171 fTubsR = fIPDistance; // 31-jan-05 - as for Fred case
173 fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
174 fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05
175 fEtaModuleSize = fPhiModuleSize; // 20-may-05
178 fNPHIdiv = fNETAdiv = 2; // 13-oct-04 - division again
179 if(name.Contains("3X3")) { // 23-nov-04
180 fNPHIdiv = fNETAdiv = 3;
181 } else if(name.Contains("4X4")) {
182 fNPHIdiv = fNETAdiv = 4;
185 fPhiTileSize = fPhiModuleSize/2. - fLateralSteelStrip; // 13-may-05
186 fEtaTileSize = fEtaModuleSize/2. - fLateralSteelStrip; // 13-may-05
188 if(name.Contains("25")){
190 fECScintThick = fECPbRadThickness = 0.5;
192 if(name.Contains("WSUC")){ // 18-may-05 - about common structure
193 fShellThickness = 30.; // should be change
197 CheckAditionalOptions();
199 // constant for transition absid <--> indexes
200 fNCellsInTower = fNPHIdiv*fNETAdiv;
201 fNCellsInSupMod = fNCellsInTower*fNPhi*fNZ;
202 fNCells = fNCellsInSupMod*fNumberOfSuperModules;
203 if(name.Contains("110DEG")) fNCells -= fNCellsInSupMod;
205 fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);
206 if(name.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick);
209 if(name.Contains("TRD")) {
210 f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
211 if(name.Contains("TRD2")) { // 27-jan-05
212 f2Trd2Dy2 = fPhiModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.);
215 } else Fatal("Init", "%s is an undefined geometry!", name.Data()) ;
217 fNPhiSuperModule = fNumberOfSuperModules/2;
218 if(fNPhiSuperModule<1) fNPhiSuperModule = 1;
219 //There is always one more scintillator than radiator layer because of the first block of aluminium
220 fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick();
221 if(name.Contains("SHISH")) {
222 fShellThickness = fSteelFrontThick + fLongModuleSize;
223 if(name.Contains("TWIST")) { // 13-sep-04
224 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + fPhiModuleSize*fEtaModuleSize);
225 fShellThickness += fSteelFrontThick;
226 } else if(name.Contains("TRD")) { // 1-oct-04
227 fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
228 fShellThickness += fSteelFrontThick;
232 fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage
233 fEnvelop[0] = fIPDistance; // mother volume inner radius
234 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
235 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
240 printf("Init: geometry of EMCAL named %s is as follows:\n", name.Data());
241 printf( " ECAL : %d x (%f cm Pb, %f cm Sc) \n", GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ;
242 if(name.Contains("SHISH")){
243 printf(" fIPDistance %6.3f cm \n", fIPDistance);
244 if(fSteelFrontThick>0.)
245 printf(" fSteelFrontThick %6.3f cm \n", fSteelFrontThick);
246 printf(" fNPhi %i | fNZ %i \n", fNPhi, fNZ);
247 printf(" fNCellsInTower %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInTower, fNCellsInSupMod, fNCells);
248 if(name.Contains("MAY05")){
249 printf(" fFrontSteelStrip %6.4f cm (thickness of front steel strip)\n",
251 printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n",
253 printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n",
256 printf(" X:Y module size %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
257 printf(" X:Y tile size %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
258 printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
259 printf(" fLongModuleSize %6.3f cm \n", fLongModuleSize);
260 printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
262 if(name.Contains("TRD")) {
263 printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
264 printf(" f2Trd1Dx2 %7.4f\n", f2Trd1Dx2);
265 if(name.Contains("TRD2")) {
266 printf(" fTrd2AngleY %7.4f\n", fTrd2AngleY);
267 printf(" f2Trd2Dy2 %7.4f\n", f2Trd2Dy2);
268 printf(" fTubsR %7.2f cm\n", fTubsR);
269 printf(" fTubsTurnAngle %7.4f\n", fTubsTurnAngle);
270 printf(" fEmptySpace %7.4f cm\n", fEmptySpace);
271 } else if(name.Contains("TRD1") && name.Contains("FINAL")){
272 printf(" fPhiGapForSM %7.4f cm \n", fPhiGapForSM);
273 if(name.Contains("110DEG"))printf(" Last two modules have size 10 degree in phi (180<phi<190)\n");
276 printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
277 printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f\n",
278 GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
280 //TRU parameters. These parameters values are not the final ones.
286 //______________________________________________________________________
288 void AliEMCALGeometry::CheckAditionalOptions()
290 fArrayOpts = new TObjArray;
291 Int_t nopt = ParseString(name, *fArrayOpts);
292 if(nopt==1) { // no aditional option(s)
293 fArrayOpts->Delete();
298 for(Int_t i=1; i<nopt; i++){
299 TObjString *o = (TObjString*)fArrayOpts->At(i);
301 TString addOpt = o->String();
303 for(Int_t j=0; j<nAdditionalOpts; j++) {
304 TString opt = additionalOpts[j];
305 if(addOpt.Contains(opt,TString::kIgnoreCase)) {
311 printf("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n",
315 printf("<I> option |%s| is valid : number %i : |%s|\n",
316 addOpt.Data(), indj, additionalOpts[indj]);
317 if (addOpt.Contains("NL=",TString::kIgnoreCase)) {// number of sampling layers
318 sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
319 printf(" fNECLayers %i (new) \n", fNECLayers);
320 } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb
321 sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
322 } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc
323 sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
329 //____________________________________________________________________________
330 TClonesArray * AliEMCALGeometry::FillTRU(const TClonesArray * digits) {
333 //Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
334 //Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
335 //TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta. For the
336 //moment the TRU of the 2 smaller supermodules are considered to be equal
341 if(fNTRUEta*fNTRUPhi != fNTRU)
342 Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
344 //Initilize variables
345 //List of TRU matrices initialized to 0.
346 Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
347 Int_t nCellsEta = fNZ*2/fNTRUEta;
348 TClonesArray * matrix = new TClonesArray("TMatrixD",1000);
350 for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){
351 TMatrixD * trus = new TMatrixD(nCellsPhi,nCellsEta) ;
352 for(Int_t i = 0; i < nCellsPhi; i++)
353 for(Int_t j = 0; j < nCellsEta; j++)
356 new((*matrix)[k]) TMatrixD(*trus) ;
359 AliEMCALDigit * dig ;
371 //Digits loop to fill TRU matrices with amplitudes.
373 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
375 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
376 amp = dig->GetAmp() ; //Energy of the digit (arbitrary units)
377 id = dig->GetId() ; //Id label of the cell
378 //cout<<"idig "<<idig<<" Amp "<<amp<<" Id "<<id<<endl;
380 //Get eta and phi cell position in supermodule
381 Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ;
383 Error("FillTRU","Wrong cell id number") ;
385 GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
387 //Check to which TRU in the supermodule belongs the cell.
388 //Supermodules are divided in a TRU matrix of dimension
389 //(fNTRUPhi,fNTRUEta).
390 //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
392 //First calculate the row and column in the supermodule
393 //of the TRU to which the cell belongs.
395 Int_t col = (ieta-1)/nCellsEta+1;
396 Int_t row = (iphi-1)/nCellsPhi+1;
397 Int_t itru = col*row + (iSupMod-1)*fNTRU - 1; //Label number of the TRU
398 // Info("FillTRU","SM %d, cell: phi %d, eta %d",iSupMod,iphi,ieta);
399 // Info("FillTRU","SM TRU: SMrow %d, SMcol %d, SMtru %d,",row,col,itru);
402 //Fill TRU matrix with cell values
404 TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(itru)) ;
406 //Calculate row and column of the cell inside the TRU with number itru
408 Int_t irow = (iphi-1) - (row-1) * nCellsPhi;
409 Int_t icol = (ieta-1) - (col-1) * nCellsEta;
411 (*trus)(irow,icol) = amp ;
414 // Info("FillTRU","TRU: row %d, col %d",irow,icol);
421 //______________________________________________________________________
422 AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
423 // Returns the pointer of the unique instance
425 return static_cast<AliEMCALGeometry *>( fgGeom ) ;
428 //______________________________________________________________________
429 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
430 const Text_t* title){
431 // Returns the pointer of the unique instance
433 AliEMCALGeometry * rv = 0;
435 if ( strcmp(name,"") == 0 ) rv = 0;
437 fgGeom = new AliEMCALGeometry(name, title);
438 if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
444 } // end if strcmp(name,"")
446 if ( strcmp(fgGeom->GetName(), name) != 0 ) {
447 printf("\ncurrent geometry is ") ;
448 printf(fgGeom->GetName());
449 printf("\n you cannot call ");
452 rv = (AliEMCALGeometry *) fgGeom;
458 // These methods are obsolete but use in AliEMCALRecPoint - keep it now
459 //______________________________________________________________________
460 Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const {
461 // Returns the tower index number from the based on the Z and Phi
464 // Int_t ieta // index along z axis [1-fNZ]
465 // Int_t iphi // index along phi axis [1-fNPhi]
469 // Int_t index // Tower index number
471 if ( (ieta <= 0 || ieta>GetNEta()) ||
472 (iphi <= 0 || iphi>GetNPhi())) {
473 Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ;
476 return ( (iphi - 1)*GetNEta() + ieta );
479 //______________________________________________________________________
480 void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const {
482 // Int_t index // Tower index number [1-fNZ*fNPhi]
484 // Int_t ieta // index allong z axis [1-fNZ]
485 // Int_t iphi // index allong phi axis [1-fNPhi]
491 if ( IsInECA(index) ) { // ECAL index
495 Error("TowerIndexes", "Unexpected Id number!") ;
502 iphi = nindex / GetNZ() + 1 ;
504 iphi = nindex / GetNZ() ;
505 ieta = nindex - (iphi - 1) * GetNZ() ;
508 printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ;
513 //______________________________________________________________________
514 void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
515 // given the tower index number it returns the based on the eta and phi
518 // Int_t index // Tower index number [1-fNZ*fNPhi]
520 // Float_t eta // eta of center of tower in pseudorapidity
521 // Float_t phi // phi of center of tower in degrees
527 TowerIndexes(index,ieta,iphi);
530 printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ;
532 deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta()));
533 eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta;
535 dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees.
536 phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi].
539 //______________________________________________________________________
540 Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
541 // returns the tower index number based on the eta and phi of the tower.
543 // Float_t eta // eta of center of tower in pseudorapidity
544 // Float_t phi // phi of center of tower in degrees
548 // Int_t index // Tower index number [1-fNZ*fNPhi]
552 ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ;
554 if( ieta <= 0 || ieta > GetNEta() ) {
555 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
559 iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ;
561 if( iphi <= 0 || iphi > GetNPhi() ) {
562 Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ;
566 return TowerIndex(ieta,iphi);
569 //______________________________________________________________________
570 Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
571 // Converts the absolute numbering into the following array/
572 // relid[0] = Row number inside EMCAL
573 // relid[1] = Column number inside EMCAL
575 // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
577 // Int_t *relid // array of 2. Described above.
579 Int_t ieta=0,iphi=0,index=AbsId;
581 TowerIndexes(index,ieta,iphi);
588 //______________________________________________________________________
589 void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const
591 // Converts the relative numbering into the local EMCAL-module (x, z)
593 Int_t ieta = relid[0]; // offset along x axis
594 Int_t iphi = relid[1]; // offset along z axis
598 index = TowerIndex(ieta,iphi);
599 EtaPhiFromIndex(index,eta,phi);
600 //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
601 theta = 2.0*TMath::ATan(TMath::Exp(-eta));
603 // correct for distance to IP
604 Float_t d = GetIP2ECASection() - GetIPDistance() ;
606 Float_t correction = 1 + d/GetIPDistance() ;
607 Float_t tantheta = TMath::Tan(theta) * correction ;
608 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
615 //______________________________________________________________________
616 void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const
618 // Converts the relative numbering into the local EMCAL-module (x, z)
621 AbsToRelNumbering(absid, relid) ;
622 Int_t ieta = relid[0]; // offset along x axis
623 Int_t iphi = relid[1]; // offset along z axis
627 index = TowerIndex(ieta,iphi);
628 EtaPhiFromIndex(index,eta,phi);
629 theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ;
631 // correct for distance to IP
634 d = GetIP2ECASection() - GetIPDistance() ;
636 Error("PosInAlice", "Unexpected id # %d!", absid) ;
640 Float_t correction = 1 + d/GetIPDistance() ;
641 Float_t tantheta = TMath::Tan(theta) * correction ;
642 theta = TMath::ATan(tantheta) * TMath::RadToDeg() ;
649 //______________________________________________________________________
650 void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
651 // given the tower relative number it returns the X, Y and Z
655 // Float_t x // x of center of tower in cm
656 // Float_t y // y of center of tower in cm
657 // Float_t z // z of centre of tower in cm
661 Float_t eta,theta, phi,cylradius=0. ;
663 Int_t ieta = relid[0]; // offset along x axis
664 Int_t iphi = relid[1]; // offset along z axis.
667 index = TowerIndex(ieta,iphi);
668 EtaPhiFromIndex(index,eta,phi);
669 theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
671 cylradius = GetIP2ECASection() ;
673 Double_t kDeg2Rad = TMath::DegToRad() ;
674 x = cylradius * TMath::Cos(phi * kDeg2Rad ) ;
675 y = cylradius * TMath::Sin(phi * kDeg2Rad ) ;
676 z = cylradius / TMath::Tan(theta * kDeg2Rad ) ;
681 //______________________________________________________________________
682 void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const {
683 // given the tower relative number it returns the X, Y and Z
687 // Float_t x // x of center of tower in cm
688 // Float_t y // y of center of tower in cm
689 // Float_t z // z of centre of tower in cm
693 Float_t theta, phi,cylradius=0. ;
695 PosInAlice(absid, theta, phi) ;
697 if ( IsInECA(absid) )
698 cylradius = GetIP2ECASection() ;
700 Error("XYZFromIndex", "Unexpected Tower section") ;
704 Double_t kDeg2Rad = TMath::DegToRad() ;
705 v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) );
706 v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) );
707 v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ;
712 Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
713 // Checks whether point is inside the EMCal volume
715 // Code uses cylindrical approximation made of inner radius (for speed)
717 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
718 // are considered to inside
720 Double_t r=sqrt(x*x+y*y);
722 if ( r > fEnvelop[0] ) {
724 theta = TMath::ATan2(r,z);
729 eta = -TMath::Log(TMath::Tan(theta/2.));
730 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
733 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
734 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
742 // == Shish-kebab cases ==
744 Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta)
747 // 13-oct-05; 110 degree case
748 // 1 <= nSupMod <= fNumberOfSuperModules
749 // 1 <= nTower <= fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
750 // 1 <= nIphi <= fNPHIdiv
751 // 1 <= nIeta <= fNETAdiv
752 // 1 <= absid <= fNCells
753 static Int_t id=0; // have to change from 1 to fNCells
754 if(fKey110DEG == 1 && nSupMod > 10) { // 110 degree case; last two supermodules
755 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-11);
757 id = fNCellsInSupMod*(nSupMod-1);
759 id += fNCellsInTower *(nTower-1);
760 id += fNPHIdiv *(nIphi-1);
762 if(id<=0 || id > fNCells) {
763 // printf(" wrong numerations !!\n");
764 // printf(" id %6i(will be force to -1)\n", id);
765 // printf(" fNCells %6i\n", fNCells);
766 // printf(" nSupMod %6i\n", nSupMod);
767 // printf(" nTower %6i\n", nTower);
768 // printf(" nIphi %6i\n", nIphi);
769 // printf(" nIeta %6i\n", nIeta);
770 id = -TMath::Abs(id);
775 Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind)
776 { // 17-niv-04 - analog of IsInECA
777 if(name.Contains("TRD")) {
778 if(ind<=0 || ind > fNCells) return kFALSE;
780 } else return IsInECA(ind);
783 Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta)
786 static Int_t tmp=0, sm10=0;
787 if(absId<=0 || absId>fNCells) {
788 // Info("GetCellIndex"," wrong abs Id %i !! \n", absId);
791 sm10 = fNCellsInSupMod*10;
792 if(fKey110DEG == 1 && absId > sm10) { // 110 degree case; last two supermodules
793 nSupMod = (absId-1-sm10) / (fNCellsInSupMod/2) + 11;
794 tmp = (absId-1-sm10) % (fNCellsInSupMod/2);
796 nSupMod = (absId-1) / fNCellsInSupMod + 1;
797 tmp = (absId-1) % fNCellsInSupMod;
800 nTower = tmp / fNCellsInTower + 1;
801 tmp = tmp % fNCellsInTower;
802 nIphi = tmp / fNPHIdiv + 1;
803 nIeta = tmp % fNPHIdiv + 1;
808 void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat)
809 { // added nSupMod; have to check - 19-oct-05 !
812 if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2;
815 ietat = (nTower-1)/nphi + 1; // have to change from 1 to fNZ
816 iphit = (nTower-1)%nphi + 1; // have to change from 1 to fNPhi
819 void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
820 int &iphi, int &ieta)
821 { // added nSupMod; Nov 25, 05
822 static Int_t iphit, ietat;
824 GetTowerPhiEtaIndexInSModule(nSupMod,nTower, iphit, ietat);
825 // have to change from 1 to fNZ*fNETAdiv
826 ieta = (ietat-1)*fNETAdiv + (3-nIeta); // x(module) = -z(SM)
827 // iphi - have to change from 1 to fNPhi*fNPHIdiv
828 iphi = (iphit-1)*fNPHIdiv + nIphi; // y(module) = y(SM)
831 int AliEMCALGeometry::ParseString(const TString &topt, TObjArray &Opt)
833 Ssiz_t begin, index, end, end2;
834 begin = index = end = end2 = 0;
835 TRegexp separator("[^ ;,\\t\\s/]+");
836 while ( (begin < topt.Length()) && (index != kNPOS) ) {
837 // loop over given options
838 index = topt.Index(separator,&end,begin);
839 if (index >= 0 && end >= 1) {
840 TString substring(topt(index,end));
841 Opt.Add(new TObjString(substring.Data()));
845 return Opt.GetEntries();