5 added files
GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -N TestBeamCalorimeter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestBeamCalorimeter.java 3 Sep 2005 01:37:19 -0000 1.1
@@ -0,0 +1,218 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import org.jdom.Attribute;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.lcsim.geometry.compact.converter.lcdd.util.Box;
+import org.lcsim.geometry.compact.converter.lcdd.util.Define;
+import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
+import org.lcsim.geometry.compact.converter.lcdd.util.Material;
+import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
+import org.lcsim.geometry.compact.converter.lcdd.util.Position;
+import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
+import org.lcsim.geometry.compact.converter.lcdd.util.Solids;
+import org.lcsim.geometry.compact.converter.lcdd.util.Structure;
+import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
+import org.lcsim.geometry.layer.LayerFromCompactCnv;
+
+/**
+ *
+ * @author tonyj
+ */
+class TestBeamCalorimeter extends LCDDSubdetector
+{
+ TestBeamCalorimeter(Element node) throws JDOMException
+ {
+ super(node);
+ }
+
+ public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
+ {
+ String detectorName = node.getAttributeValue("name");
+ int id = node.getAttribute("id").getIntValue();
+
+ Material air = lcdd.getMaterial("Air");
+ Solids solids = lcdd.getSolids();
+ Structure structure = lcdd.getStructure();
+ Volume motherVolume = lcdd.pickMotherVolume(this);
+ Define define = lcdd.getDefine();
+
+ Element dimensions = node.getChild("dimensions");
+ double xdim = dimensions.getAttribute("x").getDoubleValue();
+ double ydim = dimensions.getAttribute("y").getDoubleValue();
+ double zdim = LayerFromCompactCnv.computeDetectorTotalThickness(node);
+
+ Box envelopeBox = new Box(detectorName + "_box");
+ envelopeBox.setX(xdim);
+ envelopeBox.setY(ydim);
+ envelopeBox.setZ(zdim);
+ solids.addSolid(envelopeBox);
+ Volume envelopeVolume = new Volume(detectorName + "_envelope");
+ envelopeVolume.setSolid(envelopeBox);
+ envelopeVolume.setMaterial(air);
+
+ double xpos = 0;
+ double ypos = 0;
+ double zpos = 0;
+
+ Element positionElement = node.getChild("position");
+
+ if ( positionElement != null )
+ {
+ Attribute posAttribute = positionElement.getAttribute("x");
+ if ( posAttribute != null )
+ {
+ xpos = posAttribute.getDoubleValue();
+ }
+
+ posAttribute = positionElement.getAttribute("y");
+ if ( posAttribute != null )
+ {
+ ypos = posAttribute.getDoubleValue();
+ }
+
+ posAttribute = positionElement.getAttribute("z");
+ if ( posAttribute != null )
+ {
+ zpos = posAttribute.getDoubleValue();
+ }
+ }
+
+ Position envelopePosition = new Position(detectorName + "_position");
+ envelopePosition.setX(xpos);
+ envelopePosition.setY(ypos);
+ envelopePosition.setZ(zpos);
+ define.addPosition(envelopePosition);
+
+ double layerZPos = -zdim / 2;
+
+ int layerCount = 0;
+ int layerTypeCount = 0;
+ double maxLayerX = 0;
+ double maxLayerY = 0;
+ for ( Object lo : node.getChildren("layer") )
+ {
+ Element layer = (Element) lo;
+
+ double layerX = xdim;
+ Attribute xattrib = layer.getAttribute("x");
+ if ( xattrib != null )
+ {
+ layerX = xattrib.getDoubleValue();
+ }
+
+ double layerY = ydim;
+ Attribute yattrib = layer.getAttribute("y");
+ if ( yattrib != null )
+ {
+ layerY = yattrib.getDoubleValue();
+ }
+
+ double layerZ = LayerFromCompactCnv.computeSingleLayerThickness(layer);
+
+ int repeat = 1;
+ Attribute repeatAttrib = layer.getAttribute("repeat");
+ if ( repeatAttrib != null )
+ {
+ repeat = repeatAttrib.getIntValue();
+ }
+
+ String layerVolumeName = detectorName + "_layerType" + layerTypeCount;
+ Box layerBox = new Box(layerVolumeName + "_box");
+ layerBox.setX(layerX);
+ layerBox.setY(layerY);
+ layerBox.setZ(layerZ);
+ solids.addSolid(layerBox);
+
+ Volume layerVolume = new Volume(layerVolumeName);
+ layerVolume.setMaterial(air);
+ layerVolume.setSolid(layerBox);
+
+ int sliceCount = 0;
+ double slicePosZ = -layerZ / 2;
+ for ( Object so : layer.getChildren("slice"))
+ {
+ System.out.println("proc slice");
+
+ Element slice = (Element) so;
+ double sliceX = layerX;
+ double sliceY = layerY;
+ xattrib = slice.getAttribute("x");
+ if ( xattrib != null )
+ {
+ sliceX = xattrib.getDoubleValue();
+ }
+
+ yattrib = slice.getAttribute("y");
+ if ( yattrib != null )
+ {
+ sliceY = yattrib.getDoubleValue();
+ }
+ double sliceZ = slice.getAttribute("thickness").getDoubleValue();
+
+ Attribute s = slice.getAttribute("sensitive");
+ boolean sensitive = s != null && s.getBooleanValue();
+
+ String sliceName = layerVolumeName + "_slice" + sliceCount;
+
+ Box sliceBox = new Box(sliceName + "_box");
+ sliceBox.setX(sliceX);
+ sliceBox.setY(sliceY);
+ sliceBox.setZ(sliceZ);
+ solids.addSolid(sliceBox);
+
+ Volume sliceVolume = new Volume(sliceName);
+ sliceVolume.setSolid(sliceBox);
+ Material sliceMaterial = lcdd.getMaterial(slice.getAttributeValue("material"));
+ sliceVolume.setMaterial(sliceMaterial);
+ if ( sensitive ) sliceVolume.setSensitiveDetector(sens);
+ structure.addVolume(sliceVolume);
+
+ PhysVol slicePhysVol = new PhysVol(sliceVolume);
+ slicePhysVol.addPhysVolID("slice", sliceCount);
+ Position slicePosition = new Position(sliceName + "_position");
+ slicePosZ += sliceZ / 2;
+ slicePosition.setZ(slicePosZ);
+ slicePosZ += sliceZ / 2;
+ define.addPosition(slicePosition);
+ slicePhysVol.setPosition(slicePosition);
+ layerVolume.addPhysVol(slicePhysVol);
+
+ ++sliceCount;
+ }
+
+ structure.addVolume(layerVolume);
+
+ for ( int i=0; i<repeat; i++)
+ {
+ String layerPhysVolName = detectorName + "_layer" + layerCount;
+
+ PhysVol layerPhysVol = new PhysVol(layerVolume);
+ layerPhysVol.addPhysVolID("layer", layerCount);
+
+ layerZPos += layerZ / 2;
+ Position layerPosition = new Position(layerPhysVolName + "_position");
+ define.addPosition(layerPosition);
+ layerPosition.setZ(layerZPos);
+ layerPhysVol.setPosition(layerPosition);
+ layerZPos += layerZ / 2;
+
+ envelopeVolume.addPhysVol(layerPhysVol);
+
+ ++layerCount;
+ }
+ ++layerTypeCount;
+ }
+
+ structure.addVolume(envelopeVolume);
+ PhysVol envelopePhysVol = new PhysVol(envelopeVolume);
+ envelopePhysVol.addPhysVolID("system", id);
+ envelopePhysVol.setPosition(envelopePosition);
+ motherVolume.addPhysVol(envelopePhysVol);
+ }
+
+ public boolean isCalorimeter()
+ {
+ return true;
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/subdetector
diff -N TestBeamCalorimeter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestBeamCalorimeter.java 3 Sep 2005 01:37:20 -0000 1.1
@@ -0,0 +1,132 @@
+/*
+ * TestBeamCalorimeter.java
+ *
+ * Created on September 2, 2005, 3:43 PM
+ *
+ */
+
+package org.lcsim.geometry.subdetector;
+
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import org.jdom.Attribute;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+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;
+
+/**
+ * @author jeremym
+ */
+public class TestBeamCalorimeter extends AbstractCalorimeter
+{
+ double x;
+ double y;
+ double z;
+
+ Hep3Vector position;
+
+ public TestBeamCalorimeter(Element node) throws JDOMException
+ {
+ super(node);
+ build(node);
+ }
+
+ private void build(Element node) throws JDOMException
+ {
+ Element dimensions = node.getChild("dimensions");
+
+ x = dimensions.getAttribute("x").getDoubleValue();
+ y = dimensions.getAttribute("y").getDoubleValue();
+ z = getLayering().getThickness();
+
+ Element position = node.getChild("position");
+
+ double posX=0;
+ double posY=0;
+ double posZ=0;
+ if ( position != null )
+ {
+ Attribute posAttrib = position.getAttribute("x");
+ if ( posAttrib != null )
+ {
+ posX = posAttrib.getDoubleValue();
+ }
+ posAttrib = position.getAttribute("y");
+ if ( posAttrib != null )
+ {
+ posY = posAttrib.getDoubleValue();
+ }
+
+ posAttrib = position.getAttribute("z");
+ if ( posAttrib != null )
+ {
+ posZ = posAttrib.getDoubleValue();
+ }
+ }
+
+ setPosition(new BasicHep3Vector(posX, posY, posZ));
+ }
+
+ /** @return full maximum dimension in X */
+ public double getX()
+ {
+ return x;
+ }
+
+ /** @return full maximum dimension in Y */
+ public double getY()
+ {
+ return y;
+ }
+
+ /**
+ * @return full maximum dimension in Z, computed and cached at build time from
+ * layering thickness
+ */
+ public double getZ()
+ {
+ return z;
+ }
+
+ public Hep3Vector getPosition()
+ {
+ return position;
+ }
+
+ public void setPosition(Hep3Vector position)
+ {
+ this.position = position;
+ }
+
+ 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","Prism");
+
+ HepRepInstance instance = factory.createHepRepInstance(instanceTree, type);
+
+ Hep3Vector position = getPosition();
+ double x = getX()/2 + position.x();
+ double y = getY()/2 + position.y();
+ double z = getZ()/2 + position.z();
+
+ factory.createHepRepPoint(instance, x, y, -z);
+ factory.createHepRepPoint(instance, x, -y, -z);
+ factory.createHepRepPoint(instance, -x, -y, -z);
+ factory.createHepRepPoint(instance, -x, y, -z);
+
+ factory.createHepRepPoint(instance, x, y, z);
+ factory.createHepRepPoint(instance, x, -y, z);
+ factory.createHepRepPoint(instance, -x, -y, z);
+ factory.createHepRepPoint(instance, -x, y, z);
+ }
+}
\ No newline at end of file
GeomConverter/test/org/lcsim/geometry/compact/converter/lcdd
diff -N TestBeamCalorimeterConverterTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestBeamCalorimeterConverterTest.java 3 Sep 2005 01:37:20 -0000 1.1
@@ -0,0 +1,34 @@
+/*
+ * TestBeamCalorimeterConverterTest.java
+ *
+ * Created on June 16, 2005, 3:23 PM
+ */
+
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import java.io.InputStream;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ *
+ * @author jeremym
+ */
+public class TestBeamCalorimeterConverterTest extends TestCase
+{
+ public TestBeamCalorimeterConverterTest(String name)
+ {
+ super(name);
+ }
+
+ public static TestSuite suite()
+ {
+ return new TestSuite(TestBeamCalorimeterConverterTest.class);
+ }
+
+ public void testTestBeamCalorimeterConverter() throws Exception
+ {
+ InputStream in = TestBeamCalorimeterConverterTest.class.getResourceAsStream("/org/lcsim/geometry/subdetector/TestBeamCalorimeterTest.xml");
+ new Main(true).convert("TestBeamCalorimeterTest",in,null);
+ }
+}
\ No newline at end of file
GeomConverter/test/org/lcsim/geometry/subdetector
diff -N TestBeamCalorimeterTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestBeamCalorimeterTest.java 3 Sep 2005 01:37:20 -0000 1.1
@@ -0,0 +1,53 @@
+/*
+ * CylindricalBarrelCalorimeterTest.java
+ *
+ * Created on June 15, 2005, 12:00 PM
+ */
+
+package org.lcsim.geometry.subdetector;
+
+import hep.graphics.heprep.HepRepProvider;
+import java.io.IOException;
+import java.io.InputStream;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.jdom.JDOMException;
+import org.lcsim.geometry.Calorimeter;
+import org.lcsim.geometry.GeometryReader;
+import org.lcsim.geometry.compact.Detector;
+import org.lcsim.util.xml.ElementFactory.ElementCreationException;
+
+import org.lcsim.geometry.layer.Layering;
+
+/**
+ *
+ * @author jeremym
+ */
+public class TestBeamCalorimeterTest extends TestCase
+{
+ Detector detector;
+
+ /** Creates a new instance of CylindricalBarrelCalorimeterTest */
+ public TestBeamCalorimeterTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws java.lang.Exception
+ {
+ InputStream in = this.getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/TestBeamCalorimeterTest.xml");
+
+ GeometryReader reader = new GeometryReader();
+ Detector det = reader.read(in);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new TestSuite(TestBeamCalorimeterTest.class);
+ }
+
+ public void testDummy()
+ {
+ return;
+ }
+}
GeomConverter/test/org/lcsim/geometry/subdetector
diff -N TestBeamCalorimeterTest.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestBeamCalorimeterTest.xml 3 Sep 2005 01:37:21 -0000 1.1
@@ -0,0 +1,60 @@
+<!-- top-level compact description element -->
+<lccdd xmlns:lccdd="namespaceUrl"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:noNamespaceSchemaLocation="noNamespaceUrl">
+
+ <info name="TestBeamCalorimeterTest"
+ title="TestBeamCalorimeterTest"
+ author="Norman Graf"
+ url="http://confluence.slac.stanford.edu/display/ilc/sidmay05">
+ <comment>Test of class org.lcsim.geometry.compact.converter.lcdd.TestBeamCalorimeter</comment>
+ </info>
+
+ <define>
+
+ <constant name="cm" value="10"/>
+
+ <!-- world -->
+ <constant name="world_side" value="30000" />
+ <constant name="world_x" value="world_side" />
+ <constant name="world_y" value="world_side" />
+ <constant name="world_z" value="world_side" />
+
+ <!-- tracking region -->
+ <constant name="tracking_region_radius" value="150.0*cm"/>
+ <constant name="tracking_region_zmax" value="200.0*cm"/>
+
+ </define>
+
+ <materials>
+ </materials>
+
+ <detectors>
+
+ <detector id="0"
+ name="TestBeamCalorimeterTest"
+ type="TestBeamCalorimeter"
+ readout="CalHits"
+ insideTrackingVolume="true">
+ <dimensions x="100.0 * cm" y="100.0 * cm" />
+ <layer repeat="30">
+ <slice material="Polystyrene" thickness="1.0*cm" sensitive="true"/>
+ <slice material="Lead" thickness="5.0 * cm" />
+ </layer>
+ </detector>
+ </detectors>
+
+ <readouts>
+ <readout name="CalHits">
+ <segmentation type="GridXYZ" gridSizeX="10.0" gridSizeY="10.0" />
+ <id>layer:7,system:3,x:32:-16,y:-16</id>
+ </readout>
+ </readouts>
+ <fields>
+ <field type="Solenoid" name="GlobalSolenoid"
+ inner_field="5.0"
+ outer_field="-0.6"
+ zmax="1000"
+ outer_radius="(221.0+ 5.0 + 17.5 + 40./2.)*cm"/>
+ </fields>
+</lccdd>
CVSspam 0.2.8