lcsim/src/org/lcsim/recon/util
diff -N CalInfoDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalInfoDriver.java 12 Jan 2010 22:59:10 -0000 1.1
@@ -0,0 +1,20 @@
+package org.lcsim.recon.util;
+
+import org.lcsim.util.Driver;
+import org.lcsim.geometry.Detector;
+/**
+ * Driver to initialize CalorimeterInformation class
+ * @author cassell
+ */
+public class CalInfoDriver extends Driver
+{
+ CalorimeterInformation ci;
+ public CalInfoDriver()
+ {
+ }
+ protected void detectorChanged(Detector d)
+ {
+ ci = new CalorimeterInformation();
+ ci.init(d);
+ }
+}
lcsim/src/org/lcsim/recon/util
diff -N CalorimeterInformation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalorimeterInformation.java 12 Jan 2010 22:59:10 -0000 1.1
@@ -0,0 +1,480 @@
+package org.lcsim.recon.util;
+
+/**
+ * Stores often needed Calorimeter information for easy access
+ * @author cassell
+ */
+import java.util.*;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Calorimeter;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.subdetector.*;
+
+public class CalorimeterInformation
+{
+ static CalorimeterInformation theCalorimeterInformation;
+ private int ncal = 0;
+ private List<Subdetector> sublist;
+ private Subdetector[] subdetector;
+ private IDDecoder[] idd;
+ private String[] subtype;
+ private String[] name;
+ private String[] collname;
+ private String[] digicollname;
+ private int[] sysid;
+ private int[] nlayers;
+ private double[] rmin;
+ private double[] rmax;
+ private double[] zmin;
+ private double[] zmax;
+ private Map<Calorimeter.CalorimeterType,Integer> indexmap;
+ private int index;
+ public CalorimeterInformation()
+ {
+ theCalorimeterInformation = this;
+ }
+ public static CalorimeterInformation instance()
+ {
+ return theCalorimeterInformation;
+ }
+ /**
+ * Initialize values from the Detector
+ * @param Detector
+ */
+ protected void init(Detector d)
+ {
+ sublist = new ArrayList<Subdetector>();
+ for(Subdetector s:d.getSubdetectors().values())
+ {
+ if(s.isCalorimeter())
+ {
+ if(s.getReadout() == null)
+ {
+ System.out.println("Subdetector "+s.getName()+" isCalorimeter but has null Readout");
+ }
+ else
+ {
+ sublist.add( s );
+ System.out.println("Adding subdetector "+s.getName());
+ }
+ }
+ }
+ ncal = sublist.size();
+ subdetector = new Subdetector[ncal];
+ idd = new IDDecoder[ncal];
+ subtype = new String[ncal];
+ name = new String[ncal];
+ collname = new String[ncal];
+ digicollname = new String[ncal];
+ sysid = new int[ncal];
+ nlayers = new int[ncal];
+ rmin = new double[ncal];
+ rmax = new double[ncal];
+ zmin = new double[ncal];
+ zmax = new double[ncal];
+ indexmap = new HashMap<Calorimeter.CalorimeterType,Integer>();
+ for(int i=0;i<ncal;i++)
+ {
+ Subdetector s = sublist.get(i);
+ subdetector[i] = s;
+ name[i] = s.getName();
+ sysid[i] = s.getSystemID();
+ nlayers[i] = s.getLayering().getNumberOfLayers();
+ Calorimeter c = (Calorimeter) s;
+ indexmap.put(c.getCalorimeterType(),i);
+ idd[i] = subdetector[i].getIDDecoder();
+ if(idd[i] == null)System.out.println("null IDDecoder for subdector "+subdetector[i].getName());
+ collname[i] = subdetector[i].getReadout().getName();
+ digicollname[i] = new String(collname[i]).replace("Hits","DigiHits");
+ if(s.isBarrel())
+ {
+ if(s instanceof CylindricalBarrelCalorimeter)
+ {
+ subtype[i] = "CylindricalBarrelCalorimeter";
+ CylindricalBarrelCalorimeter b = (CylindricalBarrelCalorimeter) s;
+ rmin[i] = b.getInnerRadius();
+ rmax[i] = b.getOuterRadius();
+ zmin[i] = b.getZMin();
+ zmax[i] = b.getZMax();
+ }
+ else if(s instanceof PolyhedraBarrelCalorimeter)
+ {
+ subtype[i] = "PolyhedraBarrelCalorimeter";
+ PolyhedraBarrelCalorimeter b = (PolyhedraBarrelCalorimeter) s;
+ rmin[i] = b.getInnerR();
+ rmax[i] = b.getOuterR();
+ zmin[i] = b.getZMin();
+ zmax[i] = b.getZMax();
+ }
+ else if(s instanceof EcalBarrel)
+ {
+ subtype[i] = "EcalBarrel";
+ EcalBarrel b = (EcalBarrel) s;
+ rmin[i] = b.getInnerR();
+ rmax[i] = b.getOuterR();
+ zmin[i] = b.getZMin();
+ zmax[i] = b.getZMax();
+ }
+ else
+ {
+ System.out.println("Barrel calorimeter "+name[i]+" is unknown type");
+ subtype[i] = "unknown";
+ }
+ }
+ else if(c.isEndcap())
+ {
+ if(s instanceof CylindricalEndcapCalorimeter)
+ {
+ subtype[i] = "CylindricalEndcapCalorimeter";
+ CylindricalEndcapCalorimeter e = (CylindricalEndcapCalorimeter) s;
+ rmin[i] = e.getInnerRadius();
+ rmax[i] = e.getOuterRadius();
+ zmin[i] = e.getZMin();
+ zmax[i] = e.getZMax();
+ }
+ else if(s instanceof PolyhedraEndcapCalorimeter)
+ {
+ subtype[i] = "PolyhedraEndcapCalorimeter";
+ PolyhedraEndcapCalorimeter e = (PolyhedraEndcapCalorimeter) s;
+ rmin[i] = e.getInnerR();
+ rmax[i] = e.getOuterR();
+ zmin[i] = e.getZMin();
+ zmax[i] = e.getZMax();
+ }
+ else if(s instanceof PolyhedraEndcapCalorimeter2)
+ {
+ subtype[i] = "PolyhedraEndcapCalorimeter2";
+ PolyhedraEndcapCalorimeter2 e = (PolyhedraEndcapCalorimeter2) s;
+ rmin[i] = e.getInnerR();
+ rmax[i] = e.getOuterR();
+ zmin[i] = e.getZMin();
+ zmax[i] = e.getZMax();
+ }
+ else
+ {
+ System.out.println("Endcap calorimeter "+name[i]+" is unknown type");
+ subtype[i] = "unknown";
+
+ }
+ }
+ else
+ {
+ System.out.println("Calorimeter "+name[i]+" is not barrel or endcap: Information lost");
+ subtype[i] = "unknown";
+ }
+ }
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return Subdetector
+ */
+ public Subdetector getSubdetector(String s)
+ {
+ return getSubdetector(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return Subdetector
+ */
+ public Subdetector getSubdetector(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return null;
+ }
+ index = ind.intValue();
+ return subdetector[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return IDDecoder for this calorimeter
+ */
+ public IDDecoder getIDDecoder(String s)
+ {
+ return getIDDecoder(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return IDDecoder for this calorimeter
+ */
+ public IDDecoder getIDDecoder(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return null;
+ }
+ index = ind.intValue();
+ return idd[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the calorimeter name
+ */
+ public String getName(String s)
+ {
+ return getName(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the calorimeter name
+ */
+ public String getName(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return null;
+ }
+ index = ind.intValue();
+ return name[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the collection name for this calorimeter
+ */
+ public String getCollectionName(String s)
+ {
+ return getCollectionName(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the collection name for this calorimeter
+ */
+ public String getCollectionName(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return null;
+ }
+ index = ind.intValue();
+ return collname[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the DigiSim output collection name
+ */
+ public String getDigiCollectionName(String s)
+ {
+ return getDigiCollectionName(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the DigiSim output collection name
+ */
+ public String getDigiCollectionName(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return null;
+ }
+ index = ind.intValue();
+ return digicollname[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the segmentation type
+ */
+ public String getCalorimeterType(String s)
+ {
+ return getCalorimeterType(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the segmentation type
+ */
+ public String getCalorimeterType(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return null;
+ }
+ index = ind.intValue();
+ return subtype[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return integer system ID
+ */
+ public int getSystemID(String s)
+ {
+ return getSystemID(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return integer system ID
+ */
+ public int getSystemID(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return -1;
+ }
+ index = ind.intValue();
+ return sysid[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return # layers
+ */
+ public int getNLayers(String s)
+ {
+ return getNLayers(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return # layers
+ */
+ public int getNLayers(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return -1;
+ }
+ index = ind.intValue();
+ return nlayers[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the maximum radius
+ */
+ public double getRMax(String s)
+ {
+ return getRMax(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the maximum radius
+ */
+ public double getRMax(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return -1.;
+ }
+ index = ind.intValue();
+ return rmax[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the Minimum radius
+ */
+ public double getRMin(String s)
+ {
+ return getRMin(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the minimum radius
+ */
+ public double getRMin(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return -1.;
+ }
+ index = ind.intValue();
+ return rmin[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the minimum z
+ */
+ public double getZMin(String s)
+ {
+ return getZMin(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the minimum z
+ */
+ public double getZMin(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return -1.;
+ }
+ index = ind.intValue();
+ return zmin[index];
+ }
+ /**
+ *
+ * @param String representation of Calorimeter type
+ * @return the maximum z
+ */
+ public double getZMax(String s)
+ {
+ return getZMax(Calorimeter.CalorimeterType.fromString(s));
+ }
+ /**
+ *
+ * @param CalorimetType representation from
+ * Calorimeter.CalorimeterType
+ * @return the maximum z
+ */
+ public double getZMax(Calorimeter.CalorimeterType s)
+ {
+ Integer ind = indexmap.get(s);
+ if(ind == null)
+ {
+ System.out.println("Type "+s+" did not map to a CalorimeterType");
+ return -1.;
+ }
+ index = ind.intValue();
+ return zmax[index];
+ }
+}