Print

Print


Author: [log in to unmask]
Date: Mon Feb  2 14:15:32 2015
New Revision: 3498

Log:
Allow bottom and top gap sizes to be different in HPSEcal3 detector model.  HPSJAVA-388

Added:
    projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSEcal3Test.java
Removed:
    projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/detector/converter/compact/HPSEcal3ConverterTest.java
Modified:
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSEcal3Converter.java
    projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal3.java
    projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSEcal3Test.xml

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSEcal3Converter.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSEcal3Converter.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/detector/converter/compact/HPSEcal3Converter.java	Mon Feb  2 14:15:32 2015
@@ -104,7 +104,8 @@
 
         double dx1, dx2, dy1, dy2, dz;
         Element layout;
-        double beamgap;
+        double beamgap = 0;
+        double beamgapTop, beamgapBottom;
         int nx, ny;
         double dface;
         double tdx, tdy, tdz;
@@ -120,7 +121,21 @@
 
             // Layout parameters.
             layout = subdet.getNode().getChild("layout");
-            beamgap = layout.getAttribute("beamgap").getDoubleValue();
+            if (layout.getAttribute("beamgap") != null) {
+                beamgap = layout.getAttribute("beamgap").getDoubleValue();
+            } else {
+                if (layout.getAttribute("beamgapTop") == null || layout.getAttribute("beamgapBottom") == null) {
+                    throw new RuntimeException("Missing beamgap parameter in layout element, and beamgapTop or beamgapBottom was not provided.");
+                }
+            }
+            beamgapTop = beamgap;
+            if (layout.getAttribute("beamgapTop") != null) {
+                beamgapTop = layout.getAttribute("beamgapTop").getDoubleValue();
+            }
+            beamgapBottom = beamgap;
+            if (layout.getAttribute("beamgapBottom") != null) {
+                beamgapBottom = layout.getAttribute("beamgapBottom").getDoubleValue();
+            }                         
             nx = layout.getAttribute("nx").getIntValue();
             ny = layout.getAttribute("ny").getIntValue();
             dface = layout.getAttribute("dface").getDoubleValue();
@@ -249,7 +264,7 @@
 
                 if (checkRange(ix, -iy, ranges)) {
                     // Transform of positive bottom crystal.
-                    ITranslation3D iposBot = new Translation3D(xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
+                    ITranslation3D iposBot = new Translation3D(xcenter + bdx, -(beamgapBottom + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
                     IRotation3D irotBot = new RotationGeant(-thetax, -thetay, thetaz);
 
                     // Place positive crystal.
@@ -262,7 +277,7 @@
                 if (ix != 0) {
                     if (checkRange(-ix, -iy, ranges)) {
                         // Transform of negative.
-                        ITranslation3D iposnegBot = new Translation3D(-xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
+                        ITranslation3D iposnegBot = new Translation3D(-xcenter + bdx, -(beamgapBottom + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
                         IRotation3D irotnegBot = new RotationGeant(-thetax, thetay, thetaz);
 
                         // Place negative crystal.
@@ -274,7 +289,7 @@
 
                 if (checkRange(ix, iy, ranges)) {
                     // Transform of positive top crystal.
-                    Translation3D iposTop = new Translation3D(xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
+                    Translation3D iposTop = new Translation3D(xcenter + tdx, beamgapTop + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
                     IRotation3D irotTop = new RotationGeant(thetax, -thetay, thetaz);
 
                     // Place positive top crystal.
@@ -287,7 +302,7 @@
                 if (ix != 0) {
                     if (checkRange(-ix, iy, ranges)) {
                         // Transform of negative.
-                        ITranslation3D iposnegTop = new Translation3D(-xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
+                        ITranslation3D iposnegTop = new Translation3D(-xcenter + tdx, beamgapTop + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
                         IRotation3D irotnegTop = new RotationGeant(thetax, thetay, thetaz);
 
                         // Place negative crystal.

Modified: projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal3.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal3.java	(original)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal3.java	Mon Feb  2 14:15:32 2015
@@ -36,6 +36,8 @@
  * 
  * <ul>
  * <li><b>beamgap</b> - offset from the beamline in the Y coordinate of the top and bottom halves</li>
+ * <li><b>beamgapTop</b> - offset from the beamline in the Y coordinate for the top half (defaults to <b>beamgap</b>)</li>
+ * <li><b>beamgapBottom</b> - offset from the beamline in the Y coordinate for the bottom half (defaults to <b>beamgap</b>)</li>
  * <li><b>nx</b> - number of crystals in X</li>
  * <li><b>ny</b> - number of crystals in Y along each side of beam</li>
  * <li><b>dface</b> - distance from origin to the face of the calorimeter along Z</li>
@@ -142,7 +144,22 @@
 
         // Layout parameters.
         Element layout = node.getChild("layout");
-        double beamgap = layout.getAttribute("beamgap").getDoubleValue();
+        double beamgap = 0;
+        if (layout.getAttribute("beamgap") != null) {
+            beamgap = layout.getAttribute("beamgap").getDoubleValue();
+        } else {
+            if (layout.getAttribute("beamgapTop") == null || layout.getAttribute("beamgapBottom") == null) {
+                throw new RuntimeException("Missing beamgap parameter in layout element, and beamgapTop or beamgapBottom was not provided.");
+            }
+        }
+        double beamgapTop = beamgap;
+        if (layout.getAttribute("beamgapTop") != null) {
+            beamgapTop = layout.getAttribute("beamgapTop").getDoubleValue();
+        }
+        double beamgapBottom = beamgap;
+        if (layout.getAttribute("beamgapBottom") != null) {
+            beamgapBottom = layout.getAttribute("beamgapBottom").getDoubleValue();
+        } 
         int nx = layout.getAttribute("nx").getIntValue();
         int ny = layout.getAttribute("ny").getIntValue();
         double dface = layout.getAttribute("dface").getDoubleValue();
@@ -269,7 +286,7 @@
 
                 if (checkRange(ix, -iy, ranges)) {
                     // Transform of positive bottom crystal.
-                    Position iposBot = new Position(baseName + "_pos_pos_bot", xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
+                    Position iposBot = new Position(baseName + "_pos_pos_bot", xcenter + bdx, -(beamgapBottom + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
                     
                     //System.out.println("iposBot = " + iposBot.x() + ", " + iposBot.y() + " , " + iposBot.z() + " --> " + ix + ", " + -iy);
                     Rotation irotBot = new Rotation(baseName + "_rot_pos_bot", -thetax, -thetay, thetaz);
@@ -289,7 +306,7 @@
                 if (ix != 0) {
                     if (checkRange(-ix, -iy, ranges)) {
                         // Transform of negative.
-                        Position iposnegBot = new Position(baseName + "_pos_neg_bot", -xcenter + bdx, -(beamgap + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
+                        Position iposnegBot = new Position(baseName + "_pos_neg_bot", -xcenter + bdx, -(beamgapBottom + ycenter + tolerance) + bdy, zcenter + tolerance + dface + bdz);
                         //System.out.println("iposnegBot = " + iposnegBot.x() + ", " + iposnegBot.y() + " , " + iposnegBot.z() + " --> " + -ix + ", " + -iy);
                         Rotation irotnegBot = new Rotation(baseName + "_rot_neg_bot", -thetax, thetay, thetaz);
 
@@ -308,7 +325,7 @@
 
                 if (checkRange(ix, iy, ranges)) {
                     // Transform of positive top crystal.
-                    Position iposTop = new Position(baseName + "_pos_pos_top", xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
+                    Position iposTop = new Position(baseName + "_pos_pos_top", xcenter + tdx, beamgapTop + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
                     //System.out.println("iposTop = " + iposTop.x() + ", " + iposTop.y() + " , " + iposTop.z() + " --> " + ix + ", " + iy);
                     Rotation irotTop = new Rotation(baseName + "_rot_pos_top", thetax, -thetay, thetaz);
                     define.addPosition(iposTop);
@@ -327,7 +344,7 @@
                 if (ix != 0) {
                     if (checkRange(-ix, iy, ranges)) {
                         // Transform of negative.
-                        Position iposnegTop = new Position(baseName + "_pos_neg_top", -xcenter + tdx, beamgap + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
+                        Position iposnegTop = new Position(baseName + "_pos_neg_top", -xcenter + tdx, beamgapTop + ycenter + tolerance + tdy, zcenter + tolerance + dface + tdz);
                         //System.out.println("iposTop = " + iposnegTop.x() + ", " + iposnegTop.y() + " , " + iposnegTop.z() + " --> " + -ix + ", " + iy);
                         Rotation irotnegTop = new Rotation(baseName + "_rot_neg_top", thetax, thetay, thetaz);
 

Added: projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSEcal3Test.java
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSEcal3Test.java	(added)
+++ projects/lcsim/trunk/detector-framework/src/test/java/org/lcsim/geometry/subdetector/HPSEcal3Test.java	Mon Feb  2 14:15:32 2015
@@ -0,0 +1,57 @@
+package org.lcsim.geometry.subdetector;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import junit.framework.TestCase;
+
+import org.lcsim.detector.IDetectorElement;
+import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.GeometryReader;
+import org.lcsim.geometry.compact.converter.lcdd.Main;
+import org.lcsim.util.test.TestUtil.TestOutputFile;
+
+/**
+ * Test conversion of detector type {@link org.lcsim.geometry.subdetector.HPSEcal3} 
+ * to LCDD, Heprep, and in-memory Java objects.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class HPSEcal3Test extends TestCase {
+        
+    public void testLCDD() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/HPSEcal3Test.xml");
+        new TestOutputFile(getClass().getSimpleName()).mkdir();
+        File file = new TestOutputFile(getClass().getSimpleName()  + File.separator + "HPSEcal3Test.lcdd");
+        OutputStream out = new FileOutputStream(file);
+        new Main().convert("HPSEcal3Test", in, out);
+    }
+    
+    public void testHeprep() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/HPSEcal3Test.xml");
+        new TestOutputFile(getClass().getSimpleName()).mkdir();
+        File file = new TestOutputFile(getClass().getSimpleName()  + File.separator + "HPSEcal3Test.heprep");
+        OutputStream out = new FileOutputStream(file);
+        new org.lcsim.geometry.compact.converter.heprep.Main().convert("HPSEcal3Test", in, out);
+    }
+    
+    public void testDetector() throws Exception {
+        GeometryReader geometryReader = new GeometryReader();
+        InputStream in = getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/HPSEcal3Test.xml");
+        Detector detector = geometryReader.read(in);
+        System.out.println("built detector " + detector.getName());
+        
+        IDetectorElement de = detector.getSubdetector("ECAL").getDetectorElement();
+        System.out.println("ECAL has " + de.getChildren().size() + " crystals.");
+        IIdentifierHelper helper = de.getIdentifierHelper();
+        for (IDetectorElement crystal : de.getChildren()) {
+            IGeometryInfo geometry = crystal.getGeometry();
+            System.out.println(crystal.getName() + " - " + helper.unpack(crystal.getIdentifier()) + " @ " + geometry.getPosition());
+        }
+        
+    }
+}

Modified: projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSEcal3Test.xml
 =============================================================================
--- projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSEcal3Test.xml	(original)
+++ projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSEcal3Test.xml	Mon Feb  2 14:15:32 2015
@@ -1,7 +1,5 @@
-<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
-       xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
-       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
-    <info name="HPSEcal3Test"/>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+    <info name="HPSEcal3Test" />
     <define>   
         <!-- world volume -->
         <constant name="world_side" value="10000.0*cm" />
@@ -9,32 +7,28 @@
         <constant name="world_y" value="world_side" />
         <constant name="world_z" value="world_side" />
         <!-- tracking region -->
-        <constant name="tracking_region_radius" value="200.0*cm"/>
-        <constant name="tracking_region_min" value="5.0*cm"/>
-        <constant name="tracking_region_zmax" value="100.0*cm"/>
-        <!-- ECal placement parameters -->       
+        <constant name="tracking_region_radius" value="200.0*cm" />
+        <constant name="tracking_region_min" value="5.0*cm" />
+        <constant name="tracking_region_zmax" value="100.0*cm" />
+        <!-- ECal placement parameters -->
         <constant name="ecal_front" value="13.3/2*mm" />
         <constant name="ecal_back" value="16/2*mm" />
         <constant name="ecal_z" value="160/2*mm" />
     </define>
     <materials>
         <material name="LeadTungstate">
-            <D value="8.28" unit="g/cm3"/>
-            <composite n="1" ref="Pb"/>
-            <composite n="1" ref="W"/>
-            <composite n="4" ref="O"/>
+            <D value="8.28" unit="g/cm3" />
+            <composite n="1" ref="Pb" />
+            <composite n="1" ref="W" />
+            <composite n="4" ref="O" />
         </material>
     </materials>
     <detectors>
-        <detector id="2" 
-                  name="ECAL" 
-                  type="HPSEcal3" 
-                  insideTrackingVolume="false" 
-                  readout="ECAL_HITS">
+        <detector id="2" name="ECAL" type="HPSEcal3" insideTrackingVolume="false" readout="ECAL_HITS">
             <material name="LeadTungstate" />
             <dimensions x1="ecal_front" y1="ecal_front" x2="ecal_back" y2="ecal_back" z="ecal_z" />
-            <layout beamgap="20.0*mm" nx="46" ny="5" dface="120.0*cm">
-                <remove ixmin="2" ixmax="7" iymin="-1" iymax="1" /> 
+            <layout beamgapBottom="40.0*mm" beamgapTop="20.0*mm" nx="46" ny="5" dface="120.0*cm">
+                <remove ixmin="2" ixmax="7" iymin="-1" iymax="1" />
             </layout>
         </detector>
     </detectors>
@@ -44,4 +38,4 @@
             <id>system:6,side:-2,layer:4,ix:-8,iy:-6</id>
         </readout>
     </readouts>
-</lccdd>
+</lccdd>

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1