lcsim/src/org/lcsim/contrib/onoprien/vsegment/geom/sensortype
diff -N CylinderLZR.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CylinderLZR.java 5 Sep 2008 21:40:02 -0000 1.1
@@ -0,0 +1,127 @@
+package org.lcsim.contrib.onoprien.vsegment.geom.sensortype;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.vsegment.geom.SensorType;
+import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
+import org.lcsim.contrib.onoprien.vsegment.transform.ConstHep3Vector;
+import org.lcsim.contrib.onoprien.vsegment.transform.IRefFrame;
+
+/**
+ * This class represents a cylindrical sensor with pixels or strips parallel to its axis.
+ * <p>
+ * The reference frame is (U,V,W = R0*Phi,Z,R-R0), where R0 is the reference surface
+ * radius supplied to the constructor.
+ *
+ * @author D.Onoprienko
+ * @version $Id: CylinderLZR.java,v 1.1 2008/09/05 21:40:02 onoprien Exp $
+ */
+public class CylinderLZR extends Rectangle {
+
+// -- Constructors : ----------------------------------------------------------
+
+ /**
+ * Create <tt>Cylinder</tt> instance.
+ * The <tt>center</tt> parameter controls offsets in the local reference frame.
+ *
+ * @param length Length of the cylinder (along strip direction).
+ * @param radius Radius of the cylinder (average between inner and outer redii).
+ * @param thickness Thickness of the cylinder.
+ * @param nLength Number of divisions along the cylinder length.
+ * @param nPhi Number of divisions in phi.
+ * @param rReference Radius of the reference surface.
+ */
+ public CylinderLZR(double radius, double length, double thickness, int nPhi, int nLength, double rReference) {
+ super(2.*Math.PI*rReference, length, thickness, nPhi, nLength, new ConstHep3Vector(0., 0., radius-rReference));
+ _hitType = ((length/nLength)/((2.*Math.PI*rReference)/nPhi) < 4.) ? ITrackerHit.Type.PIXEL : ITrackerHit.Type.STRIP;
+ }
+
+ /**
+ * Create <tt>Cylinder</tt> instance.
+ * Strip width will be adjusted to make sure integral number of strips fits the
+ * circumference of the cylinder.
+ *
+ * @param length Length of the cylinder (along strip direction).
+ * @param radius Radius of the cylinder.
+ * @param thickness Thickness of the sensor.
+ * @param stripPitch Strip width.
+ * @param stripLength Strip length.
+ * @param center Controls definition of the local reference frame
+ */
+ public CylinderLZR(double radius, double length, double thickness, double stripPitch, double stripLength, double rReference) {
+ this(radius, length, thickness, (int) Math.round((2.*Math.PI*rReference)/stripPitch), (int) Math.round(length/stripLength), rReference);
+ }
+
+// -----------------------------------------------------------------------------
+
+ /**
+ * Converts a point in local sensor coordinates to channel ID.
+ * Returns -1 if the point is outside of sensor sensitive area.
+ */
+ public int getChannelID(Hep3Vector point) {
+
+ double u = point.x();
+ double v = point.y();
+
+ int nV = (int) Math.floor((v-_vLow)/_length);
+ if ((nV < 0) || (nV >= _nDivV)) return -1;
+
+ int nU = (int) Math.floor((u-_uLow)/_pitch);
+ while (nU < 0) nU += _nDivU;
+ while (nU >= _nDivU) nU -= _nDivU;
+
+ return nV*_nDivU + nU;
+ }
+
+ /**
+ * Returns local cartesian reference frame at the specified position in local sensor coordinates.
+ * For this type of sensor, the specified sensor reference frame is returned, independent of position.
+ */
+ public IRefFrame getLocalFrame(IRefFrame sensorFrame, Hep3Vector position) {
+ return sensorFrame;
+ }
+
+ /**
+ * Returns channel ID of a neighbor channel.
+ * Returns -1 if the channel defined by shifts does not exist on this sensor.
+ *
+ * @param channelID ID of the original channel
+ * @param shiftV move in <tt>V</tt> direction by <tt>shiftV</tt> channels
+ * @param shiftU move in <tt>U</tt> direction by <tt>shiftU</tt> channels
+ */
+ public int getNeighbor(int channelID, int shiftU, int shiftV) {
+ int nV = (channelID / _nDivU) + shiftV;
+ if (nV < 0 || nV >= _nDivV) return -1;
+ int nU = (channelID % _nDivU) + shiftU;
+ while (nU < 0) nU += _nDivU;
+ while (nU >= _nDivU) nU -= _nDivU;
+ return nV*_nDivU + nU;
+ }
+
+ /**
+ * Returns array of IDs of all immediate neighbor channels.
+ * For strips ({@link #getHitDimension()} returns 1), this method looks for neighbors
+ * in U direction only. Therefore, each strip has 1 or 2 neighbors. For pixels
+ * ({@link #getHitDimension()} returns 2), up to 8 neighbors can be found.
+ */
+ public List<Integer> getNeighbors(int channelID) {
+ int nU = channelID % _nDivU;
+ int nV = channelID / _nDivU;
+ ArrayList<Integer> out = new ArrayList<Integer>(8);
+ int vDown = ((_hitType.nMeasDir() == 2) && (nV > 0)) ? nV-1 : nV;
+ int vUp = ((_hitType.nMeasDir() == 2) && (nV < _nDivV-1)) ? nV+1 : nV;
+ for (int iV = vDown; iV < vUp; iV++) {
+ for (int iU = nU-1; iU < nU+1; iU++) {
+ while (nU < 0) nU += _nDivU;
+ while (nU >= _nDivU) nU -= _nDivU;
+ out.add(nV*_nDivU + nU);
+ }
+ }
+ return out;
+ }
+
+}
lcsim/src/org/lcsim/contrib/onoprien/vsegment/geom/sensortype
diff -u -r1.1 -r1.2
--- Cylinder.java 3 Sep 2008 04:28:29 -0000 1.1
+++ Cylinder.java 5 Sep 2008 21:40:02 -0000 1.2
@@ -8,23 +8,20 @@
import org.lcsim.contrib.onoprien.vsegment.geom.SensorType;
import org.lcsim.contrib.onoprien.vsegment.hit.ITrackerHit;
+import org.lcsim.contrib.onoprien.vsegment.transform.ConstHep3Vector;
import org.lcsim.contrib.onoprien.vsegment.transform.IRefFrame;
+import org.lcsim.contrib.onoprien.vsegment.transform.RefFrameCylinder;
+import org.lcsim.contrib.onoprien.vsegment.transform.RefFrameLocalOnCylinder;
/**
- * This class represents a cylindrical sensor with strips parallel to its axis.
- * The reference frame is cylindrical (U,V,W = Phi,Z,R), with the position of origin
- * controled by <tt>Hep3Vector center</tt> parameter given to a constructor.
- * If <tt>center = (Phi0,Z0,R0)</tt>, then the sensor volume of the cylinder will be defined by
- * <tt><nobr>Phi0-PI < u < Phi0+PI ,</nobr>
- * <nobr>Z0-length < v < Z0+length ,</nobr>
- * <nobr>R0-thickness/2 < w < R0+thickness/2</nobr></tt>.
- * Constructors that do not require <tt>center</tt> parameter assume
- * <nobr><tt>center = (0.,0.,radius)</tt></nobr>,
- * placing the local reference frame origin in the center of the detector with
- * <tt>phi</tt> ranging from <tt>-PI</tt> to <tt>PI</tt>.
+ * This class represents a cylindrical sensor with pixels or strips parallel to its axis.
+ * <p>
+ * The reference frame is (U,V,W = Phi,Z,R).
+ * Channel positions returned by <tt>getChannelPosition</tt> method will be on the cylindrical
+ * reference surface specified by the radius supplied to the constructor.
*
* @author D.Onoprienko
- * @version $Id: Cylinder.java,v 1.1 2008/09/03 04:28:29 onoprien Exp $
+ * @version $Id: Cylinder.java,v 1.2 2008/09/05 21:40:02 onoprien Exp $
*/
public class Cylinder extends Rectangle {
@@ -35,28 +32,15 @@
* The <tt>center</tt> parameter controls offsets in the local reference frame.
*
* @param length Length of the cylinder (along strip direction).
- * @param radius Radius of the cylinder.
- * @param thickness Thickness of the sensor.
+ * @param radius Radius of the cylinder (average between inner and outer redii).
+ * @param thickness Thickness of the cylinder.
* @param nLength Number of divisions along the cylinder length.
* @param nPhi Number of divisions in phi.
- * @param center Controls definition of the local reference frame
+ * @param rReference Radius of the reference surface.
*/
- public Cylinder(double radius, double length, double thickness, int nPhi, int nLength, Hep3Vector center) {
- super(TWOPI, length, thickness, nPhi, nLength, center);
- _hitType = ((length/nLength)/(TWOPI*radius/nPhi) < 4.) ? ITrackerHit.Type.PIXEL : ITrackerHit.Type.STRIP;
- }
-
- /**
- * Create <tt>Cylinder</tt> instance.
- *
- * @param length Length of the cylinder (along strip direction).
- * @param radius Radius of the cylinder.
- * @param thickness Thickness of the sensor.
- * @param nLength Number of divisions along the cylinder length.
- * @param nPhi Number of divisions in phi.
- */
- public Cylinder(double radius, double length, double thickness, int nPhi, int nLength) {
- this(radius, length, thickness, nPhi, nLength, new BasicHep3Vector(0.,0.,radius));
+ public Cylinder(double radius, double length, double thickness, int nPhi, int nLength, double rReference) {
+ super(TWOPI, length, thickness, nPhi, nLength, new ConstHep3Vector(0., 0., rReference));
+ _hitType = ((length/nLength)/((TWOPI*rReference)/nPhi) < 4.) ? ITrackerHit.Type.PIXEL : ITrackerHit.Type.STRIP;
}
/**
@@ -71,23 +55,8 @@
* @param stripLength Strip length.
* @param center Controls definition of the local reference frame
*/
- public Cylinder(double radius, double length, double thickness, double stripPitch, double stripLength, Hep3Vector center) {
- this(radius, length, thickness, (int) Math.round((TWOPI*radius)/stripPitch), (int) Math.round(length/stripLength), center);
- }
-
- /**
- * Create <tt>Cylinder</tt> instance.
- * Strip width will be adjusted to make sure integral number of strips fits the
- * circumference of the cylinder.
- *
- * @param length Length of the cylinder (along strip direction).
- * @param radius Radius of the cylinder.
- * @param thickness Thickness of the sensor.
- * @param stripPitch Strip width.
- * @param stripLength Strip length.
- */
- public Cylinder(double radius, double length, double thickness, double stripPitch, double stripLength) {
- this(radius, length, thickness, stripPitch, stripLength, new BasicHep3Vector(0.,0.,radius));
+ public Cylinder(double radius, double length, double thickness, double stripPitch, double stripLength, double rReference) {
+ this(radius, length, thickness, (int) Math.round((TWOPI*rReference)/stripPitch), (int) Math.round(length/stripLength), rReference);
}
// -----------------------------------------------------------------------------
@@ -97,8 +66,6 @@
* Returns -1 if the point is outside of sensor sensitive area.
*/
public int getChannelID(Hep3Vector point) {
-
-// if (Math.abs(point.z()-_wCenter) > _thick/2.) return -1;
double u = point.x();
double v = point.y();
@@ -114,6 +81,14 @@
}
/**
+ * Returns local cartesian reference frame at the specified position in local sensor coordinates.
+ * For this type of sensor, the specified sensor reference frame is returned, independent of position.
+ */
+ public IRefFrame getLocalFrame(IRefFrame sensorFrame, Hep3Vector position) {
+ return new RefFrameLocalOnCylinder((RefFrameCylinder)sensorFrame, position);
+ }
+
+ /**
* Returns channel ID of a neighbor channel.
* Returns -1 if the channel defined by shifts does not exist on this sensor.
*
@@ -151,8 +126,8 @@
}
return out;
}
-
+
// -- Private parts : ---------------------------------------------------------
- static final double TWOPI = 2.*Math.PI;
+ static private final double TWOPI = Math.PI*2.;
}