Commit in GeomConverter on MAIN
src/org/lcsim/detector/DetectorFactory.java+12-271.7 -> 1.8
                      /IDetectorFactory.java+4-131.9 -> 1.10
src/org/lcsim/detector/converter/lcdd/MaterialElementConverter.java+10-31.2 -> 1.3
                                     /MaterialMixtureConverter.java+5-61.2 -> 1.3
src/org/lcsim/detector/material/IMaterial.java+61-81.3 -> 1.4
                               /IMaterialMixture.java+431.2 -> 1.3
                               /MaterialMixture.java+25-471.5 -> 1.6
                               /MaterialElement.java+92-1021.3 -> 1.4
test/org/lcsim/detector/material/MaterialConverterTest.java+41-401.2 -> 1.3
test/org/lcsim/material/XMLMaterialManagerTest.java+7-11.6 -> 1.7
+300-247
10 modified files
JM: refactoring and bug fixes in org.lcsim.detector.material package

GeomConverter/src/org/lcsim/detector
DetectorFactory.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- DetectorFactory.java	11 Sep 2007 19:21:25 -0000	1.7
+++ DetectorFactory.java	9 Nov 2007 23:47:49 -0000	1.8
@@ -56,38 +56,23 @@
 		return new LogicalVolume(name, solid, material);
 	}
 
-	public IMaterial createMaterialElement(
-			String name, 
-			double Z, 
-			double A,
-			double density) 
-	{
-		return new MaterialElement(name,Z,A,density);
-	}
-
-	public IMaterial createMaterialElement(
-			String name, 
-			int Z, 
-			int A,
-			double density, 
-			double ionizationPotential, 
-			State state,
-			double temperature, 
-			double pressure, 
-			double meltingPoint,
-			double boilingPoint) 
+    public IMaterial createMaterialElement(
+            String name,
+            double Z,
+            double A,
+            double density, 
+            State state,
+            double temperature,
+            double pressure)
 	{
 		return new MaterialElement(
 				name, 
 				Z, 
 				A, 
-				density, 
-				ionizationPotential, 
-				state, 
-				temperature, 
-				pressure, 
-				meltingPoint, 
-				boilingPoint);
+				density,  
+				state,
+                temperature,
+                pressure);
 	}
 
 	public IMaterial createMaterialMixture(

GeomConverter/src/org/lcsim/detector
IDetectorFactory.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- IDetectorFactory.java	7 May 2007 22:32:48 -0000	1.9
+++ IDetectorFactory.java	9 Nov 2007 23:47:49 -0000	1.10
@@ -41,20 +41,11 @@
 			String name,
 			double Z,
 			double A,
-			double density);
-	
-    public IMaterial createMaterialElement(			
-			String name, 
-			int Z, 
-			int A, 
 			double density, 
-			double ionizationPotential, 
-			State state,
-			double temperature,
-			double pressure,
-			double meltingPoint,
-			double boilingPoint);
-	
+            State state,
+            double temperature,
+            double pressure);
+		
     public IMaterial createMaterialMixture(
 	  		String name,
             int nComponents,

GeomConverter/src/org/lcsim/detector/converter/lcdd
MaterialElementConverter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MaterialElementConverter.java	22 May 2007 20:02:05 -0000	1.2
+++ MaterialElementConverter.java	9 Nov 2007 23:47:49 -0000	1.3
@@ -3,6 +3,7 @@
 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;
 
 /**
@@ -39,9 +40,15 @@
 				//}				
 				//a = a * unit;				
 				
-				new MaterialElement(name, z, a, 1.0);
-				
-				//System.out.println("added material <" + MaterialStore.getInstance().get(name) + ">");
+                // FIXME: Get state, temperature, and pressure from the XML file.
+				new MaterialElement(
+                        name, 
+                        z, 
+                        a, 
+                        1.0, 
+                        IMaterial.Unknown, 
+                        IMaterial.defaultTemperature, 
+                        IMaterial.defaultPressure);				
 			}
 			else {
 				throw new JDOMException("The MaterialElement <" + name + "> is missing <atom>.");

GeomConverter/src/org/lcsim/detector/converter/lcdd
MaterialMixtureConverter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MaterialMixtureConverter.java	22 May 2007 20:02:05 -0000	1.2
+++ MaterialMixtureConverter.java	9 Nov 2007 23:47:49 -0000	1.3
@@ -69,8 +69,6 @@
 					
 					int ncomponents = element.getChildren(defType).size();
 					
-					//System.out.println("ncomponents: " + ncomponents);
-
 					MaterialMixture material = 
 						new MaterialMixture(
 				    		name,
@@ -81,14 +79,13 @@
 					
 					// 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!");
@@ -112,8 +109,10 @@
 						for ( Object obj : element.getChildren("fraction"))
 						{
 							Element fraction = (Element)obj;
+                            
 							IMaterial matlkp =
-								MaterialStore.getInstance().get(fraction.getAttributeValue("ref"));
+								MaterialStore.getInstance().get(fraction.getAttributeValue("ref"));                                                      
+                                                                                    
 							if ( matlkp == null )
 							{
 								throw new JDOMException("The material <" + fraction.getAttributeValue("ref") + "> was not found!");

GeomConverter/src/org/lcsim/detector/material
IMaterial.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- IMaterial.java	6 Mar 2007 20:22:17 -0000	1.3
+++ IMaterial.java	9 Nov 2007 23:47:49 -0000	1.4
@@ -2,21 +2,76 @@
 
 public interface IMaterial 
 {
+    /**
+     * Get the name of this material.
+     * @return The name of the material.
+     */
 	public String getName();
+    
+    /**
+     * Get the density of this material in g/cm3.
+     * @return The density in g/cm3.
+     */
 	public double getDensity();
+    
+    /**
+     * Get the atomic mass of this material.
+     * @return The atomic mass.
+     */
 	public double getZ();
+    
+    /**
+     * Get the atomic number of this material.
+     * @return The atomic number.
+     */
 	public double getA();
-	public double getMeltingPoint();
-	public double getBoilingPoint();
-	public double getTemperature();
-	public double getPressure();
-	public double getMolecularWeight();
-	public double getEffectiveNumberOfNucleons();
+       
+    /**
+     * Get the nuclear interaction length in g/cm2.
+     * @return The nuclear interaction length in g/cm2.
+     */
 	public double getNuclearInteractionLength();
+    
+    /**
+     * Get the nuclear interaction length in g/cm2.
+     * @return The nuclear interaction length in cm.
+     */
 	public double getNuclearInteractionLengthWithDensity();
+    
+    /**
+     * Get the radiation length in g/cm2.
+     * @return The radiation length in g/cm2.
+     */
 	public double getRadiationLength();
+    
+    /**
+     * Get the radiation length in cm.
+     * @return The radiation length in cm.
+     */
 	public double getRadiationLengthWithDensity();
+    
+    /**
+     * Get the Moliere radius in cm.
+     * @return The moliere radius in cm.
+     */
 	public double getMoliereRadius();
+    
+    /**
+     * Get the temperature of the material in Kelvin.
+     * @return The temperature in Kelvin.
+     */
+    public double getTemperature();
+    
+    /**
+     * Get the pressure of the material in atmospheres.
+     * @return The pressure of the material in atmospheres.
+     */
+    public double getPressure();
+    
+    /**
+     * Get the state of this material, either liquid, gas, solid, or unknown.
+     * @return The state of this material.
+     */
 	public State getState();
 	
     public final static State Unknown = new State("unknown");
@@ -42,8 +97,6 @@
 	// Defaults for non-mandatory parameters.
 	static public final double defaultTemperature=273.15;
 	static public final State defaultState=Unknown;
-	static public final double defaultBoilingPoint=0.0;
-	static public final double defaultMeltingPoint=0.0;
 	static public final double defaultPressure=1.0;
 	static public final double defaultIonizationPotential=0.0;	
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector/material
IMaterialMixture.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- IMaterialMixture.java	25 Sep 2007 22:30:44 -0000	1.2
+++ IMaterialMixture.java	9 Nov 2007 23:47:49 -0000	1.3
@@ -2,14 +2,57 @@
 
 import java.util.List;
 
+/**
+ * A material mixture that is defined by a list of sub-materials.
+ * The sub-materials are added by mass fraction or atom count.
+ * Mixing mass fractions and atom counts is not allowed and
+ * will cause a fatal error.
+ * 
+ * @author jeremym
+ *
+ */
 public interface IMaterialMixture 
 extends IMaterial
 {
+    /**
+     * Get the total number of components allowed in this mixture.
+     * @return The maximum number of allowed components.
+     */
 	public int getNComponentsMax();
+    
+    /**
+     * The number of components added thusfar to the mixture.
+     * @return The number of components added so far.
+     */
 	public int getNComponents();
+    
+    /**
+     * Get the number of different elements in this mixture.
+     * @return The number of different elements in this mixture.
+     */
 	public int getNElements();	
+    
+    /**
+     * Get a list of elements in this mixture.
+     * @return A list of elements in this mixture.
+     */
 	public List<MaterialElement> getElements();
+    
+    /**
+     * Get the list of mass fractions in this element.  Same order as {@link #getElements()}. 
+     * @return
+     */
 	public List<Double> getMassFractions();
+    
+    /**
+     * Get the list of atom counts in this element.  Same order as {@link #getElements()}.
+     * @return The list of atom counts.
+     */
 	public List<Integer> getAtomCounts();
+    
+    /**
+     * 
+     * @return True if {@link #getNComponents()} is equal to {@link #getNComponentsMax()}.
+     */
 	public boolean isFilled();
 }

GeomConverter/src/org/lcsim/detector/material
MaterialMixture.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- MaterialMixture.java	25 Sep 2007 23:37:19 -0000	1.5
+++ MaterialMixture.java	9 Nov 2007 23:47:49 -0000	1.6
@@ -20,24 +20,21 @@
     
     // Max interaction length.
     public static final double MAX_NUCLEAR_INTERACTION_LENGTH = java.lang.Double.MAX_VALUE;
-         
-    // Corresponds to single MaterialElement? 
-    boolean isElement=false;
-    
+             
     // Effective, computed Z value.
-    public double Zeff;
+    private double Zeff;
     
     // Effective, computed A value.
-    public double Aeff;
+    private double Aeff;
     
     // Number of components added.
-    int nComponentsAdded=0;
+    private int nComponentsAdded=0;
     
     // Number of components that are allowed to be added.
-    int nComponentsMax=0;
+    private int nComponentsMax=0;
     
     // Number of elements in the mass fraction list.
-    int nElements=0;
+    private int nElements=0;
     
     // The list of elements making up the mixture.
     private List<MaterialElement> elementList = new ArrayList<MaterialElement>();
@@ -49,14 +46,15 @@
     private List<Integer> atomCountList = new ArrayList<Integer>();      
     
     /** Construct a material with a number of components. */
-    public MaterialMixture(String name,
+    public MaterialMixture(
+            String name,
             int nComponents,
             double density,
-            State state,
-            double temp,
-            double pressure)
+            State state)
     {
-    	super(name,0,0,density,0.0,state,temp,pressure,0,0);
+        this.name = name;
+        this.density = density;
+        this.state = state;
         
         if ( nComponents <= 0 )
         {
@@ -66,23 +64,6 @@
         this.nComponentsMax = nComponents;
     }
     
-    /** Construct a material with a number of components. */
-    public MaterialMixture(
-    		String name,
-            int nComponents,
-            double density,
-            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()
     {
     	return Zeff;
@@ -124,7 +105,7 @@
         
         nuclearInteractionLength = (NILinv <= 0.0 ? MAX_NUCLEAR_INTERACTION_LENGTH : 1.0/NILinv);
         nuclearInteractionLengthWithDensity = nuclearInteractionLength / getDensity();
-        
+
         return NILinv;
     }
     
@@ -140,22 +121,22 @@
         }
         
         radiationLength = (rlinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0/rlinv);
+        radiationLengthWithDensity = radiationLength / getDensity();
         
         return radiationLength;
     }
     
     /** Caches computed quantities after all components have been added to the material. */
     private void computeDerivedQuantities()
-    {
-
-        computeZeff();
-        computeAeff();
+    {                
+        computeZeff();        
+        computeAeff();        
+        //computeEffectiveNumberOfNucleons();
+        //computeMolecularWeigth();
         computeRadiationLengthForMixture();
         computeNuclearInteractionLengthForMixture();
-		computeCriticalEnergy();
-		computeMoliereRadius();
-    	computeEffectiveNumberOfNucleons();
-		computeMolecularWeigth();    
+        computeCriticalEnergy();
+        computeMoliereRadius();    			    
     }    
     
     /** @return total number of (unique) elements in the element list for this material */
@@ -187,8 +168,7 @@
      *
      * Based on Geant4's G4Material::AddElement() .
      */
-    public void addElement(MaterialElement element,
-            int nAtoms)
+    public void addElement(MaterialElement element, int nAtoms)
     {
         if ( nElements < nComponentsMax )
         {
@@ -203,7 +183,6 @@
         
         if ( isFilled() )
         {
-            //double Zmol = 0;
             double Amol = 0;
             
             int atomCnt = 0;
@@ -353,7 +332,6 @@
         for ( int i = 0; i < nelem; i++ )
         {
             MaterialElement me = this.getElements().get(i);
-            //double elemZ = me.getZ();
             double massFrac = this.getMassFractions().get(i);
             double atomCntFrac = massFrac / me.getA();
             ZsumNotNorm += atomCntFrac * me.getZ();
@@ -390,9 +368,9 @@
     {
     	StringBuffer sb = new StringBuffer();
     	sb.append(super.toString());
-    	sb.append("nComponents=" + nComponentsAdded + "; ");
-    	sb.append("nComponentsMax=" + nComponentsMax + "; ");
-    	sb.append("nElements=" + nElements);                                  
+    	sb.append("numberOfComponents = " + nComponentsAdded + "; ");
+    	sb.append("maxNumberOfComponents = " + nComponentsMax + "; ");
+    	sb.append("numberOfElements = " + nElements);                                  
         
         for ( int i = 0; i < this.getNElements(); i++)
         {

GeomConverter/src/org/lcsim/detector/material
MaterialElement.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MaterialElement.java	6 Mar 2007 20:22:17 -0000	1.3
+++ MaterialElement.java	9 Nov 2007 23:47:49 -0000	1.4
@@ -2,7 +2,6 @@
 
 import static java.lang.Math.log;
 import static java.lang.Math.pow;
-import static org.lcsim.units.clhep.PhysicalConstants.Avogadro;
 import static org.lcsim.units.clhep.PhysicalConstants.fine_structure_const;
 
 /**
@@ -21,85 +20,103 @@
 implements IMaterial
 {	
 	// From constructor.
-	private String name;
-	private double Z;
-	private double A;
-	private double density;
+    protected String name;
+    protected double Z;
+    protected double A;
+    protected double density;
+    protected double temperature;
+    protected double pressure;
 	
 	// Set by the detailed constructor.  Otherwise, use defaults.
-	private double ionizationPotential=defaultIonizationPotential;
-	private double temperature=defaultTemperature;
-	private double pressure=defaultPressure;
-	private double meltingPoint=defaultMeltingPoint;
-	private double boilingPoint=defaultBoilingPoint;
-	private State state=defaultState;
+    protected State state=defaultState;
 	
 	// Derived quantities.
 	protected double N;
-	protected double molecularWeight;
 	protected double nuclearInteractionLength;
 	protected double nuclearInteractionLengthWithDensity;
 	protected double radiationLength;
 	protected double radiationLengthWithDensity;
 	protected double criticalEnergy;
 	protected double moliereRadius;
-	
-	public MaterialElement(
-			String name,
-			double Z,
-			double A,
-			double density)
-	{
-		// Basic parameters.
-		this.name = name;
-		this.Z = Z;
-		this.A = A;
-		this.density = density;		
-		
-		// Compute derived.
-		computeDerivedQuantities();
-		
-		MaterialStore.getInstance().add(this);
-	}	
-	
+    
+    /**
+     * Constructor for sub-classes.
+     */
+    protected MaterialElement()
+    {
+        MaterialStore.getInstance().add(this);
+    }
+		   
+    /**
+     * Construct a MaterialElement.
+     * 
+     * @param name The name of the material, which must be globally unique.
+     * @param Z The atomic mass.
+     * @param A The atomic number.
+     * @param density The density in g/cm3.
+     * @param state The material's state.
+     * @param temperature The temperature in Kelvin.
+     * @param pressure The pressure in atmospheres.
+     */
 	public MaterialElement(
 			String name, 
-			int Z, 
-			int A, 
-			double density, 
-			double ionizationPotential, 
+			double Z, 
+			double A, 
+			double density,
 			State state,
-			double temperature,
-			double pressure,
-			double meltingPoint,
-			double boilingPoint)
+            double temperature,
+            double pressure)
 	{
-		// Basic parameters.
+        // Set parameters.
 		this.name = name;
 		this.Z = Z;
 		this.A = A;
-		this.density = density;
-		
-		// Detailed parameters.
+		this.density = density;		
         this.density = density;
-        this.ionizationPotential = ionizationPotential;
         this.state = state;
-		this.temperature = temperature;
-		this.pressure = pressure;
-		this.meltingPoint = meltingPoint;
-		this.boilingPoint = boilingPoint;
+        this.temperature = temperature;
+        this.pressure = pressure;
                 
-		// Compute derived.
+		// Compute derived quantities.
         computeDerivedQuantities();
-        
+
+        // Add to global static materials store.
         MaterialStore.getInstance().add(this);
 	}
+    
+    /**
+     * Construct a MaterialElement.
+     * 
+     * @param name The name of the material, which must be globally unique.
+     * @param Z The atomic mass.
+     * @param A The atomic number.
+     * @param density The density in g/cm3.
+     */
+    public MaterialElement(
+            String name, 
+            double Z, 
+            double A, 
+            double density)
+    {
+        // Set parameters.
+        this.name = name;
+        this.Z = Z;
+        this.A = A;
+        this.density = density;     
+        this.density = density;
+        this.state = Unknown;
+        this.temperature = defaultTemperature;
+        this.pressure = defaultPressure;
+                
+        // Compute derived quantities.
+        computeDerivedQuantities();
+
+        // Add to global static materials store.
+        MaterialStore.getInstance().add(this);
+    }    
 	
 	private void computeDerivedQuantities()
 	{		
-		// Order is important!
-		computeEffectiveNumberOfNucleons();
-		computeMolecularWeigth();
 		computeRadiationLength();
 		computeNuclearInteractionLength();
 		computeCriticalEnergy();
@@ -115,18 +132,6 @@
 	{
 		moliereRadius = getRadiationLengthWithDensity() * 21.2052 / criticalEnergy;
 	}
-		
-	protected void computeEffectiveNumberOfNucleons()
-	{
-		N = A / Avogadro;	
-	}
-	
-	// FIXME: Wrong for isotopes.
-	protected void computeMolecularWeigth()
-	{
-		double natoms=1.0;
-		molecularWeight = A * natoms;
-	}
 	
 	protected void computeRadiationLength()
 	{
@@ -173,36 +178,6 @@
 		return Z;
 	}
 
-	public double getBoilingPoint() 
-	{
-		return boilingPoint;
-	}
-
-	public double getMeltingPoint() 
-	{
-		return meltingPoint;
-	}
-
-	public double getPressure() 
-	{
-		return pressure;
-	}
-
-	public double getTemperature() 
-	{
-		return temperature;
-	}
-	
-	public double getMolecularWeight()
-	{
-		return molecularWeight;
-	}
-	
-	public double getIonizationPotential()
-	{
-		return ionizationPotential;
-	}
-	
 	public double getEffectiveNumberOfNucleons()
 	{
 		return N;
@@ -222,7 +197,6 @@
 	{
 		return radiationLengthWithDensity;
 	}
-
 	
 	public static double computeRadiationLengthTsai(double A, double Z)
     {
@@ -288,15 +262,31 @@
         return NIL;
     }	       
     
+    public double getTemperature()
+    {
+        return temperature;
+    }
+    
+    public double getPressure()
+    {
+        return pressure;
+    }    
+    
     public String toString()
     {
     	StringBuffer sb = new StringBuffer();
-    	sb.append(getName() + "; ");
-    	sb.append(getDensity() + " g/cm3 ; ");
-    	sb.append("A="+getA() + "; ");
-    	sb.append("Z="+getZ() + "; ");
-    	sb.append("nucIntLen=" + getNuclearInteractionLength() + "; ");
-    	sb.append("radLen=" + getRadiationLength() + "; ");
+    	sb.append(getName() + '\n');
+    	sb.append("D = " + getDensity() + " {g/cm3} ; ");
+    	sb.append("A = " + getA() + "; ");
+    	sb.append("Z = " + getZ());
+        sb.append('\n');
+    	sb.append("LamdaT = " + getNuclearInteractionLength() + " {g/cm2}; ");
+        sb.append("LamdaT = " + getNuclearInteractionLengthWithDensity() + " {cm}; ");
+    	sb.append("X0 = " + getRadiationLength() + " {g/cm2}; ");
+        sb.append("X0 = " + getRadiationLengthWithDensity() + " {cm}; ");
+        sb.append("Rm = " + getMoliereRadius() + " {cm} ");
+        sb.append('\n');
+        
     	return sb.toString();
     }
 }
\ No newline at end of file

GeomConverter/test/org/lcsim/detector/material
MaterialConverterTest.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MaterialConverterTest.java	17 Mar 2007 00:10:42 -0000	1.2
+++ MaterialConverterTest.java	9 Nov 2007 23:47:49 -0000	1.3
@@ -18,9 +18,7 @@
 
 public class MaterialConverterTest
 extends TestCase
-{
-    double tolerance = 1e-10;
-    
+{    
     public MaterialConverterTest(String name)
     {
         super(name);
@@ -44,28 +42,20 @@
         
         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 = 
@@ -79,55 +69,66 @@
                 
         //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() < tolerance );
+               
+        		assertEquals(oldmaterial.getAeff(), material.getA(), 1e-8 );
         		
-        		assertTrue(
-        				oldmaterial.getZeff() - material.getZ() < tolerance );
+        		assertEquals(oldmaterial.getZeff(), material.getZ(), 1e-8 );
         		
-        		assertTrue(
-        				oldmaterial.getNuclearInteractionLength() -
-        				material.getNuclearInteractionLength() < tolerance );
+        		assertEquals(
+                        oldmaterial.getNuclearInteractionLength(),
+                        material.getNuclearInteractionLength(), 
+                        1e-8 );
+                
+                assertEquals(
+                        oldmaterial.getNuclearInteractionLengthWithDensity(),
+                        material.getNuclearInteractionLengthWithDensity(),
+                        1e-8 );
         		
         		assertTrue(
         				oldmaterial.getRadiationLength() -
-        				material.getRadiationLength() < tolerance );
+        				material.getRadiationLength() <=
+                        1E-5 );
+                
+                assertTrue(
+                        oldmaterial.getRadiationLengthWithDensity() - 
+                        material.getRadiationLengthWithDensity() <=
+                        1E-5 );
+                
+                assertTrue(
+                        oldmaterial.getMoliereRadius() - 
+                        material.getMoliereRadius() <=
+                        1e-4 );
+                
+                // Old material does not have this.
+                //assertTrue(
+                //        material.getEffectiveNumberOfNucleons() != 0
+                //        );                
+                
+                if (material.getName().equals("Silicon"))
+                {
+                    System.out.println("old material ...");
+                    System.out.println(oldmaterial.toString());
+                    System.out.println("----");
+                    System.out.println("new material ...");
+                    System.out.println(material.toString());
+                }
         	}
         }        
     }

GeomConverter/test/org/lcsim/material
XMLMaterialManagerTest.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- XMLMaterialManagerTest.java	16 May 2007 23:27:39 -0000	1.6
+++ XMLMaterialManagerTest.java	9 Nov 2007 23:47:49 -0000	1.7
@@ -47,6 +47,12 @@
         }
     }
     
+    public void testSilicon() throws Exception
+    {
+        Material m = MaterialManager.instance().findMaterial("Silicon");
+        System.out.println(m.toString());
+    }
+    
     public void testLambdaNonzero() throws org.lcsim.material.MaterialNotFoundException
     {
         Material quartz = MaterialManager.instance().findMaterial("Quartz");
@@ -57,7 +63,7 @@
         quartzNIL = quartz.getNuclearInteractionLength();
         epoxyNIL = epoxy.getNuclearInteractionLength();
         g10NIL = g10.getNuclearInteractionLength();
-        
+                
         assertTrue(quartzNIL != 0);
         assertTrue(epoxyNIL != 0);
         assertTrue(g10NIL != 0);                
CVSspam 0.2.8