GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -N SiPixels.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SiPixels.java 3 Apr 2009 22:10:29 -0000 1.1
@@ -0,0 +1,388 @@
+/*
+ * SiPixels.java
+ *
+ * Created on May 10, 2008, 4:52 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.detector.tracker.silicon;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.ITransform3D;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.solids.GeomOp2D;
+import org.lcsim.detector.solids.GeomOp3D;
+import org.lcsim.detector.solids.Point3D;
+import org.lcsim.detector.solids.Polygon3D;
+
+/**
+ *
+ * @author tknelson
+ */
+public class SiPixels implements SiSensorElectrodes
+{
+
+ private ChargeCarrier _carrier; // charge carrier collected
+ private int _nrows; // number of rows - row index measures x
+ private int _ncols; // number of columns - column index measures y
+ private double _row_pitch; // row pitch
+ private double _col_pitch; // column pitch
+
+ // cached for convenience
+ private double _row_offset; // row offset
+ private double _col_offset; // column offset
+
+
+ private IDetectorElement _detector; // associated detector element
+ private ITransform3D _parent_to_local; // parent to local transform
+ private ITransform3D _local_to_global; // transformation to global coordinates
+ private ITransform3D _global_to_local; // transformation from global coordinates
+ private Polygon3D _geometry; // region in which strips are defined
+
+ /** Creates a new instance of SiPixels */
+ public SiPixels(ChargeCarrier carrier, double row_pitch, double col_pitch,
+ IDetectorElement detector, ITransform3D parent_to_local)
+ {
+
+// System.out.println("Plane of polygon in sensor coordinates has... ");
+// System.out.println(" normal: "+((SiSensor)detector).getBiasSurface(carrier).getNormal());
+// System.out.println(" distance: "+((SiSensor)detector).getBiasSurface(carrier).getDistance());
+
+ setCarrier(carrier);
+ setRowPitch(row_pitch);
+ setColumnPitch(col_pitch);
+ setGeometry(((SiSensor)detector).getBiasSurface(carrier).transformed(parent_to_local));
+ setPixelNumbering();
+ setDetectorElement(detector);
+ setParentToLocal(parent_to_local);
+ setGlobalToLocal(Transform3D.multiply(parent_to_local,detector.getGeometry().getGlobalToLocal()));
+ setLocalToGlobal(getGlobalToLocal().inverse());
+ }
+
+
+
+
+ // Cell shape, assumed to be strips or rectancular pixels
+ public int getNAxes()
+ {
+ return 2;
+ }
+
+ // Get Detector element for associated sensor
+ public IDetectorElement getDetectorElement()
+ {
+ return _detector;
+ }
+
+ // Transformation from sensor coordinates to electrode coordinates
+ public ITransform3D getParentToLocal()
+ {
+ return _parent_to_local;
+ }
+
+ // Transformation from electrode coordinates to global coordinates
+ public ITransform3D getLocalToGlobal()
+ {
+ return _local_to_global;
+ }
+
+ // Transformation from gloabl coordinates to electrode coordinates
+ public ITransform3D getGlobalToLocal()
+ {
+ return _global_to_local;
+ }
+
+ // Polygon on which electrodes are defined
+ public Polygon3D getGeometry()
+ {
+ return _geometry;
+ }
+
+ // Direction of each measured coordinate
+ public Hep3Vector getMeasuredCoordinate(int axis)
+ {
+ if (axis == 0) return new BasicHep3Vector(1.0,0.0,0.0);
+ else if (axis == 1) return new BasicHep3Vector(0.0,1.0,0.0);
+ else return null;
+ }
+
+ // Direction of each non-measured coordinate (i.e. strip axis for strips)
+ public Hep3Vector getUnmeasuredCoordinate(int axis)
+ {
+ if (axis == 0) return new BasicHep3Vector(0.0,1.0,0.0);
+ if (axis == 1) return new BasicHep3Vector(1.0,0.0,0.0);
+ else return null;
+ }
+
+ // Neigbor ncells away along each axis
+ public int getNeighborCell(int cell_id, int ncells_row, int ncells_col)
+ {
+ int neighbor = cell_id + ncells_row*_ncols + ncells_col;
+ if (isValidCell(neighbor))
+ {
+ return neighbor;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ // Get all nearest neighbor cells
+ 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++)
+ {
+ if (irow == 0 && icol == 0) continue;
+ int neighbor = getCellID(irow,icol);
+ if (isValidCell(neighbor))
+ {
+ neighbors.add(neighbor);
+ }
+ }
+ }
+ return neighbors;
+ }
+
+ // Cell number is valid
+ public boolean isValidCell(int cell_id)
+ {
+ return GeomOp3D.intersects(new Point3D(getCellPosition(cell_id)),_geometry); // FIXME: should cell position be a Point3D??
+ }
+
+ // Number of cells (strips or pixels)
+ public int getNCells()
+ {
+ return _nrows*_ncols;
+ }
+
+ // Number of cells along each axis
+ public int getNCells(int axis)
+ {
+ if (axis == 0) return _nrows;
+ else if (axis == 1) return _ncols;
+ else return 0;
+ }
+
+ // Size of a cell (strip or pixel pitch)
+ public double getPitch(int axis)
+ {
+ if (axis == 0) return _row_pitch;
+ else if (axis == 1) return _col_pitch;
+ else return 0;
+ }
+
+ // ID of cell at a given position (cell number)
+ public int getCellID(Hep3Vector position)
+ {
+ return getCellID(getRowNumber(position),getColumnNumber(position));
+ }
+
+ // Row number of cell at given position
+ public int getRowNumber(Hep3Vector position)
+ {
+ return (int)Math.round((position.x()+_row_offset)/_row_pitch);
+ }
+
+ // Column number of cell at given position
+ public int getColumnNumber(Hep3Vector position)
+ {
+ return (int)Math.round((position.y()+_col_offset)/_col_pitch);
+ }
+
+ // ID of cell from row and column number
+ public int getCellID(int row_number, int column_number)
+ {
+ return row_number*_ncols + column_number;
+ }
+
+ // Row number of cell from ID
+ public int getRowNumber(int cell_id)
+ {
+ return (int)Math.floor(cell_id/_ncols);
+ }
+
+ // Column number of cell from ID
+ public int getColumnNumber(int cell_id)
+ {
+ return cell_id - getRowNumber(cell_id)*_ncols;
+ }
+
+ // Location of given position within a cell
+ public Hep3Vector getPositionInCell(Hep3Vector position)
+ {
+ return VecOp.sub(position,getCellPosition(getCellID(position)));
+ }
+ // Position of a particular cell (by cell number)
+ public Hep3Vector getCellPosition(int cell_id)
+ {
+ return new BasicHep3Vector(getRowNumber(cell_id)*_row_pitch-_row_offset, getColumnNumber(cell_id)*_col_pitch-_col_offset,0.0);
+ }
+
+ // Charge carrier
+ public ChargeCarrier getChargeCarrier()
+ {
+ return _carrier;
+ }
+
+ // Capacitance of electrode
+ public double getCapacitance(int cell_id)
+ {
+ return 0.1; // FIXME: hard wired for now to 0.1 pf
+ }
+
+ // Compute Gaussian-distributed charge on electrodes
+ public SortedMap<Integer,Integer> computeElectrodeData(ChargeDistribution distribution)
+ {
+ SortedMap<Integer,Integer> electrode_data = new TreeMap<Integer,Integer>();
+
+
+
+ return electrode_data;
+ }
+
+ // Private setters
+ //==================
+
+ public void setCarrier(ChargeCarrier carrier)
+ {
+ _carrier = carrier;
+ }
+
+ public void setGeometry(Polygon3D geometry)
+ {
+// System.out.println("Plane of polygon has... ");
+// System.out.println(" normal: "+geometry.getNormal());
+// System.out.println(" distance: "+geometry.getDistance());
+//
+// System.out.println("Working plane has... ");
+// System.out.println(" normal: "+GeomOp2D.PLANE.getNormal());
+// System.out.println(" distance: "+GeomOp2D.PLANE.getDistance());
+
+ if (GeomOp3D.equals(geometry.getPlane(),GeomOp2D.PLANE))
+ {
+ _geometry = geometry;
+ }
+ else
+ {
+ throw new RuntimeException("Electrode geometry must be defined in x-y plane!!");
+ }
+ }
+
+
+ private void setPixelNumbering()
+ {
+ double xmin = Double.MAX_VALUE;
+ double xmax = Double.MIN_VALUE;
+ double ymin = Double.MAX_VALUE;
+ double ymax = Double.MIN_VALUE;
+ for (Point3D vertex : _geometry.getVertices())
+ {
+ xmin = Math.min(xmin,vertex.x());
+ xmax = Math.max(xmax,vertex.x());
+ ymin = Math.min(ymin,vertex.y());
+ ymax = Math.max(ymax,vertex.y());
+ }
+
+// System.out.println("xmin: " + xmin);
+// System.out.println("xmax: " + xmax);
+//
+//
+// System.out.println("# strips: " + (int)Math.ceil((xmax-xmin)/getPitch(0)) ) ;
+
+ setNRows((int)Math.ceil((xmax-xmin)/getPitch(0)));
+ setNColumns((int)Math.ceil((ymax-ymin)/getPitch(1)));
+
+ }
+
+ private void setNRows(int nrows)
+ {
+ _nrows = nrows;
+ setRowOffset();
+ }
+
+ private void setNColumns(int ncolumns)
+ {
+ _ncols = ncolumns;
+ setColumnOffset();
+ }
+
+ private void setRowOffset()
+ {
+ double xmin = Double.MAX_VALUE;
+ double xmax = Double.MIN_VALUE;
+ for (Point3D vertex : _geometry.getVertices())
+ {
+ xmin = Math.min(xmin,vertex.x());
+ xmax = Math.max(xmax,vertex.x());
+ }
+
+ double row_center = (xmin+xmax)/2;
+
+ _row_offset = ((_nrows-1)*_row_pitch)/2 - row_center;
+
+ }
+
+ private void setColumnOffset()
+ {
+ double ymin = Double.MAX_VALUE;
+ double ymax = Double.MIN_VALUE;
+ for (Point3D vertex : _geometry.getVertices())
+ {
+ ymin = Math.min(ymin,vertex.y());
+ ymax = Math.max(ymax,vertex.y());
+ }
+
+ double column_center = (ymin+ymax)/2;
+
+ _col_offset = ((_ncols-1)*_col_pitch)/2 - column_center;
+
+ }
+
+ private void setRowPitch(double row_pitch)
+ {
+ _row_pitch = row_pitch;
+ }
+
+ private void setColumnPitch(double col_pitch)
+ {
+ _col_pitch = col_pitch;
+ }
+
+ private void setDetectorElement(IDetectorElement detector)
+ {
+ _detector = detector;
+ }
+
+ private void setParentToLocal(ITransform3D parent_to_local)
+ {
+ _parent_to_local = parent_to_local;
+ }
+
+ private void setLocalToGlobal(ITransform3D local_to_global)
+ {
+ _local_to_global = local_to_global;
+ }
+
+ private void setGlobalToLocal(ITransform3D global_to_local)
+ {
+ _global_to_local = global_to_local;
+ }
+
+}
GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -u -r1.9 -r1.10
--- SiSensorElectrodes.java 3 Dec 2007 23:23:30 -0000 1.9
+++ SiSensorElectrodes.java 3 Apr 2009 22:10:29 -0000 1.10
@@ -55,9 +55,6 @@
// Cell number is valid
public boolean isValidCell(int cell);
- // Cell number along this coordinate is valid
- public boolean isValidCell(int cell, int axis);
-
// Number of cells (strips or pixels)
public int getNCells();
GeomConverter/src/org/lcsim/detector/tracker/silicon
diff -u -r1.15 -r1.16
--- SiStrips.java 6 Jun 2008 17:09:48 -0000 1.15
+++ SiStrips.java 3 Apr 2009 22:10:29 -0000 1.16
@@ -151,11 +151,6 @@
return (cell >= 0 && cell < getNCells());
}
- public boolean isValidCell(int cell, int axis)
- {
- return (cell >= 0 && cell < getNCells(axis));
- }
-
public int getNCells()
{
return _nstrips;