Print

Print


Commit in GeomConverter/sandbox/solids on MAIN
Box.java+66added 1.1
ISolid.java+34added 1.1
Trapezoid.java+80added 1.1
TubeSegment.java+85added 1.1
+265
4 added files
JM: sandbox

GeomConverter/sandbox/solids
Box.java added at 1.1
diff -N Box.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Box.java	28 Feb 2007 19:49:30 -0000	1.1
@@ -0,0 +1,66 @@
+/*
+ * Box.java
+ *
+ * Created on October 6, 2006, 4:41 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.subdetector.tracker.silicon;
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class Box implements ISolid
+{
+    
+    // Fields
+    //=======
+    private double _dimensions[] = new double[3];
+
+    /** Creates a new instance of Box */
+    public Box(Element box)
+    {
+        buildFromXML(box);
+    }
+    
+    // Public methods
+    //===============
+    public double[] getDimensions()
+    {
+        return _dimensions;
+    }
+    
+    public double getVolume()
+    {
+        return _dimensions[0]*_dimensions[1]*_dimensions[2];
+    }
+    
+    public boolean isInside(Hep3Vector point)
+    {
+        return ( Math.abs(point.x()) < _dimensions[0]/2.0 &&
+                 Math.abs(point.y()) < _dimensions[1]/2.0 &&
+                 Math.abs(point.z()) < _dimensions[2]/2.0 );
+    }
+    
+    public void buildFromXML(Element box)
+    {
+        try
+        {
+            _dimensions[0] = box.getAttribute("x_size").getDoubleValue();
+            _dimensions[1] = box.getAttribute("y_size").getDoubleValue();
+            _dimensions[2] = box.getAttribute("z_size").getDoubleValue();
+        }
+        catch (DataConversionException dce)
+        {
+            System.out.println("Cannot convert Box dimensions to double!");
+        }   
+    }
+        
+}

GeomConverter/sandbox/solids
ISolid.java added at 1.1
diff -N ISolid.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ISolid.java	28 Feb 2007 19:49:30 -0000	1.1
@@ -0,0 +1,34 @@
+/*
+ * ISolid.java
+ *
+ * Created on October 9, 2006, 3:44 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.detector;
+
+//import hep.physics.vec.Hep3Vector;
+//import org.jdom.Element;
+//import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public interface ISolid
+{
+    
+    // Return dimensions
+    public double[] getDimensions();
+    
+    // Calculate volume
+    public double getVolume();
+    
+    // Is a particular point inside?
+    public boolean isInside(IPosition point);
+    
+    // Must be buildable from xml
+    //public void buildFromXML(Element solid); 
+}

GeomConverter/sandbox/solids
Trapezoid.java added at 1.1
diff -N Trapezoid.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Trapezoid.java	28 Feb 2007 19:49:30 -0000	1.1
@@ -0,0 +1,80 @@
+/*
+ * Trapezoid.java
+ *
+ * Created on October 6, 2006, 4:41 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.subdetector.tracker.silicon;
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class Trapezoid implements ISolid
+{
+    
+    // Fields
+    //=======
+    private double _dimensions[] = new double[4];
+
+    /** Creates a new instance of Box */
+    public Trapezoid(double[] dimensions)
+    {
+        _dimensions = dimensions;
+    }
+    
+    public Trapezoid(double x1, double x2, double y, double z)
+    {
+        _dimensions[0] = x1;
+        _dimensions[1] = x2;
+        _dimensions[2] = y;
+        _dimensions[3] = z;
+    }
+    
+    // Public methods
+    //===============
+    public double[] getDimensions()
+    {
+        return _dimensions;
+    }
+    
+    public double getVolume()
+    {
+        return (_dimensions[0]+_dimensions[1])/2.0 * _dimensions[2] * _dimensions[3];
+    }
+    
+    public boolean isInside(Hep3Vector point)
+    {
+        double inverse_slope = (_dimensions[1]-_dimensions[0])/(2.0*_dimensions[2]);
+        double x_intercept = (_dimensions[0]+_dimensions[1]/4.0);
+   
+        double x_limit = inverse_slope*point.y()+x_intercept;
+        
+        return ( Math.abs(point.x()) < x_limit &&
+                 Math.abs(point.y()) < _dimensions[2]/2.0 &&
+                 Math.abs(point.z()) < _dimensions[3]/2.0 );
+    }
+    
+    public void buildFromXML(Element trapezoid)
+    {
+        try
+        {
+            _dimensions[0] = trapezoid.getAttribute("size_x1").getDoubleValue();
+            _dimensions[1] = trapezoid.getAttribute("size_x2").getDoubleValue();
+            _dimensions[2] = trapezoid.getAttribute("size_y").getDoubleValue();
+            _dimensions[3] = trapezoid.getAttribute("size_z").getDoubleValue();
+        }
+        catch (DataConversionException dce)
+        {
+            System.out.println("Cannot convert Trapezoid dimensions to double!");
+        }
+    }
+    
+}

GeomConverter/sandbox/solids
TubeSegment.java added at 1.1
diff -N TubeSegment.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TubeSegment.java	28 Feb 2007 19:49:30 -0000	1.1
@@ -0,0 +1,85 @@
+/*
+ * TubeSegment.java
+ *
+ * Created on November 3, 2006, 2:41 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.subdetector.tracker.silicon;
+
+import hep.physics.vec.Hep3Vector;
+import org.jdom.Element;
+import org.jdom.DataConversionException;
+
+/**
+ *
+ * @author tknelson
+ */
+public class TubeSegment implements ISolid
+{
+     
+    // Fields
+    //=======
+    private double _dimensions[] = new double[3];
+
+    /** Creates a new instance of Box */
+    public TubeSegment(Element tubesegment)
+    {
+        buildFromXML(tubesegment);
+    }
+    
+    // Accessors
+    //==========
+    public double getInnerRadius()
+    {
+        return _dimensions[0];
+    }
+    
+    public double getOuterRadius()
+    {
+        return _dimensions[1];
+    }
+    
+    public double getZLength()
+    {
+        return _dimensions[2];
+    }
+    
+    // Implementation of ISolid
+    //=========================
+    public double[] getDimensions()
+    {
+        return _dimensions;
+    }
+    
+    public double getVolume()
+    {
+        return Math.PI*(_dimensions[1]*_dimensions[1] - _dimensions[0]*_dimensions[0])*_dimensions[2];
+    }
+    
+    public boolean isInside(Hep3Vector point)
+    {
+        double r_xy = Math.sqrt(point.x()*point.x() + point.y()*point.y());
+
+        return ( r_xy > _dimensions[0] &&
+                 r_xy < _dimensions[1] &&
+                 Math.abs(point.z()) < _dimensions[2]/2.0 );
+    }
+    
+    public void buildFromXML(Element tubesegment)
+    {
+        try
+        {
+            _dimensions[0] = tubesegment.getAttribute("r_inner").getDoubleValue();
+            _dimensions[1] = tubesegment.getAttribute("r_outer").getDoubleValue();
+            _dimensions[2] = tubesegment.getAttribute("z_length").getDoubleValue();
+        }
+        catch (DataConversionException dce)
+        {
+            System.out.println("Cannot convert TubeSegment dimensions to double!");
+        }
+    }
+    
+}
CVSspam 0.2.8