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 // with scintillator fiber arranged as "shish-kebab" skewers
22 // Places the the Barrel Geometry of The EMCAL at Midrapidity
23 // between 80 and 180(or 190) degrees of Phi and
26 // EMCAL geometry tree:
27 // EMCAL -> superModule -> module -> tower(cell)
29 // absId -> nSupMod -> nModule -> (nIphi,nIeta)
32 // EMCAL_PDC06 (geometry used for PDC06 simulations, kept for backward compatibility)
33 // = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG in old notation
34 // EMCAL_COMPLETE (geometry for expected complete detector)
35 // = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG scTh=0.176 pbTh=0.144
37 // EMCAL_FIRSTYEARV1 - geometry for December 2009 to December 2010 run period;
38 // fixed bug for positions of modules inside SM
39 // (first module has tilt 0.75 degree);
40 // the sizes updated with last information from production
41 // drawing (end of October 2010).
43 // EMCAL_COMPLETEV1: Same fixes as FIRSTYEAR and 10 SM instead of 10 + 2 one_third SM, for 2011 runs
45 // EMCAL_COMPLETE12SMV1: contains 12 SM for runs from year 2012 and on
47 // EMCAL_COMPLETE12SMV1_DCAL: contains 12 SM and 6 DCAL SM
49 // EMCAL_COMPLETE12SMV1_DCAL_8SM: contains 12 SM and 8 DCAL SM including the DCAL extention (2 SM)
51 // EMCAL_COMPLETE12SMV1_DCAL_DEV: contains 12 SM shifted and 10 DCAL SM
53 // EMCAL_WSUC (Wayne State test stand)
54 // = no definite equivalent in old notation, was only used by
55 // Aleksei, but kept for testing purposes
61 // You can create the AliEMCALGeometry object independently from anything.
62 // You have to use just the correct name of geometry. If name is empty string the
63 // default name of geometry will be used.
65 // AliEMCALGeometry* g = AliEMCALGeometry::GetInstance(name,title); // first time
67 // g = AliEMCALGeometry::GetInstance(); // after first time
69 // MC: If you work with MC data you have to get geometry the next way:
70 // == =============================
71 // AliRunLoader *rl = AliRunLoader::Instance();
72 // AliEMCALGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
73 // TGeoManager::Import("geometry.root");
75 //*-- Author: Sahal Yacoob (LBL / UCT)
76 // and : Yves Schutz (SUBATECH)
77 // and : Jennifer Klay (LBL)
78 // and : Alexei Pavlinov (WSU)
80 // Implementation for analysis usage, before AliEMCALGeometry now (06/2011) merged again
81 // in AliEMCALGeometry
83 // -- Author: Magali Estienne (magali.estienne@subatech.in2p3.fr)
84 // and : Adapted for DCAL, M.L. Wang CCNU & Subatech Oct-18-2012
88 // You can create the AliEMCALGeometry object independently from anything.
89 // You have to use just the correct name of geometry. If name is empty string the
90 // default name of geometry will be used.
92 // AliEMCALGeometry* geom = new AliEMCALGeometry("EMCAL_COMPLETE12SMV1","EMCAL");
93 // TGeoManager::Import("geometry.root");
95 // MC: If you work with MC data you have to get geometry the next way:
96 // == =============================
97 // !!!!!!!!! This part has to be modified
98 // AliRunLoader *rl = AliRunLoader::GetRunLoader();
99 // AliEMCALEMCGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
100 // TGeoManager::Import("geometry.root");
103 // --- ROOT system ---
105 #include <TParticle.h>
106 #include <TGeoManager.h>
107 #include <TGeoMatrix.h>
108 #include <TGeoBBox.h>
110 #include <TBrowser.h>
112 // --- Standard library ---
113 //#include <Riostream.h>
115 // --- AliRoot header files ---
117 #include "AliEMCALGeometry.h"
118 #include "AliEMCALShishKebabTrd1Module.h"
120 ClassImp(AliEMCALGeometry)
122 // these initialisations are needed for a singleton
123 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
124 const Char_t* AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETE12SMV1";
126 //____________________________________________________________________________
127 AliEMCALGeometry::AliEMCALGeometry():
128 fEMCGeometry(0x0),fGeoName(0),fEMCSMSystem(0x0),
129 fKey110DEG(0),fnSupModInDCAL(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0),
130 fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0),
131 fPhiCentersOfSMSec(0x0),fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0),
132 fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0),
133 fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0),
134 fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0),
135 fDCALPhiMin(0),fDCALPhiMax(0),fEMCALPhiMax(0),fDCALStandardPhiMax(0),
136 fDCALInnerExtandedEta(0),fShishKebabTrd1Modules(0),fPhiModuleSize(0.),
137 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0),
138 fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.),
139 fZLength(0.),fSampling(0.),fUseExternalMatrices(kFALSE)
142 // must be kept public for root persistency purposes, but should never be called by the outside world
149 for (Int_t i=0;i<AliEMCALGeoParams::fgkEMCALModules;i++)
150 fkSModuleMatrix[i]=0 ;
152 for (Int_t i = 0; i < 48; i++)
153 for (Int_t j = 0; j < 124; j++) fFastOR2DMap[i][j] = -1;
156 //____________________________________________________________________________
157 AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry & geo)
159 fEMCGeometry(geo.fEMCGeometry),fGeoName(geo.fGeoName),fEMCSMSystem(geo.fEMCSMSystem),
160 fKey110DEG(geo.fKey110DEG),fnSupModInDCAL(geo.fnSupModInDCAL),fNCellsInSupMod(geo.fNCellsInSupMod),fNETAdiv(geo.fNETAdiv),fNPHIdiv(geo.fNPHIdiv),
161 fNCellsInModule(geo.fNCellsInModule),fPhiBoundariesOfSM(geo.fPhiBoundariesOfSM),fPhiCentersOfSM(geo.fPhiCentersOfSM),
162 fPhiCentersOfSMSec(geo.fPhiCentersOfSMSec),fPhiCentersOfCells(geo.fPhiCentersOfCells),fCentersOfCellsEtaDir(geo.fCentersOfCellsEtaDir),
163 fCentersOfCellsPhiDir(geo.fCentersOfCellsPhiDir),fEtaCentersOfCells(geo.fEtaCentersOfCells),
164 fNCells(geo.fNCells),fNPhi(geo.fNPhi),fCentersOfCellsXDir(geo.fCentersOfCellsXDir),fArm1EtaMin(geo.fArm1EtaMin),
165 fArm1EtaMax(geo.fArm1EtaMax),fArm1PhiMin(geo.fArm1PhiMin),fArm1PhiMax(geo.fArm1PhiMax),fEtaMaxOfTRD1(geo.fEtaMaxOfTRD1),
166 fDCALPhiMin(geo.fDCALPhiMin),fDCALPhiMax(geo.fDCALPhiMax),fEMCALPhiMax(geo.fEMCALPhiMax),fDCALStandardPhiMax(geo.fDCALStandardPhiMax),
167 fDCALInnerExtandedEta(geo.fDCALInnerExtandedEta),fShishKebabTrd1Modules(geo.fShishKebabTrd1Modules),fPhiModuleSize(geo.fPhiModuleSize),
168 fEtaModuleSize(geo.fEtaModuleSize),fPhiTileSize(geo.fPhiTileSize),fEtaTileSize(geo.fEtaTileSize),fNZ(geo.fNZ),
169 fIPDistance(geo.fIPDistance),fLongModuleSize(geo.fLongModuleSize),fShellThickness(geo.fShellThickness),
170 fZLength(geo.fZLength),fSampling(geo.fSampling),fUseExternalMatrices(geo.fUseExternalMatrices)
173 fEnvelop[0] = geo.fEnvelop[0];
174 fEnvelop[1] = geo.fEnvelop[1];
175 fEnvelop[2] = geo.fEnvelop[2];
176 fParSM[0] = geo.fParSM[0];
177 fParSM[1] = geo.fParSM[1];
178 fParSM[2] = geo.fParSM[2];
179 for (Int_t i=0;i<AliEMCALGeoParams::fgkEMCALModules;i++)
180 fkSModuleMatrix[i]=0 ;
182 for (Int_t i = 0; i < 48; i++)
183 for (Int_t j = 0; j < 124; j++) fFastOR2DMap[i][j] = geo.fFastOR2DMap[i][j];
186 //____________________________________________________________________________
187 AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title,
188 const Text_t* mcname, const Text_t* mctitle)
189 : TNamed(name, title),
190 fEMCGeometry(0x0),fGeoName(0),fEMCSMSystem(0x0),
191 fKey110DEG(0),fnSupModInDCAL(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0),
192 fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0),
193 fPhiCentersOfSMSec(0x0),fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0),
194 fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0),
195 fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0),
196 fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0),
197 fDCALPhiMin(0),fDCALPhiMax(0),fEMCALPhiMax(0),fDCALStandardPhiMax(0),
198 fDCALInnerExtandedEta(0),fShishKebabTrd1Modules(0),fPhiModuleSize(0.),
199 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0),
200 fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.),
201 fZLength(0.),fSampling(0.), fUseExternalMatrices(kFALSE)
203 // ctor only for normal usage
205 fEMCGeometry = new AliEMCALEMCGeometry(name,title,mcname,mctitle);
206 fGeoName = fEMCGeometry->GetGeoName();
207 fEMCSMSystem = fEMCGeometry->GetEMCSystem();
208 fKey110DEG = fEMCGeometry->GetKey110DEG();
209 fnSupModInDCAL = fEMCGeometry->GetnSupModInDCAL();
210 fNCellsInSupMod = fEMCGeometry->GetNCellsInSupMod();
211 fNETAdiv = fEMCGeometry->GetNETAdiv();
212 fNPHIdiv = fEMCGeometry->GetNPHIdiv();
213 fNCellsInModule = fNPHIdiv*fNETAdiv;
215 Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules();
216 fPhiBoundariesOfSM.Set(nSMod);
217 fPhiCentersOfSM.Set(nSMod/2);
218 fPhiCentersOfSMSec.Set(nSMod/2);
219 for(Int_t sm=0; sm<nSMod; sm++) {
221 fEMCGeometry->GetPhiBoundariesOfSM(sm,fPhiBoundariesOfSM[2*i],fPhiBoundariesOfSM[2*i+1]);
224 Double_t phiMin = 0.;
225 Double_t phiMax = 0.;
226 for(Int_t sm=0; sm<nSMod; sm++) {
227 fEMCGeometry->GetPhiBoundariesOfSM(sm,phiMin,phiMax);
229 fPhiCentersOfSM[i] = fEMCGeometry->GetPhiCenterOfSM(sm);
230 fPhiCentersOfSMSec[i] = fEMCGeometry->GetPhiCenterOfSMSec(sm);
232 fNCells = fEMCGeometry->GetNCells();
233 fNPhi = fEMCGeometry->GetNPhi();
234 fEnvelop[0] = fEMCGeometry->GetEnvelop(0);
235 fEnvelop[1] = fEMCGeometry->GetEnvelop(1);
236 fEnvelop[2] = fEMCGeometry->GetEnvelop(2);
237 fParSM[0] = fEMCGeometry->GetSuperModulesPar(0);
238 fParSM[1] = fEMCGeometry->GetSuperModulesPar(1);
239 fParSM[2] = fEMCGeometry->GetSuperModulesPar(2);
240 fArm1EtaMin = fEMCGeometry->GetArm1EtaMin();
241 fArm1EtaMax = fEMCGeometry->GetArm1EtaMax();
242 fArm1PhiMin = fEMCGeometry->GetArm1PhiMin();
243 fArm1PhiMax = fEMCGeometry->GetArm1PhiMax();
244 fDCALPhiMin = fEMCGeometry->GetDCALPhiMin();
245 fDCALPhiMax = fEMCGeometry->GetDCALPhiMax();
246 fEMCALPhiMax = fEMCGeometry->GetEMCALPhiMax();
247 fDCALStandardPhiMax = fEMCGeometry->GetDCALStandardPhiMax();
248 fDCALInnerExtandedEta = fEMCGeometry->GetDCALInnerExtandedEta();
249 fShellThickness = fEMCGeometry->GetShellThickness();
250 fZLength = fEMCGeometry->GetZLength();
251 fSampling = fEMCGeometry->GetSampling();
252 fEtaModuleSize = fEMCGeometry->GetEtaModuleSize();
253 fPhiModuleSize = fEMCGeometry->GetPhiModuleSize();
254 fEtaTileSize = fEMCGeometry->GetEtaTileSize();
255 fPhiTileSize = fEMCGeometry->GetPhiTileSize();
256 fNZ = fEMCGeometry->GetNZ();
257 fIPDistance = fEMCGeometry->GetIPDistance();
258 fLongModuleSize = fEMCGeometry->GetLongModuleSize();
260 CreateListOfTrd1Modules();
262 for(Int_t smod=0; smod < AliEMCALGeoParams::fgkEMCALModules; smod++)
263 fkSModuleMatrix[smod]=0 ;
265 if (AliDebugLevel()>=2) {
266 fEMCGeometry->Print();
267 PrintGeometryGeoUtils();
270 for (Int_t ix = 0; ix < 48; ix++)
271 for(Int_t jx = 0; jx < 124; jx++) fFastOR2DMap[ix][jx] = -1;
276 //____________________________________________________________________________
277 AliEMCALGeometry & AliEMCALGeometry::operator = (const AliEMCALGeometry & /*rvalue*/)
280 Fatal("assignment operator", "not implemented") ;
284 //____________________________________________________________________________
285 AliEMCALGeometry::~AliEMCALGeometry(void)
290 AliError("Do not call delete on me");
296 for(Int_t smod = 0 ; smod < fEMCGeometry->GetNumberOfSuperModules(); smod++)
298 if(fkSModuleMatrix[smod])
299 delete fkSModuleMatrix[smod] ;
301 fkSModuleMatrix[smod]=0 ;
304 delete fEMCGeometry; // fEMCGeometry = 0 ;
308 //______________________________________________________________________
309 AliEMCALGeometry * AliEMCALGeometry::GetInstance()
311 // Returns the pointer of the unique instance
313 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
317 //______________________________________________________________________
318 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name, const Text_t* title,
319 const Text_t* mcname, const Text_t* mctitle )
321 // Returns the pointer of the unique instance
323 AliEMCALGeometry * rv = 0;
325 if ( strcmp(name,"") == 0 ) { // get default geometry
326 fgGeom = new AliEMCALGeometry(fgkDefaultGeometryName, title,mcname,mctitle);
328 fgGeom = new AliEMCALGeometry(name, title,mcname,mctitle);
329 } // end if strcmp(name,"")
330 if ( AliEMCALEMCGeometry::fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
337 if ( strcmp(fgGeom->GetName(), name) != 0) {
338 printf("\ncurrent geometry is %s : ", fgGeom->GetName());
339 printf(" you cannot call %s ",name);
341 rv = (AliEMCALGeometry *) fgGeom;
347 //________________________________________________________________________________________________
348 void AliEMCALGeometry::Browse(TBrowser* b)
351 if(fShishKebabTrd1Modules) b->Add(fShishKebabTrd1Modules);
354 //________________________________________________________________________________________________
355 Bool_t AliEMCALGeometry::IsFolder() const
357 //Check if fShishKebabTrd1Modules is in folder
358 if(fShishKebabTrd1Modules) return kTRUE;
362 //________________________________________________________________________________________________
363 void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
365 // Figure out the global numbering
366 // of a given supermodule from the
367 // local numbering and the transformation
368 // matrix stored by the geometry manager (allows for misaligned
371 const TGeoHMatrix* m = GetMatrixForSuperModule(ind);
373 m->LocalToMaster(loc, glob);
375 AliFatal("Geo matrixes are not loaded \n") ;
379 //________________________________________________________________________________________________
380 void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const
382 //Figure out the global numbering
383 //of a given supermodule from the
384 //local numbering given a 3-vector location
386 static Double_t tglob[3], tloc[3];
388 GetGlobal(tloc, tglob, ind);
389 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
392 //________________________________________________________________________________________________
393 void AliEMCALGeometry::GetGlobal(Int_t absId , double glob[3]) const
395 // Alice numbering scheme - Jun 03, 2006
396 static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
397 static double loc[3];
399 glob[0]=glob[1]=glob[2]=0.0; // bad case
400 if(RelPosCellInSModule(absId, loc)) {
401 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
402 const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
404 m->LocalToMaster(loc, glob);
406 AliFatal("Geo matrixes are not loaded \n") ;
411 //___________________________________________________________________
412 void AliEMCALGeometry::GetGlobal(Int_t absId , TVector3 &vglob) const
414 // Alice numbering scheme - Jun 03, 2006
415 static Double_t glob[3];
417 GetGlobal(absId, glob);
418 vglob.SetXYZ(glob[0], glob[1], glob[2]);
421 //______________________________________________________________________
422 void AliEMCALGeometry::PrintCellIndexes(Int_t absId, int pri, const char *tit) const
425 Int_t nSupMod, nModule, nIphi, nIeta;
429 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
430 printf(" %s | absId : %i -> nSupMod %i nModule %i nIphi %i nIeta %i \n", tit, absId, nSupMod, nModule, nIphi, nIeta);
432 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
433 printf(" local SM index : iphi %i : ieta %i \n", iphi,ieta);
434 GetGlobal(absId, vg);
435 printf(" vglob : mag %7.2f : perp %7.2f : z %7.2f : eta %6.4f : phi %6.4f(%6.2f) \n",
436 vg.Mag(), vg.Perp(), vg.Z(), vg.Eta(), vg.Phi(), vg.Phi()*TMath::RadToDeg());
440 void AliEMCALGeometry::PrintLocalTrd1(Int_t pri) const
442 // For comparing with numbers from drawing
443 for(Int_t i=0; i<GetShishKebabTrd1Modules()->GetSize(); i++){
444 printf(" %s | ", GetShishKebabModule(i)->GetName());
445 if(i==0 && pri<1) GetShishKebabModule(i)->PrintShish(1);
446 else GetShishKebabModule(i)->PrintShish(pri);
450 //________________________________________________________________________________________________
451 void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Double_t &eta,Double_t &phi) const
453 // Nov 16, 2006- float to double
454 // version for TRD1 only
455 static TVector3 vglob;
456 GetGlobal(absId, vglob);
461 //________________________________________________________________________________________________
462 void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const
464 // Nov 16,2006 - should be discard in future
465 static TVector3 vglob;
466 GetGlobal(absId, vglob);
467 eta = float(vglob.Eta());
468 phi = float(vglob.Phi());
472 // == Shish-kebab cases ==
474 //________________________________________________________________________________________________
475 Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const
479 // 13-oct-05; 110 degree case
480 // May 31, 2006; ALICE numbering scheme:
481 // 0 <= nSupMod < fNumberOfSuperModules
482 // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
483 // 0 <= nIphi < fNPHIdiv
484 // 0 <= nIeta < fNETAdiv
485 // 0 <= absid < fNCells
486 Int_t id=0; // have to change from 0 to fNCells-1
487 for( int i = 0 ; i < nSupMod; i++) {
488 if( GetSMType(i) == kEMCAL_Standard) id += fNCellsInSupMod;
489 else if( GetSMType(i) == kEMCAL_Half) id += fNCellsInSupMod/2;
490 else if( GetSMType(i) == kEMCAL_3rd) id += fNCellsInSupMod/3;
491 else if( GetSMType(i) == kDCAL_Standard) id += 2*fNCellsInSupMod/3;
492 else if( GetSMType(i) == kDCAL_Ext) id += fNCellsInSupMod/3;
494 AliError(Form("Uknown SuperModule Type !!"));
498 id += fNCellsInModule *nModule;
499 id += fNPHIdiv *nIphi;
501 if( !CheckAbsCellId(id) ) {
502 id = -TMath::Abs(id); // if negative something wrong
507 //________________________________________________________________________________________________
508 void AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
509 Int_t &iphim, Int_t &ietam, Int_t &nModule) const
511 // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
512 static Int_t nphi=-1;
513 nphi = GetNumberOfModuleInPhiDirection(nSupMod);
515 ietam = ieta/fNETAdiv;
516 iphim = iphi/fNPHIdiv;
517 nModule = ietam * nphi + iphim;
520 //________________________________________________________________________________________________
521 Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
523 // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId
525 // Check if the indeces correspond to existing SM or tower indeces
526 if(iphi < 0 || iphi >= AliEMCALGeoParams::fgkEMCALRows ||
527 ieta < 0 || ieta >= AliEMCALGeoParams::fgkEMCALCols ||
528 nSupMod < 0 || nSupMod >= GetNumberOfSuperModules() )
530 AliDebug(1,Form("Wrong cell indexes : SM %d, column (eta) %d, row (phi) %d", nSupMod,ieta,iphi));
534 static Int_t ietam=-1, iphim=-1, nModule=-1;
535 static Int_t nIeta=-1, nIphi=-1; // cell indexes in module
537 GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule);
539 nIeta = ieta%fNETAdiv;
540 nIeta = fNETAdiv - 1 - nIeta;
541 nIphi = iphi%fNPHIdiv;
543 return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
546 //________________________________________________________________________________________________
547 Bool_t AliEMCALGeometry::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const
549 // Return false if phi belongs a phi cracks between SM
553 if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE;
555 phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
556 Int_t nphism = fEMCGeometry->GetNumberOfSuperModules()/2;
557 for(i=0; i<nphism; i++) {
558 if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) {
560 if(eta < 0.0) nSupMod++;
561 if( GetSMType(nSupMod) == kDCAL_Standard) {// Gap between DCAL
562 if(TMath::Abs(eta) < GetNEta()/3*(GetEMCGeometry()->GetTrd1Angle())*TMath::DegToRad()) return kFALSE;
564 AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i));
572 //________________________________________________________________________________________________
573 Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const
577 // stay here - phi problem as usual
578 static Int_t nSupMod=-1, i=0, ieta=-1, iphi=-1, etaShift=0, neta=-1, nphi=-1;
579 static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc=0;
580 absId = nSupMod = - 1;
581 if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
583 phi = TVector2::Phi_0_2pi(phi);
584 phiLoc = phi - fPhiCentersOfSMSec[nSupMod/2];
585 nphi = fPhiCentersOfCells.GetSize();
586 if ( GetSMType(nSupMod) == kEMCAL_Half ) nphi /= 2;
587 else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi /= 3;
588 else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi /= 3;
590 dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc);
592 for(i=1; i<nphi; i++) {
593 d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc);
598 //printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]);
600 // odd SM are turned with respect of even SM - reverse indexes
601 AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc));
604 absEta = TMath::Abs(eta);
605 neta = fCentersOfCellsEtaDir.GetSize();
606 etaShift = iphi*neta;
608 if( GetSMType(nSupMod) == kDCAL_Standard) ieta += 16; //jump 16 cells for DCSM
609 dmin = TMath::Abs(fEtaCentersOfCells[etaShift + ieta]-absEta);
610 for(i= ieta+1 ; i<neta; i++) {
611 d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta);
617 if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //jump 16 cells for DCSM
619 AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod));
621 //patch for mapping following alice convention
622 if(nSupMod%2 == 0) {// 47 + 16 -ieta for DCSM, 47 - ieta for others, revert the ordering on A side in order to keep convention.
623 ieta = (neta -1)-ieta;
624 if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //recover cells for DCSM
627 absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
633 //________________________________________________________________________________________________
634 Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t absId) const
636 // May 31, 2006; only trd1 now
637 if(absId<0 || absId >= fNCells) return kFALSE;
641 //________________________________________________________________________________________________
642 Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const
644 // 21-sep-04; 19-oct-05;
645 // May 31, 2006; ALICE numbering scheme:
648 // absId - cell is as in Geant, 0<= absId < fNCells;
650 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
651 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
652 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
653 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
655 if(!CheckAbsCellId(absId)) return kFALSE;
657 static Int_t tmp = absId;
660 for(nSupMod = -1; test >= 0; ) {
663 if( GetSMType(nSupMod) == kEMCAL_Standard) test -= fNCellsInSupMod;
664 else if( GetSMType(nSupMod) == kEMCAL_Half) test -= fNCellsInSupMod/2;
665 else if( GetSMType(nSupMod) == kEMCAL_3rd) test -= fNCellsInSupMod/3;
666 else if( GetSMType(nSupMod) == kDCAL_Standard) test -= 2*fNCellsInSupMod/3;
667 else if( GetSMType(nSupMod) == kDCAL_Ext) test -= fNCellsInSupMod/3;
669 AliError(Form("Uknown SuperModule Type !!"));
673 nModule = tmp / fNCellsInModule;
674 tmp = tmp % fNCellsInModule;
675 nIphi = tmp / fNPHIdiv;
676 nIeta = tmp % fNPHIdiv;
681 //________________________________________________________________________________________________
682 Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const
684 // Return the number of the supermodule given the absolute
685 // ALICE numbering id
687 static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
688 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
692 //________________________________________________________________________________________________
693 void AliEMCALGeometry::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, int &iphim, int &ietam) const
695 // added nSupMod; - 19-oct-05 !
696 // Alice numbering scheme - Jun 01,2006
697 // ietam, iphi - indexes of module in two dimensional grid of SM
698 // ietam - have to change from 0 to fNZ-1
699 // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1)
700 static Int_t nphi=-1;
701 if( GetSMType(nSupMod) == kEMCAL_Half ) nphi = fNPhi/2; // halfSM
702 else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi = fNPhi/3; // 1/3 SM
703 else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi = fNPhi/3; // 1/3 SM
704 else nphi = fNPhi; // full SM
706 ietam = nModule/nphi;
707 iphim = nModule%nphi;
710 //________________________________________________________________________________________________
711 void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta,
712 int &iphi, int &ieta) const
715 // Added nSupMod; Nov 25, 05
716 // Alice numbering scheme - Jun 01,2006
718 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
719 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
720 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
721 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
724 // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM
725 // ieta - have to change from 0 to (fNZ*fNETAdiv-1)
726 // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1)
728 static Int_t iphim=-1, ietam=-1;
730 GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam);
731 // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM)
732 ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM)
733 iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM)
736 AliDebug(1,Form(" nSupMod %i nModule %i nIphi %i nIeta %i => ieta %i iphi %i\n",
737 nSupMod, nModule, nIphi, nIeta, ieta, iphi));
740 // Methods for AliEMCALRecPoint - Feb 19, 2006
741 //________________________________________________________________________________________________
742 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const
744 // Look to see what the relative
745 // position inside a given cell is
747 // Alice numbering scheme - Jun 08, 2006
749 // absId - cell is as in Geant, 0<= absId < fNCells;
751 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
753 // Shift index taking into account the difference between standard SM
754 // and SM of half (or one third) size in phi direction
756 const Int_t kNphiIndex = fCentersOfCellsPhiDir.GetSize();
757 Double_t zshift = 0.5*GetDCALInnerEdge();
759 static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
760 if(!CheckAbsCellId(absId)) return kFALSE;
762 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
763 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
765 //Get eta position. Careful with ALICE conventions (increase index decrease eta)
768 ieta2 = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
770 if( GetSMType(nSupMod) == kDCAL_Standard && nSupMod%2 ) ieta2 += 16; // DCAL revert the ordering on C side ...
771 zr = fCentersOfCellsEtaDir.At(ieta2);
772 if( GetSMType(nSupMod) == kDCAL_Standard ) zr -= zshift; // DCAL shift (SMALLER SM)
773 xr = fCentersOfCellsXDir.At(ieta2);
775 //Get phi position. Careful with ALICE conventions (increase index increase phi)
777 if( GetSMType(nSupMod) == kDCAL_Ext ) {
778 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
779 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
780 } else if( GetSMType(nSupMod) == kEMCAL_Half ){
781 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/2 -1)-iphi; //11-iphi [1/2SM], revert the ordering on C side in order to keep convention.
782 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/4);
783 } else if( GetSMType(nSupMod) == kEMCAL_3rd ){
784 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
785 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
787 if(nSupMod%2 != 0) iphi2 = (kNphiIndex -1)-iphi;// 23-iphi, revert the ordering on C side in order to keep conventi
788 yr = fCentersOfCellsPhiDir.At(iphi2);
790 AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
795 //________________________________________________________________________________________________
796 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const
798 // Look to see what the relative
799 // position inside a given cell is
800 // for a recpoint. // Alice numbering scheme - Jun 03, 2006
801 loc[0] = loc[1] = loc[2]=0.0;
802 if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) {
808 //________________________________________________________________________________________________
809 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, TVector3 &vloc) const
811 // Look to see what the relative
812 // position inside a given cell is
814 // Alice numbering scheme - Jun 03, 2006
815 static Double_t loc[3];
816 if(RelPosCellInSModule(absId,loc)) {
817 vloc.SetXYZ(loc[0], loc[1], loc[2]);
825 //________________________________________________________________________________________________
826 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
828 // Jul 30, 2007 - taking into account position of shower max
829 // Look to see what the relative
830 // position inside a given cell is
833 // absId - cell is as in Geant, 0<= absId < fNCells;
834 // e - cluster energy
836 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
838 // Shift index taking into account the difference between standard SM
839 // and SM of half (or one third) size in phi direction
841 const Int_t kNphiIndex = fCentersOfCellsPhiDir.GetSize();
842 Double_t zshift = 0.5*GetDCALInnerEdge();
843 Int_t kDCalshift = 8;//wangml DCal cut first 8 modules(16 cells)
845 static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
846 static Int_t iphim=-1, ietam=-1;
847 static AliEMCALShishKebabTrd1Module *mod = 0;
849 if(!CheckAbsCellId(absId)) return kFALSE;
851 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
852 GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
853 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
855 //Get eta position. Careful with ALICE conventions (increase index decrease eta)
857 ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 24-ietam, revert the ordering on A side in order to keep convention.
858 if(nIeta == 0) nIeta = 1;
861 if( GetSMType(nSupMod) == kDCAL_Standard && nSupMod%2) ietam += kDCalshift; // DCAL revert the ordering on C side ....
862 mod = GetShishKebabModule(ietam);
863 mod ->GetPositionAtCenterCellLine(nIeta, distEff, v);
864 xr = v.Y() - fParSM[0];
865 zr = v.X() - fParSM[2];
866 if( GetSMType(nSupMod) == kDCAL_Standard ) zr -= zshift; // DCAL shift (SMALLER SM)
868 //Get phi position. Careful with ALICE conventions (increase index increase phi)
870 if( GetSMType(nSupMod) == kDCAL_Ext ) {
871 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
872 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
873 } else if( GetSMType(nSupMod) == kEMCAL_Half ){
874 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/2 -1)-iphi; //11-iphi [1/2SM], revert the ordering on C side in order to keep convention.
875 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/2);
876 } else if( GetSMType(nSupMod) == kEMCAL_3rd ){
877 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
878 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
880 if(nSupMod%2 != 0) iphi2 = (kNphiIndex -1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
881 yr = fCentersOfCellsPhiDir.At(iphi2);
884 AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
889 //________________________________________________________________________________________________
890 void AliEMCALGeometry::CreateListOfTrd1Modules()
892 // Generate the list of Trd1 modules
893 // which will make up the EMCAL
895 // key: look to the AliEMCALShishKebabTrd1Module::
897 AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started "));
899 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
900 if(fShishKebabTrd1Modules == 0) {
901 fShishKebabTrd1Modules = new TList;
902 fShishKebabTrd1Modules->SetName("ListOfTRD1");
903 for(int iz=0; iz< fEMCGeometry->GetNZ(); iz++) {
905 // mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
906 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,fEMCGeometry);
908 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
911 fShishKebabTrd1Modules->Add(mod);
914 AliDebug(2,Form(" Already exits : "));
916 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1);
917 fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0);
919 AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
920 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1));
922 // Jun 01, 2006 - ALICE numbering scheme
923 // define grid for cells in eta(z) and x directions in local coordinates system of SM
924 // Works just for 2x2 case only -- ?? start here
927 // Define grid for cells in phi(y) direction in local coordinates system of SM
928 // as for 2X2 as for 3X3 - Nov 8,2006
930 AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize()));
931 Int_t ind=0; // this is phi index
932 Int_t ieta=0, nModule=0, iphiTemp;
933 Double_t xr=0., zr=0., theta=0., phi=0., eta=0., r=0., x=0.,y=0.;
935 Double_t ytCenterModule=0.0, ytCenterCell=0.0;
937 fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv);
938 fPhiCentersOfCells.Set(fNPhi*fNPHIdiv);
940 Double_t r0 = fIPDistance + fLongModuleSize/2.;
941 for(Int_t it=0; it<fNPhi; it++) { // cycle on modules
942 ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module
943 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module
945 ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.;
946 } else if(fNPHIdiv==3){
947 ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1);
948 } else if(fNPHIdiv==1){
949 ytCenterCell = ytCenterModule;
951 fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind);
952 // Define grid on phi direction
953 // Grid is not the same for different eta bin;
954 // Effect is small but is still here
955 phi = TMath::ATan2(ytCenterCell, r0);
956 fPhiCentersOfCells.AddAt(phi, ind);
958 AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind)));
963 fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv);
964 fCentersOfCellsXDir.Set(fNZ *fNETAdiv);
965 fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv);
966 AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()));
967 for(Int_t it=0; it<fNZ; it++) {
968 AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
970 for(Int_t ic=0; ic<fNETAdiv; ic++) {
972 trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2
973 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
975 trd1->GetCenterOfCellInLocalCoordinateofSM3X3(ic, xr, zr); // case of 3X3
976 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
978 trd1->GetCenterOfCellInLocalCoordinateofSM1X1(xr, zr); // case of 1X1
979 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
981 fCentersOfCellsXDir.AddAt(float(xr) - fParSM[0],ieta);
982 fCentersOfCellsEtaDir.AddAt(float(zr) - fParSM[2],ieta);
983 // Define grid on eta direction for each bin in phi
984 for(int iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
985 x = xr + trd1->GetRadius();
986 y = fCentersOfCellsPhiDir[iphi];
987 r = TMath::Sqrt(x*x + y*y + zr*zr);
988 theta = TMath::ACos(zr/r);
989 eta = AliEMCALShishKebabTrd1Module::ThetaToEta(theta);
990 // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi;
991 ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta;
992 fEtaCentersOfCells.AddAt(eta, ind);
994 //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta);
997 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
998 AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1,
999 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)));
1004 //________________________________________________________________________________________________
1005 AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta) const
1007 //This method was too long to be
1008 //included in the header file - the
1009 //rule checker complained about it's
1010 //length, so we move it here. It returns the
1011 //shishkebabmodule at a given eta index point.
1013 static AliEMCALShishKebabTrd1Module* trd1=0;
1014 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
1015 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);
1020 //___________________________________________________________________
1021 void AliEMCALGeometry::PrintGeometryGeoUtils()
1023 //Print information from geometry
1024 fEMCGeometry->PrintGeometry();
1026 printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
1027 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1);
1029 printf("\n Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize());
1030 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
1031 printf(" ind %2.2i : z %8.3f : x %8.3f \n", i,
1032 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i));
1033 int ind=0; // Nov 21,2006
1034 for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
1035 ind = iphi*fCentersOfCellsEtaDir.GetSize() + i;
1036 printf("%6.4f ", fEtaCentersOfCells[ind]);
1037 if((iphi+1)%12 == 0) printf("\n");
1043 printf("\n Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize());
1044 for(Int_t i=0; i<fCentersOfCellsPhiDir.GetSize(); i++) {
1045 double phi=fPhiCentersOfCells.At(i);
1046 printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i),
1047 phi, phi*TMath::RadToDeg());
1051 //____________________________________________________________________________
1052 Bool_t AliEMCALGeometry::Impact(const TParticle * particle) const
1054 // Tells if a particle enters EMCAL
1057 TVector3 vtx(particle->Vx(),particle->Vy(),particle->Vz());
1058 TVector3 vimpact(0,0,0);
1059 ImpactOnEmcal(vtx,particle->Theta(),particle->Phi(),absID,vimpact);
1064 //____________________________________________________________________________
1065 void AliEMCALGeometry::ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi,
1066 Int_t & absId, TVector3 & vimpact) const
1068 // calculates the impact coordinates on EMCAL (centre of a tower/not on EMCAL surface)
1069 // of a neutral particle
1070 // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system
1072 TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ;
1074 vimpact.SetXYZ(0,0,0);
1076 if(phi==0 || theta==0) return;
1079 Double_t factor = (fIPDistance-vtx[1])/p[1];
1080 direction = vtx + factor*p;
1082 //from particle direction -> tower hitted
1083 GetAbsCellIdFromEtaPhi(direction.Eta(),direction.Phi(),absId);
1085 //tower absID hitted -> tower/module plane (evaluated at the center of the tower)
1086 Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
1087 Double_t loc[3],loc2[3],loc3[3];
1088 Double_t glob[3]={},glob2[3]={},glob3[3]={};
1090 if(!RelPosCellInSModule(absId,loc)) return;
1092 //loc is cell center of tower
1093 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
1095 //look at 2 neighbours-s cell using nIphi={0,1} and nIeta={0,1}
1096 Int_t nIphi2=-1,nIeta2=-1,absId2=-1,absId3=-1;
1097 if(nIeta==0) nIeta2=1;
1099 absId2=GetAbsCellId(nSupMod,nModule,nIphi,nIeta2);
1100 if(nIphi==0) nIphi2=1;
1102 absId3=GetAbsCellId(nSupMod,nModule,nIphi2,nIeta);
1104 //2nd point on emcal cell plane
1105 if(!RelPosCellInSModule(absId2,loc2)) return;
1107 //3rd point on emcal cell plane
1108 if(!RelPosCellInSModule(absId3,loc3)) return;
1111 const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
1113 m->LocalToMaster(loc, glob);
1114 m->LocalToMaster(loc2, glob2);
1115 m->LocalToMaster(loc3, glob3);
1117 AliFatal("Geo matrixes are not loaded \n") ;
1120 //Equation of Plane from glob,glob2,glob3 (Ax+By+Cz+D=0)
1121 Double_t a = glob[1]*(glob2[2]-glob3[2]) + glob2[1]*(glob3[2]-glob[2]) + glob3[1]*(glob[2]-glob2[2]);
1122 Double_t b = glob[2]*(glob2[0]-glob3[0]) + glob2[2]*(glob3[0]-glob[0]) + glob3[2]*(glob[0]-glob2[0]);
1123 Double_t c = glob[0]*(glob2[1]-glob3[1]) + glob2[0]*(glob3[1]-glob[1]) + glob3[0]*(glob[1]-glob2[1]);
1124 Double_t d = glob[0]*(glob2[1]*glob3[2]-glob3[1]*glob2[2]) + glob2[0]*(glob3[1]*glob[2]-glob[1]*glob3[2]) + glob3[0]*(glob[1]*glob2[2]-glob2[1]*glob[2]);
1127 //shift equation of plane from tower/module center to surface along vector (A,B,C) normal to tower/module plane
1128 Double_t dist = fLongModuleSize/2.;
1129 Double_t norm = TMath::Sqrt(a*a+b*b+c*c);
1130 Double_t glob4[3]={};
1131 TVector3 dir(a,b,c);
1132 TVector3 point(glob[0],glob[1],glob[2]);
1133 if(point.Dot(dir)<0) dist*=-1;
1134 glob4[0]=glob[0]-dist*a/norm;
1135 glob4[1]=glob[1]-dist*b/norm;
1136 glob4[2]=glob[2]-dist*c/norm;
1137 d = glob4[0]*a + glob4[1]*b + glob4[2]*c ;
1140 //Line determination (2 points for equation of line : vtx and direction)
1141 //impact between line (particle) and plane (module/tower plane)
1142 Double_t den = a*(vtx(0)-direction(0)) + b*(vtx(1)-direction(1)) + c*(vtx(2)-direction(2));
1144 printf("ImpactOnEmcal() No solution :\n");
1148 Double_t length = a*vtx(0)+b*vtx(1)+c*vtx(2)+d;
1151 vimpact.SetXYZ(vtx(0)+length*(direction(0)-vtx(0)),vtx(1)+length*(direction(1)-vtx(1)),vtx(2)+length*(direction(2)-vtx(2)));
1153 //shift vimpact from tower/module surface to center along vector (A,B,C) normal to tower/module plane
1154 vimpact.SetXYZ(vimpact(0)+dist*a/norm,vimpact(1)+dist*b/norm,vimpact(2)+dist*c/norm);
1159 //_____________________________________________________________________________
1160 Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const
1162 // Checks whether point is inside the EMCal volume
1163 if( IsInEMCALOrDCAL(x,y,z) == 1 ) return kTRUE;
1167 //_____________________________________________________________________________
1168 Bool_t AliEMCALGeometry::IsInDCAL(Double_t x, Double_t y, Double_t z) const
1170 // Checks whether point is inside the DCal volume
1171 if( IsInEMCALOrDCAL(x,y,z) == 2 ) return kTRUE;
1175 //_____________________________________________________________________________
1176 Int_t AliEMCALGeometry::IsInEMCALOrDCAL(Double_t x, Double_t y, Double_t z) const
1178 // Checks whether point is inside the EMCal volume (included DCal), used in AliEMCALv*.cxx
1180 // Code uses cylindrical approximation made of inner radius (for speed)
1182 // Points behind EMCAl/DCal, i.e. R > outer radius, but eta, phi in acceptance
1183 // are considered to inside
1185 Double_t r=sqrt(x*x+y*y);
1187 if ( r <= fEnvelop[0] ) return 0;
1189 Double_t theta = TMath::ATan2(r,z);
1191 if(theta == 0) eta = 9999;
1192 else eta = -TMath::Log(TMath::Tan(theta/2.));
1193 if (eta < fArm1EtaMin || eta > fArm1EtaMax) return 0;
1195 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
1196 if (phi < 0) phi += 360; // phi should go from 0 to 360 in this case
1198 if ( phi >= fArm1PhiMin && phi <= fEMCALPhiMax ) return 1;
1199 else if ( phi >= fDCALPhiMin && phi <= fDCALStandardPhiMax && TMath::Abs(eta) > fDCALInnerExtandedEta ) return 2;
1200 else if ( phi > fDCALStandardPhiMax && phi <= fDCALPhiMax ) return 2;
1205 //________________________________________________________________________________________________
1206 Int_t AliEMCALGeometry::GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const
1209 // Get TRU absolute number from column, row and Super Module number
1210 Int_t itru = row + col*fEMCGeometry->GetNModulesInTRUPhi() + sm*fEMCGeometry->GetNTRU();
1211 // printf(" GetAbsTRUNumberFromNumberInSm : row %2i col %2i sm %2i -> itru %2i\n", row, col, sm, itru);
1215 //________________________________________________________________________________________________
1216 Bool_t AliEMCALGeometry::GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const
1218 //Trigger mapping method, get FastOr Index from TRU
1220 if (iTRU > GetNTotalTRU()-1 || iTRU < 0 || iADC > 95 || iADC < 0)
1222 AliError("TRU out of range!");
1226 id = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4);
1231 //________________________________________________________________________________________________
1232 Bool_t AliEMCALGeometry::GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const
1234 //Trigger mapping method, get TRU number from FastOr Index
1236 Int_t nModule = GetNTotalTRU()*96;
1237 if (id > nModule-1 || id < 0)
1239 AliError("Id out of range!");
1245 iADC = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4);
1249 //________________________________________________________________________________________________
1250 Bool_t AliEMCALGeometry::GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const
1252 //Trigger mapping method, get position in TRU from FasOr Index
1255 if (!GetTRUFromAbsFastORIndex(id, iTRU, iADC)) return kFALSE;
1259 if ( iTRU % 2 ) // C side
1272 //________________________________________________________________________________________________
1273 Bool_t AliEMCALGeometry::GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const
1275 //Trigger mapping method, get position in Super Module from FasOr Index
1278 if (!GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi)) return kFALSE;
1279 if (iTRU % 2) // C side
1281 iSM = 2 * ( int( int(iTRU / 2) / 3 ) ) + 1;
1285 iSM = 2 * ( int( int(iTRU / 2) / 3 ) );
1287 iPhi += 4 * int((iTRU % 6) / 2);
1291 //________________________________________________________________________________________________
1292 Bool_t AliEMCALGeometry::GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const
1294 //Trigger mapping method, get position in EMCAL from FastOR index
1297 if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi))
1299 if (iSM % 2) iEta += 24;
1300 iPhi += 12 * int(iSM / 2);
1306 //________________________________________________________________________________________________
1307 Bool_t AliEMCALGeometry::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const
1309 //Trigger mapping method, get Index if FastOr from Position in TRU
1310 if (iTRU < 0 || iTRU > GetNTotalTRU()-1 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3)
1312 AliError(Form("Out of range! iTRU=%d, iEta=%d, iPhi=%d", iTRU, iEta, iPhi));
1315 id = iPhi + 4 * iEta + iTRU * 96;
1319 //________________________________________________________________________________________________
1320 Bool_t AliEMCALGeometry::GetAbsFastORIndexFromPositionInSM(const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const
1322 //Trigger mapping method, from position in SM Index get FastOR index
1324 Int_t iSMMax = fEMCGeometry->GetNumberOfSuperModules();
1325 Int_t iEtaMax = fEMCGeometry->GetNZ();
1326 Int_t iPhiMax = fEMCGeometry->GetNPhi();
1327 if( GetSMType(iSM) == kEMCAL_3rd || GetSMType(iSM) == kDCAL_Ext ) iPhiMax /= 3;
1328 if( GetSMType(iSM) == kEMCAL_Half ) iPhiMax /= 2;
1329 if( GetSMType(iSM) == kDCAL_Standard ) iEtaMax = iEtaMax*2/3;
1331 if (iSM < 0 || iSM >= iSMMax || iEta < 0 || iEta >= iEtaMax || iPhi < 0 || iPhi >= iPhiMax)
1333 AliError("Out of range!");
1338 Int_t iOff = (iSM % 2) ? 1 : 0;
1339 Int_t iTRU = 2 * int(iPhi / 4) + 6 * int(iSM / 2) + iOff;
1340 if(IsDCALSM(iSM) ) iTRU -=4;
1341 if (GetAbsFastORIndexFromPositionInTRU(iTRU, x, y, id))
1348 //________________________________________________________________________________________________
1349 Bool_t AliEMCALGeometry::GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, const Int_t iPhi, Int_t& id) const
1351 //Trigger mapping method, from position in EMCAL Index get FastOR index
1353 if (iEta < 0 || iEta > 47 || iPhi < 0 || iPhi >= 2*GetNTotalTRU() )//for future DCAL trigge
1355 AliError(Form("Out of range! eta: %2d phi: %2d", iEta, iPhi));
1358 if (fFastOR2DMap[iEta][iPhi] == -1)
1360 AliError("Invalid index!");
1363 id = fFastOR2DMap[iEta][iPhi];
1367 //________________________________________________________________________________________________
1368 Bool_t AliEMCALGeometry::GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const
1370 //Trigger mapping method, from cell index get FastOR index
1372 Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam;
1373 Bool_t isOK = GetCellIndex( id, iSupMod, nModule, nIphi, nIeta );
1374 GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam );
1375 if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx))
1382 //________________________________________________________________________________________________
1383 Bool_t AliEMCALGeometry::GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const
1385 //Trigger mapping method, from FASTOR index get cell index
1387 Int_t iSM=-1, iEta=-1, iPhi=-1;
1388 if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi))
1390 Int_t ix = 2 * iEta;
1391 Int_t iy = 2 * iPhi;
1392 for (Int_t i=0; i<2; i++)
1394 for (Int_t j=0; j<2; j++)
1396 idx[2*i+j] = GetAbsCellIdFromCellIndexes(iSM, iy + i, ix + j);
1404 //________________________________________________________________________________________________
1405 Bool_t AliEMCALGeometry::GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const
1407 //Trigger mapping method, from STU index get TRU index
1409 idx = GetTRUIndexFromSTUIndex(id);
1410 if (idx > GetNTotalTRU()-1 || idx < 0)
1412 AliError(Form("TRU index out of range: %d",idx));
1418 //________________________________________________________________________________________________
1419 Int_t AliEMCALGeometry::GetTRUIndexFromSTUIndex(const Int_t id) const
1421 //Trigger mapping method, from STU index get TRU index
1423 if (id > GetNTotalTRU()-1 || id < 0)
1425 AliError(Form("TRU index out of range: %d",id));
1430 idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1;
1431 } else if(id >= 32){// DCAL
1432 idx = (id > 32+3*fnSupModInDCAL/2-1) ? 2 * (GetNTotalTRU()-1 - id)+32 : 2 * (32+3*fnSupModInDCAL/2-1 - id) + 32+1;
1437 //________________________________________________________________________________________________
1438 void AliEMCALGeometry::BuildFastOR2DMap()
1442 for (Int_t i = 0; i < GetNTotalTRU(); i++)
1444 for (Int_t j = 0; j < 24; j++)
1446 for (Int_t k = 0; k < 4; k++)
1449 if (GetAbsFastORIndexFromPositionInTRU(i, j, k, id))
1451 Int_t x = j, y = k + 4 * int(i / 2);
1453 fFastOR2DMap[x][y] = id;
1460 //________________________________________________________________________________________________
1461 Bool_t AliEMCALGeometry::GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const
1463 //Trigger mapping method, from STU index get TRU index
1465 idx = GetOnlineIndexFromTRUIndex(id);
1466 if (idx > GetNTotalTRU()-1 || idx < 0)
1468 AliError(Form("TRU index out of range: %d",idx));
1474 //________________________________________________________________________________________________
1475 Int_t AliEMCALGeometry::GetTRUIndexFromOnlineIndex(const Int_t id) const
1477 //Trigger mapping method, from STU index get TRU index
1479 if (id > GetNTotalTRU()-1 || id < 0)
1481 AliError(Form("TRU index out of range: %d",id));
1486 if (fGeoName.Contains("DCAL_8SM") && id == 51) {
1490 //jump 4 TRUs for DCAL
1492 if(id > 31) tmp = id+4;
1494 Int_t idx = ((tmp% 6) < 3) ? 6 * int(tmp/ 6) + 2 * (tmp% 3) : 6 * int(tmp/ 6) + 2 * (2 - (tmp% 3)) + 1;
1499 //________________________________________________________________________________________________
1500 Bool_t AliEMCALGeometry::GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const
1502 //Trigger mapping method, from STU index get TRU index
1504 idx = GetOnlineIndexFromTRUIndex(id);
1505 if (idx > GetNTotalTRU()-1 || idx < 0)
1507 AliError(Form("TRU index out of range: %d",idx));
1512 //________________________________________________________________________________________________
1513 Int_t AliEMCALGeometry::GetOnlineIndexFromTRUIndex(const Int_t id) const
1515 //Trigger mapping method, from STU index get TRU index
1517 if (id > GetNTotalTRU()-1 || id < 0)
1519 AliError(Form("TRU index out of range: %d",id));
1524 if (fGeoName.Contains("DCAL_8SM") && id == 51) {
1528 //jump 4 TRUs for DCAL
1530 if(id > 31) tmp = id+4;
1532 Int_t idx = (tmp % 2) ? int((6 - (tmp % 6)) / 2) + 3 * (2 * int(tmp / 6) + 1) : 3 * int(tmp / 6) + int(tmp / 2);
1537 //________________________________________________________________________________________________
1538 Bool_t AliEMCALGeometry::GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const
1540 //Trigger mapping method, from L0 index get FastOR index
1542 if (size <= 0 ||size > 4)
1544 AliError("Size not supported!");
1548 Int_t motif[4] = {0, 1, 4, 5};
1551 case 1: // Cosmic trigger
1552 if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE;
1555 for (Int_t k = 0; k < 4; k++)
1557 Int_t iADC = motif[k] + 4 * int(id / 3) + (id % 3);
1559 if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE;
1569 //____________________________________________________________________________
1570 const TGeoHMatrix * AliEMCALGeometry::GetMatrixForSuperModule(Int_t smod) const
1572 //Provides shift-rotation matrix for EMCAL
1574 if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules())
1575 AliFatal(Form("Wrong supermodule index -> %d",smod));
1577 //If GeoManager exists, take matrixes from it
1580 // if(fKey110DEG && ind>=10) {
1583 // if(!gGeoManager->cd(volpath.Data()))
1584 // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data()));
1586 // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
1588 //Use matrices set externally
1589 if(!gGeoManager || (gGeoManager && fUseExternalMatrices)){
1590 if(fkSModuleMatrix[smod]){
1591 return fkSModuleMatrix[smod] ;
1595 printf("\t Can not find EMCAL misalignment matrixes\n") ;
1596 printf("\t Either import TGeoManager from geometry.root or \n");
1597 printf("\t read stored matrixes from AliESD Header: \n") ;
1598 printf("\t AliEMCALGeometry::SetMisalMatrixes(header->GetEMCALMisalMatrix()) \n") ;
1601 }//external matrices
1604 const Int_t buffersize = 255;
1605 char path[buffersize] ;
1609 //Get the order for SM
1610 for( Int_t i = 0; i < smod+1; i++){
1611 if(GetSMType(i) == tmpType) {
1614 tmpType = GetSMType(i);
1619 if(GetSMType(smod) == kEMCAL_Standard ) SMName = "SMOD";
1620 else if(GetSMType(smod) == kEMCAL_Half ) SMName = "SM10";
1621 else if(GetSMType(smod) == kEMCAL_3rd ) SMName = "SM3rd";
1622 else if( GetSMType(smod) == kDCAL_Standard ) SMName = "DCSM";
1623 else if( GetSMType(smod) == kDCAL_Ext ) SMName = "DCEXT";
1624 else AliError("Unkown SM Type!!");
1625 snprintf(path,buffersize,"/ALIC_1/XEN1_1/%s_%d", SMName.Data(), SMOrder) ;
1627 if (!gGeoManager->cd(path)){
1628 AliFatal(Form("Geo manager can not find path %s!\n",path));
1630 return gGeoManager->GetCurrentMatrix();
1635 //______________________________________________________________________
1636 void AliEMCALGeometry::GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const
1638 // This method transforms the (eta,phi) index of module in a
1639 // TRU matrix into Super Module (eta,phi) index.
1641 // Calculate in which row and column where the TRU are
1642 // ordered in the SM
1644 Int_t col = itru/fEMCGeometry->GetNTRUPhi() ; // indexes of TRU in SM
1645 Int_t row = itru - col*fEMCGeometry->GetNTRUPhi();
1647 iphiSM = fEMCGeometry->GetNModulesInTRUPhi()*row + iphitru ;
1648 ietaSM = fEMCGeometry->GetNModulesInTRUEta()*col + ietatru ;
1651 //__________________________________________________________________________________________________________________
1652 void AliEMCALGeometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth,
1653 const Float_t misaligTransShifts[15], const Float_t misaligRotShifts[15], Float_t global[3]) const
1655 //Transform clusters cell position into global with alternative method, taking into account the depth calculation.
1656 //Input are: the tower indeces,
1658 // particle type (photon 0, electron 1, hadron 2 )
1659 // misalignment shifts to global position in case of need.
1660 // Federico.Ronchetti@cern.ch
1662 // To use in a print later
1663 Float_t droworg = drow;
1664 Float_t dcolorg = dcol;
1667 //Recover some stuff
1669 const Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules();
1671 gGeoManager->cd("ALIC_1/XEN1_1");
1672 TGeoNode *geoXEn1 = gGeoManager->GetCurrentNode();
1673 TGeoNodeMatrix *geoSM[nSMod];
1674 TGeoVolume *geoSMVol[nSMod];
1675 TGeoShape *geoSMShape[nSMod];
1676 TGeoBBox *geoBox[nSMod];
1677 TGeoMatrix *geoSMMatrix[nSMod];
1679 for(int iSM = 0; iSM < nSMod; iSM++) {
1680 geoSM[iSM] = dynamic_cast<TGeoNodeMatrix *>(geoXEn1->GetDaughter(iSM));
1681 geoSMVol[iSM] = geoSM[iSM]->GetVolume();
1682 geoSMShape[iSM] = geoSMVol[iSM]->GetShape();
1683 geoBox[iSM] = dynamic_cast<TGeoBBox *>(geoSMShape[iSM]);
1684 geoSMMatrix[iSM] = geoSM[iSM]->GetMatrix();
1697 Float_t x,y,z; // return variables in terry's RF
1699 //***********************************************************
1700 //Do not like this: too many hardcoded values, is it not already stored somewhere else?
1701 // : need more comments in the code
1702 //***********************************************************
1704 Float_t dz = 6.0; // base cell width in eta
1705 Float_t dx = 6.004; // base cell width in phi
1708 //Float_t L = 26.04; // active tower length for hadron (lead+scint+paper)
1709 // we use the geant numbers 13.87*2=27.74
1712 //Do some basic checks
1713 if (dcol >= 47.5 || dcol<-0.5) {
1714 AliError(Form("Bad tower coordinate dcol=%f, where dcol >= 47.5 || dcol<-0.5; org: %f", dcol, dcolorg));
1717 if (drow >= 23.5 || drow<-0.5) {
1718 AliError(Form("Bad tower coordinate drow=%f, where drow >= 23.5 || drow<-0.5; org: %f", drow, droworg));
1721 if (sm >= nSMod || sm < 0) {
1722 AliError(Form("Bad SM number sm=%d, where sm >= %d || sm < 0", nSMod, sm));
1726 istrip = int ((dcol+0.5)/2);
1729 teta1 = TMath::DegToRad() * istrip * 1.5;
1731 // calculation of module corner along z
1732 // as a function of strip
1734 for (int is=0; is<= istrip; is++) {
1736 teta1 = TMath::DegToRad() * (is*1.5 + 0.75);
1738 zIs = zIs + 2*dz*TMath::Cos(teta1);
1740 zIs = zIs + 2*dz*TMath::Cos(teta1) + 2*dz*TMath::Sin(teta1)*TMath::Tan(teta1-0.75*TMath::DegToRad());
1744 z0 = dz*(dcol-2*istrip+0.5);
1745 zb = (2*dz-z0-depth*TMath::Tan(teta1));
1747 z = zIs - zb*TMath::Cos(teta1);
1748 y = depth/TMath::Cos(teta1) + zb*TMath::Sin(teta1);
1750 x = (drow + 0.5)*dx;
1752 // moving the origin from terry's RF
1755 double xx = y - geoBox[sm]->GetDX();
1756 double yy = -x + geoBox[sm]->GetDY();
1757 double zz = z - geoBox[sm]->GetDZ();
1758 const double localIn[3] = {xx, yy, zz};
1760 //geoSMMatrix[sm]->Print();
1761 //printf("TFF Local (row = %d, col = %d, x = %3.2f, y = %3.2f, z = %3.2f)\n", iroworg, icolorg, localIn[0], localIn[1], localIn[2]);
1762 geoSMMatrix[sm]->LocalToMaster(localIn, dglobal);
1763 //printf("TFF Global (row = %2.0f, col = %2.0f, x = %3.2f, y = %3.2f, z = %3.2f)\n", drow, dcol, dglobal[0], dglobal[1], dglobal[2]);
1765 //apply global shifts
1766 if(sm == 2 || sm == 3) {//sector 1
1767 global[0] = dglobal[0] + misaligTransShifts[3] + misaligRotShifts[3]*TMath::Sin(TMath::DegToRad()*20) ;
1768 global[1] = dglobal[1] + misaligTransShifts[4] + misaligRotShifts[4]*TMath::Cos(TMath::DegToRad()*20) ;
1769 global[2] = dglobal[2] + misaligTransShifts[5];
1771 else if(sm == 0 || sm == 1){//sector 0
1772 global[0] = dglobal[0] + misaligTransShifts[0];
1773 global[1] = dglobal[1] + misaligTransShifts[1];
1774 global[2] = dglobal[2] + misaligTransShifts[2];
1777 AliInfo("Careful, correction not implemented yet!");
1778 global[0] = dglobal[0] ;
1779 global[1] = dglobal[1] ;
1780 global[2] = dglobal[2] ;
1784 AliFatal("Geometry boxes information, check that geometry.root is loaded\n");
1788 //__________________________________________________________________________________________________________________
1789 void AliEMCALGeometry::SetMisalMatrix(const TGeoHMatrix * m, Int_t smod)
1791 // Method to set shift-rotational matrixes from ESDHeader
1792 // Move from header due to coding violations : Dec 2,2011 by PAI
1793 fUseExternalMatrices = kTRUE;
1795 if (smod >= 0 && smod < fEMCGeometry->GetNumberOfSuperModules()){
1796 if(!fkSModuleMatrix[smod]) fkSModuleMatrix[smod] = new TGeoHMatrix(*m) ; //Set only if not set yet
1797 } else AliFatal(Form("Wrong supermodule index -> %d",smod));
1800 //__________________________________________________________________________________________________________________
1801 Bool_t AliEMCALGeometry::IsDCALSM(Int_t iSupMod) const
1803 if( fEMCSMSystem[iSupMod] == kDCAL_Standard || fEMCSMSystem[iSupMod] == kDCAL_Ext ) return kTRUE;
1807 //__________________________________________________________________________________________________________________
1808 Bool_t AliEMCALGeometry::IsDCALExtSM(Int_t iSupMod) const
1810 if( fEMCSMSystem[iSupMod] == kDCAL_Ext ) return kTRUE;