hps-java/src/main/java/org/lcsim/hps/users/phansson
diff -u -r1.15 -r1.16
--- MPAlignmentParameters.java 24 Oct 2012 06:47:54 -0000 1.15
+++ MPAlignmentParameters.java 1 Nov 2012 15:42:34 -0000 1.16
@@ -123,6 +123,8 @@
public void setDebug(boolean debug) {
this._DEBUG = debug;
+ _alignUtils.setDebug(debug);
+ _numDerivatives.setDebug(debug);
}
public void setUniformZFieldStrength(double bfield) {
@@ -234,24 +236,22 @@
private void CalculateGlobalDerivatives(HelicalTrackStrip strip) {
//Find interception with plane that the strips belongs to
- Hep3Vector trkpos = trackUtil.calculateIterativeHelixInterceptXPlane(_trk, strip, Math.abs(this._bfield.z()));
+ Hep3Vector x_vec = trackUtil.calculateIterativeHelixInterceptXPlane(_trk, strip, Math.abs(this._bfield.z()));
- if(Double.isNaN(trkpos.x())) {
- System.out.printf("%s: error this trkpos is wrong %s\n",this.getClass().getSimpleName(),trkpos.toString());
+ if(Double.isNaN(x_vec.x())) {
+ System.out.printf("%s: error this trkpos is wrong %s\n",this.getClass().getSimpleName(),x_vec.toString());
System.out.printf("%s: origin %s trk \n%s\n",this.getClass().getSimpleName(),strip.origin(),_trk.toString());
- trkpos = trackUtil.calculateIterativeHelixInterceptXPlane(_trk, strip, Math.abs(this._bfield.z()),true);
+ x_vec = trackUtil.calculateIterativeHelixInterceptXPlane(_trk, strip, Math.abs(this._bfield.z()),true);
System.exit(1);
}
-
double slope = _trk.slope();
- double xint = trkpos.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, 0, 0).get(0);
+ double s = HelixUtils.PathToXPlane(_trk, x_vec.x(), 0, 0).get(0);
double phi = -s/R + phi0;
double umeas = strip.umeas();
Hep3Vector corigin = strip.origin();
@@ -263,7 +263,7 @@
System.out.printf("%s: --- Calculate global derivatives ---\n",this.getClass().getSimpleName());
System.out.printf("%s: Side %d, layer %d, strip origin %s\n",this.getClass().getSimpleName(),side,layer,corigin.toString());
System.out.printf("%s: %10s%10s%10s%10s%10s%10s%10s%10s%10s\n",this.getClass().getSimpleName(),"d0","z0","slope","phi0","R","xint","phi", "xint","s");
- System.out.printf("%s: %10.4f%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f\n",this.getClass().getSimpleName(), d0, z0, slope, phi0, R,xint,phi,xint,s);
+ System.out.printf("%s: %10.4f%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f\n",this.getClass().getSimpleName(), d0, z0, slope, phi0, R,x_vec.x(),phi,x_vec.x(),s);
}
//1st index = alignment parameter (only u so far)
@@ -282,248 +282,186 @@
// [Layer]
// 1-10
-
- //go through all the global parameters defined and calculate dfdp
-
- //The global derivatives is done in the tracking frame
- //This means that after they are calculated I need to transform them
- //into the sensor frame because that is where the residuals are calculated
-
-
-
+
//Rotation matrix from the tracking fram to the sensor/strip frame
Hep3Matrix T = trackerHitUtil.getTrackToStripRotation(strip);
- //Derivatives of the rotation matrix deltaR' w.r.t. rotations a,b,c around axis x,y,z
- Hep3Matrix ddeltaRprime_da = new BasicHep3Matrix(0,0,0,0,0,1,0,-1,0);
- Hep3Matrix ddeltaRprime_db = new BasicHep3Matrix(0,0,-1,0,0,0,1,0,0);
- Hep3Matrix ddeltaRprime_dc = new BasicHep3Matrix(0,1,0,-1,0,0,0,0,0);
-
- if(_DEBUG) {
- System.out.printf("%s: Rotation matrx from tracking/global to local frame T:\n %s\n",this.getClass().getSimpleName(),T.toString());
- System.out.printf("%s: Derivatives of the rotation matrix deltaR' w.r.t. rotation a,b,c around x,y,z axis:\n",this.getClass().getSimpleName());
- System.out.printf("%s: ddeltaRprime_da:\n %s\n",this.getClass().getSimpleName(),ddeltaRprime_da.toString());
- System.out.printf("%s: ddeltaRprime_db:\n %s\n",this.getClass().getSimpleName(),ddeltaRprime_db.toString());
- System.out.printf("%s: ddeltaRprime_dc:\n %s\n",this.getClass().getSimpleName(),ddeltaRprime_dc.toString());
- }
+
+ /*
+ * Calculate jacobian da/db
+ */
-
+ BasicMatrix da_db = this._alignUtils.calculateJacobian(x_vec,T);
- //****************************************************************************
- //Calculate jacobian da/db
-
- // Upper left 3x3
- Hep3Vector deltaX_gl = new BasicHep3Vector(1,0,0);
- Hep3Vector deltaY_gl = new BasicHep3Vector(0,1,0);
- Hep3Vector deltaZ_gl = new BasicHep3Vector(0,0,1);
- Hep3Vector dq_dx = VecOp.mult(T, deltaX_gl);
- Hep3Vector dq_dy = VecOp.mult(T, deltaY_gl);
- Hep3Vector dq_dz = VecOp.mult(T, deltaZ_gl);
if(_DEBUG) {
- System.out.printf("%s: - Upper left 3x3 of Jacobian da/db: dq_dx,dq_dy,dq_dz\n",this.getClass().getSimpleName());
- System.out.printf("%s: dq_dx: %s\n",this.getClass().getSimpleName(),dq_dx.toString());
- System.out.printf("%s: dq_dy: %s\n",this.getClass().getSimpleName(),dq_dy.toString());
- System.out.printf("%s: dq_dz: %s\n",this.getClass().getSimpleName(),dq_dz.toString());
+ this._alignUtils.printJacobianInfo(da_db);
}
-
-
- if(_DEBUG) {
- System.out.printf("%s: - Upper right 3x3 of Jacobian da/db: dq_dx,dq_dy,dq_dz\n",this.getClass().getSimpleName());
- }
- // Upper right 3x3
- Hep3Vector x_vec = trkpos; //position around where the small rotation happens
- Hep3Vector x_vec_tmp = VecOp.mult(ddeltaRprime_da, x_vec); // derivative of the position
- Hep3Vector x_vec_tmp2 = VecOp.sub(x_vec_tmp, x_vec); // subtract position
- Hep3Vector dq_da = VecOp.mult(T,x_vec_tmp2); //rotated into local frame
+ /*
+ * Invert the Jacobian
+ */
- if(_DEBUG) {
- System.out.printf("%s: position %s rotation derivative w.r.t. a ddeltaR'/da %s\n",this.getClass().getSimpleName(),x_vec.toString(),x_vec_tmp.toString());
- System.out.printf("%s: subtracted %s and rotated to local %s \n",this.getClass().getSimpleName(),x_vec_tmp2.toString(),dq_da.toString());
- }
+ BasicMatrix db_da = (BasicMatrix) MatrixOp.inverse(da_db);
- x_vec_tmp = VecOp.mult(ddeltaRprime_db, x_vec);
- x_vec_tmp2 = VecOp.sub(x_vec_tmp, x_vec);
- Hep3Vector dq_db = VecOp.mult(T,x_vec_tmp2);
+
if(_DEBUG) {
- System.out.printf("%s: position %s rotation derivative w.r.t. a ddeltaR'/db %s\n",this.getClass().getSimpleName(),x_vec.toString(),x_vec_tmp.toString());
- System.out.printf("%s: subtracted %s and rotated to local %s \n",this.getClass().getSimpleName(),x_vec_tmp2.toString(),dq_db.toString());
+ System.out.printf("%s: Invert the Jacobian. We get da_db^-1=db_da: \n%s \n",this.getClass().getSimpleName(),db_da.toString());
+ BasicMatrix prod = (BasicMatrix) MatrixOp.mult(db_da,da_db);
+ System.out.printf("%s: Check the inversion i.e. db_da*da_db: \n%s \n",this.getClass().getSimpleName(),prod.toString());
}
-
- x_vec_tmp = VecOp.mult(ddeltaRprime_dc, x_vec);
- x_vec_tmp2 = VecOp.sub(x_vec_tmp, x_vec);
- Hep3Vector dq_dc = VecOp.mult(T,x_vec_tmp2);
- if(_DEBUG) {
- System.out.printf("%s: position %s rotation derivative w.r.t. a ddeltaR'/dc %s\n",this.getClass().getSimpleName(),x_vec.toString(),x_vec_tmp.toString());
- System.out.printf("%s: subtracted %s and rotated to local %s \n",this.getClass().getSimpleName(),x_vec_tmp2.toString(),dq_dc.toString());
- }
+
+ /*
+ * Calculate global derivative of the residual dz/db = dq_a^gl/db-dq_p^gl/db
+ * dq_a^gl is the alignment corrected position in the global tracking frame
+ * dq_p^gl_db is the predicted hit position (from the track model) in the global/tracking frame
+ *
+ */
+
+
+
+ //****************************************************************************
+ // First term in dz/db
+
+ //3x6 matrix
+ BasicMatrix dq_agl_db = _alignUtils.calculateGlobalHitPositionDers(x_vec);
+
-
if(_DEBUG) {
- System.out.printf("%s: Summary:\n",this.getClass().getSimpleName());
- System.out.printf("%s: dq_da: %s\n",this.getClass().getSimpleName(),dq_da.toString());
- System.out.printf("%s: dq_db: %s\n",this.getClass().getSimpleName(),dq_db.toString());
- System.out.printf("%s: dq_dc: %s\n",this.getClass().getSimpleName(),dq_dc.toString());
+ _alignUtils.printGlobalHitPositionDers(dq_agl_db);
}
-
- // Lower left 3x3
- //deltaR = (alpha,beta,gamma) the rotation alignment parameters in the local frame
- Hep3Vector ddeltaR_dx = new BasicHep3Vector(0,0,0);
- Hep3Vector ddeltaR_dy = new BasicHep3Vector(0,0,0);
- Hep3Vector ddeltaR_dz = new BasicHep3Vector(0,0,0);
+ /*
+ * Second term in dz/db
+ * dq_p^gl_db is the predicted hit position (from the track model) in the global/tracking frame
+ *
+ */
+
+ //3x6 matrix
+ BasicMatrix dq_pgl_db = _alignUtils.calculateGlobalPredictedHitPositionDers(_trk,x_vec);
-
if(_DEBUG) {
- System.out.printf("%s: - Lower left 3x3 of Jacobian ddeltaR/d(x,y,z): dDeltaR_dx,dDeltaR_dy,dDeltaR_dz\n",this.getClass().getSimpleName());
- System.out.printf("%s: ddeltaR_dx: %s\n",this.getClass().getSimpleName(),ddeltaR_dx.toString());
- System.out.printf("%s: ddeltaR_dy: %s\n",this.getClass().getSimpleName(),ddeltaR_dy.toString());
- System.out.printf("%s: ddeltaR_dz: %s\n",this.getClass().getSimpleName(),ddeltaR_dz.toString());
- }
-
+ _alignUtils.printGlobalPredictedHitPositionDers(dq_pgl_db);
-
+ System.out.printf("%s: Cross-check using numerical derivatives for dq_pgl/db (numder)\n",this.getClass().getSimpleName());
- // Lower right 3x3
-/*
- //deltaR = (alpha,beta,gamma) the rotation alignment parameters in the local frame
- //Expressing T in Euler angles i,j,k
- double i = 0;
- double j = 0;
- double k = 0;
- double dalpha_da = Math.cos(k)*Math.sin(i)*Math.sin(j) + Math.cos(i)*Math.sin(k);
- double dbeta_da = Math.cos(i)*Math.cos(k) - Math.sin(i)*Math.sin(j)*Math.sin(k);
- double dgamma_da = -Math.cos(j)*Math.sin(i);
- double dalpha_db = -Math.cos(i)*Math.cos(k)*Math.sin(j) + Math.sin(i)*Math.sin(k);
- double dbeta_db = Math.cos(k)*Math.sin(i) + Math.cos(i)*Math.sin(j)*Math.sin(k);
- double dgamma_db = Math.cos(i)*Math.cos(j);
- double dalpha_dc = -Math.cos(i)*Math.cos(k)*Math.sin(j) + Math.sin(i)*Math.sin(k);
- double dbeta_dc = Math.cos(k)*Math.sin(i) + Math.cos(i)*Math.sin(j)*Math.sin(k);
- double dgamma_dc = Math.sin(i)*Math.sin(j);
-
- Hep3Vector ddeltaR_da = new BasicHep3Vector(dalpha_da,dbeta_da,dgamma_da);
- Hep3Vector ddeltaR_db = new BasicHep3Vector(dalpha_db,dbeta_db,dgamma_db);
- Hep3Vector ddeltaR_dc = new BasicHep3Vector(dalpha_dc,dbeta_dc,dgamma_dc);
-*/
+ BasicMatrix dq_pgl_db_numder = this._numDerivatives.calculateGlobalPredictedHitPositionDers(_trk,x_vec);
+ _alignUtils.printGlobalPredictedHitPositionDers(dq_pgl_db_numder);
- if(_DEBUG) {
- System.out.printf("%s: - Lower right 3x3 of Jacobian ddeltaR/d(a,b,c): \n",this.getClass().getSimpleName());
- System.out.printf("%s: T: %s\n",this.getClass().getSimpleName(),T.toString());
}
+ /*
+ * Note that a shift in the position of the hit (q_agl) in in the
+ * y/z plane is equivalent of the shift of the position of the prediction hit q_pgl
+ * in the same plane. Thus we set these terms of the derivative to zero
+ *
+ */
+
+ dq_pgl_db.setElement(0, 0, 0);
+ dq_pgl_db.setElement(1, 1, 0);
+ dq_pgl_db.setElement(2, 2, 0);
- //Now fill the Jacobian 6x6 matrix
- BasicMatrix da_db = new BasicMatrix(6,6);
- //upper left 3x3
- da_db.setElement(0,0,dq_dx.x());
- da_db.setElement(1,0,dq_dx.y());
- da_db.setElement(2,0,dq_dx.z());
- da_db.setElement(0,1,dq_dy.x());
- da_db.setElement(1,1,dq_dy.y());
- da_db.setElement(2,1,dq_dy.z());
- da_db.setElement(0,2,dq_dz.x());
- da_db.setElement(1,2,dq_dz.y());
- da_db.setElement(2,2,dq_dz.z());
- //upper right 3x3
- da_db.setElement(0,3,dq_da.x());
- da_db.setElement(1,3,dq_da.y());
- da_db.setElement(2,3,dq_da.z());
- da_db.setElement(0,4,dq_db.x());
- da_db.setElement(1,4,dq_db.y());
- da_db.setElement(2,4,dq_db.z());
- da_db.setElement(0,5,dq_dc.x());
- da_db.setElement(1,5,dq_dc.y());
- da_db.setElement(2,5,dq_dc.z());
- //lower right 3x3
- da_db.setElement(3,3,T.e(0, 0));
- da_db.setElement(4,3,T.e(1, 0));
- da_db.setElement(5,3,T.e(2, 0));
- da_db.setElement(3,4,T.e(0, 1));
- da_db.setElement(4,4,T.e(1, 1));
- da_db.setElement(5,4,T.e(2, 1));
- da_db.setElement(3,5,T.e(0, 2));
- da_db.setElement(4,5,T.e(1, 2));
- da_db.setElement(5,5,T.e(2, 2));
-// da_db.setElement(4,3,ddeltaR_da.y());
-// da_db.setElement(5,3,ddeltaR_da.z());
-// da_db.setElement(3,4,ddeltaR_db.x());
-// da_db.setElement(4,4,ddeltaR_db.y());
-// da_db.setElement(5,4,ddeltaR_db.z());
-// da_db.setElement(3,5,ddeltaR_dc.x());
-// da_db.setElement(4,5,ddeltaR_dc.y());
-// da_db.setElement(5,5,ddeltaR_dc.z());
- //lower left 3x3
- da_db.setElement(3,0,ddeltaR_dx.x());
- da_db.setElement(4,0,ddeltaR_dx.y());
- da_db.setElement(5,0,ddeltaR_dx.z());
- da_db.setElement(3,1,ddeltaR_dy.x());
- da_db.setElement(4,1,ddeltaR_dy.y());
- da_db.setElement(5,1,ddeltaR_dy.z());
- da_db.setElement(3,2,ddeltaR_dz.x());
- da_db.setElement(4,2,ddeltaR_dz.y());
- da_db.setElement(5,2,ddeltaR_dz.z());
+ /*
+ * For the rotations in this global frame the rotation leads to a shift of the position
+ * of the predicted hit. Since angles are small this rotation is the same as the
+ * rotation of the hit position
+ */
- if(_DEBUG) {
- System.out.printf("%s: da_db:\n%s \n",this.getClass().getSimpleName(),da_db.toString());
- System.out.printf("%s: det(da_db) = %.3f \n",this.getClass().getSimpleName(),da_db.det());
- }
+ dq_pgl_db.setElement(0, 3, 0);
+ dq_pgl_db.setElement(1, 3, 0);
+ dq_pgl_db.setElement(2, 3, 0);
+ dq_pgl_db.setElement(0, 4, 0);
+ dq_pgl_db.setElement(1, 4, 0);
+ dq_pgl_db.setElement(2, 4, 0);
+ dq_pgl_db.setElement(0, 5, 0);
+ dq_pgl_db.setElement(1, 5, 0);
+ dq_pgl_db.setElement(2, 5, 0);
- BasicMatrix db_da = (BasicMatrix) MatrixOp.inverse(da_db);
- //db_da.invert();
-
+ if(_DEBUG) {
+ System.out.printf("%s: Fixing the predicted derivatives that are equivalent to the hit position derivatives. The result is below.\n",this.getClass().getSimpleName());
+ _alignUtils.printGlobalPredictedHitPositionDers(dq_pgl_db);
+ }
+ /*
+ * Putting them together i.e. subtract the predicted from the hit position derivative
+ */
+
+ //3x6 matrix
+ BasicMatrix dz_db = (BasicMatrix) MatrixOp.sub(dq_agl_db, dq_pgl_db);
+
+
if(_DEBUG) {
- System.out.printf("%s: db_da: \n%s \n",this.getClass().getSimpleName(),db_da.toString());
- BasicMatrix prod = (BasicMatrix) MatrixOp.mult(db_da,da_db);
- System.out.printf("%s: db_da*da_db: \n%s \n",this.getClass().getSimpleName(),prod.toString());
+ _alignUtils.printGlobalResidualDers(dz_db);
}
-
-
-
- if(1==1)
- return;
+ /*
+ * Convert the to the local frame using the Jacobian
+ */
+
+ //3x6 = 3x6*6x6 matrix
+ BasicMatrix dz_da = (BasicMatrix) MatrixOp.mult(dz_db, db_da);
+ if(_DEBUG) {
+ _alignUtils.printLocalResidualDers(dz_da);
+ }
+
+ if(_DEBUG) {
+ System.out.printf("%s: PELLE check manual one entry\n",this.getClass().getSimpleName());
+ double dx_dx = dz_db.e(0, 0);
+ double dx_dy = dz_db.e(0, 1);
+ double dx_dz = dz_db.e(0, 2);
+ double dx_da = dz_db.e(0, 3);
+ double dx_db = dz_db.e(0, 4);
+ double dx_dc = dz_db.e(0, 5);
+ double dx_du = db_da.e(0, 0);
+ double dy_du = db_da.e(1, 0);
+ double dz_du = db_da.e(2, 0);
+ double da_du = db_da.e(3, 0);
+ double db_du = db_da.e(4, 0);
+ double dc_du = db_da.e(5, 0);
+ System.out.printf("%s: dx_dx*dx_du = %.3f ",this.getClass().getSimpleName(),dx_dx*dx_du);
+ System.out.printf(" dx_dy*dy_du = %.3f ",dx_dy*dy_du);
+ System.out.printf(" dx_dz*dz_du = %.3f (=%.3f*%.3f)\n",dx_dz*dz_du,dx_dz,dz_du);
+ System.out.printf("%s: dx_da*da_du = %.3f ",this.getClass().getSimpleName(),dx_da*da_du);
+ System.out.printf(" dx_db*db_du = %.3f ",dx_db*db_du);
+ System.out.printf(" dx_dc*dc_du = %.3f \n",dx_dc*dc_du);
+
+ double du_du = dx_dx*dx_du + dx_dy*dy_du + dx_dz*dz_du + dx_da*da_du + dx_db*db_du + dx_dc*dc_du;
+ System.out.printf("%s: du_du = %.3f comapred to %.3f \n",this.getClass().getSimpleName(),du_du,dz_da.e(0, 0));
+ }
+
- //****************************************************************************
- // Calcualte the global derivatives in the global frame dz/db
- // where z is the residual in the global frame and b are the alignment
- // parameters in the global frame
+ if(1==1) return;
+
//Flag to tell if this hit is affected by the given global parameter
boolean useGL = false;
//Clear the old parameter list
_glp.clear();
+
+
+
-
-
- //****************************************************************************
- //Derivatives of the predicted hit position qp for a translation of in x
-
BasicMatrix dqp_da_TRACK = new BasicMatrix(3,1);
- dqp_da_TRACK.setElement(0, 0, _alignUtils.dx_dx());
- dqp_da_TRACK.setElement(1, 0, _alignUtils.dy_dx(xint, d0, phi0, R, phi));
- dqp_da_TRACK.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 _dqp_da_TRACK = FillMatrix(dqp_da_TRACK, 3, 1);
@@ -548,7 +486,7 @@
//****************************************************************************
//Derivatives of the predicted hit position qp for a translation of in y
- double y = -(R-d0)*Math.cos(phi0) + _alignUtils.sign(R) *Math.sqrt(Math.pow(R, 2)-Math.pow(xint-(R-d0)*Math.sin(phi0), 2));
+ double y = -(R-d0)*Math.cos(phi0) + _alignUtils.sign(R) *Math.sqrt(Math.pow(R, 2)-Math.pow(x_vec.x()-(R-d0)*Math.sin(phi0), 2));
dqp_da_TRACK.setElement(0, 0, _alignUtils.dx_dy(y, d0, phi0, R, phi));
dqp_da_TRACK.setElement(1, 0, _alignUtils.dy_dy());
dqp_da_TRACK.setElement(2, 0, _alignUtils.dz_dy(y, d0, phi0, slope, R, phi));
@@ -591,56 +529,7 @@
}
- //I need to convert the dqp/da in the global frame to dqp_da in the sensor fram
-
- //place holders
- double dup_dw = 0;
- double dvp_dw = 0;
- double um = umeas;
- double vm = vmeas; //should always be zero, I think
-
- BasicMatrix dres_ddu = new BasicMatrix(3,1);
- dres_ddu.setElement(0, 0, 1);
- dres_ddu.setElement(1, 0, 0);
- dres_ddu.setElement(2, 0, 0);
- BasicMatrix dres_ddv = new BasicMatrix(3,1);
- dres_ddv.setElement(0, 0, 0);
- dres_ddv.setElement(1, 0, 1);
- dres_ddv.setElement(2, 0, 0);
- BasicMatrix dres_ddw = new BasicMatrix(3,1);
- dres_ddw.setElement(0, 0, -dup_dw);
- dres_ddw.setElement(1, 0, -dvp_dw);
- dres_ddw.setElement(2, 0, 0);
- BasicMatrix dres_dalpha = new BasicMatrix(3,1);
- dres_dalpha.setElement(0, 0, vm*dup_dw);
- dres_dalpha.setElement(1, 0, vm*dvp_dw);
- dres_dalpha.setElement(2, 0, 0);
- BasicMatrix dres_dbeta = new BasicMatrix(3,1);
- dres_dbeta.setElement(0, 0, -um*dup_dw);
- dres_dbeta.setElement(1, 0, -um*dvp_dw);
- dres_dbeta.setElement(2, 0, 0);
- BasicMatrix dres_dgamma = new BasicMatrix(3,1);
- dres_dgamma.setElement(0, 0, vm);
- dres_dgamma.setElement(1, 0, -um);
- dres_dgamma.setElement(2, 0, 0);
-
- //compact version
- BasicMatrix dres_da = new BasicMatrix(3,6);
- for(int icol=0;icol<6;++icol) {
- for(int irow=0;irow<3;++irow) {
- if(icol==0) dres_da.setElement(irow, icol, dres_ddu.e(irow, 0));
- if(icol==1) dres_da.setElement(irow, icol, dres_ddv.e(irow, 0));
- if(icol==2) dres_da.setElement(irow, icol, dres_ddw.e(irow, 0));
- if(icol==3) dres_da.setElement(irow, icol, dres_dalpha.e(irow, 0));
- if(icol==4) dres_da.setElement(irow, icol, dres_dbeta.e(irow, 0));
- if(icol==5) dres_da.setElement(irow, icol, dres_dgamma.e(irow, 0));
- }
- }
-
-
-
-
-
+
@@ -804,7 +693,7 @@
aida.profile1D("res_u_vs_ydiff_layer_" + strip.layer() + "_" + side).fill(vdiffTrk.y(),_resid[0]);
if (_DEBUG) {
- System.out.printf("%s: ---- CalculateResidual ----\n",this.getClass().getSimpleName());
+ System.out.printf("%s: CalculateResidual Result ----\n",this.getClass().getSimpleName());
System.out.printf("%s: Strip Origin: %s\n",this.getClass().getSimpleName(),corigin.toString());
System.out.printf("%s: Position on the track (tracking coordinates) at the strip: %s\n",this.getClass().getSimpleName(),trkpos.toString());
System.out.printf("%s: vdiffTrk %s\n",this.getClass().getSimpleName(),vdiffTrk.toString());
@@ -864,23 +753,23 @@
private void PrintStripResiduals(HelicalTrackStrip strip) {
if (_DEBUG) {
- System.out.println(this.getClass().getSimpleName() + ": --- PrintStripResiduals ---");
+ System.out.printf("%s: --- Alignment Results for this Strip ---",this.getClass().getSimpleName());
String side = SvtUtils.getInstance().isTopLayer((SiSensor) ((RawTrackerHit)strip.rawhits().get(0)).getDetectorElement()) ? "top" : "bottom";
System.out.printf("%s: Strip layer %4d in %s at origin %s\n",this.getClass().getSimpleName(), strip.layer(), side, strip.origin().toString());
- System.out.printf("Residuals (u,v,w) : %5.5e %5.5e %5.5e\n", _resid[0], _resid[1], _resid[2]);
- System.out.printf("Errors (u,v,w) : %5.5e %5.5e %5.5e\n", _error[0], _error[1], _error[2]);
+ System.out.printf("%s: Residuals (u,v,w) : %5.5e %5.5e %5.5e\n",this.getClass().getSimpleName(), _resid[0], _resid[1], _resid[2]);
+ System.out.printf("%s: Errors (u,v,w) : %5.5e %5.5e %5.5e\n",this.getClass().getSimpleName(), _error[0], _error[1], _error[2]);
String[] q = {"d0", "z0", "slope", "phi0", "R"};
- System.out.println("track parameter derivatives");
+ System.out.printf("%s: track parameter derivatives:\n",this.getClass().getSimpleName());
for (int i = 0; i < _nTrackParameters; i++) {
- System.out.printf("%s %5.5e %5.5e %5.5e\n", q[i], _dfdq.e(0, i), _dfdq.e(1, i), _dfdq.e(2, i));
+ System.out.printf("%s: %s %5.5e %5.5e %5.5e\n",this.getClass().getSimpleName(), q[i], _dfdq.e(0, i), _dfdq.e(1, i), _dfdq.e(2, i));
}
//String[] p = {"u-displacement"};
- System.out.println("global parameter derivatives");
+ System.out.printf("%s: Global parameter derivatives\n",this.getClass().getSimpleName());
for (GlobalParameter gl : _glp) {
- System.out.printf("%s %5.5e %5.5e %5.5e %5d %10s\n", "", gl.dfdp(0), gl.dfdp(1), gl.dfdp(2), gl.getLabel(),gl.getName());
+ System.out.printf("%s: %s %5.5e %5.5e %5.5e %5d %10s\n",this.getClass().getSimpleName(), "", gl.dfdp(0), gl.dfdp(1), gl.dfdp(2), gl.getLabel(),gl.getName());
//System.out.printf("%s %5.5e %5.5e %5.5e %5d\n", p[j], _dfdp.e(0, j), _dfdp.e(1, j), _dfdp.e(2, j), _globalLabel[j]);
}
- System.out.println(this.getClass().getSimpleName() + ": --- END PrintStripResiduals ---");
+ System.out.printf("%s: --- Alignment Results for this Strip ---\n",this.getClass().getSimpleName());
}
pWriter.printf("%d\n", strip.layer());
// Loop over the three directions u,v,w and print residuals and derivatives