Commit in GeomConverter/src/org/lcsim/geometry/subdetector on MAIN
AbstractTestBeam.java+41-461.11 -> 1.12
correction to fix from Christian; use the correct variable to check if the position element is null

GeomConverter/src/org/lcsim/geometry/subdetector
AbstractTestBeam.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- AbstractTestBeam.java	11 Feb 2013 08:57:11 -0000	1.11
+++ AbstractTestBeam.java	11 Feb 2013 21:48:30 -0000	1.12
@@ -14,7 +14,7 @@
 
 /**
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: AbstractTestBeam.java,v 1.11 2013/02/11 08:57:11 grefe Exp $
+ * @version $Id: AbstractTestBeam.java,v 1.12 2013/02/11 21:48:30 jeremy Exp $
  */
 public abstract class AbstractTestBeam extends AbstractLayeredSubdetector
 {
@@ -37,47 +37,43 @@
      * @param node The XML element from compact description.
      * @throws JDOMException If XML parsing fails.
      */
-    public AbstractTestBeam( Element node ) throws JDOMException
+    public AbstractTestBeam(Element node) throws JDOMException
     {
-        super( node );
-        build( node );
+        super(node);
+        build(node);
     }
 
-    private void build( Element node ) throws JDOMException
+    private void build(Element node) throws JDOMException
     {
-        Element dimensions = node.getChild( "dimensions" );
+        Element dimensions = node.getChild("dimensions");
 
-        x = dimensions.getAttribute( "x" ).getDoubleValue();
-        y = dimensions.getAttribute( "y" ).getDoubleValue();
+        x = dimensions.getAttribute("x").getDoubleValue();
+        y = dimensions.getAttribute("y").getDoubleValue();
         z = getLayering().getThickness();
 
         // Set the outer radius.
-        r = Math.sqrt( Math.pow( x / 2, 2 ) + Math.pow( y / 2, 2 ) );
+        r = Math.sqrt(Math.pow(x / 2, 2) + Math.pow(y / 2, 2));
 
-        Element positionElem = node.getChild( "position" );
+        Element positionElem = node.getChild("position");
 
-        if ( position == null )
-        {
+        if (positionElem != null) {
             double posX = 0;
             double posY = 0;
             double posZ = 0;
-            Attribute posAttrib = positionElem.getAttribute( "x" );
-            if ( posAttrib != null )
-            {
+            Attribute posAttrib = positionElem.getAttribute("x");
+            if (posAttrib != null) {
                 posX = posAttrib.getDoubleValue();
             }
-            posAttrib = positionElem.getAttribute( "y" );
-            if ( posAttrib != null )
-            {
+            posAttrib = positionElem.getAttribute("y");
+            if (posAttrib != null) {
                 posY = posAttrib.getDoubleValue();
             }
 
-            posAttrib = positionElem.getAttribute( "z" );
-            if ( posAttrib != null )
-            {
+            posAttrib = positionElem.getAttribute("z");
+            if (posAttrib != null) {
                 posZ = posAttrib.getDoubleValue();
             }
-            this.position = new BasicHep3Vector( posX, posY, posZ );
+            this.position = new BasicHep3Vector(posX, posY, posZ);
         }
     }
 
@@ -122,9 +118,9 @@
      * 
      * @param The position of the TestBeam.
      */
-    public void setPosition( Hep3Vector position )
+    public void setPosition(Hep3Vector position)
     {
-        if ( this.position != null )
+        if (this.position != null)
             return;
         this.position = position;
     }
@@ -132,21 +128,21 @@
     /**
      * Convert this TestBeam to HepRep format.
      */
-    public void appendHepRep( HepRepFactory factory, HepRep heprep )
+    public void appendHepRep(HepRepFactory factory, HepRep heprep)
     {
-        HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop( "Detector", "1.0" );
-        HepRepTypeTree typeTree = heprep.getTypeTree( "DetectorType", "1.0" );
+        HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop("Detector", "1.0");
+        HepRepTypeTree typeTree = heprep.getTypeTree("DetectorType", "1.0");
+
+        HepRepType ec = typeTree.getType("Endcap");
+        HepRepType type = factory.createHepRepType(ec, getName());
 
-        HepRepType ec = typeTree.getType( "Endcap" );
-        HepRepType type = factory.createHepRepType( ec, getName() );
-        
         // Set color.
-        type.addAttValue( "color", getVisAttributes().getColor() );
-        
+        type.addAttValue("color", getVisAttributes().getColor());
+
         // Set shape.
-        type.addAttValue( "drawAs", "Prism" );        
+        type.addAttValue("drawAs", "Prism");
 
-        HepRepInstance instance = factory.createHepRepInstance( instanceTree, type );
+        HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
 
         Hep3Vector position = getPosition();
 
@@ -159,21 +155,20 @@
         double z1 = position.z() + getZ() / 2;
         double z2 = position.z() - getZ() / 2;
 
-        factory.createHepRepPoint( instance, x1, y1, z1 );
-        factory.createHepRepPoint( instance, x1, y2, z1 );
-        factory.createHepRepPoint( instance, x2, y2, z1 );
-        factory.createHepRepPoint( instance, x2, y1, z1 );
+        factory.createHepRepPoint(instance, x1, y1, z1);
+        factory.createHepRepPoint(instance, x1, y2, z1);
+        factory.createHepRepPoint(instance, x2, y2, z1);
+        factory.createHepRepPoint(instance, x2, y1, z1);
 
-        factory.createHepRepPoint( instance, x1, y1, z2 );
-        factory.createHepRepPoint( instance, x1, y2, z2 );
-        factory.createHepRepPoint( instance, x2, y2, z2 );
-        factory.createHepRepPoint( instance, x2, y1, z2 );
+        factory.createHepRepPoint(instance, x1, y1, z2);
+        factory.createHepRepPoint(instance, x1, y2, z2);
+        factory.createHepRepPoint(instance, x2, y2, z2);
+        factory.createHepRepPoint(instance, x2, y1, z2);
     }
 
     /**
-     * All TestBeams currently existing in GeomConverter have box envelopes, so
-     * numberOfSides is always 4. If this changes, then this method will need to take that
-     * into account.
+     * All TestBeams currently existing in GeomConverter have box envelopes, so numberOfSides is always 4. If
+     * this changes, then this method will need to take that into account.
      * 
      * @return
      */
@@ -199,7 +194,7 @@
     // FIXME Not adjusted for position.
     public double getInnerZ()
     {
-        return -( z / 2 );
+        return -(z / 2);
     }
 
     /**
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