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