Commit in GeomConverter/src/org/lcsim/material on MAIN
Material.java+36-1091.12 -> 1.13
Values for NIL and RL with density are now cached at material creation time.  Functions added to retrieve these values.

GeomConverter/src/org/lcsim/material
Material.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- Material.java	5 Jul 2005 23:11:39 -0000	1.12
+++ Material.java	7 Jul 2005 00:48:36 -0000	1.13
@@ -18,29 +18,14 @@
  */
 public class Material
 {
-    /* Default temperature in kelvin = 1.0 */
+    /* Default temperature in kelvin */
     public static final double DEFAULT_TEMPERATURE = 273.15;
     
     /* Default pressure in atmospheres = 1.0 */
-    public static final double DEFAULT_PRESSURE = 1.0;
-    
-    /* 1 mole */
-    //public static final double AVOGADRO = 6.022136736e23;
+    public static final double DEFAULT_PRESSURE = 1.0;    
     
     public static final double MAX_RADIATION_LENGTH = java.lang.Double.MAX_VALUE;
-    public static final double MAX_NUCLEAR_INTERACTION_LENGTH = java.lang.Double.MAX_VALUE;
-    
-    /* nuclear interaction length factor in g/cm2 */
-    public static final double LAMBDA0 = 35.0;
-    
-    /* atomic mass unit (rest mass) in MeV */
-    //public static final double AMU_C2 = 931.49432;
-    
-    /* speed of light in mm/s */
-    //public static final double C_LIGHT = 299.792458;
-    
-    /* atomic mass unit */
-    //public static final double AMU = AMU_C2 / (C_LIGHT * C_LIGHT);
+    public static final double MAX_NUCLEAR_INTERACTION_LENGTH = java.lang.Double.MAX_VALUE;    
     
     double _temp;
     double _pressure;
@@ -53,33 +38,26 @@
     String _name;
     String _formula;
     
+    int _nComponents;
+    int _nComponentsMax;
+    int _nElements;    
+    
     private List<MaterialElement> _elements = new ArrayList<MaterialElement>();
     private List<Double> _massFractions = new ArrayList<Double>();
     private List<Integer> _atoms = new ArrayList<Integer>();
-    private List<Double> _nAtomsPerVolume = new ArrayList<Double>();
-    
-    /* electrons per element */
-    //double _totalElectronsPerVolume;
+    private List<Double> _nAtomsPerVolume = new ArrayList<Double>();    
     
-    /* radiation length */
+    /* radiation length in g/cm2 */
     double _radiationLength;
     
+    /* radiation length in cm, taking into account the density */
+    double _radiationLengthWithDensity;    
+    
     /* nuclear interaction length in g/cm2 */
     double _nuclearInteractionLength;
     
-    int _nComponents;
-    int _nComponentsMax;
-    int _nElements;
-    
-    /*
-    public Material()
-    {
-        _Z=0;
-        _state = MaterialState.UNKNOWN;
-        _isElement = false;
-        _name = "Vacuum";
-    }
-     */
+    /* NIL in cm, taking into account the density */
+    double _nuclearInteractionLengthWithDensity;        
     
     /* Construct base material with all info, creating a MaterialElement, also. */
     public Material(String name,
@@ -296,8 +274,7 @@
                     ++_nElements;
                 }
             }
-            ++_nComponents;
-            //System.out.println("ncomp, ncompmax: " + _nComponents + " " +_nComponentsMax);
+            ++_nComponents;            
         }
         else
         {
@@ -325,15 +302,7 @@
         }
         
         if ( abs(1 - weightSum) > 0.001 )
-        {
-            //System.err.println("bad weight sum: " + weightSum);
-            
-            //System.out.println("listing weights...");
-            //for ( int i = 0; i < _massFractions.size(); i++)
-            //{
-            //System.out.println(_elements.get(i).getName() + " = " + _massFractions.get(i));
-            //}
-            
+        {            
             throw new RuntimeException("Mass fractions do not sum to 1 within 0.001 tolerance for this material: " + getName() );
         }
     }
@@ -364,8 +333,7 @@
     }
     
     public void computeDerivedQuantities()
-    {
-        //computeNAtomsPerVolume();
+    {        
         computeRadiationLength();
         computeNuclearInteractionLength();
     }
@@ -381,7 +349,8 @@
             NILinv += _massFractions.get(i) / me.getNuclearInteractionLength();
         }
         
-        _nuclearInteractionLength = (NILinv <= 0.0 ? MAX_NUCLEAR_INTERACTION_LENGTH : 1.0/NILinv);
+        _nuclearInteractionLength = (NILinv <= 0.0 ? MAX_NUCLEAR_INTERACTION_LENGTH : 1.0/NILinv);        
+        _nuclearInteractionLengthWithDensity = _nuclearInteractionLength / _density;
         
         return NILinv;
     }
@@ -397,71 +366,34 @@
             rlinv += _massFractions.get(i) / me.getRadiationLength();
         }
         
-        _radiationLength = (rlinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0/rlinv);
+        _radiationLength = (rlinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0/rlinv);        
+        _radiationLengthWithDensity = _radiationLength / _density;
         
-        return rlinv;
-    }
-    
-    /* These are from Geant4 and kind of overkill for us right now.*/
-    /*
-    public void computeNAtomsPerVolume()
-    {
-        double Zi, Ai;
-        _totalElectronsPerVolume = 0.0;
-     
-        for ( int i = 0; i < _nElements; i++)
-        {
-            Zi = _elements.get(i).getZ();
-            Ai = _elements.get(i).getA();
-            double nElec = AVOGADRO * _density * _massFractions.get(i) / Ai;
-            _nAtomsPerVolume.add(i, nElec);
-            _totalElectronsPerVolume += _nAtomsPerVolume.get(i);
-            _totalElectronsPerVolume += _nAtomsPerVolume.get(i) * Zi;
-        }
-    }
-     
-    void computeRadiationLength()
-    {
-        double radinv = 0.0;
-        for ( int i = 0; i < _nElements; i++)
-        {
-            radinv += _nAtomsPerVolume.get(i) * ( _elements.get(i).getTsaiFactor() );
-        }
-        _radiationLength = ( radinv <= 0.0 ? MAX_RADIATION_LENGTH : 1.0 / radinv);
-    }
-     */
-    
-    /** compute nuclear interaction length in g/cm2 */
-    /*
-    void computeNuclearInteractionLength()
-    {
-        double NILinv = 0.0;
-        for ( int i = 0; i < _nElements; i++)
-        {
-            NILinv += _nAtomsPerVolume.get(i) * pow(_elements.get(i).getN(), 0.6666667);
-        }
-        NILinv *= AMU/LAMBDA0;
-     
-        _nuclearInteractionLength = (NILinv <= 0.0 ? MAX_NUCLEAR_INTERACTION_LENGTH : 1.0/NILinv);
+        return _radiationLength;
     }
-     */
-    
+       
     public double getRadiationLength()
     {
         return _radiationLength;
     }
     
-    /* get radiation length for this material in mm */
-    public double getNuclearInteractionLengthForMaterial()
+    public double getNuclearInteractionLength()
     {
-        return ( _nuclearInteractionLength / _density) * 10;
+        return _nuclearInteractionLength;
     }
     
-    public double getNuclearInteractionLength()
+    /* get NIL/density in cm */
+    public double getNuclearInteractionLengthWithDensity()
     {
-        return _nuclearInteractionLength;
+        return _nuclearInteractionLengthWithDensity;
     }
     
+    /* get RL/density in cm */
+    public double getRadiationLengthWithDensity()
+    {
+        return _radiationLengthWithDensity;
+    }        
+    
     public String toString()
     {
         return "Material=" + getName() + "; nComponents=" + _nComponents +
@@ -469,12 +401,7 @@
                 "pressure=" + _pressure + "; density=" + _density +
                 "; state=" + _state.toString() + "\t\n" + "NIL=" + 
                 _nuclearInteractionLength + "; RL=" + _radiationLength +
-                "; NILmat=" + getNuclearInteractionLengthForMaterial();                
-        
-        //+ "elecPerVol=" +
-        //        _totalElectronsPerVolume 
-        //        +
-        //                "; NILestimate: " + estimateNuclearInteractionLength() +
-        //                "; RLestimate: " + estimateRadiationLength();
+                "; NILdens=" + getNuclearInteractionLengthWithDensity() +
+                "; RLdens=" + getRadiationLengthWithDensity();        
     }
 }
\ No newline at end of file
CVSspam 0.2.8