Commit in trf/src/test/java/org/lcsim/recon/tracking/magfield on MAIN
Cartesian3DMagneticFieldMapTest.java+57added 1.1
mag field tests

trf/src/test/java/org/lcsim/recon/tracking/magfield
Cartesian3DMagneticFieldMapTest.java added at 1.1
diff -N Cartesian3DMagneticFieldMapTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Cartesian3DMagneticFieldMapTest.java	25 Sep 2012 22:56:18 -0000	1.1
@@ -0,0 +1,57 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.recon.tracking.magfield;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.StringTokenizer;
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.spacegeom.CartesianPoint;
+import org.lcsim.recon.tracking.spacegeom.SpacePoint;
+import org.lcsim.recon.tracking.spacegeom.SpacePointVector;
+import static java.lang.Math.abs;
+
+/**
+ *
+ * @author ngraf
+ */
+public class Cartesian3DMagneticFieldMapTest extends TestCase
+{
+
+    public void testCartesian3DMagneticFieldMap() throws Exception
+    {
+        InputStream is = this.getClass().getResourceAsStream("ThreeDFieldMap.dat");
+        Cartesian3DMagneticFieldMap map = new Cartesian3DMagneticFieldMap(is, 0., 0., 0.);
+
+        is.close();
+        // now read in field map again, and check that we get the correct values at the
+        // measured points
+        // does not test the interpolation per se but is a check.
+        BufferedReader myInput = new BufferedReader(new InputStreamReader(new BufferedInputStream(this.getClass().getResourceAsStream("ThreeDFieldMap.dat"))));
+        String thisLine;
+        //skip the first nine lines of metadata
+        for (int i = 0; i < 9; ++i) {
+            thisLine = myInput.readLine();
+        }
+        // loop over the field points
+
+        for (int i = 0; i < 360; ++i) {
+            thisLine = myInput.readLine();
+            StringTokenizer st = new StringTokenizer(thisLine, " ");
+            double x = Double.parseDouble(st.nextToken());
+            double y = Double.parseDouble(st.nextToken());
+            double z = Double.parseDouble(st.nextToken());
+            double bx = Double.parseDouble(st.nextToken());
+            double by = Double.parseDouble(st.nextToken());
+            double bz = Double.parseDouble(st.nextToken());
+            SpacePointVector spv = map.field(new CartesianPoint(x, y, z));
+            assertEquals(bx, spv.v_x(), abs(.001 * bx));
+            assertEquals(by, spv.v_y(), abs(.001 * by));
+            assertEquals(bz, spv.v_z(), abs(.001 * bz));
+        }
+    }
+}
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1