Commit in GeomConverter/src/org/lcsim/geometry/segmentation on MAIN
SegmentationBase.java+68-531.2 -> 1.3
Added generic global to local function which calls detector ref's method.

GeomConverter/src/org/lcsim/geometry/segmentation
SegmentationBase.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SegmentationBase.java	12 Jul 2005 18:54:08 -0000	1.2
+++ SegmentationBase.java	13 Jul 2005 05:28:07 -0000	1.3
@@ -7,8 +7,8 @@
 package org.lcsim.geometry.segmentation;
 
 import static java.lang.Math.sqrt;
+import org.lcsim.geometry.Subdetector;
 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;
@@ -19,26 +19,31 @@
 /**
  * @author jeremym
  * Base implementation
+ *
+ * FIXME: Why not implement functions that "callback" to the detector object within the detector class instead?
+ * FIXME: It makes no sense that this class extends what is, in effect, a CalorimeterId, e.g. CalorimeterIDDecoder.
+ *
  */
-public abstract class SegmentationBase 
-       extends org.lcsim.geometry.compact.Segmentation 
-       implements CalorimeterIDDecoder
-{   
-    public enum CoordinateSystemType { GLOBAL, LOCAL, UNDEFINED };
+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;         
+    protected int layerIndex;
     
-    /** 
+    /**
      * FIXME: Caching the Subdetector is an ugly hack.  --JM
-     */    
+     */
     protected LayeredSubdetector detector;
     
-    SegmentationBase(Element e)        
-    {        
-        super(e);        
+    SegmentationBase(Element e)
+    {
+        super(e);
     }
     
     public CoordinateSystemType getCoordinateSystemType()
@@ -47,98 +52,108 @@
     }
     
     abstract public double getX();
-      
+    
     abstract public double getY();
-        
-    abstract public double getZ();    
-            
+    
+    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. */
+    abstract public long[] getNeighbourIDs(int deltaLayer, int deltaTheta, int deltaPhi);           
+    
+    /** 
+     * Override but make sure to call this super method. 
+     *
+     * FIXME: Above way is clunky and easy to forget...
+     */
     public void setIDDescription(IDDescriptor id)
-    {        
+    {
         decoder = new IDDecoder(id);
-        encoder = new IDEncoder(id);        
+        encoder = new IDEncoder(id);
         values = new int[id.fieldCount()];
         
         /** FIXME: Doesn't seem to belong here. */
-        layerIndex = id.indexOf("layer");            
+        layerIndex = id.indexOf("layer");
     }
     
-    /** 
-     * Next set of methods should probably not need to be 
+    /**
+     * Next set of methods should probably not need to be
      * overridden but will leave as non-final (for now).
-     */                            
-    public void setSubdetector(Subdetector det)
+     */
+    public void setSubdetector(LayeredSubdetector det)
     {
-      detector = (LayeredSubdetector) det;
+        detector = (LayeredSubdetector) det;
     }
     
-    /** 
-     * FIXME: Should be renamed as it is actually returning the distance to the midpoint of the sensitive layer. 
+    /**
+     * 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);
-    }        
+        return detector.getDistanceToLayerSensorMid(layer);
+    }
     
-    public double computeCylindricalRadiusFromPosition()
-    {        
+    public double getCylindricalRadiusFromPosition()
+    {
         return sqrt(getX() * getX() + getY() * getY() );
     }
     
     public int getIndex(String field)
-    {
-      return decoder.getValue(field);
+    {        
+        return decoder.getValue(field);
     }
-
+    
     public int getValue(int index)
     {
-      return decoder.getValue(index);
+        return decoder.getValue(index);
     }
-
+    
     public String getFieldName(int index)
     {
-      return decoder.getFieldName(index);
+        return decoder.getFieldName(index);
     }
-
+    
     public int getFieldCount()
     {
-       return values.length;
+        return values.length;
     }
-   
+    
     public String toString()
     {
-       return decoder == null ? "NoDecoder" : decoder.toString();
-    }                     
+        return decoder == null ? "NoDecoder" : decoder.toString();
+    }
     
     public void setID(long id)
-    {
-       decoder.setID(id);
-       decoder.getValues(values);
-    }  
+    {        
+        decoder.setID(id);
+        decoder.getValues(values);
+    }
     
     public double[] getPosition()
     {
         return new double[] { getX(), getY(), getZ() };
     }
     
+    /** FIXME: Probably doesn't belong here. */
+    public double[] transformLocalToGlobal(double[] localPos)
+    {
+        return ((org.lcsim.geometry.Subdetector)detector).transformLocalToGlobal(localPos);
+    }
+    
     public int getLayer()
     {
         return values[layerIndex];
     }
-   
+    
     public boolean supportsNeighbours()
     {
         return false;
     }
-        
+    
     public long[] getNeighbourIDs()
     {
         return getNeighbourIDs(1,1,1);
-    }   
-}
+    }
+}
\ No newline at end of file
CVSspam 0.2.8