Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
TrackUtils.java | +195 | added 1.1 |
A class to hold various track utilities
diff -N TrackUtils.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TrackUtils.java 12 May 2012 22:20:44 -0000 1.1 @@ -0,0 +1,195 @@
+package org.lcsim.hps.recon.tracking; + +//--- 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: TrackUtils.java,v 1.1 2012/05/12 22:20:44 omoreno Exp $ + */ + +public class TrackUtils { + + SeedTrack track; + double[] trackParameters; + + /** + * + */ + public TrackUtils(){ + track = null; + } + + /** + * + */ + public void setTrack(SeedTrack track){ + this.track = track; + trackParameters = new double[9]; + this.setTrackParameters(track); + } + + /** + * + */ + 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 double getXOnHelixProjection(double y){ + + // Check if a track has been set + if(track == null) throw new RuntimeException("Track has not been set!"); + + // 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){ + + // 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)); + + } + + /** + * + */ + public double arcLength(double x, double y){ + + 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; + + if (dphi > Math.PI) dphi -= 2. * Math.PI; + if (dphi < -Math.PI) dphi += 2. * Math.PI; + + return -this.getR()*dphi; + } + + /** + * + */ + 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() ); + + } + + + /** + * + */ + private void setTrackParameters(SeedTrack track){ + + // 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 Hep3Vector extrapolateHelixToXPlane(double x){ + double y = this.getYOnHelixProjection(x); + double s = this.arcLength(x, y); + double z = this.getZ0() + s*this.getTanLambda(); + + return new BasicHep3Vector(x, y, z); + } + + /** + * + */ + public Hep3Vector extrapolateHelixToYPlane(double y){ + double x = this.getXOnHelixProjection(y); + double s = this.arcLength(x, y); + double z = this.getZ0() + s*this.getTanLambda(); + + return new BasicHep3Vector(x, y, z); + } +}
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