hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -N SvtTrackExtrapolator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SvtTrackExtrapolator.java 12 May 2012 22:21:20 -0000 1.1
@@ -0,0 +1,78 @@
+package org.lcsim.hps.recon.tracking;
+
+//--- org.lcsim ---//
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.recon.tracking.seedtracker.SeedTrack;
+
+public class SvtTrackExtrapolator {
+
+ SeedTrack track;
+ TrackUtils trackUtils;
+
+ public static final double ECAL_FACE = 1450; // mm
+ public static final double DIPOLE_EDGE = 914; // mm
+
+ /**
+ *
+ */
+ public SvtTrackExtrapolator(){
+ track = null;
+ trackUtils = new TrackUtils();
+ }
+
+ /**
+ *
+ */
+ public void setTrack(SeedTrack track){
+ this.track = track;
+ trackUtils.setTrack(track);
+ }
+
+ /**
+ *
+ */
+ public Hep3Vector getTrackPositionAtEcal(){
+
+ return this.extrapolateTrack(ECAL_FACE);
+ }
+
+ /**
+ *
+ */
+ public Hep3Vector extrapolateTrack(double x){
+
+ if(track == null) throw new RuntimeException("Track has not been set!");
+
+ if(x > DIPOLE_EDGE){
+ double yDipole = trackUtils.getYOnHelixProjection(x);
+ double s = trackUtils.arcLength(DIPOLE_EDGE, yDipole);
+ double zDipole = trackUtils.getZ0() + s*trackUtils.getTanLambda();
+ double phi = trackUtils.getPhi0() - s/trackUtils.getR();
+
+ double dx = x - DIPOLE_EDGE;
+ double r = dx/(Math.cos(phi)*(1/Math.sqrt(1 + Math.pow(trackUtils.getTanLambda(), 2))));
+ double dy = r*Math.sin(phi)*(1/Math.sqrt(1 + Math.pow(trackUtils.getTanLambda(), 2)));
+ double dz = r*(trackUtils.getTanLambda()/Math.sqrt(1 + Math.pow(trackUtils.getTanLambda(), 2)));
+
+ double y = yDipole + dy;
+ double z = zDipole + dz;
+
+ return new BasicHep3Vector(x, y, z);
+
+ } else if(x < 0){
+ double dx = x - trackUtils.getX0();
+ double r = dx/(Math.cos(trackUtils.getPhi0())*(1/Math.sqrt(1 + Math.pow(trackUtils.getTanLambda(), 2))));
+ double dy = r*Math.sin(trackUtils.getPhi0())*(1/Math.sqrt(1 + Math.pow(trackUtils.getTanLambda(), 2)));
+ double dz = r*(trackUtils.getTanLambda()/Math.sqrt(1 + Math.pow(trackUtils.getTanLambda(), 2)));
+
+ double y = trackUtils.getY0() + dy;
+ double z = trackUtils.getZ0() + dz;
+
+ return new BasicHep3Vector(x, y, z);
+
+ } else throw new RuntimeException(x + " value is invalid! z-coordinate must lie outside dipole volume.");
+
+ }
+}