]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Add protection in method AliEMCALGeometry::GetAbsCellIdFromCellIndexes in case eta...
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 May 2012 13:18:25 +0000 (13:18 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 May 2012 13:18:25 +0000 (13:18 +0000)
EMCAL/AliEMCALGeometry.cxx
EMCAL/AliEMCALRecoUtils.cxx

index a9802119a9975f0a67e2e853c68468f3b9f0be1b..e46a5e60b3344c784ad2ddb48147831eaf238362 100644 (file)
@@ -501,6 +501,16 @@ void  AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod,
 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
 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
 
   static Int_t ietam=-1, iphim=-1, nModule=-1;
   static Int_t nIeta=-1, nIphi=-1; // cell indexes in module
 
@@ -509,7 +519,7 @@ Int_t  AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi,
   nIeta = ieta%fNETAdiv;
   nIeta = fNETAdiv - 1 - nIeta;
   nIphi = iphi%fNPHIdiv;
   nIeta = ieta%fNETAdiv;
   nIeta = fNETAdiv - 1 - nIeta;
   nIphi = iphi%fNPHIdiv;
-
+  
   return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
 }
 
   return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
 }
 
@@ -591,7 +601,6 @@ Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_
    if(nSupMod%2 == 0)            
       ieta = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
    
    if(nSupMod%2 == 0)            
       ieta = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
    
-  
     absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
 
     return kTRUE;
     absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
 
     return kTRUE;
index cde9aa993852f0a1ee9d8c6d3740cfe718b33f1f..37e5c734918e2d787ed7587aba3269eaee633f5c 100644 (file)
@@ -346,7 +346,7 @@ Bool_t AliEMCALRecoUtils::AcceptCalibrateCell(const Int_t absID, const Int_t bc,
   }
   
   geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);       
   }
   
   geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);       
-  
+
   // Do not include bad channels found in analysis,
   if( IsBadChannelsRemovalSwitchedOn() && GetEMCALChannelStatus(imod, ieta, iphi)) 
   {
   // Do not include bad channels found in analysis,
   if( IsBadChannelsRemovalSwitchedOn() && GetEMCALChannelStatus(imod, ieta, iphi)) 
   {
@@ -499,30 +499,40 @@ Bool_t AliEMCALRecoUtils::IsExoticCell(const Int_t absID, AliVCaloCells* cells,
   geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);       
   
   //Get close cells index, energy and time, not in corners
   geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);       
   
   //Get close cells index, energy and time, not in corners
+
+  Int_t absID1 = -1;
+  Int_t absID2 = -1;
   
   
-  Int_t absID1 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi+1, ieta);
-  Int_t absID2 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi-1, ieta);
+  if( iphi < AliEMCALGeoParams::fgkEMCALRows-1) absID1 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi+1, ieta);
+  if( iphi > 0 )                                absID2 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi-1, ieta);
   
   // In case of cell in eta = 0 border, depending on SM shift the cross cell index
   
   // In case of cell in eta = 0 border, depending on SM shift the cross cell index
+
   Int_t absID3 = -1;
   Int_t absID4 = -1;
   
   Int_t absID3 = -1;
   Int_t absID4 = -1;
   
-  if     ( ieta == AliEMCALGeoParams::fgkEMCALCols - 1 && !(imod%2) )
+  
+  if     ( ieta == AliEMCALGeoParams::fgkEMCALCols-1 && !(imod%2) )
   {
   {
-    absID3 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, 0);
-    absID4 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta-1); 
+    absID3 = geom-> GetAbsCellIdFromCellIndexes(imod+1, iphi, 0);
+    absID4 = geom-> GetAbsCellIdFromCellIndexes(imod,   iphi, ieta-1); 
   }
   else if( ieta == 0 && imod%2 )
   {
   }
   else if( ieta == 0 && imod%2 )
   {
-    absID3 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta+1);
-    absID4 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, AliEMCALGeoParams::fgkEMCALCols-1); 
+    absID3 = geom-> GetAbsCellIdFromCellIndexes(imod,   iphi, ieta+1);
+    absID4 = geom-> GetAbsCellIdFromCellIndexes(imod-1, iphi, AliEMCALGeoParams::fgkEMCALCols-1); 
   }
   else
   {
   }
   else
   {
-    absID3 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta+1);
-    absID4 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta-1); 
+    if( ieta < AliEMCALGeoParams::fgkEMCALCols-1 ) 
+      absID3 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta+1);
+    if( ieta > 0 )                                 
+      absID4 = geom-> GetAbsCellIdFromCellIndexes(imod, iphi, ieta-1); 
   }
 
   }
 
+  //printf("IMOD %d, AbsId %d, a %d, b %d, c %d e %d \n",imod,absID,absID1,absID2,absID3,absID4);
+
+  
   Float_t  ecell  = 0, ecell1  = 0, ecell2  = 0, ecell3  = 0, ecell4  = 0;
   Double_t tcell  = 0, tcell1  = 0, tcell2  = 0, tcell3  = 0, tcell4  = 0;
   Bool_t   accept = 0, accept1 = 0, accept2 = 0, accept3 = 0, accept4 = 0;
   Float_t  ecell  = 0, ecell1  = 0, ecell2  = 0, ecell3  = 0, ecell4  = 0;
   Double_t tcell  = 0, tcell1  = 0, tcell2  = 0, tcell3  = 0, tcell4  = 0;
   Bool_t   accept = 0, accept1 = 0, accept2 = 0, accept3 = 0, accept4 = 0;