]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALGeoUtils.cxx
correct mapping in method GetAbsCellIdFromEtaPhi
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeoUtils.cxx
CommitLineData
0c5b726e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id: AliEMCALGeoUtils.cxx 25590 2008-05-06 07:09:11Z prsnko $ */
17
18//_________________________________________________________________________
19// Geometry class for EMCAL : singleton
20//
21// -- Author: Magali Estienne (magali.estienne@subatech.in2p3.fr)
22
23//
24// Usage:
25// You can create the AliEMCALGeoUtils object independently from anything.
26// You have to use just the correct name of geometry. If name is empty string the
27// default name of geometry will be used.
28//
29// AliEMCALGeoUtils* geom = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL");
30// TGeoManager::Import("geometry.root");
31//
32// MC: If you work with MC data you have to get geometry the next way:
33// == =============================
34// !!!!!!!!! This part has to be modified
35// AliRunLoader *rl = AliRunLoader::GetRunLoader();
36// AliEMCALEMCGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
37// TGeoManager::Import("geometry.root");
38
39
40// --- ROOT system ---
41
42#include <TParticle.h>
43#include <TGeoManager.h>
44#include <TGeoMatrix.h>
45#include <TList.h>
46#include <TBrowser.h>
47
48// --- Standard library ---
49//#include <Riostream.h>
50
51// --- AliRoot header files ---
52#include "AliEMCALGeoUtils.h"
53#include "AliEMCALShishKebabTrd1Module.h"
54
55ClassImp(AliEMCALGeoUtils)
56
57//____________________________________________________________________________
58AliEMCALGeoUtils::AliEMCALGeoUtils():
59 fEMCGeometry(0x0),fGeoName(0),
60 fKey110DEG(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0),
61 fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0),
62 fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0),
63 fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0),
64 fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0),
65 fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0),
66 fShishKebabTrd1Modules(0),fParSM(0x0),fPhiModuleSize(0.),
67 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0),
68 fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.),
69 fZLength(0.),fSampling(0.)
70{
71 // default ctor
72 // must be kept public for root persistency purposes, but should never be called by the outside world
73 fEnvelop[0] = 0.;
74 fEnvelop[1] = 0.;
75 fEnvelop[2] = 0.;
76
77}
78
79//____________________________________________________________________________
80AliEMCALGeoUtils::AliEMCALGeoUtils(const AliEMCALGeoUtils & geo)
81 : TNamed(geo),
82 fEMCGeometry(geo.fEMCGeometry),fGeoName(geo.fGeoName),
83 fKey110DEG(geo.fKey110DEG),fNCellsInSupMod(geo.fNCellsInSupMod),fNETAdiv(geo.fNETAdiv),fNPHIdiv(geo.fNPHIdiv),
84 fNCellsInModule(geo.fNCellsInModule),fPhiBoundariesOfSM(geo.fPhiBoundariesOfSM),fPhiCentersOfSM(geo.fPhiCentersOfSM),
85 fPhiCentersOfCells(geo.fPhiCentersOfCells),fCentersOfCellsEtaDir(geo.fCentersOfCellsEtaDir),
86 fCentersOfCellsPhiDir(geo.fCentersOfCellsPhiDir),fEtaCentersOfCells(geo.fEtaCentersOfCells),
87 fNCells(geo.fNCells),fNPhi(geo.fNPhi),fCentersOfCellsXDir(geo.fCentersOfCellsXDir),fArm1EtaMin(geo.fArm1EtaMin),
88 fArm1EtaMax(geo.fArm1EtaMax),fArm1PhiMin(geo.fArm1PhiMin),fArm1PhiMax(geo.fArm1PhiMax),fEtaMaxOfTRD1(geo.fEtaMaxOfTRD1),
89 fShishKebabTrd1Modules(geo.fShishKebabTrd1Modules),fParSM(geo.fParSM),fPhiModuleSize(geo.fPhiModuleSize),
90 fEtaModuleSize(geo.fEtaModuleSize),fPhiTileSize(geo.fPhiTileSize),fEtaTileSize(geo.fEtaTileSize),fNZ(geo.fNZ),
91 fIPDistance(geo.fIPDistance),fLongModuleSize(geo.fLongModuleSize),fShellThickness(geo.fShellThickness),
92 fZLength(geo.fZLength),fSampling(geo.fSampling)
93{
94 fEnvelop[0] = geo.fEnvelop[0];
95 fEnvelop[1] = geo.fEnvelop[1];
96 fEnvelop[2] = geo.fEnvelop[2];
97}
98
99//____________________________________________________________________________
100AliEMCALGeoUtils::AliEMCALGeoUtils(const Text_t* name, const Text_t* title)
101 : TNamed(name, title),
102 fEMCGeometry(0x0),fGeoName(0),
103 fKey110DEG(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0),
104 fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0),
105 fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0),
106 fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0),
107 fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0),
108 fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0),
109 fShishKebabTrd1Modules(0),fParSM(0x0),fPhiModuleSize(0.),
110 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0),
111 fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.),
112 fZLength(0.),fSampling(0.)
113{
114
115 // ctor only for normal usage
116
117 fEMCGeometry = new AliEMCALEMCGeometry(name,title);
118
119 fGeoName = fEMCGeometry->GetGeoName();
120 fKey110DEG = fEMCGeometry->GetKey110DEG();
121 fNCellsInSupMod = fEMCGeometry->GetNCellsInSupMod();
122 fNETAdiv = fEMCGeometry->GetNETAdiv();
123 fNPHIdiv = fEMCGeometry->GetNPHIdiv();
124 fNCellsInModule = fNPHIdiv*fNETAdiv;
125 static int i;
126 Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules();
127 fPhiBoundariesOfSM.Set(nSMod);
128 fPhiCentersOfSM.Set(nSMod/2);
129 for(Int_t sm=0; sm<nSMod; sm++) {
130 i = sm/2;
131 fEMCGeometry->GetPhiBoundariesOfSM(sm,fPhiBoundariesOfSM[2*i],fPhiBoundariesOfSM[2*i+1]);
132 }
133
134 Double_t phiMin = 0.;
135 Double_t phiMax = 0.;
136 for(Int_t sm=0; sm<nSMod; sm++) {
137 fEMCGeometry->GetPhiBoundariesOfSM(sm,phiMin,phiMax);
138 i=sm/2;
139 fPhiCentersOfSM[i] = fEMCGeometry->GetPhiCenterOfSM(sm);
140 }
141 fNCells = fEMCGeometry->GetNCells();
142 fNPhi = fEMCGeometry->GetNPhi();
143 fEnvelop[0] = fEMCGeometry->GetEnvelop(0);
144 fEnvelop[1] = fEMCGeometry->GetEnvelop(1);
145 fEnvelop[2] = fEMCGeometry->GetEnvelop(2);
146 fArm1EtaMin = fEMCGeometry->GetArm1EtaMin();
147 fArm1EtaMax = fEMCGeometry->GetArm1EtaMax();
148 fArm1PhiMin = fEMCGeometry->GetArm1PhiMin();
149 fArm1PhiMax = fEMCGeometry->GetArm1PhiMax();
150 fShellThickness = fEMCGeometry->GetShellThickness();
151 fZLength = fEMCGeometry->GetZLength();
152 fSampling = fEMCGeometry->GetSampling();
153 fParSM = fEMCGeometry->GetSuperModulesPars();
154 fEtaModuleSize = fEMCGeometry->GetEtaModuleSize();
155 fPhiModuleSize = fEMCGeometry->GetPhiModuleSize();
156 fEtaTileSize = fEMCGeometry->GetEtaTileSize();
157 fPhiTileSize = fEMCGeometry->GetPhiTileSize();
158 fNZ = fEMCGeometry->GetNZ();
159 fIPDistance = fEMCGeometry->GetIPDistance();
160 fLongModuleSize = fEMCGeometry->GetLongModuleSize();
161
162 CreateListOfTrd1Modules();
163
164 for(Int_t smod=0; smod < fEMCGeometry->GetNumberOfSuperModules(); smod++)
165 fkSModuleMatrix[smod]=0 ;
166
167 if (AliDebugLevel()>=2) {
168 fEMCGeometry->Print();
169 PrintGeometry();
170 }
171
172}
173
174//____________________________________________________________________________
175AliEMCALGeoUtils & AliEMCALGeoUtils::operator = (const AliEMCALGeoUtils & /*rvalue*/) {
176
177 Fatal("assignment operator", "not implemented") ;
178 return *this ;
179}
180
181//____________________________________________________________________________
182AliEMCALGeoUtils::~AliEMCALGeoUtils(void)
183{
184 // dtor
185 if(fEMCGeometry){
186 delete fEMCGeometry; fEMCGeometry = 0 ;
187 }
188}
189
190
191//________________________________________________________________________________________________
192void AliEMCALGeoUtils::Browse(TBrowser* b)
193{
194 //Browse the modules
195 if(fShishKebabTrd1Modules) b->Add(fShishKebabTrd1Modules);
196}
197
198//________________________________________________________________________________________________
199Bool_t AliEMCALGeoUtils::IsFolder() const
200{
201 //Check if fShishKebabTrd1Modules is in folder
202 if(fShishKebabTrd1Modules) return kTRUE;
203 else return kFALSE;
204}
205
206//________________________________________________________________________________________________
207void AliEMCALGeoUtils::GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
208{
209 // Figure out the global numbering
210 // of a given supermodule from the
211 // local numbering and the transformation
212 // matrix stored by the geometry manager (allows for misaligned
213 // geometry)
0c5b726e 214
215 const TGeoHMatrix* m = GetMatrixForSuperModule(ind);
216 if(m) {
217 m->LocalToMaster(loc, glob);
218 } else {
219 AliFatal("Geo matrixes are not loaded \n") ;
220 }
0c5b726e 221}
222
223//________________________________________________________________________________________________
224void AliEMCALGeoUtils::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const
225{
226 //Figure out the global numbering
227 //of a given supermodule from the
228 //local numbering given a 3-vector location
229
230 static Double_t tglob[3], tloc[3];
231 vloc.GetXYZ(tloc);
232 GetGlobal(tloc, tglob, ind);
233 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
234}
235
236//________________________________________________________________________________________________
237void AliEMCALGeoUtils::GetGlobal(Int_t absId , double glob[3]) const
238{
239 // Alice numbering scheme - Jun 03, 2006
240 static Int_t nSupMod, nModule, nIphi, nIeta;
241 static double loc[3];
242
0c5b726e 243 glob[0]=glob[1]=glob[2]=0.0; // bad case
244 if(RelPosCellInSModule(absId, loc)) {
245 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
246
0c5b726e 247 const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
248 if(m) {
249 m->LocalToMaster(loc, glob);
250 } else {
251 AliFatal("Geo matrixes are not loaded \n") ;
252 }
253 }
254}
255
256//___________________________________________________________________
257void AliEMCALGeoUtils::GetGlobal(Int_t absId , TVector3 &vglob) const
258{
259 // Alice numbering scheme - Jun 03, 2006
260 static Double_t glob[3];
261
262 GetGlobal(absId, glob);
263 vglob.SetXYZ(glob[0], glob[1], glob[2]);
264
265}
266
267
268//______________________________________________________________________
269void AliEMCALGeoUtils::PrintCellIndexes(Int_t absId, int pri, const char *tit) const
270{
271 // Service methods
272 Int_t nSupMod, nModule, nIphi, nIeta;
273 Int_t iphi, ieta;
274 TVector3 vg;
275
276 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
277 printf(" %s | absId : %i -> nSupMod %i nModule %i nIphi %i nIeta %i \n", tit, absId, nSupMod, nModule, nIphi, nIeta);
278 if(pri>0) {
279 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
280 printf(" local SM index : iphi %i : ieta %i \n", iphi,ieta);
281 GetGlobal(absId, vg);
282 printf(" vglob : mag %7.2f : perp %7.2f : z %7.2f : eta %6.4f : phi %6.4f(%6.2f) \n",
283 vg.Mag(), vg.Perp(), vg.Z(), vg.Eta(), vg.Phi(), vg.Phi()*TMath::RadToDeg());
284 }
285}
286
287//________________________________________________________________________________________________
288void AliEMCALGeoUtils::EtaPhiFromIndex(Int_t absId,Double_t &eta,Double_t &phi) const
289{
290 // Nov 16, 2006- float to double
291 // version for TRD1 only
292 static TVector3 vglob;
293 GetGlobal(absId, vglob);
294 eta = vglob.Eta();
295 phi = vglob.Phi();
296}
297
298//________________________________________________________________________________________________
299void AliEMCALGeoUtils::EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const
300{
301 // Nov 16,2006 - should be discard in future
302 static TVector3 vglob;
303 GetGlobal(absId, vglob);
304 eta = float(vglob.Eta());
305 phi = float(vglob.Phi());
306}
307
308//
309// == Shish-kebab cases ==
310//
311//________________________________________________________________________________________________
312Int_t AliEMCALGeoUtils::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const
313{
314 // 27-aug-04;
315 // corr. 21-sep-04;
316 // 13-oct-05; 110 degree case
317 // May 31, 2006; ALICE numbering scheme:
318 // 0 <= nSupMod < fNumberOfSuperModules
319 // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
320 // 0 <= nIphi < fNPHIdiv
321 // 0 <= nIeta < fNETAdiv
322 // 0 <= absid < fNCells
323 static Int_t id=0; // have to change from 0 to fNCells-1
324 if(fKey110DEG == 1 && nSupMod >= 10) { // 110 degree case; last two supermodules
325 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-10);
326 } else {
327 id = fNCellsInSupMod*nSupMod;
328 }
329 id += fNCellsInModule *nModule;
330 id += fNPHIdiv *nIphi;
331 id += nIeta;
332 if(id<0 || id >= fNCells) {
333// printf(" wrong numerations !!\n");
334// printf(" id %6i(will be force to -1)\n", id);
335// printf(" fNCells %6i\n", fNCells);
336// printf(" nSupMod %6i\n", nSupMod);
337// printf(" nModule %6i\n", nModule);
338// printf(" nIphi %6i\n", nIphi);
339// printf(" nIeta %6i\n", nIeta);
340 id = -TMath::Abs(id); // if negative something wrong
341 }
342 return id;
343}
344
345//________________________________________________________________________________________________
346void AliEMCALGeoUtils::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
347 Int_t &iphim, Int_t &ietam, Int_t &nModule) const
348{
349 // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
350 static Int_t nphi;
351 nphi = GetNumberOfModuleInPhiDirection(nSupMod);
352
353 ietam = ieta/fNETAdiv;
354 iphim = iphi/fNPHIdiv;
355 nModule = ietam * nphi + iphim;
356}
357
358//________________________________________________________________________________________________
359Int_t AliEMCALGeoUtils::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
360{
361 // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId
362 static Int_t ietam, iphim, nModule;
363 static Int_t nIeta, nIphi; // cell indexes in module
364
365 GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule);
366
367 nIeta = ieta%fNETAdiv;
368 nIeta = fNETAdiv - 1 - nIeta;
369 nIphi = iphi%fNPHIdiv;
370
371 return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
372}
373
374//________________________________________________________________________________________________
375Bool_t AliEMCALGeoUtils::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const
376{
377 // Return false if phi belongs a phi cracks between SM
378
379 static Int_t i;
380
381 if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE;
382
383 phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
384 for(i=0; i<6; i++) {
385 if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) {
386 nSupMod = 2*i;
387 if(eta < 0.0) nSupMod++;
388 AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i));
389 return kTRUE;
390 }
391 }
392 return kFALSE;
393}
394
395
396//________________________________________________________________________________________________
397Bool_t AliEMCALGeoUtils::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const
398{
399 // Nov 17,2006
400 // stay here - phi problem as usual
401 static Int_t nSupMod, i, ieta, iphi, etaShift, nphi;
402 static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc;
403 absId = nSupMod = - 1;
404 if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
405 // phi index first
406 phi = TVector2::Phi_0_2pi(phi);
407 phiLoc = phi - fPhiCentersOfSM[nSupMod/2];
408 nphi = fPhiCentersOfCells.GetSize();
409 if(nSupMod>=10) {
410 phiLoc = phi - 190.*TMath::DegToRad();
411 nphi /= 2;
412 }
413
414 dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc);
415 iphi = 0;
416 for(i=1; i<nphi; i++) {
417 d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc);
418 if(d < dmin) {
419 dmin = d;
420 iphi = i;
421 }
422 // printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]);
423 }
424 // odd SM are turned with respect of even SM - reverse indexes
425 AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc));
426 // eta index
427 absEta = TMath::Abs(eta);
428 etaShift = iphi*fCentersOfCellsEtaDir.GetSize();
429 dmin = TMath::Abs(fEtaCentersOfCells[etaShift]-absEta);
430 ieta = 0;
431 for(i=1; i<fCentersOfCellsEtaDir.GetSize(); i++) {
432 d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta);
433 if(d < dmin) {
434 dmin = d;
435 ieta = i;
436 }
437 }
438 AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod));
439
440 if(eta<0) iphi = (nphi-1) - iphi;
02194d2d 441
442 //patch for mapping following alice convention
443 if(nSupMod%2 == 0)
444 ieta = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
445 else {
446 if(nSupMod<10)
447 iphi = (fCentersOfCellsPhiDir.GetSize()-1) -iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
448 else
449 iphi = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
450 }
451
0c5b726e 452 absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
453
454 return kTRUE;
455 }
456 return kFALSE;
457}
458
459//________________________________________________________________________________________________
460Bool_t AliEMCALGeoUtils::CheckAbsCellId(Int_t absId) const
461{
462 // May 31, 2006; only trd1 now
463 if(absId<0 || absId >= fNCells) return kFALSE;
464 else return kTRUE;
465}
466
467//________________________________________________________________________________________________
468Bool_t AliEMCALGeoUtils::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const
469{
470 // 21-sep-04; 19-oct-05;
471 // May 31, 2006; ALICE numbering scheme:
472 //
473 // In:
474 // absId - cell is as in Geant, 0<= absId < fNCells;
475 // Out:
476 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
477 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
478 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
479 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
480 //
481 static Int_t tmp=0, sm10=0;
482 if(!CheckAbsCellId(absId)) return kFALSE;
483
484 sm10 = fNCellsInSupMod*10;
485 if(fKey110DEG == 1 && absId >= sm10) { // 110 degree case; last two supermodules
486 nSupMod = (absId-sm10) / (fNCellsInSupMod/2) + 10;
487 tmp = (absId-sm10) % (fNCellsInSupMod/2);
488 } else {
489 nSupMod = absId / fNCellsInSupMod;
490 tmp = absId % fNCellsInSupMod;
491 }
492
493 nModule = tmp / fNCellsInModule;
494 tmp = tmp % fNCellsInModule;
495 nIphi = tmp / fNPHIdiv;
496 nIeta = tmp % fNPHIdiv;
497
498 return kTRUE;
499}
500
501//________________________________________________________________________________________________
502Int_t AliEMCALGeoUtils::GetSuperModuleNumber(Int_t absId) const
503{
504 // Return the number of the supermodule given the absolute
505 // ALICE numbering id
506
507 static Int_t nSupMod, nModule, nIphi, nIeta;
508 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
509 return nSupMod;
510}
511
512//________________________________________________________________________________________________
513void AliEMCALGeoUtils::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, int &iphim, int &ietam) const
514{
515 // added nSupMod; - 19-oct-05 !
516 // Alice numbering scheme - Jun 01,2006
517 // ietam, iphi - indexes of module in two dimensional grid of SM
518 // ietam - have to change from 0 to fNZ-1
519 // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1)
520 static Int_t nphi;
521
522 if(fKey110DEG == 1 && nSupMod>=10) nphi = fNPhi/2;
523 else nphi = fNPhi;
524
525 ietam = nModule/nphi;
526 iphim = nModule%nphi;
527}
528
529//________________________________________________________________________________________________
530void AliEMCALGeoUtils::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta,
531int &iphi, int &ieta) const
532{
533 //
534 // Added nSupMod; Nov 25, 05
535 // Alice numbering scheme - Jun 01,2006
536 // IN:
537 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
538 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
539 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
540 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
541 //
542 // OUT:
543 // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM
544 // ieta - have to change from 0 to (fNZ*fNETAdiv-1)
545 // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1)
546 //
547 static Int_t iphim, ietam;
548
549 GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam);
550 // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM)
551 ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM)
552 iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM)
553
554 if(iphi<0 || ieta<0)
555 AliDebug(1,Form(" nSupMod %i nModule %i nIphi %i nIeta %i => ieta %i iphi %i\n",
556 nSupMod, nModule, nIphi, nIeta, ieta, iphi));
557}
558
559
560// Methods for AliEMCALRecPoint - Feb 19, 2006
561//________________________________________________________________________________________________
562Bool_t AliEMCALGeoUtils::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const
563{
564 // Look to see what the relative
565 // position inside a given cell is
566 // for a recpoint.
567 // Alice numbering scheme - Jun 08, 2006
568 // In:
569 // absId - cell is as in Geant, 0<= absId < fNCells;
570 // OUT:
571 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
572
573 // Shift index taking into account the difference between standard SM
574 // and SM of half size in phi direction
575 const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
576 static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta;
577 if(!CheckAbsCellId(absId)) return kFALSE;
578
579 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
580 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
dd91d8ac 581
f8a955ba 582 //Get eta position. Careful with ALICE conventions (increase index decrease eta)
583 Int_t ieta2 = ieta;
584 if(nSupMod%2 == 0)
585 ieta2 = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
586 zr = fCentersOfCellsEtaDir.At(ieta2);
587 xr = fCentersOfCellsXDir.At(ieta2);
588
589 //Get phi position. Careful with ALICE conventions (increase index increase phi)
dd91d8ac 590 Int_t iphi2 = iphi;
dd91d8ac 591 if(nSupMod<10) {
592 if(nSupMod%2 != 0)
593 iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
594 yr = fCentersOfCellsPhiDir.At(iphi2);
595
0c5b726e 596 } else {
dd91d8ac 597 if(nSupMod%2 != 0)
598 iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
599 yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift);
0c5b726e 600 }
601 AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
602
603 return kTRUE;
604}
605
606//________________________________________________________________________________________________
607Bool_t AliEMCALGeoUtils::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const
608{
609 // Look to see what the relative
610 // position inside a given cell is
611 // for a recpoint. // Alice numbering scheme - Jun 03, 2006
612 loc[0] = loc[1] = loc[2]=0.0;
613 if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) {
614 return kTRUE;
615 }
616 return kFALSE;
617}
618
619//________________________________________________________________________________________________
620Bool_t AliEMCALGeoUtils::RelPosCellInSModule(Int_t absId, TVector3 &vloc) const
621{
622 // Look to see what the relative
623 // position inside a given cell is
624 // for a recpoint.
625 // Alice numbering scheme - Jun 03, 2006
626 static Double_t loc[3];
627 if(RelPosCellInSModule(absId,loc)) {
628 vloc.SetXYZ(loc[0], loc[1], loc[2]);
629 return kTRUE;
630 } else {
631 vloc.SetXYZ(0,0,0);
632 return kFALSE;
633 }
634}
635
636//________________________________________________________________________________________________
637void AliEMCALGeoUtils::CreateListOfTrd1Modules()
638{
639 // Generate the list of Trd1 modules
640 // which will make up the EMCAL
641 // geometry
642
643 AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started "));
644
645 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
646 if(fShishKebabTrd1Modules == 0) {
647 fShishKebabTrd1Modules = new TList;
648 fShishKebabTrd1Modules->SetName("ListOfTRD1");
649 for(int iz=0; iz< fEMCGeometry->GetNZ(); iz++) {
650 if(iz==0) {
651 // mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
652 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,fEMCGeometry);
653 } else {
654 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
655 mod = mTmp;
656 }
657 fShishKebabTrd1Modules->Add(mod);
658 }
659 } else {
660 AliDebug(2,Form(" Already exits : "));
661 }
662 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1);
663 fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0);
664
665 AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
666 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1));
667 // Feb 20,2006;
668 // Jun 01, 2006 - ALICE numbering scheme
669 // define grid for cells in eta(z) and x directions in local coordinates system of SM
670 // Works just for 2x2 case only -- ?? start here
671 //
672 //
673 // Define grid for cells in phi(y) direction in local coordinates system of SM
674 // as for 2X2 as for 3X3 - Nov 8,2006
675 //
676 AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize()));
677 Int_t ind=0; // this is phi index
678 Int_t ieta=0, nModule=0, iphiTemp;
679 Double_t xr=0., zr=0., theta=0., phi=0., eta=0., r=0., x=0.,y=0.;
680 TVector3 vglob;
681 Double_t ytCenterModule=0.0, ytCenterCell=0.0;
682
683 fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv);
684 fPhiCentersOfCells.Set(fNPhi*fNPHIdiv);
685
686 Double_t r0 = fIPDistance + fLongModuleSize/2.;
687 for(Int_t it=0; it<fNPhi; it++) { // cycle on modules
688 ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module
689 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module
690 if(fNPHIdiv==2) {
691 ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.;
692 } else if(fNPHIdiv==3){
693 ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1);
694 } else if(fNPHIdiv==1){
695 ytCenterCell = ytCenterModule;
696 }
697 fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind);
698 // Define grid on phi direction
699 // Grid is not the same for different eta bin;
700 // Effect is small but is still here
701 phi = TMath::ATan2(ytCenterCell, r0);
702 fPhiCentersOfCells.AddAt(phi, ind);
703
704 AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind)));
705 ind++;
706 }
707 }
708
709 fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv);
710 fCentersOfCellsXDir.Set(fNZ *fNETAdiv);
711 fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv);
712 AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()));
713 for(Int_t it=0; it<fNZ; it++) {
714 AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
715 nModule = fNPhi*it;
716 for(Int_t ic=0; ic<fNETAdiv; ic++) {
717 if(fNPHIdiv==2) {
718 trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2
719 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
720 } if(fNPHIdiv==3) {
721 trd1->GetCenterOfCellInLocalCoordinateofSM3X3(ic, xr, zr); // case of 3X3
722 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
723 } if(fNPHIdiv==1) {
724 trd1->GetCenterOfCellInLocalCoordinateofSM1X1(xr, zr); // case of 1X1
725 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
726 }
727 fCentersOfCellsXDir.AddAt(float(xr) - fParSM[0],ieta);
728 fCentersOfCellsEtaDir.AddAt(float(zr) - fParSM[2],ieta);
729 // Define grid on eta direction for each bin in phi
730 for(int iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
731 x = xr + trd1->GetRadius();
732 y = fCentersOfCellsPhiDir[iphi];
733 r = TMath::Sqrt(x*x + y*y + zr*zr);
734 theta = TMath::ACos(zr/r);
735 eta = AliEMCALShishKebabTrd1Module::ThetaToEta(theta);
736 // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi;
737 ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta;
738 fEtaCentersOfCells.AddAt(eta, ind);
739 }
740 //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta);
741 }
742 }
743 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
744 AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1,
745 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)));
746 }
747
748}
749
750
751//________________________________________________________________________________________________
752AliEMCALShishKebabTrd1Module* AliEMCALGeoUtils::GetShishKebabModule(Int_t neta) const
753{
754 //This method was too long to be
755 //included in the header file - the
756 //rule checker complained about it's
757 //length, so we move it here. It returns the
758 //shishkebabmodule at a given eta index point.
759
760 static AliEMCALShishKebabTrd1Module* trd1=0;
761 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
762 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);
763 } else trd1 = 0;
764 return trd1;
765}
766
767//___________________________________________________________________
768void AliEMCALGeoUtils::PrintGeometry()
769{
770 //Print information from geometry
771 fEMCGeometry->PrintGeometry();
772
773 printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
774 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1);
775
776 printf("\n Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize());
777 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
778 printf(" ind %2.2i : z %8.3f : x %8.3f \n", i,
779 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i));
780 int ind=0; // Nov 21,2006
781 for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
782 ind = iphi*fCentersOfCellsEtaDir.GetSize() + i;
783 printf("%6.4f ", fEtaCentersOfCells[ind]);
784 if((iphi+1)%12 == 0) printf("\n");
785 }
786 printf("\n");
787
788 }
789
790 printf("\n Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize());
791 for(Int_t i=0; i<fCentersOfCellsPhiDir.GetSize(); i++) {
792 double phi=fPhiCentersOfCells.At(i);
793 printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i),
794 phi, phi*TMath::RadToDeg());
795 }
796
797}
798
799//____________________________________________________________________________
800Bool_t AliEMCALGeoUtils::Impact(const TParticle * particle) const
801{
802 // Tells if a particle enters EMCAL
803 Bool_t in=kFALSE;
804 Int_t absID=0;
805 TVector3 vtx(particle->Vx(),particle->Vy(),particle->Vz());
806 TVector3 vimpact(0,0,0);
807 ImpactOnEmcal(vtx,particle->Theta(),particle->Phi(),absID,vimpact);
808 if(absID!=0)
809 in=kTRUE;
810 return in;
811}
812//____________________________________________________________________________
813void AliEMCALGeoUtils::ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi,
814 Int_t & absId, TVector3 & vimpact) const
815{
816 // calculates the impact coordinates on EMCAL (centre of a tower/not on EMCAL surface)
817 // of a neutral particle
818 // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system
819
820 TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ;
821
822 vimpact.SetXYZ(0,0,0);
823 absId=-1;
824 if(phi==0 || theta==0) return;
825
826 TVector3 direction;
827 Double_t factor = (fIPDistance-vtx[1])/p[1];
828 direction = vtx + factor*p;
829
0c5b726e 830 //from particle direction -> tower hitted
831 GetAbsCellIdFromEtaPhi(direction.Eta(),direction.Phi(),absId);
832
833 //tower absID hitted -> tower/module plane (evaluated at the center of the tower)
834 Int_t nSupMod, nModule, nIphi, nIeta;
835 Double_t loc[3],loc2[3],loc3[3];
836 Double_t glob[3]={},glob2[3]={},glob3[3]={};
837
838 if(!RelPosCellInSModule(absId,loc)) return;
839
840 //loc is cell center of tower
841 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
842
843 //look at 2 neighbours-s cell using nIphi={0,1} and nIeta={0,1}
844 Int_t nIphi2,nIeta2,absId2,absId3;
845 if(nIeta==0) nIeta2=1;
846 else nIeta2=0;
847 absId2=GetAbsCellId(nSupMod,nModule,nIphi,nIeta2);
848 if(nIphi==0) nIphi2=1;
849 else nIphi2=0;
850 absId3=GetAbsCellId(nSupMod,nModule,nIphi2,nIeta);
851
852 //2nd point on emcal cell plane
853 if(!RelPosCellInSModule(absId2,loc2)) return;
854
855 //3rd point on emcal cell plane
856 if(!RelPosCellInSModule(absId3,loc3)) return;
857
a7e8255c 858 // Get Matrix
0c5b726e 859 const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
860 if(m) {
861 m->LocalToMaster(loc, glob);
862 m->LocalToMaster(loc2, glob2);
863 m->LocalToMaster(loc3, glob3);
864 } else {
865 AliFatal("Geo matrixes are not loaded \n") ;
866 }
867
868 //Equation of Plane from glob,glob2,glob3 (Ax+By+Cz+D=0)
869 Double_t a = glob[1]*(glob2[2]-glob3[2]) + glob2[1]*(glob3[2]-glob[2]) + glob3[1]*(glob[2]-glob2[2]);
870 Double_t b = glob[2]*(glob2[0]-glob3[0]) + glob2[2]*(glob3[0]-glob[0]) + glob3[2]*(glob[0]-glob2[0]);
871 Double_t c = glob[0]*(glob2[1]-glob3[1]) + glob2[0]*(glob3[1]-glob[1]) + glob3[0]*(glob[1]-glob2[1]);
872 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]);
873 d=-d;
874
875 //shift equation of plane from tower/module center to surface along vector (A,B,C) normal to tower/module plane
876 Double_t dist = fLongModuleSize/2.;
877 Double_t norm = TMath::Sqrt(a*a+b*b+c*c);
878 Double_t glob4[3]={};
879 TVector3 dir(a,b,c);
880 TVector3 point(glob[0],glob[1],glob[2]);
881 if(point.Dot(dir)<0) dist*=-1;
882 glob4[0]=glob[0]-dist*a/norm;
883 glob4[1]=glob[1]-dist*b/norm;
884 glob4[2]=glob[2]-dist*c/norm;
885 d = glob4[0]*a + glob4[1]*b + glob4[2]*c ;
886 d = -d;
887
888 //Line determination (2 points for equation of line : vtx and direction)
889 //impact between line (particle) and plane (module/tower plane)
890 Double_t den = a*(vtx(0)-direction(0)) + b*(vtx(1)-direction(1)) + c*(vtx(2)-direction(2));
891 if(den==0){
892 printf("ImpactOnEmcal() No solution :\n");
893 return;
894 }
895
896 Double_t length = a*vtx(0)+b*vtx(1)+c*vtx(2)+d;
897 length /=den;
898
899 vimpact.SetXYZ(vtx(0)+length*(direction(0)-vtx(0)),vtx(1)+length*(direction(1)-vtx(1)),vtx(2)+length*(direction(2)-vtx(2)));
900
901 //shift vimpact from tower/module surface to center along vector (A,B,C) normal to tower/module plane
902 vimpact.SetXYZ(vimpact(0)+dist*a/norm,vimpact(1)+dist*b/norm,vimpact(2)+dist*c/norm);
903
904 return;
905}
906
907//_____________________________________________________________________________
908Bool_t AliEMCALGeoUtils::IsInEMCAL(Double_t x, Double_t y, Double_t z) const {
909 // Checks whether point is inside the EMCal volume, used in AliEMCALv*.cxx
910 //
911 // Code uses cylindrical approximation made of inner radius (for speed)
912 //
913 // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance
914 // are considered to inside
915
916 Double_t r=sqrt(x*x+y*y);
917
918 if ( r > fEnvelop[0] ) {
919 Double_t theta;
920 theta = TMath::ATan2(r,z);
921 Double_t eta;
922 if(theta == 0)
923 eta = 9999;
924 else
925 eta = -TMath::Log(TMath::Tan(theta/2.));
926 if (eta < fArm1EtaMin || eta > fArm1EtaMax)
927 return 0;
928
929 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
930 if (phi < 0) phi += 360; // phi should go from 0 to 360 in this case
931 if (phi > fArm1PhiMin && phi < fArm1PhiMax)
932 return 1;
933 }
934 return 0;
935}
936
937//________________________________________________________________________________________________
938Int_t AliEMCALGeoUtils::GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const
939{ // Nov 6, 2007
940 // Get TRU absolute number from column, row and Super Module number
941 Int_t itru = row + col*fEMCGeometry->GetNModulesInTRUPhi() + sm*fEMCGeometry->GetNTRU();
942 // printf(" GetAbsTRUNumberFromNumberInSm : row %2i col %2i sm %2i -> itru %2i\n", row, col, sm, itru);
943 return itru;
944}
945
916f1e76 946//________________________________________________________________________________________________
947Bool_t AliEMCALGeoUtils::GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const
948{
a7e8255c 949 //Trigger mapping method, get FastOr Index from TRU
950
916f1e76 951 if (iTRU > 31 || iTRU < 0 || iADC > 95 || iADC < 0)
952 {
953 AliError("TRU out of range!");
954 return kFALSE;
955 }
956
957 id = iADC + iTRU * 96;
958
959 return kTRUE;
960}
961
962//________________________________________________________________________________________________
963Bool_t AliEMCALGeoUtils::GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const
964{
a7e8255c 965
966 //Trigger mapping method, get TRU number from FastOr Index
967
916f1e76 968 if (id > 3071 || id < 0)
969 {
970 AliError("Id out of range!");
971 return kFALSE;
972 }
973
974 iTRU = id / 96;
975 iADC = id % 96;
976
977 return kTRUE;
978}
979
980//________________________________________________________________________________________________
981Bool_t AliEMCALGeoUtils::GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const
982{
a7e8255c 983 //Trigger mapping method, get position in TRU from FasOr Index
984
916f1e76 985 Int_t iADC;
986
987 Bool_t isOK = GetTRUFromAbsFastORIndex(id, iTRU, iADC);
988
989 if (!isOK) return kFALSE;
990
991 Int_t x = iADC / 4;
992 Int_t y = iADC % 4;
993
994 if ( int( iTRU / 3 ) % 2 ) // C side
995 {
996 iEta = 23 - x;
997 iPhi = y;
998 }
999 else // A side
1000 {
1001 iEta = x;
1002 iPhi = 3 - y;
1003 }
1004
1005 return kTRUE;
1006}
1007
1008//________________________________________________________________________________________________
1009Bool_t AliEMCALGeoUtils::GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const
1010{
a7e8255c 1011 //Trigger mapping method, get position in Super Module from FasOr Index
1012
916f1e76 1013 Int_t iTRU;
1014 Bool_t isOK = GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi);
1015
1016 if (!isOK) return kFALSE;
1017
1018 iSM = iTRU / 3;
1019
1020 if ( int( iTRU / 3 ) % 2 ) // C side
1021 {
1022 iPhi = iPhi + 4 * ( 2 - ( iTRU % 3 ) );
1023 }
1024 else // A side
1025 {
1026 iPhi = iPhi + 4 * ( iTRU % 3 );
1027 }
1028
1029 return kTRUE;
1030}
1031
1032//________________________________________________________________________________________________
1033Bool_t AliEMCALGeoUtils::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const
1034{
a7e8255c 1035 //Trigger mapping method, get Index if FastOr from Position in TRU
1036
916f1e76 1037 if (iTRU < 0 || iTRU > 31 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3) return kFALSE;
1038
1039 if ( int( iTRU / 3 ) % 2 ) // C side
1040 {
1041 id = iPhi + 4 * ( 23 - iEta ) + iTRU * 96;
1042 }
1043 else
1044 {
1045 id = (3 - iPhi) + 4 * iEta + iTRU * 96;
1046 }
1047
1048 return kTRUE;
1049}
0c5b726e 1050
1051//____________________________________________________________________________
1052const TGeoHMatrix * AliEMCALGeoUtils::GetMatrixForSuperModule(Int_t smod) const {
a7e8255c 1053
0c5b726e 1054 //Provides shift-rotation matrix for EMCAL
1055
1056 if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules())
1057 AliFatal(Form("Wrong supermodule index -> %d",smod));
1058
1059 //If GeoManager exists, take matrixes from it
1060
1061 //
1062 // if(fKey110DEG && ind>=10) {
1063 // }
1064 //
1065 // if(!gGeoManager->cd(volpath.Data()))
1066 // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data()));
1067 //
1068 // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
1069
1070 if(gGeoManager){
1071 char path[255] ;
1072 sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ;
1073 //TString volpath = "ALIC_1/XEN1_1/SMOD_";
1074 //volpath += smod+1;
1075
1076 if(fKey110DEG && smod >= 10){
1077 sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ;
1078 //volpath = "ALIC_1/XEN1_1/SM10_";
1079 //volpath += smod-10+1;
1080 }
1081 if (!gGeoManager->cd(path)){
1082 AliFatal(Form("Geo manager can not find path %s!\n",path));
1083 }
1084 return gGeoManager->GetCurrentMatrix();
1085 }
a7e8255c 1086
0c5b726e 1087 if(fkSModuleMatrix[smod]){
1088 return fkSModuleMatrix[smod] ;
1089 }
1090 else{
a7e8255c 1091 AliInfo("Stop:");
1092 printf("\t Can not find EMCAL misalignment matrixes\n") ;
1093 printf("\t Either import TGeoManager from geometry.root or \n");
1094 printf("\t read stored matrixes from AliESD Header: \n") ;
1095 printf("\t AliEMCALGeoUtils::SetMisalMatrixes(header->GetEMCALMisalMatrix()) \n") ;
0c5b726e 1096 abort() ;
1097 }
1098 return 0 ;
1099}
1100
1101//______________________________________________________________________
1102void AliEMCALGeoUtils::GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const
1103{
1104
1105 // This method transforms the (eta,phi) index of module in a
1106 // TRU matrix into Super Module (eta,phi) index.
1107
1108 // Calculate in which row and column where the TRU are
1109 // ordered in the SM
1110
1111 Int_t col = itru/fEMCGeometry->GetNTRUPhi() ; // indexes of TRU in SM
1112 Int_t row = itru - col*fEMCGeometry->GetNTRUPhi();
1113
1114 iphiSM = fEMCGeometry->GetNModulesInTRUPhi()*row + iphitru ;
1115 ietaSM = fEMCGeometry->GetNModulesInTRUEta()*col + ietatru ;
1116 //printf(" GetModulePhiEtaIndexInSModuleFromTRUIndex : itru %2i iphitru %2i ietatru %2i iphiSM %2i ietaSM %2i \n",
1117 // itru, iphitru, ietatru, iphiSM, ietaSM);
1118}