15 modified files
lcsim
diff -u -r1.38 -r1.39
--- project.xml 9 Oct 2006 17:31:02 -0000 1.38
+++ project.xml 14 Oct 2006 08:45:20 -0000 1.39
@@ -155,7 +155,6 @@
<exclude>org/lcsim/contrib/CarstenHensel/**</exclude>
<exclude>org/lcsim/contrib/LeiXia/**</exclude>
<exclude>org/lcsim/contrib/JanStrube/*</exclude>
- <exclude>org/lcsim/contrib/JanStrube/zvtop/*</exclude>
<exclude>org/lcsim/contrib/JanStrube/standalone/**</exclude>
<exclude>org/lcsim/contrib/SteveKuhlmann/**</exclude>
<exclude>org/lcsim/contrib/compile/**</exclude>
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.5 -r1.6
--- FitterTestDriver.java 12 Sep 2006 13:28:23 -0000 1.5
+++ FitterTestDriver.java 14 Oct 2006 08:45:21 -0000 1.6
@@ -50,7 +50,7 @@
Track unsmearedTrack = tf.getTrack(
new SpaceVector(daughter.getMomentum()),
new SpacePoint(daughter.getOrigin()),
- origin,
+ new SpacePoint(part.getEndPoint()),
(int)daughter.getCharge(),
rand,
false);
@@ -73,7 +73,7 @@
Track smearedTrack = tf.getTrack(
new SpaceVector(daughter.getMomentum()),
new SpacePoint(daughter.getOrigin()),
- origin,
+ new SpacePoint(part.getEndPoint()),
(int)daughter.getCharge(),
rand,
true);
@@ -102,9 +102,9 @@
double sigmaX = sqrt(newVtx2.getSpatialCovarianceMatrix().get(0, 0));
double sigmaY = sqrt(newVtx2.getSpatialCovarianceMatrix().get(1, 1));
double sigmaZ = sqrt(newVtx2.getSpatialCovarianceMatrix().get(2, 2));
- double deltaX = newVtx2.origin().x() - part.getOrigin().x();
- double deltaY = newVtx2.origin().y() - part.getOrigin().y();
- double deltaZ = newVtx2.origin().z() - part.getOrigin().z();
+ double deltaX = newVtx2.location().x() - part.getEndPoint().x();
+ double deltaY = newVtx2.location().y() - part.getEndPoint().y();
+ double deltaZ = newVtx2.location().z() - part.getEndPoint().z();
aida.cloud1D("decayLength").fill(new SpacePoint(part.getEndPoint()).magnitude());
aida.cloud1D("vtx_smeared_deltaX").fill(deltaX);
aida.cloud1D("vtx_smeared_deltaY").fill(deltaY);
@@ -115,9 +115,9 @@
aida.cloud1D("vtx_pull_x").fill(deltaX/sigmaX);
aida.cloud1D("vtx_pull_y").fill(deltaY/sigmaY);
aida.cloud1D("vtx_pull_z").fill(deltaZ/sigmaZ);
- aida.cloud1D("vtx_unsmeared_deltaX").fill(newVtx1.origin().x() - part.getOrigin().x());
- aida.cloud1D("vtx_unsmeared_deltaY").fill(newVtx1.origin().y() - part.getOrigin().y());
- aida.cloud1D("vtx_unsmeared_deltaZ").fill(newVtx1.origin().z() - part.getOrigin().z());
+ aida.cloud1D("vtx_unsmeared_deltaX").fill(newVtx1.location().x() - part.getEndPoint().x());
+ aida.cloud1D("vtx_unsmeared_deltaY").fill(newVtx1.location().y() - part.getEndPoint().y());
+ aida.cloud1D("vtx_unsmeared_deltaZ").fill(newVtx1.location().z() - part.getEndPoint().z());
}
}
}
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.3 -r1.4
--- FitterTestDriver_ReconTrack.java 10 Sep 2006 11:47:39 -0000 1.3
+++ FitterTestDriver_ReconTrack.java 14 Oct 2006 08:45:21 -0000 1.4
@@ -57,7 +57,7 @@
SpacePoint org = new CartesianPoint(t.getReferencePoint());
SpaceVector mom = new CartesianVector(t.getMomentum());
Matrix errors = new Matrix(t.getErrorMatrix());
- EMap parameters = EMap.SpaceMomentum2Parameters(org, mom, referencePoint, t.getCharge(), 5);
+ EMap parameters = EMap.SpaceMomentum2Parameters(mom, org, referencePoint, t.getCharge(), 5);
tracks.add(new NewTrack(referencePoint, parameters, errors, t.getCharge()));
}
SpacePoint startingPoint = new SpacePoint();
@@ -67,9 +67,9 @@
double sigmaX = sqrt(newVtx2.getSpatialCovarianceMatrix().get(0, 0));
double sigmaY = sqrt(newVtx2.getSpatialCovarianceMatrix().get(1, 1));
double sigmaZ = sqrt(newVtx2.getSpatialCovarianceMatrix().get(2, 2));
- double deltaX = newVtx2.origin().x() - mother.getOrigin().x();
- double deltaY = newVtx2.origin().y() - mother.getOrigin().y();
- double deltaZ = newVtx2.origin().z() - mother.getOrigin().z();
+ double deltaX = newVtx2.location().x() - mother.getOrigin().x();
+ double deltaY = newVtx2.location().y() - mother.getOrigin().y();
+ double deltaZ = newVtx2.location().z() - mother.getOrigin().z();
aida.cloud1D("decayLength").fill(new SpacePoint(mother.getEndPoint()).magnitude());
aida.cloud1D("smeared_deltaX").fill(deltaX);
aida.cloud1D("smeared_deltaY").fill(deltaY);
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.5 -r1.6
--- MainLoop.java 12 Sep 2006 13:28:23 -0000 1.5
+++ MainLoop.java 14 Oct 2006 08:45:21 -0000 1.6
@@ -24,6 +24,7 @@
// URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/Zgamma/stdhep/pythia/pythiaZgamma.stdhep");
// URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/K0S_pipi_Theta45-135_5-25Gev.stdhep");
URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/singleParticle/stdhep/psi_mumu_Theta4-176_5-100GeV.stdhep");
+// URL location = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/ILC/ILC500/mumu/stdhep/pandorapythia/panpymumu.stdhep");
FileCache cache = new FileCache();
File trackFile = cache.getCachedFile(location);
loop.setStdhepRecordSource(trackFile, "sidaug05");
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.1 -r1.2
--- PrimaryParticleDaughterFitter.java 29 Aug 2006 19:50:18 -0000 1.1
+++ PrimaryParticleDaughterFitter.java 14 Oct 2006 08:45:21 -0000 1.2
@@ -1,5 +1,5 @@
/**
- * @version $Id: PrimaryParticleDaughterFitter.java,v 1.1 2006/08/29 19:50:18 jstrube Exp $
+ * @version $Id: PrimaryParticleDaughterFitter.java,v 1.2 2006/10/14 08:45:21 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.standalone;
@@ -46,7 +46,7 @@
Fitter fitter = new Fitter(event);
Vertex vtx = fitter.fit(tracks, new SpacePoint());
SpacePoint p_org = new SpacePoint(part.getOrigin());
- SpacePoint v_org = new SpacePoint(vtx.origin());
+ SpacePoint v_org = new SpacePoint(vtx.location());
Matrix spatialError = vtx.getSpatialCovarianceMatrix();
aida.cloud1D("pull_X").fill(abs(p_org.x()-v_org.x())/sqrt(spatialError.get(0, 0)));
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.1 -r1.2
--- fitPullDist.py 9 Oct 2006 16:40:39 -0000 1.1
+++ fitPullDist.py 14 Oct 2006 08:45:21 -0000 1.2
@@ -1,7 +1,11 @@
#! /usr/bin/env jython
from hep.aida import IAnalysisFactory
+from java.lang import Boolean
import sys
+True = Boolean("true")
+False = Boolean("false")
+
filename = sys.argv[1]
af = IAnalysisFactory.create()
@@ -10,10 +14,10 @@
fitter = ff.createFitter('chi2')
-tree = tf.create(filename)
+tree = tf.create(filename, "xml", True, False)
-for pull in 'pull_x', 'pull_y', 'pull_z':
+for pull in 'vtx_pull_x', 'vtx_pull_y', 'vtx_pull_z':
p = tree.find(pull)
p.convertToHistogram()
h = p.histogram()
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.4 -r1.5
--- EMap.java 10 Sep 2006 11:47:36 -0000 1.4
+++ EMap.java 14 Oct 2006 08:45:22 -0000 1.5
@@ -1,5 +1,5 @@
/**
- * @version $Id: EMap.java,v 1.4 2006/09/10 11:47:36 jstrube Exp $
+ * @version $Id: EMap.java,v 1.5 2006/10/14 08:45:22 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.tracking;
@@ -59,13 +59,13 @@
* Calculates the parameters of the Track under the assumption that the
* space-momentum representation is given at the POCA to the reference point.
* @param pos The point of closest approach on the track to the reference point
- * @param mom The momentum vector at @see pos
- * @param ref The reference point
- * @param charge The charge of the particle
- * @param Bz The z component of the magnetic field. Assuming a homogeneous field parallel to z
+ * @param mom The momentum vector at @see pos
+ * @param ref The reference point
+ * @param charge The charge of the particle
+ * @param Bz The z component of the magnetic field. Assuming a homogeneous field parallel to z
* @return The Parameter object corresponding to the arguments
*/
- public static EMap SpaceMomentum2Parameters(SpaceVector mom, SpacePoint pos, SpacePoint ref, int charge, double field_z) {
+ public static EMap SpaceMomentum2Parameters(SpacePoint pos, SpaceVector mom, SpacePoint ref, int charge, double field_z) {
EMap result = new EMap();
double aqBz = charge*field_z*fieldConversion;
double x = pos.x() - ref.x();
@@ -86,6 +86,10 @@
double[] values;
double pt;
+ public EMap(EMap map) {
+ values = map.values.clone();
+ pt = map.pt;
+ }
EMap() {
values = new double[5];
@@ -127,29 +131,4 @@
sb.append(String.format("%10s: %g\n", "pt", pt));
return sb.toString();
}
-
-
- private static EMap SpaceMomentum2Parameters_tt(SpacePoint pos, SpacePoint mom, SpacePoint ref, int charge, double field_z) {
- EMap result = new EMap();
- double aqBz = charge*field_z*fieldConversion;
- double x = pos.x() - ref.x();
- double y = pos.y() - ref.y();
- double z = pos.z() - ref.z();
- double px0 = mom.x() - aqBz*y;
- double py0 = mom.y() + aqBz*x;
- double pt0 = sqrt(px0*px0 + py0*py0);
-
- double phi_0 = atan2(py0, px0);
- double phi = mom.phi();
- double pt = mom.rxy();
- double l = (phi_0 - phi)*pt/aqBz;
-
- result.set(d0, (pt-pt0)/aqBz);
- result.set(phi0, phi_0);
- result.set(omega, aqBz/pt);
- result.set(z0, z - l*mom.z()/pt);
- result.set(tanLambda, mom.z()/pt);
- result.setPt(pt);
- return result;
- }
}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.10 -r1.11
--- NewFastMCTrackFactory.java 10 Sep 2006 11:47:35 -0000 1.10
+++ NewFastMCTrackFactory.java 14 Oct 2006 08:45:22 -0000 1.11
@@ -1,5 +1,5 @@
/**
- * @version $Id: NewFastMCTrackFactory.java,v 1.10 2006/09/10 11:47:35 jstrube Exp $
+ * @version $Id: NewFastMCTrackFactory.java,v 1.11 2006/10/14 08:45:22 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.tracking;
@@ -128,7 +128,7 @@
double alpha = _swimmer.getTrackLengthToPoint(referencePoint);
SpacePoint poca = _swimmer.getPointAtLength(alpha);
SpaceVector momentumAtPoca = _swimmer.getMomentumAtLength(alpha);
- EMap parameters = EMap.SpaceMomentum2Parameters(momentumAtPoca, poca, referencePoint, charge, _Bz);
+ EMap parameters = EMap.SpaceMomentum2Parameters(poca, momentumAtPoca, referencePoint, charge, _Bz);
Matrix errorMatrix = new Matrix(5, 5);
// this sets the measurement error
double cosTheta = abs(momentumAtPoca.cosTheta());
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.8 -r1.9
--- NewTrack.java 10 Sep 2006 11:47:34 -0000 1.8
+++ NewTrack.java 14 Oct 2006 08:45:22 -0000 1.9
@@ -1,5 +1,5 @@
/**
- * @version $Id: NewTrack.java,v 1.8 2006/09/10 11:47:34 jstrube Exp $
+ * @version $Id: NewTrack.java,v 1.9 2006/10/14 08:45:22 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.tracking;
@@ -24,12 +24,12 @@
protected SpacePoint _referencePoint;
protected int _charge;
- private NewTrack() {
+ protected NewTrack() {
_parameters = new EMap();
_errorMatrix = new Matrix(5, 5);
}
- public NewTrack(SpacePoint refPoint, EMap parameters, Matrix errorMatrix, int charge) {
- this();
+
+ protected NewTrack(SpacePoint refPoint, EMap parameters, Matrix errorMatrix, int charge) {
_referencePoint = refPoint;
_parameters = parameters;
_charge = charge;
lcsim/src/org/lcsim/contrib/JanStrube/vtxFitter
diff -u -r1.12 -r1.13
--- Fitter.java 10 Sep 2006 11:47:31 -0000 1.12
+++ Fitter.java 14 Oct 2006 08:45:22 -0000 1.13
@@ -2,7 +2,7 @@
package org.lcsim.contrib.JanStrube.vtxFitter;
/**
- * @version $Id: Fitter.java,v 1.12 2006/09/10 11:47:31 jstrube Exp $
+ * @version $Id: Fitter.java,v 1.13 2006/10/14 08:45:22 jstrube Exp $
*/
import static java.lang.Math.abs;
@@ -17,8 +17,10 @@
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.event.EventHeader;
import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.CartesianVector;
import org.lcsim.spacegeom.SpacePoint;
import org.lcsim.spacegeom.SpaceVector;
+import org.lcsim.util.aida.AIDA;
import Jama.Matrix;
@@ -32,13 +34,14 @@
*
*/
public class Fitter {
- // The Vertex object
- Vertex particle;
-
+ // The Vertex that is being fitted
+ // TODO: maybe the filter and smoothe functions should be part of Vertex...
+ Vertex fitVertex;
+ AIDA aida = AIDA.defaultInstance();
double B_z;
// convergence criterion
double delta_chi2 = 1e-2;
- int max_iter = 20;
+ int max_iter = 25;
// position
Matrix x_prev;
// covariance for x
@@ -67,65 +70,67 @@
_swimmer = new HelixSwimmer(bz);
}
- public Vertex fit(Collection< ? extends Track> tracks, SpacePoint initialPosition) {
+ public Vertex fit(Collection<Track> tracks, SpacePoint initialPosition) {
C_prev = new Matrix(new double[][] { { 10000, 0, 0 }, { 0, 10000, 0 }, { 0, 0, 10000 } });
x_prev = new Matrix(initialPosition.getCartesianArray(), 3);
- particle = new Vertex();
- particle.setOrigin(initialPosition);
-
+ // The Vertex object
+ Vertex particle = new Vertex(tracks, initialPosition);
// set the conditions to enter the loop
chi2_prev = 1000;
double chi2_this = 0;
int n_iter = 0;
while (abs(chi2_prev - chi2_this) > delta_chi2 && n_iter < max_iter) {
-// for (int i=0; i<10; ++i) {
+ // System.out.printf("iteration: %d\tdelta chi2: %.3f\n", n_iter, chi2_prev - chi2_this);
n_iter++;
- particle._tracks.clear();
-// System.out.printf("before: %f\t after: %f\n", chi2_this, chi2_prev);
+ // the Vertex that is being worked on in this iteration
+ fitVertex = new Vertex();
+ fitVertex._location = particle._location;
+ // System.out.printf("before: %f\t after: %f\n", chi2_this, chi2_prev);
chi2_this = chi2_prev;
chi2_prev = 0;
- for (Track t : tracks) {
- double chi2_track = filter(t);
- // System.out.printf("filtering: chi2=%f\n", chi2_track);
+ for (VtxTrack t : particle.getVtxTracks()) {
+ fitVertex.addTrack(t, filter(t));
}
// FIXME: This only changes the parameters of the tracks.
-// for (Track t : tracks) {
-// double chi2_track = smoothe(t, false);
- // System.out.printf("smoothing: %f\n", chi2_track);
-// }
+ //for (VtxTrack t : fitVertex.getVtxTracks()) {
+ // smoothe(t, false);
+ //}
+ // the particle is now the currently best approximation
+ particle = fitVertex;
}
+ aida.cloud1D("n_iter").fill(n_iter);
particle._spatialCovarianceMatrix = C_prev;
particle._chi2 = chi2_this;
// final iteration, this time compute the full covariance matrix
-// for (Track t : tracks) {
-// double chi2_track = smoothe(t, true);
- // System.out.printf("smoothing: %f\n", chi2_track);
-// }
+ for (VtxTrack t : particle.getVtxTracks()) {
+ smoothe(t, true);
+ }
return particle;
}
// Turn everything into a Matrix
- private double filter(Track t) {
+ private double filter(VtxTrack t) {
// First, get the Matrices at the point of linearization x0, p0
// a good choice for x0 is the previous best estimate and
// p0 is the momentum of the track at the POCA to x0
_swimmer.setTrack(t);
+ SpacePoint vtxPosition = fitVertex.location();
// at the moment, particle.origin is the best estimate so far
- double alpha = _swimmer.getTrackLengthToPoint(particle.origin());
+ double alpha = _swimmer.getTrackLengthToPoint(vtxPosition);
SpaceVector p = _swimmer.getMomentumAtLength(alpha);
// x is the POCA of the current track to the best estimate
SpacePoint x = _swimmer.getPointAtLength(alpha);
- Matrix A_k = getSpatialDerivativeMatrix(particle.origin(), p, t.getCharge(), B_z);
- Matrix B_k = getMomentumDerivativeMatrix(particle.origin(), p, t.getCharge(), B_z);
+ Matrix A_k = getSpatialDerivativeMatrix(vtxPosition, p, t.getCharge(), B_z);
+ Matrix B_k = getMomentumDerivativeMatrix(vtxPosition, p, t.getCharge(), B_z);
Matrix q0 = new Matrix(p.getCartesianArray(), 3);
// turn the measurement into a Matrix object
- Matrix h = new Matrix(EMap.SpaceMomentum2Parameters(p, particle.origin(), particle.origin(), t.getCharge(), B_z)
+ Matrix h = new Matrix(EMap.SpaceMomentum2Parameters(vtxPosition, p, vtxPosition, t.getCharge(), B_z)
.getValues(), 5);
// the measurement of the track is taken at the POCA to the best estimate
- Matrix m_k = new Matrix(EMap.SpaceMomentum2Parameters(p, x, particle.origin(), t.getCharge(), B_z).getValues(), 5);
+ Matrix m_k = new Matrix(EMap.SpaceMomentum2Parameters(x, p, vtxPosition, t.getCharge(), B_z).getValues(), 5);
Matrix c_k0 = h.minus(A_k.times(x_prev).plus(B_k.times(q0)));
// Now for the real filtering equations
@@ -140,6 +145,8 @@
Matrix x_k = C_k.times(C_prev.inverse().times(x_prev).plus(A_k.transpose().times(G_kB).times(m_k.minus(c_k0))));
Matrix q_k = W_k.times(B_k.transpose().times(G_k.times(m_k.minus(c_k0.plus(A_k.times(x_k))))));
+ SpaceVector updatedMomentum = new CartesianVector(q_k.getRowPackedCopy());
+ t.updateMomentum(updatedMomentum, vtxPosition, B_z);
// cov(q)
// now the chi2
Matrix r_k = h.minus(c_k0.plus(A_k.times(x_k).plus(B_k.times(q_k))));
@@ -153,8 +160,7 @@
x_prev = x_k;
// System.out.printf("after: %s", x_prev);
C_prev = C_k;
- particle.addTrack(t, chi2_kf);
- particle._origin = new CartesianPoint(x_k.getRowPackedCopy());
+ fitVertex._location = new CartesianPoint(x_k.getRowPackedCopy());
// System.out.println(particle._origin);
// if (fullFit) {
// Matrix D_k = W_k.plus(W_k.times(B_k.transpose().times(
@@ -163,36 +169,35 @@
// // cov(x, q)
// Matrix E_k = C_k.times(A_k.transpose().times(G_k.times(B_k.times(W_k)))).uminus();
// }
-
return chi2_kf;
}
- private double smoothe(Track t, boolean fullFit) {
+ private void smoothe(VtxTrack t, boolean fullFit) {
_swimmer.setTrack(t);
+ SpacePoint vtxPosition = fitVertex.location();
// at the moment, particle.origin is the best estimate so far
- double alpha = _swimmer.getTrackLengthToPoint(particle.origin());
+ double alpha = _swimmer.getTrackLengthToPoint(vtxPosition);
SpaceVector p = _swimmer.getMomentumAtLength(alpha);
// x is the POCA of the current track to the best estimate
Matrix q0 = new Matrix(p.getCartesianArray(), 3);
SpacePoint x = _swimmer.getPointAtLength(alpha);
- Matrix A_k = getSpatialDerivativeMatrix(particle.origin(), p, t.getCharge(), B_z);
- Matrix B_k = getMomentumDerivativeMatrix(particle.origin(), p, t.getCharge(), B_z);
+ Matrix A_k = getSpatialDerivativeMatrix(vtxPosition, p, t.getCharge(), B_z);
+ Matrix B_k = getMomentumDerivativeMatrix(vtxPosition, p, t.getCharge(), B_z);
Matrix G_k = t.getErrorMatrix().inverse();
Matrix W_k = B_k.transpose().times(G_k.times(B_k)).uminus();
// the measurement of the track is taken at the POCA to the best estimate
- Matrix m_k = new Matrix(EMap.SpaceMomentum2Parameters(p, x, particle.origin(), t.getCharge(), B_z).getValues(), 5);
+ Matrix m_k = new Matrix(EMap.SpaceMomentum2Parameters(x, p, vtxPosition, t.getCharge(), B_z).getValues(), 5);
Matrix c_k0 = m_k.minus(A_k.times(x_prev).plus(B_k.times(q0)));
-
+ Matrix q_kN = W_k.times(B_k.transpose().times(G_k)).times(m_k.minus(c_k0.plus(A_k.times(x_prev))));
+ SpaceVector updatedMomentum = new CartesianVector(q_kN.getRowPackedCopy());
+ t.updateMomentum(updatedMomentum, vtxPosition, B_z);
if (fullFit) {
- Matrix q_kN = W_k.times(B_k.transpose().times(G_k)).times(m_k.minus(c_k0.plus(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();
}
-
- return 0;
}
// // returns y = A.x
lcsim/src/org/lcsim/contrib/JanStrube/vtxFitter
diff -u -r1.5 -r1.6
--- Vertex.java 29 Aug 2006 19:50:20 -0000 1.5
+++ Vertex.java 14 Oct 2006 08:45:23 -0000 1.6
@@ -1,7 +1,9 @@
package org.lcsim.contrib.JanStrube.vtxFitter;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -17,9 +19,9 @@
import Jama.Matrix;
public class Vertex {
- SpacePoint _origin;
- SpacePoint _originError;
- Map<Track, Double> _tracks;
+ SpacePoint _location;
+ SpacePoint _locationError;
+ Map<VtxTrack, Double> _tracks;
double _chi2;
double _ndf;
@@ -28,40 +30,57 @@
Matrix _momentumCovarianceMatrix;
public Vertex() {
- _origin = new SpacePoint();
- _originError = new SpacePoint();
- _tracks = new HashMap<Track, Double>();
+ _location = new SpacePoint();
+ _locationError = new SpacePoint();
+ _tracks = new HashMap<VtxTrack, Double>();
+ }
+
+ public Vertex(Collection<Track> tracks, SpacePoint initialPos) {
+ this();
+ setTracks(tracks);
+ _location = initialPos;
}
- public void setOrigin(SpacePoint x) {
- _origin = x;
+ public void setLocation(SpacePoint x) {
+ _location = x;
}
- public SpacePoint origin() {
- return _origin;
+ public SpacePoint location() {
+ return _location;
}
- public void addTrack(Track t, double chi2) {
+ void addTrack(VtxTrack t, double chi2) {
_tracks.put(t, chi2);
}
- public void setTracks(Map<Track, Double> tracks) {
+ void setTracks(Map<VtxTrack, Double> tracks) {
_tracks = tracks;
}
- public void setTracks(List<Track> tracks) {
- _tracks.clear();
- for (Track t : tracks) {
- _tracks.put(t, 0.);
- }
+ void setTracks(Collection<Track> tracks) {
+ for (Track t : tracks) {
+ addTrack(new VtxTrack(t), 1000);
+ }
}
+// public void setTracks(List<Track> tracks) {
+// _tracks.clear();
+// for (Track t : tracks) {
+// _tracks.put(t, 0.);
+// }
+// }
+
public double getChi2() {
return _chi2;
}
- public void setChi2(double chi2) {
+ public void setMaxChi2(double chi2) {
_chi2 = chi2;
+ for (Track t : _tracks.keySet()) {
+ if (_tracks.get(t) > _chi2) {
+ _tracks.remove(t);
+ }
+ }
}
public double getNdf() {
@@ -72,9 +91,18 @@
_ndf = ndf;
}
- public Set<Track> getTracks() {
+ public Set<VtxTrack> getVtxTracks() {
return _tracks.keySet();
}
+
+ public Set<Track> getTracks() {
+ Set<Track> set = new HashSet<Track>();
+ for (Track t : _tracks.keySet()) {
+ set.add(t);
+ }
+ return set;
+ }
+
/**
* @return The full covarianceMatrix.
lcsim/src/org/lcsim/contrib/JanStrube/zvtop
diff -u -r1.1 -r1.2
--- ZvTop.java 9 Oct 2006 17:25:27 -0000 1.1
+++ ZvTop.java 14 Oct 2006 08:45:23 -0000 1.2
@@ -31,7 +31,7 @@
* Main class to handle the vertexing Vertices are found by the function
* @see #findVertices(List)
* @author jstrube
- * @version $Id: ZvTop.java,v 1.1 2006/10/09 17:25:27 jstrube Exp $
+ * @version $Id: ZvTop.java,v 1.2 2006/10/14 08:45:23 jstrube Exp $
*/
public class ZvTop {
/**
@@ -69,6 +69,20 @@
}
+ /*
+ * ZVTOP groups overlaps that cannot be resolved.
+ * This class holds for each of those clusters the set of tracks associated with them
+ * as well as the position of the overlap with the highest value
+ */
+ private class TrackCluster {
+ public Set<Track> tracks;
+ public SpacePoint position;
+ public TrackCluster(Set<Track> t, SpacePoint p) {
+ tracks = t;
+ position = p;
+ }
+ }
+
// if a two-track overlap is less than this cut, do not add max to the list
private double _globalOverlapCut = 1E-10;
private SpaceVector _jetAxis;
@@ -83,7 +97,7 @@
// The fitVertices function takes care of assigning tracks uniquely to a
// vertex.
// TODO need to distinguish between pruning and fitting
- private List<Vertex> _vertexCandidateList;
+ private List<TrackCluster> _vertexCandidateList;
// Special weight for the angle of the spatial point (argument of overlap)
// wrt. the jet axis
private double angularWeight = 5;
@@ -127,7 +141,7 @@
isResolvedFromMap = new HashMap<ZvMaximum, Set<ZvMaximum>>();
unresolvedMaximaMap = new HashMap<ZvMaximum, Set<ZvMaximum>>();
trackList = new ArrayList<Track>();
- _vertexCandidateList = new ArrayList<Vertex>();
+ _vertexCandidateList = new ArrayList<TrackCluster>();
vtxFitter = f;
return;
}
@@ -220,13 +234,12 @@
Set<ZvMaximum> unresolvedSet = unresolvedMaximaMap
.get(highestRemaining);
unresolvedSet.add(highestRemaining);
- Vertex vtx = new Vertex();
Set<Track> tracks = new HashSet<Track>();
for (ZvMaximum imax : unresolvedSet) {
tracks.add(imax.getTrack_i());
tracks.add(imax.getTrack_j());
}
- _vertexCandidateList.add(vtx);
+ _vertexCandidateList.add(new TrackCluster(tracks, highestRemaining.getLocation()));
isAvailable.removeAll(unresolvedSet);
}
// System.err.printf("done clusterCandidates: %d Candidates",
@@ -399,27 +412,26 @@
List<Vertex> l = new ArrayList<Vertex>();
Set<Track> unavailableTracks = new HashSet<Track>();
// System.err.printf("found %d Candidates\n", _vertexCandidateList.size());
- for (Vertex iCand : _vertexCandidateList) {
+// for (Set<Track> iCand : _vertexCandidateList) {
// System.err.printf(iCand.toString());
- }
+// }
// The Maxima are clustered according to the resolution function
// A Cluster is a Set of ZvMaxima
// Add all tracks from a cluster to the vertex
// The vertex decides based on the chiSquared value
// which of those tracks it wants to keep
- for (Vertex iVtx : _vertexCandidateList) {
+ for (TrackCluster iVtx : _vertexCandidateList) {
// System.out.println("using chi2 cut of " + chiSquareCut);
- iVtx.setChi2(chiSquareCut);
for (Track t : unavailableTracks) {
- iVtx.removeTrack(t);
+ iVtx.tracks.remove(t);
}
// FIXME using a vertex as the container isn't so good
// because a) tracks can drop out
// so that a newly created vertex should be returned...
// that makes for messy bookkeeping
- vtxFitter.fit(iVtx.getTracks(), iVtx.origin());
- l.add(iVtx);
- unavailableTracks.addAll(iVtx.getTracks());
+ Vertex v = vtxFitter.fit(iVtx.tracks, iVtx.position);
+ l.add(v);
+ unavailableTracks.addAll(v.getTracks());
}
return l;
}
lcsim/src/org/lcsim/recon/vertexing/zvtop4
diff -u -r1.14 -r1.15
--- VectorArithmetic.java 10 Sep 2006 11:47:43 -0000 1.14
+++ VectorArithmetic.java 14 Oct 2006 08:45:24 -0000 1.15
@@ -14,7 +14,7 @@
/**
* Class to perform basic vector arithmetic on Hep3Vectors
* @author jstrube
- * @version $Id: VectorArithmetic.java,v 1.14 2006/09/10 11:47:43 jstrube Exp $
+ * @version $Id: VectorArithmetic.java,v 1.15 2006/10/14 08:45:24 jstrube Exp $
*/
final public class VectorArithmetic {
@@ -96,8 +96,8 @@
* @param b SpacePoint 2
* @return a-b
*/
- public static SpacePoint subtract(SpacePoint a, SpacePoint b) {
- return new CartesianPoint(a.x() - b.x(), a.y() - b.y(), a.z() - b.z());
+ public static SpaceVector subtract(SpacePoint a, SpacePoint b) {
+ return new CartesianVector(a.x() - b.x(), a.y() - b.y(), a.z() - b.z());
}
public static double[] subtract(double[] a, double[] b) {
@@ -189,9 +189,9 @@
* @param v the direction
* @return a SpacePoint at the and of the unit vector
*/
- public static Hep3Vector unit(Hep3Vector v) {
+ public static SpaceVector unit(Hep3Vector v) {
double mag = v.magnitude();
- return new BasicHep3Vector(v.x() / mag, v.y() / mag, v.z() / mag);
+ return new CartesianVector(v.x() / mag, v.y() / mag, v.z() / mag);
}
/**
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.1 -r1.2
--- EMapTest.java 10 Sep 2006 11:47:41 -0000 1.1
+++ EMapTest.java 14 Oct 2006 08:45:24 -0000 1.2
@@ -25,7 +25,7 @@
SpacePoint ref2 = new CartesianPoint(-1, -2, -30);
for (int charge=-2; charge<3; charge++) {
for (double field=-5; field<5.1; field += 0.5) {
- EMap parms = EMap.SpaceMomentum2Parameters(mom, pos, pos, charge, field);
+ EMap parms = EMap.SpaceMomentum2Parameters(pos, mom, pos, charge, field);
assertEquals(pos, EMap.Parameters2Position(parms, pos));
assertEquals(mom, EMap.Parameters2Momentum(parms));
}
@@ -38,7 +38,7 @@
SpacePoint location = new CartesianPoint(1, 0, 0);
SpaceVector mom = new CartesianVector(0, -1, 1);
SpacePoint zero = new SpacePoint();
- EMap params = EMap.SpaceMomentum2Parameters(mom, location, zero, 1, field);
+ EMap params = EMap.SpaceMomentum2Parameters(location, mom, zero, 1, field);
assertEquals(params.pt, 1.0);
assertEquals(params.get(ParameterName.z0), 0.0);
assertEquals(params.get(ParameterName.d0), 1.0);
@@ -47,7 +47,7 @@
// The reference point has to be on the y axis
SpacePoint refPoint = new CartesianPoint(-20, 0, -60);
- EMap params2 = EMap.SpaceMomentum2Parameters(mom, location, refPoint, -1, -field);
+ EMap params2 = EMap.SpaceMomentum2Parameters(location, mom, refPoint, -1, -field);
assertEquals(params2.pt, 1.0);
assertEquals(params2.get(ParameterName.z0), 60.0);
@@ -64,7 +64,7 @@
SpaceVector mom = new CartesianVector(1, 0, 2);
// make sure it's the same y as the location
SpacePoint refPoint = new CartesianPoint(3.6, 9.2, -11.7);
- EMap params = EMap.SpaceMomentum2Parameters(mom, location, refPoint, charge, field);
+ EMap params = EMap.SpaceMomentum2Parameters(location, mom, refPoint, charge, field);
assertEquals(params.get(ParameterName.phi0), 0, 1e-15);
assertEquals(params.get(ParameterName.d0), -4.5, 1e-10);
SpaceVector newMom = EMap.Parameters2Momentum(params);
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.2 -r1.3
--- NewTrackTest.java 10 Sep 2006 11:47:40 -0000 1.2
+++ NewTrackTest.java 14 Oct 2006 08:45:24 -0000 1.3
@@ -1,5 +1,5 @@
/**
- * @version $Id: NewTrackTest.java,v 1.2 2006/09/10 11:47:40 jstrube Exp $
+ * @version $Id: NewTrackTest.java,v 1.3 2006/10/14 08:45:24 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.tracking;
@@ -126,7 +126,7 @@
SpacePoint newPos1 = t.getPosition();
SpaceVector newMom1 = t.getMomentum();
- EMap parms = EMap.SpaceMomentum2Parameters(newMom1, newPos1, ref1, charge, _Bz);
+ EMap parms = EMap.SpaceMomentum2Parameters(newPos1, newMom1, ref1, charge, _Bz);
assertEquals(t.getPosition(), EMap.Parameters2Position(parms, ref1));
assertEquals(t.getMomentum(), EMap.Parameters2Momentum(parms));
// lazy method for comparison
CVSspam 0.2.8