GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -u -r1.10 -r1.11
--- SiPixels.java 22 Sep 2009 18:46:49 -0000 1.10
+++ SiPixels.java 22 Sep 2009 18:57:36 -0000 1.11
@@ -132,17 +132,16 @@
public Set<Integer> getNearestNeighborCells(int cell_id) {
Set<Integer> neighbors = new HashSet<Integer>();
- int row = getRowNumber(cell_id);
- int col = getColumnNumber(cell_id);
-
- for (int irow = row - 1; irow <= row + 1; irow++) {
- for (int icol = col - 1; icol <= col + 1; icol++) {
-// RP: Not sure why this corner cell was not allowed to be a neighbor - comment out and see if something breaks
-// if (irow == 0 && icol == 0) continue;
- int neighbor = getCellID(irow, icol);
- if (neighbor >= 0) {
- neighbors.add(neighbor);
- }
+ // Loop over cells in 3x3 array around cell_id
+ for (int irow = -1; irow <= 1; irow++) {
+ for (int icol = - 1; icol <= 1; icol++) {
+
+ // Exclude the starting cell
+ if (irow == 0 && icol == 0) continue;
+
+ // Get the neighbor cell and add it to the neighbor set if valid
+ int neighbor = getNeighborCell(cell_id, irow, icol);
+ if (neighbor >= 0) neighbors.add(neighbor);
}
}
return neighbors;