Commit in GeomConverter on MAIN
resources/org/lcsim/schemas/lcdd/1.0/lcdd_fields.xsd+199-1691.1 -> 1.2
src/org/lcsim/geometry/compact/converter/lcdd/BoxDipole.java+43added 1.1
src/org/lcsim/geometry/compact/converter/lcdd/util/BoxDipole.java+35added 1.1
src/org/lcsim/geometry/field/BoxDipole.java+57added 1.1
test/org/lcsim/geometry/field/BoxDipoleTest.java+68added 1.1
testResources/org/lcsim/geometry/field/BoxDipoleTest.xml+61added 1.1
+463-169
5 added + 1 modified, total 6 files
add BoxDipole binding for compact2lcdd and compact description

GeomConverter/resources/org/lcsim/schemas/lcdd/1.0
lcdd_fields.xsd 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- lcdd_fields.xsd	14 Dec 2007 21:46:32 -0000	1.1
+++ lcdd_fields.xsd	24 Jun 2011 22:17:13 -0000	1.2
@@ -7,173 +7,203 @@
 	   xmlns:lcdd="http://www.lcsim.org/schemas/lcdd/1.0/"
 	   xmlns:xs="http://www.w3.org/2001/XMLSchema">
 
-  <xs:complexType name="FieldsType">
-    <xs:annotation>
-      <xs:documentation>
-      </xs:documentation>
-    </xs:annotation>
-    <xs:sequence>
-      <xs:element minOccurs="0" maxOccurs="unbounded" ref="field" />
-      <xs:element name="global_field" minOccurs="0" maxOccurs="1" type="GlobalFieldType" />
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="fields" type="FieldsType">
-  </xs:element>
-
-  <xs:complexType name="GlobalFieldType">
-    <xs:annotation>
-      <xs:documentation>
-      </xs:documentation>
-    </xs:annotation>
-    <xs:sequence>
-      <xs:element name="fieldref" minOccurs="1" maxOccurs="unbounded" type="ReferenceType" />
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:complexType name="FieldType">
-    <xs:attribute name="name" type="xs:ID"/>
-    <xs:attribute default="tesla" name="funit" type="xs:string"/>
-    <xs:attribute default="mm" name="lunit" type="xs:string" />
-  </xs:complexType>
-
-  <xs:element name="field" type="FieldType">
-  </xs:element>
-
-  <xs:complexType name="SolenoidType">
-    <xs:annotation>
-      <xs:documentation>
-	Solenoid with z min/max, radius min/max, strength
-	and units.  lunit is for z and radius (mm). funit is
-	the unit for the field strength (Tesla).
-      </xs:documentation>
-    </xs:annotation>
-    <xs:complexContent>
-      <xs:extension base="FieldType">
-	<xs:attribute name="inner_field" type="xs:string" />
-	<xs:attribute name="outer_field" type="xs:string" />
-	<xs:attribute name="zmin" type="xs:string" />
-	<xs:attribute name="zmax" type="xs:string" />
-	<xs:attribute name="inner_radius" type="xs:string" />
-	<xs:attribute name="outer_radius" type="xs:string" />
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:element name="solenoid" substitutionGroup="field" type="SolenoidType">
-    <xs:annotation>
-      <xs:documentation>
-	Solenoidal field element
-      </xs:documentation>
-    </xs:annotation>
-  </xs:element>
-
-  <xs:complexType name="DipoleType">
-   <xs:annotation>
-      <xs:documentation>
-	Dipole field using simple polynomial fit with a variable number of coefficients.
-      </xs:documentation>
-    </xs:annotation>
-    <xs:complexContent>
-      <xs:extension base="FieldType">
-	<xs:sequence>
-	  <xs:element name="dipole_coeff" minOccurs="1" maxOccurs="unbounded">
-	    <xs:complexType>
-	      <xs:attribute name="value" type="xs:double" use="required"/>
-	    </xs:complexType>
-	  </xs:element>
-	</xs:sequence>
-	<xs:attribute name="zmin" type="xs:double" />
-	<xs:attribute name="zmax" type="xs:double" />
-	<xs:attribute name="rmax" type="xs:double" />
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:element name="dipole" substitutionGroup="field" type="DipoleType">
-    <xs:annotation>
-      <xs:documentation>
-	Dipole field element.
-      </xs:documentation>
-    </xs:annotation>
-  </xs:element>
-
-  <xs:complexType name="FieldMapType">
-    <xs:annotation>
-      <xs:documentation>
-      </xs:documentation>
-    </xs:annotation>
-    <xs:complexContent>
-      <xs:extension base="FieldType">
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="RZBType">
-    <xs:annotation>
-      <xs:documentation>
-      </xs:documentation>
-    </xs:annotation>
-    <xs:attribute name="r" type="xs:double"/>
-    <xs:attribute name="z" type="xs:double"/>
-    <xs:attribute name="Br" type="xs:double"/>
-    <xs:attribute name="Bz" type="xs:double"/>
-  </xs:complexType>
-
-  <xs:complexType name="RZFieldMapType">
-    <xs:annotation>
-      <xs:documentation>
-      </xs:documentation>
-    </xs:annotation>
-    <xs:complexContent>
-      <xs:extension base="FieldMapType">
-
-	<xs:sequence>
-	  <xs:element name="rzB" type="RZBType" minOccurs="2" maxOccurs="unbounded" />
-	</xs:sequence>
-
-	<xs:attribute name="num_bins_r">
-	  <xs:simpleType>
-	    <xs:restriction base="xs:integer">
-	      <xs:minInclusive value="2"/>
-	    </xs:restriction>
-	  </xs:simpleType>
-	</xs:attribute>
-
-	<xs:attribute name="num_bins_z">
-	  <xs:simpleType>
-	    <xs:restriction base="xs:integer">
-	      <xs:minInclusive value="2"/>
-	    </xs:restriction>
-	  </xs:simpleType>
-	</xs:attribute>
-
-	<xs:attribute name="grid_size_r">
-	  <xs:simpleType>
-	    <xs:restriction base="xs:double">
-	      <xs:minExclusive value="0"/>
-	    </xs:restriction>
-	  </xs:simpleType>
-	</xs:attribute>
-
-	<xs:attribute name="grid_size_z">
-	  <xs:simpleType>
-	    <xs:restriction base="xs:double">
-	      <xs:minExclusive value="0"/>
-	    </xs:restriction>
-	  </xs:simpleType>
-	</xs:attribute>
-
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:element name="rz_field_map" substitutionGroup="field" type="RZFieldMapType">
-    <xs:annotation>
-      <xs:documentation>
-	An RZ field map element.
-      </xs:documentation>
-    </xs:annotation>
-  </xs:element>
-
+    <xs:complexType name="FieldsType">
+        <xs:annotation>
+            <xs:documentation>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:sequence>
+            <xs:element minOccurs="0" maxOccurs="unbounded" ref="field" />
+            <xs:element name="global_field" minOccurs="0" maxOccurs="1" type="GlobalFieldType" />
+        </xs:sequence>
+    </xs:complexType>
+    
+    <xs:element name="fields" type="FieldsType">
+    </xs:element>
+    
+    <xs:complexType name="GlobalFieldType">
+        <xs:annotation>
+            <xs:documentation>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:sequence>
+            <xs:element name="fieldref" minOccurs="1" maxOccurs="unbounded" type="ReferenceType" />
+        </xs:sequence>
+    </xs:complexType>
+    
+    <xs:complexType name="FieldType">
+        <xs:attribute name="name" type="xs:ID"/>
+        <xs:attribute default="tesla" name="funit" type="xs:string"/>
+        <xs:attribute default="mm" name="lunit" type="xs:string" />
+    </xs:complexType>
+    
+    <xs:element name="field" type="FieldType">
+    </xs:element>
+    
+    <xs:complexType name="SolenoidType">
+        <xs:annotation>
+            <xs:documentation>
+                Solenoid with z min/max, radius min/max, strength
+                and units.  lunit is for z and radius (mm). funit is
+                the unit for the field strength (Tesla).
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FieldType">
+                <xs:attribute name="inner_field" type="xs:string" />
+                <xs:attribute name="outer_field" type="xs:string" />
+                <xs:attribute name="zmin" type="xs:string" />
+                <xs:attribute name="zmax" type="xs:string" />
+                <xs:attribute name="inner_radius" type="xs:string" />
+                <xs:attribute name="outer_radius" type="xs:string" />
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+    
+    <xs:element name="solenoid" substitutionGroup="field" type="SolenoidType">
+        <xs:annotation>
+            <xs:documentation>
+                Solenoidal field element
+            </xs:documentation>
+        </xs:annotation>
+    </xs:element>
+    
+    <xs:complexType name="DipoleType">
+        <xs:annotation>
+            <xs:documentation>
+                Dipole field using simple polynomial fit with a variable number of coefficients.
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FieldType">
+                <xs:sequence>
+                    <xs:element name="dipole_coeff" minOccurs="1" maxOccurs="unbounded">
+                        <xs:complexType>
+                            <xs:attribute name="value" type="xs:double" use="required"/>
+                        </xs:complexType>
+                    </xs:element>
+                </xs:sequence>
+                <xs:attribute name="zmin" type="xs:double" />
+                <xs:attribute name="zmax" type="xs:double" />
+                <xs:attribute name="rmax" type="xs:double" />
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+    
+    <xs:element name="dipole" substitutionGroup="field" type="DipoleType">
+        <xs:annotation>
+            <xs:documentation>
+                Dipole field element.
+            </xs:documentation>
+        </xs:annotation>
+    </xs:element>
+    
+    <xs:complexType name="FieldMapType">
+        <xs:annotation>
+            <xs:documentation>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FieldType">
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+    
+    <xs:complexType name="RZBType">
+        <xs:annotation>
+            <xs:documentation>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:attribute name="r" type="xs:double"/>
+        <xs:attribute name="z" type="xs:double"/>
+        <xs:attribute name="Br" type="xs:double"/>
+        <xs:attribute name="Bz" type="xs:double"/>
+    </xs:complexType>
+
+    <xs:complexType name="RZFieldMapType">
+        <xs:annotation>
+            <xs:documentation>
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FieldMapType">
+
+                <xs:sequence>
+                    <xs:element name="rzB" type="RZBType" minOccurs="2" maxOccurs="unbounded" />
+                </xs:sequence>
+                
+                <xs:attribute name="num_bins_r">
+                    <xs:simpleType>
+                        <xs:restriction base="xs:integer">
+                            <xs:minInclusive value="2"/>
+                        </xs:restriction>
+                    </xs:simpleType>
+                </xs:attribute>
+                
+                <xs:attribute name="num_bins_z">
+                    <xs:simpleType>
+                        <xs:restriction base="xs:integer">
+                            <xs:minInclusive value="2"/>
+                        </xs:restriction>
+                    </xs:simpleType>
+                </xs:attribute>
+                
+                <xs:attribute name="grid_size_r">
+                    <xs:simpleType>
+                        <xs:restriction base="xs:double">
+                            <xs:minExclusive value="0"/>
+                        </xs:restriction>
+                    </xs:simpleType>
+                </xs:attribute>
+                
+                <xs:attribute name="grid_size_z">
+                    <xs:simpleType>
+                        <xs:restriction base="xs:double">
+                            <xs:minExclusive value="0"/>
+                        </xs:restriction>
+                    </xs:simpleType>
+                </xs:attribute>
+                
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+    
+    <xs:element name="rz_field_map" substitutionGroup="field" type="RZFieldMapType">
+        <xs:annotation>
+            <xs:documentation>
+                An RZ field map element.
+            </xs:documentation>
+        </xs:annotation>
+    </xs:element>
+
+
+    <xs:complexType name="BoxDipoleType">
+        <xs:annotation>
+            <xs:documentation>
+                A simple generic dipole field with settable B-field in x, y, and z, within a positioned box region.
+            </xs:documentation>
+        </xs:annotation>
+        <xs:complexContent>
+            <xs:extension base="FieldType">
+                <xs:attribute name="dx" type="xs:double" use="required" />
+                <xs:attribute name="dy" type="xs:double" use="required" />
+                <xs:attribute name="dz" type="xs:double" use="required" />
+                <xs:attribute name="x" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="y" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="z" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="bx" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="by" type="xs:double" use="optional" default="0.0" />
+                <xs:attribute name="bz" type="xs:double" use="optional" default="0.0" />
+            </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+
+    <xs:element name="box_dipole" substitutionGroup="field" type="BoxDipoleType">
+        <xs:annotation>
+            <xs:documentation>
+                A box dipole element.
+            </xs:documentation>
+        </xs:annotation>
+    </xs:element>    
+    
 </xs:schema>
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
BoxDipole.java added at 1.1
diff -N BoxDipole.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BoxDipole.java	24 Jun 2011 22:17:13 -0000	1.1
@@ -0,0 +1,43 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
+
+/**
+ * The converter class for adding an LCDD box_dipole element to the document.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: BoxDipole.java,v 1.1 2011/06/24 22:17:13 jeremy Exp $
+ */
+class BoxDipole extends LCDDField
+{
+    private Element node;
+           
+    boolean setExplicitly = false;
+
+    BoxDipole(Element element)
+    {
+        super(element);
+        this.node = element;
+    }    
+
+    void addToLCDD(LCDD lcdd) throws JDOMException
+    {
+        double x = node.getAttribute("x").getDoubleValue();
+        double y = node.getAttribute("y").getDoubleValue();
+        double z = node.getAttribute("z").getDoubleValue();
+        double dx = node.getAttribute("dx").getDoubleValue();
+        double dy = node.getAttribute("dy").getDoubleValue();
+        double dz = node.getAttribute("dz").getDoubleValue();
+        double bx = node.getAttribute("bx").getDoubleValue();
+        double by = node.getAttribute("by").getDoubleValue();
+        double bz = node.getAttribute("bz").getDoubleValue();
+        
+        org.lcsim.geometry.compact.converter.lcdd.util.BoxDipole dip = 
+            new org.lcsim.geometry.compact.converter.lcdd.util.BoxDipole(
+                    getName(), x, y, z, dx, dy, dz, bx, by, bz);
+        
+        lcdd.add(dip);
+    }
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd/util
BoxDipole.java added at 1.1
diff -N BoxDipole.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BoxDipole.java	24 Jun 2011 22:17:13 -0000	1.1
@@ -0,0 +1,35 @@
+package org.lcsim.geometry.compact.converter.lcdd.util;
+
+/**
+ * The element for box_dipole in LCDD. 
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: BoxDipole.java,v 1.1 2011/06/24 22:17:13 jeremy Exp $
+ */
+public class BoxDipole extends Field
+{
+    public BoxDipole(
+            String name,
+            double x,
+            double y,
+            double z,
+            double dx,
+            double dy,
+            double dz,
+            double bx, 
+            double by,
+            double bz)
+    {
+       super("box_dipole", name);
+       
+       setAttribute("x", Double.toString(x));
+       setAttribute("y", Double.toString(y));
+       setAttribute("z", Double.toString(z));
+       setAttribute("dx", Double.toString(dx));
+       setAttribute("dy", Double.toString(dy));
+       setAttribute("dz", Double.toString(dz));
+       setAttribute("bx", Double.toString(bx));
+       setAttribute("by", Double.toString(by));
+       setAttribute("bz", Double.toString(bz));
+    }    
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/field
BoxDipole.java added at 1.1
diff -N BoxDipole.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BoxDipole.java	24 Jun 2011 22:17:13 -0000	1.1
@@ -0,0 +1,57 @@
+package org.lcsim.geometry.field;
+
+import hep.physics.vec.BasicHep3Vector;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+/**
+ * Simple dipole field in a box.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: BoxDipole.java,v 1.1 2011/06/24 22:17:13 jeremy Exp $
+ */
+public class BoxDipole extends AbstractFieldMap
+{
+   private double x, y, z, dx, dy, dz, bx, by, bz;
+   private double xmax, ymax, zmax, xmin, ymin, zmin;   
+
+   BoxDipole(Element node) throws JDOMException
+   {
+      super(node);  
+
+      x = node.getAttribute("x").getDoubleValue();
+      y = node.getAttribute("y").getDoubleValue();
+      z = node.getAttribute("z").getDoubleValue();
+      dx = node.getAttribute("dx").getDoubleValue();
+      dy = node.getAttribute("dy").getDoubleValue();
+      dz = node.getAttribute("dz").getDoubleValue();
+      bx = node.getAttribute("bx").getDoubleValue();
+      by = node.getAttribute("by").getDoubleValue();
+      bz = node.getAttribute("bz").getDoubleValue();
+      
+      xmax = x + dx;
+      xmin = x - dx;
+      ymax = y + dy;
+      ymin = y - dy;
+      zmax = z + dz;
+      zmin = z - dz;
+   }
+
+   void getField(double x, double y, double z, BasicHep3Vector field)
+   {
+       // Check if point is within bounds.
+       if (x > xmax || x < xmin)
+           return;
+       if (y > ymax || y < ymin)
+           return;
+       if (z > zmax || z < zmin)
+           return;
+       
+       // Add dipole B field values to the existing field.
+       double obx = field.x();
+       double oby = field.y();
+       double obz = field.z();            
+       field.setV(bx + obx, by + oby, bz + obz);
+   }
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/field
BoxDipoleTest.java added at 1.1
diff -N BoxDipoleTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BoxDipoleTest.java	24 Jun 2011 22:17:13 -0000	1.1
@@ -0,0 +1,68 @@
+package org.lcsim.geometry.field;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.test.OneTimeDetectorSetup;
+
+/**
+ * Test that checks BoxDipole returns the correct B values for a test detector.  It 
+ * also checks that several BoxDipoles overlay their values correctly.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: BoxDipoleTest.java,v 1.1 2011/06/24 22:17:13 jeremy Exp $
+ */
+public class BoxDipoleTest extends TestCase
+{
+    Detector det;
+    
+    // Test resource containing two BoxDipole fields.
+    static final String detLoc = "/org/lcsim/geometry/field/BoxDipoleTest.xml";
+    
+    public static Test suite()
+    {
+        TestSuite ts = new TestSuite();
+        ts.addTestSuite(BoxDipoleTest.class);
+        return new OneTimeDetectorSetup(ts, detLoc);
+    }
+
+    protected void setUp() throws Exception
+    {
+        if (det == null)
+            det = OneTimeDetectorSetup.getDetector();
+    }
+    
+    public void testDipole()
+    {
+        // Points to test.
+        List<Hep3Vector> testPoints = new ArrayList<Hep3Vector>();
+        testPoints.add(new BasicHep3Vector(0,0,0));
+        testPoints.add(new BasicHep3Vector(251,0,0));
+        
+        // Answer key.
+        List<Hep3Vector> answerKey = new ArrayList<Hep3Vector>();
+        answerKey.add(new BasicHep3Vector(2., 1., 0.5));
+        answerKey.add(new BasicHep3Vector(2.1, 1.2, 0.8));
+        
+        // Loop over test points.
+        for (int i=0, n=testPoints.size(); i<n; i++)
+        {
+            // Get the point to check.
+            Hep3Vector point = testPoints.get(i);
+            
+            // Get the B-field values at this point.
+            Hep3Vector bfield = det.getFieldMap().getField(point);
+           
+            // Check that B-field value matches key.
+            assertEquals(bfield, answerKey.get(i));
+        }
+    }
+}
\ No newline at end of file

GeomConverter/testResources/org/lcsim/geometry/field
BoxDipoleTest.xml added at 1.1
diff -N BoxDipoleTest.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BoxDipoleTest.xml	24 Jun 2011 22:17:14 -0000	1.1
@@ -0,0 +1,61 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+    <info name="BoxDipoleTest">
+        <comment>Test detector for org.lcsim.geometry.field.BoxDipole class.</comment>
+    </info>
+    
+    <define>
+        
+        <constant name="world_side" value="30000" />
+        <constant name="world_x" value="world_side" />
+        <constant name="world_y" value="world_side" />
+        <constant name="world_z" value="world_side" />
+                
+        <constant name="tracking_region_radius" value="1100.0*cm"/>
+        <constant name="tracking_region_zmax" value="150.0*cm"/>
+        
+    </define>
+
+    <materials>
+    </materials>
+    
+    <detectors>
+    </detectors>
+    
+    <readouts>
+    </readouts>
+    
+    <fields>
+
+        <field type="BoxDipole" 
+               name="BoxDipoleTest1"
+               lunit="mm"
+               funit="tesla"
+               x="0."
+               y="0."
+               z="0."
+               dx="500."
+               dy="500."
+               dz="500."
+               bx="1.0"
+               by="0.5"
+               bz="0.25" />
+
+        <field type="BoxDipole" 
+               name="BoxDipoleTest2"
+               lunit="mm"
+               funit="tesla"
+               x="250."
+               y="0."
+               z="0."
+               dx="100."
+               dy="100."
+               dz="100."
+               bx="0.1"
+               by="0.2"
+               bz="0.3" />
+
+    </fields>
+</lccdd>
CVSspam 0.2.8