-//______________________________________________________________________
-void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
- // given the tower index number it returns the based on the eta and phi
- // of the tower.
- // Inputs:
- // Int_t index // Tower index number [1-2*fNZ*fNPhi]
- // Outputs:
- // Float_t eta // eta of center of tower in pseudorapidity
- // Float_t phi // phi of center of tower in degrees
- // Returned
- // none.
- Int_t ieta,iphi,ipre;
- Double_t deta,dphi,phid;
-
- TowerIndexes(index,ieta,iphi,ipre);
- deta = (GetArm1EtaMax()-GetArm1EtaMin())/((Float_t)GetNEta());
- eta = GetArm1EtaMin() + (((Float_t)ieta)-0.5)*deta;
- dphi = (GetArm1PhiMax() - GetArm1PhiMin())/((Float_t)GetNPhi()); // in degrees.
- phid = GetArm1PhiMin() + dphi*((Float_t)iphi -0.5);//iphi range [1-fNphi].
- phi = phid;
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Int_t maxAbsId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
+{
+ // Jul 31, 2007 - taking into account position of shower max and apply coor2.
+ // Look to see what the relative
+ // position inside a given cell is
+ // for a recpoint.
+ // In:
+ // absId - cell is as in Geant, 0<= absId < fNCells;
+ // maxAbsId - abs id of cell with highest energy
+ // e - cluster energy
+ // OUT:
+ // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
+
+ // Shift index taking into account the difference between standard SM
+ // and SM of half size in phi direction
+ const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
+ static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta;
+ static Int_t iphim, ietam;
+ static AliEMCALShishKebabTrd1Module *mod = 0;
+ static TVector2 v;
+
+ static Int_t nSupModM, nModuleM, nIphiM, nIetaM, iphiM, ietaM;
+ static Int_t iphimM, ietamM, maxAbsIdCopy=-1;
+ static AliEMCALShishKebabTrd1Module *modM = 0;
+ static Double_t distCorr;
+
+ if(!CheckAbsCellId(absId)) return kFALSE;
+
+ GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
+ GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
+ GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
+
+ //Get eta position. Careful with ALICE conventions (increase index decrease eta)
+ if(nSupMod%2 == 0) {
+ ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 23-ietam, revert the ordering on A side in order to keep convention.
+ if(nIeta == 0) nIeta = 1;
+ else nIeta = 0;
+ }
+
+ mod = GetShishKebabModule(ietam);
+
+ if(absId != maxAbsId) {
+ distCorr = 0.;
+ if(maxAbsIdCopy != maxAbsId) {
+ GetCellIndex(maxAbsId, nSupModM, nModuleM, nIphiM, nIetaM);
+ GetModulePhiEtaIndexInSModule(nSupModM, nModuleM, iphimM, ietamM);
+ GetCellPhiEtaIndexInSModule(nSupModM,nModuleM,nIphiM,nIetaM, iphiM, ietaM);
+ //Careful with ALICE conventions (increase index decrease eta)
+ if(nSupModM%2 == 0) {
+ ietamM = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietamM;// 47-ietam, revert the ordering on A side in order to keep convention.
+ }
+
+ modM = GetShishKebabModule(ietamM); // do I need this ?
+ maxAbsIdCopy = maxAbsId;
+ }
+
+ if(ietamM !=0) {
+ distCorr = fEMCGeometry->GetEtaModuleSize()*(ietam-ietamM)/TMath::Tan(modM->GetTheta()); // Stay here
+ //printf(" distCorr %f | dist %f | ietam %i -> etamM %i\n", distCorr, dist, ietam, ietamM);
+ }
+ // distEff += distCorr;
+ }
+ // Bad resolution in this case, strong bias vs phi
+ // distEff = 0.0;
+ mod->GetPositionAtCenterCellLine(nIeta, distEff, v); // Stay here
+ xr = v.Y() - fParSM[0];
+ zr = v.X() - fParSM[2];
+
+ //Get phi position. Careful with ALICE conventions (increase index increase phi)
+ Int_t iphi2 = iphi;
+ if(nSupMod<10) {
+ if(nSupMod%2 != 0)
+ iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
+ yr = fCentersOfCellsPhiDir.At(iphi2);
+
+ } else {
+ if(nSupMod%2 != 0)
+ iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
+ yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift);
+ }
+ AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
+
+ return kTRUE;