Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/pandora on MAIN
Main.java+24-61.4 -> 1.5
add sampling fractions to layers in pandora output

GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
Main.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- Main.java	28 Jan 2010 19:46:36 -0000	1.4
+++ Main.java	3 Feb 2010 21:02:00 -0000	1.5
@@ -1,5 +1,8 @@
 package org.lcsim.geometry.compact.converter.pandora;
 
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
+import org.lcsim.geometry.util.SamplingFractionManager;
 import static org.lcsim.geometry.Calorimeter.CalorimeterType.EM_BARREL;
 import static org.lcsim.geometry.Calorimeter.CalorimeterType.EM_ENDCAP;
 import static org.lcsim.geometry.Calorimeter.CalorimeterType.HAD_BARREL;
@@ -40,11 +43,22 @@
  * @author jeremym
  */
 public class Main implements Converter
-{    
+{   
+    private ConditionsManager conditionsManager = ConditionsManager.defaultInstance();
+ 
     public void convert(String inputFileName, InputStream in, OutputStream out) throws Exception
     {
         GeometryReader reader = new GeometryReader();
-        Detector det = reader.read(in);      
+        Detector det = reader.read(in);     
+        String detectorName = det.getDetectorName();
+        try 
+        {
+            conditionsManager.setDetector(detectorName,0);
+        }
+        catch (ConditionsNotFoundException x)
+        {
+                throw new RuntimeException("Failed to setup conditions system for detector: " + detectorName, x);
+        } 
         Document doc = convertDetectorToPandora(det);        
         XMLOutputter outputter = new XMLOutputter();                
         if (out != null)
@@ -66,6 +80,7 @@
         
         DecimalFormat xlen = new DecimalFormat("#.########");
         DecimalFormat xthick = new DecimalFormat("#.##");
+        DecimalFormat xfrac = new DecimalFormat("#.########");
         
         for ( Subdetector subdetector : detector.getSubdetectors().values() )
         {
@@ -130,7 +145,7 @@
                         
                         Element layerElem = new Element("layer");
                         layersElem.addContent(layerElem);
-                                                                                                                                                                     
+                     
                         double intLen = 0;
                         double radLen = 0;
                                                                                                
@@ -138,15 +153,18 @@
                         {
                             LayerSlice slice = layer.getSlice(j);
                             radLen += slice.getThickness() / slice.getMaterial().getRadiationLength();
-                            intLen += slice.getThickness() / slice.getMaterial().getNuclearInteractionLength();                            
+                            intLen += slice.getThickness() / slice.getMaterial().getNuclearInteractionLength();                       
                         }
                         
                         double layerD2 = layerD + layer.getThicknessToSensitiveMid();
-                        
+     
                         layerElem.setAttribute("distanceToIp", xthick.format(layerD2));
                         layerElem.setAttribute("radLen", xlen.format(radLen));
                         layerElem.setAttribute("intLen", xlen.format(intLen));
                         
+                        double samplingFraction = SamplingFractionManager.defaultInstance().getSamplingFraction(subdetector,i);
+                        layerElem.setAttribute("samplingFraction", xfrac.format(samplingFraction));
+
                         layerD += layer.getThickness();
                     }
                 }
@@ -225,4 +243,4 @@
             return "Pandora Geometry file (*.xml)";
         }
     }
-}
\ No newline at end of file
+}
CVSspam 0.2.8