Commit in lcsim/sandbox/RobKutschke/TRFTests/v1 on MAIN
RKCovSmear.java+72added 1.1
RKDebug.java+61added 1.1
+133
2 added files
First releases.

lcsim/sandbox/RobKutschke/TRFTests/v1
RKCovSmear.java added at 1.1
diff -N RKCovSmear.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RKCovSmear.java	7 Sep 2007 19:06:53 -0000	1.1
@@ -0,0 +1,72 @@
+import java.util.Random;
+
+import org.lcsim.recon.tracking.trfbase.TrackVector;
+import org.lcsim.recon.tracking.trfbase.TrackError;
+
+import Jama.Matrix;
+import Jama.EigenvalueDecomposition;
+
+/**
+ *
+ * Given a set of track parameters and a covariance matrix
+ * smear the track parameters by a multi-dimensional gaussian
+ * drawn from the covariance matrix.
+ *
+ * The method is to find the transformation that diagonalizes the
+ * covariance matrix, smear the diagonalize matrix and then transform
+ * the smearing back to the orignal basis.
+ *
+ *@author $Author: kutschke $
+ *@version $Id: RKCovSmear.java,v 1.1 2007/09/07 19:06:53 kutschke Exp $
+ *
+ * Date $Date: 2007/09/07 19:06:53 $
+ *
+ */
+
+public class RKCovSmear{
+
+    private Random ran = null;
+
+    public RKCovSmear( long seed ){
+	ran = new Random(seed);
+    }
+
+    public TrackVector  Smear ( TrackError e, TrackVector v ){
+	Matrix m = new Matrix(e.matrix());
+
+	// Extract eigenvalues and the matrix of eigenvectors.
+	EigenvalueDecomposition eigen = new EigenvalueDecomposition(m);
+	double[] ev = eigen.getRealEigenvalues();
+	Matrix a    = eigen.getV();
+
+	// Smear the diagonalized eigenvalue matrix.
+	int n = ev.length;
+	Matrix mout = new Matrix(n,1);
+	for ( int i=0; i<n; ++i ){
+	    double x = ev[i];
+	    if ( x < 0. ){
+		System.out.println("RKCovSmear Warning  negative element on diag: " 
+				   + i + " "
+				   + x 
+				   );
+		x = Math.abs(x);
+	    }
+	    double g = ran.nextGaussian();
+	    x = Math.sqrt(x)*g;
+	    mout.set(i,0,x);
+	}
+
+	// Rotate smeared vector to original basis.
+	Matrix m2 = a.times(mout);
+
+	// Apply smearing to the input vector.
+	TrackVector vout = new TrackVector();
+	for ( int i=0; i<n; ++i ){
+	    vout.set(i,v.get(i)+m2.get(i,0));
+	}
+	return vout;
+
+    }
+
+
+}

lcsim/sandbox/RobKutschke/TRFTests/v1
RKDebug.java added at 1.1
diff -N RKDebug.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ RKDebug.java	7 Sep 2007 19:06:53 -0000	1.1
@@ -0,0 +1,61 @@
+import org.lcsim.recon.tracking.trfbase.PropDir;
+
+/**
+ * 
+ * A way to propagate debug info to low level routines.
+ *
+ *@author $Author: kutschke $
+ *@version $Id: RKDebug.java,v 1.1 2007/09/07 19:06:53 kutschke Exp $
+ *
+ * Date $Date: 2007/09/07 19:06:53 $
+ *
+ */
+
+public class RKDebug {
+
+    static private int track = -1;
+    static private PropDir pdir;
+    static private RKTrack rkt;
+    static private int start_type;
+
+    static private RKDebug instance = null;
+
+    private RKDebug(){
+    }
+
+    static RKDebug Instance(){
+	if ( instance == null ){
+	    instance = new RKDebug();
+	}
+	return instance;
+    }
+
+    static public int getTrack(){
+	return track;
+    }
+    static public void setTrack( int trk){
+	track = trk;
+    }
+
+    static public PropDir getPropDir(){
+	return pdir;
+    }
+    static public void setPropDir( PropDir dir){
+	pdir = dir;
+    }
+
+    static public RKTrack getRKTrack(){
+	return rkt;
+    }
+    static public void setRKTrack( RKTrack t){
+	rkt = t;
+    }
+
+    static public int getStartType(){
+	return start_type;
+    }
+    static public void setStartType( int type){
+	start_type = type;
+    }
+
+}
CVSspam 0.2.8