Commit in GeomConverter/src/org/lcsim/geometry on MAIN
compact/converter/pandora/Main.java+6-61.3 -> 1.4
segmentation/AbstractCartesianGrid.java+59-411.7 -> 1.8
            /CartesianGridXY.java+12-121.8 -> 1.9
            /CartesianGridXZ.java+12-121.5 -> 1.6
            /GlobalGridXY.java+15-61.2 -> 1.3
+104-77
5 modified files


GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
Main.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- Main.java	18 Dec 2009 22:24:56 -0000	1.3
+++ Main.java	28 Jan 2010 19:46:36 -0000	1.4
@@ -185,17 +185,17 @@
         if (dec instanceof AbstractCartesianGrid)
         {
             AbstractCartesianGrid cgrid = (AbstractCartesianGrid)dec;
-            if (cgrid.getCellSizeX() != 0)
+            if (cgrid.getGridSizeX() != 0)
             {
-                cellSizes.add(cgrid.getCellSizeX());
+                cellSizes.add(cgrid.getGridSizeX());
             }
-            if (cgrid.getCellSizeY() != 0)
+            if (cgrid.getGridSizeY() != 0)
             {
-                cellSizes.add(cgrid.getCellSizeY());
+                cellSizes.add(cgrid.getGridSizeY());
             }
-            if (cgrid.getCellSizeZ() != 0)
+            if (cgrid.getGridSizeZ() != 0)
             {
-                cellSizes.add(cgrid.getCellSizeZ());
+                cellSizes.add(cgrid.getGridSizeZ());
             }           
         }
         if (cellSizes.size() != 2)

GeomConverter/src/org/lcsim/geometry/segmentation
AbstractCartesianGrid.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- AbstractCartesianGrid.java	18 Dec 2009 22:44:22 -0000	1.7
+++ AbstractCartesianGrid.java	28 Jan 2010 19:46:36 -0000	1.8
@@ -11,32 +11,40 @@
 import org.lcsim.detector.identifier.ExpandedIdentifier;
 import org.lcsim.detector.identifier.IExpandedIdentifier;
 import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.identifier.Identifier;
-import org.lcsim.geometry.util.IDDescriptor;
 import org.lcsim.geometry.util.BaseIDDecoder;
+import org.lcsim.geometry.util.IDDescriptor;
 import org.lcsim.geometry.util.IDEncoder;
 
 /**
- * Abstract base class for Cartesian grid segmentation types.
- * This class computes positions in 3D space but only allows
- * for two id fields that correspond to dimensions.  The 
- * detailed Java geometry is used to generically transform
- * 2D coordinates into 3D points in the detector.
+ * This is the abstract base class for Cartesian grid segmentation types.
+ * It can compute positions in 3D space but only allows two fields that 
+ * correspond to dimensions.  The other field is the layer.  The detailed 
+ * Java geometry system is used to transform 2D coordinates into 3D points 
+ * within the detector.
  * 
  * @author jeremym
  */
 public abstract class AbstractCartesianGrid extends SegmentationBase 
 {				
+    // Cached local position array.
 	double[] localPosition = {0, 0, 0};
-	double[] globalPosition = {0, 0, 0};	
+	
+	// Cached global position array.
+	double[] globalPosition = {0, 0, 0};
+	
+	// Flag if positions need to be recomputed.	
 	boolean needsCompute = true;
+	
+	// Geometry field indices.
 	List<Integer> geomFields;
-	double cellSizeX, cellSizeY, cellSizeZ;
+	
+	// The grid cell sizes.  (Can be zero.)
+	double gridSizeX, gridSizeY, gridSizeZ;
 	
 	/**
-	 * Sub-types will set their grid values from the XML element.
-	 * This constructor basically does nothing.
+	 * This constructor does nothing.  Sub-types will set their 
+	 * grid values from the XML element. 
 	 * 
 	 * @param segmentation The XML element for the segmentation.
 	 */
@@ -49,37 +57,36 @@
 	 * Using the current ID, compute the local position in the readout volume
 	 * and set the <code>localPosition</code> array.
 	 */
-	protected void computeLocalPosition()
-	{}
+	abstract protected void computeLocalPosition();
 	
 	/**
 	 * Make a list of fields that are geometric by stripping out this segmentation's
 	 * fields from the given <code>IDDescriptor</code>.
+	 * 
 	 * @param id The description of the Id.
 	 */
-	protected void setupGeomFields(IDDescriptor id)
-	{}
+	abstract protected void setupGeomFields(IDDescriptor id);
 	
 	/**
-	 * Check if the id is valid.  It must be in bounds of the readout volume it points to.
+	 * Check if the id is valid.  It must be in bounds of the corresponding readout volume.
+	 * 
 	 * @param rawId
 	 * @return True if id is valid for this segmentation type; False if not.
 	 */
-	public boolean boundsCheck(long rawId)
-	{
-	    return false;
-	}
+	abstract public boolean boundsCheck(long rawId);
 	
 	/**
-	 * Set the segmentation field values on the given <code>IExpandedIdentifier</code>.
+	 * Set the segmentation field values on the given <code>IExpandedIdentifier</code>
+	 * given a local hit position.
+	 * 
 	 * @param geomId The expanded id.
 	 * @param localPositionVec The local position of the hit.
 	 */
-	protected void setSegmentationValues(IExpandedIdentifier geomId, Hep3Vector localPositionVec)
-	{}
+	abstract protected void setSegmentationValues(IExpandedIdentifier geomId, Hep3Vector localPositionVec);
 	
 	/**
-	 * Compute the integer bin given a coordinate value and a grid size.
+	 * Compute the integer bin value given a coordinate and a grid size.
+	 * 
 	 * @param u The coordinate value.
 	 * @param gridSize The grid size.
 	 * @return The bin value.
@@ -92,7 +99,8 @@
 	}
 	
 	/**
-	 * Compute the coordinate value given a bin. 
+	 * Compute the coordinate given a bin value.
+	 *  
 	 * @param binValue The bin value.
 	 * @param gridSize The grid size.
 	 * @return The coordinate value.
@@ -103,7 +111,8 @@
 	}
 	
 	/**
-	 * Generic computation of hit's global position.  Sets the <code>globalPosition</code> array.
+	 * Generic computation of hit's global position.  
+	 * Sets the <code>globalPosition</code> array.
 	 */
 	protected void computeGlobalPosition()
 	{											
@@ -114,19 +123,19 @@
 		// Search for the the DetectorElement associated with the geometry id.
 		List<IDetectorElement> deSearch = detector.getDetectorElement().findDetectorElement(geomId);
 
-		// Check if the lookup failed.
+		// Check if the DetectorElement lookup failed.
 		if (deSearch == null || deSearch.size() == 0)
 		{
 			throw new RuntimeException("Failed to find DetectorElement with geometry id <" + geomIdExp.toString() + "> !");
 		}
 
-		// Set the DetectorElement to use for local to global transform.
+		// Set the DetectorElement to use for the local to global transform.
 		IDetectorElement sensor = deSearch.get(0);
 		
-		// Create a vector of the local position.		
+		// Create a vector from the local position array.
 		Hep3Vector posVecLocal = new BasicHep3Vector(localPosition[0], localPosition[1], localPosition[2]);		
 		
-		// Compute the global position of the hit using the DetectorElement.
+		// Compute the global position of the hit using the local position and the DetectorElement.
 		Hep3Vector posVecGlobal = sensor.getGeometry().transformLocalToGlobal(posVecLocal);
 
 		// Set the internal global position array.
@@ -136,7 +145,8 @@
 	}
 		
 	/**
-	 * Find the readout cell given a global position in the 3D detector space.
+	 * Find the readout cell given a global position.
+	 * 
 	 * @return The cell id for the position.
 	 */
 	public long findCellContainingXYZ(double x, double y, double z) 
@@ -158,6 +168,7 @@
 	
 	/**
 	 * Get the position from the current cell ID.  Recomputes the position if necessary.
+	 * 
 	 * @return The position of the current cell.
 	 */
 	public final double[] getPosition()
@@ -181,6 +192,7 @@
 	
 	/**
 	 * Create an id with geometry fields only given an id including geometry and segmentation fields.
+	 * 
 	 * @param id The cell id.
 	 * @return A cell id with values for geometry fields only.
 	 */
@@ -191,8 +203,9 @@
 	}
 	
 	/**
-	 * We override this method to flag the decoder as dirty so that internal position data is 
-	 * recomputed next time a position is retrieved by the user.
+	 * This method is overridden in order to flag the decoder as dirty 
+	 * so that internal position data can be recomputed the next time a position 
+	 * is retrieved by the user.
 	 */
 	public final void setID(long id)
 	{
@@ -211,6 +224,7 @@
 	
 	/**
 	 * All implementations must support neighbor finding.
+	 * 
 	 * @return True.
 	 */
 	public final boolean supportsNeighbours()
@@ -220,6 +234,7 @@
 	
 	/**
 	 * Get the X coordinate.
+	 * 
 	 * @return The X coordinate.
 	 */
 	public final double getX()
@@ -229,6 +244,7 @@
 	
 	/**
 	 * Get the Y coordinate.
+	 * 
 	 * @return The Y coordinate.
 	 */
 	public final double getY()
@@ -238,7 +254,8 @@
 	
 	/**
 	 * Get the Z coordinate.
-	 * @return The Z coordinate.
+	 * 
+	 * @return The Z coordinate.	 
 	 */
 	public final double getZ()
 	{
@@ -246,7 +263,8 @@
 	}
 	
 	/**
-	 * Utility method for finding neighbors in layer and 2D segmentation grid.
+	 * Utility method for finding neighbors in a 2D readout grid with layers.
+	 * 
 	 * @param layerRange The layer range.
 	 * @param uRange The u range.
 	 * @param vRange The v range.
@@ -316,18 +334,18 @@
 		return result;
 	}	
 	
-	public double getCellSizeX()
+	public double getGridSizeX()
 	{
-	    return cellSizeX;
+	    return gridSizeX;
 	}
 	
-	public double getCellSizeY()
+	public double getGridSizeY()
 	{
-	    return cellSizeY;
+	    return gridSizeY;
 	}
 	
-	public double getCellSizeZ()
+	public double getGridSizeZ()
 	{
-	    return cellSizeZ;
+	    return gridSizeZ;
 	}
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/segmentation
CartesianGridXY.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- CartesianGridXY.java	18 Dec 2009 22:24:56 -0000	1.8
+++ CartesianGridXY.java	28 Jan 2010 19:46:36 -0000	1.9
@@ -33,7 +33,7 @@
 
 		if (node.getAttribute("gridSizeX") != null)
 		{
-			cellSizeX = node.getAttribute("gridSizeX").getDoubleValue();
+			gridSizeX = node.getAttribute("gridSizeX").getDoubleValue();
 		}
 		else
 		{
@@ -42,7 +42,7 @@
 
 		if (node.getAttribute("gridSizeY") != null)
 		{
-			cellSizeY = node.getAttribute("gridSizeY").getDoubleValue();
+			gridSizeY = node.getAttribute("gridSizeY").getDoubleValue();
 		}
 		else
 		{
@@ -50,14 +50,14 @@
 		}
 	}
 	
-	public double getCellSizeX()
+	public double getGridSizeX()
 	{
-	    return cellSizeX;
+	    return gridSizeX;
 	}
 	
-	public double getCellSizeY()
+	public double getGridSizeY()
 	{
-	    return cellSizeY;
+	    return gridSizeY;
 	}
 	
 	public long[] getNeighbourIDs(int layerRange, int xRange, int yRange)
@@ -73,12 +73,12 @@
 	
 	public int getXBin(double x)
 	{
-		return getBin(x, cellSizeX);
+		return getBin(x, gridSizeX);
 	}
 
 	public int getYBin(double y)
 	{
-		return getBin(y, cellSizeY);
+		return getBin(y, gridSizeY);
 	}
 	
 	public boolean boundsCheck(long rawId)
@@ -94,8 +94,8 @@
 			return false;
 		}
 		IDetectorElement de = deSrch.get(0);
-		double xPos = computeCoordinate(xVal, cellSizeX);
-		double yPos = computeCoordinate(yVal, cellSizeY);
+		double xPos = computeCoordinate(xVal, gridSizeX);
+		double yPos = computeCoordinate(yVal, gridSizeY);
 		if (de.getGeometry().getLogicalVolume().getSolid() instanceof Box)
 		{			
 			Box sensorBox = (Box)de.getGeometry().getLogicalVolume().getSolid();
@@ -140,12 +140,12 @@
 		
 	private void computeLocalX()
 	{	
-		localPosition[0] = (((double) getValue(xIndex)) + 0.5) * cellSizeX;	
+		localPosition[0] = (((double) getValue(xIndex)) + 0.5) * gridSizeX;	
 	}
 
 	private void computeLocalY()
 	{
-		localPosition[1] = (((double) getValue(yIndex)) + 0.5) * cellSizeY;
+		localPosition[1] = (((double) getValue(yIndex)) + 0.5) * gridSizeY;
 	}
 	
 	protected void computeLocalPosition()

GeomConverter/src/org/lcsim/geometry/segmentation
CartesianGridXZ.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- CartesianGridXZ.java	18 Dec 2009 22:24:56 -0000	1.5
+++ CartesianGridXZ.java	28 Jan 2010 19:46:36 -0000	1.6
@@ -31,22 +31,22 @@
 	{
 		super(node);
 
-		if (node.getAttribute("cellSizeX") != null)
+		if (node.getAttribute("gridSizeX") != null)
 		{
-			cellSizeX = node.getAttribute("cellSizeX").getDoubleValue();
+			gridSizeX = node.getAttribute("gridSizeX").getDoubleValue();
 		}
 		else
 		{
-			throw new RuntimeException("Missing cellSizeX parameter.");
+			throw new RuntimeException("Missing gridSizeX parameter.");
 		}
 
-		if (node.getAttribute("cellSizeZ") != null)
+		if (node.getAttribute("gridSizeZ") != null)
 		{
-			cellSizeZ = node.getAttribute("cellSizeZ").getDoubleValue();
+			gridSizeZ = node.getAttribute("gridSizeZ").getDoubleValue();
 		}
 		else
 		{
-			throw new RuntimeException("Missing cellSizeZ parameter.");
+			throw new RuntimeException("Missing gridSizeZ parameter.");
 		}
 	}
 
@@ -63,12 +63,12 @@
 
 	public int getXBin(double x)
 	{
-		return getBin(x, cellSizeX);
+		return getBin(x, gridSizeX);
 	}
 
 	public int getZBin(double z)
 	{
-		return getBin(z, cellSizeZ);
+		return getBin(z, gridSizeZ);
 	}
 			
 	public boolean boundsCheck(long rawId)
@@ -84,8 +84,8 @@
 			return false;
 		}
 		IDetectorElement de = deSrch.get(0);
-		double xPos = computeCoordinate(xVal, cellSizeX);
-		double zPos = computeCoordinate(zVal, cellSizeZ);
+		double xPos = computeCoordinate(xVal, gridSizeX);
+		double zPos = computeCoordinate(zVal, gridSizeZ);
 		if (de.getGeometry().getLogicalVolume().getSolid() instanceof Trd)
 		{
 			Trd sensorTrd = (Trd)de.getGeometry().getLogicalVolume().getSolid();
@@ -130,12 +130,12 @@
 		
 	private void computeLocalX()
 	{	
-		localPosition[0] = (((double) getValue(xIndex)) + 0.5) * cellSizeX;	
+		localPosition[0] = (((double) getValue(xIndex)) + 0.5) * gridSizeX;	
 	}
 
 	private void computeLocalZ()
 	{
-		localPosition[2] = (((double) getValue(zIndex)) + 0.5) * cellSizeZ;
+		localPosition[2] = (((double) getValue(zIndex)) + 0.5) * gridSizeZ;
 	}
 	
 	protected void computeLocalPosition()

GeomConverter/src/org/lcsim/geometry/segmentation
GlobalGridXY.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- GlobalGridXY.java	18 Dec 2009 22:24:56 -0000	1.2
+++ GlobalGridXY.java	28 Jan 2010 19:46:36 -0000	1.3
@@ -31,7 +31,7 @@
 
         if (node.getAttribute("gridSizeX") != null)
         {
-            cellSizeX = node.getAttribute("gridSizeX").getDoubleValue();
+            gridSizeX = node.getAttribute("gridSizeX").getDoubleValue();
         }
         else
         {
@@ -40,7 +40,7 @@
 
         if (node.getAttribute("gridSizeY") != null)
         {
-            cellSizeY = node.getAttribute("gridSizeY").getDoubleValue();
+            gridSizeY = node.getAttribute("gridSizeY").getDoubleValue();
         }
         else
         {
@@ -90,22 +90,22 @@
      
     public int getXBin(double x)
     {
-        return getBin(x, cellSizeX);
+        return getBin(x, gridSizeX);
     }
 
     public int getYBin(double y)
     {
-        return getBin(y, cellSizeY);
+        return getBin(y, gridSizeY);
     }
                               
     private void computeGlobalX()
     {   
-        globalPosition[0] = (((double) getValue(xIndex)) + 0.5) * cellSizeX; 
+        globalPosition[0] = (((double) getValue(xIndex)) + 0.5) * gridSizeX; 
     }
 
     private void computeGlobalY()
     {
-        globalPosition[1] = (((double) getValue(yIndex)) + 0.5) * cellSizeY;
+        globalPosition[1] = (((double) getValue(yIndex)) + 0.5) * gridSizeY;
     }      
     
     private void computeGlobalZ()
@@ -145,4 +145,13 @@
             
         return getSubdetector().getDetectorElement().getIdentifierHelper().pack(geomId).getValue();
     }    
+    
+    // TODO: Implement this method.
+    public boolean boundsCheck(long rawId)
+    {
+        return false;
+    }
+    
+    protected void computeLocalPosition()
+    {}
 }
\ No newline at end of file
CVSspam 0.2.8