Commit in hps-java/src/main/java/org/lcsim/hps/users/phansson on MAIN
GlobalParameter.java+20-11.1 -> 1.2
AlignmentUtils.java+110-71.3 -> 1.4
MPAlignmentParameters.java+278-1231.6 -> 1.7
+408-131
3 modified files
Added global ders, fixed bug(?) in dphi calc, removed parameter list.

hps-java/src/main/java/org/lcsim/hps/users/phansson
GlobalParameter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- GlobalParameter.java	24 May 2012 01:30:31 -0000	1.1
+++ GlobalParameter.java	31 Aug 2012 02:49:46 -0000	1.2
@@ -32,7 +32,26 @@
         _active = active;
     
     }
-    
+
+    public void setParameters(String name,int side,int layer,int type,int direction,boolean active) {
+        clear();
+        _name = name;
+        _side = side;
+        _layer = layer;
+        _type = type;
+        _direction = direction;
+        _active = active;
+    }
+
+    public void clear() {
+        _name = "";
+        _side = -1;
+        _layer = -1;
+        _type = -1;
+        _direction = -1;
+        _active = false;
+        _dfdp=null;
+    }
     
     public void setDfDp(BasicMatrix mat) {
         _dfdp = mat;

hps-java/src/main/java/org/lcsim/hps/users/phansson
AlignmentUtils.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- AlignmentUtils.java	29 Aug 2012 02:06:22 -0000	1.3
+++ AlignmentUtils.java	31 Aug 2012 02:49:46 -0000	1.4
@@ -72,6 +72,109 @@
     
     
     
+    //-----------------------------------
+    // Derivatives for translation
+    
+    public double dx_dx() {
+        return 1;
+    }
+    
+    public double dy_dx(double xint, double xr, double yr ,double d0, double phi0, double R) {
+        return -1*sign(R)*(xint-xc(xr,d0,phi0,R))/(y(xint,xr,yr,d0,phi0,R) - yc(yr,d0,phi0,R));
+    }
+    
+    
+    public double dz_dx(double xint, double xr,double yr,double d0, double phi0, double slope, double R) {   
+        return -slope*(y(xint,xr,yr,d0,phi0,R) - yc(yr,d0,phi0,R))/R;
+    }
+    
+    public double dx_dy(double xint, double xr, double yr ,double d0, double phi0, double R) {
+        double d = -sign(R)*(y(xint,xr,yr,d0,phi0,R) - yc(yr,d0,phi0,R))/(xint-xc(xr,d0,phi0,R)); 
+        System.out.println("dx_dy: y=" + y(xint,xr,yr,d0,phi0,R) + ", yc=" + yc(yr,d0,phi0,R));
+        System.out.println("dx_dy: xint=" + xint + ", xc=" + xc(xr,d0,phi0,R));
+        System.out.println("dx_dy: sign(R)=" + sign(R));
+        System.out.println(" ===> " + d);
+        return d;
+    }
+    
+    public double dy_dy() {
+        return 1;
+    }
+    
+    public double dz_dy(double xint, double xr ,double d0, double phi0, double slope, double R) {
+        return slope*(xint-xc(xr,d0,phi0,R))/R;
+    }
+
+    public double dx_dz(double xint, double xr, double yr ,double d0, double phi0, double slope, double R) {
+        double A = Math.atan2(x0(xr,d0,phi0)-xc(xr,d0,phi0,R),y0(yr,d0,phi0)-yc(yr,d0,phi0,R));
+        double dphi = tmpdphi(xint,xr,yr,d0,phi0,R);
+        return -1/(R*slope)*(y(xint,xr,yr,d0,phi0,R) - yc(yr,d0,phi0,R))*(1 + Math.pow(Math.tan(dphi+A),2));
+    }
+    
+    public double dy_dz(double xint, double xr, double yr ,double d0, double phi0, double slope, double R) {
+        double A = phi1(xr,yr,d0,phi0,R);
+        double dphi = tmpdphi(xint,xr,yr,d0,phi0,R);
+        double d = 1/(R*slope)*(xint-xc(xr,d0,phi0,R))*(1 + 1/(Math.pow(Math.tan(dphi+A),2)));
+        System.out.println("dy_dz: y0=" + y0(yr,d0,phi0) + ", yc=" + yc(yr,d0,phi0,R));
+        System.out.println("dy_dz: x0=" + x0(xr,d0,phi0) + ", xc=" + xc(xr,d0,phi0,R));
+        System.out.println("dy_dz: dphi="+dphi+", A="+A+", tan(dphi+A)="+Math.tan(dphi+A));
+        System.out.print(" ===> " + d);
+        return d;
+    }
+    
+    public double dz_dz() {
+        return 1;
+    }
+    
+    
+     //-----------------------------------
+    // Derivatives for rotation
+    // alpha - rotation around x (beamline direction)
+    // beta - rotation around y (bend direction)
+    // gammaa - rotation around z (non-bend direction)
+    
+    public double dx_dalpha() {
+        return 0;
+    }
+    public double dy_dalpha() {
+        return -1;
+    }
+    public double dz_dalpha() {
+        return 1;
+    }
+    
+    public double dx_dbeta() {
+        return 1;
+    }
+    public double dy_dbeta() {
+        return 0;
+    }
+    public double dz_dbeta() {
+        return -1;
+    }
+    
+    public double dx_dgamma() {
+        return -1;
+    }
+    public double dy_dgamma() {
+        return 1;
+    }
+    public double dz_dgamma() {
+        return 0;
+    }
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
     //d0,z0,slope,phi0,R
     
     
@@ -165,7 +268,7 @@
     //Helper functions
 
     
-
+    
     
     public double get_dphi(double x, double xr, double yr, double d0, double phi0, double R) {
         //Takes into account that phi=[-pi,pi] by checking where the points (x0,y0) and (x,y) are        
@@ -263,7 +366,7 @@
     
     // 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 phi1(xr,yr,d0,phi0,R)- phi2(x,xr,yr,d0,phi0,R);
+        return phi2(x,xr,yr,d0,phi0,R) - phi1(xr,yr,d0,phi0,R);
     }
     
     // derivative of delta phi between point on helix (x,y) and point of closest approach (x0,y0)
@@ -282,11 +385,11 @@
 
         // 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) {
-        // 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);
+        // 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
         
         return num/den;
         

hps-java/src/main/java/org/lcsim/hps/users/phansson
MPAlignmentParameters.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- MPAlignmentParameters.java	29 Aug 2012 02:06:22 -0000	1.6
+++ MPAlignmentParameters.java	31 Aug 2012 02:49:46 -0000	1.7
@@ -53,7 +53,7 @@
 
     private int _nlc = 5;  //the five track parameters
     private int _ngl = 1; //delta(u) and delta(gamma) for each plane
-    private GlobalParameters _globalParameterList;
+    //private GlobalParameters _globalParameterList;
     private List<GlobalParameter> _glp = new ArrayList<GlobalParameter>();
     private BasicMatrix _dfdq;
     //private BasicMatrix _dfdp;
@@ -102,8 +102,8 @@
             Logger.getLogger(RunAlignment.class.getName()).log(Level.SEVERE, null, ex);
         }
         
-        _globalParameterList = new GlobalParameters();
-        if(_DEBUG) _globalParameterList.print();
+        //_globalParameterList = new GlobalParameters();
+        //if(_DEBUG) _globalParameterList.print();
         
         
         
@@ -355,19 +355,13 @@
 
         if (_DEBUG) {
             double[] trackpars = {d0, z0, slope, phi0, R, s, xint};
+            System.out.println("             d0           z0           slope         phi0          R");
+            System.out.printf("Values       %5.5f    %5.5f     %5.5f      %5.5f      %5.5f\n", d0, z0, slope, phi0, R);
             System.out.println("Strip Origin: ");
             System.out.println(strip.origin());
-            System.out.println("trkToStrip Rotation:");
-            System.out.println(trkToStrip.toString());
-            printDerivatives(trackpars, dfdq);
-        //}
-            System.out.println("-----------------------------------------------------");
-            System.out.println("Compare local derivatives for strip at ");
-            System.out.println(strip.origin());
             System.out.println("s         xint");
             System.out.printf("%5.5f %5.5f\n", s, xint);
-            System.out.println("             d0           z0           slope         phi0          R");
-            System.out.printf("Values       %5.5f    %5.5f     %5.5f      %5.5f      %5.5f\n", d0, z0, slope, phi0, R);
+            System.out.println("Compare local derivatives ");
             System.out.println("dfdqGlobal:");
             System.out.println(dfdqGlobal.toString());
             System.out.println("dfdqGlobalNew:");
@@ -377,10 +371,26 @@
     }
 
     private void CalculateGlobalDerivatives(HelicalTrackStrip strip) {
+       
+        
+        double slope = _trk.slope();
+        double xint = strip.origin().z();
+        double xr = 0.0;
+        double yr = 0.0;
+        double d0 = _trk.dca();
+        double phi0 = _trk.phi0();
+        double R = _trk.R();
+        double z0 = _trk.z0();
+
         if(_DEBUG) {
-            System.out.println("Calculate global derivaties for this sensor hit in layer " + strip.layer());
+            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);
+            
         }
         
+
+        
         //1st index = alignment parameter (only u so far)
         //2nd index = residual coordinate (on du so far)
         //Naming scheme:
@@ -392,8 +402,8 @@
         // 2000 - rotation
         //[Direction] (tracker coord. frame)
         // 100 - x (beamline direction)
-        // 200 - y (non-measurement plane / bend plane)
-        // 300 - z (measurement direction)
+        // 200 - y (bend plane)
+        // 300 - z (non-bend direction)
         // [Layer]
         // 1-10
         
@@ -404,11 +414,7 @@
         //This means that after they are calculated I need to transform them 
         //into the sensor frame because that is where the residuals are calculated
         
-        double[][] dfdpTRACK = new double[3][1];
-        dfdpTRACK[0][0] = 0; //df/dx
-        dfdpTRACK[1][0] = 0; //df/dy
-        dfdpTRACK[2][0] = 0; //df/dz
-        
+       
         //Which half of the detecotor?
         int side = strip.origin().z()>0 ? 10000 : 20000;
         int layer = strip.layer();
@@ -419,105 +425,254 @@
         //Clear the old parameter list
         _glp.clear();
         
-        //Go through each global parameter and see if it has non-zero contribution
-        for (GlobalParameter gp : _globalParameterList.getList()) {
-            
-            
-            useGL = false;
-            
-            dfdpTRACK[0][0] = 0; 
-            dfdpTRACK[1][0] = 0; 
-            dfdpTRACK[2][0] = 0; 
-            
-            if(gp.getSide()==side) {
-                
-                
-                // correct side
-                if(gp.getLayer()==layer) {
-                    //correct layer
-                    
-                    //Calcuate dfdp derivatives depending on type of global parameter
-                    if(gp.getType()==1000) {
-                        
-                        //This residual is affected by a global parameter
-                        useGL = true;
-                        
-                        //translation
-                        if(gp.getDirection()==100) {
-                            //x - tracking frame --> beamline direction
-                            dfdpTRACK[0][0] = 1; //df/dx
-                            dfdpTRACK[1][0] = 0; //df/dy
-                            dfdpTRACK[2][0] = 0; //df/dz
-                        }
-                        else if(gp.getDirection()==200) {
-                            //y - tracking frame --> almost unmeasured coordinate direction
-                            dfdpTRACK[0][0] = 0; //df/dx
-                            dfdpTRACK[1][0] = 1; //df/dy
-                            dfdpTRACK[2][0] = 0; //df/dz
-
-                        }
-                        else {
-                            //z - tracking frame --> almost measured coordinate direction
-                            dfdpTRACK[0][0] = 0; //df/dx
-                            dfdpTRACK[1][0] = 0; //df/dy
-                            dfdpTRACK[2][0] = 1; //df/dz
-                        }
-                        
-                    }//type
-                    else if(gp.getType()==2000) {
-                        //rotation
+      
+        
+        //****************************************************************************
+        //Calculate derivatives for a residual in x,y,z-direction for translation in x
+        
+        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));
 
-                        //This residual is affected by a global parameter
-                        useGL = true;
+        
+        //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);
+        //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);
+        if (_DEBUG) {
+            gp.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());
+        }
 
-                        
-                        if(gp.getDirection()==100) {
-                            //x - tracking frame --> beamline direction
-                            dfdpTRACK[0][0] = 0; //df_x/d(alpha)
-                            dfdpTRACK[1][0] = -1; //df_y/d(alpha)
-                            dfdpTRACK[2][0] = 1; //df_z/d(alpha)
-                        }
-                        else if(gp.getDirection()==200) {
-                            //y - tracking frame --> almost unmeasured coordinate direction
-                            dfdpTRACK[0][0] = 1; //df_x/d(beta)
-                            dfdpTRACK[1][0] = 0; //df_y/d(beta)
-                            dfdpTRACK[2][0] = -1; //df_z/d(beta)
-                        }
-                        else {
-                            // Rotation around z 
-                            dfdpTRACK[0][0] = -1; //df_x/d(gamma)
-                            dfdpTRACK[1][0] = 1; //df_y/d(gamma)
-                            dfdpTRACK[2][0] = 0; //df_z/d(gamma)
+        
+        //****************************************************************************
+        //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(1, 0, _alignUtils.dy_dy()); 
+        dfdpTRACK.setElement(2, 0, _alignUtils.dz_dy(xint, xr, d0, phi0, slope, R)); 
 
-                        }
-                        
-                    }//type
-                }//layer  
-            }//side
-         
-            if(useGL) {
-
-                //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);
-                //Transform derivatives to sensor frame!
-                BasicMatrix dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, _dfdpTRACK);
-                //Add it to the global parameter object
-                gp.setDfDp(dfdp);
-                _glp.add(gp);
-                if (_DEBUG) {
-                    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());
-                }
-            } else {
-                if (_DEBUG) {
-                    System.out.printf("Global parameters %s name %s didn't affect this strip on side %d and layer %d\n",gp.getLabel(),gp.getName(),side,layer);
-                }   
-            }
-        } //gps
         
-                
-  
+        //Put it into a matrix to be able to transform easily
+        //BasicMatrix _dfdpTRACK = FillMatrix(dfdpTRACK, 3, 1);
+        //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);
+        if (_DEBUG) {
+            gp.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());
+        }
+
+        //****************************************************************************
+        //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(2, 0, _alignUtils.dz_dz());
+
+        
+        //Put it into a matrix to be able to transform easily
+        //BasicMatrix _dfdpTRACK = FillMatrix(dfdpTRACK, 3, 1);
+        //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);
+        if (_DEBUG) {
+            gp.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());
+        }
+
+        
+        //****************************************************************************
+        //Calculate derivatives for a residual in x,y,z-direction for rotation alpha (rotation around beamline direction x )
+        
+        dfdpTRACK.setElement(0, 0, _alignUtils.dx_dalpha());
+        dfdpTRACK.setElement(1, 0, _alignUtils.dy_dalpha());
+        dfdpTRACK.setElement(2, 0, _alignUtils.dz_dalpha());
+
+        
+        //Put it into a matrix to be able to transform easily
+        //BasicMatrix _dfdpTRACK = FillMatrix(dfdpTRACK, 3, 1);
+        //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);
+        if (_DEBUG) {
+            gp.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());
+        }
+
+        
+        //****************************************************************************
+        //Calculate derivatives for a residual in x,y,z-direction for rotation beta (rotation around beamline direction y )
+        
+        dfdpTRACK.setElement(0, 0, _alignUtils.dx_dbeta());
+        dfdpTRACK.setElement(1, 0, _alignUtils.dy_dbeta());
+        dfdpTRACK.setElement(2, 0, _alignUtils.dz_dbeta());
+
+        
+        //Put it into a matrix to be able to transform easily
+        //BasicMatrix _dfdpTRACK = FillMatrix(dfdpTRACK, 3, 1);
+        //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);
+        if (_DEBUG) {
+            gp.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());
+        }
+        
+        
+        //****************************************************************************
+        //Calculate derivatives for a residual in x,y,z-direction for rotation gamma (rotation around beamline direction z )
+        
+        dfdpTRACK.setElement(0, 0, _alignUtils.dx_dgamma());
+        dfdpTRACK.setElement(1, 0, _alignUtils.dy_dgamma());
+        dfdpTRACK.setElement(2, 0, _alignUtils.dz_dgamma());
+
+        
+        //Put it into a matrix to be able to transform easily
+        //BasicMatrix _dfdpTRACK = FillMatrix(dfdpTRACK, 3, 1);
+        //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);
+        if (_DEBUG) {
+            gp.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());
+        }
+        
+        
+        
+        
+        
+        
+        
+//        //Go through each global parameter and see if it has non-zero contribution
+//        for (GlobalParameter gp : _globalParameterList.getList()) {
+//            
+//            
+//            useGL = false;
+//            
+////            dfdpTRACK.setElement(0, 0, 0);
+////            dfdpTRACK.setElement(1, 0, 0);
+////            dfdpTRACK.setElement(2, 0, 0);
+////            
+//            
+//            //Is this global parameter on the same side
+//            if(gp.getSide()==side) {
+//                
+//                
+//                // correct side
+//                if(gp.getLayer()==layer) {
+//                    //correct layer
+//                    
+//                    //Calcuate dfdp derivatives depending on type of global parameter
+//                    if(gp.getType()==1000) {
+//                        
+//                        //This residual is affected by a global parameter
+//                        useGL = true;
+//                        
+//                        //translation
+//                        if(gp.getDirection()==100) {
+//                            //x - tracking frame --> beamline direction
+//                            dfdpTRACK[0][0] = 1; //df/dx
+//                            dfdpTRACK[1][0] = 0; //df/dy
+//                            dfdpTRACK[2][0] = 0; //df/dz
+//                        }
+//                        else if(gp.getDirection()==200) {
+//                            //y - tracking frame --> almost unmeasured coordinate direction
+//                            dfdpTRACK[0][0] = 0; //df/dx
+//                            dfdpTRACK[1][0] = 1; //df/dy
+//                            dfdpTRACK[2][0] = 0; //df/dz
+//
+//                        }
+//                        else {
+//                            //z - tracking frame --> almost measured coordinate direction
+//                            dfdpTRACK[0][0] = 0; //df/dx
+//                            dfdpTRACK[1][0] = 0; //df/dy
+//                            dfdpTRACK[2][0] = 1; //df/dz
+//                        }
+//                        
+//                    }//type
+//                    else if(gp.getType()==2000) {
+//                        //rotation
+//
+//                        //This residual is affected by a global parameter
+//                        useGL = true;
+//
+//                        
+//                        if(gp.getDirection()==100) {
+//                            //x - tracking frame --> beamline direction
+//                            dfdpTRACK[0][0] = 0; //df_x/d(alpha)
+//                            dfdpTRACK[1][0] = -1; //df_y/d(alpha)
+//                            dfdpTRACK[2][0] = 1; //df_z/d(alpha)
+//                        }
+//                        else if(gp.getDirection()==200) {
+//                            //y - tracking frame --> almost unmeasured coordinate direction
+//                            dfdpTRACK[0][0] = 1; //df_x/d(beta)
+//                            dfdpTRACK[1][0] = 0; //df_y/d(beta)
+//                            dfdpTRACK[2][0] = -1; //df_z/d(beta)
+//                        }
+//                        else {
+//                            // Rotation around z 
+//                            dfdpTRACK[0][0] = -1; //df_x/d(gamma)
+//                            dfdpTRACK[1][0] = 1; //df_y/d(gamma)
+//                            dfdpTRACK[2][0] = 0; //df_z/d(gamma)
+//
+//                        }
+//                        
+//                    }//type
+//                }//layer  
+//            }//side
+//         
+//            if(useGL) {
+//
+//                //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);
+//                //Transform derivatives to sensor frame!
+//                BasicMatrix dfdp = (BasicMatrix) MatrixOp.mult(trkToStrip, _dfdpTRACK);
+//                //Add it to the global parameter object
+//                gp.setDfDp(dfdp);
+//                _glp.add(gp);
+//                if (_DEBUG) {
+//                    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());
+//                }
+//            } else {
+//                if (_DEBUG) {
+//                    System.out.printf("Global parameters %s name %s didn't affect this strip on side %d and layer %d\n",gp.getLabel(),gp.getName(),side,layer);
+//                }   
+//            }
+//        } //gps
+//        
+//                
+//  
         
         
 
@@ -545,7 +700,7 @@
         Hep3Vector vdiffTrk = VecOp.sub(trkpos, corigin);
         Hep3Matrix trkToStrip = getTrackToStripRotation(strip);
         Hep3Vector vdiff = VecOp.mult(trkToStrip, vdiffTrk);
-        Hep3Vector mserrrot = VecOp.mult(trkToStrip, mserr);
+        //Hep3Vector mserrrot = VecOp.mult(trkToStrip, mserr);
         double umc = vdiff.x();
         double vmc = vdiff.y();
         double wmc = vdiff.z();
@@ -577,7 +732,7 @@
             System.out.println("MS: drdphi=" + msdrdphi  + ", dz=" + msdz);
             System.out.println("MS: phi=" + phi  + " => msvec=" + mserr.toString());
             System.out.println("MS: msuError = " + msuError + " (msvec*u = " + mserr.toString() + " * " + u.toString() + ")" );
-            System.out.println("MS: msvec rotated to strip?  = " + mserrrot.toString());
+            //System.out.println("MS: msvec rotated to strip?  = " + mserrrot.toString());
             
         }
 
@@ -966,8 +1121,8 @@
                 * sqrtTerm);
 
 
-        if (_DEBUG)
-            System.out.println("xint = " + xint + "; dsdr = " + dsdr);
+//        if (_DEBUG)
+//            System.out.println("xint = " + xint + "; dsdr = " + dsdr);
         return dsdr;
 
     }
@@ -976,8 +1131,8 @@
         double sqrtTerm = Sqrt(R * R - Math.pow(((d0 - R) * Sin(phi0) + xint), 2));
         double rsign = Math.signum(R);
         double dsdphi = R * (sqrtTerm + rsign * d0 * Cos(phi0) - rsign * R * Cos(phi0)) / sqrtTerm;
-        if (_DEBUG)
-            System.out.println("xint = " + xint + "; dsdphi = " + dsdphi);
+//        if (_DEBUG)
+//            System.out.println("xint = " + xint + "; dsdphi = " + dsdphi);
         return dsdphi;
     }
 
@@ -985,8 +1140,8 @@
         double sqrtTerm = Sqrt(R * R - Math.pow(((d0 - R) * Sin(phi0) + xint), 2));
         double rsign = Math.signum(R);
         double dsdd0 = rsign * (R * Sin(phi0)) / sqrtTerm;
-        if (_DEBUG)
-            System.out.println("xint = " + xint + "; dsdd0 = " + dsdd0);
+//        if (_DEBUG)
+//            System.out.println("xint = " + xint + "; dsdd0 = " + dsdd0);
         return dsdd0;
     }
 
CVSspam 0.2.12


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