GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd/util
diff -u -r1.2 -r1.3
--- Trap.java 29 Oct 2007 21:10:54 -0000 1.2
+++ Trap.java 1 Nov 2007 22:03:49 -0000 1.3
@@ -1,8 +1,10 @@
package org.lcsim.geometry.compact.converter.lcdd.util;
+import org.jdom.DataConversionException;
+
+// FIXME: Hard-coded mult and div by 2 to match GDML convention of dividing inputs by 2.
public class Trap extends Solid
-{
- // FIXME: Hard-coded multiplication by 2 to match GDML convention of dividing inputs by 2.
+{
public Trap(
String name,
double z,
@@ -18,10 +20,7 @@
double alpha2)
{
super("trap",name);
-
- setAttribute("aunit","radian");
- setAttribute("lunit","mm");
-
+
setAttribute("z",String.valueOf(z*2));
setAttribute("theta",String.valueOf(theta));
setAttribute("phi",String.valueOf(phi));
@@ -33,5 +32,75 @@
setAttribute("x3",String.valueOf(x3*2));
setAttribute("x4",String.valueOf(x4*2));
setAttribute("alpha2",String.valueOf(alpha2));
+
+ setAttribute("aunit","radian");
+ setAttribute("lunit","mm");
}
+
+ private double p(String dim)
+ {
+ try
+ {
+ return getAttribute(dim).getDoubleValue();
+ }
+ catch (DataConversionException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+
+ public double getZHalfLength()
+ {
+ return p("z") / 2;
+ }
+
+ public double getTheta()
+ {
+ return p("theta");
+ }
+
+ public double getPhi()
+ {
+ return p("phi");
+ }
+
+ public double getYHalfLength1()
+ {
+ return p("y1") / 2;
+ }
+
+ public double getXHalfLength1()
+ {
+ return p("x1") / 2;
+ }
+
+ public double getXHalfLength2()
+ {
+ return p("x2") / 2;
+ }
+
+ public double getAlpha1()
+ {
+ return p("alpha1");
+ }
+
+ public double getYHalfLength2()
+ {
+ return p("y2") / 2;
+ }
+
+ public double getXHalfLength3()
+ {
+ return p("x3") / 2;
+ }
+
+ public double getXHalfLength4()
+ {
+ return p("x4") / 2;
+ }
+
+ public double getAlpha2()
+ {
+ return p("alpha2") / 2;
+ }
}
\ No newline at end of file