Commit in GeomConverter on MAIN | |||
src/org/lcsim/detector/converter/compact/HPSMuonCalorimeterConverter.java | +132 | added 1.1 | |
src/org/lcsim/geometry/compact/converter/lcdd/HPSMuonCalorimeter.java | +6 | -1 | 1.3 -> 1.4 |
src/org/lcsim/geometry/subdetector/HPSMuonCalorimeter.java | +14 | added 1.1 | |
test/org/lcsim/detector/converter/compact/HPSMuonCalorimeterTest.java | +48 | added 1.1 | |
testResources/org/lcsim/geometry/subdetector/HPSMuonCalorimeterTest.xml | +3 | -2 | 1.8 -> 1.9 |
+203 | -3 |
checkpointing work on HPS muon system
diff -N HPSMuonCalorimeterConverter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSMuonCalorimeterConverter.java 24 Jan 2013 22:25:38 -0000 1.1 @@ -0,0 +1,132 @@
+package org.lcsim.detector.converter.compact; + +import org.jdom.DataConversionException; +import org.jdom.Element; +import org.lcsim.detector.DetectorElement; +import org.lcsim.detector.ILogicalVolume; +import org.lcsim.detector.IRotation3D; +import org.lcsim.detector.ITranslation3D; +import org.lcsim.detector.LogicalVolume; +import org.lcsim.detector.PhysicalVolume; +import org.lcsim.detector.RotationGeant; +import org.lcsim.detector.Transform3D; +import org.lcsim.detector.Translation3D; +import org.lcsim.detector.identifier.ExpandedIdentifier; +import org.lcsim.detector.identifier.IExpandedIdentifier; +import org.lcsim.detector.identifier.IIdentifier; +import org.lcsim.detector.identifier.IIdentifierDictionary; +import org.lcsim.detector.identifier.IIdentifierHelper; +import org.lcsim.detector.material.IMaterial; +import org.lcsim.detector.material.MaterialStore; +import org.lcsim.detector.solids.Box; +import org.lcsim.geometry.compact.Detector; +import org.lcsim.geometry.compact.Subdetector; +import org.lcsim.geometry.subdetector.HPSMuonCalorimeter; + + +/** + * @author jeremym + * @version $Id: HPSMuonCalorimeterConverter.java,v 1.1 2013/01/24 22:25:38 jeremy Exp $ + */ +public class HPSMuonCalorimeterConverter extends AbstractSubdetectorConverter +{ + + public Class getSubdetectorType() + { + return HPSMuonCalorimeter.class; + } + + public void convert(Subdetector subdet, Detector detector) + { + + IIdentifierHelper helper = subdet.getDetectorElement().getIdentifierHelper(); + IIdentifierDictionary dict = helper.getIdentifierDictionary(); + + try { + Element node = subdet.getNode(); + String name = node.getAttributeValue("name"); + ILogicalVolume mother = detector.getWorldVolume().getLogicalVolume(); + + for (Object layerObject : node.getChildren("layer")) { + + Element layer = (Element) layerObject; + int layerId = layer.getAttribute("id").getIntValue(); + + int slice = 1; + for (Object boxObject : layer.getChildren("box")) { + + Element element = (Element) boxObject; + + double x, y, z, px, py, pz, rx, ry, rz; + x = y = z = px = py = pz = rx = ry = rz = 0.; + + if (element.getAttribute("x") != null) { + x = element.getAttribute("x").getDoubleValue(); + } else { + throw new RuntimeException("x is required."); + } + if (element.getAttribute("y") != null) { + y = element.getAttribute("y").getDoubleValue(); + } else { + throw new RuntimeException("y is required."); + } + if (element.getAttribute("z") != null) { + z = element.getAttribute("z").getDoubleValue(); + } else { + throw new RuntimeException("z is required."); + } + + if (element.getAttribute("px") != null) + px = element.getAttribute("px").getDoubleValue(); + if (element.getAttribute("py") != null) + py = element.getAttribute("py").getDoubleValue(); + if (element.getAttribute("pz") != null) + pz = element.getAttribute("pz").getDoubleValue(); + + if (element.getAttribute("rx") != null) + rx = element.getAttribute("rx").getDoubleValue(); + if (element.getAttribute("ry") != null) + ry = element.getAttribute("ry").getDoubleValue(); + if (element.getAttribute("rz") != null) + rz = element.getAttribute("rz").getDoubleValue(); + + String materialName = element.getAttributeValue("material"); + IMaterial material = MaterialStore.getInstance().get(materialName); + + String shapeBaseName = name + "_layer" + layerId + "_sublayer" + slice; + + Box box = new Box(shapeBaseName + "_box", x, y, z); + + ITranslation3D pos = new Translation3D(px, py, pz); + IRotation3D rot = new RotationGeant(rx, ry, rz); + ILogicalVolume vol = new LogicalVolume(shapeBaseName + "_vol", box, material); + + String physVolName = shapeBaseName + "_pv"; + new PhysicalVolume(new Transform3D(pos, rot), physVolName, vol, mother, 0); + + final IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); + expId.setValue(dict.getFieldIndex("system"), subdet.getSystemID()); + expId.setValue(dict.getFieldIndex("layer"), layerId); + expId.setValue(dict.getFieldIndex("slice"), slice); + int side = 1; + if (py < 0) { + side = -1; + } + expId.setValue(dict.getFieldIndex("side"), side); + final IIdentifier id = helper.pack(expId); + new DetectorElement(shapeBaseName, subdet.getDetectorElement(), "/" + physVolName, id); + + ++slice; + } + } + } catch (DataConversionException e) { + throw new RuntimeException(e); + } + + } + + public boolean isCalorimeter() + { + return true; + } +}
\ No newline at end of file
diff -u -r1.3 -r1.4 --- HPSMuonCalorimeter.java 6 Dec 2012 00:22:36 -0000 1.3 +++ HPSMuonCalorimeter.java 24 Jan 2013 22:25:38 -0000 1.4 @@ -13,7 +13,7 @@
/** * @author jeremym
- * @version $Id: HPSMuonCalorimeter.java,v 1.3 2012/12/06 00:22:36 jeremy Exp $
+ * @version $Id: HPSMuonCalorimeter.java,v 1.4 2013/01/24 22:25:38 jeremy Exp $
*/ public class HPSMuonCalorimeter extends LCDDSubdetector {
@@ -99,6 +99,11 @@
PhysVol physVol = new PhysVol(vol, mother, pos, rot); physVol.addPhysVolID("layer", layerId); physVol.addPhysVolID("slice", slice);
+ if (py >= 0) { + physVol.addPhysVolID("side", 1); + } else { + physVol.addPhysVolID("side", -1); + }
physVol.addPhysVolID("system", id); ++slice;
diff -N HPSMuonCalorimeter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSMuonCalorimeter.java 24 Jan 2013 22:25:38 -0000 1.1 @@ -0,0 +1,14 @@
+package org.lcsim.geometry.subdetector; + +import org.jdom.Element; +import org.jdom.JDOMException; + +/** + * @author Jeremy McCormick <[log in to unmask]> + * @version $Id: HPSMuonCalorimeter.java,v 1.1 2013/01/24 22:25:38 jeremy Exp $ + */ +public class HPSMuonCalorimeter extends AbstractSubdetector { + HPSMuonCalorimeter(Element node) throws JDOMException { + super(node); + } +}
\ No newline at end of file
diff -N HPSMuonCalorimeterTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSMuonCalorimeterTest.java 24 Jan 2013 22:25:38 -0000 1.1 @@ -0,0 +1,48 @@
+package org.lcsim.detector.converter.compact; + +import java.io.InputStream; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.identifier.IIdentifierDictionary; +import org.lcsim.detector.identifier.IIdentifierHelper; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.GeometryReader; + +public class HPSMuonCalorimeterTest extends TestCase +{ + + Detector detector = null; + private static final String resource = "/org/lcsim/geometry/subdetector/HPSMuonCalorimeterTest.xml"; + + public static Test suite() + { + return new TestSuite(HPSMuonCalorimeterTest.class); + } + + public void setUp() + { + InputStream in = this.getClass().getResourceAsStream(resource); + GeometryReader reader = new GeometryReader(); + try { + detector = reader.read(in); + } catch (Throwable x) { + throw new RuntimeException(x); + } + } + + public void testMuon() + { + IDetectorElement de = detector.getSubdetector("MUON").getDetectorElement(); + System.out.println("MUON has " + de.getChildren().size() + " children."); + IIdentifierHelper helper = de.getIdentifierHelper(); + IIdentifierDictionary dict = helper.getIdentifierDictionary(); + System.out.println(dict.toString()); + for (IDetectorElement child : de.getChildren()) { + System.out.println(child.getName() + " => " + helper.unpack(child.getIdentifier())); + } + } +}
\ No newline at end of file
diff -u -r1.8 -r1.9 --- HPSMuonCalorimeterTest.xml 11 Dec 2012 23:49:31 -0000 1.8 +++ HPSMuonCalorimeterTest.xml 24 Jan 2013 22:25:38 -0000 1.9 @@ -139,7 +139,8 @@
<readouts> <readout name="MUON_HITS"> <segmentation type="GridXYZ" gridSizeX="5.0" gridSizeY="5.0" gridSizeZ="0.0" />
- <id>system:6,side:-2,layer:4,slice:3,ix:32:-8,iy:-6</id>
+ <!--<id>system:6,side:-2,layer:4,slice:3,ix:32:-8,iy:-6</id>--> + <id>system:6,side:-2,layer:4,slice:3,x:32:-8,y:-6</id>
</readout> </readouts>
@@ -147,4 +148,4 @@
<gdmlFile file="./testResources/org/lcsim/geometry/subdetector/hps_2014_muon_vacuum_flange.gdml" /> </includes>
-</lccdd>
+</lccdd>
\ No newline at end of file
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1