4 added files
trf/src/test/java/org/lcsim/recon/tracking/spacegeom
diff -N SpacePointTensorTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SpacePointTensorTest.java 6 Jul 2011 17:23:30 -0000 1.1
@@ -0,0 +1,21 @@
+package org.lcsim.recon.tracking.spacegeom;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author Norman A. Graf
+ *
+ * @version $Id:
+ */
+public class SpacePointTensorTest extends TestCase
+{
+
+ public void testSpacePointTensor()
+ {
+ SpacePointTensor spt = new SpacePointTensor();
+ System.out.println(spt);
+ //TODO should check that everything is initialized to zero
+ // trust Java for now.
+ }
+}
trf/src/test/java/org/lcsim/recon/tracking/spacegeom
diff -N CartesianPointTensorTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CartesianPointTensorTest.java 6 Jul 2011 17:23:30 -0000 1.1
@@ -0,0 +1,164 @@
+package org.lcsim.recon.tracking.spacegeom;
+
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+import static java.lang.Math.abs;
+
+/**
+ *
+ * @author Norman A. Graf
+ *
+ * @version $Id:
+ */
+public class CartesianPointTensorTest extends TestCase
+{
+
+ public void testCartesianPointTensor()
+ {
+ int np = 10; // Number of points data.
+ int nt = 5; // Number of tensors data.
+
+ double p[][] =
+ {
+ {
+ 0., 0., 0.
+ },
+ {
+ 1., 0., 0.
+ },
+ {
+ 0., 1., 0.
+ },
+ {
+ 0., 0., 1.
+ },
+ {
+ 1., 1., 0.
+ },
+ {
+ 0., 1., 1.
+ },
+ {
+ 1., 0., 1.
+ },
+ {
+ 1., 2., 3.
+ },
+ {
+ -2., -3., 1.
+ },
+ {
+ 4., -5., 3.
+ }
+ };
+
+ double t[][][] =
+ {
+ {
+ {
+ 0., 0., 0.
+ },
+ {
+ 0., 0., 0.
+ },
+ {
+ 0., 0., 0.
+ }
+ },
+ {
+ {
+ 1., 0., 0.
+ },
+ {
+ 0., 1., 0.
+ },
+ {
+ 0., 0., 1.
+ }
+ },
+ {
+ {
+ 1., 1., 1.
+ },
+ {
+ 1., 1., 1.
+ },
+ {
+ 1., 1., 1.
+ }
+ },
+ {
+ {
+ 3., -2., 4.
+ },
+ {
+ -3., 6., -5.
+ },
+ {
+ -1., 2., 1.
+ }
+ },
+ {
+ {
+ -2., 2., -1.
+ },
+ {
+ 3., -4., 5.
+ },
+ {
+ 1., -5., 3.
+ }
+ }
+ };
+
+ // Loop over points.
+
+ for (int ip = 0; ip < np; ++ip)
+ {
+ // Loop over tensors.
+ for (int it = 0; it < nt; ++it)
+ {
+
+ // Construct tensor in Cartesian coordinates.
+
+ CartesianPointTensor tensor0 = new CartesianPointTensor(p[ip][0], p[ip][1], p[ip][2],
+ t[it][0][0], t[it][0][1], t[it][0][2],
+ t[it][1][0], t[it][1][1], t[it][1][2],
+ t[it][2][0], t[it][2][1], t[it][2][2]);
+ System.out.println("Cartesian coordinates.");
+ System.out.println(tensor0);
+ CartesianPoint point0 = new CartesianPoint(p[ip][0], p[ip][1], p[ip][2]);
+ CartesianPointTensor tensor0a = new CartesianPointTensor(point0,
+ t[it][0][0], t[it][0][1], t[it][0][2],
+ t[it][1][0], t[it][1][1], t[it][1][2],
+ t[it][2][0], t[it][2][1], t[it][2][2]);
+ Assert.assertTrue(tensor0.equals(tensor0a));
+ SpacePointTensor tensor0b = new SpacePointTensor(tensor0);
+ System.out.println("tensor0: \n" + tensor0);
+ System.out.println("tensor0b: \n" +tensor0b);
+ Assert.assertTrue(tensor0.equals(tensor0b));
+ tensor0b = tensor0;
+ Assert.assertTrue(tensor0.equals(tensor0b));
+
+ // Test components.
+
+ Assert.assertTrue(myequal(tensor0.t_x_x(), t[it][0][0]));
+ Assert.assertTrue(myequal(tensor0.t_x_y(), t[it][0][1]));
+ Assert.assertTrue(myequal(tensor0.t_x_z(), t[it][0][2]));
+ Assert.assertTrue(myequal(tensor0.t_y_x(), t[it][1][0]));
+ Assert.assertTrue(myequal(tensor0.t_y_y(), t[it][1][1]));
+ Assert.assertTrue(myequal(tensor0.t_y_z(), t[it][1][2]));
+ Assert.assertTrue(myequal(tensor0.t_z_x(), t[it][2][0]));
+ Assert.assertTrue(myequal(tensor0.t_z_y(), t[it][2][1]));
+ Assert.assertTrue(myequal(tensor0.t_z_z(), t[it][2][2]));
+
+ }
+ }
+ }
+
+ static boolean myequal(double x1, double x2)
+ {
+ return abs(x2 - x1) < 1.e-10;
+ }
+}
trf/src/test/java/org/lcsim/recon/tracking/spacegeom
diff -N CylindricalPointTensorTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CylindricalPointTensorTest.java 6 Jul 2011 17:23:30 -0000 1.1
@@ -0,0 +1,158 @@
+package org.lcsim.recon.tracking.spacegeom;
+
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+import static java.lang.Math.abs;
+/**
+ *
+ * @author Norman A. Graf
+ *
+ * @version $Id:
+ */
+public class CylindricalPointTensorTest extends TestCase
+{
+
+ public void testCylindricalPointTensor()
+ {
+ int np = 10; // Number of points data.
+ int nt = 5; // Number of tensors data.
+
+ double p[][] =
+ {
+ {
+ 0., 0., 0.
+ },
+ {
+ 1., 0., 0.
+ },
+ {
+ 0., 1., 0.
+ },
+ {
+ 0., 0., 1.
+ },
+ {
+ 1., 1., 0.
+ },
+ {
+ 0., 1., 1.
+ },
+ {
+ 1., 0., 1.
+ },
+ {
+ 1., 2., 3.
+ },
+ {
+ -2., -3., 1.
+ },
+ {
+ 4., -5., 3.
+ }
+ };
+
+ double t[][][] =
+ {
+ {
+ {
+ 0., 0., 0.
+ },
+ {
+ 0., 0., 0.
+ },
+ {
+ 0., 0., 0.
+ }
+ },
+ {
+ {
+ 1., 0., 0.
+ },
+ {
+ 0., 1., 0.
+ },
+ {
+ 0., 0., 1.
+ }
+ },
+ {
+ {
+ 1., 1., 1.
+ },
+ {
+ 1., 1., 1.
+ },
+ {
+ 1., 1., 1.
+ }
+ },
+ {
+ {
+ 3., -2., 4.
+ },
+ {
+ -3., 6., -5.
+ },
+ {
+ -1., 2., 1.
+ }
+ },
+ {
+ {
+ -2., 2., -1.
+ },
+ {
+ 3., -4., 5.
+ },
+ {
+ 1., -5., 3.
+ }
+ }
+ };
+ // Loop over points.
+
+ for (int ip = 0; ip < np; ++ip)
+ {
+ // Loop over tensors.
+ for (int it = 0; it < nt; ++it)
+ {
+ // Construct tensor in Cylindrical coordinates.
+
+ CylindricalPointTensor tensor1 = new CylindricalPointTensor (p[ip][0], p[ip][1], p[ip][2],
+ t[it][0][0], t[it][0][1], t[it][0][2],
+ t[it][1][0], t[it][1][1], t[it][1][2],
+ t[it][2][0], t[it][2][1], t[it][2][2]);
+ System.out.println("Cylindrical coordinates.");
+ System.out.println(tensor1);
+ CylindricalPoint point1 = new CylindricalPoint(p[ip][0], p[ip][1], p[ip][2]);
+ CylindricalPointTensor tensor1a = new CylindricalPointTensor (point1,
+ t[it][0][0], t[it][0][1], t[it][0][2],
+ t[it][1][0], t[it][1][1], t[it][1][2],
+ t[it][2][0], t[it][2][1], t[it][2][2]);
+ Assert.assertTrue(tensor1.equals(tensor1a));
+ SpacePointTensor tensor1b = new SpacePointTensor(tensor1);
+ Assert.assertTrue(tensor1.equals(tensor1b));
+ SpacePointTensor tensor0b = tensor1;
+ Assert.assertTrue(tensor1.equals(tensor0b));
+
+ // Test components.
+
+ Assert.assertTrue(myequal(tensor1.t_rxy_rxy(), t[it][0][0]));
+ Assert.assertTrue(myequal(tensor1.t_rxy_phi(), t[it][0][1]));
+ Assert.assertTrue(myequal(tensor1.t_rxy_z(), t[it][0][2]));
+ Assert.assertTrue(myequal(tensor1.t_phi_rxy(), t[it][1][0]));
+ Assert.assertTrue(myequal(tensor1.t_phi_phi(), t[it][1][1]));
+ Assert.assertTrue(myequal(tensor1.t_phi_z(), t[it][1][2]));
+ Assert.assertTrue(myequal(tensor1.t_z_rxy(), t[it][2][0]));
+ Assert.assertTrue(myequal(tensor1.t_z_phi(), t[it][2][1]));
+ Assert.assertTrue(myequal(tensor1.t_z_z(), t[it][2][2]));
+
+ }
+ }
+ }
+ static boolean myequal(double x1, double x2)
+ {
+ return abs(x2 - x1) < 1.e-10;
+ }
+}
trf/src/test/java/org/lcsim/recon/tracking/spacegeom
diff -N SphericalPointTensorTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SphericalPointTensorTest.java 6 Jul 2011 17:23:30 -0000 1.1
@@ -0,0 +1,162 @@
+package org.lcsim.recon.tracking.spacegeom;
+
+import junit.framework.TestCase;
+import org.lcsim.recon.tracking.trfutil.Assert;
+
+import static java.lang.Math.abs;
+/**
+ *
+ * @author Norman A. Graf
+ *
+ * @version $Id:
+ */
+public class SphericalPointTensorTest extends TestCase
+{
+
+ public void testSphericalPointTensor()
+ {
+ int np = 10; // Number of points data.
+ int nt = 5; // Number of tensors data.
+
+ double p[][] =
+ {
+ {
+ 0., 0., 0.
+ },
+ {
+ 1., 0., 0.
+ },
+ {
+ 0., 1., 0.
+ },
+ {
+ 0., 0., 1.
+ },
+ {
+ 1., 1., 0.
+ },
+ {
+ 0., 1., 1.
+ },
+ {
+ 1., 0., 1.
+ },
+ {
+ 1., 2., 3.
+ },
+ {
+ -2., -3., 1.
+ },
+ {
+ 4., -5., 3.
+ }
+ };
+
+ double t[][][] =
+ {
+ {
+ {
+ 0., 0., 0.
+ },
+ {
+ 0., 0., 0.
+ },
+ {
+ 0., 0., 0.
+ }
+ },
+ {
+ {
+ 1., 0., 0.
+ },
+ {
+ 0., 1., 0.
+ },
+ {
+ 0., 0., 1.
+ }
+ },
+ {
+ {
+ 1., 1., 1.
+ },
+ {
+ 1., 1., 1.
+ },
+ {
+ 1., 1., 1.
+ }
+ },
+ {
+ {
+ 3., -2., 4.
+ },
+ {
+ -3., 6., -5.
+ },
+ {
+ -1., 2., 1.
+ }
+ },
+ {
+ {
+ -2., 2., -1.
+ },
+ {
+ 3., -4., 5.
+ },
+ {
+ 1., -5., 3.
+ }
+ }
+ };
+
+ // Loop over points.
+
+ for (int ip = 0; ip < np; ++ip)
+ {
+ // Loop over tensors.
+ for (int it = 0; it < nt; ++it)
+ {
+ // Construct tensor in Spherical coordinates.
+
+ SphericalPointTensor tensor2 = new SphericalPointTensor(p[ip][0], p[ip][1], p[ip][2],
+ t[it][0][0], t[it][0][1], t[it][0][2],
+ t[it][1][0], t[it][1][1], t[it][1][2],
+ t[it][2][0], t[it][2][1], t[it][2][2]);
+ System.out.println("Spherical coordinates.");
+ System.out.println(tensor2);
+ SphericalPoint point2 = new SphericalPoint(p[ip][0], p[ip][1], p[ip][2]);
+ SphericalPointTensor tensor2a = new SphericalPointTensor(point2,
+ t[it][0][0], t[it][0][1], t[it][0][2],
+ t[it][1][0], t[it][1][1], t[it][1][2],
+ t[it][2][0], t[it][2][1], t[it][2][2]);
+ Assert.assertTrue(tensor2.equals(tensor2a));
+ SpacePointTensor tensor2b = new SpacePointTensor(tensor2);
+ Assert.assertTrue(tensor2.equals(tensor2b));
+ SpacePointTensor tensor0b = tensor2;
+ Assert.assertTrue(tensor2.equals(tensor0b));
+
+ // Test components.
+
+ Assert.assertTrue(myequal(tensor2.t_rxyz_rxyz(), t[it][0][0]));
+ Assert.assertTrue(myequal(tensor2.t_rxyz_theta(), t[it][0][1]));
+ Assert.assertTrue(myequal(tensor2.t_rxyz_phi(), t[it][0][2]));
+ Assert.assertTrue(myequal(tensor2.t_theta_rxyz(), t[it][1][0]));
+ Assert.assertTrue(myequal(tensor2.t_theta_theta(), t[it][1][1]));
+ Assert.assertTrue(myequal(tensor2.t_theta_phi(), t[it][1][2]));
+ Assert.assertTrue(myequal(tensor2.t_phi_rxyz(), t[it][2][0]));
+ Assert.assertTrue(myequal(tensor2.t_phi_theta(), t[it][2][1]));
+ Assert.assertTrue(myequal(tensor2.t_phi_phi(), t[it][2][2]));
+
+ }
+ }
+
+
+ }
+ static boolean myequal(double x1, double x2)
+ {
+ return abs(x2 - x1) < 1.e-10;
+ }
+
+}
CVSspam 0.2.8