GeomConverter/src/org/lcsim/geometry/field
diff -u -r1.2 -r1.3
--- RZFieldMap.java 1 Sep 2005 23:10:12 -0000 1.2
+++ RZFieldMap.java 3 Sep 2005 01:04:36 -0000 1.3
@@ -45,9 +45,7 @@
public RZFieldMap(Element node) throws JDOMException
{
- super(node);
-
-// System.out.println("RZFieldMap");
+ super(node);
numBinsR = node.getAttribute("numBinsR").getIntValue();
@@ -69,8 +67,9 @@
BrArray = new double[numBinsZ][numBinsR];
BzArray = new double[numBinsZ][numBinsR];
- gridSizeR = node.getAttribute("gridSizeR").getDoubleValue();
- gridSizeZ = node.getAttribute("gridSizeZ").getDoubleValue();
+ /* FIXME: Hard-coded conversion of cm to mm. */
+ gridSizeR = node.getAttribute("gridSizeR").getDoubleValue() * 10;
+ gridSizeZ = node.getAttribute("gridSizeZ").getDoubleValue() * 10;
location = node.getAttribute("url").getValue();
@@ -103,32 +102,38 @@
String line = reader.readLine();
if (line == null) break;
String[] chunks = line.trim().split(" +");
-
- if ( chunks.length != 4 )
- {
- throw new IOException("Invalid RZ field map line: " + line);
- }
-
- double z = Double.valueOf(chunks[0]).doubleValue();
- double r = Double.valueOf(chunks[1]).doubleValue();
- double Bz = Double.valueOf(chunks[2]).doubleValue();
- double Br = Double.valueOf(chunks[3]).doubleValue();
-
- int iz= (int) ((z + 0.0001)/gridSizeZ);
- int ir=(int) ((r + 0.0001)/gridSizeR);
- if ( iz > ( numBinsZ - 1) )
+ if ( chunks.length > 0 )
{
- throw new IOException("z bin out of range: " + iz);
+ if ( chunks.length != 4 )
+ {
+ throw new IOException("Invalid RZ field map line: " + line);
+ }
+
+ /* FIXME: Hard-coded unit conversion of cm to mm. */
+ double z = Double.valueOf(chunks[0]).doubleValue() * 10;
+ double r = Double.valueOf(chunks[1]).doubleValue() * 10;
+
+ /* FIXME: Hard-coded unit conversion of kilogauss to tesla. */
+ double Bz = Double.valueOf(chunks[2]).doubleValue() / 10;
+ double Br = Double.valueOf(chunks[3]).doubleValue() / 10;
+
+ int iz= (int) ((z + 0.0001)/gridSizeZ);
+ int ir=(int) ((r + 0.0001)/gridSizeR);
+
+ if ( iz > ( numBinsZ - 1) )
+ {
+ throw new IOException("z bin out of range: " + iz);
+ }
+
+ if ( ir > ( numBinsR - 1) )
+ {
+ throw new IOException("r bin out of range:" + ir);
+ }
+
+ BzArray[iz][ir] = Bz;
+ BrArray[iz][ir] = Br;
}
-
- if ( ir > ( numBinsR - 1) )
- {
- throw new IOException("r bin out of range:" + ir);
- }
-
- BzArray[iz][ir] = Bz;
- BrArray[iz][ir] = Br;
}
}