hps-java/src/main/java/org/lcsim/hps/users/phansson
diff -u -r1.5 -r1.6
--- AlignmentUtils.java 3 Sep 2012 00:32:18 -0000 1.5
+++ AlignmentUtils.java 4 Sep 2012 03:01:12 -0000 1.6
@@ -7,6 +7,7 @@
import hep.physics.matrix.BasicMatrix;
import org.lcsim.fit.helicaltrack.HelicalTrackFit;
import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
+import org.lcsim.fit.helicaltrack.HelixUtils;
/**
*
@@ -15,11 +16,11 @@
public class AlignmentUtils {
- public AlignmentUtils() {
-
+ public AlignmentUtils(boolean debug) {
+ _debug = debug;
}
- public BasicMatrix calculateLocalHelixDerivatives(HelicalTrackFit trk, HelicalTrackStrip strip) {
+ public BasicMatrix calculateLocalHelixDerivatives(HelicalTrackFit trk, HelicalTrackStrip strip, double smax, int _nlc) {
// Calculate the derivative w.r.t. to the track parameters (in order/index):
// d0, z0, slope, phi0, R
@@ -40,7 +41,8 @@
double phi0 = trk.phi0();
double R = trk.R();
double slope = trk.slope();
-
+ double s = HelixUtils.PathToXPlane(trk, xint, smax, _nlc).get(0);
+ double phi = -s/R + phi0;
BasicMatrix dfdq = new BasicMatrix(3,5); //3-dim,ntrackparams
@@ -48,7 +50,7 @@
dfdq.setElement(0, 1, dx_dz0());
dfdq.setElement(0, 2, dx_dslope());
dfdq.setElement(0, 3, dx_dphi0(xint,xr,yr,d0,phi0,R));
- dfdq.setElement(0, 4, dx_dR(xint,xr,yr,d0,phi0,R));
+ dfdq.setElement(0, 4, dx_dR(xint,xr,yr,d0,phi0,R,phi));
dfdq.setElement(1, 0, dy_dd0(xint,xr,d0,phi0,R));
@@ -58,11 +60,11 @@
dfdq.setElement(1, 4, dy_dR(xint,xr,d0,phi0,R));
- dfdq.setElement(2, 0, dz_dd0(xint,xr,yr,d0,phi0,slope,R));
+ dfdq.setElement(2, 0, dz_dd0(xint,xr,yr,d0,phi0,slope,R,phi));
dfdq.setElement(2, 1, dz_dz0());
- dfdq.setElement(2, 2, dz_dslope(xint,xr,yr,d0,phi0,slope,R));
- dfdq.setElement(2, 3, dz_ddphi(xint,xr,yr,d0,phi0,slope,R));
- dfdq.setElement(2, 4, dz_dR(xint,xr,yr,d0,phi0,slope,R));
+ dfdq.setElement(2, 2, dz_dslope(xint,xr,yr,d0,phi0,slope,R,phi));
+ dfdq.setElement(2, 3, dz_ddphi(xint,xr,yr,d0,phi0,slope,R,phi));
+ dfdq.setElement(2, 4, dz_dR(xint,xr,yr,d0,phi0,slope,R,phi));
return dfdq;
@@ -71,18 +73,18 @@
- public double dphi_dx(double xint,double xr, double yr, double d0, double phi0, double R) {
+ public double dphi_dx(double xint,double xr, double yr, double d0, double phi0, double R, double phi) {
double arg1 = Math.sin(phi0) - (xint-x0(xr,d0,phi0))/R;
- double arg2 = Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R)-y0(yr,d0,phi0))/R;
+ double arg2 = Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R,phi)-y0(yr,d0,phi0))/R;
return (-1/R)*arg2/(arg2*arg2+arg1*arg1);
}
- public double dphi_dy(double xint,double xr, double yr, double d0, double phi0, double R) {
- System.out.println("dphi_dy:");
+ public double dphi_dy(double xint,double xr, double yr, double d0, double phi0, double R, double phi) {
+ if(_debug) System.out.println("dphi_dy:");
double arg1 = Math.sin(phi0) - (xint-x0(xr,d0,phi0))/R;
- double arg2 = Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R)-y0(yr,d0,phi0))/R;
- System.out.println("dphi_dy: arg1=" + arg1 + " arg2="+arg2 + " R =" + R );
- System.out.println("dphi_dy ===> " + (-1/R)*arg1/(arg2*arg2+arg1*arg1));
+ double arg2 = Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R,phi)-y0(yr,d0,phi0))/R;
+ if(_debug) System.out.println("dphi_dy: arg1=" + arg1 + " arg2="+arg2 + " R =" + R );
+ if(_debug) System.out.println("dphi_dy ===> " + (-1/R)*arg1/(arg2*arg2+arg1*arg1));
return (-1/R)*arg1/(arg2*arg2+arg1*arg1);
}
public double dphi_dz(double slope, double R) {
@@ -101,36 +103,37 @@
return 1;
}
- public double dy_dx(double xint, double xr, double yr ,double d0, double phi0, double R) {
- return -1*sign(R)*R*this.phi(xint, xr, yr, d0, phi0, R)*this.dphi_dx(xint, xr, yr, d0, phi0, R);
+ public double dy_dx(double xint, double xr, double yr ,double d0, double phi0, double R, double phi) {
+ return -1*sign(R)*R*phi*this.dphi_dx(xint, xr, yr, d0, phi0, R, phi);
+ //return -1*sign(R)*R*this.phi(xint, xr, yr, d0, phi0, R)*this.dphi_dx(xint, xr, yr, d0, phi0, R);
}
- public double dz_dx(double xint, double xr,double yr,double d0, double phi0, double slope, double R) {
- return -slope*R*this.dphi_dx(xint, xr, yr, d0, phi0, R);
+ public double dz_dx(double xint, double xr,double yr,double d0, double phi0, double slope, double R, double phi) {
+ return -slope*R*this.dphi_dx(xint, xr, yr, d0, phi0, R, phi);
}
- public double dx_dy(double xint, double xr, double yr ,double d0, double phi0, double R) {
- System.out.println("dx_dy: xint=" + xint + " phi0="+phi0+" R="+R );
- System.out.println("dx_dy: cos(phi)="+Math.cos(this.phi(xint, xr, yr, d0, phi0, R)) + " dphi_dy="+this.dphi_dy(xint, xr, yr, d0, phi0, R));
- System.out.println("dx_dy: ====> R*cos*dphi_dy = "+ sign(R)*R*Math.cos(this.phi(xint, xr, yr, d0, phi0, R))*this.dphi_dy(xint, xr, yr, d0, phi0, R));
- return sign(R)*R*Math.cos(this.phi(xint, xr, yr, d0, phi0, R))*this.dphi_dy(xint, xr, yr, d0, phi0, R);
+ public double dx_dy(double xint, double xr, double yr ,double d0, double phi0, double R, double phi) {
+ if(_debug) System.out.println("dx_dy: xint=" + xint + " phi0="+phi0+" R="+R );
+ if(_debug) System.out.println("dx_dy: cos(phi)="+Math.cos(phi) + " dphi_dy="+this.dphi_dy(xint, xr, yr, d0, phi0, R, phi));
+ if(_debug) System.out.println("dx_dy: ====> R*cos*dphi_dy = "+ sign(R)*R*Math.cos(phi)*this.dphi_dy(xint, xr, yr, d0, phi0, R, phi));
+ return sign(R)*R*Math.cos(phi)*this.dphi_dy(xint, xr, yr, d0, phi0, R, phi);
}
public double dy_dy() {
return 1;
}
- public double dz_dy(double xint, double xr ,double d0, double phi0, double slope, double R) {
- return -R*slope*this.dphi_dy(xint, xr, xr, d0, phi0, R);
+ public double dz_dy(double xint, double xr ,double d0, double phi0, double slope, double R, double phi) {
+ return -R*slope*this.dphi_dy(xint, xr, xr, d0, phi0, R, phi);
}
- public double dx_dz(double xint, double xr, double yr ,double d0, double phi0, double slope, double R) {
- return sign(R)*R*Math.cos(this.phi(xint, xr, yr, d0, phi0, R))*this.dphi_dz(slope, R);
+ public double dx_dz(double xint, double xr, double yr ,double d0, double phi0, double slope, double R, double phi) {
+ return sign(R)*R*Math.cos(phi)*this.dphi_dz(slope, R);
}
- public double dy_dz(double xint, double xr, double yr ,double d0, double phi0, double slope, double R) {
- return -sign(R)*R*Math.sin(this.phi(xint, xr, yr, d0, phi0, R))*this.dphi_dz(slope, R);
+ public double dy_dz(double xint, double xr, double yr ,double d0, double phi0, double slope, double R, double phi) {
+ return -sign(R)*R*Math.sin(phi)*this.dphi_dz(slope, R);
}
public double dz_dz() {
@@ -206,8 +209,8 @@
return (-d0+R)*Math.cos(phi0) + sign(R)*ddeltayc_dphi0(x,xr,yr,d0,phi0,R);
}
- public double dx_dR(double x, double xr, double yr, double d0, double phi0, double R) {
- return Math.sin(phi0) + deltayc(x,xr,yr,d0,phi0,R)*dsign_dR(R) + sign(R)*ddeltayc_dR(x,xr,d0,phi0,R);
+ public double dx_dR(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
+ return Math.sin(phi0) + deltayc(x,xr,yr,d0,phi0,R,phi)*dsign_dR(R) + sign(R)*ddeltayc_dR(x,xr,d0,phi0,R);
}
//-----------------------------------
@@ -248,26 +251,26 @@
// Derivatives of z
- public double dz_dd0(double x, double xr, double yr, double d0, double phi0, double slope, double R) {
- return -R*slope*dtmpdphi_dd0(x, xr, yr, d0, phi0, R);
+ public double dz_dd0(double x, double xr, double yr, double d0, double phi0, double slope, double R, double phi) {
+ return -R*slope*dtmpdphi_dd0(x, xr, yr, d0, phi0, R, phi);
}
public double dz_dz0() {
return 1.0;
}
- public double dz_dslope(double x, double xr, double yr, double d0, double phi0, double slope, double R) {
- double dphi = get_dphi(x,xr,yr,d0,phi0,R);
+ public double dz_dslope(double x, double xr, double yr, double d0, double phi0, double slope, double R, double phi) {
+ double dphi = get_dphi(x,xr,yr,d0,phi0,R,phi);
return -R*dphi;
}
- public double dz_ddphi(double x, double xr, double yr, double d0, double phi0, double slope, double R) {
- return -R*slope*dtmpdphi_ddphi(x, xr, yr, d0, phi0, R);
+ public double dz_ddphi(double x, double xr, double yr, double d0, double phi0, double slope, double R, double phi) {
+ return -R*slope*dtmpdphi_ddphi(x, xr, yr, d0, phi0, R, phi);
}
- public double dz_dR(double x, double xr, double yr, double d0, double phi0, double slope, double R) {
- double dphi = get_dphi(x,xr,yr,d0,phi0,R);
- double derdphi_dR = dtmpdphi_dR(x,xr,yr,d0,phi0,R);
+ public double dz_dR(double x, double xr, double yr, double d0, double phi0, double slope, double R, double phi) {
+ double dphi = get_dphi(x,xr,yr,d0,phi0,R,phi);
+ double derdphi_dR = dtmpdphi_dR(x,xr,yr,d0,phi0,R,phi);
return -slope*( dphi + R*derdphi_dR);
}
@@ -281,9 +284,9 @@
- public double get_dphi(double x, double xr, double yr, double d0, double phi0, double R) {
+ public double get_dphi(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
//Takes into account that phi=[-pi,pi] by checking where the points (x0,y0) and (x,y) are
- double dphi = tmpdphi(x,xr,yr,d0,phi0,R);
+ double dphi = tmpdphi(x,xr,yr,d0,phi0,R,phi);
dphi = dphi > Math.PI ? dphi - 2*Math.PI : dphi < -Math.PI ? dphi + 2*Math.PI : dphi;
return dphi;
}
@@ -294,10 +297,10 @@
//Generic point y on circle/helix
- public double y(double x, double xr, double yr, double d0, double phi0, double R) {
+ public double y(double x, double xr, double yr, double d0, double phi0, double R,double phi) {
//double phi_angle = phi(x, xr, yr, d0, phi0, R);
- //double value = yc(yr,d0,phi0,R) + R*Math.cos(phi);
- double value = yolddangerous(x, xr, yr, d0, phi0, R);
+ double value = yc(yr,d0,phi0,R) + R*Math.cos(phi);
+ //double value = yolddangerous(x, xr, yr, d0, phi0, R);
/*
double ydanger = yolddangerous(x, xr, yr, d0, phi0, R);
if(value!=ydanger) {
@@ -346,8 +349,8 @@
// distance between generic point x and center of circle/helix => x-xc
// FIX THE NAME SO THAT THIS IS deltaxc ->MAKES MORE SENSE
- public double deltayc(double x, double xr, double yr, double d0,double phi0, double R) {
- return Math.sqrt( R*R - Math.pow(y(x,xr,yr,d0,phi0,R) - yc(yr,d0,phi0,R),2) );
+ public double deltayc(double x, double xr, double yr, double d0,double phi0, double R,double phi) {
+ return Math.sqrt( R*R - Math.pow(y(x,xr,yr,d0,phi0,R,phi) - yc(yr,d0,phi0,R),2) );
}
// derivate of deltayc
@@ -389,24 +392,24 @@
}
// Azimuthal angle for generic point - used in dphi calculation
- public double phi2(double x, double xr, double yr, double d0, double phi0, double R) {
- return Math.atan2( x - xc(xr,d0,phi0,R) , y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R) );
+ public double phi2(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
+ return Math.atan2( x - xc(xr,d0,phi0,R) , y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R) );
}
// delta phi between point on helix (x,y) and point of closest approach (x0,y0)
- public double tmpdphi(double x, double xr, double yr, double d0, double phi0, double R) {
- return phi2(x,xr,yr,d0,phi0,R) - phi1(xr,yr,d0,phi0,R);
+ public double tmpdphi(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
+ return phi2(x,xr,yr,d0,phi0,R,phi) - phi1(xr,yr,d0,phi0,R);
}
// derivative of delta phi between point on helix (x,y) and point of closest approach (x0,y0)
- public double baddtmpdphi_dR(double x, double xr, double yr, double d0, double phi0, double R) {
+ public double baddtmpdphi_dR(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
// this calculation has been large "simplified" from the original by using x, x0, xc, y, y0, yc
double term1 = ((yc(yr,d0,phi0,R) - y0(yr,d0,phi0))*Math.sin(phi0) - (x0(xr,d0,phi0) - xc(xr,d0,phi0,R))*Math.cos(phi0) ) / (R*R);
- double num = Math.sin(phi0)*Math.pow(y(x, xr, yr, d0, phi0, R) - y0(yr,d0,phi0),2) + ( x - xc(xr,d0,phi0,R))*( R + Math.sin(phi0)*(x-xc(xr,d0,phi0,R)) + Math.pow(y(x, xr, yr, d0, phi0, R)-y0(yr,d0,phi0),2) );
+ double num = Math.sin(phi0)*Math.pow(y(x, xr, yr, d0, phi0, R, phi) - y0(yr,d0,phi0),2) + ( x - xc(xr,d0,phi0,R))*( R + Math.sin(phi0)*(x-xc(xr,d0,phi0,R)) + Math.pow(y(x, xr, yr, d0, phi0, R, phi)-y0(yr,d0,phi0),2) );
- double den = (y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R))*Math.pow(x-xc(xr,d0,phi0,R),2) + sign(R)*sign(R)*Math.pow(y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R),3);
+ double den = (y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R))*Math.pow(x-xc(xr,d0,phi0,R),2) + sign(R)*sign(R)*Math.pow(y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R),3);
double term2 = sign(R) * num/den;
@@ -414,10 +417,18 @@
}
- public double phi(double xint,double xr, double yr, double d0, double phi0, double R) {
- double arg1 = Math.sin(phi0) - (xint-x0(xr,d0,phi0))/R;
- double arg2 = Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R)-y0(yr,d0,phi0))/R;
- double p = Math.atan2( arg1,arg2);
+ //public double phi(double xint,double xr, double yr, double d0, double phi0, double R) {
+
+ //s = -dphi/C=-R*dphi=-R*(phi-phi0)
+ //phi = -s/R+phi0
+ //=>(z-z0)/slope = -R*(phi-phi0)
+ //=>phi = (z-z0)/(slope*-R)+phi0
+ //double z_pos = 0.0;
+ //double p = z_pos
+
+ //double arg1 = Math.sin(phi0) - (xint-x0(xr,d0,phi0))/R;
+ //double arg2 = Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R)-y0(yr,d0,phi0))/R;
+ //double p = Math.atan2( arg1,arg2);
// double arg1_2 = R*Math.sin(phi0) + (x0(xr,d0,phi0)-xint);
// double arg2_2 = R*Math.cos(phi0) + (y(xint,xr,yr,d0,phi0,R)-y0(yr,d0,phi0));
@@ -455,16 +466,16 @@
*/
- return p;
- }
+ //return p;
+ //}
// derivative of delta phi between point on helix (x,y) and point of closest approach (x0,y0)
- public double dtmpdphi_dR(double x, double xr, double yr, double d0, double phi0, double R) {
+ public double dtmpdphi_dR(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
// this calculation has been large "simplified" from the original by using x, x0, xc, y, y0, yc
//double num = R*sign(R)*(x-x0(xr,d0,phi0));
//double den = (yc(yr,d0,phi0,R) - y0(yr,d0,phi0))*(2*(x-xc(xr,d0,phi0,R))-R*R);
double num = -R*sign(R)*(x-x0(xr,d0,phi0));//PHA 30/08/12 fixed
- double den = -(y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R))*(R*R); //PHA 30/08/12 fixed
+ double den = -(y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R))*(R*R); //PHA 30/08/12 fixed
return num/den;
@@ -484,23 +495,23 @@
// derivative of delta phi between point on helix (x,y) and point of closest approach (x0,y0)
- public double dtmpdphi_dd0(double x, double xr, double yr, double d0, double phi0, double R) {
+ public double dtmpdphi_dd0(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
- double num = sign(R)*Math.sin(phi0)*Math.pow(x - xc(xr,d0,phi0,R),2) + sign(R)*Math.sin(phi0)*Math.pow(y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R),2);
+ double num = sign(R)*Math.sin(phi0)*Math.pow(x - xc(xr,d0,phi0,R),2) + sign(R)*Math.sin(phi0)*Math.pow(y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R),2);
- double den = Math.pow(x-xc(xr,d0,phi0,R),2) + sign(R)*sign(R)*Math.pow( y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R),2);
+ double den = Math.pow(x-xc(xr,d0,phi0,R),2) + sign(R)*sign(R)*Math.pow( y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R),2);
- return -1/(y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R))*num/den;
+ return -1/(y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R))*num/den;
}
// derivative of delta phi between point on helix (x,y) and point of closest approach (x0,y0)
- public double dtmpdphi_ddphi(double x, double xr, double yr, double d0, double phi0, double R) {
+ public double dtmpdphi_ddphi(double x, double xr, double yr, double d0, double phi0, double R, double phi) {
double term1 = -(Math.pow(yc(yr,d0,phi0,R)-y0(yr,d0,phi0),2)+Math.pow(x0(xr,d0,phi0)-xc(xr,d0,phi0,R),2))/(R*R);
- double term2 = sign(R)*(yr-yc(yr,d0,phi0,R))/(y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R))*(R*R)/( Math.pow(x-xc(xr,d0,phi0,R),2) + sign(R)*sign(R)*Math.pow(y(x, xr, yr, d0, phi0, R) - yc(yr,d0,phi0,R),2) );
+ double term2 = sign(R)*(yr-yc(yr,d0,phi0,R))/(y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R))*(R*R)/( Math.pow(x-xc(xr,d0,phi0,R),2) + sign(R)*sign(R)*Math.pow(y(x, xr, yr, d0, phi0, R, phi) - yc(yr,d0,phi0,R),2) );
return term1 + term2;
@@ -513,6 +524,6 @@
//-------------------------------------------
-
+ private boolean _debug;
}
hps-java/src/main/java/org/lcsim/hps/users/phansson
diff -u -r1.7 -r1.8
--- MPAlignmentParameters.java 31 Aug 2012 02:49:46 -0000 1.7
+++ MPAlignmentParameters.java 4 Sep 2012 03:01:13 -0000 1.8
@@ -67,7 +67,7 @@
boolean _DEBUG=false;
double smax = 1e3;
ResLimit _resLimits = new ResLimit();
- AlignmentUtils _alignUtils = new AlignmentUtils();
+ AlignmentUtils _alignUtils = new AlignmentUtils(_DEBUG);
private AIDAFrame plotterFrame;
private AIDA aida = AIDA.defaultInstance();
@@ -331,7 +331,7 @@
//strip origin is defined in the tracking coordinate system (x=beamline)
double xint = strip.origin().x();
double s = HelixUtils.PathToXPlane(_trk, xint, smax, _nlc).get(0);
- double phi = s / R - phi0;
+ double phi = -s/R + phi0;
double[][] dfdq = new double[3][5];
//dx/dq
//these are wrong for X, but for now it doesn't matter
@@ -348,7 +348,7 @@
}
BasicMatrix dfdqGlobal = FillMatrix(dfdq, 3, 5);
- BasicMatrix dfdqGlobalNew = _alignUtils.calculateLocalHelixDerivatives(_trk, strip);
+ BasicMatrix dfdqGlobalNew = _alignUtils.calculateLocalHelixDerivatives(_trk, strip, smax, _nlc);
Hep3Matrix trkToStrip = getTrackToStripRotation(strip);
//_dfdq = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdqGlobal);
_dfdq = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdqGlobalNew);
@@ -374,18 +374,20 @@
double slope = _trk.slope();
- double xint = strip.origin().z();
+ double xint = strip.origin().x();
double xr = 0.0;
double yr = 0.0;
double d0 = _trk.dca();
double phi0 = _trk.phi0();
double R = _trk.R();
double z0 = _trk.z0();
+ double s = HelixUtils.PathToXPlane(_trk, xint, smax, _nlc).get(0);
+ double phi = -s/R + phi0;
if(_DEBUG) {
- System.out.println("Calculate global derivaties for this strip hit in layer " + strip.layer());
- System.out.println(" d0 z0 slope phi0 R xint");
- System.out.printf("Values %5.5f %5.5f %5.5f %5.5f %5.5f %5.5f\n", d0, z0, slope, phi0, R,xint);
+ System.out.println("Calculate global derivatives for this strip hit in layer " + strip.layer());
+ System.out.printf(" %10s%10s%10s%10s%10s%10s%10s\n","d0","z0","slope","phi0","R","xint","phi");
+ System.out.printf(" %10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f\n", d0, z0, slope, phi0, R,xint,phi);
}
@@ -432,22 +434,27 @@
BasicMatrix dfdpTRACK = new BasicMatrix(3,1);
dfdpTRACK.setElement(0, 0, _alignUtils.dx_dx());
- dfdpTRACK.setElement(1, 0, _alignUtils.dy_dx(xint,xr,yr,d0,phi0,R));
- dfdpTRACK.setElement(2, 0, _alignUtils.dz_dx(xint, xr, yr, d0, phi0, slope, R));
+ dfdpTRACK.setElement(1, 0, _alignUtils.dy_dx(xint,xr,yr,d0,phi0,R,phi));
+ dfdpTRACK.setElement(2, 0, _alignUtils.dz_dx(xint, xr, yr, d0, phi0, slope, R, phi));
//Put it into a matrix to be able to transform easily
//BasicMatrix _dfdpTRACK = FillMatrix(dfdpTRACK, 3, 1);
//Get transformation matrix from tracking frame to sensor frame where the residuals are calculated
Hep3Matrix trkToStrip = getTrackToStripRotation(strip);
+ if(_DEBUG) {
+ System.out.println("Final transformation from tracking frame to strip frame:\n" + trkToStrip.toString());
+ }
+
+
//Transform derivatives to sensor frame!
BasicMatrix dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdpTRACK);
//Add it to the global parameter object
- GlobalParameter gp = new GlobalParameter("Translation in x",side,layer,1000,100,true);
- gp.setDfDp(dfdp);
- _glp.add(gp);
+ GlobalParameter gp_tx = new GlobalParameter("Translation in x",side,layer,1000,100,true);
+ gp_tx.setDfDp(dfdp);
+ _glp.add(gp_tx);
if (_DEBUG) {
- gp.print();
+ gp_tx.print();
System.out.println("Track frame dfdp: " + dfdpTRACK);
//System.out.printf("dfdp = %5.5f %5.5f %5.5f GL%d name: %s\n", gp.dfdp(0), gp.dfdp(1), gp.dfdp(2), gp.getLabel(),gp.getName());
}
@@ -456,9 +463,9 @@
//****************************************************************************
//Calculate derivatives for a residual in x,y,z-direction for translation in y
- dfdpTRACK.setElement(0, 0, _alignUtils.dx_dy(xint,xr,yr,d0,phi0,R));
+ dfdpTRACK.setElement(0, 0, _alignUtils.dx_dy(xint,xr,yr,d0,phi0,R,phi));
dfdpTRACK.setElement(1, 0, _alignUtils.dy_dy());
- dfdpTRACK.setElement(2, 0, _alignUtils.dz_dy(xint, xr, d0, phi0, slope, R));
+ dfdpTRACK.setElement(2, 0, _alignUtils.dz_dy(xint, xr, d0, phi0, slope, R, phi));
//Put it into a matrix to be able to transform easily
@@ -466,11 +473,11 @@
//Transform derivatives to sensor frame!
dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdpTRACK);
//Add it to the global parameter object
- gp.setParameters("Translation in y",side,layer,1000,200,true);
- gp.setDfDp(dfdp);
- _glp.add(gp);
+ GlobalParameter gp_ty = new GlobalParameter("Translation in y",side,layer,1000,200,true);
+ gp_ty.setDfDp(dfdp);
+ _glp.add(gp_ty);
if (_DEBUG) {
- gp.print();
+ gp_ty.print();
System.out.println("Track frame dfdp: " + dfdpTRACK);
//System.out.printf("dfdp = %5.5f %5.5f %5.5f GL%d name: %s\n", gp.dfdp(0), gp.dfdp(1), gp.dfdp(2), gp.getLabel(),gp.getName());
}
@@ -478,8 +485,8 @@
//****************************************************************************
//Calculate derivatives for a residual in x,y,z-direction for translation in z
- dfdpTRACK.setElement(0, 0, _alignUtils.dx_dz(xint, xr, yr, d0, phi0, slope, R));
- dfdpTRACK.setElement(1, 0, _alignUtils.dy_dz(xint, xr, yr, d0, phi0, slope, R));
+ dfdpTRACK.setElement(0, 0, _alignUtils.dx_dz(xint, xr, yr, d0, phi0, slope, R, phi));
+ dfdpTRACK.setElement(1, 0, _alignUtils.dy_dz(xint, xr, yr, d0, phi0, slope, R, phi));
dfdpTRACK.setElement(2, 0, _alignUtils.dz_dz());
@@ -488,11 +495,11 @@
//Transform derivatives to sensor frame!
dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdpTRACK);
//Add it to the global parameter object
- gp.setParameters("Translation in z",side,layer,1000,300,true);
- gp.setDfDp(dfdp);
- _glp.add(gp);
+ GlobalParameter gp_tz = new GlobalParameter("Translation in z",side,layer,1000,300,true);
+ gp_tz.setDfDp(dfdp);
+ _glp.add(gp_tz);
if (_DEBUG) {
- gp.print();
+ gp_tz.print();
System.out.println("Track frame dfdp: " + dfdpTRACK);
//System.out.printf("dfdp = %5.5f %5.5f %5.5f GL%d name: %s\n", gp.dfdp(0), gp.dfdp(1), gp.dfdp(2), gp.getLabel(),gp.getName());
}
@@ -511,11 +518,11 @@
//Transform derivatives to sensor frame!
dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdpTRACK);
//Add it to the global parameter object
- gp.setParameters("Rotation alpha",side,layer,2000,100,true);
- gp.setDfDp(dfdp);
- _glp.add(gp);
+ GlobalParameter gp_ra = new GlobalParameter("Rotation alpha",side,layer,2000,100,true);
+ gp_ra.setDfDp(dfdp);
+ _glp.add(gp_ra);
if (_DEBUG) {
- gp.print();
+ gp_ra.print();
System.out.println("Track frame dfdp: " + dfdpTRACK);
//System.out.printf("dfdp = %5.5f %5.5f %5.5f GL%d name: %s\n", gp.dfdp(0), gp.dfdp(1), gp.dfdp(2), gp.getLabel(),gp.getName());
}
@@ -534,11 +541,11 @@
//Transform derivatives to sensor frame!
dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdpTRACK);
//Add it to the global parameter object
- gp.setParameters("Rotation beta",side,layer,2000,200,true);
- gp.setDfDp(dfdp);
- _glp.add(gp);
+ GlobalParameter gp_rb = new GlobalParameter("Rotation beta",side,layer,2000,200,true);
+ gp_rb.setDfDp(dfdp);
+ _glp.add(gp_rb);
if (_DEBUG) {
- gp.print();
+ gp_rb.print();
System.out.println("Track frame dfdp: " + dfdpTRACK);
//System.out.printf("dfdp = %5.5f %5.5f %5.5f GL%d name: %s\n", gp.dfdp(0), gp.dfdp(1), gp.dfdp(2), gp.getLabel(),gp.getName());
}
@@ -557,11 +564,11 @@
//Transform derivatives to sensor frame!
dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, dfdpTRACK);
//Add it to the global parameter object
- gp.setParameters("Rotation gamma",side,layer,2000,300,true);
- gp.setDfDp(dfdp);
- _glp.add(gp);
+ GlobalParameter gp_rg = new GlobalParameter("Rotation gamma",side,layer,2000,300,true);
+ gp_rg.setDfDp(dfdp);
+ _glp.add(gp_rg);
if (_DEBUG) {
- gp.print();
+ gp_rg.print();
System.out.println("Track frame dfdp: " + dfdpTRACK);
//System.out.printf("dfdp = %5.5f %5.5f %5.5f GL%d name: %s\n", gp.dfdp(0), gp.dfdp(1), gp.dfdp(2), gp.getLabel(),gp.getName());
}
@@ -688,9 +695,7 @@
double R = _trk.R();
double xint = strip.origin().x();
double s = HelixUtils.PathToXPlane(_trk, xint, smax, _nlc).get(0);
- //double phi = s / R - phi0;
- //corrected sign PHA
- double phi = phi0 - s / R ;
+ double phi = -s/R + phi0;
Hep3Vector trkpos = HelixUtils.PointOnHelix(_trk, s);
//System.out.println("trkpos = "+trkpos.toString());
@@ -721,13 +726,17 @@
if (_DEBUG) {
System.out.println("Strip Origin: ");
System.out.println(corigin.toString());
- System.out.println("Position on Track:");
+ System.out.println("Position on the track (tracking coordinates) at the strip:");
System.out.println(trkpos.toString());
+ System.out.println("Difference between the track position and strip origin (tracking coordinates) at the strip:");
+ System.out.println("vdiffTrk :");
+ System.out.println(vdiffTrk.toString());
+ System.out.println("Difference between the track position and strip origin (\"strip\" coordinates) at the strip:");
System.out.println("vdiff :");
System.out.println(vdiff.toString());
System.out.println("u :");
System.out.println(u.toString());
- System.out.println("umeas = " + umeas + "; umc = " + umc);
+ System.out.println("umeas = " + umeas + "; umc = " + umc + " ( prediction)");
System.out.println("udiff = " + _resid[0] + " +/- " + _error[0] + " ( uError=" + uError + ", msuError=" + msuError + ")");
System.out.println("MS: drdphi=" + msdrdphi + ", dz=" + msdz);
System.out.println("MS: phi=" + phi + " => msvec=" + mserr.toString());