hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.6 -r1.7
--- TrackUtils.java 9 Oct 2012 01:16:11 -0000 1.6
+++ TrackUtils.java 18 Oct 2012 14:45:03 -0000 1.7
@@ -19,13 +19,15 @@
import org.lcsim.event.Track;
import org.lcsim.event.TrackState;
import org.lcsim.fit.helicaltrack.*;
+import org.lcsim.hps.users.phansson.WTrack;
+import org.lcsim.hps.users.phansson.WTrackUtils;
import org.lcsim.recon.tracking.seedtracker.SeedCandidate;
import org.lcsim.recon.tracking.seedtracker.SeedTrack;
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: TrackUtils.java,v 1.6 2012/10/09 01:16:11 phansson Exp $
+ * @version $Id: TrackUtils.java,v 1.7 2012/10/18 14:45:03 phansson Exp $
* TODO: Switch to JLab coordinates
*/
@@ -34,6 +36,9 @@
boolean _debug = false;
boolean isTrackSet = false;
double[] trackParameters;
+ WTrackUtils _wutils = new WTrackUtils();
+ Hep3Vector _bfield_vec = new BasicHep3Vector(0,0,1);
+
/**
*
@@ -244,6 +249,13 @@
}
+ public Hep3Vector calculateIterativeHelixInterceptXPlane(HelicalTrackFit helfit, HelicalTrackStrip strip, double bfield) {
+ WTrack wtrack = new WTrack(helfit,bfield);
+ Hep3Vector point_on_plane = strip.origin();
+ Hep3Vector unit_vec_normal_to_plane = VecOp.cross(strip.u(),strip.v());//strip.w();
+ Hep3Vector intercept_point = _wutils.getHelixAndPlaneIntercept(wtrack, point_on_plane, unit_vec_normal_to_plane, _bfield_vec);
+ return intercept_point;
+ }
public double calculateHelixInterceptXPlane(HelicalTrackFit helfit, HelicalTrackStrip strip) {
/*
@@ -413,6 +425,56 @@
Map<HelicalTrackHit, MultipleScatter> msmap = new HashMap<HelicalTrackHit, MultipleScatter>();
HelicalTrackFit fit = new HelicalTrackFit(helix_parameters, cov, chisq, ndf,smap,msmap);
return fit;
+ }
+
+ public Map<String,Double> calculateTrackHitResidual(HelicalTrackHit hth,HelicalTrackFit track, boolean includeMS ) {
+ Map<String,Double> residuals = new HashMap<String,Double>();
+
+ Map<HelicalTrackHit, MultipleScatter> msmap = track.ScatterMap();
+ double msdrphi = 0;
+ double msdz = 0;
+
+ if(includeMS) {
+ msdrphi = msmap.get(hth).drphi();
+ msdz = msmap.get(hth).dz();
+ }
+
+ //Calculate the residuals that are being used in the track fit
+
+ //Start with the bendplane y
+ double drphi_res = hth.drphi();
+ double wrphi = Math.sqrt(drphi_res*drphi_res + msdrphi*msdrphi);
+ //This is the normal way to get s
+ double s_wrong = track.PathMap().get(hth);
+ //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);
+ 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);
+
+
+ //Now the residual for the "measurement" direction z
+ double resz = hth.z() - posOnHelix.z();
+ //double dz = HitUtils.zres(hth, msmap, track);
+
+ double slope = hth.z() / hth.r();
+ // Don't use the helix slope if the magnitude of the slope is smaller than its uncertainty
+ if (Math.abs(track.slope()) > track.getSlopeError()) slope = track.slope();
+ // Take the resolution uncertainty to be dr * |slope|
+ double dzres = hth.dr() * Math.abs(slope);
+ // Combine resolution and multiple scattering uncertainties in quadrature
+ double dz = dzres; //Math.sqrt(dzres*dzres + msdz*msdz);
+
+ residuals.put("resz",resz);
+ residuals.put("errz",dz);
+
+ return residuals;
}
+
}