Commit in hps-java/src/main/java/org/lcsim/hps/users/omoreno on MAIN | |||
ExtendTrack.java | +172 | -74 | 1.2 -> 1.3 |
Added the ability to extrapolate anywhere outside the Dipole volume; Stores track parameters
diff -u -r1.2 -r1.3 --- ExtendTrack.java 9 May 2012 11:52:05 -0000 1.2 +++ ExtendTrack.java 11 May 2012 13:07:44 -0000 1.3 @@ -1,129 +1,227 @@
package org.lcsim.hps.users.omoreno;
+//--- hep ---//
import hep.physics.vec.BasicHep3Vector; import hep.physics.vec.Hep3Vector;
+//--- org.lcsim ---//
import org.lcsim.recon.tracking.seedtracker.SeedTrack; /** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: ExtendTrack.java,v 1.2 2012/05/09 11:52:05 omoreno Exp $
+ * @version $Id: ExtendTrack.java,v 1.3 2012/05/11 13:07:44 omoreno Exp $
*/ public class ExtendTrack {
- public static final double ECAL_POSITION = 1470; // mm - public static final double DIPOLE_EDGE = 914.4; // mm
+ public static final double ECAL_FACE = 1450; // mm + public static final double DIPOLE_EDGE = 914; // mm + + + SeedTrack track; + double[] trackParameters; + + boolean debug = true;
/** * */
- public ExtendTrack(){
+ public ExtendTrack(){ + track = null;
}
-
+
/** * */
- public static double arcLengthToYPlane(SeedTrack track, double y){
+ public void setTrack(SeedTrack track){ + this.track = track; + trackParameters = new double[9]; + this.setTrackParameters(track); + } + + /** + * + */ + public void setTrackParameters(SeedTrack track){
- // Get the track parameters - double doca = track.getTrackParameter(0); - double phi0 = track.getTrackParameter(1); - double R = 1/track.getTrackParameter(2);
+ // All track parameters are in LCSim coordinates system + trackParameters[0] = track.getTrackParameter(0); // DOCA + trackParameters[1] = track.getTrackParameter(1); // phi0 + trackParameters[2] = 1/track.getTrackParameter(2); // R + trackParameters[3] = -this.getDoca()*Math.sin(this.getPhi0()); // x0 + trackParameters[4] = this.getDoca()*Math.cos(this.getPhi0()); // y0 + trackParameters[5] = track.getTrackParameter(3); // z0 + trackParameters[6] = track.getTrackParameter(4); // tan(Lambda) + trackParameters[7] = (this.getR() - this.getPhi0())*Math.sin(this.getPhi0()); // xc + trackParameters[8] = -(this.getR() - this.getPhi0())*Math.cos(this.getPhi0()); // yc + } + + /** + * + */ + public double getDoca(){ + return trackParameters[0]; + } + + /** + * + */ + public double getPhi0(){ + return trackParameters[1]; + } + + /** + * + */ + public double getR(){ + return trackParameters[2]; + } + + /** + * + */ + public double getX0(){ + return trackParameters[3]; + } + + /** + * + */ + public double getY0(){ + return trackParameters[4]; + } + /** + * + */ + public double getZ0(){ + return trackParameters[5]; + } + + /** + * + */ + public double getTanLambda(){ + return trackParameters[6]; + } + + /** + * + */ + public double getXC(){ + return trackParameters[7]; + } + + /** + * + */ + public double getYC(){ + return trackParameters[8]; + } + + /** + * + */ + public void printTrackParameters(){ + System.out.println(" DOCA: " + this.getDoca() + + " phi0: " + this.getPhi0() + + " R: " + this.getR() + + " x0: " + this.getX0() + + " y0: " + this.getY0() + + " z0: " + this.getZ0() + + " tan(Lambda): " + this.getTanLambda() + + " xc: " + this.getXC() + + " yc: " + this.getYC() );
- // Get the coordinates of the distance of closest approach - double x0 = -doca*Math.sin(phi0); - double y0 = doca*Math.cos(phi0);
+ }
- // Get the coordinates of the helix center - double xc = (R - doca)*Math.sin(phi0); - double yc = -(R - doca)*Math.cos(phi0);
+ /** + * + */ + public double getXOnHelixProjection(double y){
- System.out.println("x0: " + x0 + " y0: " + y0); - System.out.println("Phi0: " + track.getTrackParameter(1)); - System.out.println("xc: " + xc + " yc: " + yc);
+ // Check if a track has been set + if(track == null) throw new RuntimeException("Track has not been set!");
- // Find the x-coor dinate - double x = xc + Math.signum(R)*Math.sqrt(R*R - Math.pow(y-yc, 2));
+ // Find the x position + return this.getXC() + + Math.signum(this.getR())*Math.sqrt(this.getR()*this.getR() - Math.pow(y-this.getYC(), 2)); + } + + /** + * + */ + public double getYOnHelixProjection(double x){
- System.out.println("X Position: " + x);
+ // Check if a track has been set + if(track == null) throw new RuntimeException("Track has not been set!"); + + return this.getYC() + + Math.signum(this.getR())*Math.sqrt(this.getR()*this.getR() - Math.pow(x-this.getXC(), 2));
- return arcLength(R, x0, y0, x, y, xc, yc);
}
-
+
/** * */
- public static double arcLength(double R, double x1, double y1, double x2, double y2, - double xc, double yc){
+ public double arcLength(double x, double y){
- // Find the angle between these points measured wrt the circle center - double phi1 = Math.atan2(y1 - yc, x1 - xc); - System.out.println("Phi 1: " + phi1);
+ double phi0 = Math.atan2(this.getY0() - this.getYC(), this.getX0() - this.getXC()); + double phi = Math.atan2(y - this.getYC(), x - this.getXC()); + double dphi = phi - phi0;
- double phi2 = Math.atan2(y2 - yc, x2 - xc); - System.out.println("Phi 2: " + phi2); - double dphi = phi2 - phi1; - - // Make sure dphi is in the valid range (-pi, pi)
if (dphi > Math.PI) dphi -= 2. * Math.PI; if (dphi < -Math.PI) dphi += 2. * Math.PI;
- System.out.println("phi: " + dphi); - - // Return the arc length - return -R * dphi;
+ return -this.getR()*dphi;
} /** * */
- public static Hep3Vector positionOnHelix(SeedTrack track, double s){
+ public Hep3Vector positionAtEcal(){
- // Get the track parameters - double doca = track.getTrackParameter(0); - double phi0 = track.getTrackParameter(1); - double R = 1/track.getTrackParameter(2); - double z0 = track.getTrackParameter(3); - double tanLambda = track.getTrackParameter(4);
+ // Check if a track has been set + if(track == null) throw new RuntimeException("Track has not been set!");
- // Find the azimuthal angle at this position - double phi = phi0 - s/R; - - // Get the coordinates of the helix center - double xc = (R - doca)*Math.sin(phi0); - double yc = -(R - doca)*Math.cos(phi0); - - // Find the position on the helix - double x = xc - R*Math.sin(phi); - double y = yc - R*Math.cos(phi); - double z = z0 + s*tanLambda; - - return new BasicHep3Vector(x, y, z);
+ return this.extrapolateTrack(ECAL_FACE);
} /** * */
- public static Hep3Vector positionAtEcal(SeedTrack track){ - - double arcLengthDPEdge = arcLengthToYPlane(track, DIPOLE_EDGE); - Hep3Vector position = positionOnHelix(track, arcLengthDPEdge); - - // Get the track parameters - double phi0 = track.getTrackParameter(1); - double R = 1/track.getTrackParameter(2); - double tanTheta = 1/track.getTrackParameter(4);
+ public Hep3Vector extrapolateTrack(double x){
- // Find the azimuthal angle at this position - double phi = phi0 - arcLengthDPEdge/R; - - double xEcal = position.x() + (ECAL_POSITION - DIPOLE_EDGE)/Math.tan(phi); - double zEcal = position.z() + (ECAL_POSITION - DIPOLE_EDGE)/tanTheta; - - return new BasicHep3Vector(xEcal, ECAL_POSITION, zEcal);
+ if(x > DIPOLE_EDGE){ + + double yDipole = this.getYOnHelixProjection(DIPOLE_EDGE); + double s = this.arcLength(DIPOLE_EDGE, yDipole); + double zDipole = this.getZ0() + s*this.getTanLambda(); + double phi = this.getPhi0() - s/this.getR(); + + double dx = x - DIPOLE_EDGE; + double r = dx/(Math.cos(phi)*(1/Math.sqrt(1 + Math.pow(this.getTanLambda(), 2)))); + double dy = r*Math.sin(phi)*(1/Math.sqrt(1 + Math.pow(this.getTanLambda(), 2))); + double dz = r*(this.getTanLambda()/Math.sqrt(1 + Math.pow(this.getTanLambda(), 2))); + + double y = yDipole + dy; + double z = zDipole + dz; + + return new BasicHep3Vector(x, y, z); + } else if(x < 0){ + double dx = x - this.getX0(); + double r = dx/(Math.cos(this.getPhi0())*(1/Math.sqrt(1 + Math.pow(this.getTanLambda(), 2)))); + double dy = r*Math.sin(this.getPhi0())*(1/Math.sqrt(1 + Math.pow(this.getTanLambda(), 2))); + double dz = r*(this.getTanLambda()/Math.sqrt(1 + Math.pow(this.getTanLambda(), 2))); + + double y = this.getY0() + dy; + double z = this.getZ0() + dz; + + return new BasicHep3Vector(x, y, z); + } else throw new RuntimeException(x + " value is invalid! x-coodinate must be outside of dipole volume!");
}
+ +
}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1