4 modified files
lcsim/src/org/lcsim/contrib/JanStrube
diff -u -r1.1 -r1.2
--- FastMCTrackTester.py 20 Jun 2006 22:44:57 -0000 1.1
+++ FastMCTrackTester.py 27 Jun 2006 09:00:13 -0000 1.2
@@ -1,8 +1,9 @@
from hep.aida import IAnalysisFactory
from org.lcsim.mc.fast.tracking import MCFastTrackFactory
from org.lcsim.spacegeom import CartesianPoint
+from org.lcsim.util.swim import HelixSwimmer, Helix
from java.lang import Boolean
-
+from java.lang.Math import sin, cos, atan
af = IAnalysisFactory.create()
tf = af.createTreeFactory()
@@ -17,17 +18,40 @@
py = hf.createCloud1D('trackPY', 'trackPY')
pz = hf.createCloud1D('trackPZ', 'trackPZ')
+d0 = hf.createCloud1D('d0', 'd0')
+phi0 = hf.createCloud1D('phi0', 'phi0')
+omega = hf.createCloud1D('omega', 'omega')
+z0 = hf.createCloud1D('z0', 'z0')
+s = hf.createCloud1D('s', 's')
+
+orgx = hf.createCloud1D('orgX', 'orgX')
+#orgy = hf.createCloud1D('orgY', 'orgY')
+
fac = MCFastTrackFactory()
-point = CartesianPoint(0, 0, 0)
-momentum = CartesianPoint(1, 2, 3)
-for iev in range(10000):
+momentum = CartesianPoint(2, 2, 2)
+for iev in range(1,100):
+ for iy in range(1,100):
+ point = CartesianPoint(-10 + 20./iev, -10 + 20./iy, 5)
+
track = fac.getMCTrack(momentum, point, 1)
- x.fill(track.getReferencePointX())
- y.fill(track.getReferencePointY())
- z.fill(track.getReferencePointZ())
- px.fill(track.getPX())
- py.fill(track.getPY())
- pz.fill(track.getPZ())
+
+# x.fill(track.getReferencePointX())
+# y.fill(track.getReferencePointY())
+# z.fill(track.getReferencePointZ())
+# px.fill(track.getPX())
+# py.fill(track.getPY())
+# pz.fill(track.getPZ())
+ parms = track.getTrackParameters()
+ helix = HelixSwimmer(5)
+ helix.setTrack(track)
+
+ d0.fill(parms[0])
+ phi0.fill(parms[1])
+ omega.fill(parms[2])
+ z0.fill(parms[3])
+ s.fill(parms[4])
+ orgx.fill(helix.getDistanceToPoint(point))
+# orgy.fill(xy.y())
tree.commit()
tree.close()
lcsim/src/org/lcsim/contrib/JanStrube
diff -u -r1.3 -r1.4
--- MainLoop.py 28 Mar 2006 23:48:07 -0000 1.3
+++ MainLoop.py 27 Jun 2006 09:00:13 -0000 1.4
@@ -9,8 +9,9 @@
from java.io import File
#from ZvTubePlotter import ZvTubePlotter
from java.lang import System
-import VertexFitterDriver
+#import VertexFitterDriver
from java.lang import Boolean
+from ReconParticleTestDriver import ReconParticleTestDriver
true = Boolean("true")
false = Boolean("false")
@@ -25,7 +26,8 @@
# loop.setLCIORecordSource(input)
loop.add(MCFast(false, false))
# loop.add(ZvTubePlotter())
- loop.add(VertexFitterDriver())
+# loop.add(VertexFitterDriver())
+ loop.add(ReconParticleTestDriver())
# output = File(System.getProperty("user.home"),"fastmc.slcio")
# loop.add(LCIODriver(output))
loop.loop(-1)
lcsim/src/org/lcsim/contrib/JanStrube/vtxFitter
diff -u -r1.2 -r1.3
--- Fitter.java 27 Jun 2006 01:52:30 -0000 1.2
+++ Fitter.java 27 Jun 2006 09:00:14 -0000 1.3
@@ -1,4 +1,4 @@
-package vtxFitter;
+package org.lcsim.contrib.JanStrube.vtxFitter;
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.Track;
@@ -12,19 +12,19 @@
double deltaChi2 = 1e-4;
// position
- double[] x_k, x_prev, x;
+ double[] x_prev;
// covariance for x
- Matrix C_k, C_prev, C;
+ Matrix C_prev;
// momentum
- double[] q_k, q_prev, q;
+ double[] q_prev;
// covariance for momentum
- Matrix D_k, D_prev, D;
+ Matrix D_prev;
//covariance for x and q
- Matrix E_k, E_prev, E;
+ Matrix E_prev;
// covariance for track measurement
- Matrix V_k, V_prev, V;
+ Matrix V_prev;
// inverse of covariance matrix
- Matrix G_k, G_prev, G;
+ Matrix G_prev;
Matrix G_B;
// linearity factors of the measeurement eq.
@@ -65,8 +65,8 @@
public Fitter(ReconstructedParticle p, double[] x0, double[][] C0) {
particle = p;
- x = x0;
- C = new Matrix(C0);
+ x_prev = x0;
+ C_prev = new Matrix(C0);
}
@@ -79,15 +79,16 @@
}
}
private void filter(Track t) {
+ Matrix G_k = new Matrix(t.getErrorMatrix()).inverse();
double[] m_k = t.getTrackParameters();
- C_k = C_prev.inverse().plus(A_k.transpose().times(G_B.times(A_k))).inverse();
+ Matrix C_k = C_prev.inverse().plus(A_k.transpose().times(G_B.times(A_k))).inverse();
- x = C_k.times(add(C_prev.inverse().times(x_prev)
+ double[] x_k = C_k.times(add(C_prev.inverse().times(x_prev)
, A_k.transpose().times(G_B).times(subtract(m_k, c_k0))));
- q = W_k.times(B_k.transpose().times(G_k)).times(subtract(m_k, add(c_k0, A_k.times(x_k))));
- D = W_k.plus(W_k.times(B_k.transpose().plus(G_k.times(A_k.times(C_k.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))))))));
- E = C_k.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))).uminus();
+ double[] q_k = W_k.times(B_k.transpose().times(G_k)).times(subtract(m_k, add(c_k0, A_k.times(x_k))));
+ Matrix D_k = W_k.plus(W_k.times(B_k.transpose().plus(G_k.times(A_k.times(C_k.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))))))));
+ Matrix E_k = C_k.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))).uminus();
W_k = (B_k.transpose().times(G_k.times(B_k))).times(-1);
G_B = G_k.minus((G_k.times(B_k.times(W_k.times(B_k.transpose().times(G_k))))));
@@ -95,15 +96,15 @@
chi2 = chi2_prev + dot(r_k, G_k.times(r_k)) + dot(subtract(x_k, x_prev), C_prev.inverse().times(subtract(x_k, x_prev)));
r_k = subtract(m_k, add(c_k0, add(A_k.times(x_k), B_k.times(q_k))));
+ C_prev = C_k;
}
private void smoothe(Track t) {
+ Matrix G_k = new Matrix(t.getErrorMatrix()).inverse();
double[] m_k = t.getTrackParameters();
- double[] x_N = x_k;
- double[] q_kN = W_k.times(B_k.transpose().times(G_k)).times(subtract(m_k, add(c_k0, A_k.times(x_N))));
- Matrix C_kN = C_k;
- Matrix D_kN = W_k.plus(W_k.times(B_k.transpose().times(G_k.times(A_k.times(C_kN.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))))))));
- Matrix E_kN = C_kN.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))).uminus();
+ double[] q_kN = W_k.times(B_k.transpose().times(G_k)).times(subtract(m_k, add(c_k0, A_k.times(x_prev))));
+ Matrix D_kN = W_k.plus(W_k.times(B_k.transpose().times(G_k.times(A_k.times(C_prev.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))))))));
+ Matrix E_kN = C_prev.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))).uminus();
}
// // returns y = A.x
lcsim/src/org/lcsim/contrib/JanStrube/vtxFitter
diff -u -r1.2 -r1.3
--- FitterTest.java 27 Jun 2006 01:52:30 -0000 1.2
+++ FitterTest.java 27 Jun 2006 09:00:14 -0000 1.3
@@ -1,21 +1,31 @@
-package vtxFitter;
+package org.lcsim.contrib.JanStrube.vtxFitter;
-import Jama.Matrix;
+import static org.lcsim.contrib.JanStrube.vtxFitter.Fitter.add;
+import static org.lcsim.contrib.JanStrube.vtxFitter.Fitter.dot;
+import static org.lcsim.contrib.JanStrube.vtxFitter.Fitter.subtract;
import junit.framework.TestCase;
-import static vtxFitter.Fitter.subtract;
-import static vtxFitter.Fitter.add;
-//import static vtxFitter.Fitter.multiply;
-import static vtxFitter.Fitter.dot;
+
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.base.BaseReconstructedParticle;
+import org.lcsim.mc.fast.tracking.MCFastTrackFactory;
+import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.SpacePoint;
+
+import Jama.Matrix;
public class FitterTest extends TestCase {
Matrix A;
double[] x;
double[] y;
+ ReconstructedParticle part;
protected void setUp() throws Exception {
super.setUp();
A = new Matrix(2, 3, 2.5);
x = new double[] {1, 2, 3};
y = x.clone();
+ part = new BaseReconstructedParticle();
+ Fitter fitter = new Fitter(part);
}
protected void tearDown() throws Exception {
@@ -58,4 +68,13 @@
double r = dot(x, y);
assertEquals(r, 14.);
}
+
+ public void testFit() {
+ SpacePoint mom = new CartesianPoint(1, 1, 1);
+ SpacePoint pos = new CartesianPoint(0.3, 0.5, 0.2);
+ MCFastTrackFactory fac = new MCFastTrackFactory();
+ Track t = fac.getMCTrack(mom, pos, -1);
+ part.addTrack(t);
+
+ }
}
CVSspam 0.2.8