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"
119 #include "AliEMCALTriggerMappingV1.h"
120 #include "AliEMCALTriggerMappingV2.h"
122 ClassImp(AliEMCALGeometry)
124 // these initialisations are needed for a singleton
125 AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
126 const Char_t* AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETE12SMV1";
128 //____________________________________________________________________________
129 AliEMCALGeometry::AliEMCALGeometry():
130 fEMCGeometry(0x0),fTriggerMapping(0x0),fGeoName(0),fEMCSMSystem(0x0),
131 fKey110DEG(0),fnSupModInDCAL(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0),
132 fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0),
133 fPhiCentersOfSMSec(0x0),fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0),
134 fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0),
135 fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0),
136 fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0),
137 fDCALPhiMin(0),fDCALPhiMax(0),fEMCALPhiMax(0),fDCALStandardPhiMax(0),
138 fDCALInnerExtandedEta(0),fShishKebabTrd1Modules(0),fPhiModuleSize(0.),
139 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0),
140 fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.),
141 fZLength(0.),fSampling(0.),fUseExternalMatrices(kFALSE)
144 // must be kept public for root persistency purposes, but should never be called by the outside world
151 for (Int_t i=0;i<AliEMCALGeoParams::fgkEMCALModules;i++)
152 fkSModuleMatrix[i]=0 ;
155 //____________________________________________________________________________
156 AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry & geo)
158 fEMCGeometry(geo.fEMCGeometry),fTriggerMapping(geo.fTriggerMapping),fGeoName(geo.fGeoName),fEMCSMSystem(geo.fEMCSMSystem),
159 fKey110DEG(geo.fKey110DEG),fnSupModInDCAL(geo.fnSupModInDCAL),fNCellsInSupMod(geo.fNCellsInSupMod),fNETAdiv(geo.fNETAdiv),fNPHIdiv(geo.fNPHIdiv),
160 fNCellsInModule(geo.fNCellsInModule),fPhiBoundariesOfSM(geo.fPhiBoundariesOfSM),fPhiCentersOfSM(geo.fPhiCentersOfSM),
161 fPhiCentersOfSMSec(geo.fPhiCentersOfSMSec),fPhiCentersOfCells(geo.fPhiCentersOfCells),fCentersOfCellsEtaDir(geo.fCentersOfCellsEtaDir),
162 fCentersOfCellsPhiDir(geo.fCentersOfCellsPhiDir),fEtaCentersOfCells(geo.fEtaCentersOfCells),
163 fNCells(geo.fNCells),fNPhi(geo.fNPhi),fCentersOfCellsXDir(geo.fCentersOfCellsXDir),fArm1EtaMin(geo.fArm1EtaMin),
164 fArm1EtaMax(geo.fArm1EtaMax),fArm1PhiMin(geo.fArm1PhiMin),fArm1PhiMax(geo.fArm1PhiMax),fEtaMaxOfTRD1(geo.fEtaMaxOfTRD1),
165 fDCALPhiMin(geo.fDCALPhiMin),fDCALPhiMax(geo.fDCALPhiMax),fEMCALPhiMax(geo.fEMCALPhiMax),fDCALStandardPhiMax(geo.fDCALStandardPhiMax),
166 fDCALInnerExtandedEta(geo.fDCALInnerExtandedEta),fShishKebabTrd1Modules(geo.fShishKebabTrd1Modules),fPhiModuleSize(geo.fPhiModuleSize),
167 fEtaModuleSize(geo.fEtaModuleSize),fPhiTileSize(geo.fPhiTileSize),fEtaTileSize(geo.fEtaTileSize),fNZ(geo.fNZ),
168 fIPDistance(geo.fIPDistance),fLongModuleSize(geo.fLongModuleSize),fShellThickness(geo.fShellThickness),
169 fZLength(geo.fZLength),fSampling(geo.fSampling),fUseExternalMatrices(geo.fUseExternalMatrices)
172 fEnvelop[0] = geo.fEnvelop[0];
173 fEnvelop[1] = geo.fEnvelop[1];
174 fEnvelop[2] = geo.fEnvelop[2];
175 fParSM[0] = geo.fParSM[0];
176 fParSM[1] = geo.fParSM[1];
177 fParSM[2] = geo.fParSM[2];
178 for (Int_t i=0;i<AliEMCALGeoParams::fgkEMCALModules;i++)
179 fkSModuleMatrix[i]=0 ;
182 //____________________________________________________________________________
183 AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title,
184 const Text_t* mcname, const Text_t* mctitle)
185 : TNamed(name, title),
186 fEMCGeometry(0x0),fTriggerMapping(0x0),fGeoName(0),fEMCSMSystem(0x0),
187 fKey110DEG(0),fnSupModInDCAL(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0),
188 fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0),
189 fPhiCentersOfSMSec(0x0),fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0),
190 fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0),
191 fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0),
192 fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0),
193 fDCALPhiMin(0),fDCALPhiMax(0),fEMCALPhiMax(0),fDCALStandardPhiMax(0),
194 fDCALInnerExtandedEta(0),fShishKebabTrd1Modules(0),fPhiModuleSize(0.),
195 fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0),
196 fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.),
197 fZLength(0.),fSampling(0.), fUseExternalMatrices(kFALSE)
199 // ctor only for normal usage
201 fEMCGeometry = new AliEMCALEMCGeometry(name,title,mcname,mctitle);
202 fGeoName = fEMCGeometry->GetGeoName();
203 fEMCSMSystem = fEMCGeometry->GetEMCSystem();
204 fKey110DEG = fEMCGeometry->GetKey110DEG();
205 fnSupModInDCAL = fEMCGeometry->GetnSupModInDCAL();
206 fNCellsInSupMod = fEMCGeometry->GetNCellsInSupMod();
207 fNETAdiv = fEMCGeometry->GetNETAdiv();
208 fNPHIdiv = fEMCGeometry->GetNPHIdiv();
209 fNCellsInModule = fNPHIdiv*fNETAdiv;
211 Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules();
212 fPhiBoundariesOfSM.Set(nSMod);
213 fPhiCentersOfSM.Set(nSMod/2);
214 fPhiCentersOfSMSec.Set(nSMod/2);
215 for(Int_t sm=0; sm<nSMod; sm++) {
217 fEMCGeometry->GetPhiBoundariesOfSM(sm,fPhiBoundariesOfSM[2*i],fPhiBoundariesOfSM[2*i+1]);
220 Double_t phiMin = 0.;
221 Double_t phiMax = 0.;
222 for(Int_t sm=0; sm<nSMod; sm++) {
223 fEMCGeometry->GetPhiBoundariesOfSM(sm,phiMin,phiMax);
225 fPhiCentersOfSM[i] = fEMCGeometry->GetPhiCenterOfSM(sm);
226 fPhiCentersOfSMSec[i] = fEMCGeometry->GetPhiCenterOfSMSec(sm);
228 fNCells = fEMCGeometry->GetNCells();
229 fNPhi = fEMCGeometry->GetNPhi();
230 fEnvelop[0] = fEMCGeometry->GetEnvelop(0);
231 fEnvelop[1] = fEMCGeometry->GetEnvelop(1);
232 fEnvelop[2] = fEMCGeometry->GetEnvelop(2);
233 fParSM[0] = fEMCGeometry->GetSuperModulesPar(0);
234 fParSM[1] = fEMCGeometry->GetSuperModulesPar(1);
235 fParSM[2] = fEMCGeometry->GetSuperModulesPar(2);
236 fArm1EtaMin = fEMCGeometry->GetArm1EtaMin();
237 fArm1EtaMax = fEMCGeometry->GetArm1EtaMax();
238 fArm1PhiMin = fEMCGeometry->GetArm1PhiMin();
239 fArm1PhiMax = fEMCGeometry->GetArm1PhiMax();
240 fDCALPhiMin = fEMCGeometry->GetDCALPhiMin();
241 fDCALPhiMax = fEMCGeometry->GetDCALPhiMax();
242 fEMCALPhiMax = fEMCGeometry->GetEMCALPhiMax();
243 fDCALStandardPhiMax = fEMCGeometry->GetDCALStandardPhiMax();
244 fDCALInnerExtandedEta = fEMCGeometry->GetDCALInnerExtandedEta();
245 fShellThickness = fEMCGeometry->GetShellThickness();
246 fZLength = fEMCGeometry->GetZLength();
247 fSampling = fEMCGeometry->GetSampling();
248 fEtaModuleSize = fEMCGeometry->GetEtaModuleSize();
249 fPhiModuleSize = fEMCGeometry->GetPhiModuleSize();
250 fEtaTileSize = fEMCGeometry->GetEtaTileSize();
251 fPhiTileSize = fEMCGeometry->GetPhiTileSize();
252 fNZ = fEMCGeometry->GetNZ();
253 fIPDistance = fEMCGeometry->GetIPDistance();
254 fLongModuleSize = fEMCGeometry->GetLongModuleSize();
256 CreateListOfTrd1Modules();
258 for(Int_t smod=0; smod < AliEMCALGeoParams::fgkEMCALModules; smod++)
259 fkSModuleMatrix[smod]=0 ;
261 if (AliDebugLevel()>=2) {
262 fEMCGeometry->Print();
263 PrintGeometryGeoUtils();
266 if ((fEMCGeometry->GetGeoName()).Contains("DCAL")) {
267 fTriggerMapping = new AliEMCALTriggerMappingV2(46, this);
268 AliLog::Message(AliLog::kInfo, "EMCAL Trigger Mapping Version V2 Enabled",
269 MODULENAME(), "AliEMCALGeometry", FUNCTIONNAME(), __FILE__, __LINE__);
272 fTriggerMapping = new AliEMCALTriggerMappingV1(32, this);
273 AliLog::Message(AliLog::kInfo, "EMCAL Trigger Mapping Version V1 Enabled",
274 MODULENAME(), "AliEMCALGeometry", FUNCTIONNAME(), __FILE__, __LINE__);
278 //____________________________________________________________________________
279 AliEMCALGeometry & AliEMCALGeometry::operator = (const AliEMCALGeometry & /*rvalue*/)
282 Fatal("assignment operator", "not implemented") ;
286 //____________________________________________________________________________
287 AliEMCALGeometry::~AliEMCALGeometry(void)
292 AliError("Do not call delete on me");
298 for(Int_t smod = 0 ; smod < fEMCGeometry->GetNumberOfSuperModules(); smod++)
300 if(fkSModuleMatrix[smod])
301 delete fkSModuleMatrix[smod] ;
303 fkSModuleMatrix[smod]=0 ;
306 delete fEMCGeometry; // fEMCGeometry = 0 ;
309 if (fTriggerMapping) delete fTriggerMapping;
312 //______________________________________________________________________
313 AliEMCALGeometry * AliEMCALGeometry::GetInstance()
315 // Returns the pointer of the unique instance
317 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
321 //______________________________________________________________________
322 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name, const Text_t* title,
323 const Text_t* mcname, const Text_t* mctitle )
325 // Returns the pointer of the unique instance
327 AliEMCALGeometry * rv = 0;
329 if ( strcmp(name,"") == 0 ) { // get default geometry
330 fgGeom = new AliEMCALGeometry(fgkDefaultGeometryName, title,mcname,mctitle);
332 fgGeom = new AliEMCALGeometry(name, title,mcname,mctitle);
333 } // end if strcmp(name,"")
334 if ( AliEMCALEMCGeometry::fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
341 if ( strcmp(fgGeom->GetName(), name) != 0) {
342 printf("\ncurrent geometry is %s : ", fgGeom->GetName());
343 printf(" you cannot call %s ",name);
345 rv = (AliEMCALGeometry *) fgGeom;
351 //________________________________________________________________________________________________
352 void AliEMCALGeometry::Browse(TBrowser* b)
355 if(fShishKebabTrd1Modules) b->Add(fShishKebabTrd1Modules);
358 //________________________________________________________________________________________________
359 Bool_t AliEMCALGeometry::IsFolder() const
361 //Check if fShishKebabTrd1Modules is in folder
362 if(fShishKebabTrd1Modules) return kTRUE;
366 //________________________________________________________________________________________________
367 void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
369 // Figure out the global numbering
370 // of a given supermodule from the
371 // local numbering and the transformation
372 // matrix stored by the geometry manager (allows for misaligned
375 const TGeoHMatrix* m = GetMatrixForSuperModule(ind);
377 m->LocalToMaster(loc, glob);
379 AliFatal("Geo matrixes are not loaded \n") ;
383 //________________________________________________________________________________________________
384 void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const
386 //Figure out the global numbering
387 //of a given supermodule from the
388 //local numbering given a 3-vector location
390 static Double_t tglob[3], tloc[3];
392 GetGlobal(tloc, tglob, ind);
393 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
396 //________________________________________________________________________________________________
397 void AliEMCALGeometry::GetGlobal(Int_t absId , double glob[3]) const
399 // Alice numbering scheme - Jun 03, 2006
400 static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
401 static double loc[3];
403 glob[0]=glob[1]=glob[2]=0.0; // bad case
404 if(RelPosCellInSModule(absId, loc)) {
405 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
406 const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
408 m->LocalToMaster(loc, glob);
410 AliFatal("Geo matrixes are not loaded \n") ;
415 //___________________________________________________________________
416 void AliEMCALGeometry::GetGlobal(Int_t absId , TVector3 &vglob) const
418 // Alice numbering scheme - Jun 03, 2006
419 static Double_t glob[3];
421 GetGlobal(absId, glob);
422 vglob.SetXYZ(glob[0], glob[1], glob[2]);
425 //______________________________________________________________________
426 void AliEMCALGeometry::PrintCellIndexes(Int_t absId, int pri, const char *tit) const
429 Int_t nSupMod, nModule, nIphi, nIeta;
433 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
434 printf(" %s | absId : %i -> nSupMod %i nModule %i nIphi %i nIeta %i \n", tit, absId, nSupMod, nModule, nIphi, nIeta);
436 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
437 printf(" local SM index : iphi %i : ieta %i \n", iphi,ieta);
438 GetGlobal(absId, vg);
439 printf(" vglob : mag %7.2f : perp %7.2f : z %7.2f : eta %6.4f : phi %6.4f(%6.2f) \n",
440 vg.Mag(), vg.Perp(), vg.Z(), vg.Eta(), vg.Phi(), vg.Phi()*TMath::RadToDeg());
444 void AliEMCALGeometry::PrintLocalTrd1(Int_t pri) const
446 // For comparing with numbers from drawing
447 for(Int_t i=0; i<GetShishKebabTrd1Modules()->GetSize(); i++){
448 printf(" %s | ", GetShishKebabModule(i)->GetName());
449 if(i==0 && pri<1) GetShishKebabModule(i)->PrintShish(1);
450 else GetShishKebabModule(i)->PrintShish(pri);
454 //________________________________________________________________________________________________
455 void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Double_t &eta,Double_t &phi) const
457 // Nov 16, 2006- float to double
458 // version for TRD1 only
459 static TVector3 vglob;
460 GetGlobal(absId, vglob);
465 //________________________________________________________________________________________________
466 void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const
468 // Nov 16,2006 - should be discard in future
469 static TVector3 vglob;
470 GetGlobal(absId, vglob);
471 eta = float(vglob.Eta());
472 phi = float(vglob.Phi());
476 // == Shish-kebab cases ==
478 //________________________________________________________________________________________________
479 Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const
483 // 13-oct-05; 110 degree case
484 // May 31, 2006; ALICE numbering scheme:
485 // 0 <= nSupMod < fNumberOfSuperModules
486 // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
487 // 0 <= nIphi < fNPHIdiv
488 // 0 <= nIeta < fNETAdiv
489 // 0 <= absid < fNCells
490 Int_t id=0; // have to change from 0 to fNCells-1
491 for( int i = 0 ; i < nSupMod; i++) {
492 if( GetSMType(i) == kEMCAL_Standard) id += fNCellsInSupMod;
493 else if( GetSMType(i) == kEMCAL_Half) id += fNCellsInSupMod/2;
494 else if( GetSMType(i) == kEMCAL_3rd) id += fNCellsInSupMod/3;
495 else if( GetSMType(i) == kDCAL_Standard) id += 2*fNCellsInSupMod/3;
496 else if( GetSMType(i) == kDCAL_Ext) id += fNCellsInSupMod/3;
498 AliError(Form("Uknown SuperModule Type !!"));
502 id += fNCellsInModule *nModule;
503 id += fNPHIdiv *nIphi;
505 if( !CheckAbsCellId(id) ) {
506 id = -TMath::Abs(id); // if negative something wrong
511 //________________________________________________________________________________________________
512 void AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
513 Int_t &iphim, Int_t &ietam, Int_t &nModule) const
515 // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
516 static Int_t nphi=-1;
517 nphi = GetNumberOfModuleInPhiDirection(nSupMod);
519 ietam = ieta/fNETAdiv;
520 iphim = iphi/fNPHIdiv;
521 nModule = ietam * nphi + iphim;
524 //________________________________________________________________________________________________
525 Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
527 // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId
529 // Check if the indeces correspond to existing SM or tower indeces
530 if(iphi < 0 || iphi >= AliEMCALGeoParams::fgkEMCALRows ||
531 ieta < 0 || ieta >= AliEMCALGeoParams::fgkEMCALCols ||
532 nSupMod < 0 || nSupMod >= GetNumberOfSuperModules() )
534 AliDebug(1,Form("Wrong cell indexes : SM %d, column (eta) %d, row (phi) %d", nSupMod,ieta,iphi));
538 static Int_t ietam=-1, iphim=-1, nModule=-1;
539 static Int_t nIeta=-1, nIphi=-1; // cell indexes in module
541 GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule);
543 nIeta = ieta%fNETAdiv;
544 nIeta = fNETAdiv - 1 - nIeta;
545 nIphi = iphi%fNPHIdiv;
547 return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
550 //________________________________________________________________________________________________
551 Bool_t AliEMCALGeometry::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const
553 // Return false if phi belongs a phi cracks between SM
557 if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE;
559 phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
560 Int_t nphism = fEMCGeometry->GetNumberOfSuperModules()/2;
561 for(i=0; i<nphism; i++) {
562 if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) {
564 if(eta < 0.0) nSupMod++;
565 if( GetSMType(nSupMod) == kDCAL_Standard) {// Gap between DCAL
566 if(TMath::Abs(eta) < GetNEta()/3*(GetEMCGeometry()->GetTrd1Angle())*TMath::DegToRad()) return kFALSE;
568 AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i));
576 //________________________________________________________________________________________________
577 Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const
581 // stay here - phi problem as usual
582 static Int_t nSupMod=-1, i=0, ieta=-1, iphi=-1, etaShift=0, neta=-1, nphi=-1;
583 static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc=0;
584 absId = nSupMod = - 1;
585 if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
587 phi = TVector2::Phi_0_2pi(phi);
588 phiLoc = phi - fPhiCentersOfSMSec[nSupMod/2];
589 nphi = fPhiCentersOfCells.GetSize();
590 if ( GetSMType(nSupMod) == kEMCAL_Half ) nphi /= 2;
591 else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi /= 3;
592 else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi /= 3;
594 dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc);
596 for(i=1; i<nphi; i++) {
597 d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc);
602 //printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]);
604 // odd SM are turned with respect of even SM - reverse indexes
605 AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc));
608 absEta = TMath::Abs(eta);
609 neta = fCentersOfCellsEtaDir.GetSize();
610 etaShift = iphi*neta;
612 if( GetSMType(nSupMod) == kDCAL_Standard) ieta += 16; //jump 16 cells for DCSM
613 dmin = TMath::Abs(fEtaCentersOfCells[etaShift + ieta]-absEta);
614 for(i= ieta+1 ; i<neta; i++) {
615 d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta);
621 if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //jump 16 cells for DCSM
623 AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod));
625 //patch for mapping following alice convention
626 if(nSupMod%2 == 0) {// 47 + 16 -ieta for DCSM, 47 - ieta for others, revert the ordering on A side in order to keep convention.
627 ieta = (neta -1)-ieta;
628 if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //recover cells for DCSM
631 absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
637 //________________________________________________________________________________________________
638 Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t absId) const
640 // May 31, 2006; only trd1 now
641 if(absId<0 || absId >= fNCells) return kFALSE;
645 //________________________________________________________________________________________________
646 Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const
648 // 21-sep-04; 19-oct-05;
649 // May 31, 2006; ALICE numbering scheme:
652 // absId - cell is as in Geant, 0<= absId < fNCells;
654 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
655 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
656 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
657 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
659 if(!CheckAbsCellId(absId)) return kFALSE;
661 static Int_t tmp = absId;
664 for(nSupMod = -1; test >= 0; ) {
667 if( GetSMType(nSupMod) == kEMCAL_Standard) test -= fNCellsInSupMod;
668 else if( GetSMType(nSupMod) == kEMCAL_Half) test -= fNCellsInSupMod/2;
669 else if( GetSMType(nSupMod) == kEMCAL_3rd) test -= fNCellsInSupMod/3;
670 else if( GetSMType(nSupMod) == kDCAL_Standard) test -= 2*fNCellsInSupMod/3;
671 else if( GetSMType(nSupMod) == kDCAL_Ext) test -= fNCellsInSupMod/3;
673 AliError(Form("Uknown SuperModule Type !!"));
677 nModule = tmp / fNCellsInModule;
678 tmp = tmp % fNCellsInModule;
679 nIphi = tmp / fNPHIdiv;
680 nIeta = tmp % fNPHIdiv;
685 //________________________________________________________________________________________________
686 Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const
688 // Return the number of the supermodule given the absolute
689 // ALICE numbering id
691 static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
692 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
696 //________________________________________________________________________________________________
697 void AliEMCALGeometry::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, int &iphim, int &ietam) const
699 // added nSupMod; - 19-oct-05 !
700 // Alice numbering scheme - Jun 01,2006
701 // ietam, iphi - indexes of module in two dimensional grid of SM
702 // ietam - have to change from 0 to fNZ-1
703 // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1)
704 static Int_t nphi=-1;
705 if( GetSMType(nSupMod) == kEMCAL_Half ) nphi = fNPhi/2; // halfSM
706 else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi = fNPhi/3; // 1/3 SM
707 else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi = fNPhi/3; // 1/3 SM
708 else nphi = fNPhi; // full SM
710 ietam = nModule/nphi;
711 iphim = nModule%nphi;
714 //________________________________________________________________________________________________
715 void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta,
716 int &iphi, int &ieta) const
719 // Added nSupMod; Nov 25, 05
720 // Alice numbering scheme - Jun 01,2006
722 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
723 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
724 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
725 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
728 // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM
729 // ieta - have to change from 0 to (fNZ*fNETAdiv-1)
730 // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1)
732 static Int_t iphim=-1, ietam=-1;
734 GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam);
735 // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM)
736 ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM)
737 iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM)
740 AliDebug(1,Form(" nSupMod %i nModule %i nIphi %i nIeta %i => ieta %i iphi %i\n",
741 nSupMod, nModule, nIphi, nIeta, ieta, iphi));
744 // Methods for AliEMCALRecPoint - Feb 19, 2006
745 //________________________________________________________________________________________________
746 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const
748 // Look to see what the relative
749 // position inside a given cell is
751 // Alice numbering scheme - Jun 08, 2006
753 // absId - cell is as in Geant, 0<= absId < fNCells;
755 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
757 // Shift index taking into account the difference between standard SM
758 // and SM of half (or one third) size in phi direction
760 const Int_t kNphiIndex = fCentersOfCellsPhiDir.GetSize();
761 Double_t zshift = 0.5*GetDCALInnerEdge();
763 static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
764 if(!CheckAbsCellId(absId)) return kFALSE;
766 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
767 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
769 //Get eta position. Careful with ALICE conventions (increase index decrease eta)
772 ieta2 = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
774 if( GetSMType(nSupMod) == kDCAL_Standard && nSupMod%2 ) ieta2 += 16; // DCAL revert the ordering on C side ...
775 zr = fCentersOfCellsEtaDir.At(ieta2);
776 if( GetSMType(nSupMod) == kDCAL_Standard ) zr -= zshift; // DCAL shift (SMALLER SM)
777 xr = fCentersOfCellsXDir.At(ieta2);
779 //Get phi position. Careful with ALICE conventions (increase index increase phi)
781 if( GetSMType(nSupMod) == kDCAL_Ext ) {
782 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
783 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
784 } else if( GetSMType(nSupMod) == kEMCAL_Half ){
785 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/2 -1)-iphi; //11-iphi [1/2SM], revert the ordering on C side in order to keep convention.
786 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/4);
787 } else if( GetSMType(nSupMod) == kEMCAL_3rd ){
788 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
789 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
791 if(nSupMod%2 != 0) iphi2 = (kNphiIndex -1)-iphi;// 23-iphi, revert the ordering on C side in order to keep conventi
792 yr = fCentersOfCellsPhiDir.At(iphi2);
794 AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
799 //________________________________________________________________________________________________
800 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const
802 // Look to see what the relative
803 // position inside a given cell is
804 // for a recpoint. // Alice numbering scheme - Jun 03, 2006
805 loc[0] = loc[1] = loc[2]=0.0;
806 if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) {
812 //________________________________________________________________________________________________
813 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, TVector3 &vloc) const
815 // Look to see what the relative
816 // position inside a given cell is
818 // Alice numbering scheme - Jun 03, 2006
819 static Double_t loc[3];
820 if(RelPosCellInSModule(absId,loc)) {
821 vloc.SetXYZ(loc[0], loc[1], loc[2]);
829 //________________________________________________________________________________________________
830 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
832 // Jul 30, 2007 - taking into account position of shower max
833 // Look to see what the relative
834 // position inside a given cell is
837 // absId - cell is as in Geant, 0<= absId < fNCells;
838 // e - cluster energy
840 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
842 // Shift index taking into account the difference between standard SM
843 // and SM of half (or one third) size in phi direction
845 const Int_t kNphiIndex = fCentersOfCellsPhiDir.GetSize();
846 Double_t zshift = 0.5*GetDCALInnerEdge();
847 Int_t kDCalshift = 8;//wangml DCal cut first 8 modules(16 cells)
849 static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
850 static Int_t iphim=-1, ietam=-1;
851 static AliEMCALShishKebabTrd1Module *mod = 0;
853 if(!CheckAbsCellId(absId)) return kFALSE;
855 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
856 GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
857 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
859 //Get eta position. Careful with ALICE conventions (increase index decrease eta)
861 ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 24-ietam, revert the ordering on A side in order to keep convention.
862 if(nIeta == 0) nIeta = 1;
865 if( GetSMType(nSupMod) == kDCAL_Standard && nSupMod%2) ietam += kDCalshift; // DCAL revert the ordering on C side ....
866 mod = GetShishKebabModule(ietam);
867 mod ->GetPositionAtCenterCellLine(nIeta, distEff, v);
868 xr = v.Y() - fParSM[0];
869 zr = v.X() - fParSM[2];
870 if( GetSMType(nSupMod) == kDCAL_Standard ) zr -= zshift; // DCAL shift (SMALLER SM)
872 //Get phi position. Careful with ALICE conventions (increase index increase phi)
874 if( GetSMType(nSupMod) == kDCAL_Ext ) {
875 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
876 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
877 } else if( GetSMType(nSupMod) == kEMCAL_Half ){
878 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/2 -1)-iphi; //11-iphi [1/2SM], revert the ordering on C side in order to keep convention.
879 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/2);
880 } else if( GetSMType(nSupMod) == kEMCAL_3rd ){
881 if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention.
882 yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3);
884 if(nSupMod%2 != 0) iphi2 = (kNphiIndex -1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
885 yr = fCentersOfCellsPhiDir.At(iphi2);
888 AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
893 //________________________________________________________________________________________________
894 void AliEMCALGeometry::CreateListOfTrd1Modules()
896 // Generate the list of Trd1 modules
897 // which will make up the EMCAL
899 // key: look to the AliEMCALShishKebabTrd1Module::
901 AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started "));
903 AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module
904 if(fShishKebabTrd1Modules == 0) {
905 fShishKebabTrd1Modules = new TList;
906 fShishKebabTrd1Modules->SetName("ListOfTRD1");
907 for(int iz=0; iz< fEMCGeometry->GetNZ(); iz++) {
909 // mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this);
910 mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,fEMCGeometry);
912 mTmp = new AliEMCALShishKebabTrd1Module(*mod);
915 fShishKebabTrd1Modules->Add(mod);
918 AliDebug(2,Form(" Already exits : "));
920 mod = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1);
921 fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0);
923 AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
924 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1));
926 // Jun 01, 2006 - ALICE numbering scheme
927 // define grid for cells in eta(z) and x directions in local coordinates system of SM
928 // Works just for 2x2 case only -- ?? start here
931 // Define grid for cells in phi(y) direction in local coordinates system of SM
932 // as for 2X2 as for 3X3 - Nov 8,2006
934 AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize()));
935 Int_t ind=0; // this is phi index
936 Int_t ieta=0, nModule=0, iphiTemp;
937 Double_t xr=0., zr=0., theta=0., phi=0., eta=0., r=0., x=0.,y=0.;
939 Double_t ytCenterModule=0.0, ytCenterCell=0.0;
941 fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv);
942 fPhiCentersOfCells.Set(fNPhi*fNPHIdiv);
944 Double_t r0 = fIPDistance + fLongModuleSize/2.;
945 for(Int_t it=0; it<fNPhi; it++) { // cycle on modules
946 ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module
947 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module
949 ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.;
950 } else if(fNPHIdiv==3){
951 ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1);
952 } else if(fNPHIdiv==1){
953 ytCenterCell = ytCenterModule;
955 fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind);
956 // Define grid on phi direction
957 // Grid is not the same for different eta bin;
958 // Effect is small but is still here
959 phi = TMath::ATan2(ytCenterCell, r0);
960 fPhiCentersOfCells.AddAt(phi, ind);
962 AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind)));
967 fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv);
968 fCentersOfCellsXDir.Set(fNZ *fNETAdiv);
969 fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv);
970 AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()));
971 for(Int_t it=0; it<fNZ; it++) {
972 AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
974 for(Int_t ic=0; ic<fNETAdiv; ic++) {
976 trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2
977 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
979 trd1->GetCenterOfCellInLocalCoordinateofSM3X3(ic, xr, zr); // case of 3X3
980 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
982 trd1->GetCenterOfCellInLocalCoordinateofSM1X1(xr, zr); // case of 1X1
983 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
985 fCentersOfCellsXDir.AddAt(float(xr) - fParSM[0],ieta);
986 fCentersOfCellsEtaDir.AddAt(float(zr) - fParSM[2],ieta);
987 // Define grid on eta direction for each bin in phi
988 for(int iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
989 x = xr + trd1->GetRadius();
990 y = fCentersOfCellsPhiDir[iphi];
991 r = TMath::Sqrt(x*x + y*y + zr*zr);
992 theta = TMath::ACos(zr/r);
993 eta = AliEMCALShishKebabTrd1Module::ThetaToEta(theta);
994 // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi;
995 ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta;
996 fEtaCentersOfCells.AddAt(eta, ind);
998 //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta);
1001 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
1002 AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1,
1003 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)));
1008 //________________________________________________________________________________________________
1009 AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta) const
1011 //This method was too long to be
1012 //included in the header file - the
1013 //rule checker complained about it's
1014 //length, so we move it here. It returns the
1015 //shishkebabmodule at a given eta index point.
1017 static AliEMCALShishKebabTrd1Module* trd1=0;
1018 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
1019 trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);
1024 //___________________________________________________________________
1025 void AliEMCALGeometry::PrintGeometryGeoUtils()
1027 //Print information from geometry
1028 fEMCGeometry->PrintGeometry();
1030 printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
1031 fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1);
1033 printf("\n Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize());
1034 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
1035 printf(" ind %2.2i : z %8.3f : x %8.3f \n", i,
1036 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i));
1037 int ind=0; // Nov 21,2006
1038 for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
1039 ind = iphi*fCentersOfCellsEtaDir.GetSize() + i;
1040 printf("%6.4f ", fEtaCentersOfCells[ind]);
1041 if((iphi+1)%12 == 0) printf("\n");
1047 printf("\n Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize());
1048 for(Int_t i=0; i<fCentersOfCellsPhiDir.GetSize(); i++) {
1049 double phi=fPhiCentersOfCells.At(i);
1050 printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i),
1051 phi, phi*TMath::RadToDeg());
1055 //____________________________________________________________________________
1056 Bool_t AliEMCALGeometry::Impact(const TParticle * particle) const
1058 // Tells if a particle enters EMCAL
1061 TVector3 vtx(particle->Vx(),particle->Vy(),particle->Vz());
1062 TVector3 vimpact(0,0,0);
1063 ImpactOnEmcal(vtx,particle->Theta(),particle->Phi(),absID,vimpact);
1068 //____________________________________________________________________________
1069 void AliEMCALGeometry::ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi,
1070 Int_t & absId, TVector3 & vimpact) const
1072 // calculates the impact coordinates on EMCAL (centre of a tower/not on EMCAL surface)
1073 // of a neutral particle
1074 // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system
1076 TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ;
1078 vimpact.SetXYZ(0,0,0);
1080 if(phi==0 || theta==0) return;
1083 Double_t factor = (fIPDistance-vtx[1])/p[1];
1084 direction = vtx + factor*p;
1086 //from particle direction -> tower hitted
1087 GetAbsCellIdFromEtaPhi(direction.Eta(),direction.Phi(),absId);
1089 //tower absID hitted -> tower/module plane (evaluated at the center of the tower)
1090 Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
1091 Double_t loc[3],loc2[3],loc3[3];
1092 Double_t glob[3]={},glob2[3]={},glob3[3]={};
1094 if(!RelPosCellInSModule(absId,loc)) return;
1096 //loc is cell center of tower
1097 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
1099 //look at 2 neighbours-s cell using nIphi={0,1} and nIeta={0,1}
1100 Int_t nIphi2=-1,nIeta2=-1,absId2=-1,absId3=-1;
1101 if(nIeta==0) nIeta2=1;
1103 absId2=GetAbsCellId(nSupMod,nModule,nIphi,nIeta2);
1104 if(nIphi==0) nIphi2=1;
1106 absId3=GetAbsCellId(nSupMod,nModule,nIphi2,nIeta);
1108 //2nd point on emcal cell plane
1109 if(!RelPosCellInSModule(absId2,loc2)) return;
1111 //3rd point on emcal cell plane
1112 if(!RelPosCellInSModule(absId3,loc3)) return;
1115 const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
1117 m->LocalToMaster(loc, glob);
1118 m->LocalToMaster(loc2, glob2);
1119 m->LocalToMaster(loc3, glob3);
1121 AliFatal("Geo matrixes are not loaded \n") ;
1124 //Equation of Plane from glob,glob2,glob3 (Ax+By+Cz+D=0)
1125 Double_t a = glob[1]*(glob2[2]-glob3[2]) + glob2[1]*(glob3[2]-glob[2]) + glob3[1]*(glob[2]-glob2[2]);
1126 Double_t b = glob[2]*(glob2[0]-glob3[0]) + glob2[2]*(glob3[0]-glob[0]) + glob3[2]*(glob[0]-glob2[0]);
1127 Double_t c = glob[0]*(glob2[1]-glob3[1]) + glob2[0]*(glob3[1]-glob[1]) + glob3[0]*(glob[1]-glob2[1]);
1128 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]);
1131 //shift equation of plane from tower/module center to surface along vector (A,B,C) normal to tower/module plane
1132 Double_t dist = fLongModuleSize/2.;
1133 Double_t norm = TMath::Sqrt(a*a+b*b+c*c);
1134 Double_t glob4[3]={};
1135 TVector3 dir(a,b,c);
1136 TVector3 point(glob[0],glob[1],glob[2]);
1137 if(point.Dot(dir)<0) dist*=-1;
1138 glob4[0]=glob[0]-dist*a/norm;
1139 glob4[1]=glob[1]-dist*b/norm;
1140 glob4[2]=glob[2]-dist*c/norm;
1141 d = glob4[0]*a + glob4[1]*b + glob4[2]*c ;
1144 //Line determination (2 points for equation of line : vtx and direction)
1145 //impact between line (particle) and plane (module/tower plane)
1146 Double_t den = a*(vtx(0)-direction(0)) + b*(vtx(1)-direction(1)) + c*(vtx(2)-direction(2));
1148 printf("ImpactOnEmcal() No solution :\n");
1152 Double_t length = a*vtx(0)+b*vtx(1)+c*vtx(2)+d;
1155 vimpact.SetXYZ(vtx(0)+length*(direction(0)-vtx(0)),vtx(1)+length*(direction(1)-vtx(1)),vtx(2)+length*(direction(2)-vtx(2)));
1157 //shift vimpact from tower/module surface to center along vector (A,B,C) normal to tower/module plane
1158 vimpact.SetXYZ(vimpact(0)+dist*a/norm,vimpact(1)+dist*b/norm,vimpact(2)+dist*c/norm);
1163 //_____________________________________________________________________________
1164 Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const
1166 // Checks whether point is inside the EMCal volume
1167 if( IsInEMCALOrDCAL(x,y,z) == 1 ) return kTRUE;
1171 //_____________________________________________________________________________
1172 Bool_t AliEMCALGeometry::IsInDCAL(Double_t x, Double_t y, Double_t z) const
1174 // Checks whether point is inside the DCal volume
1175 if( IsInEMCALOrDCAL(x,y,z) == 2 ) return kTRUE;
1179 //_____________________________________________________________________________
1180 Int_t AliEMCALGeometry::IsInEMCALOrDCAL(Double_t x, Double_t y, Double_t z) const
1182 // Checks whether point is inside the EMCal volume (included DCal), used in AliEMCALv*.cxx
1184 // Code uses cylindrical approximation made of inner radius (for speed)
1186 // Points behind EMCAl/DCal, i.e. R > outer radius, but eta, phi in acceptance
1187 // are considered to inside
1189 Double_t r=sqrt(x*x+y*y);
1191 if ( r <= fEnvelop[0] ) return 0;
1193 Double_t theta = TMath::ATan2(r,z);
1195 if(theta == 0) eta = 9999;
1196 else eta = -TMath::Log(TMath::Tan(theta/2.));
1197 if (eta < fArm1EtaMin || eta > fArm1EtaMax) return 0;
1199 Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi();
1200 if (phi < 0) phi += 360; // phi should go from 0 to 360 in this case
1202 if ( phi >= fArm1PhiMin && phi <= fEMCALPhiMax ) return 1;
1203 else if ( phi >= fDCALPhiMin && phi <= fDCALStandardPhiMax && TMath::Abs(eta) > fDCALInnerExtandedEta ) return 2;
1204 else if ( phi > fDCALStandardPhiMax && phi <= fDCALPhiMax ) return 2;
1209 //____________________________________________________________________________
1210 const TGeoHMatrix * AliEMCALGeometry::GetMatrixForSuperModule(Int_t smod) const
1212 //Provides shift-rotation matrix for EMCAL
1214 if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules())
1215 AliFatal(Form("Wrong supermodule index -> %d",smod));
1217 //If GeoManager exists, take matrixes from it
1220 // if(fKey110DEG && ind>=10) {
1223 // if(!gGeoManager->cd(volpath.Data()))
1224 // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data()));
1226 // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
1228 //Use matrices set externally
1229 if(!gGeoManager || (gGeoManager && fUseExternalMatrices)){
1230 if(fkSModuleMatrix[smod]){
1231 return fkSModuleMatrix[smod] ;
1235 printf("\t Can not find EMCAL misalignment matrixes\n") ;
1236 printf("\t Either import TGeoManager from geometry.root or \n");
1237 printf("\t read stored matrixes from AliESD Header: \n") ;
1238 printf("\t AliEMCALGeometry::SetMisalMatrixes(header->GetEMCALMisalMatrix()) \n") ;
1241 }//external matrices
1244 const Int_t buffersize = 255;
1245 char path[buffersize] ;
1249 //Get the order for SM
1250 for( Int_t i = 0; i < smod+1; i++){
1251 if(GetSMType(i) == tmpType) {
1254 tmpType = GetSMType(i);
1259 if(GetSMType(smod) == kEMCAL_Standard ) SMName = "SMOD";
1260 else if(GetSMType(smod) == kEMCAL_Half ) SMName = "SM10";
1261 else if(GetSMType(smod) == kEMCAL_3rd ) SMName = "SM3rd";
1262 else if( GetSMType(smod) == kDCAL_Standard ) SMName = "DCSM";
1263 else if( GetSMType(smod) == kDCAL_Ext ) SMName = "DCEXT";
1264 else AliError("Unkown SM Type!!");
1265 snprintf(path,buffersize,"/ALIC_1/XEN1_1/%s_%d", SMName.Data(), SMOrder) ;
1267 if (!gGeoManager->cd(path)){
1268 AliFatal(Form("Geo manager can not find path %s!\n",path));
1270 return gGeoManager->GetCurrentMatrix();
1275 //__________________________________________________________________________________________________________________
1276 void AliEMCALGeometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth,
1277 const Float_t misaligTransShifts[15], const Float_t misaligRotShifts[15], Float_t global[3]) const
1279 //Transform clusters cell position into global with alternative method, taking into account the depth calculation.
1280 //Input are: the tower indeces,
1282 // particle type (photon 0, electron 1, hadron 2 )
1283 // misalignment shifts to global position in case of need.
1284 // Federico.Ronchetti@cern.ch
1286 // To use in a print later
1287 Float_t droworg = drow;
1288 Float_t dcolorg = dcol;
1291 //Recover some stuff
1293 const Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules();
1295 gGeoManager->cd("ALIC_1/XEN1_1");
1296 TGeoNode *geoXEn1 = gGeoManager->GetCurrentNode();
1297 TGeoNodeMatrix *geoSM[nSMod];
1298 TGeoVolume *geoSMVol[nSMod];
1299 TGeoShape *geoSMShape[nSMod];
1300 TGeoBBox *geoBox[nSMod];
1301 TGeoMatrix *geoSMMatrix[nSMod];
1303 for(int iSM = 0; iSM < nSMod; iSM++) {
1304 geoSM[iSM] = dynamic_cast<TGeoNodeMatrix *>(geoXEn1->GetDaughter(iSM));
1305 geoSMVol[iSM] = geoSM[iSM]->GetVolume();
1306 geoSMShape[iSM] = geoSMVol[iSM]->GetShape();
1307 geoBox[iSM] = dynamic_cast<TGeoBBox *>(geoSMShape[iSM]);
1308 geoSMMatrix[iSM] = geoSM[iSM]->GetMatrix();
1321 Float_t x,y,z; // return variables in terry's RF
1323 //***********************************************************
1324 //Do not like this: too many hardcoded values, is it not already stored somewhere else?
1325 // : need more comments in the code
1326 //***********************************************************
1328 Float_t dz = 6.0; // base cell width in eta
1329 Float_t dx = 6.004; // base cell width in phi
1332 //Float_t L = 26.04; // active tower length for hadron (lead+scint+paper)
1333 // we use the geant numbers 13.87*2=27.74
1336 //Do some basic checks
1337 if (dcol >= 47.5 || dcol<-0.5) {
1338 AliError(Form("Bad tower coordinate dcol=%f, where dcol >= 47.5 || dcol<-0.5; org: %f", dcol, dcolorg));
1341 if (drow >= 23.5 || drow<-0.5) {
1342 AliError(Form("Bad tower coordinate drow=%f, where drow >= 23.5 || drow<-0.5; org: %f", drow, droworg));
1345 if (sm >= nSMod || sm < 0) {
1346 AliError(Form("Bad SM number sm=%d, where sm >= %d || sm < 0", nSMod, sm));
1350 istrip = int ((dcol+0.5)/2);
1353 teta1 = TMath::DegToRad() * istrip * 1.5;
1355 // calculation of module corner along z
1356 // as a function of strip
1358 for (int is=0; is<= istrip; is++) {
1360 teta1 = TMath::DegToRad() * (is*1.5 + 0.75);
1362 zIs = zIs + 2*dz*TMath::Cos(teta1);
1364 zIs = zIs + 2*dz*TMath::Cos(teta1) + 2*dz*TMath::Sin(teta1)*TMath::Tan(teta1-0.75*TMath::DegToRad());
1368 z0 = dz*(dcol-2*istrip+0.5);
1369 zb = (2*dz-z0-depth*TMath::Tan(teta1));
1371 z = zIs - zb*TMath::Cos(teta1);
1372 y = depth/TMath::Cos(teta1) + zb*TMath::Sin(teta1);
1374 x = (drow + 0.5)*dx;
1376 // moving the origin from terry's RF
1379 double xx = y - geoBox[sm]->GetDX();
1380 double yy = -x + geoBox[sm]->GetDY();
1381 double zz = z - geoBox[sm]->GetDZ();
1382 const double localIn[3] = {xx, yy, zz};
1384 //geoSMMatrix[sm]->Print();
1385 //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]);
1386 geoSMMatrix[sm]->LocalToMaster(localIn, dglobal);
1387 //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]);
1389 //apply global shifts
1390 if(sm == 2 || sm == 3) {//sector 1
1391 global[0] = dglobal[0] + misaligTransShifts[3] + misaligRotShifts[3]*TMath::Sin(TMath::DegToRad()*20) ;
1392 global[1] = dglobal[1] + misaligTransShifts[4] + misaligRotShifts[4]*TMath::Cos(TMath::DegToRad()*20) ;
1393 global[2] = dglobal[2] + misaligTransShifts[5];
1395 else if(sm == 0 || sm == 1){//sector 0
1396 global[0] = dglobal[0] + misaligTransShifts[0];
1397 global[1] = dglobal[1] + misaligTransShifts[1];
1398 global[2] = dglobal[2] + misaligTransShifts[2];
1401 AliInfo("Careful, correction not implemented yet!");
1402 global[0] = dglobal[0] ;
1403 global[1] = dglobal[1] ;
1404 global[2] = dglobal[2] ;
1408 AliFatal("Geometry boxes information, check that geometry.root is loaded\n");
1412 //__________________________________________________________________________________________________________________
1413 void AliEMCALGeometry::SetMisalMatrix(const TGeoHMatrix * m, Int_t smod)
1415 // Method to set shift-rotational matrixes from ESDHeader
1416 // Move from header due to coding violations : Dec 2,2011 by PAI
1417 fUseExternalMatrices = kTRUE;
1419 if (smod >= 0 && smod < fEMCGeometry->GetNumberOfSuperModules()){
1420 if(!fkSModuleMatrix[smod]) fkSModuleMatrix[smod] = new TGeoHMatrix(*m) ; //Set only if not set yet
1421 } else AliFatal(Form("Wrong supermodule index -> %d",smod));
1424 //__________________________________________________________________________________________________________________
1425 Bool_t AliEMCALGeometry::IsDCALSM(Int_t iSupMod) const
1427 if( fEMCSMSystem[iSupMod] == kDCAL_Standard || fEMCSMSystem[iSupMod] == kDCAL_Ext ) return kTRUE;
1431 //__________________________________________________________________________________________________________________
1432 Bool_t AliEMCALGeometry::IsDCALExtSM(Int_t iSupMod) const
1434 if( fEMCSMSystem[iSupMod] == kDCAL_Ext ) return kTRUE;