11 modified files
GeomConverter/src/org/lcsim/detector
diff -u -r1.7 -r1.8
--- DetectorElement.java 20 Mar 2007 01:31:03 -0000 1.7
+++ DetectorElement.java 20 Mar 2007 21:19:59 -0000 1.8
@@ -12,34 +12,121 @@
IIdentifier id;
/**
- * Create a DE with support in the geometry tree.
+ * Create a DE with complete arguments, including
+ * a parent DE, geometry support as a String, and
+ * an id.
+ *
+ * @param name The name of this DE.
+ * @param parent The parent DE.
+ * @param support The geometry support as a String.
+ * @param id The DE's identifier.
+ */
+ public DetectorElement(
+ String name,
+ IDetectorElement parent,
+ IPhysicalVolumePath support,
+ IIdentifier id)
+ {
+ super(name);
+ setup(parent,support,id);
+ register();
+ }
+
+ /**
+ * Create a DE with a parent and support in the geometry tree.
*
* @param name
* @param parent
* @param support
- * @param id
*/
public DetectorElement(
String name,
IDetectorElement parent,
- IPhysicalVolumePath support,
- IIdentifier id)
+ IPhysicalVolumePath support)
{
super(name);
-
- setup(parent, support, id);
-
+ setup(parent,support,null);
+ register();
+ }
+
+ /**
+ * Create a DE with complete arguments, including
+ * a parent DE, geometry support, and an id.
+ *
+ * @param name
+ * @param parent
+ * @param support
+ */
+ public DetectorElement(
+ String name,
+ IDetectorElement parent,
+ String support)
+ {
+ super(name);
+ setup(parent,support,id);
+ register();
+ }
+
+
+ /**
+ * Create a DE with a parent but no support in the geometry,
+ * e.g. a ghost volume.
+ *
+ * @param name
+ * @param parent
+ */
+ public DetectorElement(
+ String name,
+ IDetectorElement parent)
+ {
+ super(name);
+ setParent(parent);
register();
}
+ /**
+ * Create a DE with no parent and no support.
+ * If this constructor is used, then an external
+ * routine must setup the parent, support, and/or
+ * id later.
+ *
+ * @param name
+ */
public DetectorElement(
String name)
{
- super(name);
-
+ super(name);
register();
}
+ /**
+ * Set the parent IDetectorElement. Once this
+ * has been set, additional calls to this method
+ * will cause a RuntimeException.
+ *
+ * @param parent The parent IDetectorElement.
+ * @throws RuntimeException If the parent IDetectorElement is already set.
+ * @throws IllegalArgumentException If @param parent is null.
+ */
+ public void setParent(IDetectorElement parent)
+ {
+ if ( this.parent != null )
+ {
+ throw new RuntimeException("The IDetectorElement <" + getName() + "> already has a parent!");
+ }
+
+ if ( parent == null )
+ {
+ throw new IllegalArgumentException("The parent IDetectorElement is null!");
+ }
+
+ this.parent=parent;
+ ((DetectorElement)parent).addChild(this);
+ }
+
+ /**
+ * Register this IDetectorElement with the DetectorElementStore.
+ */
private void register()
{
if ( !DetectorElementStore.getInstance().contains(this) )
@@ -47,38 +134,81 @@
DetectorElementStore.getInstance().add(this);
}
}
-
- protected void setup(
+
+ private void setup(
IDetectorElement parent,
IPhysicalVolumePath support,
IIdentifier id
)
{
- this.parent = parent;
- this.geometry = new GeometryInfo( this, support );
- this.id = id;
- }
+ if ( parent != null )
+ {
+ setParent(parent);
+ }
+
+ if ( support != null )
+ {
+ setSupport(support);
+ }
+
+ if ( id != null )
+ {
+ setIdentifier(id);
+ }
+ }
- public void createGeometryInfo(IPhysicalVolumePath path)
+ private void setup(
+ IDetectorElement parent,
+ String support,
+ IIdentifier id
+ )
+ {
+ if ( parent != null )
+ {
+ setParent(parent);
+ }
+
+ if ( support != null )
+ {
+ setSupport(support);
+ }
+
+ if ( id != null )
+ {
+ setIdentifier(id);
+ }
+ }
+
+ public void setSupport(IPhysicalVolumePath support)
+ {
+ createGeometryInfo(support);
+ }
+
+ public void setSupport(String path)
+ {
+ createGeometryInfo(path);
+ }
+
+ private void createGeometryInfo(IPhysicalVolumePath path)
{
geometry = new GeometryInfo(this,path);
}
-
- public void createGeometryInfo(String path)
+
+ private void createGeometryInfo(String path)
{
IPhysicalVolumeNavigator nav = PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
geometry = new GeometryInfo(this,nav.getPath(path));
}
-
- public void createGeometryInfo()
+
+ private void createGeometryInfo()
{
if ( geometry == null )
{
geometry = new GeometryInfo(this, (IPhysicalVolumePath)null);
}
}
-
- public void addChild(IDetectorElement child)
+
+ protected void addChild(IDetectorElement child)
{
children.add(child);
}
GeomConverter/src/org/lcsim/detector
diff -u -r1.1 -r1.2
--- DetectorElementContainer.java 17 Mar 2007 00:10:40 -0000 1.1
+++ DetectorElementContainer.java 20 Mar 2007 21:19:59 -0000 1.2
@@ -5,4 +5,40 @@
public class DetectorElementContainer
extends ArrayList<IDetectorElement>
implements IDetectorElementContainer
-{}
\ No newline at end of file
+{
+ public IDetectorElement get(String name)
+ {
+ IDetectorElement search=null;
+ for ( IDetectorElement de : this )
+ {
+ if ( de.getName().equals(name))
+ {
+ search = de;
+ break;
+ }
+ }
+ return search;
+ }
+
+ public boolean contains(String name)
+ {
+ return get(name) != null;
+ }
+
+ public boolean add(IDetectorElement de)
+ {
+ if ( contains(de) )
+ {
+ throw new IllegalArgumentException("The DetectorElement <"+de.getName()+"> is already registered!");
+ }
+
+ if ( get(de.getName()) != null )
+ {
+ throw new IllegalArgumentException("There is already a DetectorElement called <"+de.getName()+"> in this container!");
+ }
+
+ super.add(de);
+
+ return true;
+ }
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -u -r1.3 -r1.4
--- IDetectorElement.java 17 Mar 2007 00:10:40 -0000 1.3
+++ IDetectorElement.java 20 Mar 2007 21:19:59 -0000 1.4
@@ -1,6 +1,7 @@
package org.lcsim.detector;
import org.lcsim.detector.identifier.IIdentifiable;
+import org.lcsim.detector.identifier.IIdentifier;
/**
* A class to represent a node in the detector tree,
@@ -8,7 +9,7 @@
*
* @author Tim Nelson <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: IDetectorElement.java,v 1.3 2007/03/17 00:10:40 jeremy Exp $
+ * @version $Id: IDetectorElement.java,v 1.4 2007/03/20 21:19:59 jeremy Exp $
*/
public interface IDetectorElement
extends IIdentifiable, INamed
@@ -31,6 +32,11 @@
*/
public IDetectorElementContainer getChildren();
+ /**
+ * True if the IDetectorElement has children.
+ *
+ * @return True if has children else False.
+ */
public boolean hasChildren();
/**
@@ -38,4 +44,25 @@
* @return The name this DE.
*/
public String getName();
+
+
+ /**
+ * Set the identifier of this DE.
+ *
+ * @param id
+ */
+ public void setIdentifier(IIdentifier id);
+
+ /**
+ * Get the identifier of this DE.
+ */
+ public IIdentifier getIdentifier();
+
+ /**
+ * Set the parent IDetectorElement. This method
+ * also calls addChild on the parent.
+ *
+ * @param parent
+ */
+ public void setParent(IDetectorElement parent);
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -u -r1.2 -r1.3
--- IDetectorElementContainer.java 17 Mar 2007 00:10:40 -0000 1.2
+++ IDetectorElementContainer.java 20 Mar 2007 21:19:59 -0000 1.3
@@ -4,4 +4,7 @@
public interface IDetectorElementContainer
extends List<IDetectorElement>
-{}
\ No newline at end of file
+{
+ public IDetectorElement get(String name);
+ public boolean contains(String name);
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.3 -r1.4
--- CylindricalBarrelCalorimeterConverter.java 20 Mar 2007 00:47:19 -0000 1.3
+++ CylindricalBarrelCalorimeterConverter.java 20 Mar 2007 21:19:59 -0000 1.4
@@ -51,12 +51,13 @@
IPhysicalVolumeNavigator nav =
PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
IPhysicalVolumePath path = nav.getPath( cal.getName() );
- cal.createGeometryInfo(path);
+ cal.setSupport(path);
// Build the layers.
buildLayers(cal, envelope);
- detector.addChild(subdet);
+ // Set the parent DE.
+ subdet.setParent(detector);
}
private ILogicalVolume buildEnvelope(
@@ -88,7 +89,7 @@
double zHalfLength = cal.getZMax();
- int sensorNumber = 1;
+ int sensorNumber = 0;
for (int i=0; i<layering.getNumberOfLayers(); i++)
{
@@ -155,14 +156,14 @@
{
// Path to the PhysicalVolume of this sensor.
String sensorPath = "/" + cal.getName() + "/" + layerName + "/" + sliceName;
-
- DetectorElement sensor = new DetectorElement("sensor"+sensorNumber);
- sensor.createGeometryInfo(sensorPath);
+
+ new DetectorElement(
+ cal.getName() + "_sensor" + sensorNumber,
+ cal,
+ sensorPath);
// Increment the number of sensors.
- ++sensorNumber;
-
- cal.addChild(sensor);
+ ++sensorNumber;
}
sliceInnerRadius += sliceThickness;
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.2 -r1.3
--- CylindricalEndcapCalorimeterConverter.java 20 Mar 2007 00:47:19 -0000 1.2
+++ CylindricalEndcapCalorimeterConverter.java 20 Mar 2007 21:19:59 -0000 1.3
@@ -46,30 +46,27 @@
double negz = -cal.getZMin() - width;
// DE for positive endcap.
- DetectorElement endcap = new DetectorElement(cal.getName() + "_positive");
- endcap.createGeometryInfo(cal.getName() + "_positive");
- detector.addChild(endcap);
+ DetectorElement endcap = new DetectorElement(cal.getName() + "_positive", detector);
+ endcap.setSupport(cal.getName() + "_positive");
// DE for negative endcap.
DetectorElement reflectedEndcap=null;
if ( cal.getReflect() )
{
Rotation3D reflect =
- new Rotation3D(Rotation3D.passiveXRotation(Math.PI));
-
- IPhysicalVolume pv2 =
- new PhysicalVolume(
- new Transform3D(new BasicHep3Vector(0,0,negz), reflect),
- cal.getName() + "_negative",
- envelope,
- world.getLogicalVolume(),
- subdet.getSystemID()
- );
+ new Rotation3D(Rotation3D.passiveXRotation(Math.PI));
- reflectedEndcap = new DetectorElement(cal.getName() + "_negative");
- reflectedEndcap.createGeometryInfo(cal.getName() + "_negative");
-
- detector.addChild(reflectedEndcap);
+ new PhysicalVolume
+ (
+ new Transform3D(new BasicHep3Vector(0,0,negz), reflect),
+ cal.getName() + "_negative",
+ envelope,
+ world.getLogicalVolume(),
+ subdet.getSystemID()
+ );
+
+ reflectedEndcap = new DetectorElement(cal.getName() + "_negative", detector);
+ reflectedEndcap.setSupport(cal.getName() + "_negative");
}
// Build the layers into the logical volume.
@@ -84,7 +81,7 @@
DetectorElement endcap,
DetectorElement reflectedEndcap)
{
- int sensorNum=1;
+ int sensorNum=0;
for (int i=0; i<cal.getLayering().getNumberOfLayers(); i++)
{
@@ -95,18 +92,25 @@
String sliceName = "slice" + j;
LayerSlice slice = layer.getSlice(j);
if ( slice.isSensitive() )
- {
- DetectorElement detelem = new DetectorElement("sensor"+sensorNum);
- String pathName = "/" + cal.getName() + "_positive" + "/" + layerName + "/" + sliceName;
- detelem.createGeometryInfo(pathName);
- endcap.addChild(detelem);
+ {
+ // Create the DE for an endcap sensor.
+ String pathName = "/" + cal.getName() + "_positive" + "/" + layerName + "/" + sliceName;
+ new DetectorElement(
+ cal.getName() + "_positive_sensor" + sensorNum,
+ endcap,
+ pathName);
+
+ // Create the DE for a reflected endcap sensor.
if ( reflectedEndcap != null )
{
- detelem = new DetectorElement("sensor"+sensorNum);
pathName = "/" + cal.getName() + "_negative" + "/" + layerName + "/" + sliceName;
- detelem.createGeometryInfo(pathName);
- reflectedEndcap.addChild(detelem);
+ new DetectorElement(
+ cal.getName() + "_negative_sensor" + sensorNum,
+ reflectedEndcap,
+ pathName);
}
+
+ // Increment the sensor number.
++sensorNum;
}
}
@@ -145,16 +149,12 @@
double outerRadius = cal.getOuterRadius();
String name = cal.getName();
-
- //double zLayer = cal.getZMin();
-
+
double thickness = cal.getZMax() - cal.getZMin();
double zLayer = -thickness/2;
for (int i=0; i<layering.getNumberOfLayers(); i++)
- {
- //System.out.println("zLayer="+zLayer);
-
+ {
Layer layer = layering.getLayer(i);
Tube tubeLayer = new Tube(
@@ -182,9 +182,7 @@
double zSlice = zLayer;
for (int j=0; j<layer.getNumberOfSlices(); j++)
- {
- //System.out.println("zSlice="+zSlice);
-
+ {
LayerSlice slice = layer.getSlice(j);
Tube tubeSlice = new Tube(
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.6 -r1.7
--- DetectorConverter.java 20 Mar 2007 00:47:19 -0000 1.6
+++ DetectorConverter.java 20 Mar 2007 21:19:59 -0000 1.7
@@ -59,7 +59,7 @@
// Create the default navigator.
PhysicalVolumeNavigatorStore.getInstance().reset();
PhysicalVolumeNavigatorStore.getInstance().createDefault(pvWorld);
- detector.createGeometryInfo("/");
+ detector.setSupport("/");
detector.setWorldVolume(pvWorld);
convertMaterials("/org/lcsim/material/elements.xml");
GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.3 -r1.4
--- DESubdetectorBox.java 17 Mar 2007 00:21:12 -0000 1.3
+++ DESubdetectorBox.java 20 Mar 2007 21:20:00 -0000 1.4
@@ -33,7 +33,9 @@
{
DummyDE(IPhysicalVolumePath support)
{
- super("dummy",null,support,null);
+ //super("dummy",null,support,null);
+ super("dummy");
+ this.setSupport(support);
}
}
GeomConverter/test/org/lcsim/detector
diff -u -r1.9 -r1.10
--- SimpleDetectorTest.java 20 Mar 2007 00:47:19 -0000 1.9
+++ SimpleDetectorTest.java 20 Mar 2007 21:20:00 -0000 1.10
@@ -3,10 +3,6 @@
import static org.lcsim.units.clhep.SystemOfUnits.m;
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
-
-import java.util.ArrayList;
-import java.util.List;
-
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -299,7 +295,9 @@
{
DummyDE(IPhysicalVolumePath support)
{
- super("dummy",null,support,null);
+ //super("dummy",null,support,null);
+ super("dummy");
+ setSupport(support);
}
}
}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector/converter/compact
diff -u -r1.3 -r1.4
--- DetectorConverterTest.java 20 Mar 2007 00:47:19 -0000 1.3
+++ DetectorConverterTest.java 20 Mar 2007 21:20:00 -0000 1.4
@@ -11,8 +11,13 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.lcsim.detector.DetectorElementStore;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.IPhysicalVolume;
+import org.lcsim.detector.IPhysicalVolumeNavigator;
+import org.lcsim.detector.PhysicalVolumeNavigatorStore;
+import org.lcsim.detector.PhysicalVolumeStore;
import org.lcsim.detector.solids.Tube;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.GeometryReader;
@@ -20,6 +25,8 @@
public class DetectorConverterTest
extends TestCase
{
+ private Detector detector;
+
public DetectorConverterTest(String name)
{
super(name);
@@ -30,7 +37,43 @@
return new TestSuite(DetectorConverterTest.class);
}
- private static final String resource = "/org/lcsim/detector/converter/compact/DetectorConverterTest.xml";
+ private static final String resource = "/org/lcsim/detector/converter/compact/DetectorConverterTest.xml";
+ 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 testGeometry() throws Exception
+ {
+ IPhysicalVolumeNavigator nav =
+ PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
+ IPhysicalVolume world = nav.getTopPhysicalVolume();
+
+ // Check that the world volume is there with the correct name.
+ assertTrue("Top volume is not the world!", world.getName().equals("world"));
+
+ // Check that the world volume does not have a mother volume.
+ assertTrue("World volume has a mother!", world.getMotherLogicalVolume() == null);
+
+ IDetectorElement deDetector = (IDetectorElement)detector;
+
+ String des[] = new String[]{"ecal_barrel","ecal_endcap_positive","ecal_endcap_negative"};
+
+ // Check for DEs that should have been built.
+ for ( String de : des ) {
+ assertTrue(de + " is missing!", deDetector.getChildren().get(de) != null);
+ }
+ }
/**
* Read in a Detector and test the detailed geometry that is created.
@@ -38,32 +81,45 @@
* @throws Exception
*/
public void testDetectorConverter() throws Exception
- {
- InputStream in =
- this.getClass().
- getResourceAsStream(resource);
- GeometryReader reader = new GeometryReader();
- Detector det = reader.read(in);
+ {
+ System.out.println("dumping pv store ...");
+ for (IPhysicalVolume pv : PhysicalVolumeStore.getInstance())
+ {
+ System.out.println(pv.getName());
+ }
+ System.out.println();
+
+ System.out.println("dumping de store ...");
+ for (IDetectorElement de : DetectorElementStore.getInstance())
+ {
+ System.out.println(de.getName());
+ for (IDetectorElement child : de.getChildren())
+ {
+ System.out.println(" "+child.getName());
+ }
+ }
+ System.out.println();
List<Hep3Vector> points = new ArrayList<Hep3Vector>();
//points.add(new BasicHep3Vector(0,105*cm,0));
//points.add(new BasicHep3Vector(0,115*cm,0));
points.add(new BasicHep3Vector(0,0,255*cm));
//points.add(new BasicHep3Vector(0,0,265*cm));
- //points.add(new BasicHep3Vector(0,0,-255.0*cm));
+ points.add(new BasicHep3Vector(0,0,-255.0*cm));
//points.add(new BasicHep3Vector(0,0,-265*cm));
+
+ IPhysicalVolumeNavigator nav =
+ PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
- System.out.println(det.getName());
+ //IPhysicalVolumePath ecn = nav.getPath("/ecal_endcap_negative");
+ //System.out.println("ecn="+ecn.getTopVolume().getName());
+ //System.out.println("ecn trans="+ecn.getTopVolume().getTransform());
- for ( IDetectorElement child : det.getChildren() )
+ for ( IDetectorElement child : detector.getChildren() )
{
for ( IDetectorElement sensor : child.getChildren() )
{
IGeometryInfo sensorGeo = sensor.getGeometry();
-
- //System.out.println("Checking isInside for </" + child.getName() + "/" + sensor.getName() + ">.");
-
- //System.out.println("Position of <" + sensor.getName() + "> : " + sensor.getGeometry().getPosition() );
Tube sensorTube = (Tube)sensorGeo.getLogicalVolume().getSolid();
@@ -98,7 +154,7 @@
System.out.println("zpoint < (zsensor + zwidth ) = " + (zpoint < (zsensor + zwidth )));
*/
- assertTrue(sensor.getGeometry().isInside(point));
+ //assertTrue(sensor.getGeometry().isInside(point));
if ( zpoint > (zsensor - zwidth ) &&
zpoint < (zsensor + zwidth ) )
@@ -107,11 +163,20 @@
}
}
// Check isInside for endcap negative.
- else if ( child.getName().contains("endcap_negative") )
+ else if ( child.getName().contains("ecal_endcap_negative") )
{
+ //System.out.println("point = " + point);
+ //System.out.println("point path = " + nav.getPath(point));
+ //System.out.println("endcap_negative");
if ( zpoint < (zsensor + zwidth ) &&
zpoint > (zsensor - zwidth ) )
{
+ sensorGeo.getDetectorElement();
+ sensorGeo.getDetectorElement().getParent();
+ sensorGeo.getDetectorElement().getParent().getName();
+
+ //System.out.println("check " + sensor.getName() + " @ point = " + point);
+
assertTrue(sensorGeo.isInside(point));
}
}
GeomConverter/test/org/lcsim/detector/converter/compact
diff -u -r1.3 -r1.4
--- DetectorConverterTest.xml 20 Mar 2007 00:51:42 -0000 1.3
+++ DetectorConverterTest.xml 20 Mar 2007 21:20:00 -0000 1.4
@@ -35,9 +35,9 @@
</layer>
</detector>
- <detector id="2" name="ecal_endcap" reflect="false" type="CylindricalEndcapCalorimeter" readout="EcalEndcapHits">
+ <detector id="2" name="ecal_endcap" reflect="true" type="CylindricalEndcapCalorimeter" readout="EcalEndcapHits">
<dimensions inner_r = "0.0" inner_z = "250.0*cm" outer_r = "100.0*cm" />
- <layer repeat="1">
+ <layer repeat="2">
<slice material = "Silicon" thickness = "10.0*cm" sensitive = "yes" />
</layer>
</detector>
CVSspam 0.2.8