Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/pandora on MAIN
Main.java+31-111.6 -> 1.7
write out detailed identifier information to pandora geometry output file

GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
Main.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- Main.java	8 Feb 2010 23:19:16 -0000	1.6
+++ Main.java	24 Feb 2010 00:27:21 -0000	1.7
@@ -1,8 +1,5 @@
 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;
@@ -21,6 +18,8 @@
 import org.jdom.Element;
 import org.jdom.output.Format;
 import org.jdom.output.XMLOutputter;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
 import org.lcsim.detector.solids.Tube;
 import org.lcsim.geometry.Calorimeter;
 import org.lcsim.geometry.Detector;
@@ -35,6 +34,8 @@
 import org.lcsim.geometry.segmentation.AbstractCartesianGrid;
 import org.lcsim.geometry.subdetector.AbstractPolyhedraCalorimeter;
 import org.lcsim.geometry.util.BaseIDDecoder;
+import org.lcsim.geometry.util.IDDescriptor;
+import org.lcsim.geometry.util.SamplingFractionManager;
 
 /**
  * This class converts from a compact detector description to a format
@@ -45,6 +46,9 @@
 public class Main implements Converter
 {   
     private ConditionsManager conditionsManager = ConditionsManager.defaultInstance();
+    static final DecimalFormat xlen = new DecimalFormat("#.########");
+    static final DecimalFormat xfrac = new DecimalFormat("#.########");
+    static final DecimalFormat xthick = new DecimalFormat("#.######");        
  
     public void convert(String inputFileName, InputStream in, OutputStream out) throws Exception
     {
@@ -77,11 +81,7 @@
         
         Element calorimeters = new Element("calorimeters");
         root.addContent(calorimeters);
-        
-        DecimalFormat xlen = new DecimalFormat("#.########");
-        DecimalFormat xfrac = new DecimalFormat("#.########");
-        DecimalFormat xthick = new DecimalFormat("#.######");        
-        
+                
         for ( Subdetector subdetector : detector.getSubdetectors().values() )
         {
             // Only handle polyhedra calorimeters for now.
@@ -115,9 +115,11 @@
                     calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(0)));
                     calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(1)));
                     
-                    Element iddesc = new Element("id");
-                    iddesc.setText(polycal.getReadout().getIDDescriptor().toString());
-                    calorimeter.addContent(iddesc);
+                    //Element iddesc = new Element("id");
+                    //iddesc.setText(polycal.getReadout().getIDDescriptor().toString());
+                    
+                    // Create identifier description and add to subdet.
+                    calorimeter.addContent(makeIdentifierDescription(polycal));
                     
                     calorimeters.addContent(calorimeter);
                     
@@ -165,6 +167,7 @@
                         
                         double samplingFraction = SamplingFractionManager.defaultInstance().getSamplingFraction(subdetector,i);
                         layerElem.setAttribute("samplingFraction", xfrac.format(samplingFraction));
+                        // TODO: Add separate EM + HAD sampling fractions here.
 
                         layerD += layer.getThickness();
                     }
@@ -197,6 +200,23 @@
         return outputDoc;        
     }
     
+    Element makeIdentifierDescription(Subdetector subdet)
+    {
+        IDDescriptor descr = subdet.getIDDecoder().getIDDescription();
+        Element id = new Element("id");
+        for (int i=0, j=descr.fieldCount(); i<j; i++)
+        {
+            Element field = new Element("field");
+            field.setAttribute("name", descr.fieldName(i));
+            field.setAttribute("length", Integer.toString(descr.fieldLength(i)));
+            field.setAttribute("start", Integer.toString(descr.fieldStart(i)));
+            field.setAttribute("signed", Boolean.toString(descr.isSigned(i)));
+            
+            id.addContent(field);
+        }
+        return id;
+    }
+    
     private List<Double> getCellSizes(Subdetector subdetector)
     {
         List<Double> cellSizes = new ArrayList<Double>();
CVSspam 0.2.8