Print

Print


Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/pandora on MAIN
Main.java+68-471.21 -> 1.22
correct the XY to UV cell dimension mapping; it is flipped for polyhedra barrels; needs to be tested

GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
Main.java 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- Main.java	30 Sep 2010 18:18:17 -0000	1.21
+++ Main.java	6 Oct 2010 23:57:19 -0000	1.22
@@ -15,9 +15,7 @@
 import java.io.OutputStream;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.StringTokenizer;
 
 import javax.swing.filechooser.FileFilter;
@@ -27,16 +25,16 @@
 import org.jdom.output.Format;
 import org.jdom.output.XMLOutputter;
 import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.conditions.ConditionsSet;
 import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
+import org.lcsim.conditions.ConditionsSet;
 import org.lcsim.detector.material.BetheBlochCalculator;
 import org.lcsim.detector.material.IMaterial;
 import org.lcsim.detector.material.MaterialStore;
 import org.lcsim.detector.solids.Tube;
 import org.lcsim.geometry.Calorimeter;
+import org.lcsim.geometry.Calorimeter.CalorimeterType;
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.GeometryReader;
-import org.lcsim.geometry.Calorimeter.CalorimeterType;
 import org.lcsim.geometry.compact.Field;
 import org.lcsim.geometry.compact.Subdetector;
 import org.lcsim.geometry.compact.converter.Converter;
@@ -55,7 +53,7 @@
  * geometry input format.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: Main.java,v 1.21 2010/09/30 18:18:17 jeremy Exp $
+ * @version $Id: Main.java,v 1.22 2010/10/06 23:57:19 jeremy Exp $
  */
 public class Main implements Converter
 {
@@ -192,21 +190,25 @@
          */
         protected CalorimeterConditions(Calorimeter calorimeter, ConditionsSet conditions)
         {
-            System.out.println("conditions: " + calorimeter.getName());
+            // System.out.println("conditions: " + calorimeter.getName());
             this.name = calorimeter.getName();
 
-            // Figure out which layering conditions to use based on the CalorimeterType.
+            // Figure out which layering conditions to use based on the
+            // CalorimeterType.
             String layeringName = null;
             if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP)
             {
                 layeringName = "ECalLayering";
-            } else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP)
+            }
+            else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP)
             {
                 layeringName = "HCalLayering";
-            } else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
+            }
+            else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
             {
                 layeringName = "MuonLayering";
-            } else
+            }
+            else
             {
                 throw new RuntimeException("Don't know how to handle CalorimeterConditions for " + calorimeter.getName() + ".");
             }
@@ -217,7 +219,8 @@
             {
                 emName = "EMBarrel_SF";
                 hadName = "HadBarrel_SF";
-            } else if (calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
+            }
+            else if (calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
             {
                 emName = "EMEndcap_SF";
                 hadName = "HadEndcap_SF";
@@ -256,8 +259,9 @@
                 layers.add(nextLayer);
             }
 
-            // FIXME Hack to get the correct starting index for the sampling fractions.  Ideally, the sampling fractions
-            //       should be separated by subdetector name.
+            // FIXME Hack to get the correct starting index for the sampling
+            // fractions. Ideally, the sampling fractions
+            // should be separated by subdetector name.
             int samplingIndex = 0;
             if (calorimeter.getCalorimeterType() == HAD_BARREL || calorimeter.getCalorimeterType() == HAD_ENDCAP)
             {
@@ -269,7 +273,7 @@
                 samplingIndex += (new StringTokenizer(conditions.getString("HCalLayering"), ",").countTokens());
             }
 
-            System.out.println("    samplingIndex: " + samplingIndex);
+            // System.out.println("    samplingIndex: " + samplingIndex);
 
             // Create the SamplingLayerRange list.
             samplingLayers = new SamplingLayers();
@@ -283,15 +287,12 @@
                 else
                     upperLayer = layers.get(i + 1) - 1;
 
-                // Create the sampling layer range.                
+                // Create the sampling layer range.
                 double emSamplingFraction = emSamplingFractions.get(samplingIndex);
                 double hadSamplingFraction = hadSamplingFractions.get(samplingIndex);
-                SamplingLayerRange samplingLayerRange = new SamplingLayerRange(
-                        lowerLayer,
-                        upperLayer,
-                        emSamplingFraction,
-                        hadSamplingFraction);
-                System.out.println("    " + lowerLayer + " - " + upperLayer + " : " + emSamplingFraction + ", " + hadSamplingFraction);
+                SamplingLayerRange samplingLayerRange = new SamplingLayerRange(lowerLayer, upperLayer, emSamplingFraction, hadSamplingFraction);
+                // System.out.println("    " + lowerLayer + " - " + upperLayer +
+                // " : " + emSamplingFraction + ", " + hadSamplingFraction);
 
                 samplingLayers.add(samplingLayerRange);
 
@@ -302,20 +303,21 @@
             String mipCondition = null;
             String mipSigmaCondition = null;
             String mipCutCondition = null;
-            if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL
-                    || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP)
+            
+            // FIXME: Cleanup this ugliness.
+            if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP)
             {
                 mipCondition = "ECalMip_MPV";
                 mipSigmaCondition = "ECalMip_sig";
                 mipCutCondition = "ECalMip_Cut";
-            } else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL
-                    || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP)
+            }
+            else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP)
             {
                 mipCondition = "HCalMip_MPV";
                 mipSigmaCondition = "HCalMip_sig";
                 mipCutCondition = "HCalMip_Cut";
-            }else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL
-                    || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
+            }
+            else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
             {
                 mipCondition = "MuonMip_MPV";
                 mipSigmaCondition = "MuonMip_sig";
@@ -326,10 +328,12 @@
             mipCut = conditions.getDouble(mipCutCondition);
             timeCut = conditions.getDouble("timeCut");
 
-            System.out.println("    mipEnergy: " + mipEnergy);
-            System.out.println("    mipSigma: " + mipSigma);
-            System.out.println("    mipCut: " + mipCut);
-            System.out.println("    timeCut: " + timeCut);
+            /*
+             * System.out.println("    mipEnergy: " + mipEnergy);
+             * System.out.println("    mipSigma: " + mipSigma);
+             * System.out.println("    mipCut: " + mipCut);
+             * System.out.println("    timeCut: " + timeCut);
+             */
         }
 
         public SamplingLayerRange getSamplingLayerRange(int layer)
@@ -371,7 +375,8 @@
         try
         {
             conditionsManager.setDetector(detectorName, 0);
-        } catch (ConditionsNotFoundException x)
+        }
+        catch (ConditionsNotFoundException x)
         {
             throw new RuntimeException("Failed to setup conditions system for detector: " + detectorName, x);
         }
@@ -399,13 +404,14 @@
         try
         {
             calorimeterCalibration = conditionsManager.getConditions("CalorimeterCalibration");
-        } 
+        }
         catch (Exception x)
-        {}
+        {
+        }
         boolean haveCalCalib = (calorimeterCalibration == null) ? false : true;
 
         // Setup QCalCalibration.
-        //QCalCalibration qcalib = new QCalCalibration(detector);
+        // QCalCalibration qcalib = new QCalCalibration(detector);
 
         // Process the subdetectors.
         for (Subdetector subdetector : detector.getSubdetectors().values())
@@ -416,7 +422,8 @@
                 Element calorimeter = new Element("calorimeter");
                 AbstractPolyhedraCalorimeter polycal = (AbstractPolyhedraCalorimeter) subdetector;
 
-                // Look for specific calorimeter types in the compact description.
+                // Look for specific calorimeter types in the compact
+                // description.
                 Calorimeter.CalorimeterType calType = polycal.getCalorimeterType();
                 if (calType.equals(HAD_BARREL) || calType.equals(HAD_ENDCAP) || calType.equals(EM_ENDCAP) || calType.equals(EM_BARREL) || calType.equals(MUON_BARREL) || calType.equals(MUON_ENDCAP))
                 {
@@ -432,10 +439,21 @@
                     calorimeter.setAttribute("outerSymmetryOrder", Double.toString(polycal.getOuterNumberOfSides()));
                     calorimeter.setAttribute("collection", subdetector.getReadout().getName());
 
-                    // Set cell sizes.
+                    // Get the cell sizes from the segmentation.
                     List<Double> cellSizes = getCellSizes(subdetector);
-                    calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(0)));
-                    calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(1)));
+                    
+                    // For endcaps, X is U, and Y is V.
+                    if (subdetector.isEndcap())
+                    {
+                        calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(0)));
+                        calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(1)));
+                    }
+                    // The UV mapping is flipped around for barrel.  X is V, and Y is U.
+                    else if (subdetector.isBarrel())
+                    {
+                        calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(1)));
+                        calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(0)));
+                    }
 
                     // Create identifier description and add to subdet.
                     calorimeter.addContent(makeIdentifierDescription(polycal));
@@ -455,7 +473,8 @@
                     if (polycal.isBarrel())
                     {
                         layerD = polycal.getInnerR();
-                    } else if (polycal.isEndcap())
+                    }
+                    else if (polycal.isEndcap())
                     {
                         layerD = polycal.getInnerZ();
                     }
@@ -475,7 +494,7 @@
                         calorimeter.setAttribute("mipCut", xfrac.format(subdetectorCalorimeterConditions.getMipCut()));
                         calorimeter.setAttribute("timeCut", xfrac.format(subdetectorCalorimeterConditions.getTimeCut()));
                     } // Set MIP energy from Bethe-Bloche calculation.
-                    // TODO Check accuracy of this algorithm.
+                      // TODO Check accuracy of this algorithm.
                     else
                     {
                         List<LayerSlice> sensors = subdetector.getLayering().getLayerStack().getLayer(0).getSensors();
@@ -516,14 +535,15 @@
                         layerElem.setAttribute("radLen", xlen.format(radLen));
                         layerElem.setAttribute("intLen", xlen.format(intLen));
 
-                        // Set distance to IP.                        
+                        // Set distance to IP.
                         double layerD2 = layerD + layer.getThicknessToSensitiveMid();
                         layerElem.setAttribute("distanceToIp", xthick.format(layerD2));
 
-                        // Set cell thickness. 
+                        // Set cell thickness.
                         layerElem.setAttribute("cellThickness", xthick.format(layer.getSensorThickness()));
 
-                        // Set EM and HAD sampling fractions from CalorimeterCalibration conditions, if present.
+                        // Set EM and HAD sampling fractions from
+                        // CalorimeterCalibration conditions, if present.
                         if (haveCalCalib)
                         {
                             SamplingLayerRange layerRange = subdetectorCalorimeterConditions.getSamplingLayerRange(i);
@@ -541,8 +561,9 @@
                             }
                             layerElem.setAttribute("emSamplingFraction", xfrac.format(layerRange.getEMSampling()));
                             layerElem.setAttribute("hadSamplingFraction", xfrac.format(layerRange.getHADSampling()));
-                        } 
-                        // Set from base SamplingFraction conditions.  May throw an exception if neither CalorimeterCalibration
+                        }
+                        // Set from base SamplingFraction conditions. May throw
+                        // an exception if neither CalorimeterCalibration
                         // or SamplingFractions conditions exists.
                         else
                         {
@@ -563,7 +584,7 @@
                     ConditionsSet conditions = conditionsManager.getConditions("SamplingFractions/" + subdetector.getName());
                     boolean isDigital = conditions.getBoolean("digital");
                     calorimeter.setAttribute("digital", String.valueOf(isDigital));
-                } 
+                }
                 catch (Exception x)
                 {
                     calorimeter.setAttribute("digital", "false");
CVSspam 0.2.8