2 added + 1 removed + 10 modified, total 13 files
GeomConverter/src/org/lcsim/detector
diff -u -r1.32 -r1.33
--- DetectorElement.java 12 Jul 2007 04:41:14 -0000 1.32
+++ DetectorElement.java 6 Aug 2007 19:09:31 -0000 1.33
@@ -1,20 +1,21 @@
package org.lcsim.detector;
+import hep.physics.vec.Hep3Vector;
+
import java.util.ArrayList;
import java.util.List;
-import hep.physics.vec.Hep3Vector;
-
import org.lcsim.detector.identifier.IExpandedIdentifier;
import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.Identifier;
import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
+import org.lcsim.detector.solids.Inside;
/**
* Implementation of {@link IDetectorElement}.
*
* @author Jeremy McCormick
- * @version $Id: DetectorElement.java,v 1.32 2007/07/12 04:41:14 jeremy Exp $
+ * @version $Id: DetectorElement.java,v 1.33 2007/08/06 19:09:31 jeremy Exp $
*/
public class DetectorElement
extends Named
@@ -303,7 +304,8 @@
if ( hasGeometryInfo() )
{
- if ( getGeometry().isInside(globalPoint))
+ Inside inside = getGeometry().inside(globalPoint);
+ if (inside == Inside.INSIDE)
{
srch = this;
}
GeomConverter/src/org/lcsim/detector
diff -u -r1.13 -r1.14
--- GeometryInfo.java 9 May 2007 00:59:57 -0000 1.13
+++ GeometryInfo.java 6 Aug 2007 19:09:31 -0000 1.14
@@ -1,8 +1,12 @@
package org.lcsim.detector;
+import static org.lcsim.detector.solids.Inside.INSIDE;
+import static org.lcsim.detector.solids.Inside.OUTSIDE;
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
+import org.lcsim.detector.solids.Inside;
+
/**
* IGeometryInfo provides a cache of detailed geometry
* information for its associated DetectorElement,
@@ -239,20 +243,20 @@
* have a corresponding node in the geometry tree, i.e. if it
* is a "ghost" that is just a container for other DetectorElements.
*/
- public boolean isInside(Hep3Vector globalPoint)
+ public Inside inside(Hep3Vector globalPoint)
{
- boolean inside=false;
+ Inside inside=OUTSIDE;
if ( hasPath() )
{
- inside = getLogicalVolume().getSolid().isInside(
- getGlobalToLocal().transformed(globalPoint)
+ inside = getLogicalVolume().getSolid().inside(
+ getGlobalToLocal().transformed(globalPoint)
);
}
else {
for ( IDetectorElement child : getDetectorElement().getChildren() )
{
- inside = child.getGeometry().isInside(globalPoint);
- if (inside)
+ inside = child.getGeometry().inside(globalPoint);
+ if (inside==INSIDE)
{
break;
}
GeomConverter/src/org/lcsim/detector
diff -u -r1.14 -r1.15
--- IGeometryInfo.java 11 May 2007 00:21:09 -0000 1.14
+++ IGeometryInfo.java 6 Aug 2007 19:09:31 -0000 1.15
@@ -2,6 +2,8 @@
import hep.physics.vec.Hep3Vector;
+import org.lcsim.detector.solids.Inside;
+
/**
* IGeometryInfo provides geometry information about an {@link IDetectorElement}.
*
@@ -23,7 +25,7 @@
*
* @author Jeremy McCormick
* @author Tim Nelson
- * @version $Id: IGeometryInfo.java,v 1.14 2007/05/11 00:21:09 jeremy Exp $
+ * @version $Id: IGeometryInfo.java,v 1.15 2007/08/06 19:09:31 jeremy Exp $
*/
public interface IGeometryInfo
{
@@ -119,7 +121,7 @@
* @return True if the global point is inside this DetectorElement
* or any of its descendants.
*/
- public boolean isInside(Hep3Vector globalPoint);
+ public Inside inside(Hep3Vector globalPoint);
/**
* Get the combined local to global transform.
GeomConverter/src/org/lcsim/detector
diff -u -r1.13 -r1.14
--- PhysicalVolumeNavigator.java 9 May 2007 00:59:57 -0000 1.13
+++ PhysicalVolumeNavigator.java 6 Aug 2007 19:09:31 -0000 1.14
@@ -3,6 +3,8 @@
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
+import org.lcsim.detector.solids.Inside;
+
/**
* Navigates from a top or "world" volume
* into daughter volumes using String
@@ -64,7 +66,7 @@
ILogicalVolume lvCurr = world.getLogicalVolume();
// First time, see if point is inside the world.
- if (lvCurr.getSolid().isInside(globalPoint))
+ if (lvCurr.getSolid().inside(globalPoint) == Inside.INSIDE)
{
// Add world to path.
path.add(world);
@@ -106,7 +108,7 @@
dau.getTransform().inverse().transformed(localPoint);
// Check if the point is inside this daughter's solid.
- if (dau.getLogicalVolume().getSolid().isInside(checkLocalPoint))
+ if (dau.getLogicalVolume().getSolid().inside(checkLocalPoint) == Inside.INSIDE)
{
// Found a containing daughter.
inDau=true;
GeomConverter/src/org/lcsim/detector/solids
diff -N Inside.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Inside.java 6 Aug 2007 19:09:32 -0000 1.1
@@ -0,0 +1,13 @@
+package org.lcsim.detector.solids;
+
+/**
+ * An enum to indicate whether a point is inside, outside, or on the surface of a solid.
+ *
+ * @author Jeremy McCormick
+ * @version $Id: Inside.java,v 1.1 2007/08/06 19:09:32 jeremy Exp $
+ */
+
+public enum Inside
+{
+ INSIDE, OUTSIDE, SURFACE
+}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/solids
diff -N Tolerance.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tolerance.java 6 Aug 2007 19:09:32 -0000 1.1
@@ -0,0 +1,14 @@
+package org.lcsim.detector.solids;
+
+/**
+ * Tolerance variable when doing checks for inside or outside.
+ *
+ * @author Jeremy McCormick
+ * @version $Id: Tolerance.java,v 1.1 2007/08/06 19:09:32 jeremy Exp $
+ */
+
+public final class Tolerance
+{
+ private Tolerance() {}
+ public static final double TOLERANCE=1E-9;
+}
GeomConverter/src/org/lcsim/detector/solids
diff -u -r1.1 -r1.2
--- Box.java 2 Mar 2007 02:28:24 -0000 1.1
+++ Box.java 6 Aug 2007 19:09:32 -0000 1.2
@@ -1,5 +1,7 @@
package org.lcsim.detector.solids;
+import static org.lcsim.detector.solids.Tolerance.TOLERANCE;
+import static java.lang.Math.abs;
import hep.physics.vec.Hep3Vector;
/**
@@ -9,45 +11,74 @@
*
* @author Tim Nelson <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: Box.java,v 1.1 2007/03/02 02:28:24 jeremy Exp $
+ * @version $Id: Box.java,v 1.2 2007/08/06 19:09:32 jeremy Exp $
*/
public class Box
extends AbstractSolid
{
double xHalf, yHalf, zHalf;
-
- public Box(String name, double halfX, double halfY, double halfZ)
- {
- super(name);
- this.xHalf = halfX;
- this.yHalf = halfY;
- this.zHalf = halfZ;
- }
-
- public double getXHalfLength()
- {
- return xHalf;
- }
-
- public double getYHalfLength()
- {
- return yHalf;
- }
-
- public double getZHalfLength()
- {
- return zHalf;
- }
-
- public boolean isInside(Hep3Vector point)
- {
- return ( Math.abs(point.x()) < xHalf &&
- Math.abs(point.y()) < yHalf &&
- Math.abs(point.z()) < zHalf );
- }
-
- public double getCubicVolume()
- {
- return 8 * (getXHalfLength() * getYHalfLength() * getZHalfLength());
- }
+
+ public Box(String name, double halfX, double halfY, double halfZ)
+ {
+ super(name);
+ this.xHalf = halfX;
+ this.yHalf = halfY;
+ this.zHalf = halfZ;
+ }
+
+ public double getXHalfLength()
+ {
+ return xHalf;
+ }
+
+ public double getYHalfLength()
+ {
+ return yHalf;
+ }
+
+ public double getZHalfLength()
+ {
+ return zHalf;
+ }
+
+ /*
+ public boolean isInside(Hep3Vector point)
+ {
+ return ( Math.abs(point.x()) < xHalf &&
+ Math.abs(point.y()) < yHalf &&
+ Math.abs(point.z()) < zHalf );
+ }
+ */
+
+ public Inside inside(Hep3Vector p)
+ {
+ Inside in = Inside.OUTSIDE ;
+
+ if (abs(p.x()) <= xHalf - TOLERANCE*0.5 )
+ {
+ if (abs(p.y()) <= yHalf - TOLERANCE*0.5 )
+ {
+ if (abs(p.z()) <= zHalf - TOLERANCE*0.5 ) in = Inside.INSIDE;
+ else if (abs(p.z()) <= zHalf + TOLERANCE*0.5 ) in = Inside.SURFACE;
+ }
+ else if (abs(p.y()) <= yHalf + TOLERANCE*0.5 )
+ {
+ if (abs(p.z()) <= zHalf + TOLERANCE*0.5 ) in = Inside.SURFACE;
+ }
+ }
+ else if (abs(p.x()) <= xHalf + TOLERANCE*0.5 )
+ {
+ if (abs(p.y()) <= yHalf + TOLERANCE*0.5 )
+ {
+ if (abs(p.z()) <= zHalf + TOLERANCE*0.5) in = Inside.SURFACE;
+ }
+ }
+ return in;
+ }
+
+
+ public double getCubicVolume()
+ {
+ return 8 * (getXHalfLength() * getYHalfLength() * getZHalfLength());
+ }
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/solids
diff -u -r1.1 -r1.2
--- ISolid.java 3 Mar 2007 01:19:39 -0000 1.1
+++ ISolid.java 6 Aug 2007 19:09:32 -0000 1.2
@@ -7,6 +7,6 @@
public interface ISolid
extends INamed
{
- public boolean isInside(Hep3Vector position);
+ public Inside inside(Hep3Vector position);
public double getCubicVolume();
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/solids
diff -u -r1.1 -r1.2
--- Trd.java 24 Jul 2007 19:58:18 -0000 1.1
+++ Trd.java 6 Aug 2007 19:09:32 -0000 1.2
@@ -2,13 +2,16 @@
import hep.physics.vec.Hep3Vector;
import static java.lang.Math.abs;
+import static org.lcsim.detector.solids.Inside.INSIDE;
+import static org.lcsim.detector.solids.Inside.OUTSIDE;
+import static org.lcsim.detector.solids.Inside.SURFACE;
/**
- * A Trapezoid based on Geant4's
+ * A Trapezoid solid that is based on Geant4's
* <a href="http://www.lcsim.org/software/geant4/doxygen/html/classG4Trd.html">G4Trd class</a>.
*
* @author Jeremy McCormick
- * @version $Id: Trd.java,v 1.1 2007/07/24 19:58:18 jeremy Exp $
+ * @version $Id: Trd.java,v 1.2 2007/08/06 19:09:32 jeremy Exp $
*/
public class Trd
extends AbstractSolid
@@ -49,6 +52,7 @@
* True if point <code>p</code> is inside the shape.
* False if the point is outside the shape or on the surface.
*/
+ /*
public boolean isInside(Hep3Vector p)
{
boolean in=false;
@@ -71,6 +75,63 @@
}
}
return in;
+ }*/
+
+ public Inside inside(Hep3Vector p)
+ {
+ Inside in=OUTSIDE;
+ double x,y,zbase1,zbase2;
+
+ if (abs(p.z())<=dz-tolerance/2)
+ {
+ zbase1=p.z()+dz; // Dist from -ve z plane
+ zbase2=dz-p.z(); // Dist from +ve z plane
+
+ // Check whether inside x tolerance
+ //
+ x=0.5*(dx2*zbase1+dx1*zbase2)/dz - tolerance/2;
+ if (abs(p.x())<=x)
+ {
+ y=0.5*((dy2*zbase1+dy1*zbase2))/dz - tolerance/2;
+ if (abs(p.y())<=y)
+ {
+ in=Inside.INSIDE;
+ }
+ else if (abs(p.y())<=y+tolerance)
+ {
+ in=SURFACE;
+ }
+ }
+ else if (abs(p.x())<=x+tolerance)
+ {
+ // y = y half width of shape at z of point + tolerant boundary
+ //
+ y=0.5*((dy2*zbase1+dy1*zbase2))/dz + tolerance/2;
+ if (abs(p.y())<=y)
+ {
+ in=SURFACE;
+ }
+ }
+ }
+ else if (abs(p.z())<=dz+tolerance/2)
+ {
+ // Only need to check outer tolerant boundaries
+ //
+ zbase1=p.z()+dz; // Dist from -ve z plane
+ zbase2=dz-p.z(); // Dist from +ve z plane
+
+ // x = x half width of shape at z of point plus tolerance
+ //
+ x=0.5*(dx2*zbase1+dx1*zbase2)/dz + tolerance/2;
+ if (abs(p.x())<=x)
+ {
+ // y = y half width of shape at z of point
+ //
+ y=0.5*((dy2*zbase1+dy1*zbase2))/dz + tolerance/2;
+ if (abs(p.y())<=y) in=SURFACE;
+ }
+ }
+ return in;
}
public double getXHalfLength1()
GeomConverter/src/org/lcsim/detector/solids
diff -u -r1.5 -r1.6
--- Tube.java 20 Mar 2007 00:47:19 -0000 1.5
+++ Tube.java 6 Aug 2007 19:09:32 -0000 1.6
@@ -4,11 +4,18 @@
import org.lcsim.detector.Named;
+import static java.lang.Math.abs;
+import static org.lcsim.detector.solids.Inside.INSIDE;
+import static org.lcsim.detector.solids.Inside.OUTSIDE;
+import static org.lcsim.detector.solids.Inside.SURFACE;
+import static org.lcsim.detector.solids.Tolerance.TOLERANCE;
+import static java.lang.Math.sqrt;
+
/**
*
* @author Tim Nelson <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: Tube.java,v 1.5 2007/03/20 00:47:19 jeremy Exp $
+ * @version $Id: Tube.java,v 1.6 2007/08/06 19:09:32 jeremy Exp $
*/
public class Tube
extends Named
@@ -54,12 +61,45 @@
innerRadius * innerRadius) * (zHalfLength * 2);
}
- public boolean isInside(Hep3Vector point)
+ public Inside inside(Hep3Vector p)
{
- double r_xy = Math.sqrt(point.x()*point.x() + point.y()*point.y());
+ Inside inside = OUTSIDE;
+
+ double r_xy = sqrt(p.x()*p.x() + p.y()*p.y());
- return ( r_xy >= innerRadius &&
- r_xy < outerRadius &&
- Math.abs(point.z()) < zHalfLength );
+ // Inside.
+ if ( r_xy > innerRadius - TOLERANCE*0.5 &&
+ r_xy < outerRadius + TOLERANCE*0.5 &&
+ abs(p.z()) < zHalfLength + TOLERANCE*0.5)
+ {
+ inside = INSIDE;
+ }
+ else
+ {
+ // Inner surface.
+ if (r_xy >= innerRadius - TOLERANCE*0.5
+ && r_xy <= innerRadius + TOLERANCE*0.5
+ && abs(p.z()) <= zHalfLength + TOLERANCE*0.5)
+ {
+ inside = SURFACE;
+ }
+ // Outer surface.
+ else if (r_xy >= outerRadius - TOLERANCE*0.5
+ && r_xy <= outerRadius + TOLERANCE*0.5
+ && abs(p.z()) <= zHalfLength + TOLERANCE*0.5)
+ {
+ inside = SURFACE;
+ }
+ // Z plane.
+ else if (abs(p.z()) >= zHalfLength - TOLERANCE*0.5 &&
+ abs(p.z()) <= zHalfLength + TOLERANCE*0.5 &&
+ r_xy >= innerRadius - TOLERANCE*0.5 &&
+ r_xy <= outerRadius + TOLERANCE*0.5)
+ {
+ inside = SURFACE;
+ }
+ }
+
+ return inside;
}
}
\ No newline at end of file
GeomConverter/src/org/lcsim/detector/solids
diff -N Trapezoid.java
--- Trapezoid.java 15 Mar 2007 02:09:15 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-package org.lcsim.detector.solids;
-
-import hep.physics.vec.Hep3Vector;
-
-import org.lcsim.detector.Named;
-
-/**
- *
- * Trapezoid solid.
- *
- * @author Tim Nelson <[log in to unmask]>
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class Trapezoid
-extends Named
-implements ISolid
-{
- double xHalfLength1, xHalfLength2, yHalfLength, zHalfLength;
-
- public Trapezoid(String name, double xHalfLength1, double xHalfLength2, double yHalfLength, double zHalfLength)
- {
- super(name);
- this.xHalfLength1 = xHalfLength1;
- this.xHalfLength2 = xHalfLength2;
- this.yHalfLength = yHalfLength;
- this.zHalfLength = zHalfLength;
- }
-
- public double getCubicVolume()
- {
- return (xHalfLength1+xHalfLength2) * yHalfLength * zHalfLength * 2;
- }
-
- public boolean isInside(Hep3Vector point)
- {
- double inverse_slope = (xHalfLength2-xHalfLength1)/(zHalfLength);
- double x_intercept = (xHalfLength1+xHalfLength2/2.0);
-
- double x_limit = inverse_slope*point.y()+x_intercept;
-
- return ( Math.abs(point.x()) < x_limit &&
- Math.abs(point.y()) < yHalfLength &&
- Math.abs(point.z()) < zHalfLength );
- }
-}
GeomConverter/test/org/lcsim/detector
diff -u -r1.14 -r1.15
--- SimpleDetectorTest.java 25 May 2007 20:16:27 -0000 1.14
+++ SimpleDetectorTest.java 6 Aug 2007 19:09:32 -0000 1.15
@@ -9,6 +9,7 @@
import org.lcsim.detector.material.IMaterial;
import org.lcsim.detector.material.MaterialElement;
import org.lcsim.detector.solids.Box;
+import org.lcsim.detector.solids.Inside;
import org.lcsim.detector.solids.Tube;
public class SimpleDetectorTest extends TestCase
@@ -136,11 +137,11 @@
for (double x : xpoints)
{
Hep3Vector thisx = new BasicHep3Vector(x,0,0);
- boolean isInside = gi.isInside(thisx);
+ Inside inside = gi.inside(thisx);
if (x<5.0)
{
- assertTrue(isInside);
+ assertEquals(inside,Inside.INSIDE);
}
}
GeomConverter/test/org/lcsim/detector/converter/compact
diff -u -r1.11 -r1.12
--- DetectorConverterTest.java 25 May 2007 20:16:27 -0000 1.11
+++ DetectorConverterTest.java 6 Aug 2007 19:09:32 -0000 1.12
@@ -11,12 +11,12 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.lcsim.detector.DetectorElementContainer;
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.solids.Inside;
import org.lcsim.detector.solids.Tube;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.GeometryReader;
@@ -150,7 +150,7 @@
if ( ypoint > sensorTube.getInnerRadius() &&
ypoint < sensorTube.getOuterRadius() )
{
- assertTrue(sensorGeo.isInside(point));
+ assertEquals(sensorGeo.inside(point),Inside.INSIDE);
}
}
// Check isInside for endcap positive.
@@ -172,7 +172,7 @@
if ( zpoint > (zsensor - zwidth ) &&
zpoint < (zsensor + zwidth ) )
{
- assertTrue(sensorGeo.isInside(point));
+ assertEquals(sensorGeo.inside(point),Inside.INSIDE);
}
}
// Check isInside for endcap negative.
@@ -190,7 +190,7 @@
//System.out.println("check " + sensor.getName() + " @ point = " + point);
- assertTrue(sensorGeo.isInside(point));
+ assertEquals(sensorGeo.inside(point),Inside.INSIDE);
}
}
}
CVSspam 0.2.8