GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.9 -r1.10
--- PolyhedraBarrelCalorimeter.java 5 Feb 2009 21:43:23 -0000 1.9
+++ PolyhedraBarrelCalorimeter.java 18 Nov 2009 18:53:41 -0000 1.10
@@ -27,10 +27,12 @@
orad = irad + getLayering().getThickness();
}
+ /*
public void appendHepRep(HepRepFactory factory, HepRep heprep)
{
DetectorElementToHepRepConverter.convert(getDetectorElement(), factory, heprep, 0, -1);
}
+ */
public boolean isBarrel()
{
GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.10 -r1.11
--- PolyhedraEndcapCalorimeter.java 5 Feb 2009 21:44:27 -0000 1.10
+++ PolyhedraEndcapCalorimeter.java 18 Nov 2009 18:53:41 -0000 1.11
@@ -6,12 +6,18 @@
*/
package org.lcsim.geometry.subdetector;
+import static java.lang.Math.cos;
+import static java.lang.Math.sin;
+import static java.lang.Math.tan;
import hep.graphics.heprep.HepRep;
import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstance;
+import hep.graphics.heprep.HepRepInstanceTree;
+import hep.graphics.heprep.HepRepType;
+import hep.graphics.heprep.HepRepTypeTree;
import org.jdom.Element;
import org.jdom.JDOMException;
-import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
/**
*
@@ -19,46 +25,115 @@
*/
public class PolyhedraEndcapCalorimeter extends AbstractPolyhedraCalorimeter
{
- private double zmin;
- private double zmax;
-
- public PolyhedraEndcapCalorimeter(Element node) throws JDOMException
- {
- super(node);
- build(node);
- }
-
- private void build(Element node) throws JDOMException
- {
- double thickness = getLayering().getThickness();
- zlength = thickness;
-
- Element dimensions = node.getChild("dimensions");
-
- zmin = dimensions.getAttribute("zmin").getDoubleValue();
- zmax = zmin + thickness;
-
- irad = dimensions.getAttribute("rmin").getDoubleValue();
- orad = dimensions.getAttribute("rmax").getDoubleValue();
- }
-
- public double getZMin()
- {
- return zmin;
- }
-
- public double getZMax()
- {
- return zmax;
- }
-
- public void appendHepRep(HepRepFactory factory, HepRep heprep)
- {
- DetectorElementToHepRepConverter.convert(getDetectorElement(), factory, heprep, 0, -1);
- }
-
- public boolean isEndcap()
- {
- return true;
- }
+ private double zmin;
+ private double zmax;
+
+ public PolyhedraEndcapCalorimeter(Element node) throws JDOMException
+ {
+ super(node);
+ build(node);
+ }
+
+ private void build(Element node) throws JDOMException
+ {
+ double thickness = getLayering().getThickness();
+ zlength = thickness;
+
+ Element dimensions = node.getChild("dimensions");
+
+ zmin = dimensions.getAttribute("zmin").getDoubleValue();
+ zmax = zmin + thickness;
+
+ irad = dimensions.getAttribute("rmin").getDoubleValue();
+ orad = dimensions.getAttribute("rmax").getDoubleValue();
+ }
+
+ public double getZMin()
+ {
+ return zmin;
+ }
+
+ public double getZMax()
+ {
+ return zmax;
+ }
+
+ public void appendHepRep(HepRepFactory factory, HepRep heprep)
+ {
+ HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop("Detector","1.0");
+ HepRepTypeTree typeTree = heprep.getTypeTree("DetectorType","1.0");
+ HepRepType barrel = typeTree.getType("Barrel");
+
+ HepRepType type = factory.createHepRepType(barrel, getName());
+ type.addAttValue("drawAs","Polygon");
+
+ setHepRepColor(type);
+
+ HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+
+ // Compute section (x,y) coordinates.
+ double rmin = getInnerR();
+
+ double x1 = rmin * tan(this.getHalfSectionPhi());
+ double y1 = rmin;
+
+ double x2 = -x1;
+ double y2 = y1;
+
+ double t = this.getLayering().getLayerStack().getTotalThickness();
+ double zin = this.getZMin();
+ double zout = zin + t;
+
+ double rmax = this.getOuterR();
+
+ double x4 = rmax * tan(this.getHalfSectionPhi());
+ double y4 = rmax;
+
+ double x3 = -x4;
+ double y3 = y4;
+
+ // Place nsides sections by applying matrix transform to starting coordinates.
+ double phi = 0;
+ for (int i=0; i < 2; i++)
+ {
+ for (int j=0; j<getNumberOfSides(); j++)
+ {
+ instance = factory.createHepRepInstance(instanceTree, type);
+
+ double ix1 = x1 * cos(phi) - y1 * sin(phi);
+ double iy1 = x1 * sin(phi) + y1 * cos(phi);
+
+ double ix2 = x2 * cos(phi) - y2 * sin(phi);
+ double iy2 = x2 * sin(phi) + y2 * cos(phi);
+
+ double ix3 = x3 * cos(phi) - y3 * sin(phi);
+ double iy3 = x3 * sin(phi) + y3 * cos(phi);
+
+ double ix4 = x4 * cos(phi) - y4 * sin(phi);
+ double iy4 = x4 * sin(phi) + y4 * cos(phi);
+
+ factory.createHepRepPoint(instance, ix1, iy1, zin);
+ factory.createHepRepPoint(instance, ix2, iy2, zin);
+ factory.createHepRepPoint(instance, ix3, iy3, zin);
+ factory.createHepRepPoint(instance, ix4, iy4, zin);
+
+ factory.createHepRepPoint(instance, ix4, iy4, zout);
+ factory.createHepRepPoint(instance, ix3, iy3, zout);
+ factory.createHepRepPoint(instance, ix2, iy2, zout);
+ factory.createHepRepPoint(instance, ix1, iy1, zout);
+
+ phi += getSectionPhi();
+ }
+ // TODO: Break here if not reflected. Heprep converter does not pickup correct default
+ // of reflect being true unless set to false. Doesn't have access to compact
+ // schema defaults.
+ zin = -zin;
+ zout = -zout;
+ }
+ }
+
+ public boolean isEndcap()
+ {
+ return true;
+ }
}
\ No newline at end of file