GeomConverter/src/org/lcsim/geometry/segmentation
diff -N SegmentationBase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SegmentationBase.java 12 Jul 2005 18:23:00 -0000 1.1
@@ -0,0 +1,144 @@
+/*
+ * Segmentation.java
+ *
+ * Created on June 1, 2005, 2:05 PM
+ */
+
+package org.lcsim.geometry.segmentation;
+
+import java.lang.Math.sqrt;
+import org.lcsim.geometry.compact.Segmentation;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.util.IDDecoder;
+import org.lcsim.geometry.util.IDDescriptor;
+import org.lcsim.geometry.util.IDEncoder;
+import org.lcsim.geometry.CalorimeterIDDecoder;
+import org.lcsim.geometry.compact.LayeredSubdetector;
+import org.jdom.Element;
+
+/**
+ * @author jeremym
+ * Base implementation
+ */
+public abstract class SegmentationBase
+ extends org.lcsim.geometry.compact.Segmentation
+ implements CalorimeterIDDecoder
+{
+ public enum CoordinateSystemType { GLOBAL, LOCAL, UNDEFINED };
+
+ protected IDDecoder decoder;
+ protected IDEncoder encoder;
+ protected int[] values;
+ protected int layerIndex;
+
+ /**
+ * FIXME: Caching the Subdetector is an ugly hack. --JM
+ */
+ protected LayeredSubdetector detector;
+
+ SegmentationBase(Element e)
+ {
+ super(e);
+ }
+
+ public CoordinateSystemType getCoordinateSystemType()
+ {
+ return CoordinateSystemType.UNDEFINED;
+ }
+
+ abstract public double getX();
+
+ abstract public double getY();
+
+ abstract public double getZ();
+
+ abstract public double getTheta();
+
+ abstract public double getPhi();
+
+ abstract public long[] getNeighbourIDs(int deltaLayer, int deltaTheta, int deltaPhi);
+
+ /** Override but make sure to call this super method. */
+ public void setIDDescription(IDDescriptor id)
+ {
+ decoder = new IDDecoder(id);
+ encoder = new IDEncoder(id);
+ values = new int[id.fieldCount()];
+
+ /** FIXME: Doesn't seem to belong here. */
+ layerIndex = id.indexOf("layer");
+ }
+
+ /**
+ * Next set of methods should probably not need to be
+ * overridden but will leave as non-final (for now).
+ */
+ public void setSubdetector(Subdetector det)
+ {
+ detector = (LayeredSubdetector) det;
+ }
+
+ /**
+ * FIXME: Should be renamed as it is actually returning the distance to the midpoint of the sensitive layer.
+ */
+ public double getRadius(int layer)
+ {
+ return detector.getDistanceToLayerSensorMid(layer);
+ }
+
+ public double computeCylindricalRadiusFromPosition()
+ {
+ return sqrt(getX() * getX() + getY() * getY() );
+ }
+
+ public int getIndex(String field)
+ {
+ return decoder.getValue(field);
+ }
+
+ public int getValue(int index)
+ {
+ return decoder.getValue(index);
+ }
+
+ public String getFieldName(int index)
+ {
+ return decoder.getFieldName(index);
+ }
+
+ public int getFieldCount()
+ {
+ return values.length;
+ }
+
+ public String toString()
+ {
+ return decoder == null ? "NoDecoder" : decoder.toString();
+ }
+
+ public void setID(long id)
+ {
+ decoder.setID(id);
+ decoder.getValues(values);
+ }
+
+ public double[] getPosition()
+ {
+ return new double[] { getX(), getY(), getZ() };
+ }
+
+ public int getLayer()
+ {
+ return values[layerIndex];
+ }
+
+ public boolean supportsNeighbours()
+ {
+ return false;
+ }
+
+ public long[] getNeighbourIDs()
+ {
+ return getNeighbourIDs(1,1,1);
+ }
+}
GeomConverter/src/org/lcsim/geometry/segmentation
diff -N SegmentationImpl.java
--- SegmentationImpl.java 23 Jun 2005 20:52:18 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,138 +0,0 @@
-/*
- * Segmentation.java
- *
- * Created on June 1, 2005, 2:05 PM
- */
-
-package org.lcsim.geometry.segmentation;
-
-import org.lcsim.geometry.compact.Segmentation;
-import org.lcsim.geometry.compact.Subdetector;
-import org.lcsim.geometry.util.IDDecoder;
-import org.lcsim.geometry.util.IDDescriptor;
-import org.lcsim.geometry.util.IDEncoder;
-import org.lcsim.geometry.CalorimeterIDDecoder;
-import org.lcsim.geometry.compact.LayeredSubdetector;
-import org.jdom.Element;
-
-/**
- * @author jeremym
- * Base implementation
- */
-public abstract class SegmentationImpl
- extends org.lcsim.geometry.compact.Segmentation
- implements CalorimeterIDDecoder
-{
- public enum CoordinateSystemType { GLOBAL, LOCAL, UNDEFINED };
-
- protected IDDecoder decoder;
- protected IDEncoder encoder;
- protected int[] values;
- protected int layerIndex;
-
- /**
- * FIXME: Caching the Subdetector here seems like an ugly hack. --JM
- */
- protected LayeredSubdetector detector;
-
- SegmentationImpl(Element e)
- {
- super(e);
- }
-
- public CoordinateSystemType getCoordinateSystemType()
- {
- return CoordinateSystemType.UNDEFINED;
- }
-
- abstract public double getX();
-
- abstract public double getY();
-
- abstract public double getZ();
-
- abstract public double getTheta();
-
- abstract public double getPhi();
-
- abstract public long[] getNeighbourIDs(int deltaLayer, int deltaTheta, int deltaPhi);
-
- /** Override but make sure to call this super method. */
- public void setIDDescription(IDDescriptor id)
- {
- decoder = new IDDecoder(id);
- encoder = new IDEncoder(id);
- values = new int[id.fieldCount()];
-
- /** FIXME: Doesn't seem to belong here. */
- layerIndex = id.indexOf("layer");
- }
-
- /**
- * Next set of methods should probably not need to be
- * overridden but will leave as non-final (for now).
- */
- public void setSubdetector(Subdetector det)
- {
- detector = (LayeredSubdetector) det;
- }
-
- /**
- * FIXME: Should be renamed as it is actually returning the distance to the midpoint of the sensitive layer.
- */
- public double getRadius(int layer)
- {
- return detector.getDistanceToLayerSensorMid(layer);
- }
-
- public int getIndex(String field)
- {
- return decoder.getValue(field);
- }
-
- public int getValue(int index)
- {
- return decoder.getValue(index);
- }
-
- public String getFieldName(int index)
- {
- return decoder.getFieldName(index);
- }
-
- public int getFieldCount()
- {
- return values.length;
- }
-
- public String toString()
- {
- return decoder == null ? "NoDecoder" : decoder.toString();
- }
-
- public void setID(long id)
- {
- decoder.setID(id);
- decoder.getValues(values);
- }
-
- public double[] getPosition()
- {
- return new double[] { getX(), getY(), getZ() };
- }
-
- public int getLayer()
- {
- return values[layerIndex];
- }
-
- public boolean supportsNeighbours()
- {
- return false;
- }
-
- public long[] getNeighbourIDs()
- {
- return getNeighbourIDs(1,1,1);
- }
-}