lcsim/test/org/lcsim/recon/vertexing/zvtop4/fitter
diff -u -r1.2 -r1.3
--- VertexFitterTest.java 22 Mar 2006 00:38:08 -0000 1.2
+++ VertexFitterTest.java 22 Mar 2006 09:37:36 -0000 1.3
@@ -40,6 +40,7 @@
loop = new LCSimLoop();
// contains psi- mu mu events
location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/Zgamma/stdhep/pythia/pythiaZgamma.stdhep");
+// location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/psi_mumu_Theta4-176_5-100GeV.stdhep");
cache = new FileCache();
trackFile = cache.getCachedFile(location);
loop.setStdhepRecordSource(trackFile, "sidaug05");
@@ -49,7 +50,7 @@
public void testFit() throws org.freehep.record.loop.LoopException, java.io.IOException {
loop.add(new MCFast());
loop.add(new TrackFitDriver());
- loop.loop(5);
+ loop.loop(-1);
}
private class TrackFitDriver extends Driver {
private List<double[]> weights = new ArrayList<double[]>();
@@ -58,18 +59,26 @@
trackParams.clear();
weights.clear();
List<Track> tracks = event.getTracks();
+ if (tracks.size() != 2)
+ return;
for (Track iTrack : tracks) {
Matrix olderrors = new Matrix(iTrack.getErrorMatrix());
- olderrors.print(5, 3);
+ olderrors.print(21, 20);
double[] params = iTrack.getTrackParameters();
System.err.println();
Matrix jacobi = new Matrix(getJacobi(params));
+ jacobi.print(21, 20);
double theta = PI/2 - atan(params[4]);
double[] newparams = new double[]{params[0], params[3], theta, params[1], params[2]};
trackParams.add(newparams);
- double[][] weightArray = jacobi.arrayTimes(olderrors).times(jacobi.transpose()).getArray();
+ double[][] weightArray = jacobi.times(olderrors).times(jacobi.transpose()).getArray();
+ Matrix nw = new Matrix(weightArray);
+ nw.print(31, 30);
+ System.err.printf("Old Det: %g\nNew Det: %g\nJacobi Det: %g\n", olderrors.det(), nw.det(), jacobi.det());
weights.add(flattenWeights(weightArray));
}
+
+ System.err.printf("%d tracks\n", trackParams.size());
System.err.println("fitting");
boolean[] inVtx = new boolean[] {true, true};
double[] initialPosition = new double[] {0, 0, 0};
@@ -98,9 +107,11 @@
System.err.println();
}
Matrix newTrackParams = new Matrix(trackParams.toArray(new double[][]{}));
+ newTrackParams.print(20, 21);
Matrix newWeights = new Matrix(weights.toArray(new double[][]{}));
-// Vertex v = fitter.fit(tracks.size(), false, inVtx, newTrackParams.transpose().getArray(), newWeights.transpose().getArray(), initialPosition);
-// aida.histogram1D("vtx_chi2").fill(v._chi2);
+ newWeights.print(21, 20);
+ Vertex v = fitter.fit(tracks.size(), false, inVtx, newTrackParams.transpose().getArray(), newWeights.transpose().getArray(), initialPosition);
+ aida.cloud1D("vtx_chi2").fill(v._chi2);
}
private double[][] getJacobi(double[] old) {
@@ -109,7 +120,7 @@
, {0, 0, 0, old[1], 0}
, {0, 0, 0, 0, old[2]}
, {0, old[3], 0, 0, 0}
- , {0, 0, 1/(Math.cos(old[4])*Math.cos(old[4])), 0, 0}};
+ , {0, 0, 1+Math.tan(old[4])*Math.tan(old[4]), 0, 0}};
return jacobi;
}