hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.15 -r1.16
--- TrackUtils.java 9 Feb 2013 00:34:16 -0000 1.15
+++ TrackUtils.java 13 Feb 2013 18:20:54 -0000 1.16
@@ -27,7 +27,7 @@
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: TrackUtils.java,v 1.15 2013/02/09 00:34:16 phansson Exp $
+ * @version $Id: TrackUtils.java,v 1.16 2013/02/13 18:20:54 phansson Exp $
* TODO: Switch to JLab coordinates
*/
@@ -426,22 +426,38 @@
//This is how I do it with HelicalTrackFits
double s = HelixUtils.PathToXPlane(track, hth.x(), 0, 0).get(0);
//System.out.printf("x %f s %f smap %f\n",hth.x(),s,s_wrong);
+ if(Double.isNaN(s)) {
+ double x0 = track.x0();
+ double y0 = track.y0();
+
+ double xc=track.xc();
+ double yc=track.yc();
+ double RC = track.R();
+ double y=yc+Math.signum(RC)*Math.sqrt(RC*RC-Math.pow(hth.x()-xc,2));
+ System.out.printf("calculateTrackHitResidual: s is NaN. p=%.3f RC=%.3f, x=%.3f, xc=%.3f\n",track.p(-0.491),RC,hth.x(),xc);
+ }
+
Hep3Vector posOnHelix = HelixUtils.PointOnHelix(track, s);
double resy = hth.y() - posOnHelix.y();
double erry = includeMS ? wrphi : drphi_res;
-
- residuals.put("resy", resy);
- residuals.put("erry", erry);
- residuals.put("drphi", drphi_res);
- residuals.put("msdrphi",msdrphi);
-
-
//Now the residual for the "measurement" direction z
double resz = hth.z() - posOnHelix.z();
double dz_res = HitUtils.zres(hth, msmap, track);
double dz_res2 = hth.getCorrectedCovMatrix().diagonal(2);
+
+ if(Double.isNaN(resy)) {
+ System.out.printf("calculateTrackHitResidual: resy is NaN. hit at %s posOnHelix=%s path=%.3f wrong_path=%.3f helix:\n%s\n",hth.getCorrectedPosition().toString(),posOnHelix.toString(),s,s_wrong,track.toString());
+ resy=-9999999.9;
+ resz=-9999999.9;
+
+ }
+
+ residuals.put("resy", resy);
+ residuals.put("erry", erry);
+ residuals.put("drphi", drphi_res);
+ residuals.put("msdrphi",msdrphi);
residuals.put("resz",resz);
residuals.put("errz",dz_res);