lcsim/src/org/lcsim/recon/cluster/structural/likelihood
diff -u -r1.3 -r1.4
--- TrackToTrackDOCA.java 2 Jan 2008 23:20:39 -0000 1.3
+++ TrackToTrackDOCA.java 9 Jan 2008 18:44:03 -0000 1.4
@@ -21,7 +21,7 @@
* four hits (otherwise the direction is not so meaningful).
*
* @author Mat Charles <[log in to unmask]>
- * @version $Id: TrackToTrackDOCA.java,v 1.3 2008/01/02 23:20:39 mcharles Exp $
+ * @version $Id: TrackToTrackDOCA.java,v 1.4 2008/01/09 18:44:03 mcharles Exp $
*/
public class TrackToTrackDOCA implements StructuralLikelihoodQuantity
@@ -58,7 +58,8 @@
// Another symptom of parallel lines.
linesAreParallel = true;
}
-
+
+ double doca = -1.0;
if (linesAreParallel) {
// Lines are parallel!
// Find a point on each line
@@ -74,14 +75,22 @@
double direction_z = line1.getDirection().z();
double dotProduct = displacement_x*direction_x + displacement_y*direction_y + displacement_z*direction_z;
// Subtract in quadrature to get perpendicular distance (DOCA)
- double doca = distanceBetweenPoints*distanceBetweenPoints - dotProduct*dotProduct;
- return doca;
+ doca = distanceBetweenPoints*distanceBetweenPoints - dotProduct*dotProduct;
} else {
Hep3Vector poca1 = line1.getPointAtDistance(distancesAlongLinesToPOCAs[0]);
Hep3Vector poca2 = line2.getPointAtDistance(distancesAlongLinesToPOCAs[1]);
- double doca = VecOp.sub(poca1,poca2).magnitude();
- return doca;
+ doca = VecOp.sub(poca1,poca2).magnitude();
+ }
+
+ // DOCA should never be less than zero
+ if (doca < 0.0 && doca > -1.0E-10) {
+ // Rounding error -- ignore it
+ doca = 0.0;
+ } else if (doca < 0.0) {
+ // Error
+ throw new AssertionError("DOCA is "+doca+" but values below zero are forbidden! Flag [linesAreParallel]="+linesAreParallel);
}
+ return doca;
}