+void AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
+ Int_t &iphim, Int_t &ietam, Int_t &nModule) const
+{
+ // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
+ static Int_t nphi=-1;
+ nphi = GetNumberOfModuleInPhiDirection(nSupMod);
+
+ ietam = ieta/fNETAdiv;
+ iphim = iphi/fNPHIdiv;
+ nModule = ietam * nphi + iphim;
+}
+
+//________________________________________________________________________________________________
+Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
+{
+ // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId
+
+ // Check if the indeces correspond to existing SM or tower indeces
+ if(iphi < 0 || iphi >= AliEMCALGeoParams::fgkEMCALRows ||
+ ieta < 0 || ieta >= AliEMCALGeoParams::fgkEMCALCols ||
+ nSupMod < 0 || nSupMod >= GetNumberOfSuperModules() )
+ {
+ AliDebug(1,Form("Wrong cell indexes : SM %d, column (eta) %d, row (phi) %d", nSupMod,ieta,iphi));
+ return -1 ;
+ }
+
+ static Int_t ietam=-1, iphim=-1, nModule=-1;
+ static Int_t nIeta=-1, nIphi=-1; // cell indexes in module
+
+ GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule);
+
+ nIeta = ieta%fNETAdiv;
+ nIeta = fNETAdiv - 1 - nIeta;
+ nIphi = iphi%fNPHIdiv;
+
+ return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeometry::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const
+{
+ // Return false if phi belongs a phi cracks between SM
+
+ static Int_t i=0;
+
+ if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE;
+
+ phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
+ Int_t nphism = fEMCGeometry->GetNumberOfSuperModules()/2;
+ for(i=0; i<nphism; i++) {
+ if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) {
+ nSupMod = 2*i;
+ if(eta < 0.0) nSupMod++;
+ if( GetSMType(nSupMod) == kDCAL_Standard) {// Gap between DCAL
+ if(TMath::Abs(eta) < GetNEta()/3*(GetEMCGeometry()->GetTrd1Angle())*TMath::DegToRad()) return kFALSE;
+ }
+ AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i));
+ return kTRUE;
+ }
+ }
+ return kFALSE;
+}
+
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const
+{
+
+ // Nov 17,2006
+ // stay here - phi problem as usual
+ static Int_t nSupMod=-1, i=0, ieta=-1, iphi=-1, etaShift=0, neta=-1, nphi=-1;
+ static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc=0;
+ absId = nSupMod = - 1;
+ if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
+ // phi index first
+ phi = TVector2::Phi_0_2pi(phi);
+ phiLoc = phi - fPhiCentersOfSMSec[nSupMod/2];
+ nphi = fPhiCentersOfCells.GetSize();
+ if ( GetSMType(nSupMod) == kEMCAL_Half ) nphi /= 2;
+ else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi /= 3;
+ else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi /= 3;
+
+ dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc);
+ iphi = 0;
+ for(i=1; i<nphi; i++) {
+ d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc);
+ if(d < dmin) {
+ dmin = d;
+ iphi = i;
+ }
+ //printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]);
+ }
+ // odd SM are turned with respect of even SM - reverse indexes
+ AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc));
+
+ // eta index
+ absEta = TMath::Abs(eta);
+ neta = fCentersOfCellsEtaDir.GetSize();
+ etaShift = iphi*neta;
+ ieta = 0;
+ if( GetSMType(nSupMod) == kDCAL_Standard) ieta += 16; //jump 16 cells for DCSM
+ dmin = TMath::Abs(fEtaCentersOfCells[etaShift + ieta]-absEta);
+ for(i= ieta+1 ; i<neta; i++) {
+ d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta);
+ if(d < dmin) {
+ dmin = d;
+ ieta = i;
+ }
+ }
+ if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //jump 16 cells for DCSM
+
+ AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod));
+
+ //patch for mapping following alice convention
+ if(nSupMod%2 == 0) {// 47 + 16 -ieta for DCSM, 47 - ieta for others, revert the ordering on A side in order to keep convention.
+ ieta = (neta -1)-ieta;
+ if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //recover cells for DCSM
+ }
+
+ absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
+ return kTRUE;
+ }
+ return kFALSE;
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t absId) const
+{
+ // May 31, 2006; only trd1 now
+ if(absId<0 || absId >= fNCells) return kFALSE;
+ else return kTRUE;
+}