GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -u -r1.6 -r1.7
--- SiPixels.java 29 Apr 2009 19:22:53 -0000 1.6
+++ SiPixels.java 29 Apr 2009 21:46:09 -0000 1.7
@@ -170,12 +170,18 @@
// Row number of cell at given position
public int getRowNumber(Hep3Vector position) {
- return (int) Math.round((position.x() + _row_offset) / _row_pitch);
+ int row = (int) Math.round((position.x() + _row_offset) / _row_pitch);
+ if (row < 0) row = 0;
+ if (row >= _nrows) row = _nrows - 1;
+ return row;
}
// Column number of cell at given position
public int getColumnNumber(Hep3Vector position) {
- return (int) Math.round((position.y() + _col_offset) / _col_pitch);
+ int col = (int) Math.round((position.y() + _col_offset) / _col_pitch);
+ if (col < 0) col = 0;
+ if (col >= _ncols) col = _ncols - 1;
+ return col;
}
// ID of cell from row and column number
@@ -185,7 +191,7 @@
// Row number of cell from ID
public int getRowNumber(int cell_id) {
- return (int) Math.floor(cell_id / _ncols);
+ return cell_id / _ncols;
}
// Column number of cell from ID