GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
diff -N CalorimeterConditions.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalorimeterConditions.java 8 Feb 2012 19:59:04 -0000 1.1
@@ -0,0 +1,233 @@
+package org.lcsim.geometry.compact.converter.pandora;
+
+import static org.lcsim.geometry.Calorimeter.CalorimeterType.HAD_BARREL;
+import static org.lcsim.geometry.Calorimeter.CalorimeterType.HAD_ENDCAP;
+import static org.lcsim.geometry.Calorimeter.CalorimeterType.MUON_BARREL;
+import static org.lcsim.geometry.Calorimeter.CalorimeterType.MUON_ENDCAP;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.lcsim.conditions.ConditionsSet;
+import org.lcsim.geometry.Calorimeter;
+import org.lcsim.geometry.Calorimeter.CalorimeterType;
+
+/**
+ * Represents CalorimeterConditions for a single subdetector.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+// FIXME: Put into separate package from Pandora converter.
+public class CalorimeterConditions
+{
+ SamplingLayers samplingLayers;
+ String name;
+ double mipEnergy;
+ double mipSigma;
+ double mipCut;
+ double timeCut;
+
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+ buff.append(name + '\n');
+ for (SamplingLayerRange range : samplingLayers)
+ {
+ buff.append("[" + range.getLowerLayer() + " - " + range.getUpperLayer() + "]" + '\n');
+ buff.append(" em = " + range.getEMSampling() + '\n');
+ buff.append(" had = " + range.getHADSampling() + '\n');
+ }
+
+ return buff.toString();
+ }
+
+ public SamplingLayers getSamplingLayers()
+ {
+ return samplingLayers;
+ }
+
+ /**
+ * Constructor that parses raw CalorimeterCalibration conditions for a
+ * single subdetector.
+ *
+ * @param calorimeter
+ * @param conditions
+ */
+ public CalorimeterConditions(Calorimeter calorimeter, ConditionsSet conditions)
+ {
+ //System.out.println("conditions: " + calorimeter.getName());
+ this.name = calorimeter.getName();
+
+ // 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)
+ {
+ layeringName = "HCalLayering";
+ }
+ else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
+ {
+ layeringName = "MuonLayering";
+ }
+ else
+ {
+ throw new RuntimeException("Don't know how to handle CalorimeterConditions for " + calorimeter.getName() + ".");
+ }
+
+ String emName = null;
+ String hadName = null;
+ if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL)
+ {
+ emName = "EMBarrel_SF";
+ hadName = "HadBarrel_SF";
+ }
+ else if (calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
+ {
+ emName = "EMEndcap_SF";
+ hadName = "HadEndcap_SF";
+ }
+
+ if (emName == null || hadName == null)
+ {
+ throw new RuntimeException("Sampling fractions not found for " + calorimeter.getName() + ".");
+ }
+
+ String emSampling = conditions.getString(emName);
+ String hadSampling = conditions.getString(hadName);
+ List<Double> emSamplingFractions = new ArrayList<Double>();
+ List<Double> hadSamplingFractions = new ArrayList<Double>();
+ StringTokenizer tok = new StringTokenizer(emSampling, ",");
+ while (tok.hasMoreTokens())
+ {
+ Double emSamplingFraction = Double.valueOf(tok.nextToken().trim());
+ emSamplingFractions.add(emSamplingFraction);
+ }
+ tok = new StringTokenizer(hadSampling, ",");
+ while (tok.hasMoreTokens())
+ {
+ Double hadSamplingFraction = Double.valueOf(tok.nextToken().trim());
+ hadSamplingFractions.add(hadSamplingFraction);
+ }
+
+ String layering = conditions.getString(layeringName);
+ tok = new StringTokenizer(layering, ",");
+ List<Integer> layers = new ArrayList<Integer>();
+ int maxLayer = calorimeter.getLayering().getLayerCount() - 1;
+ while (tok.hasMoreTokens())
+ {
+ String nextToken = tok.nextToken().trim();
+ int nextLayer = Integer.valueOf(nextToken);
+ 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.
+ int samplingIndex = 0;
+ if (calorimeter.getCalorimeterType() == HAD_BARREL || calorimeter.getCalorimeterType() == HAD_ENDCAP)
+ {
+ samplingIndex = (new StringTokenizer(conditions.getString("ECalLayering"), ",").countTokens());
+ }
+ if (calorimeter.getCalorimeterType() == MUON_BARREL || calorimeter.getCalorimeterType() == MUON_ENDCAP)
+ {
+ samplingIndex = (new StringTokenizer(conditions.getString("ECalLayering"), ",").countTokens());
+ samplingIndex += (new StringTokenizer(conditions.getString("HCalLayering"), ",").countTokens());
+ }
+
+ // System.out.println(" samplingIndex: " + samplingIndex);
+
+ // Create the SamplingLayerRange list.
+ samplingLayers = new SamplingLayers();
+ for (int i = 0; i < layers.size(); i++)
+ {
+ // Figure out the layer range.
+ int lowerLayer = layers.get(i);
+ int upperLayer = 0;
+ if (i + 1 > layers.size() - 1)
+ upperLayer = maxLayer;
+ else
+ upperLayer = layers.get(i + 1) - 1;
+
+ // 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);
+
+ samplingLayers.add(samplingLayerRange);
+
+ ++samplingIndex;
+ }
+
+ // MIP energy.
+ String mipCondition = null;
+ String mipSigmaCondition = null;
+ String mipCutCondition = null;
+
+ // 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)
+ {
+ mipCondition = "HCalMip_MPV";
+ mipSigmaCondition = "HCalMip_sig";
+ mipCutCondition = "HCalMip_Cut";
+ }
+ else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
+ {
+ mipCondition = "MuonMip_MPV";
+ mipSigmaCondition = "MuonMip_sig";
+ mipCutCondition = "MuonMip_Cut";
+ }
+ mipEnergy = conditions.getDouble(mipCondition);
+ mipSigma = conditions.getDouble(mipSigmaCondition);
+ 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);
+ */
+ }
+
+ public SamplingLayerRange getSamplingLayerRange(int layer)
+ {
+ for (SamplingLayerRange layers : this.samplingLayers)
+ {
+ if (layers.inRange(layer))
+ return layers;
+ }
+ return null;
+ }
+
+ public double getMipEnergy()
+ {
+ return mipEnergy;
+ }
+
+ public double getMipSigma()
+ {
+ return mipSigma;
+ }
+
+ public double getMipCut()
+ {
+ return mipCut;
+ }
+
+ public double getTimeCut()
+ {
+ return timeCut;
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
diff -N SamplingLayerRange.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SamplingLayerRange.java 8 Feb 2012 19:59:04 -0000 1.1
@@ -0,0 +1,48 @@
+package org.lcsim.geometry.compact.converter.pandora;
+
+/**
+ * A range of layers with associated EM and HAD sampling fractions.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+// FIXME: Put into separate package from Pandora converter.
+public class SamplingLayerRange
+{
+ int lowerLayer;
+ int upperLayer;
+ double em;
+ double had;
+
+ SamplingLayerRange(int lowerLayer, int upperLayer, double em, double had)
+ {
+ this.lowerLayer = lowerLayer;
+ this.upperLayer = upperLayer;
+ this.em = em;
+ this.had = had;
+ }
+
+ public boolean inRange(int layerNumber)
+ {
+ return layerNumber >= lowerLayer && layerNumber <= upperLayer;
+ }
+
+ public int getLowerLayer()
+ {
+ return lowerLayer;
+ }
+
+ public int getUpperLayer()
+ {
+ return upperLayer;
+ }
+
+ public double getEMSampling()
+ {
+ return em;
+ }
+
+ public double getHADSampling()
+ {
+ return had;
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
diff -N SamplingLayers.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SamplingLayers.java 8 Feb 2012 19:59:04 -0000 1.1
@@ -0,0 +1,39 @@
+package org.lcsim.geometry.compact.converter.pandora;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A list of SamplingLayerRange objects to represent the sampling for a
+ * subdetector.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ *
+ */
+//FIXME: Put into separate package from Pandora converter.
+public class SamplingLayers extends ArrayList<SamplingLayerRange>
+{
+ public SamplingLayers()
+ {
+ }
+
+ public SamplingLayers(SamplingLayerRange range)
+ {
+ this.add(range);
+ }
+
+ public SamplingLayers(List<SamplingLayerRange> ranges)
+ {
+ this.addAll(ranges);
+ }
+
+ public SamplingLayerRange getSamplingLayerRange(int layern)
+ {
+ for (SamplingLayerRange range : this)
+ {
+ if (range.inRange(layern))
+ return range;
+ }
+ return null;
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/compact/converter/pandora
diff -u -r1.33 -r1.34
--- Main.java 17 Mar 2011 22:06:36 -0000 1.33
+++ Main.java 8 Feb 2012 19:59:04 -0000 1.34
@@ -16,7 +16,6 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
import javax.swing.filechooser.FileFilter;
@@ -32,7 +31,6 @@
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.compact.Subdetector;
@@ -53,7 +51,7 @@
* geometry input format.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: Main.java,v 1.33 2011/03/17 22:06:36 jeremy Exp $
+ * @version $Id: Main.java,v 1.34 2012/02/08 19:59:04 jeremy Exp $
*/
public class Main implements Converter
{
@@ -67,304 +65,6 @@
static final DecimalFormat xfrac = new DecimalFormat("#.########");
static final DecimalFormat xthick = new DecimalFormat("#.######");
- /**
- * A range of layers with associated EM and HAD sampling fractions.
- *
- * @author Jeremy McCormick <[log in to unmask]>
- */
- static class SamplingLayerRange
- {
- int lowerLayer;
- int upperLayer;
- double em;
- double had;
-
- SamplingLayerRange(int lowerLayer, int upperLayer, double em, double had)
- {
- this.lowerLayer = lowerLayer;
- this.upperLayer = upperLayer;
- this.em = em;
- this.had = had;
- }
-
- public boolean inRange(int layerNumber)
- {
- return layerNumber >= lowerLayer && layerNumber <= upperLayer;
- }
-
- public int getLowerLayer()
- {
- return lowerLayer;
- }
-
- public int getUpperLayer()
- {
- return upperLayer;
- }
-
- public double getEMSampling()
- {
- return em;
- }
-
- public double getHADSampling()
- {
- return had;
- }
- }
-
- /**
- * A list of SamplingLayerRange objects to represent the sampling for a
- * subdetector.
- *
- * @author Jeremy McCormick <[log in to unmask]>
- *
- */
- static class SamplingLayers extends ArrayList<SamplingLayerRange>
- {
- public SamplingLayers()
- {
- }
-
- public SamplingLayers(SamplingLayerRange range)
- {
- this.add(range);
- }
-
- public SamplingLayers(List<SamplingLayerRange> ranges)
- {
- this.addAll(ranges);
- }
-
- public SamplingLayerRange getSamplingLayerRange(int layern)
- {
- for (SamplingLayerRange range : this)
- {
- if (range.inRange(layern))
- return range;
- }
- return null;
- }
- }
-
- /**
- * Represents CalorimeterConditions for a single subdetector.
- *
- * @author Jeremy McCormick <[log in to unmask]>
- */
- private static class CalorimeterConditions
- {
- SamplingLayers samplingLayers;
- String name;
- double mipEnergy;
- double mipSigma;
- double mipCut;
- double timeCut;
-
- public String toString()
- {
- StringBuffer buff = new StringBuffer();
- buff.append(name + '\n');
- for (SamplingLayerRange range : samplingLayers)
- {
- buff.append("[" + range.getLowerLayer() + " - " + range.getUpperLayer() + "]" + '\n');
- buff.append(" em = " + range.getEMSampling() + '\n');
- buff.append(" had = " + range.getHADSampling() + '\n');
- }
-
- return buff.toString();
- }
-
- public SamplingLayers getSamplingLayers()
- {
- return samplingLayers;
- }
-
- /**
- * Constructor that parses raw CalorimeterCalibration conditions for a
- * single subdetector.
- *
- * @param calorimeter
- * @param conditions
- */
- protected CalorimeterConditions(Calorimeter calorimeter, ConditionsSet conditions)
- {
- //System.out.println("conditions: " + calorimeter.getName());
- this.name = calorimeter.getName();
-
- // 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)
- {
- layeringName = "HCalLayering";
- }
- else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
- {
- layeringName = "MuonLayering";
- }
- else
- {
- throw new RuntimeException("Don't know how to handle CalorimeterConditions for " + calorimeter.getName() + ".");
- }
-
- String emName = null;
- String hadName = null;
- if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL)
- {
- emName = "EMBarrel_SF";
- hadName = "HadBarrel_SF";
- }
- else if (calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
- {
- emName = "EMEndcap_SF";
- hadName = "HadEndcap_SF";
- }
-
- if (emName == null || hadName == null)
- {
- throw new RuntimeException("Sampling fractions not found for " + calorimeter.getName() + ".");
- }
-
- String emSampling = conditions.getString(emName);
- String hadSampling = conditions.getString(hadName);
- List<Double> emSamplingFractions = new ArrayList<Double>();
- List<Double> hadSamplingFractions = new ArrayList<Double>();
- StringTokenizer tok = new StringTokenizer(emSampling, ",");
- while (tok.hasMoreTokens())
- {
- Double emSamplingFraction = Double.valueOf(tok.nextToken().trim());
- emSamplingFractions.add(emSamplingFraction);
- }
- tok = new StringTokenizer(hadSampling, ",");
- while (tok.hasMoreTokens())
- {
- Double hadSamplingFraction = Double.valueOf(tok.nextToken().trim());
- hadSamplingFractions.add(hadSamplingFraction);
- }
-
- String layering = conditions.getString(layeringName);
- tok = new StringTokenizer(layering, ",");
- List<Integer> layers = new ArrayList<Integer>();
- int maxLayer = calorimeter.getLayering().getLayerCount() - 1;
- while (tok.hasMoreTokens())
- {
- String nextToken = tok.nextToken().trim();
- int nextLayer = Integer.valueOf(nextToken);
- 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.
- int samplingIndex = 0;
- if (calorimeter.getCalorimeterType() == HAD_BARREL || calorimeter.getCalorimeterType() == HAD_ENDCAP)
- {
- samplingIndex = (new StringTokenizer(conditions.getString("ECalLayering"), ",").countTokens());
- }
- if (calorimeter.getCalorimeterType() == MUON_BARREL || calorimeter.getCalorimeterType() == MUON_ENDCAP)
- {
- samplingIndex = (new StringTokenizer(conditions.getString("ECalLayering"), ",").countTokens());
- samplingIndex += (new StringTokenizer(conditions.getString("HCalLayering"), ",").countTokens());
- }
-
- // System.out.println(" samplingIndex: " + samplingIndex);
-
- // Create the SamplingLayerRange list.
- samplingLayers = new SamplingLayers();
- for (int i = 0; i < layers.size(); i++)
- {
- // Figure out the layer range.
- int lowerLayer = layers.get(i);
- int upperLayer = 0;
- if (i + 1 > layers.size() - 1)
- upperLayer = maxLayer;
- else
- upperLayer = layers.get(i + 1) - 1;
-
- // 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);
-
- samplingLayers.add(samplingLayerRange);
-
- ++samplingIndex;
- }
-
- // MIP energy.
- String mipCondition = null;
- String mipSigmaCondition = null;
- String mipCutCondition = null;
-
- // 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)
- {
- mipCondition = "HCalMip_MPV";
- mipSigmaCondition = "HCalMip_sig";
- mipCutCondition = "HCalMip_Cut";
- }
- else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP)
- {
- mipCondition = "MuonMip_MPV";
- mipSigmaCondition = "MuonMip_sig";
- mipCutCondition = "MuonMip_Cut";
- }
- mipEnergy = conditions.getDouble(mipCondition);
- mipSigma = conditions.getDouble(mipSigmaCondition);
- 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);
- */
- }
-
- public SamplingLayerRange getSamplingLayerRange(int layer)
- {
- for (SamplingLayerRange layers : this.samplingLayers)
- {
- if (layers.inRange(layer))
- return layers;
- }
- return null;
- }
-
- public double getMipEnergy()
- {
- return mipEnergy;
- }
-
- public double getMipSigma()
- {
- return mipSigma;
- }
-
- public double getMipCut()
- {
- return mipCut;
- }
-
- public double getTimeCut()
- {
- return timeCut;
- }
- }
-
public void convert(String inputFileName, InputStream in, OutputStream out) throws Exception
{
GeometryReader reader = new GeometryReader();