GeomConverter/src/org/lcsim/detector/converter/compact
diff -N PolyconeSupportConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolyconeSupportConverter.java 11 Sep 2007 20:18:33 -0000 1.1
@@ -0,0 +1,77 @@
+package org.lcsim.detector.converter.compact;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jdom.DataConversionException;
+import org.jdom.Element;
+import org.lcsim.detector.DetectorFactory;
+import org.lcsim.detector.ILogicalVolume;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.LogicalVolume;
+import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialStore;
+import org.lcsim.detector.solids.Polycone;
+import org.lcsim.detector.solids.Polycone.ZPlane;
+import org.lcsim.geometry.compact.Detector;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.subdetector.PolyconeSupport;
+
+/**
+ * Convert a {@link org.lcsim.geometry.subdetector.PolyconeSupport}
+ * to the {@link org.lcsim.detector} detailed detector representation.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: PolyconeSupportConverter.java,v 1.1 2007/09/11 20:18:33 jeremy Exp $
+ */
+
+public class PolyconeSupportConverter
+implements ISubdetectorConverter
+{
+
+ public void convert(Subdetector subdet, Detector detector)
+ {
+ List<ZPlane> zplanes = new ArrayList<ZPlane>();
+ Element node = subdet.getNode();
+ for(Iterator i = node.getChildren("zplane").iterator(); i.hasNext(); )
+ {
+ try
+ {
+ Element zplane = (Element) i.next();
+ zplanes.add(
+ new ZPlane(zplane.getAttribute("rmin").getDoubleValue(),
+ zplane.getAttribute("rmax").getDoubleValue(),
+ zplane.getAttribute("z").getDoubleValue()
+ ));
+ }
+ catch (DataConversionException dce)
+ {
+ throw new RuntimeException("bad values for zplane from the xml file", dce);
+ }
+ }
+
+ Polycone polycone = new Polycone(subdet.getName(), zplanes);
+
+ IMaterial material = MaterialStore.getInstance().get(node.getChild("material").getAttributeValue("name"));
+
+ ILogicalVolume lvPolycone = new LogicalVolume(subdet.getName(), polycone, material);
+
+ ILogicalVolume mom = null;
+ if (subdet.isInsideTrackingVolume())
+ {
+ mom = detector.getTrackingVolume().getLogicalVolume();
+ }
+ else
+ {
+ mom = detector.getWorldVolume().getLogicalVolume();
+ }
+
+ IPhysicalVolume pv = DetectorFactory.getInstance().createPhysicalVolume(null, subdet.getName(), lvPolycone, mom, 0);
+ }
+
+ public Class getSubdetectorType()
+ {
+ return PolyconeSupport.class;
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.21 -r1.22
--- DetectorConverter.java 6 Sep 2007 18:14:46 -0000 1.21
+++ DetectorConverter.java 11 Sep 2007 20:18:33 -0000 1.22
@@ -110,6 +110,7 @@
addSubdetectorConverter( new MultiLayerTrackerConverter() );
addSubdetectorConverter( new DiskTrackerConverter() );
addSubdetectorConverter( new SiTrackerBarrelConverter() );
+ addSubdetectorConverter( new PolyconeSupportConverter() );
}
private void addSubdetectorConverter(ISubdetectorConverter s)
@@ -181,10 +182,8 @@
checkIdDict(iddict);
// Convert to detailed description if a suitable converter exists.
- if ( cnv != null && iddict != null )
+ if ( cnv != null )
{
- //System.out.println(subdet.getName() + " will be converted to detailed descr");
-
// Convert parameters.
try {
paramCnv.convert(subdet.getNode());
@@ -233,20 +232,8 @@
makeIdentifiers(subdet);
}
}
-
- //System.out.println("done converting " + subdet.getName());
}
}
- /*
- else
- {
- System.out.print("skipping " + subdet.getName() + " - ");
- if (cnv == null)
- System.out.println("cnv is null");
- if (iddict == null)
- System.out.println("iddict is null");
- }
- */
}
}