Author: [log in to unmask] Date: Mon Aug 31 17:18:45 2015 New Revision: 3476 Log: use better initial conditions, add more failsafes Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/MultipleScattering.java java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/MultipleScattering.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/MultipleScattering.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/MultipleScattering.java Mon Aug 31 17:18:45 2015 @@ -294,15 +294,14 @@ System.out.printf("%s: found simple intercept at %s \n", this.getClass().getSimpleName(), pos_int_trk.toString()); } - // TODO Catch special cases where the incidental iteration procedure seem to fail -// if (Math.abs(helix.R()) < 2000) { -// if (_debug) { -// System.out.printf("%s: momentum is low (p=%f,R=%f,B=%f), skip the iterative calculation\n", this.getClass().getSimpleName(), helix.p(Math.abs(_bfield)), helix.R(), _bfield); -// } -// -// return pos_int_trk; -// } - + // TODO Catch special cases where the incidental iteration procedure seems to fail + if (Math.abs(helix.R()) < 2000 && Math.abs(helix.dca()) > 10.0) { + if (_debug) { + System.out.printf("%s: momentum is low (p=%f,R=%f,B=%f) and d0 is big (d0=%f), skip the iterative calculation\n", this.getClass().getSimpleName(), helix.p(Math.abs(_bfield)), helix.R(), _bfield, helix.dca()); + } + return pos_int_trk; + } + if (_debug) { System.out.printf("%s: calculate iterative helix intercept\n", this.getClass().getSimpleName()); } Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java Mon Aug 31 17:18:45 2015 @@ -139,7 +139,7 @@ * @return point at intercept */ public static Hep3Vector getHelixPlaneIntercept(HelicalTrackFit helfit, Hep3Vector unit_vec_normal_to_plane, Hep3Vector point_on_plane, double bfield) { - return getHelixPlaneIntercept(helfit,unit_vec_normal_to_plane,point_on_plane,bfield,0); + return getHelixPlaneIntercept(helfit, unit_vec_normal_to_plane, point_on_plane, bfield, 0); } public static Hep3Vector getHelixPlaneIntercept(HelicalTrackFit helfit, Hep3Vector unit_vec_normal_to_plane, Hep3Vector point_on_plane, double bfield, double initial_s) { @@ -148,8 +148,9 @@ //WTrack wtrack = new WTrack(helfit, -1.0*bfield); // Hep3Vector B = new BasicHep3Vector(0, 0, 1); WTrack wtrack = new WTrack(helfit, bfield); // - if (initial_s!=0) + if (initial_s != 0) { wtrack.setTrackParameters(wtrack.getHelixParametersAtPathLength(initial_s, B)); + } if (debug) { System.out.printf("getHelixPlaneIntercept:find intercept between plane defined by point on plane %s, unit vec %s, bfield %.3f, h=%s and WTrack \n%s \n", point_on_plane.toString(), unit_vec_normal_to_plane.toString(), bfield, B.toString(), wtrack.toString()); } @@ -176,7 +177,8 @@ public static Hep3Vector getHelixPlaneIntercept(HelicalTrackFit helfit, HelicalTrackStripGbl strip, double bfield) { Hep3Vector point_on_plane = strip.origin(); Hep3Vector unit_vec_normal_to_plane = VecOp.cross(strip.u(), strip.v());// strip.w(); - Hep3Vector intercept_point = getHelixPlaneIntercept(helfit, unit_vec_normal_to_plane, point_on_plane, bfield); + double s_origin = HelixUtils.PathToXPlane(helfit, strip.origin().x(), 0., 0).get(0); + Hep3Vector intercept_point = getHelixPlaneIntercept(helfit, unit_vec_normal_to_plane, point_on_plane, bfield, s_origin); return intercept_point; } Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java Mon Aug 31 17:18:45 2015 @@ -292,6 +292,12 @@ //Find intercept point with sensor in tracking frame Hep3Vector trkpos = TrackUtils.getHelixPlaneIntercept(htf, strip, Math.abs(_B.z())); + if (trkpos == null) { + if (_debug > 0) { + System.out.println("Can't find track intercept; use sensor origin"); + } + trkpos = strip.origin(); + } Hep3Vector trkposTruth = htfTruth != null ? TrackUtils.getHelixPlaneIntercept(htfTruth, strip, Math.abs(_B.z())) : new BasicHep3Vector(-999999.9, -999999.9, -999999.9); if (textFile != null) { textFile.printStripTrackPos(trkpos);