11 modified files
GeomConverter/src/org/lcsim/detector
diff -u -r1.6 -r1.7
--- GeometryInfo.java 17 Mar 2007 00:10:40 -0000 1.6
+++ GeometryInfo.java 20 Mar 2007 00:47:17 -0000 1.7
@@ -17,243 +17,288 @@
public class GeometryInfo
implements IGeometryInfo
{
- IDetectorElement detectorElement;
- IGeometryInfoContainer childIGeometryInfos;
- IGeometryInfo parentIGeometryInfo;
- IPhysicalVolumePath support;
- IPhysicalVolumeNavigator navigator;
- ILogicalVolume logicalVolume;
- ITransform3D globalToLocal;
- ITransform3D localToGlobal;
- ITransform3D parentToLocal;
- Hep3Vector globalPosition;
-
- /**
- * This constructor associates this GeometryInfo
- * with a node in the geometry tree.
- *
- * @param detectorElement
- * @param support
- */
- public GeometryInfo(
- IDetectorElement detectorElement,
- IPhysicalVolumePath support)
- {
- // This constructor does not allow a null DetectorElement.
- if ( detectorElement == null )
- {
- throw new IllegalArgumentException("DE cannot be null!");
- }
-
- // This constructor does not allow a null support.
- if ( support == null )
- {
- throw new IllegalArgumentException("Support cannot be null!");
- }
-
- // This constructor does not allow a path with no components in it.
- if ( support.size() == 0)
- {
- throw new IllegalArgumentException("Support contains no PhysicalVolumes!");
- }
-
- // Set the ref to the DetectorElement.
- this.detectorElement = detectorElement;
-
- // If this DetectorElement has children, add the
- // child IGeometryInfo to the cached list.
- if (detectorElement.getChildren() != null)
- {
- if (detectorElement.getChildren().size()>0)
- {
- this.childIGeometryInfos = new GeometryInfoContainer();
- for (IDetectorElement de : detectorElement.getChildren())
- {
- this.childIGeometryInfos.add(de.getGeometry());
- }
- }
- }
-
- // Set the parent IGeometryInfo ref.
- if (detectorElement.getParent()!=null)
- {
- this.parentIGeometryInfo = detectorElement.getParent().getGeometry();
- }
-
- // Set the support reference.
- this.support = support;
-
- // Cache a PhysicalVolumeNavigator.
- navigator = new PhysicalVolumeNavigator(support.toString(), support.getTopVolume());
-
- // Set ref to LogicalVolume.
- logicalVolume = support.get(support.size()-1).getLogicalVolume();
-
- // Cache global to local.
- globalToLocal = navigator.getTransform(support);
-
- // Cache local to global.
- localToGlobal = globalToLocal.inverse();
-
- // Cache parent to global.
- if ( parentIGeometryInfo() != null ) {
- parentToLocal = Transform3D.multiply(
- getGlobalToLocal(),
- parentIGeometryInfo().getLocalToGlobal());
- }
-
- // Cache global position.
- globalPosition = globalToLocal.transformed(new BasicHep3Vector());
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#childIGeometryInfos()
- */
- public IGeometryInfoContainer childIGeometryInfos()
- {
- return childIGeometryInfos;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolumePath(hep.physics.vec.Hep3Vector)
- */
- public IPhysicalVolumePath getPhysicalVolumePath(Hep3Vector global_point)
- {
- return navigator.getPath(global_point);
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#getLogicalVolume()
- */
- public ILogicalVolume getLogicalVolume()
- {
- return logicalVolume;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#getLogicalVolumeName()
- */
- public String getLogicalVolumeName()
- {
- return getLogicalVolume().getName();
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolume(hep.physics.vec.Hep3Vector)
- */
- public IPhysicalVolume getPhysicalVolume(Hep3Vector globalPoint)
- {
- return getPhysicalVolumePath(globalPoint).getLeafVolume();
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#getPosition()
- */
- public Hep3Vector getPosition()
- {
- return globalPosition;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolumePath()
- */
- public IPhysicalVolumePath getPhysicalVolumePath()
- {
- return support;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#globalToLocal()
- */
- public ITransform3D getGlobalToLocal()
- {
- return globalToLocal;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#globalToLocal(hep.physics.vec.Hep3Vector)
- */
- public Hep3Vector transformGlobalToLocal(Hep3Vector global_point)
- {
- return globalToLocal.transformed(global_point);
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#hasLogicalVolume()
- */
- public boolean hasLogicalVolume()
- {
- return logicalVolume != null;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#hasSupport()
- */
- public boolean hasPhysicalVolumePath()
- {
- return support != null;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#isInside(hep.physics.vec.Hep3Vector)
- */
- public boolean isInside(Hep3Vector point)
- {
- //System.out.println("isInside: " + point.toString());
- // Get the path from the navigator.
- // If the returned path is not equal
- // to this GeometryInfo's path, then
- // we are not inside this GI's exact
- // corresponding PhysicalVolume.
- //IPhysicalVolumePath path = navigator.getPath(point);
- //System.out.println("path at point : " + path.toString());
- //System.out.println("this gi path : " + support.toString());
- //System.out.println("equals : " + support.equals(navigator.getPath(point)));
- return support.equals(navigator.getPath(point));
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#localToGlobal()
- */
- public ITransform3D getLocalToGlobal()
- {
- return localToGlobal;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#localToGlobal(hep.physics.vec.Hep3Vector)
- */
- public Hep3Vector transformLocalToGlobal(Hep3Vector local_point)
- {
- return localToGlobal.transformed(local_point);
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#parentIGeometryInfo()
- */
- public IGeometryInfo parentIGeometryInfo()
- {
- return parentIGeometryInfo;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#parentToLocal()
- */
- public ITransform3D getParentToLocal()
- {
- return parentToLocal;
- }
-
- public Hep3Vector transformParentToLocal(Hep3Vector parentPoint)
- {
- return parentToLocal.transformed(parentPoint);
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#setSupport(org.lcsim.detector.IPhysicalVolumePath)
- */
- public void setPhysicalVolumePath(IPhysicalVolumePath support)
- {
- this.support = support;
- }
+ IDetectorElement de;
+ IGeometryInfoContainer childIGeometryInfos;
+ IGeometryInfo parentIGeometryInfo;
+ IPhysicalVolumePath support;
+ IPhysicalVolumeNavigator navigator;
+ ILogicalVolume logicalVolume;
+ ITransform3D globalToLocal;
+ ITransform3D localToGlobal;
+ ITransform3D parentToLocal;
+ Hep3Vector globalPosition;
+
+ private void setup(
+ IDetectorElement de,
+ IPhysicalVolumePath support)
+ {
+ if ( de == null )
+ {
+ throw new IllegalArgumentException("The IDetectorElement is null!");
+ }
+
+ // Set the ref to the DetectorElement.
+ this.de = de;
+
+ // Cache child IGeometryInfos.
+ if ( de.getChildren() != null )
+ {
+ if ( de.getChildren().size() > 0 )
+ {
+ this.childIGeometryInfos = new GeometryInfoContainer();
+ for (IDetectorElement child : de.getChildren())
+ {
+ this.childIGeometryInfos.add(child.getGeometry());
+ }
+ }
+ }
+
+ // Set the parent IGeometryInfo ref.
+ if (de.getParent() != null)
+ {
+ this.parentIGeometryInfo = de.getParent().getGeometry();
+ }
+
+ if ( support != null )
+ {
+ // Set the support reference.
+ this.support = support;
+
+ // Cache a PhysicalVolumeNavigator.
+ navigator = new PhysicalVolumeNavigator(support.toString(), support.getTopVolume());
+
+ // Set the reference to the LogicalVolume.
+ logicalVolume = support.getLeafVolume().getLogicalVolume();
+
+ // Compute and cache the local to global transform.
+ localToGlobal = navigator.getTransform(support);
+
+ // Compute and cache the global to local transform.
+ globalToLocal = localToGlobal.inverse();
+
+ // Compute and cache the parent to global transform.
+ if ( parentIGeometryInfo() != null ) {
+ parentToLocal = Transform3D.multiply(
+ getGlobalToLocal(),
+ parentIGeometryInfo().getLocalToGlobal());
+ }
+
+ // Compute and cache the global position.
+ globalPosition = localToGlobal.transformed(new BasicHep3Vector());
+ }
+ }
+
+ /**
+ * Creates a ghost volume with no support
+ * in the geometry tree.
+ *
+ * @param de The associated DetectorElement.
+ */
+ public GeometryInfo(
+ IDetectorElement de)
+ {
+ setup(de,null);
+ }
+
+ /**
+ * This constructor associates this GeometryInfo
+ * with a node in the geometry tree.
+ *
+ * @param de
+ * @param support
+ */
+ public GeometryInfo(
+ IDetectorElement de,
+ IPhysicalVolumePath support)
+ {
+ if ( support == null )
+ {
+ throw new IllegalArgumentException("The support cannot be null!");
+ }
+
+ if ( support.size() == 0)
+ {
+ throw new IllegalArgumentException("Support is empty!");
+ }
+
+ setup(de,support);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#childIGeometryInfos()
+ */
+ public IGeometryInfoContainer getChildGeometryInfos()
+ {
+ return childIGeometryInfos;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolumePath(hep.physics.vec.Hep3Vector)
+ */
+ public IPhysicalVolumePath getPhysicalVolumePath(Hep3Vector global_point)
+ {
+ return navigator.getPath(global_point);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#getLogicalVolume()
+ */
+ public ILogicalVolume getLogicalVolume()
+ {
+ return logicalVolume;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#getLogicalVolumeName()
+ */
+ public String getLogicalVolumeName()
+ {
+ return getLogicalVolume().getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolume(hep.physics.vec.Hep3Vector)
+ */
+ public IPhysicalVolume getPhysicalVolume(Hep3Vector globalPoint)
+ {
+ return getPhysicalVolumePath(globalPoint).getLeafVolume();
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#getPosition()
+ */
+ public Hep3Vector getPosition()
+ {
+ return globalPosition;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolumePath()
+ */
+ public IPhysicalVolumePath getPhysicalVolumePath()
+ {
+ return support;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#globalToLocal()
+ */
+ public ITransform3D getGlobalToLocal()
+ {
+ return globalToLocal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#globalToLocal(hep.physics.vec.Hep3Vector)
+ */
+ public Hep3Vector transformGlobalToLocal(Hep3Vector global_point)
+ {
+ return globalToLocal.transformed(global_point);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#hasLogicalVolume()
+ */
+ public boolean hasLogicalVolume()
+ {
+ return logicalVolume != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#hasSupport()
+ */
+ public boolean hasPhysicalVolumePath()
+ {
+ return support != null;
+ }
+
+ /* (non-Javadoc)
+ *
+ * Check if the point @param globalPoint is inside this volume
+ * by transforming the point from global to local coordinates
+ * and seeing if the resulting point is inside this DetectorElement's
+ * solid.
+ *
+ * Check the daughters recursively if this GeometryInfo does not
+ * have a corresponding node in the geometry tree, i.e. if it
+ * is a "ghost" that is just a container for other DetectorElements.
+ *
+ * @see org.lcsim.detector.IGeometryInfoTest#isInside(hep.physics.vec.Hep3Vector)
+ */
+ public boolean isInside(Hep3Vector globalPoint)
+ {
+ boolean inside=false;
+ if ( hasPhysicalVolumePath() )
+ {
+ inside = getLogicalVolume().getSolid().isInside(
+ getGlobalToLocal().transformed(globalPoint)
+ );
+ }
+ else {
+ for ( IDetectorElement child : getDetectorElement().getChildren() )
+ {
+ inside = child.getGeometry().isInside(globalPoint);
+ if (inside)
+ {
+ break;
+ }
+ }
+ }
+ return inside;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#localToGlobal()
+ */
+ public ITransform3D getLocalToGlobal()
+ {
+ return localToGlobal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#localToGlobal(hep.physics.vec.Hep3Vector)
+ */
+ public Hep3Vector transformLocalToGlobal(Hep3Vector local_point)
+ {
+ return localToGlobal.transformed(local_point);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#parentIGeometryInfo()
+ */
+ public IGeometryInfo parentIGeometryInfo()
+ {
+ return parentIGeometryInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#parentToLocal()
+ */
+ public ITransform3D getParentToLocal()
+ {
+ return parentToLocal;
+ }
+
+ public Hep3Vector transformParentToLocal(Hep3Vector parentPoint)
+ {
+ return parentToLocal.transformed(parentPoint);
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.detector.IGeometryInfoTest#setSupport(org.lcsim.detector.IPhysicalVolumePath)
+ */
+ public void setPhysicalVolumePath(IPhysicalVolumePath support)
+ {
+ this.support = support;
+ }
+
+ public boolean isGhost()
+ {
+ return support == null;
+ }
+
+ public IDetectorElement getDetectorElement()
+ {
+ return de;
+ }
}
GeomConverter/src/org/lcsim/detector
diff -u -r1.7 -r1.8
--- IGeometryInfo.java 9 Mar 2007 22:47:38 -0000 1.7
+++ IGeometryInfo.java 20 Mar 2007 00:47:17 -0000 1.8
@@ -31,7 +31,7 @@
* Get an IGeometryInfoContainer with the child DetectorElement's IGeometryInfo objects.
* @return Container of IGeometryInfos from the child DetectorElements.
*/
- public IGeometryInfoContainer childIGeometryInfos();
+ public IGeometryInfoContainer getChildGeometryInfos();
/**
* Get the IPhysicalVolumePath from a global point @param globalPoint.
@@ -161,4 +161,15 @@
* @param support
*/
public void setPhysicalVolumePath(IPhysicalVolumePath support);
+
+ /**
+ * True if the IGeometryInfo does not have an associated path in the geometry tree.
+ */
+ public boolean isGhost();
+
+ /**
+ * Return the associated DetectorElement.
+ * @return
+ */
+ public IDetectorElement getDetectorElement();
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector
diff -u -r1.10 -r1.11
--- PhysicalVolumeNavigator.java 17 Mar 2007 00:10:40 -0000 1.10
+++ PhysicalVolumeNavigator.java 20 Mar 2007 00:47:17 -0000 1.11
@@ -1,5 +1,6 @@
package org.lcsim.detector;
+import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
/**
@@ -39,27 +40,36 @@
implements IPhysicalVolumeNavigator
{
/**
- * Find the full geometry path to the PhysicalVolume in the tree
- * containing the global point @param globalPoint, relative to
- * the top volume.
+ * Find the full geometry path to the PhysicalVolume containing
+ * the global point @param globalPoint, relative to the world volume.
*
* @param globalPoint Point in top geometry system.
* @param level Depth to descend. -1 means to bottom.
+ * @return An IPhysicalVolumePath containing the unique path to the containing sub-volume,
+ * or null if the @param globalPoint is outside the world volume.
*/
public IPhysicalVolumePath getPath(Hep3Vector globalPoint, int level)
- {
+ {
+ // Path that will be returned to user.
+ // Empty path means globalPoint is outside
+ // the world volume.
IPhysicalVolumePath path = new PhysicalVolumePath();
- IPhysicalVolume pvtop = getTopPhysicalVolume();
- ILogicalVolume lvCurr = pvtop.getLogicalVolume();
+
+ // Get the top volume from this navigator.
+ IPhysicalVolume world = getTopPhysicalVolume();
+
+ // Start by looking in the world volume.
+ ILogicalVolume lvCurr = world.getLogicalVolume();
- // First time, this compares in top.
+ // First time, see if point is inside the world.
if (lvCurr.getSolid().isInside(globalPoint))
{
- path.add(pvtop);
+ // Add world to path.
+ path.add(world);
}
- else {
- // The point is outside the top!
- System.err.println("!!! Point " + globalPoint.v() + " is outside the top volume <"+pvtop.getName()+">. !!!");
+ // The point is outside the world volume!
+ else {
+ System.err.println("!!! Point " + globalPoint.v() + " is outside the top volume <"+world.getName()+">. !!!");
// Return an empty path.
return path;
@@ -68,53 +78,61 @@
// Current depth.
int depth=0;
- // Go into the geometry tree as long as
- // there are daughter volumes.
+ // The current local point that is computed
+ // by applying the containing daughter's transform
+ // successively as the search is performed.
+ Hep3Vector localPoint = new BasicHep3Vector(globalPoint.x(),globalPoint.y(),globalPoint.z());
+
+ // Combined transform of path to current daughter.
+ // If a daughter is found to contain the point,
+ // its transform is applied to this.
+ ITransform3D combinedTransform = new Transform3D();
+
+ // Go into the geometry tree as long as there are
+ // daughter volumes in the current LogicalVolume.
while(lvCurr.getNumberOfDaughters() != 0)
- {
+ {
+ // No daughter found yet.
boolean inDau=false;
// Loop over the daughters.
for (IPhysicalVolume dau : lvCurr.getDaughters())
- {
- // Multiply the daughter by the combined
- // transform up to this point to get the
- // combined transform.
- // !!! Is this correct??? !!!
- Transform3D combinedTransform
- = Transform3D.multiply(
- getTransform(path),
- (Transform3D)
- dau.getTransform());
-
- //System.out.println("transformed globalPoint : " + combinedTransform.transformed(globalPoint));
-
- // Check if the global point is inside the volume's solid.
- // !!! Is this correct??? !!!
- if (dau.getLogicalVolume().getSolid().isInside(
- combinedTransform.inverse().transformed(globalPoint)))
- {
+ {
+ // Transform the local point from parent
+ // into the daughter's coordinate system.
+ Hep3Vector checkLocalPoint =
+ dau.getTransform().inverse().transformed(localPoint);
+
+ // Check if the point is inside this daughter's solid.
+ if (dau.getLogicalVolume().getSolid().isInside(checkLocalPoint))
+ {
+ // Found a containing daughter.
inDau=true;
- // Add this daughter to the path.
+ // Add this daughter to the returned path.
path.add(dau);
- // Go to next logical volume.
+ // Traverse into the daughter.
lvCurr = dau.getLogicalVolume();
- // Increment the depth.
+ // Increment the current depth.
++depth;
+
+ // Add the daughter's transform to the combined transform.
+ combinedTransform.multiplyBy(dau.getTransform());
+
+ // Set the current point to the daughter's local point.
+ localPoint = checkLocalPoint;
- // Stop looking at daughters once
- // one has been found to contain
- // the point.
+ // Stop looking at this volume's daughters.
break;
- }
+ }
}
- // If depth is past selected level,
- // stop looking in sub-volumes and quit.
- if ( level != -1 && depth > level || !inDau)
+ // If depth is past selected level or
+ // no daughter was found, stop looking
+ // and quit. Current path will be returned.
+ if ( level != -1 && depth >= level || !inDau)
{
break;
}
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.2 -r1.3
--- CylindricalBarrelCalorimeterConverter.java 17 Mar 2007 00:10:41 -0000 1.2
+++ CylindricalBarrelCalorimeterConverter.java 20 Mar 2007 00:47:19 -0000 1.3
@@ -54,7 +54,9 @@
cal.createGeometryInfo(path);
// Build the layers.
- buildLayers(cal, envelope);
+ buildLayers(cal, envelope);
+
+ detector.addChild(subdet);
}
private ILogicalVolume buildEnvelope(
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- CylindricalEndcapCalorimeterConverter.java 17 Mar 2007 00:10:41 -0000 1.1
+++ CylindricalEndcapCalorimeterConverter.java 20 Mar 2007 00:47:19 -0000 1.2
@@ -1,17 +1,21 @@
package org.lcsim.detector.converter.compact;
+import hep.physics.vec.BasicHep3Vector;
+
+import org.lcsim.detector.DetectorElement;
import org.lcsim.detector.ILogicalVolume;
import org.lcsim.detector.IPhysicalVolume;
-import org.lcsim.detector.IPhysicalVolumeNavigator;
-import org.lcsim.detector.IPhysicalVolumePath;
import org.lcsim.detector.LogicalVolume;
import org.lcsim.detector.PhysicalVolume;
-import org.lcsim.detector.PhysicalVolumeNavigatorStore;
+import org.lcsim.detector.Rotation3D;
+import org.lcsim.detector.Transform3D;
import org.lcsim.detector.material.IMaterial;
+import org.lcsim.detector.material.MaterialStore;
import org.lcsim.detector.solids.Tube;
-import org.lcsim.geometry.Subdetector;
import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Subdetector;
import org.lcsim.geometry.layer.Layer;
+import org.lcsim.geometry.layer.LayerSlice;
import org.lcsim.geometry.layer.Layering;
import org.lcsim.geometry.subdetector.CylindricalEndcapCalorimeter;
@@ -19,29 +23,94 @@
implements ISubdetectorConverter
{
public void convert( Subdetector subdet, Detector detector)
- {
- //System.out.println("CylindricalEndcapCalorimeterConverter.convert");
-
+ {
CylindricalEndcapCalorimeter cal = (CylindricalEndcapCalorimeter)subdet;
-
+
IPhysicalVolume world = detector.getWorldVolume();
ILogicalVolume envelope = buildEnvelope( cal, world.getLogicalVolume().getMaterial() );
+
+ double width = (cal.getZMax() - cal.getZMin()) / 2;
+ double zcenter = cal.getZMin() + width;
+
+ // Positive endcap.
+ IPhysicalVolume pv =
+ new PhysicalVolume(
+ new Transform3D(new BasicHep3Vector(0,0,zcenter)),
+ cal.getName() + "_positive",
+ envelope,
+ world.getLogicalVolume(),
+ subdet.getSystemID()
+ );
+ double negz = -cal.getZMin() - width;
+
+ // DE for positive endcap.
+ DetectorElement endcap = new DetectorElement(cal.getName() + "_positive");
+ endcap.createGeometryInfo(cal.getName() + "_positive");
+ detector.addChild(endcap);
+
+ // 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()
+ );
+
+ reflectedEndcap = new DetectorElement(cal.getName() + "_negative");
+ reflectedEndcap.createGeometryInfo(cal.getName() + "_negative");
+
+ detector.addChild(reflectedEndcap);
+ }
+
+ // Build the layers into the logical volume.
buildLayers(cal, envelope);
-
- new PhysicalVolume(
- null,
- cal.getName(),
- envelope,
- world.getLogicalVolume(),
- subdet.getSystemID()
- );
-
- IPhysicalVolumeNavigator nav =
- PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
- IPhysicalVolumePath path = nav.getPath(cal.getName());
- cal.createGeometryInfo(path);
+
+ // Build the DetectorElements for positive and negative endcaps.
+ buildDetectorElements(cal, endcap, reflectedEndcap);
+ }
+
+ private void buildDetectorElements(
+ CylindricalEndcapCalorimeter cal,
+ DetectorElement endcap,
+ DetectorElement reflectedEndcap)
+ {
+ int sensorNum=1;
+
+ for (int i=0; i<cal.getLayering().getNumberOfLayers(); i++)
+ {
+ Layer layer = cal.getLayering().getLayer(i);
+ String layerName = "layer" + i;
+ for (int j=0; j<layer.getSlices().size(); j++)
+ {
+ 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);
+ if ( reflectedEndcap != null )
+ {
+ detelem = new DetectorElement("sensor"+sensorNum);
+ pathName = "/" + cal.getName() + "_negative" + "/" + layerName + "/" + sliceName;
+ detelem.createGeometryInfo(pathName);
+ reflectedEndcap.addChild(detelem);
+ }
+ ++sensorNum;
+ }
+ }
+ }
}
private ILogicalVolume buildEnvelope(
@@ -60,7 +129,7 @@
new LogicalVolume(
name + "_envelope",
tube,
- material);
+ material);
return lv;
}
@@ -77,12 +146,17 @@
String name = cal.getName();
- double zLayer = cal.getZMin();
+ //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(
name + "layer" + i + "_tube",
innerRadius,
@@ -92,16 +166,50 @@
ILogicalVolume lvLayer =
new LogicalVolume(
- name + "layer" + i,
+ name + "_layer" + i,
tubeLayer,
envelope.getMaterial()
);
-
- // TODO: Make layer physical volume here
-
+
+ new PhysicalVolume(
+ new Transform3D(
+ new BasicHep3Vector( 0, 0, zLayer+layer.getThickness() / 2 ) ),
+ "layer"+i,
+ lvLayer,
+ envelope,
+ i);
+
+ double zSlice = zLayer;
+
for (int j=0; j<layer.getNumberOfSlices(); j++)
{
- // TODO: Make slice here
+ //System.out.println("zSlice="+zSlice);
+
+ LayerSlice slice = layer.getSlice(j);
+
+ Tube tubeSlice = new Tube(
+ cal.getName() + "_layer" + i + "_slice" + j,
+ cal.getInnerRadius(),
+ cal.getOuterRadius(),
+ slice.getThickness() / 2
+ );
+
+ ILogicalVolume lvSlice = new LogicalVolume(
+ cal.getName() + "_layer" + i + "_slice" + j,
+ tubeSlice,
+ MaterialStore.getInstance().get(slice.getMaterial().getName())
+ );
+
+ zSlice += slice.getThickness()/2;
+
+ new PhysicalVolume(
+ new Transform3D(new BasicHep3Vector(0,0,zSlice)),
+ "slice"+j,
+ lvSlice,
+ lvLayer,
+ j);
+
+ zSlice += slice.getThickness()/2;
}
zLayer += layer.getThickness();
@@ -112,4 +220,4 @@
{
return CylindricalEndcapCalorimeter.class;
}
-}
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/converter/compact
diff -u -r1.5 -r1.6
--- DetectorConverter.java 17 Mar 2007 00:46:21 -0000 1.5
+++ DetectorConverter.java 20 Mar 2007 00:47:19 -0000 1.6
@@ -117,11 +117,12 @@
// This adds the Subdetector as a child
// DetectorElement of the Detector.
- detector.addChild(subdet);
- }
+ //detector.addChild(subdet);
+ }
+ /*
else {
System.err.println("WARNING: No ISubdetectorConverter for <" + subdet.getClass().getCanonicalName() + ">.");
- }
+ }*/
}
}
GeomConverter/src/org/lcsim/detector/solids
diff -u -r1.4 -r1.5
--- Tube.java 3 Mar 2007 13:50:33 -0000 1.4
+++ Tube.java 20 Mar 2007 00:47:19 -0000 1.5
@@ -8,7 +8,7 @@
*
* @author Tim Nelson <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: Tube.java,v 1.4 2007/03/03 13:50:33 jeremy Exp $
+ * @version $Id: Tube.java,v 1.5 2007/03/20 00:47:19 jeremy Exp $
*/
public class Tube
extends Named
@@ -57,8 +57,8 @@
public boolean isInside(Hep3Vector point)
{
double r_xy = Math.sqrt(point.x()*point.x() + point.y()*point.y());
-
- return ( r_xy > innerRadius &&
+
+ return ( r_xy >= innerRadius &&
r_xy < outerRadius &&
Math.abs(point.z()) < zHalfLength );
}
GeomConverter/src/org/lcsim/geometry/layer
diff -u -r1.10 -r1.11
--- Layer.java 17 Mar 2007 00:10:41 -0000 1.10
+++ Layer.java 20 Mar 2007 00:47:19 -0000 1.11
@@ -78,10 +78,10 @@
public LayerSlice getSlice(int idx)
{
- if ( idx > ( slices.size() - 1) )
- {
- throw new IllegalArgumentException("LayerSlice idx out of range.");
- }
+ //if ( idx > ( slices.size() - 1) )
+ //{
+ // throw new IllegalArgumentException("LayerSlice idx out of range <" + idx + ">.");
+ //}
return slices.get(idx);
}
GeomConverter/test/org/lcsim/detector
diff -u -r1.8 -r1.9
--- SimpleDetectorTest.java 17 Mar 2007 00:10:42 -0000 1.8
+++ SimpleDetectorTest.java 20 Mar 2007 00:47:19 -0000 1.9
@@ -3,6 +3,10 @@
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;
@@ -48,93 +52,95 @@
static double [] xpoints = {10.0,10.1,9.9,5.1,4.9,2.6,2.4,1.1,.9,.6,.4,.2,.1,0};
private String[] testnames = {"/box1","box1","box1/","/box1"};
+
+ /*
+ public void testIsInside()
+ {
+ IPhysicalVolumeNavigator nav = PhysicalVolumeNavigatorStore.getInstance().createDefault(world);
+
+ List<Hep3Vector> testpoints = new ArrayList<Hep3Vector>();
+ testpoints.add(new BasicHep3Vector(0,0,0));
+ testpoints.add(new BasicHep3Vector(50,0,0));
+ testpoints.add(new BasicHep3Vector(0,50,0));
+
+ for ( Hep3Vector point : testpoints )
+ {
+ IPhysicalVolumePath path = nav.getPath(point);
+ }
+ }*/
+
public void testNavigator()
{
- IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator("nav1",world);
+ IPhysicalVolumeNavigator nav =
+ PhysicalVolumeNavigatorStore.getInstance().createDefault(world);
// The string "/" should give back a reference
// to the top volume, which is encoded by a
// single "/".
assertTrue("/".equals(nav.getPath("/").toString()));
- // The navigator should normalize all the testnames to "/box1".
+ // The navigator should normalize all the test names to "/box1".
for (String testname : testnames)
- {
- //System.out.println("testname: " + testname);
-
+ {
IPhysicalVolumePath path = nav.getPath(testname);
-
- //System.out.println("got path <"+path.toString()+"> from testname <"+testname+">.");
-
+
assertEquals(path.size(),2);
+
assertTrue("/box1".equals(path.toString() ));
assertTrue( "box1".equals(path.getLeafVolume().getName() ));
assertTrue("world".equals(path.getTopVolume().getName() ));
}
IPhysicalVolumePath path = nav.getPath("/box1");
-
- ITransform3D t = nav.getTransform(path);
-
- //System.out.println("transform to <" + path.toString() +"> = " + t.toString());
-
+
+ // Check isInside for positive points on "box1".
for (double x : xpoints)
{
- IPhysicalVolumePath path3 = nav.getPath(new BasicHep3Vector(x,0,0));
+ path = nav.getPath(new BasicHep3Vector(x,0,0));
if (x<5.0)
{
- assertTrue("/box1".equals(path3.toString()));
+ assertTrue("/box1".equals(path.toString()));
}
else {
- assertTrue("/".equals(path3.toString()));
+ assertTrue("/".equals(path.toString()));
}
}
+ // Check isInside for negative points on "box1".
for (double x : xpoints)
{
IPhysicalVolumePath path3 = nav.getPath(new BasicHep3Vector(-x,0,0));
-
- //System.out.println("nav thinks x=" + -x + " has path <" + path3.toString()+">");
if (-x > -5.0)
{
- //System.out.println("x > -5.0 : path3 : " + path3.toString());
assertTrue("/box1".equals(path3.toString()));
}
else {
- //System.out.println("x < -5.0 : path3 : " + path3.toString());
assertTrue("/".equals(path3.toString()));
}
}
+ // Check isInside for some positive x points on "box2".
for (double x : new double[] {44.9,45.1,47.9,48.1,51.9,52.1,49.9,54.9,55.1})
{
- System.out.println("x="+x);
- IPhysicalVolumePath path4 = nav.getPath(new BasicHep3Vector(x,0,0));
- System.out.println("path4 : " + path4.toString());
+ IPhysicalVolumePath path4 = nav.getPath(new BasicHep3Vector(x,0,0));
if (x>45 && x<55)
{
assertTrue("/box2".equals(path4.toString()));
}
}
- // Create a dummy DE.
+ // Create a dummy DE that has the "box1" volume as its node.
IDetectorElement dummyDE = new DummyDE(nav.getPath("/box1"));
IGeometryInfo gi = dummyDE.getGeometry();
assertTrue("/box1".equals(gi.getPhysicalVolumePath().toString()));
- //System.out.println("dummyDE LV : " + gi.getLogicalVolume().getName());
- //System.out.println("dummyDE LV : " + gi.getPosition());
- //System.out.println("global to local : " + gi.getGlobalToLocal().toString());
-
- //System.out.println("checking isinside for DE : " + dummyDE.getName());
- // Positive points.
+ // Check isInside for positive points on the "box1" DE.
for (double x : xpoints)
{
Hep3Vector thisx = new BasicHep3Vector(x,0,0);
boolean isInside = gi.isInside(thisx);
- //System.out.println("isinside " + thisx.toString() + " : " + isInside);
if (x<5.0)
{
@@ -142,14 +148,12 @@
}
}
+ // Check isInside for various geometry objects.
for (double y : new double[] {44.9,45.1,47.9,48.1,51.9,52.1,49.9,54.9,55.1})
{
Hep3Vector point = new BasicHep3Vector(0,y,0);
IPhysicalVolumePath path5 = nav.getPath(point);
- System.out.println("point : " + point.toString());
- System.out.println("path : " + path5.toString());
-
if ( y < 45.0 || y > 55.0)
{
assertTrue(path5.size()==1);
@@ -168,10 +172,8 @@
IPhysicalVolumePath path6 = nav.getPath(new BasicHep3Vector(101,0,0));
assertTrue("/tube1".equals(path6.toString()));
- System.out.println("at x = 101 : " + path6.toString());
path6 = nav.getPath("/tube1");
assert("/tube1".equals(path6.toString()));
- System.out.println("tube path : " + path6.toString());
path6 = nav.getPath(new BasicHep3Vector(111.0,0,0));
assertTrue("/tube1/tube2".equals(path6.toString()));
}
@@ -185,6 +187,7 @@
}
}
+ /*
public void testTraverse()
{
IPhysicalVolumeNavigator nav = new PhysicalVolumeNavigator("nav2", world);
@@ -196,7 +199,7 @@
System.out.println("---PostOrder Traversal---");
nav.traversePostOrder(visitorTest);
- }
+ }*/
public IPhysicalVolume createTestGeometry()
{
@@ -207,7 +210,7 @@
public final void createTestSolids(IPhysicalVolume mom)
{
- // 10 cm box at 0,0,0
+ // 10 mm box at 0,0,0
Box box = new Box("test_box1",5.0,5.0,5.0);
LogicalVolume lvTest = new LogicalVolume("lvTest",box,dummymat);
new PhysicalVolume(
@@ -217,7 +220,7 @@
mom.getLogicalVolume(),
0);
- // 10 cm box at 50,0,0
+ // 10 mm box at 50,0,0
Box box2 = new Box("test_box2",5.0,5.0,5.0);
LogicalVolume lvTest2 = new LogicalVolume("lvTest2",box2,dummymat);
new PhysicalVolume(
@@ -227,7 +230,7 @@
mom.getLogicalVolume(),
1);
- // 10 cm box at 0,50,0
+ // 10 mm box at 0,50,0
Box box3 = new Box("test_box3",5.0,5.0,5.0);
LogicalVolume lvTest3 = new LogicalVolume("lvTest3",box3,dummymat);
new PhysicalVolume(
@@ -237,7 +240,7 @@
mom.getLogicalVolume(),
2);
- // A 2 cm box inside of box3.
+ // A 2 mm box inside of box3.
Box box4 = new Box("test_box4",2.0,2.0,2.0);
LogicalVolume lvTest4 = new LogicalVolume("lvTest4",box4,dummymat);
new PhysicalVolume(
@@ -248,7 +251,6 @@
0);
Tube tube1 = new Tube("test_tube1",100.0,200.0,1000.0);
- //new Transform3D(new BasicHep3Vector(0,0,0))
LogicalVolume lvTest5 = new LogicalVolume("lvTest5",tube1,dummymat);
new PhysicalVolume(
null,
GeomConverter/test/org/lcsim/detector/converter/compact
diff -u -r1.2 -r1.3
--- DetectorConverterTest.java 17 Mar 2007 00:10:42 -0000 1.2
+++ DetectorConverterTest.java 20 Mar 2007 00:47:19 -0000 1.3
@@ -44,40 +44,79 @@
getResourceAsStream(resource);
GeometryReader reader = new GeometryReader();
Detector det = reader.read(in);
-
- /*
- for ( IPhysicalVolume physvol : PhysicalVolumeStore.getInstance() )
- {
- System.out.println("physvol <"+physvol.getName()+">");
- }
- */
-
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,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,-265*cm));
System.out.println(det.getName());
for ( IDetectorElement child : det.getChildren() )
{
- //System.out.println(" "+child.getName());
for ( IDetectorElement sensor : child.getChildren() )
{
- //System.out.println(" "+sensor.getName());
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();
+
+ double zsensor = sensorGeo.getPosition().z();
+ double zwidth = sensorTube.getZHalfLength();
for ( Hep3Vector point : points )
- {
- if ( point.y() > sensorTube.getInnerRadius() &&
- point.y() < sensorTube.getOuterRadius() )
+ {
+ double zpoint = point.z();
+ double ypoint = point.y();
+
+ // Check isInside for barrel.
+ if ( sensor.getName().contains("barrel") )
+ {
+ if ( ypoint > sensorTube.getInnerRadius() &&
+ ypoint < sensorTube.getOuterRadius() )
+ {
+ assertTrue(sensorGeo.isInside(point));
+ }
+ }
+ // Check isInside for endcap positive.
+ else if ( child.getName().contains("endcap_positive") )
+ {
+ /*
+ System.out.println("endcap_positive");
+ System.out.println("point="+point);
+ System.out.println("zpoint="+zpoint);
+ System.out.println("zsensor="+zsensor);
+ System.out.println("zcheck1="+(zsensor - zwidth));
+ System.out.println("zcheck2="+(zsensor + zwidth));
+ System.out.println("zpoint > (zsensor - zwidth ) = " + (zpoint > (zsensor - zwidth )));
+ System.out.println("zpoint < (zsensor + zwidth ) = " + (zpoint < (zsensor + zwidth )));
+ */
+
+ assertTrue(sensor.getGeometry().isInside(point));
+
+ if ( zpoint > (zsensor - zwidth ) &&
+ zpoint < (zsensor + zwidth ) )
+ {
+ assertTrue(sensorGeo.isInside(point));
+ }
+ }
+ // Check isInside for endcap negative.
+ else if ( child.getName().contains("endcap_negative") )
{
- assert(sensorGeo.isInside(point));
+ if ( zpoint < (zsensor + zwidth ) &&
+ zpoint > (zsensor - zwidth ) )
+ {
+ assertTrue(sensorGeo.isInside(point));
+ }
}
- }
+ }
}
- }
+ }
}
}
\ No newline at end of file
GeomConverter/test/org/lcsim/detector/converter/compact
diff -u -r1.1 -r1.2
--- DetectorConverterTest.xml 17 Mar 2007 00:10:42 -0000 1.1
+++ DetectorConverterTest.xml 20 Mar 2007 00:47:19 -0000 1.2
@@ -28,16 +28,18 @@
<!-- Electromagnetic calorimeter -->
+<!--
<detector id="1" name="ecal_barrel" type="CylindricalBarrelCalorimeter" readout="EcalBarrHits">
<dimensions inner_r = "100.0*cm" outer_z = "200.0*cm" />
<layer repeat="2">
<slice material = "Silicon" thickness = "10.0*cm" sensitive = "yes" />
</layer>
</detector>
+-->
- <detector id="2" name="ecal_endcap" reflect="true" type="CylindricalEndcapCalorimeter" readout="EcalEndcapHits">
- <dimensions inner_r = "20.0*cm" inner_z = "168.0*cm" outer_r = "125.0*cm" />
- <layer repeat="2">
+ <detector id="2" name="ecal_endcap" reflect="false" type="CylindricalEndcapCalorimeter" readout="EcalEndcapHits">
+ <dimensions inner_r = "0.0" inner_z = "250.0*cm" outer_r = "100.0*cm" />
+ <layer repeat="1">
<slice material = "Silicon" thickness = "10.0*cm" sensitive = "yes" />
</layer>
</detector>
CVSspam 0.2.8