Commit in GeomConverter on MAIN
src/org/lcsim/detector/IBuilder.java+13added 1.1
                      /DetectorElement.java+30-191.4 -> 1.5
                      /IPhysicalVolumePath.java+21.4 -> 1.5
                      /PhysicalVolumePath.java+281.3 -> 1.4
src/org/lcsim/detector/converter/XMLConverter.java+25added 1.1
src/org/lcsim/detector/converter/compact/CompactDocumentBuilder.java+38added 1.1
                                        /CylindricalBarrelCalorimeterConverter.java+145added 1.1
                                        /DetectorConverter.java+161added 1.1
                                        /IDetectorConverter.java+13added 1.1
                                        /ISubdetectorConverter.java+10added 1.1
src/org/lcsim/detector/converter/heprep/DetectorElementToHepRepConverter.java+136added 1.1
src/org/lcsim/detector/converter/lcdd/MaterialElementConverter.java+60added 1.1
                                     /MaterialMixtureConverter.java+172added 1.1
                                     /MaterialsConverter.java+27added 1.1
src/org/lcsim/detector/material/IMaterialStore.java+3-11.1 -> 1.2
                               /MaterialMixture.java+10-11.3 -> 1.4
                               /MaterialStore.java+121.1 -> 1.2
src/org/lcsim/detector/solids/Trapezoid.java+45added 1.1
src/org/lcsim/geometry/Subdetector.java+3-11.12 -> 1.13
src/org/lcsim/geometry/compact/CompactReader.java+14-81.30 -> 1.31
                              /Subdetector.java+7-21.14 -> 1.15
src/org/lcsim/geometry/subdetector/DESubdetectorBox.java+99added 1.1
                                  /DESubdetectorTube.java+100added 1.1
                                  /AbstractSubdetector.java+2-11.8 -> 1.9
src/org/lcsim/material/XMLMaterialManager.java+11-11.19 -> 1.20
src/org/lcsim/units/clhep/SystemOfUnits.java+3-21.2 -> 1.3
test/org/lcsim/detector/converter/compact/DetectorConverterTest.java+40added 1.1
test/org/lcsim/detector/material/MaterialConverterTest.java+132added 1.1
test/org/lcsim/geometry/subdetector/DESubdetectorTest.java+43added 1.1
                                   /DESubdetectorTest.xml+48added 1.1
+1432-36
18 added + 12 modified, total 30 files
JM: Dev snapshot.

GeomConverter/src/org/lcsim/detector
IBuilder.java added at 1.1
diff -N IBuilder.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ IBuilder.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,13 @@
+package org.lcsim.detector;
+
+/**
+ * Interface for building a sub-part within
+ * a given world volume, similar to Mokka's 
+ * concept of a Subdetector driver.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public interface IBuilder 
+{
+	public void build(PhysicalVolume world);
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector
DetectorElement.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- DetectorElement.java	6 Mar 2007 20:22:16 -0000	1.4
+++ DetectorElement.java	15 Mar 2007 02:09:14 -0000	1.5
@@ -10,6 +10,25 @@
 	private IGeometryInfo geometry;
 	IDetectorElement parent;
 	IIdentifier id;
+	
+	public DetectorElement(
+			String name)
+	{
+		super(name);
+	}
+	
+	public void createGeometryInfo(IPhysicalVolumePath path)
+	{
+		geometry = new GeometryInfo(this,path);
+	}
+	
+	public void createGeometryInfo()
+	{
+		if ( geometry == null )
+		{
+			geometry = new GeometryInfo(this, null);
+		}
+	}
 
 	/**
 	 * Create a DE with support in the geometry tree.
@@ -27,32 +46,24 @@
 	{
 		super(name);
 		this.parent = parent;
-		this.geometry=new GeometryInfo(this,support);
+		this.geometry = new GeometryInfo(this,support);
 		this.id = id;
 		
 		DetectorElementStore.getInstance().add(this);
 	}
 	
-	/**
-	public DetectorElement(
-			String name, 
-			IGeometryInfo geometry, 
+	protected void setup(
 			IDetectorElement parent,
-			IDetectorElementContainer children,
-			IIdentifier id)
-	{
-		super(name);
-		this.geometry=geometry;
-		this.parent=parent;
-		// Copy the DE from container.  Don't use
-		// directly the passed reference.
-		for (IDetectorElement de : children)
-		{
-			children.add(de);
-		}
+			IPhysicalVolumePath support,
+			IIdentifier id
+			)
+	{	
+		this.parent = parent;
+		this.geometry=new GeometryInfo(this,support);
 		this.id = id;
-	}
-	*/
+		
+		DetectorElementStore.getInstance().add(this);
+	}	
 	
 	public void addChild(IDetectorElement child)
 	{

GeomConverter/src/org/lcsim/detector
IPhysicalVolumePath.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- IPhysicalVolumePath.java	4 Mar 2007 05:03:00 -0000	1.4
+++ IPhysicalVolumePath.java	15 Mar 2007 02:09:14 -0000	1.5
@@ -8,4 +8,6 @@
 	public IPhysicalVolume getTopVolume();
 	public IPhysicalVolume getLeafVolume();	
 	public boolean isEmpty();
+	public boolean equals_prefix(IPhysicalVolumePath path);
+	public boolean equals(IPhysicalVolumePath path);
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector
PhysicalVolumePath.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- PhysicalVolumePath.java	4 Mar 2007 12:08:15 -0000	1.3
+++ PhysicalVolumePath.java	15 Mar 2007 02:09:14 -0000	1.4
@@ -88,6 +88,34 @@
 		return true;
 	}
 	
+	/**
+	 * Compare the smallest prefix set of PhysicalVolumes together. 
+	 * 
+	 * @param path
+	 * @return
+	 */
+	public boolean equals_prefix(IPhysicalVolumePath path)
+	{		
+		if (path == null)
+		{
+			return false;
+		}
+		
+		if (size() != 0 && path.size() == 0)
+		{
+			return false;
+		}
+		
+		for (int i = (size() <= path.size() ? size() : path.size() ); i<size(); i++)
+		{
+			if (get(i) != path.get(i))
+			{
+				return false;
+			}
+		}
+		return true;
+	}
+	
 	public String toString()
 	{		
 		StringBuffer sb = new StringBuffer();

GeomConverter/src/org/lcsim/detector/converter
XMLConverter.java added at 1.1
diff -N XMLConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ XMLConverter.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,25 @@
+package org.lcsim.detector.converter;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+/**
+ * 
+ * A generic interface for converting from JDOM/XML 
+ * to runtime objects.  The method {@link #convert(Element)} 
+ * will be called for all elements with a name that matchs 
+ * {@link #getElementName()}.
+ * 
+ * The activate method does not return a specific type.  It
+ * can create one or more Java objects, but these must be
+ * registered with a data store to be accessed later.  Most
+ * of the important types in org.lcsim.detector, such as ISolid, 
+ * are automatically registered with a user-accessible data store.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public interface XMLConverter 
+{
+	public void convert(Element element) throws JDOMException;
+	public String getElementName();
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/converter/compact
CompactDocumentBuilder.java added at 1.1
diff -N CompactDocumentBuilder.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CompactDocumentBuilder.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,38 @@
+package org.lcsim.detector.converter.compact;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map.Entry;
+
+import org.jdom.Document;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.lcsim.units.clhep.SystemOfUnitsMap;
+import org.lcsim.util.xml.JDOMExpressionFactory;
+
+public class CompactDocumentBuilder 
+{
+	public static Document build(String resource) throws JDOMException, IOException
+	{
+		return build(CompactDocumentBuilder.class.getResourceAsStream(resource));
+	}
+	
+	public static Document build(InputStream in) throws JDOMException, IOException
+	{
+		JDOMExpressionFactory eval = new JDOMExpressionFactory();
+		registerCLHEPConstants(eval);
+		SAXBuilder builder = new SAXBuilder();                
+		builder.setFactory(eval);
+		Document doc = builder.build(in);
+		return doc;		
+	}
+	
+	public static void registerCLHEPConstants(JDOMExpressionFactory f)
+	{    
+		SystemOfUnitsMap units = new SystemOfUnitsMap();
+		for (Entry<String,Double> unit : units.entrySet())
+		{
+			f.addConstant(unit.getKey(),unit.getValue());
+		}
+	}	
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/converter/compact
CylindricalBarrelCalorimeterConverter.java added at 1.1
diff -N CylindricalBarrelCalorimeterConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CylindricalBarrelCalorimeterConverter.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,145 @@
+package org.lcsim.detector.converter.compact;
+
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.IPhysicalVolumePath;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeNavigator;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialElement;
+import org.lcsim.detector.material.MaterialStore;
+import org.lcsim.detector.solids.Tube;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.geometry.layer.Layer;
+import org.lcsim.geometry.layer.LayerSlice;
+import org.lcsim.geometry.layer.Layering;
+import org.lcsim.geometry.subdetector.CylindricalBarrelCalorimeter;
+
+public class CylindricalBarrelCalorimeterConverter 
+implements ISubdetectorConverter 
+{	
+	public void convert(
+			Subdetector subdet, 
+			IPhysicalVolume world) 
+	{
+		CylindricalBarrelCalorimeter cal = (CylindricalBarrelCalorimeter)subdet;
+		
+		IMaterial matWorld = world.getLogicalVolume().getMaterial();
+				
+		ILogicalVolume envelope = 
+			buildEnvelope(cal, matWorld);
+		
+		buildLayers(cal, envelope);		
+		
+		new PhysicalVolume(
+				null,
+				cal.getName(),
+				envelope,
+				world.getLogicalVolume(),
+				subdet.getSystemID()
+				);
+				
+		IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
+		IPhysicalVolumePath path = nav.getPath(cal.getName());
+		cal.createGeometryInfo(path);
+	}
+	
+	private ILogicalVolume buildEnvelope(
+			CylindricalBarrelCalorimeter cal,
+			IMaterial material)
+	{
+		Tube tube = new Tube(
+				cal.getName() + "_envelope_tube",
+				cal.getInnerRadius(),
+				cal.getOuterRadius(),
+				cal.getZMax()
+				);
+		
+		LogicalVolume logvol = new LogicalVolume(
+				cal.getName() + "_envelope",
+				tube,
+				material);
+		
+		return logvol;
+	}
+	
+	private void buildLayers(
+			CylindricalBarrelCalorimeter cal,
+			ILogicalVolume envelope
+			)
+	{
+		Layering layering = cal.getLayering();
+		String name = cal.getName();
+		
+		double zHalfLength = cal.getZMax();
+				
+		for (int i=0; i<layering.getNumberOfLayers(); i++)
+		{
+			Layer layer = layering.getLayer(i);
+						
+			double layerInnerRadius = layering.getDistanceToLayer(i);
+						
+			Tube tubeLayer = new Tube(
+					name + "_layer" + i + "_tube",
+					layerInnerRadius,
+					layerInnerRadius + layer.getThickness(),
+					zHalfLength);
+			
+			LogicalVolume lvLayer = 
+				new LogicalVolume(
+						name + "_layer" + i,
+						tubeLayer,
+						envelope.getMaterial()
+						);
+			
+			new PhysicalVolume(
+					null,
+					name + "_layer" + i,
+					lvLayer,
+					envelope,
+					i);			
+			
+			double sliceInnerRadius = layerInnerRadius;
+			
+			for (int j=0; j<layer.getSlices().size(); j++)
+			{
+				LayerSlice slice = layer.getSlice(j);
+				
+				double sliceThickness = slice.getThickness();
+				
+				// TODO: Use real materials engine.
+				String materialName = slice.getMaterial().getName();				
+				IMaterial material = MaterialStore.getInstance().get(materialName);
+				//IMaterial material = new MaterialElement("DUMMY_MATERIAL_"+name, 1, 1, 1);	
+				
+				Tube sliceLayer = new Tube(
+						name + "_layer" + i + "_slice" + j + "_tube",
+						sliceInnerRadius,
+						sliceInnerRadius+sliceThickness,
+						zHalfLength);
+				
+				LogicalVolume lvSlice =
+					new LogicalVolume(
+							name + "_layer" + i + "_slice" + j,
+							sliceLayer,
+							material);
+				
+				new PhysicalVolume(
+						null,
+						"slice"+j,
+						lvSlice,
+						lvLayer,
+						j);
+				
+				sliceInnerRadius += sliceThickness;
+			}			
+		}
+	}
+	
+	public Class getSubdetectorType()
+	{
+		return CylindricalBarrelCalorimeter.class;
+	}
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/converter/compact
DetectorConverter.java added at 1.1
diff -N DetectorConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DetectorConverter.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,161 @@
+package org.lcsim.detector.converter.compact;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.converter.lcdd.MaterialElementConverter;
+import org.lcsim.detector.converter.lcdd.MaterialMixtureConverter;
+import org.lcsim.detector.converter.lcdd.MaterialsConverter;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialStore;
+import org.lcsim.detector.solids.Box;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.compact.Constant;
+import org.lcsim.geometry.compact.Subdetector;
+
+public class DetectorConverter implements IDetectorConverter 
+{
+	Map<Class,ISubdetectorConverter> subdetectorConverters = 
+		new HashMap<Class,ISubdetectorConverter>();
+		
+	public DetectorConverter()
+	{
+		addSubdetectorConverter(new CylindricalBarrelCalorimeterConverter());
+	}
+	
+	private void addSubdetectorConverter(ISubdetectorConverter s)
+	{
+		if ( subdetectorConverters.get(s.getSubdetectorType() ) != null )
+		{
+			throw new IllegalArgumentException("Already have converter for <" + s.getSubdetectorType().getCanonicalName() + "> !");
+		}
+		
+		subdetectorConverters.put(s.getSubdetectorType(), s);
+	}
+	
+	private ISubdetectorConverter getSubdetectorConverter(Class klass)
+	{
+		return subdetectorConverters.get(klass);
+	}
+    	
+	public IPhysicalVolume convert(Detector detector, String resource)  throws JDOMException, IOException
+	{
+		return convert(detector, this.getClass().getResourceAsStream(resource));
+	}
+	
+	public IPhysicalVolume convert(Detector detector, InputStream in) throws JDOMException, IOException
+	{
+        //System.out.println("DetectorConverter.convert - start");
+                
+		Document doc;
+		try {
+			doc = CompactDocumentBuilder.build(in);
+		}
+		catch ( Exception x )
+		{
+			throw new RuntimeException(x);
+		}
+		
+		IPhysicalVolume pvWorld = buildWorldVolume(detector);
+		
+		convertMaterials("/org/lcsim/material/elements.xml");
+		convertMaterials("/org/lcsim/material/materials.xml");
+		convertMaterials(doc);
+        
+		convertSubdetectors(detector, pvWorld);		
+        
+        //System.out.println("DetectorConverter.convert - end");
+        
+		return pvWorld;
+	}
+	
+	private void convertMaterials(Document doc) throws JDOMException
+	{
+		(new MaterialsConverter()).convert(doc);
+	}
+	
+	private void convertMaterials(String resource) throws JDOMException, IOException
+	{
+		Document doc = CompactDocumentBuilder.build(resource);
+		
+		MaterialElementConverter elemCnv = new MaterialElementConverter();
+		MaterialMixtureConverter matCnv = new MaterialMixtureConverter();
+		
+		for ( Object obj : doc.getRootElement().getChildren())
+		{
+			Element e = (Element)obj;
+			if ( e.getName().equals("element") )
+			{			
+				elemCnv.convert(e);
+			}
+			else if ( e.getName().equals("material")) 
+			{
+				matCnv.convert(e);
+			}
+		}
+	}
+			
+	private void convertSubdetectors(Detector detector, IPhysicalVolume pvWorld)
+	{
+		for ( Map.Entry<String,Subdetector> entry : detector.getSubdetectors().entrySet())
+		{
+			Subdetector subdet = entry.getValue();
+			
+			ISubdetectorConverter cnv = getSubdetectorConverter(subdet.getClass());
+			if ( cnv != null )
+			{
+				cnv.convert(subdet, pvWorld);
+			}
+			//else {
+			//	System.err.println("No converter found for <" + subdet.getName() + "> with type <" + subdet.getClass().getCanonicalName() + "> !");
+			//}
+		}		
+	}
+	
+	private IPhysicalVolume buildWorldVolume(Detector detector)
+	{
+		Map<String,Constant> constants = detector.getConstants();
+		
+		if ( constants.get("world_x") == null ||
+		     constants.get("world_y") == null ||
+			 constants.get("world_z") == null ) {
+			throw new RuntimeException("Missing world_x, world_y, or world_z!");
+		}
+		
+		double x = constants.get("world_x").getValue();
+		double y = constants.get("world_y").getValue();
+		double z = constants.get("world_z").getValue();
+			
+		IMaterial air = MaterialStore.getInstance().get("Air");
+			
+		Box boxWorld = new Box(
+				"world_box",
+				x,
+				y,
+				z);			
+		
+		LogicalVolume lvWorld = 
+			new LogicalVolume(
+					"world",
+					boxWorld,
+					air);
+		
+		PhysicalVolume pvWorld = 
+			new PhysicalVolume(
+					null,
+					"world",
+					lvWorld,
+					null,
+					0);
+
+		return pvWorld;
+	}	
+}

GeomConverter/src/org/lcsim/detector/converter/compact
IDetectorConverter.java added at 1.1
diff -N IDetectorConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ IDetectorConverter.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,13 @@
+package org.lcsim.detector.converter.compact;
+
+import java.io.IOException;
+
+import org.jdom.JDOMException;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.geometry.Detector;
+
+public interface IDetectorConverter 
+{
+//	public IPhysicalVolume convert(Detector detector, InputStream in)  throws JDOMException;
+	public IPhysicalVolume convert(Detector detector, String resource)  throws JDOMException, IOException;
+}

GeomConverter/src/org/lcsim/detector/converter/compact
ISubdetectorConverter.java added at 1.1
diff -N ISubdetectorConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ISubdetectorConverter.java	15 Mar 2007 02:09:14 -0000	1.1
@@ -0,0 +1,10 @@
+package org.lcsim.detector.converter.compact;
+
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.geometry.Subdetector;
+
+public interface ISubdetectorConverter
+{
+	public void convert(Subdetector subdet, IPhysicalVolume world);
+	public Class getSubdetectorType();
+}

GeomConverter/src/org/lcsim/detector/converter/heprep
DetectorElementToHepRepConverter.java added at 1.1
diff -N DetectorElementToHepRepConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DetectorElementToHepRepConverter.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,136 @@
+package org.lcsim.detector.converter.heprep;
+
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
+import hep.graphics.heprep.HepRepInstanceTree;
+import hep.graphics.heprep.HepRepType;
+import hep.graphics.heprep.HepRepTypeTree;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.solids.Box;
+import org.lcsim.detector.solids.ISolid;
+import org.lcsim.detector.solids.Tube;
+
+public class DetectorElementToHepRepConverter
+{
+	public void convert(IDetectorElement detelem, HepRepFactory factory, HepRep heprep)
+	{
+		HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop("Detector","1.0");
+		HepRepTypeTree typeTree = heprep.getTypeTree("DetectorType","1.0");
+		
+		IGeometryInfo geo = detelem.getGeometry();
+		
+		ISolid solid = geo.getLogicalVolume().getSolid();
+		
+		if ( solid instanceof Box )
+		{
+			Box box = (Box)geo.getLogicalVolume().getSolid();
+			
+			HepRepType ec = typeTree.getType("Barrel");
+			HepRepType type = factory.createHepRepType(ec, detelem.getName());		
+			type.addAttValue("drawAs","Prism");
+			
+			HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+			
+			Hep3Vector points[] = new BasicHep3Vector[8];
+			
+			double x1 = box.getXHalfLength();
+			double x2 = -box.getXHalfLength();
+
+			double y1 = box.getYHalfLength();
+			double y2 = -box.getYHalfLength();
+
+			double z1 = box.getZHalfLength();
+			double z2 = -box.getZHalfLength();		
+			
+			points[0] = new BasicHep3Vector(x1,y1,z1);
+			points[1] = new BasicHep3Vector(x1,y2,z1);
+			points[2] = new BasicHep3Vector(x2,y2,z1);
+			points[3] = new BasicHep3Vector(x2,y1,z1);
+			points[4] = new BasicHep3Vector(x1,y1,z2);
+			points[5] = new BasicHep3Vector(x1,y2,z2);
+			points[6] = new BasicHep3Vector(x2,y2,z2);
+			points[7] = new BasicHep3Vector(x2,y1,z2);
+
+			// DEBUG
+			//HepRepInstance debugInstance = factory.createHepRepInstance(instanceTree, type);
+			// END DEBUG
+			
+			for (int i=0; i<points.length; i++)
+			{
+				// DEBUG
+				//factory.createHepRepPoint(
+				//		debugInstance,
+				//		points[i].x(),
+				//		points[i].y(),
+				//		points[i].z()
+				//		);
+				// END DEBUG
+				
+				System.out.println("original pnt : " + points[i]);
+				Hep3Vector vec = geo.transformLocalToGlobal(points[i]);
+				System.out.println("transformed pnt : " + vec);
+				System.out.println();
+				points[i] = vec;				
+			}
+			
+			for (int i=0; i<points.length; i++)
+			{
+				Hep3Vector vec = points[i];
+				factory.createHepRepPoint(
+						instance, 
+						vec.x(), 
+						vec.y(), 
+						vec.z()
+						);
+			}
+									
+			/*
+			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);
+			*/
+		}	
+		else if ( solid instanceof Tube ) 
+		{			
+			Tube tube = (Tube)geo.getLogicalVolume().getSolid();
+			
+			HepRepType barrel = typeTree.getType("Barrel");
+	        
+	        HepRepType type = factory.createHepRepType(barrel, detelem.getName());
+	        type.addAttValue("drawAs","Cylinder");        
+	        
+	        double zmin = -tube.getZHalfLength();
+	        double zmax = tube.getZHalfLength();
+	        
+	        Hep3Vector point1 = new BasicHep3Vector(0,0,zmin);
+	        Hep3Vector point2 = new BasicHep3Vector(0,0,zmax);
+	        
+	        point1 = geo.transformGlobalToLocal(point1);
+	        point2 = geo.transformGlobalToLocal(point2);
+	        
+	        HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+	        instance.addAttValue("radius",tube.getInnerRadius());
+	        factory.createHepRepPoint(instance,point1.x(),point1.y(),point1.z());
+	        factory.createHepRepPoint(instance,point2.x(),point2.y(),point2.z());
+	        
+	        HepRepInstance instance2 = factory.createHepRepInstance(instanceTree, type);
+	        instance2.addAttValue("radius",tube.getOuterRadius());
+	        factory.createHepRepPoint(instance2,point1.x(),point1.y(),point1.z());
+	        factory.createHepRepPoint(instance2,point2.x(),point2.y(),point2.z());
+		}				
+		else {
+			System.err.println("IDetectorElementToHepRepConverter - Don't know how to convert shape : " + solid.getName());
+		}
+	}
+}

GeomConverter/src/org/lcsim/detector/converter/lcdd
MaterialElementConverter.java added at 1.1
diff -N MaterialElementConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MaterialElementConverter.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,60 @@
+package org.lcsim.detector.converter.lcdd;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.detector.converter.XMLConverter;
+import org.lcsim.detector.material.MaterialElement;
+
+/**
+ * 
+ * This converter takes a GDML element and converts
+ * it to a MaterialElement.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class MaterialElementConverter 
+implements XMLConverter
+{
+	public void convert(Element element) throws JDOMException
+	{
+		if ( element.getName().equals("element") )
+		{
+			String name = element.getAttributeValue("name");		
+			double z = element.getAttribute("Z").getDoubleValue();
+			
+			Element atom = element.getChild("atom");
+			
+			if ( atom != null )
+			{
+				double a = atom.getAttribute("value").getDoubleValue();
+				
+				// FIXME: Application of a unit means this doesn't 
+				//        end up matching the old materials db!
+				//        Leave it out for now.
+				
+				//double unit = g / mole;
+				//if ( atom.getAttribute("unit") != null )
+				//{
+				//	unit = atom.getAttribute("unit").getDoubleValue();
+				//}				
+				//a = a * unit;				
+				
+				new MaterialElement(name, z, a, 1.0);
+				
+				//System.out.println("added material <" + MaterialStore.getInstance().get(name) + ">");
+			}
+			else {
+				throw new JDOMException("The MaterialElement <" + name + "> is missing <atom>.");
+			}				
+		}
+		else {
+			throw new JDOMException("Invalid element <" + element.getName() + "> for MaterialElementConverter.");
+		}
+	}
+	
+	private static final String elementString = "element";
+	public String getElementName()
+	{
+		return elementString;
+	}
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/converter/lcdd
MaterialMixtureConverter.java added at 1.1
diff -N MaterialMixtureConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MaterialMixtureConverter.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,172 @@
+package org.lcsim.detector.converter.lcdd;
+
+import static org.lcsim.units.clhep.SystemOfUnits.cm3;
+import static org.lcsim.units.clhep.SystemOfUnits.g;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.detector.converter.XMLConverter;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialElement;
+import org.lcsim.detector.material.MaterialMixture;
+import org.lcsim.detector.material.MaterialStore;
+
+/**
+ * 
+ * This converter takes a GDML element and converts
+ * it to a MaterialMixture.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class MaterialMixtureConverter 
+implements XMLConverter
+{	
+	private static final String compositeStr = "composite";
+	private static final String fractionStr = "fraction";
+	
+	public void convert(Element element) throws JDOMException
+	{
+		if ( element.getName().equals("material"))
+		{
+			String name = element.getAttributeValue("name");
+						
+			if ( element.getChild("D") != null)
+			{
+				Element D = element.getChild("D");
+				//double unit = g / cm3;
+				//if ( D.getAttribute("unit") != null)
+				//{
+				//	unit = D.getAttribute("unit").getDoubleValue();
+				//}
+				
+				if ( D.getAttribute("value") != null )
+				{
+					double density = D.getAttribute("value").getDoubleValue();
+					//density *= unit;
+														
+					String defType = "";
+					
+					boolean hasComposite = ( element.getChild("composite") != null);
+					boolean hasFraction = ( element.getChild("fraction") != null);
+					
+					if ( hasComposite && hasFraction )
+					{
+						throw new JDOMException("The material <"+name+"> has both <composite> and <fraction> components, which is not allowed!");
+					}
+					
+					if ( hasComposite )
+					{
+						
+						defType = compositeStr;
+					}
+					else if ( hasFraction )
+					{
+						defType = fractionStr;
+					}
+					else {
+						throw new JDOMException("MaterialMixture <" + name + "> is missing at least one <composite> or <fraction> component.");
+					}
+					
+					int ncomponents = element.getChildren(defType).size();
+					
+					//System.out.println("ncomponents: " + ncomponents);
+
+					MaterialMixture material = 
+						new MaterialMixture(
+				    		name,
+				            ncomponents,
+				            density,
+				            IMaterial.Unknown
+				            );				   						
+					
+					// Add by number of atoms.
+					if ( hasComposite )
+					{																	
+						
+						for ( Object obj : element.getChildren("composite"))
+						{
+							Element composite = (Element)obj;
+							IMaterial matlkp = 
+								MaterialStore.getInstance().get(composite.getAttributeValue("ref"));
+
+							if ( matlkp == null )
+							{
+								throw new JDOMException("The material <" + composite.getAttributeValue("ref") + "> was not found!");
+							}
+							
+							int n = composite.getAttribute("n").getIntValue();
+							
+							if ( matlkp instanceof MaterialElement )
+							{
+								material.addElement((MaterialElement)matlkp, n);
+							}
+							else if ( matlkp instanceof MaterialMixture )
+							{
+								material.addMaterial((MaterialMixture)matlkp, n);
+							}							
+						}
+					}  
+					// Add by mass fraction.
+					// Already checked for neither or both.
+					else {
+						for ( Object obj : element.getChildren("fraction"))
+						{
+							Element fraction = (Element)obj;
+							IMaterial matlkp =
+								MaterialStore.getInstance().get(fraction.getAttributeValue("ref"));
+							if ( matlkp == null )
+							{
+								throw new JDOMException("The material <" + fraction.getAttributeValue("ref") + "> was not found!");
+							}
+							
+							double f = fraction.getAttribute("n").getDoubleValue();
+							
+							if ( matlkp instanceof MaterialElement )
+							{
+								material.addElement((MaterialElement)matlkp, f);
+							}
+							else if ( matlkp instanceof MaterialMixture )
+							{
+								material.addElement((MaterialMixture)matlkp, f);
+							}
+						}
+					}
+				}
+				else {
+					throw new JDOMException("The material <" + name + " is missing a density value.");
+				}
+				
+			}
+			else {
+				throw new JDOMException("The material <" + name + "> is missing <D>.");
+			}					
+		}
+		else {
+			throw new JDOMException("Invalid element <" + element.getName() + "> for MaterialMixtureConverter.");
+		}
+	}
+	
+	private static final String elementString = "material";
+	public String getElementName()
+	{
+		return elementString;
+	}
+}
+
+/*
+
+--Examples--
+
+<material name="Air">
+<D type="density" unit="g/cm3" value="0.0012"/>
+<fraction n="0.754" ref="N"/>
+<fraction n="0.234" ref="O"/>
+<fraction n="0.012" ref="Ar"/>
+</material>
+
+<material name="Actinium">
+<D type="density" unit="g/cm3" value="10.07" />
+<composite n="1" ref="Ac" />
+</material>
+
+*/
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/converter/lcdd
MaterialsConverter.java added at 1.1
diff -N MaterialsConverter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MaterialsConverter.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,27 @@
+package org.lcsim.detector.converter.lcdd;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+public class MaterialsConverter {
+
+	public void convert(Document doc) throws JDOMException
+	{	
+		MaterialElementConverter elemCnv = new MaterialElementConverter();
+		MaterialMixtureConverter matCnv = new MaterialMixtureConverter();
+		
+		Element root = doc.getRootElement().getChild("materials");
+		for ( Object obj : root.getChildren() ) 
+		{
+			Element child = (Element)obj;
+			if ( child.getName().equals("element") ) {
+				elemCnv.convert(child);
+			}
+			else if ( child.getName().equals("material"))
+			{
+				matCnv.convert(child);
+			}
+		}
+	}
+}

GeomConverter/src/org/lcsim/detector/material
IMaterialStore.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- IMaterialStore.java	3 Mar 2007 01:19:39 -0000	1.1
+++ IMaterialStore.java	15 Mar 2007 02:09:15 -0000	1.2
@@ -4,4 +4,6 @@
 
 public interface IMaterialStore 
 extends IObjectStore<IMaterial>
-{}
+{
+	public IMaterial get(String name);
+}

GeomConverter/src/org/lcsim/detector/material
MaterialMixture.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MaterialMixture.java	7 Mar 2007 00:43:41 -0000	1.3
+++ MaterialMixture.java	15 Mar 2007 02:09:15 -0000	1.4
@@ -61,7 +61,9 @@
         if ( nComponents <= 0 )
         {
             throw new IllegalArgumentException("nComponents must be >= 0.");
-        }                        
+        }         
+        
+        this.nComponentsMax = nComponents;
     }
     
     /** Construct a material with a number of components. */
@@ -72,6 +74,13 @@
             State state)
     {
     	super(name,0,0,density,0.0,state,defaultTemperature,defaultPressure,0,0);
+    	
+        if ( nComponents <= 0 )
+        {
+            throw new IllegalArgumentException("nComponents must be >= 0.");
+        }              
+        
+        this.nComponentsMax = nComponents;
     }    
 
     public double getZ()

GeomConverter/src/org/lcsim/detector/material
MaterialStore.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MaterialStore.java	3 Mar 2007 01:19:39 -0000	1.1
+++ MaterialStore.java	15 Mar 2007 02:09:15 -0000	1.2
@@ -15,4 +15,16 @@
 		}
 		return materialStore;
 	}
+	
+	public IMaterial get(String name)
+	{
+		for (IMaterial material : this)
+		{
+			if (material.getName().equals(name))
+			{
+				return material;
+			}
+		}
+		return null;
+	}
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/solids
Trapezoid.java added at 1.1
diff -N Trapezoid.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Trapezoid.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,45 @@
+package org.lcsim.detector.solids;
+
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.detector.Named;
+
+/**
+ *
+ * Trapezoid solid.
+ *
+ * @author Tim Nelson <[log in to unmask]>
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class Trapezoid 
+extends Named
+implements ISolid
+{
+    double xHalfLength1, xHalfLength2, yHalfLength, zHalfLength;
+
+    public Trapezoid(String name, double xHalfLength1, double xHalfLength2, double yHalfLength, double zHalfLength)
+    {
+    	super(name);
+    	this.xHalfLength1 = xHalfLength1;
+    	this.xHalfLength2 = xHalfLength2;
+    	this.yHalfLength = yHalfLength;
+    	this.zHalfLength = zHalfLength;
+    }
+        
+    public double getCubicVolume()
+    {
+        return (xHalfLength1+xHalfLength2) * yHalfLength * zHalfLength * 2;
+    }
+    
+    public boolean isInside(Hep3Vector point)
+    {
+        double inverse_slope = (xHalfLength2-xHalfLength1)/(zHalfLength);
+        double x_intercept = (xHalfLength1+xHalfLength2/2.0);
+   
+        double x_limit = inverse_slope*point.y()+x_intercept;
+        
+        return ( Math.abs(point.x()) < x_limit &&
+                 Math.abs(point.y()) < yHalfLength &&
+                 Math.abs(point.z()) < zHalfLength );
+    }    
+}

GeomConverter/src/org/lcsim/geometry
Subdetector.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- Subdetector.java	12 Sep 2006 01:20:51 -0000	1.12
+++ Subdetector.java	15 Mar 2007 02:09:15 -0000	1.13
@@ -3,13 +3,15 @@
 import org.lcsim.geometry.compact.ParameterSet;
 import org.lcsim.geometry.compact.VisAttributes;
 import org.lcsim.geometry.layer.Layering;
+import org.lcsim.detector.IDetectorElement;
 
 /**
  * @author jeremym
  */
 public interface Subdetector 
+extends IDetectorElement
 {
-    public String getName();
+    //public String getName();
     public int getSystemID();
     
     public IDDecoder getIDDecoder();

GeomConverter/src/org/lcsim/geometry/compact
CompactReader.java 1.30 -> 1.31
diff -u -r1.30 -r1.31
--- CompactReader.java	8 Mar 2007 22:35:32 -0000	1.30
+++ CompactReader.java	15 Mar 2007 02:09:15 -0000	1.31
@@ -26,7 +26,7 @@
  * org.lcsim.geometry.GeometryReader class, which extends this.
  *
  * @author tonyj
- * @version $Id: CompactReader.java,v 1.30 2007/03/08 22:35:32 jeremy Exp $
+ * @version $Id: CompactReader.java,v 1.31 2007/03/15 02:09:15 jeremy Exp $
  *
  */
 public class CompactReader
@@ -80,7 +80,8 @@
         Element lccdd = doc.getRootElement();
         Detector det = factory.createElement(Detector.class,lccdd,null);
         
-        readHeader(lccdd, det, expr);
+        readHeader(lccdd, det);
+        readConstants(lccdd, det);
         readRegions(lccdd, det);
         readLimits(lccdd, det);
         readMaterials(lccdd, det);
@@ -92,19 +93,24 @@
         return det;
     }
     
-    private void readHeader(Element lccdd, Detector det, JDOMExpressionFactory jdom) throws JDOMException, ElementCreationException
+    private void readConstants(Element lccdd, Detector det) throws JDOMException, ElementCreationException
     {
-        Element info = lccdd.getChild("info");
-        det.setHeader(factory.createElement(Header.class,info,null));
-        Element define = lccdd.getChild("define");
+    	Element define = lccdd.getChild("define");
         for (Iterator i = define.getChildren("constant").iterator(); i.hasNext(); )
         {
             Element constant = (Element) i.next();
             Constant c = factory.createElement(Constant.class,constant,null);
-            jdom.addConstant(c.getName(),c.getValue());
+            expr.addConstant(c.getName(),c.getValue());
             det.addConstant(c);
         }
     }
+    
+    private void readHeader(Element lccdd, Detector det) throws JDOMException, ElementCreationException
+    {
+        Element info = lccdd.getChild("info");
+        det.setHeader(factory.createElement(Header.class,info,null));       
+    }
+    
     private void readRegions(Element lccdd, Detector det) throws JDOMException, ElementCreationException
     {
         Element regions = lccdd.getChild("regions");
@@ -254,7 +260,7 @@
         }
     }
     
-    private void registerCLHEPConstants(JDOMExpressionFactory f)
+    public static void registerCLHEPConstants(JDOMExpressionFactory f)
     {    
     	SystemOfUnitsMap units = new SystemOfUnitsMap();
     	for (Entry<String,Double> unit : units.entrySet())

GeomConverter/src/org/lcsim/geometry/compact
Subdetector.java 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- Subdetector.java	12 Sep 2006 01:20:52 -0000	1.14
+++ Subdetector.java	15 Mar 2007 02:09:15 -0000	1.15
@@ -5,12 +5,15 @@
 import org.jdom.JDOMException;
 import org.lcsim.geometry.layer.Layering;
 import org.lcsim.geometry.IDDecoder;
+import org.lcsim.detector.DetectorElement;
 
 /**
  *
  * @author tonyj
  */
-public class Subdetector implements org.lcsim.geometry.Subdetector
+public class Subdetector 
+extends DetectorElement
+implements org.lcsim.geometry.Subdetector
 {
     private boolean reflect;
     private Readout readout;
@@ -21,7 +24,9 @@
     
     protected Subdetector(Element element) throws JDOMException
     {        
-        name = element.getAttributeValue("name");
+    	super(element.getAttributeValue("name"));
+        
+    	name = element.getAttributeValue("name");
         
         Attribute r = element.getAttribute("reflect");
         reflect = r != null &&  r.getBooleanValue();

GeomConverter/src/org/lcsim/geometry/subdetector
DESubdetectorBox.java added at 1.1
diff -N DESubdetectorBox.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DESubdetectorBox.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,99 @@
+package org.lcsim.geometry.subdetector;
+
+import static org.lcsim.units.clhep.SystemOfUnits.m;
+import static org.lcsim.units.clhep.SystemOfUnits.cm;
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import hep.physics.vec.BasicHep3Vector;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.IPhysicalVolumePath;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeNavigator;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialElement;
+import org.lcsim.detector.solids.Box;
+
+public class DESubdetectorBox
+extends AbstractSubdetector
+{
+	private static IMaterial dummymat = new MaterialElement("dummymat",1,1,1.0);
+	IDetectorElement detelem = null;
+	
+	public class DummyDE
+	extends DetectorElement
+	{
+		DummyDE(IPhysicalVolumePath support)
+		{
+			super("dummy",null,support,null);
+		}
+	}
+	
+	
+	DESubdetectorBox(Element element) throws JDOMException
+	{		
+		super(element);
+		System.out.println("MySubdetector");
+		build();
+	}
+	
+	private void build()
+	{
+		IPhysicalVolume world = createWorld();
+	 
+		Box box = new Box("test_box1",1.0*m,1.0*m,1.0*m);
+		LogicalVolume lvTest = new LogicalVolume("lvTest",box,dummymat);
+		new PhysicalVolume(
+				new Transform3D(
+						new BasicHep3Vector(10.0*cm,10.0*cm,10.0*cm)
+						),
+				"box1",
+				lvTest,
+				world.getLogicalVolume(),
+				0);
+		
+		IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
+		IPhysicalVolumePath path = nav.getPath("/box1");
+		detelem = new DummyDE(path);	
+	}
+	
+	private final IPhysicalVolume createWorld()
+	{		
+		Box boxWorld = new Box(
+				"world_box",
+				10.0*m,
+				10.0*m,
+				10.0*m);
+		
+		LogicalVolume lvWorld = 
+			new LogicalVolume(
+					"world",
+					boxWorld,
+					dummymat);
+		
+		IPhysicalVolume pvTop = 
+			new PhysicalVolume(
+					null,
+					"world",
+					lvWorld,
+					null,
+					0);
+		
+		return pvTop;
+	}   	
+	
+	public void appendHepRep(HepRepFactory factory, HepRep heprep)
+	{
+		System.out.println("MySubdetector.appendHepRep");
+		DetectorElementToHepRepConverter cnv = new DetectorElementToHepRepConverter();
+		cnv.convert(this.detelem, factory, heprep);
+	}
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/subdetector
DESubdetectorTube.java added at 1.1
diff -N DESubdetectorTube.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DESubdetectorTube.java	15 Mar 2007 02:09:15 -0000	1.1
@@ -0,0 +1,100 @@
+package org.lcsim.geometry.subdetector;
+
+import static org.lcsim.units.clhep.SystemOfUnits.cm;
+import static org.lcsim.units.clhep.SystemOfUnits.m;
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import hep.physics.vec.BasicHep3Vector;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.detector.DetectorElement;
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.IPhysicalVolumePath;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.PhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeNavigator;
+import org.lcsim.detector.Transform3D;
+import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialElement;
+import org.lcsim.detector.solids.Box;
+import org.lcsim.detector.solids.Tube;
+
+public class DESubdetectorTube
+extends AbstractSubdetector
+{
+	private static IMaterial dummymat = new MaterialElement("dummymat",1,1,1.0);
+	IDetectorElement detelem = null;
+	
+	public class DummyDE
+	extends DetectorElement
+	{
+		DummyDE(IPhysicalVolumePath support)
+		{
+			super("dummy",null,support,null);
+		}
+	}
+	
+	
+	DESubdetectorTube(Element element) throws JDOMException
+	{		
+		super(element);
+		System.out.println("MySubdetector");
+		build();
+	}
+	
+	private void build()
+	{
+		IPhysicalVolume world = createWorld();
+	 
+		Tube tube = new Tube("test_tube1", 1.0*m,2.0*m,3.0*m);
+		LogicalVolume lvTest = new LogicalVolume("lvTest",tube,dummymat);
+		new PhysicalVolume(
+				new Transform3D(
+						new BasicHep3Vector(10.0*cm,10.0*cm,10.0*cm)
+						),
+				"tube1",
+				lvTest,
+				world.getLogicalVolume(),
+				0);
+		
+		IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator(world);
+		IPhysicalVolumePath path = nav.getPath("/tube1");
+		detelem = new DummyDE(path);	
+	}
+	
+	private final IPhysicalVolume createWorld()
+	{		
+		Box boxWorld = new Box(
+				"world_box",
+				10.0*m,
+				10.0*m,
+				10.0*m);
+		
+		LogicalVolume lvWorld = 
+			new LogicalVolume(
+					"world",
+					boxWorld,
+					dummymat);
+		
+		IPhysicalVolume pvTop = 
+			new PhysicalVolume(
+					null,
+					"world",
+					lvWorld,
+					null,
+					0);
+		
+		return pvTop;
+	}   	
+	
+	public void appendHepRep(HepRepFactory factory, HepRep heprep)
+	{
+		System.out.println("MySubdetector.appendHepRep");
+		DetectorElementToHepRepConverter cnv = new DetectorElementToHepRepConverter();
+		cnv.convert(this.detelem, factory, heprep);
+	}
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/subdetector
AbstractSubdetector.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- AbstractSubdetector.java	13 Oct 2006 22:31:51 -0000	1.8
+++ AbstractSubdetector.java	15 Mar 2007 02:09:15 -0000	1.9
@@ -13,6 +13,7 @@
 
 import org.jdom.Element;
 import org.jdom.JDOMException;
+import org.lcsim.detector.IDetectorElement;
 import org.lcsim.geometry.HepRepProvider;
 import org.lcsim.geometry.layer.Layering;
 
@@ -26,7 +27,7 @@
  */
 abstract class AbstractSubdetector
         extends org.lcsim.geometry.compact.Subdetector
-        implements HepRepProvider
+        implements HepRepProvider 
 {
     /** Creates a new instance of AbstractSubdetector */
     public AbstractSubdetector(Element node) throws JDOMException

GeomConverter/src/org/lcsim/material
XMLMaterialManager.java 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- XMLMaterialManager.java	28 Oct 2005 00:34:26 -0000	1.19
+++ XMLMaterialManager.java	15 Mar 2007 02:09:16 -0000	1.20
@@ -395,9 +395,14 @@
     {
         loadFromDocument(currentDoc);
     }
+    
+    public void load(String resource) throws IOException, JDOMException
+    {
+    	loadFromDocument(makeDocument(this.getClass().getResourceAsStream(resource)));    	
+    }
 
     /** Core method for loading material and element XML data from an external entity. */
-    private void loadFromDocument(Document d) throws JDOMException
+    public void loadFromDocument(Document d) throws JDOMException
     {
         org.jdom.Element root = getMaterialsRoot(d);
 
@@ -705,6 +710,7 @@
         int cnt = 0;
         for (Element me : materialMap.values() )
         {
+        	//System.out.println("making material - " + me.getAttributeValue("name"));
             makeMaterial(me, lcdd);
             ++cnt;
         }
@@ -716,6 +722,8 @@
      */
     protected void makeMaterial(org.jdom.Element materialElement, LCDD lcdd) throws JDOMException
     {
+    	//System.out.println("XMLMaterialManager.makeMaterial - " + materialElement.getAttributeValue("name"));
+    	
         /* Add the referenced material if it does not exist already. */
         if ( MaterialManager.getMaterial(materialElement.getAttributeValue("name")) == null )
         {
@@ -727,6 +735,8 @@
             {
                 org.jdom.Element tag = (org.jdom.Element) o;
                 String ref = tag.getAttributeValue("ref");
+                
+                //System.out.println("ref - " + ref);
 
                 org.jdom.Element refMatElem = getMaterial(ref);
 

GeomConverter/src/org/lcsim/units/clhep
SystemOfUnits.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SystemOfUnits.java	23 Feb 2007 02:48:48 -0000	1.2
+++ SystemOfUnits.java	15 Mar 2007 02:09:16 -0000	1.3
@@ -1,4 +1,4 @@
-// $Id: SystemOfUnits.java,v 1.2 2007/02/23 02:48:48 jeremy Exp $
+// $Id: SystemOfUnits.java,v 1.3 2007/03/15 02:09:16 jeremy Exp $
 package org.lcsim.units.clhep;
 
 /**
@@ -7,7 +7,7 @@
  * time, electric charge, mass, etc.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SystemOfUnits.java,v 1.2 2007/02/23 02:48:48 jeremy Exp $
+ * @version $Id: SystemOfUnits.java,v 1.3 2007/03/15 02:09:16 jeremy Exp $
  */
 public final class SystemOfUnits 
 {	
@@ -210,6 +210,7 @@
 	// Amount of substance
 	//
 	public static final double mole = 1.;
+	public static final double mol = mole;
 
 	//
 	// Activity [T^-1]

GeomConverter/test/org/lcsim/detector/converter/compact
DetectorConverterTest.java added at 1.1
diff -N DetectorConverterTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DetectorConverterTest.java	15 Mar 2007 02:09:16 -0000	1.1
@@ -0,0 +1,40 @@
+package org.lcsim.detector.converter.compact;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.PhysicalVolumeStore;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.GeometryReader;
+
+public class DetectorConverterTest
+extends TestCase
+{
+	public DetectorConverterTest(String name)
+    {
+        super(name);
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new TestSuite(DetectorConverterTest.class);
+    }
+    
+    private static final String resource = "/org/lcsim/geometry/subdetector/CylindricalCalorimeterTest.xml";
+    public void testDetectorConverter() throws Exception
+    {    	
+    	InputStream in = 
+    		this.getClass().
+    		getResourceAsStream(resource);
+    	GeometryReader reader = new GeometryReader();
+        Detector det = reader.read(in);
+    	IPhysicalVolume worldVolume = (new DetectorConverter()).convert(det, resource);
+    	for ( IPhysicalVolume physvol : PhysicalVolumeStore.getInstance() )
+    	{
+    		System.out.println("physvol <"+physvol.getName()+">");
+    	}
+    }
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/detector/material
MaterialConverterTest.java added at 1.1
diff -N MaterialConverterTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MaterialConverterTest.java	15 Mar 2007 02:09:16 -0000	1.1
@@ -0,0 +1,132 @@
+package org.lcsim.detector.material;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import org.lcsim.detector.converter.lcdd.MaterialElementConverter;
+import org.lcsim.detector.converter.lcdd.MaterialMixtureConverter;
+import org.lcsim.geometry.compact.CompactReader;
+import org.lcsim.material.MaterialManager;
+import org.lcsim.material.XMLMaterialManager;
+import org.lcsim.util.xml.JDOMExpressionFactory;
+
+public class MaterialConverterTest
+extends TestCase
+{
+    public MaterialConverterTest(String name)
+    {
+        super(name);
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new TestSuite(MaterialConverterTest.class);
+    }
+    
+    public void testReadElementXML() throws Exception
+    {
+    	InputStream in = 
+    		MaterialElementConverter.class.
+    		getResourceAsStream("/org/lcsim/material/elements.xml");    	
+    	JDOMExpressionFactory eval = new JDOMExpressionFactory();
+    	CompactReader.registerCLHEPConstants(eval);    	
+    	SAXBuilder builder = new SAXBuilder();                  
+    	builder.setFactory(eval);
+        Document doc = builder.build(in);
+        
+        Element root = doc.getRootElement();
+                
+        //IMaterialStore store = MaterialStore.getInstance();
+        
+        // Test conversion of <element>.
+        MaterialElementConverter cnv = new MaterialElementConverter();
+        for ( Object child : root.getChildren("element") )
+        {        	
+        	Element element = (Element)child;
+        	//System.out.println("activating MaterialElement : " + element.getAttributeValue("name"));
+        	cnv.convert(element);        	
+        	//System.out.println(store.get(element.getAttributeValue("name")).toString());
+        	//System.out.println();
+        }
+        
+        // Test conversion of <material>.
+        MaterialMixtureConverter cnv2 = new MaterialMixtureConverter();
+        for ( Object child : root.getChildren("material") )
+        {
+        	Element element = (Element)child;
+        	//System.out.println("activating MaterialMixture : " + element.getAttributeValue("name"));
+        	cnv2.convert(element);
+        	//System.out.println(store.get(element.getAttributeValue("name")).toString());
+        	//System.out.println();
+        }
+        
+        InputStream in2 = 
+    		MaterialElementConverter.class.
+    		getResourceAsStream("/org/lcsim/material/materials.xml");    	
+    	JDOMExpressionFactory eval2 = new JDOMExpressionFactory();
+    	CompactReader.registerCLHEPConstants(eval);    	
+    	SAXBuilder builder2 = new SAXBuilder();                  
+    	builder2.setFactory(eval2);
+        Document doc2 = builder.build(in2);
+                
+        //MaterialMixtureConverter cnv2 = new MaterialMixtureConverter();
+        for ( Object child : doc2.getRootElement().getChildren("material") )
+        {
+        	Element element = (Element)child;
+        	//System.out.println("activating MaterialMixture : " + element.getAttributeValue("name"));
+        	cnv2.convert(element);
+        	//System.out.println(store.get(element.getAttributeValue("name")).toString());
+        	//System.out.println();
+        }               
+        
+        XMLMaterialManager xmlMat 
+        	= XMLMaterialManager.create(XMLMaterialManager.materials() );
+        xmlMat.load("/org/lcsim/material/materials.xml");
+        xmlMat.makeMaterials(null);
+        //MaterialManager matmgr = MaterialManager.instance();
+        //System.out.println("Materials defined ...");
+        //matmgr.printMaterials();
+        	
+        //for ( Map.Entry<String,org.lcsim.material.Material> entry : matmgr.getMaterials().entrySet() ) 
+        //{
+        //	System.out.println("xml mgr has material <" + entry.getValue().getName() + ">");
+        //}
+        
+        // Compare to old materials database.
+        for ( IMaterial material : MaterialStore.getInstance())
+        {   
+        	if ( material instanceof MaterialMixture )
+        	{
+        		//System.out.println("Comparing old vs new material <" + material.getName() + "> ...");
+        		org.lcsim.material.Material oldmaterial = 
+        			MaterialManager.findMaterial(material.getName());
+        		//System.out.println("old material <" + oldmaterial.getName() + ">");
+        		System.out.println(oldmaterial.toString());
+        		//System.out.println("--");
+        		//System.out.println("new material <" + material.getName() + ">");
+        		System.out.println(material.toString());
+        		//System.out.println("----------------------------------");
+        		
+        		assertTrue(
+        				oldmaterial.getAeff() - material.getA() < 1e-10 );
+        		
+        		assertTrue(
+        				oldmaterial.getZeff() - material.getZ() < 1e-10 );
+        		
+        		assertTrue(
+        				oldmaterial.getNuclearInteractionLength() -
+        				material.getNuclearInteractionLength() < 1e-10 );
+        		
+        		assertTrue(
+        				oldmaterial.getRadiationLength() -
+        				material.getRadiationLength() < 1e-10 );
+        	}
+        }        
+    }
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/subdetector
DESubdetectorTest.java added at 1.1
diff -N DESubdetectorTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DESubdetectorTest.java	15 Mar 2007 02:09:16 -0000	1.1
@@ -0,0 +1,43 @@
+/*
+ * CylindricalBarrelCalorimeterTest.java
+ *
+ * Created on June 15, 2005, 12:00 PM
+ */
+
+package org.lcsim.geometry.subdetector;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.lcsim.geometry.GeometryReader;
+import org.lcsim.geometry.compact.Detector;
+
+/**
+ *
+ * @author jeremym
+ */
+public class DESubdetectorTest extends TestCase
+{
+    Detector detector;
+    
+    public DESubdetectorTest()
+    {}
+    
+    protected void setUp() throws java.lang.Exception
+    {
+        InputStream in = this.getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/DESubdetectorTest.xml");
+       
+        GeometryReader reader = new GeometryReader();
+        detector = reader.read(in);
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new TestSuite(DESubdetectorTest.class);
+    }        
+    
+    public void testMySubdetector()
+    {}
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/subdetector
DESubdetectorTest.xml added at 1.1
diff -N DESubdetectorTest.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DESubdetectorTest.xml	15 Mar 2007 02:09:16 -0000	1.1
@@ -0,0 +1,48 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <info name="MyDetectorTest"/>
+
+  <!-- Constants -->
+  <define>
+
+    <!-- world -->
+    <constant name="world_side" value="30000" />
+    <constant name="world_x" value="world_side" />
+    <constant name="world_y" value="world_side" />
+    <constant name="world_z" value="world_side" />
+
+    <!-- tracking region -->
+    <constant name="tracking_region_radius" value="0.1*cm"/>
+    <constant name="tracking_region_zmax" value="0.1*cm"/>
+
+  </define>
+
+  <materials>
+  </materials>
+
+  <detectors>
+
+<!-- Electromagnetic calorimeter -->
+
+    <!--  <detector id="1" name="BoxTest" type="DESubdetectorBox" readout="EcalBarrHits"/>-->
+    <detector id="2" name="TubeTest" type="DESubdetectorTube" readout="EcalBarrHits"/>
+     
+  </detectors>
+
+<!-- Sensitive Detector readout segmentation -->
+  <readouts>
+         <readout name="EcalBarrHits">
+             <segmentation type="ProjectiveCylinder" thetaBins="1000" phiBins="2000"/>
+             <id>layer:7,system:3,barrel:3,theta:32:11,phi:11</id>
+         </readout>
+   </readouts>
+    <fields>
+    <field type="Solenoid" name="GlobalSolenoid"
+              inner_field="5.0"
+              outer_field="-0.6"
+              zmax="1000"
+              outer_radius="(221.0+ 5.0 + 17.5 + 40./2.)*cm"/>  <!-- SolenoidCoilBarrel inner_radius + Al support + Oxygen gap + half coil-->
+   </fields>
+</lccdd>
CVSspam 0.2.8