Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd on MAIN
CylindricalBarrelCalorimeter.java+2-21.4 -> 1.5
CylindricalEndcapCalorimeter.java+3-31.9 -> 1.10
DiskTracker.java+1-31.9 -> 1.10
LCDDSubdetector.java+5-11.4 -> 1.5
MultiLayerTracker.java+1-31.7 -> 1.8
PolyconeSupport.java+2-41.4 -> 1.5
util/LCDD.java+42-141.11 -> 1.12
+56-30
7 modified files
Refactored picking of tracking volume or world into method of LCDD class for all subdetector converters.

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
CylindricalBarrelCalorimeter.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- CylindricalBarrelCalorimeter.java	21 Jun 2005 23:46:13 -0000	1.4
+++ CylindricalBarrelCalorimeter.java	15 Jul 2005 00:47:50 -0000	1.5
@@ -32,7 +32,7 @@
         Material air = lcdd.getMaterial("Air");
         Solids solids = lcdd.getSolids();
         Structure structure = lcdd.getStructure();
-        Volume worldVolume = structure.getWorldVolume();
+        Volume motherVolume = lcdd.pickMotherVolume(this);
         
         Element dimensions = node.getChild("dimensions");
         double z = dimensions.getAttribute("outer_z").getDoubleValue();
@@ -105,7 +105,7 @@
         PhysVol physvol = new PhysVol(envelopeVolume);
         physvol.addPhysVolID("system",id);
         physvol.addPhysVolID("barrel",0);
-        worldVolume.addPhysVol(physvol);
+        motherVolume.addPhysVol(physvol);
         
         solids.addSolid(envelope);
         structure.addVolume(envelopeVolume);

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
CylindricalEndcapCalorimeter.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- CylindricalEndcapCalorimeter.java	1 Jul 2005 00:14:53 -0000	1.9
+++ CylindricalEndcapCalorimeter.java	15 Jul 2005 00:47:50 -0000	1.10
@@ -36,7 +36,7 @@
         Rotation reflection = lcdd.getDefine().getRotation("reflect_rot");
         Solids solids = lcdd.getSolids();
         Structure structure = lcdd.getStructure();
-        Volume worldVolume = structure.getWorldVolume();
+        Volume motherVolume = lcdd.pickMotherVolume(this);
         
         Element dimensions = node.getChild("dimensions");
         double zmin = dimensions.getAttribute("inner_z").getDoubleValue();
@@ -127,7 +127,7 @@
         physvol.setZ(zmin+totWidth/2);
         physvol.addPhysVolID("system",id);
         physvol.addPhysVolID("barrel",1);
-        worldVolume.addPhysVol(physvol);
+        motherVolume.addPhysVol(physvol);
         
         if (reflect)
         {
@@ -136,7 +136,7 @@
             physvol2.setRotation(reflection);
             physvol2.addPhysVolID("system",id);
             physvol2.addPhysVolID("barrel",2);
-            worldVolume.addPhysVol(physvol2);
+            motherVolume.addPhysVol(physvol2);
         }
         
         solids.addSolid(envelope);

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
DiskTracker.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- DiskTracker.java	21 Jun 2005 22:06:59 -0000	1.9
+++ DiskTracker.java	15 Jul 2005 00:47:50 -0000	1.10
@@ -36,9 +36,7 @@
       Solids solids = lcdd.getSolids();
       Structure structure = lcdd.getStructure();
       
-      Attribute insideTrackingVolume = node.getAttribute("insideTrackingVolume");
-      boolean inside = insideTrackingVolume == null || insideTrackingVolume.getBooleanValue();
-      Volume trackingVolume = inside ? structure.getTrackingVolume() : structure.getWorldVolume();
+      Volume trackingVolume = lcdd.pickMotherVolume(this);
       
       int n = 0;
       for (Iterator i = node.getChildren("layer").iterator(); i.hasNext(); n++)

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
LCDDSubdetector.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- LCDDSubdetector.java	14 Jun 2005 18:14:16 -0000	1.4
+++ LCDDSubdetector.java	15 Jul 2005 00:47:50 -0000	1.5
@@ -11,7 +11,7 @@
  * 
  * @author tonyj
  */
-abstract class LCDDSubdetector extends Subdetector
+public abstract class LCDDSubdetector extends Subdetector
 {  
    protected Element node;
    LCDDSubdetector(Element c) throws JDOMException
@@ -20,4 +20,8 @@
       node = c;
    }
    abstract void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException;
+   public Element getElement()
+   {
+        return node;
+   }
 }

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
MultiLayerTracker.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- MultiLayerTracker.java	21 Jun 2005 22:06:59 -0000	1.7
+++ MultiLayerTracker.java	15 Jul 2005 00:47:50 -0000	1.8
@@ -33,9 +33,7 @@
       Solids solids = lcdd.getSolids();
       Structure structure = lcdd.getStructure();
       
-      Attribute insideTrackingVolume = node.getAttribute("insideTrackingVolume");
-      boolean inside = insideTrackingVolume == null || insideTrackingVolume.getBooleanValue();
-      Volume trackingVolume = inside ? structure.getTrackingVolume() : structure.getWorldVolume();
+      Volume trackingVolume = lcdd.pickMotherVolume(this);
       
       int n = 0;
       for (Iterator i = node.getChildren("layer").iterator(); i.hasNext(); n++)

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
PolyconeSupport.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- PolyconeSupport.java	9 May 2005 02:42:29 -0000	1.4
+++ PolyconeSupport.java	15 Jul 2005 00:47:50 -0000	1.5
@@ -44,10 +44,8 @@
         // get LCDD objects
         Solids solids = lcdd.getSolids();
         Structure structure = lcdd.getStructure();
-        Attribute insideTrackingVolume = node.getAttribute("insideTrackingVolume");
-        boolean inside = insideTrackingVolume == null || insideTrackingVolume.getBooleanValue();
-        Volume worldVolume = inside ? structure.getTrackingVolume() : structure.getWorldVolume();
-        
+               
+        Volume worldVolume = lcdd.pickMotherVolume(this);
         
         // polycone solid
         Polycone pc = new Polycone(suppName + "_envelope_polycone", 0, 2.*Math.PI, node);

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd/util
LCDD.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- LCDD.java	5 Jul 2005 22:40:17 -0000	1.11
+++ LCDD.java	15 Jul 2005 00:47:50 -0000	1.12
@@ -2,12 +2,12 @@
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jdom.Namespace;
+import org.jdom.Attribute;
 import org.lcsim.material.XMLMaterialManager;
+import org.lcsim.geometry.compact.converter.lcdd.LCDDSubdetector;
 
 /**
  *
@@ -134,21 +134,21 @@
         
         /**
          * This may be a material that was not defined in the materials
-         * block.  Attempt to look it up using the global materials manager.  
-         * 
+         * block.  Attempt to look it up using the global materials manager.
+         *
          * If this fails, the material reference is probably invalid/undefined.
-         *         
+         *
          */
         if (mat == null)
         {
             XMLMaterialManager.materials().resolveLCDDMaterialReference(name, this);
         }
-                
+        
         /** Retry the materials lookup as above call should have added it if found. */
         mat = (Material) materials.get(name);
         
         /** Failed! */
-        if ( mat == null ) 
+        if ( mat == null )
         {
             throw new JDOMException("Material was not found and manager lookup failed: " + name);
         }
@@ -160,23 +160,24 @@
     {
         return (Define) getChild("gdml").getChild("define");
     }
-            
+    
     public Header getHeader()
     {
         return (Header) getChild("header");
     }
     
     public void addMaterial(Material material)
-    {        
-        if ( materials.get(material.getRefName()) == null ) {
+    {
+        if ( materials.get(material.getRefName()) == null )
+        {
             getChild("gdml").getChild("materials").addContent(material);
-            materials.put(material.getRefName(),material); 
+            materials.put(material.getRefName(),material);
         }
     }
     
     public void addElement(Element element)
     {
-        if ( getElement(element.getAttributeValue("name")) == null )             
+        if ( getElement(element.getAttributeValue("name")) == null )
         {
             getChild("gdml").getChild("materials").addContent(element);
         }
@@ -195,7 +196,7 @@
             }
         }
         return e;
-    }    
+    }
     
     public void addIDSpec(IDSpec spec)
     {
@@ -224,4 +225,31 @@
     {
         getChild("regions").addContent(region);
     }
-}
+    
+    /** 
+     * Pick the world or tracking volume for a subdetector's mother volume,
+     * depending on the value of the insideTrackingVolume attribute. 
+     * @param subdet LCDD subdetector
+     */
+    public Volume pickMotherVolume(LCDDSubdetector subdet)
+    {        
+        Attribute insideTrackingVolume = subdet.getElement().getAttribute("insideTrackingVolume");
+        boolean inside;
+        try {
+            inside = (insideTrackingVolume == null) || (insideTrackingVolume.getBooleanValue() );
+        }
+        catch (org.jdom.DataConversionException dce)
+        {
+            throw new RuntimeException("Error converting insideTrackingVolume attribute.", dce);
+        }
+        
+        Volume motherVolume = inside ? getStructure().getTrackingVolume() : getStructure().getWorldVolume();
+        
+        if ( motherVolume == null )
+        {
+            throw new RuntimeException("Picked a null mother volume.");
+        }
+        
+        return motherVolume;
+    }
+}
\ No newline at end of file
CVSspam 0.2.8