Print

Print


Commit in GeomConverter on MAIN
src/org/lcsim/geometry/layer/Layering.java+10-41.2 -> 1.3
src/org/lcsim/geometry/subdetector/PolyhedraEndcapCalorimeter.java+60added 1.1
                                  /AbstractPolyhedraCalorimeter.java+20-81.2 -> 1.3
                                  /PolyhedraBarrelCalorimeter.java+21.1 -> 1.2
test/org/lcsim/geometry/compact/converter/lcdd/PolyhedraEndcapCalorimeterConverterTest.java+29added 1.1
                                              /PolyhedraBarrelCalorimeterConverterTest.java+2-31.2 -> 1.3
test/org/lcsim/geometry/subdetector/PolyhedraEndcapCalorimeterTest.java+48added 1.1
                                   /PolyhedraEndcapCalorimeterTest.xml+59added 1.1
                                   /PolyhedraBarrelCalorimeterTest.xml+3-31.3 -> 1.4
src/org/lcsim/geometry/compact/converter/lcdd/PolyhedraEndcapCalorimeter.java+226added 1.1
+459-18
5 added + 5 modified, total 10 files
Adding impl and test files for PolyhedraEndcapCalorimeter.  (Plus other misc cleanup.)

GeomConverter/src/org/lcsim/geometry/layer
Layering.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- Layering.java	20 Jul 2005 19:11:58 -0000	1.2
+++ Layering.java	26 Aug 2005 02:37:04 -0000	1.3
@@ -25,10 +25,7 @@
     }
     
     /** 
-     * Creates a new instance of Layering. 
-     *
      * @param e "detector" element.
-     *
      */
     public Layering(Element e) throws JDOMException
     {        
@@ -36,7 +33,6 @@
         layerStack = LayerFromCompactCnv.makeLayerStackFromCompact(e);
     }
     
-    /** Specific types need to implement this for their topology. */
     public double getDistanceToLayer(int layer)
     {
         return getLayerStack().getThicknessToLayerFront(layer) + offset;
@@ -47,6 +43,16 @@
     {
         return getLayerStack();
     }
+
+    public Layer getLayer(int i)
+    {
+        return getLayerStack().getLayer(i);
+    }
+    
+    public double getThickness()
+    {
+        return getLayerStack().getTotalThickness();
+    }
     
     public LayerStack getLayerStack()
     {

GeomConverter/src/org/lcsim/geometry/subdetector
PolyhedraEndcapCalorimeter.java added at 1.1
diff -N PolyhedraEndcapCalorimeter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PolyhedraEndcapCalorimeter.java	26 Aug 2005 02:37:04 -0000	1.1
@@ -0,0 +1,60 @@
+/*
+ * PolyhedraBarrelCalorimeter.java
+ *
+ * Created on August 24, 2005, 9:37 PM
+ *
+ */
+
+package org.lcsim.geometry.subdetector;
+
+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 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();
+    }
+    
+    double getZMin()
+    {
+        return zmin;
+    }
+    
+    double getZMax()
+    {
+        return zmax;
+    }
+    
+    public void appendHepRep(HepRepFactory factory, HepRep heprep)
+    {}
+}
\ No newline at end of file

GeomConverter/src/org/lcsim/geometry/subdetector
AbstractPolyhedraCalorimeter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- AbstractPolyhedraCalorimeter.java	25 Aug 2005 08:02:06 -0000	1.2
+++ AbstractPolyhedraCalorimeter.java	26 Aug 2005 02:37:04 -0000	1.3
@@ -15,13 +15,11 @@
  */
 public class AbstractPolyhedraCalorimeter extends AbstractCalorimeter
 {
-    private double irad;
-    private int nsides;
-    private double zlength;
-    
-    /**
-     * Creates a new instance of PolyhedraCalorimeter 
-     */
+    double irad;
+    double orad;
+    int nsides;
+    double zlength;
+    
     public AbstractPolyhedraCalorimeter(Element node) throws JDOMException
     {
         super(node);
@@ -33,7 +31,6 @@
         Element dimensions = node.getChild("dimensions");
         
         nsides = dimensions.getAttribute("numsides").getIntValue();
-        zlength = dimensions.getAttribute("z").getDoubleValue();
         irad = dimensions.getAttribute("rmin").getDoubleValue();
     }
     
@@ -42,11 +39,26 @@
         return irad;
     }
     
+    double getOuterR()
+    {
+        return orad;
+    }
+    
     double getZLength()
     {
         return zlength;
     }
     
+    double getZMin()
+    {
+        return -zlength/2;
+    }
+    
+    double getZMax()
+    {
+        return zlength/2;
+    }
+    
     int getNumberOfSides()
     {
         return nsides;

GeomConverter/src/org/lcsim/geometry/subdetector
PolyhedraBarrelCalorimeter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- PolyhedraBarrelCalorimeter.java	25 Aug 2005 08:03:03 -0000	1.1
+++ PolyhedraBarrelCalorimeter.java	26 Aug 2005 02:37:04 -0000	1.2
@@ -25,6 +25,8 @@
     public PolyhedraBarrelCalorimeter(Element node) throws JDOMException
     {
         super(node);
+        zlength = node.getChild("dimensions").getAttribute("z").getDoubleValue();
+        orad = irad + getLayering().getThickness();
     }
     
     public void appendHepRep(HepRepFactory factory, HepRep heprep)

GeomConverter/test/org/lcsim/geometry/compact/converter/lcdd
PolyhedraEndcapCalorimeterConverterTest.java added at 1.1
diff -N PolyhedraEndcapCalorimeterConverterTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PolyhedraEndcapCalorimeterConverterTest.java	26 Aug 2005 02:37:05 -0000	1.1
@@ -0,0 +1,29 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import java.io.InputStream;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ *
+ * @author jeremym
+ */
+public class PolyhedraEndcapCalorimeterConverterTest extends TestCase
+{    
+    public PolyhedraEndcapCalorimeterConverterTest()
+    {}
+    
+    public static TestSuite suite()
+    {
+        return new TestSuite(PolyhedraEndcapCalorimeterConverterTest.class);
+    }
+    
+    public void test_PolyhedraEndcapCalorimeterConverter() throws Exception
+    {
+        InputStream in = 
+                PolyhedraEndcapCalorimeterConverterTest.class.
+                getResourceAsStream(
+                "/org/lcsim/geometry/subdetector/PolyhedraEndcapCalorimeterTest.xml");
+        new Main(true).convert("PolyhedraEndcapCalorimeterTest",in,null);
+    }
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/compact/converter/lcdd
PolyhedraBarrelCalorimeterConverterTest.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- PolyhedraBarrelCalorimeterConverterTest.java	25 Aug 2005 20:43:27 -0000	1.2
+++ PolyhedraBarrelCalorimeterConverterTest.java	26 Aug 2005 02:37:05 -0000	1.3
@@ -24,7 +24,6 @@
                 PolyhedraBarrelCalorimeterConverterTest.class.
                 getResourceAsStream(
                 "/org/lcsim/geometry/subdetector/PolyhedraBarrelCalorimeterTest.xml");
-        // FIXME: Causes null SD bug.
-        // new Main(true).convert("PolyhedraBarrelCalorimeterTest",in,null);
+        new Main(true).convert("PolyhedraBarrelCalorimeterTest",in,null);
     }
-}
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/subdetector
PolyhedraEndcapCalorimeterTest.java added at 1.1
diff -N PolyhedraEndcapCalorimeterTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PolyhedraEndcapCalorimeterTest.java	26 Aug 2005 02:37:05 -0000	1.1
@@ -0,0 +1,48 @@
+package org.lcsim.geometry.subdetector;
+
+import java.io.InputStream;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.lcsim.geometry.GeometryReader;
+import org.lcsim.geometry.compact.Detector;
+
+/**
+ *
+ * @author jeremym
+ */
+public class PolyhedraEndcapCalorimeterTest extends TestCase
+{
+    Detector det;
+    PolyhedraEndcapCalorimeter pbc;
+    
+    /** Creates a new instance of ForwardDetectorTest */
+    public PolyhedraEndcapCalorimeterTest()
+    {}
+    
+    protected void setUp() throws java.lang.Exception
+    {                
+        InputStream in = this.getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/PolyhedraEndcapCalorimeterTest.xml");
+        GeometryReader reader = new GeometryReader();
+        det = reader.read(in);
+        
+        assert( det.getSubdetectors().get("PolyhedraEndcapCalorimeterTest") != null );
+        
+        try
+        {
+            pbc = (PolyhedraEndcapCalorimeter) det.getSubdetectors().get("PolyhedraEndcapCalorimeterTest");
+        }
+        catch ( ClassCastException cce )
+        {
+            throw new RuntimeException("Failed cast to PolyhedraEndcapCalorimeter.");
+        }
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new TestSuite(PolyhedraEndcapCalorimeterTest.class);
+    }
+    
+    public void test_PolyhedraEndcapCalorimeter()
+    {
+    }
+}
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/subdetector
PolyhedraEndcapCalorimeterTest.xml added at 1.1
diff -N PolyhedraEndcapCalorimeterTest.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PolyhedraEndcapCalorimeterTest.xml	26 Aug 2005 02:37:05 -0000	1.1
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- top-level compact description element -->
+<lccdd xmlns:lccdd="namespaceUrl"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+       xs:noNamespaceSchemaLocation="noNamespaceUrl">
+
+  <info name="PolyhedraEndcapCalorimeterTest"
+        title="PolyhedraEndcapCalorimeterTest"
+	author="Jeremy McCormick"
+	url="NONE">
+    <comment>Test of org.lcsim.geometry.subdetector.PolyhedraEndcapCalorimeter class.</comment>
+  </info>
+
+  <!-- Constants -->
+  <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="0.1*cm"/>
+    <constant name="tracking_region_zmax" value="0.1*cm"/>
+  </define>
+
+  <materials>
+  </materials>
+
+  <detectors>
+    <detector id="0" 
+              name="PolyhedraEndcapCalorimeterTest" 
+              type="PolyhedraEndcapCalorimeter" 
+              readout="CalHits"
+              reflect="true">
+         <dimensions numsides="8" zmin="1000.0" rmin="500.0" rmax="1000.0" />
+         <layer repeat="20">
+           <slice material="Silicon" thickness="5.0" sensitive="true" />
+         </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="CalHits">
+      <segmentation type="GridXYZ" gridSizeX="1.0" gridSizeZ="1.0" />
+      <id>layer:8,system:6,barrel:3,x:32:-16,z:-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"/>  <!-- SolenoidCoilBarrel inner_radius + Al support + Oxygen gap + half coil-->
+   </fields>
+</lccdd>
\ No newline at end of file

GeomConverter/test/org/lcsim/geometry/subdetector
PolyhedraBarrelCalorimeterTest.xml 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- PolyhedraBarrelCalorimeterTest.xml	25 Aug 2005 20:40:22 -0000	1.3
+++ PolyhedraBarrelCalorimeterTest.xml	26 Aug 2005 02:37:05 -0000	1.4
@@ -35,15 +35,15 @@
               type="PolyhedraBarrelCalorimeter" 
               readout="CalHits">
          <dimensions numsides="8" z="1000.0" rmin="500.0"/>
-         <layer repeat="10">
-           <slice material="Silicon" thickness="1.0*cm" sensitive="true" />
+         <layer repeat="20">
+           <slice material="Silicon" thickness="5.0" sensitive="true" />
          </layer>
     </detector>
   </detectors>
 
   <readouts>
     <readout name="CalHits">
-      <segmentation type="GridXYZ" gridSizeX="10.0" gridSizeY="10.0" />
+      <segmentation type="GridXYZ" gridSizeX="1.0" gridSizeY="1.0" />
       <id>layer:8,system:6,barrel:3,x:32:-10,y:-10</id>
     </readout>
   </readouts>

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
PolyhedraEndcapCalorimeter.java added at 1.1
diff -N PolyhedraEndcapCalorimeter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PolyhedraEndcapCalorimeter.java	26 Aug 2005 02:37:05 -0000	1.1
@@ -0,0 +1,226 @@
+package org.lcsim.geometry.compact.converter.lcdd;
+
+import java.util.Iterator;
+import org.jdom.Element;
+import org.jdom.Attribute;
+import org.jdom.JDOMException;
+import org.lcsim.geometry.compact.converter.lcdd.util.Define;
+import static java.lang.Math.PI;
+import static java.lang.Math.tan;
+import static java.lang.Math.sin;
+import static java.lang.Math.cos;
+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.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.PhysVol;
+import org.lcsim.geometry.compact.converter.lcdd.util.PolyhedraRegular;
+import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
+import org.lcsim.geometry.compact.converter.lcdd.util.Trapezoid;
+import org.lcsim.geometry.compact.converter.lcdd.util.Box;
+import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
+import org.lcsim.geometry.compact.converter.lcdd.util.Position;
+import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
+
+/**
+ *
+ * @author jeremym
+ */
+public class PolyhedraEndcapCalorimeter extends LCDDSubdetector
+{
+    private Element node;
+    
+    public PolyhedraEndcapCalorimeter(Element node) throws JDOMException
+    {
+        super(node);
+        this.node = node;
+    }
+    
+    public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
+    {
+        if ( sens == null)
+        {
+            throw new IllegalArgumentException("PolyhedraBarrelCalorimeter's SD is null.");
+        }
+        
+        /* local refs to LCDD objects */
+        Solids solids = lcdd.getSolids();
+        Structure structure = lcdd.getStructure();
+        Volume motherVolume = lcdd.pickMotherVolume(this);
+        Material air = lcdd.getMaterial("Air");
+        Define define = lcdd.getDefine();
+        
+        /* name and id */
+        String detName = node.getAttributeValue("name");
+        int id = node.getAttribute("id").getIntValue();
+        
+        /* get dimensions */
+        Element dimensions = node.getChild("dimensions");
+        double zmin = dimensions.getAttribute("zmin").getDoubleValue();
+        double rmin = dimensions.getAttribute("rmin").getDoubleValue();
+        double rmax = dimensions.getAttribute("rmax").getDoubleValue();
+        int numsides = dimensions.getAttribute("numsides").getIntValue();
+        
+        /* polyhedra rotation so it lays "flat" */
+        double zrot = Math.PI / numsides;
+        Rotation rot = new Rotation(detName + "_rotation");
+        rot.setZ(zrot);
+        define.addRotation(rot);
+        
+        /* total thickness of the detector */
+        double layersThickness = org.lcsim.geometry.layer.LayerFromCompactCnv.computeDetectorTotalThickness(node);
+        double zmax = zmin + layersThickness;
+        double radialThickness = rmax - rmin;
+        double detZ = layersThickness;
+        
+        /* envelope volume */
+        PolyhedraRegular polyhedra = new PolyhedraRegular(
+                detName + "_polyhedra",
+                numsides, rmin, rmax, detZ);
+        solids.addSolid(polyhedra);
+        
+        Volume envelopeVolume = new Volume(detName + "_envelope");
+        envelopeVolume.setSolid(polyhedra);
+        envelopeVolume.setMaterial(air);
+        
+        PhysVol envelopePhysvol = new PhysVol(envelopeVolume);
+        envelopePhysvol.setRotation(rot);
+        envelopePhysvol.addPhysVolID("system",id);
+        envelopePhysvol.addPhysVolID("barrel",0);
+        motherVolume.addPhysVol(envelopePhysvol);
+        
+        /* single stave trapezoid */
+        double innerAngle = Math.PI * 2 / numsides;
+        double halfInnerAngle = innerAngle/2;
+        
+        Trapezoid sectTrd = new Trapezoid(detName + "_stave_trapezoid");
+        sectTrd.setY2(layersThickness);
+        sectTrd.setY1(layersThickness);
+        sectTrd.setZ(radialThickness);
+        
+        double innerFaceLength = rmin * tan(halfInnerAngle) * 2;
+        sectTrd.setX1(innerFaceLength);
+        double outerFaceLength = rmax * tan(halfInnerAngle) * 2;
+        sectTrd.setX2(outerFaceLength);
+        
+        solids.addSolid(sectTrd);
+        Volume sectVolume = new Volume(detName + "_stave");
+        sectVolume.setMaterial(air);
+        sectVolume.setSolid(sectTrd);
+        
+        /* build the box layers in the stave */
+        double layerOuterAngle = (PI - innerAngle) / 2;
+        double layerInnerAngle = (PI/2 - layerOuterAngle);
+        
+        int layerNum = 0;
+        double posY = -layersThickness / 2;
+        for (Iterator i = node.getChildren("layer").iterator(); i.hasNext();)
+        {
+            Element layer = (Element) i.next();
+            int repeat = layer.getAttribute("repeat").getIntValue();
+            for ( int j=0; j<repeat; j++)
+            {
+                int sliceNum = 0;
+                for ( Iterator k = layer.getChildren("slice").iterator(); k.hasNext();)
+                {
+                    Element slice = (Element) k.next();
+                    
+                    String sliceName = detName + "_stave_layer" + layerNum + "_slice" + sliceNum;
+                    
+                    Attribute s = slice.getAttribute("sensitive");
+                    boolean sensitive = s != null && s.getBooleanValue();
+                    
+                    double thickness = slice.getAttribute("thickness").getDoubleValue();
+                    posY +=  thickness / 2;
+                    
+                    /* slice position */
+                    Position slicePosition = new Position(sliceName + "_position");
+                    slicePosition.setY(posY);
+                    define.addPosition(slicePosition);
+                    
+                    /* slice box */
+                    Trapezoid sliceTrd = new Trapezoid(sliceName + "_trapezoid");
+                    sliceTrd.setX1(innerFaceLength);
+                    sliceTrd.setX2(outerFaceLength);
+                    sliceTrd.setY1(thickness);
+                    sliceTrd.setY2(thickness);
+                    sliceTrd.setZ(radialThickness);
+                    solids.addSolid(sliceTrd);
+                    
+                    /* slice volume */
+                    Volume sliceVolume = new Volume(sliceName);
+                    sliceVolume.setSolid(sliceTrd);
+                    Material sliceMaterial = lcdd.getMaterial(slice.getAttributeValue("material"));
+                    sliceVolume.setMaterial(sliceMaterial);
+                    if ( sensitive ) sliceVolume.setSensitiveDetector(sens);
+                    structure.addVolume(sliceVolume);
+                    
+                    /* slice PhysVol */
+                    PhysVol slicePhysVol = new PhysVol(sliceVolume);
+                    slicePhysVol.setPosition(slicePosition);
+                    slicePhysVol.addPhysVolID("layer", layerNum);
+                    slicePhysVol.addPhysVolID("slice", sliceNum);
+                    sectVolume.addPhysVol(slicePhysVol);
+                    
+                    /* incr Y position */
+                    posY += thickness / 2;
+                    
+                    /* incr slice number */
+                    ++sliceNum;
+                }
+                /* incr layer number */
+                ++layerNum;
+            }
+        }
+        
+        /* add section volume after all slices */
+        structure.addVolume(sectVolume);
+        
+        /* place the staves */
+        double innerRotation = innerAngle;
+        double offsetRotation = -innerRotation / 2;
+        double placementRotation = -offsetRotation;
+        
+        double sectCenterRadius = rmin + radialThickness / 2;
+        double rotY = -offsetRotation;
+        double rotX = PI / 2;
+        double posX = -sectCenterRadius * sin(rotY);
+        double sectPosY = sectCenterRadius * cos(rotY);
+        for ( int i=0; i < numsides; i++)
+        {
+            int moduleNumber=i;
+            
+            Position position = new Position(detName + "_stave0_module" + moduleNumber + "_position");
+            position.setX(posX);
+            position.setY(sectPosY);
+            
+            Rotation rotation = new Rotation(detName + "_stave0_module" + moduleNumber + "_rotation");
+            rotation.setX(rotX);
+            rotation.setY(rotY);
+            
+            define.addPosition(position);
+            define.addRotation(rotation);
+            
+            PhysVol sectPhysVol = new PhysVol(sectVolume);
+            sectPhysVol.setPosition(position);
+            sectPhysVol.setRotation(rotation);
+            
+            envelopeVolume.addPhysVol(sectPhysVol);
+            sectPhysVol.addPhysVolID("stave",0);
+            sectPhysVol.addPhysVolID("module",moduleNumber);
+            
+            rotY -= innerRotation;
+            posX = -sectCenterRadius * sin(rotY);
+            sectPosY = sectCenterRadius * cos(rotY);
+        }
+        
+        /* add envelope volume after staves */
+        structure.addVolume(envelopeVolume);
+    }
+    
+    public boolean isCalorimeter()
+    {
+        return true;
+    }
+}
\ No newline at end of file
CVSspam 0.2.8