5 added + 5 removed + 8 modified, total 18 files
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -N FastMCTrackTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FastMCTrackTest.java 19 Feb 2007 21:07:55 -0000 1.1
@@ -0,0 +1,141 @@
+/**
+ * @version $Id: FastMCTrackTest.java,v 1.1 2007/02/19 21:07:55 jstrube Exp $
+ */
+package org.lcsim.contrib.JanStrube.tracking;
+
+import java.util.Random;
+
+import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.CartesianVector;
+import org.lcsim.spacegeom.SpacePoint;
+import org.lcsim.spacegeom.SpaceVector;
+
+import junit.framework.TestCase;
+
+/**
+ * @author jstrube
+ *
+ */
+public class FastMCTrackTest extends TestCase {
+
+ private FastMCTrackFactory factory;
+ private Track t;
+ private static final double _Bz = 5.;
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new FastMCTrackFactory("sidaug05", _Bz, true);
+ SpaceVector momentum = new CartesianVector(1, 1, 1);
+ SpacePoint location = new CartesianPoint(1, 2, 3);
+ t = factory.getTrack(momentum, location, 1);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewTrack#getPt()}.
+ * Testing equality of pt for different initializations of the track.
+ * Notable is that different values of the charge are tested.
+ */
+ public void testGetPt() {
+ SpacePoint location = new CartesianPoint(0, 0, 0);
+ SpaceVector momentum = new CartesianVector(1, 1, 1);
+ SpacePoint referencePoint = new SpacePoint();
+ int charge = 1;
+ // don't smear tracks
+ t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
+ assertEquals(t.getPt(), momentum.rxy(), 1e-10);
+
+ location = new CartesianPoint(1, 2, 3);
+ momentum = new CartesianVector(-1, -1, -1);
+ charge = 2;
+ // don't smear tracks
+ t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
+ assertEquals(t.getPt(), momentum.rxy(), 1e-10);
+
+ location = new CartesianPoint(-1, -2, -3);
+ momentum = new CartesianVector(-1, -1, -1);
+ charge = -1;
+ // don't smear tracks
+ t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
+ assertEquals(t.getPt(), momentum.rxy(), 1e-10);
+
+ location = new CartesianPoint(1, 2, 3);
+ momentum = new CartesianVector(-2, -1, 1);
+ charge = -2;
+ // don't smear tracks
+ t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
+ assertEquals(t.getPt(), momentum.rxy(), 1e-10);
+ }
+
+ /**
+ * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewTrack#getCharge()}.
+ */
+ public void testGetCharge() {
+ SpacePoint location = new CartesianPoint(0, 0, 0);
+ SpacePoint momentum = new CartesianPoint(1, 1, 1);
+ t = factory.getTrack(momentum, location, -2);
+ assertEquals(t.getCharge(), -2);
+ t = factory.getTrack(momentum, location, -1);
+ assertEquals(t.getCharge(), -1);
+ t = factory.getTrack(momentum, location, 1);
+ assertEquals(t.getCharge(), 1);
+ t = factory.getTrack(momentum, location, 2);
+ assertEquals(t.getCharge(), 2);
+ }
+
+ /**
+ * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewTrack#getReferencePoint()}.
+ */
+ public void testGetReferencePoint() {
+ SpacePoint location = new CartesianPoint(1, 2, 3);
+ SpaceVector momentum = new CartesianVector(1, 1, 1);
+ SpacePoint referencePoint = new CartesianPoint(0, 0, 0);
+ t = factory.getTrack(momentum, location, referencePoint, -2);
+ assertEquals(t.getReferencePoint(), referencePoint);
+
+ referencePoint = new CartesianPoint(1, 2, 3);
+ t = factory.getTrack(momentum, location, referencePoint, -2);
+ assertEquals(t.getReferencePoint(), referencePoint);
+
+ referencePoint = new CartesianPoint(-2, -3, -4);
+ t = factory.getTrack(momentum, location,referencePoint, -2);
+ assertEquals(t.getReferencePoint(), referencePoint);
+
+ referencePoint = new CartesianPoint(1, 0, 7);
+ t = factory.getTrack(momentum, location, referencePoint, -2);
+ assertEquals(t.getReferencePoint(), referencePoint);
+ }
+
+ public void testParameterConversion() {
+ SpacePoint pos = new CartesianPoint(3, 2, 1);
+ SpaceVector mom = new CartesianVector(4, 20, -9);
+ SpacePoint ref1 = new SpacePoint();
+ SpacePoint ref2 = new CartesianPoint(-1, -2, -30);
+
+ // case 3 need to swim parameters. Easy case ref-point == 0,0,0
+ int charge = 1;
+ Track t = factory.getTrack(mom, pos, ref1, charge, new Random(), false);
+ SpacePoint newPos1 = t.getPosition();
+ SpaceVector newMom1 = t.getMomentum();
+
+ LCIOTrackParameters parms = LCIOTrackParameters.SpaceMomentum2Parameters(newPos1, newMom1, ref1, charge, _Bz);
+ assertEquals(t.getPosition(), LCIOTrackParameters.Parameters2Position(parms, ref1));
+ assertEquals(t.getMomentum(), LCIOTrackParameters.Parameters2Momentum(parms));
+ // lazy method for comparison
+ assertEquals(t.getParameters().toString(), parms.toString());
+ }
+
+ void assertEquals(SpacePoint a, SpacePoint b) {
+ assertEquals(a.x(), b.x(), 1e-10);
+ assertEquals(a.y(), b.y(), 1e-10);
+ assertEquals(a.z(), b.z(), 1e-10);
+ }
+}
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -N FastMCTrackFactoryTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FastMCTrackFactoryTest.java 19 Feb 2007 21:07:55 -0000 1.1
@@ -0,0 +1,71 @@
+/**
+ * @version $Id: FastMCTrackFactoryTest.java,v 1.1 2007/02/19 21:07:55 jstrube Exp $
+ */
+package org.lcsim.contrib.JanStrube.tracking;
+
+import java.util.Random;
+
+import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.CartesianVector;
+import org.lcsim.spacegeom.SpacePoint;
+import org.lcsim.spacegeom.SpaceVector;
+
+import junit.framework.TestCase;
+
+/**
+ * @author jstrube
+ *
+ */
+public class FastMCTrackFactoryTest extends TestCase {
+
+ private FastMCTrackFactory fac;
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ fac = new FastMCTrackFactory("sidaug05", 5., false);
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory#getTrack(org.lcsim.spacegeom.SpacePoint, org.lcsim.spacegeom.SpacePoint, int)}.
+ */
+ public void testGetTrackSpacePointSpacePointInt() {
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory#getTrack(org.lcsim.spacegeom.SpacePoint, org.lcsim.spacegeom.SpacePoint, org.lcsim.spacegeom.SpacePoint, int, java.util.Random, boolean)}.
+ */
+ public void testGetTrackSpacePointSpacePointSpacePointIntRandomBoolean() {
+ SpacePoint position = new CartesianPoint(-0.8481597943013419, 0.14788226349232936, -0.698255181312561);
+ SpaceVector momentum = new CartesianVector(-18.58944945449937, 4.932838972376678, -8.631586722626338);
+ SpacePoint refPoint = new SpacePoint();
+ Track t = fac.getTrack(momentum, position, refPoint, -1, new Random(), false);
+ SpacePoint track_momentum = LCIOTrackParameters.Parameters2Momentum(t.getParameters());
+// assertEquals(momentum.theta(), track_momentum.theta());
+ HelixSwimmer swimmer = new HelixSwimmer(5);
+ swimmer.setTrack(t);
+ assertEquals(swimmer.getTrackLengthToPoint(refPoint), 0, 1e-10);
+ double alpha = swimmer.getTrackLengthToPoint(position);
+ SpacePoint newPos = swimmer.getPointAtLength(alpha);
+ SpacePoint newMom = swimmer.getMomentumAtLength(alpha);
+ assertEquals(t.getPosition(), LCIOTrackParameters.Parameters2Position(t.getParameters(), refPoint), 1e-10);
+ assertEquals(newPos, position, 1e-10);
+ assertEquals(newMom, momentum, 1e-10);
+ }
+
+ void assertEquals(SpacePoint a, SpacePoint b, double precision) {
+ assertEquals(a.x(), b.x(), precision);
+ assertEquals(a.y(), b.y(), precision);
+ assertEquals(a.z(), b.z(), precision);
+ }
+
+}
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.9 -r1.10
--- HelixSwimmerTrackConsistencyTest.java 28 Oct 2006 00:48:54 -0000 1.9
+++ HelixSwimmerTrackConsistencyTest.java 19 Feb 2007 21:07:55 -0000 1.10
@@ -1,5 +1,5 @@
/**
- * @version $Id: HelixSwimmerTrackConsistencyTest.java,v 1.9 2006/10/28 00:48:54 jstrube Exp $
+ * @version $Id: HelixSwimmerTrackConsistencyTest.java,v 1.10 2007/02/19 21:07:55 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.tracking;
@@ -8,7 +8,7 @@
import org.lcsim.constants.Constants;
import org.lcsim.contrib.JanStrube.tracking.HelixSwimmer;
-import org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.recon.vertexing.zvtop4.VectorArithmetic;
import org.lcsim.spacegeom.CartesianPoint;
@@ -32,14 +32,14 @@
private HelixSwimmer swimmerRaw;
private HelixSwimmer swimmerTrack;
- private NewFastMCTrackFactory factory;
+ private FastMCTrackFactory factory;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
swimmerRaw = new HelixSwimmer(5.);
- factory = new NewFastMCTrackFactory("sidaug05", 5., true);
+ factory = new FastMCTrackFactory("sidaug05", 5., true);
swimmerTrack = new HelixSwimmer(5.);
}
// Tests on some easy geometries
@@ -227,7 +227,7 @@
/**
* Creates a new Track t1 with a momentum and position constructor.
- * Creates a NewTrack t2 with the 5 parameter vector of t1.
+ * Creates a FastMCTrack t2 with the 5 parameter vector of t1.
* Compares Position and momentum of t2 with t1.
* Can't compare with position and momentum that was used to construct t1 directly,
* because the helix is swum to the POCA first.
@@ -249,7 +249,7 @@
tp.set(LCIOTrackParameters.ParameterName.z0, t.getParameter(LCIOTrackParameters.ParameterName.z0));
// we don't need an error matrix for this test
- NewTrack t1 = new NewTrack(referencePoint, tp, new SymmetricMatrix(5), charge);
+ FastMCTrack t1 = new FastMCTrack(referencePoint, tp, new SymmetricMatrix(5), charge);
swimmerRaw.setTrack(t);
swimmerTrack.setTrack(t1);
for (double alpha=-20; alpha <=20; alpha+=0.05) {
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -u -r1.4 -r1.5
--- FitterTest.java 10 Sep 2006 11:47:40 -0000 1.4
+++ FitterTest.java 19 Feb 2007 21:07:55 -0000 1.5
@@ -7,7 +7,7 @@
import junit.framework.TestCase;
-import org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory;
import org.lcsim.contrib.JanStrube.vtxFitter.Fitter;
import org.lcsim.contrib.JanStrube.vtxFitter.Vertex;
import org.lcsim.spacegeom.CartesianPoint;
@@ -45,7 +45,7 @@
public void testFit() {
List<Track> tracks = new ArrayList<Track>();
- NewFastMCTrackFactory fac = new NewFastMCTrackFactory("sidaug05", 5., false);
+ FastMCTrackFactory fac = new FastMCTrackFactory("sidaug05", 5., false);
SpacePoint pos = new CartesianPoint(0, 0, 0);
SpaceVector mom1 = new CartesianVector(1, 2, 3);
SpaceVector mom2 = new CartesianVector(2, -2, 1.5);
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -N NewTrackTest.java
--- NewTrackTest.java 28 Oct 2006 00:48:53 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,141 +0,0 @@
-/**
- * @version $Id: NewTrackTest.java,v 1.4 2006/10/28 00:48:53 jstrube Exp $
- */
-package org.lcsim.contrib.JanStrube.tracking;
-
-import java.util.Random;
-
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.CartesianVector;
-import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.spacegeom.SpaceVector;
-
-import junit.framework.TestCase;
-
-/**
- * @author jstrube
- *
- */
-public class NewTrackTest extends TestCase {
-
- private NewFastMCTrackFactory factory;
- private Track t;
- private static final double _Bz = 5.;
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- factory = new NewFastMCTrackFactory("sidaug05", _Bz, true);
- SpaceVector momentum = new CartesianVector(1, 1, 1);
- SpacePoint location = new CartesianPoint(1, 2, 3);
- t = factory.getTrack(momentum, location, 1);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewTrack#getPt()}.
- * Testing equality of pt for different initializations of the track.
- * Notable is that different values of the charge are tested.
- */
- public void testGetPt() {
- SpacePoint location = new CartesianPoint(0, 0, 0);
- SpaceVector momentum = new CartesianVector(1, 1, 1);
- SpacePoint referencePoint = new SpacePoint();
- int charge = 1;
- // don't smear tracks
- t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
- assertEquals(t.getPt(), momentum.rxy(), 1e-10);
-
- location = new CartesianPoint(1, 2, 3);
- momentum = new CartesianVector(-1, -1, -1);
- charge = 2;
- // don't smear tracks
- t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
- assertEquals(t.getPt(), momentum.rxy(), 1e-10);
-
- location = new CartesianPoint(-1, -2, -3);
- momentum = new CartesianVector(-1, -1, -1);
- charge = -1;
- // don't smear tracks
- t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
- assertEquals(t.getPt(), momentum.rxy(), 1e-10);
-
- location = new CartesianPoint(1, 2, 3);
- momentum = new CartesianVector(-2, -1, 1);
- charge = -2;
- // don't smear tracks
- t = factory.getTrack(momentum, location, referencePoint, charge, new Random(), false);
- assertEquals(t.getPt(), momentum.rxy(), 1e-10);
- }
-
- /**
- * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewTrack#getCharge()}.
- */
- public void testGetCharge() {
- SpacePoint location = new CartesianPoint(0, 0, 0);
- SpacePoint momentum = new CartesianPoint(1, 1, 1);
- t = factory.getTrack(momentum, location, -2);
- assertEquals(t.getCharge(), -2);
- t = factory.getTrack(momentum, location, -1);
- assertEquals(t.getCharge(), -1);
- t = factory.getTrack(momentum, location, 1);
- assertEquals(t.getCharge(), 1);
- t = factory.getTrack(momentum, location, 2);
- assertEquals(t.getCharge(), 2);
- }
-
- /**
- * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewTrack#getReferencePoint()}.
- */
- public void testGetReferencePoint() {
- SpacePoint location = new CartesianPoint(1, 2, 3);
- SpaceVector momentum = new CartesianVector(1, 1, 1);
- SpacePoint referencePoint = new CartesianPoint(0, 0, 0);
- t = factory.getTrack(momentum, location, referencePoint, -2);
- assertEquals(t.getReferencePoint(), referencePoint);
-
- referencePoint = new CartesianPoint(1, 2, 3);
- t = factory.getTrack(momentum, location, referencePoint, -2);
- assertEquals(t.getReferencePoint(), referencePoint);
-
- referencePoint = new CartesianPoint(-2, -3, -4);
- t = factory.getTrack(momentum, location,referencePoint, -2);
- assertEquals(t.getReferencePoint(), referencePoint);
-
- referencePoint = new CartesianPoint(1, 0, 7);
- t = factory.getTrack(momentum, location, referencePoint, -2);
- assertEquals(t.getReferencePoint(), referencePoint);
- }
-
- public void testParameterConversion() {
- SpacePoint pos = new CartesianPoint(3, 2, 1);
- SpaceVector mom = new CartesianVector(4, 20, -9);
- SpacePoint ref1 = new SpacePoint();
- SpacePoint ref2 = new CartesianPoint(-1, -2, -30);
-
- // case 3 need to swim parameters. Easy case ref-point == 0,0,0
- int charge = 1;
- Track t = factory.getTrack(mom, pos, ref1, charge, new Random(), false);
- SpacePoint newPos1 = t.getPosition();
- SpaceVector newMom1 = t.getMomentum();
-
- LCIOTrackParameters parms = LCIOTrackParameters.SpaceMomentum2Parameters(newPos1, newMom1, ref1, charge, _Bz);
- assertEquals(t.getPosition(), LCIOTrackParameters.Parameters2Position(parms, ref1));
- assertEquals(t.getMomentum(), LCIOTrackParameters.Parameters2Momentum(parms));
- // lazy method for comparison
- assertEquals(t.getParameters().toString(), parms.toString());
- }
-
- void assertEquals(SpacePoint a, SpacePoint b) {
- assertEquals(a.x(), b.x(), 1e-10);
- assertEquals(a.y(), b.y(), 1e-10);
- assertEquals(a.z(), b.z(), 1e-10);
- }
-}
lcsim/test/org/lcsim/contrib/JanStrube/tracking
diff -N NewFastMCTrackFactoryTest.java
--- NewFastMCTrackFactoryTest.java 28 Oct 2006 00:48:55 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-/**
- * @version $Id: NewFastMCTrackFactoryTest.java,v 1.2 2006/10/28 00:48:55 jstrube Exp $
- */
-package org.lcsim.contrib.JanStrube.tracking;
-
-import java.util.Random;
-
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.CartesianVector;
-import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.spacegeom.SpaceVector;
-
-import junit.framework.TestCase;
-
-/**
- * @author jstrube
- *
- */
-public class NewFastMCTrackFactoryTest extends TestCase {
-
- private NewFastMCTrackFactory fac;
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- fac = new NewFastMCTrackFactory("sidaug05", 5., false);
- super.setUp();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory#getTrack(org.lcsim.spacegeom.SpacePoint, org.lcsim.spacegeom.SpacePoint, int)}.
- */
- public void testGetTrackSpacePointSpacePointInt() {
-// fail("Not yet implemented");
- }
-
- /**
- * Test method for {@link org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory#getTrack(org.lcsim.spacegeom.SpacePoint, org.lcsim.spacegeom.SpacePoint, org.lcsim.spacegeom.SpacePoint, int, java.util.Random, boolean)}.
- */
- public void testGetTrackSpacePointSpacePointSpacePointIntRandomBoolean() {
- SpacePoint position = new CartesianPoint(-0.8481597943013419, 0.14788226349232936, -0.698255181312561);
- SpaceVector momentum = new CartesianVector(-18.58944945449937, 4.932838972376678, -8.631586722626338);
- SpacePoint refPoint = new SpacePoint();
- Track t = fac.getTrack(momentum, position, refPoint, -1, new Random(), false);
- SpacePoint track_momentum = LCIOTrackParameters.Parameters2Momentum(t.getParameters());
-// assertEquals(momentum.theta(), track_momentum.theta());
- HelixSwimmer swimmer = new HelixSwimmer(5);
- swimmer.setTrack(t);
- assertEquals(swimmer.getTrackLengthToPoint(refPoint), 0, 1e-10);
- double alpha = swimmer.getTrackLengthToPoint(position);
- SpacePoint newPos = swimmer.getPointAtLength(alpha);
- SpacePoint newMom = swimmer.getMomentumAtLength(alpha);
- assertEquals(t.getPosition(), LCIOTrackParameters.Parameters2Position(t.getParameters(), refPoint), 1e-10);
- assertEquals(newPos, position, 1e-10);
- assertEquals(newMom, momentum, 1e-10);
- }
-
- void assertEquals(SpacePoint a, SpacePoint b, double precision) {
- assertEquals(a.x(), b.x(), precision);
- assertEquals(a.y(), b.y(), precision);
- assertEquals(a.z(), b.z(), precision);
- }
-
-}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -N FastMCTrack.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FastMCTrack.java 19 Feb 2007 21:07:56 -0000 1.1
@@ -0,0 +1,92 @@
+/**
+ * @version $Id: FastMCTrack.java,v 1.1 2007/02/19 21:07:56 jstrube Exp $
+ */
+package org.lcsim.contrib.JanStrube.tracking;
+
+import hep.physics.matrix.SymmetricMatrix;
+
+import org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName;
+import org.lcsim.spacegeom.CartesianPoint;
+import org.lcsim.spacegeom.SpacePoint;
+import org.lcsim.spacegeom.SpaceVector;
+import static java.lang.Math.sqrt;
+
+
+/**
+ * @author jstrube
+ * The class to store the measurement information of the track of a charged particle in a magnetic field.
+ * This class represents the FastMC simulation.
+ * An invariant of this class is that the "origin" is the point of closest approach to the reference point.
+ */
+public class FastMCTrack implements Track {
+ protected LCIOTrackParameters _parameters;
+ protected SymmetricMatrix _errorMatrix;
+ protected SpacePoint _referencePoint;
+ protected int _charge;
+
+ protected FastMCTrack() {
+ _parameters = new LCIOTrackParameters();
+ _errorMatrix = new SymmetricMatrix(5);
+ }
+
+ public FastMCTrack(org.lcsim.event.Track t) {
+ double[] p = t.getMomentum();
+ double pt = sqrt(p[0]*p[0] + p[1]*p[1]);
+ _parameters = new LCIOTrackParameters(t.getTrackParameters(), pt);
+ _errorMatrix = t.getErrorMatrix();
+ _referencePoint = new CartesianPoint(t.getReferencePoint());
+ _charge = t.getCharge();
+ }
+
+ protected FastMCTrack(SpacePoint refPoint, LCIOTrackParameters parameters, SymmetricMatrix errorMatrix, int charge) {
+ _referencePoint = refPoint;
+ _parameters = parameters;
+ _charge = charge;
+ _errorMatrix = errorMatrix;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lcsim.contrib.JanStrube.tracking.Track#getParameter(org.lcsim.contrib.JanStrube.tracking.FastMCTrack.ParameterName)
+ */
+ public double getParameter(ParameterName name) {
+ return _parameters.get(name);
+ }
+ /* (non-Javadoc)
+ * @see org.lcsim.contrib.JanStrube.tracking.Track#getParameters()
+ */
+ public LCIOTrackParameters getParameters() {
+ return _parameters;
+ }
+ /* (non-Javadoc)
+ * @see org.lcsim.contrib.JanStrube.tracking.Track#getPt()
+ */
+ public double getPt() {
+ return _parameters.pt;
+ }
+ /* (non-Javadoc)
+ * @see org.lcsim.contrib.JanStrube.tracking.Track#getCharge()
+ */
+ public int getCharge() {
+ return _charge;
+ }
+ /* (non-Javadoc)
+ * @see org.lcsim.contrib.JanStrube.tracking.Track#getReferencePoint()
+ */
+ public SpacePoint getReferencePoint() {
+ return _referencePoint;
+ }
+ /* (non-Javadoc)
+ * @see org.lcsim.contrib.JanStrube.tracking.Track#getErrorMatrix()
+ */
+ public SymmetricMatrix getErrorMatrix() {
+ return _errorMatrix;
+ }
+
+ public SpacePoint getPosition() {
+ return LCIOTrackParameters.Parameters2Position(_parameters, _referencePoint);
+ }
+
+ public SpaceVector getMomentum() {
+ return LCIOTrackParameters.Parameters2Momentum(_parameters);
+ }
+}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -N FastMCTrackDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FastMCTrackDriver.java 19 Feb 2007 21:07:56 -0000 1.1
@@ -0,0 +1,112 @@
+/**
+ * @version $Id: FastMCTrackDriver.java,v 1.1 2007/02/19 21:07:56 jstrube Exp $
+ */
+package org.lcsim.contrib.JanStrube.tracking;
+
+import hep.physics.particle.Particle;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.conditions.ConditionsEvent;
+import org.lcsim.conditions.ConditionsListener;
+import org.lcsim.conditions.ConditionsSet;
+import org.lcsim.event.EventHeader;
+import org.lcsim.mc.fast.tracking.SimpleTables;
+import org.lcsim.mc.fast.tracking.TrackResolutionTables;
+import org.lcsim.util.Driver;
+
+/**
+ * A replacement for the current FastMC Tracks.
+ * The simple tables are currently not implemented
+ * @author jstrube
+ *
+ */
+public class FastMCTrackDriver extends Driver implements ConditionsListener {
+ private TrackResolutionTables parm;
+ private SimpleTables SmTbl;
+ private boolean beamSpotConstraint;
+ private boolean simple;
+ private final static double[] IP = { 0, 0, 0 };
+
+ public FastMCTrackDriver(boolean beamSpotConstraint)
+ {
+ this.beamSpotConstraint = beamSpotConstraint;
+ }
+
+ public FastMCTrackDriver() {
+ this(false);
+ }
+
+ protected void process(EventHeader event) {
+ if (parm == null) {
+ ConditionsSet conditions = getConditionsManager().getConditions("TrackParameters");
+ conditions.addConditionsListener(this);
+ parm = setTrackResolutionTables(conditions, beamSpotConstraint);
+ }
+
+ if (SmTbl == null) {
+ ConditionsSet conditions = getConditionsManager().getConditions("SimpleTrack");
+ conditions.addConditionsListener(this);
+ SmTbl = new SimpleTables(conditions);
+ }
+
+ FastMCTrackFactory factory = new FastMCTrackFactory(event, beamSpotConstraint);
+
+ double bField = event.getDetector().getFieldMap().getField(IP)[2];
+ boolean hist = getHistogramLevel() > 0;
+
+ List<org.lcsim.event.Track> trackList = new ArrayList<org.lcsim.event.Track>();
+ List<Track> newTrackList = new ArrayList<Track>();
+ for (Particle p : event.getMCParticles()) {
+ // filter for FINAL_STATE
+ if (p.getGeneratorStatus() != Particle.FINAL_STATE) {
+ continue;
+ }
+ double pCharge = p.getCharge();
+ if (pCharge == 0
+ || Double.isNaN(pCharge)
+ || pCharge == Double.NEGATIVE_INFINITY
+ || pCharge == Double.POSITIVE_INFINITY) {
+ continue;
+ }
+
+ double[] momentum = p.getMomentum().v();
+ double pt2 = (momentum[0] * momentum[0]) + (momentum[1] * momentum[1]);
+ double pt = Math.sqrt(pt2);
+ double ptot = Math.sqrt(pt2 + (momentum[2] * momentum[2]));
+ double cosTheta = momentum[2] / ptot;
+
+ // within acceptance
+ if (pt < parm.getPtMin()) {
+ continue;
+ }
+ if (Math.abs(cosTheta) > parm.getPolarOuter()) {
+ continue;
+ }
+
+ Track t = factory.getTrack(p.getMomentum(), p.getOrigin(), (int)p.getCharge());
+ org.lcsim.event.Track passpartout = new TransitionalTrack(t);
+ trackList.add(passpartout);
+ newTrackList.add(t);
+ }
+ event.put(EventHeader.TRACKS, newTrackList, Track.class, 0);
+ }
+
+ public void conditionsChanged(ConditionsEvent event) {
+ ConditionsSet conditions = getConditionsManager().getConditions("TrackParameters");
+ ConditionsSet simpleconditions = getConditionsManager().getConditions("SimpleTrack");
+ parm = setTrackResolutionTables(conditions, beamSpotConstraint);
+ SmTbl = new SimpleTables(simpleconditions);
+ }
+
+ private TrackResolutionTables setTrackResolutionTables(ConditionsSet conditions, boolean beamSpotConstraint) {
+ try {
+ return new TrackResolutionTables(conditions, beamSpotConstraint);
+ } catch (IOException x) {
+ throw new RuntimeException("Error reading track resolution tables", x);
+ }
+ }
+
+}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -N FastMCTrackFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FastMCTrackFactory.java 19 Feb 2007 21:07:56 -0000 1.1
@@ -0,0 +1,237 @@
+/**
+ * @version $Id: FastMCTrackFactory.java,v 1.1 2007/02/19 21:07:56 jstrube Exp $
+ */
+package org.lcsim.contrib.JanStrube.tracking;
+
+import Jama.util.Maths;
+import hep.physics.matrix.SymmetricMatrix;
+import static java.lang.Math.PI;
+import static java.lang.Math.abs;
+import static java.lang.Math.atan2;
+import static java.lang.Math.sqrt;
+import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.omega;
+import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.phi0;
+
+import hep.physics.vec.Hep3Vector;
+
+import java.io.IOException;
+import java.util.Random;
+
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsSet;
+import org.lcsim.event.EventHeader;
+import org.lcsim.mc.fast.tracking.ResolutionTable;
+import org.lcsim.mc.fast.tracking.SimpleTables;
+import org.lcsim.mc.fast.tracking.TrackResolutionTables;
+import org.lcsim.spacegeom.SpacePoint;
+import org.lcsim.spacegeom.SpaceVector;
+
+import Jama.EigenvalueDecomposition;
+import Jama.Matrix;
+
+/**
+ * @author jstrube
+ * This class creates a new FastMC Track. It is used as the interface between the track measurement and
+ * the detector. Since Track doesn't know anything about the magnetic field, and the material, it cannot
+ * transport its own parameters. Changing the reference point of a track requires swimming; it is therefore done
+ * in this class.
+ *
+ */
+public class FastMCTrackFactory {
+ private TrackResolutionTables _tables;
+ private SimpleTables _simpleTables;
+ private ConditionsManager _manager;
+ private double _Bz;
+ private HelixSwimmer _swimmer;
+
+ /**
+ * This constructor obtains the necessary information for construction like the field and the resolution tables from
+ * the event.
+ *
+ * @param event The current event
+ * @param beamConstraint A switch to obtain the resolution tables with or without beamconstraint
+ */
+ public FastMCTrackFactory(EventHeader event, boolean beamConstraint) {
+ this(event.getDetectorName(), event.getDetector().getFieldMap().getField(new double[3])[2], beamConstraint);
+ }
+
+ /**
+ * This constructor is only to be used by unit tests. It will instantiate the Factory with a detector name and a
+ * field.
+ *
+ */
+ FastMCTrackFactory(String detectorName, double field, boolean beamConstraint) {
+ _Bz = field;
+ _manager = ConditionsManager.defaultInstance();
+ try {
+ _manager.setDetector(detectorName, 0);
+ } catch (ConditionsManager.ConditionsNotFoundException e) {
+ }
+ ConditionsSet trackParameters = _manager.getConditions("TrackParameters");
+ ConditionsSet simpleTrack = _manager.getConditions("SimpleTrack");
+ try {
+ _tables = new TrackResolutionTables(trackParameters, beamConstraint);
+ _simpleTables = new SimpleTables(simpleTrack);
+ } catch (IOException e) {
+ }
+ _swimmer = new HelixSwimmer(field);
+ }
+
+ /**
+ * Creates a new Track with the given parameters.
+ * See #{@link #getTrack(SpacePoint, SpacePoint, SpacePoint, int, Random)} for details.
+ *
+ * @param momentum The momentum at a given location
+ * @param location The location where the momentum is measured
+ * @param charge The charge of the Particle that created the Track
+ * @return A new NewTFastMCTrackect with the desired properties
+ */
+ public Track getTrack(SpaceVector momentum, SpacePoint location, int charge) {
+ return getTrack(momentum, location, new SpacePoint(), charge, new Random());
+ }
+
+ /**
+ * Creates a new Track with the given parameters.
+ * See #{@link #getTrack(SpacePoint, SpacePoint, SpacePoint, int, Random)} for details.
+ *
+ * @param momentum The momentum at a given location
+ * @param location The location where the momentum is measured
+ * @param charge The charge of the Particle that created the Track
+ * @param random A random generator instance
+ * @return A new NewTrFastMCTrackct with the desired properties
+ */
+ public Track getTrack(SpaceVector momentum, SpacePoint location, int charge, Random random) {
+ return getTrack(momentum, location, new SpacePoint(), charge, random);
+ }
+
+ /**
+ * Creates a new Track with the given parameters.
+ * See #{@link #getTrack(SpacePoint, SpacePoint, SpacePoint, int, Random)} for details.
+ *
+ * @param momentum The momentum at a given location
+ * @param location The location where the momentum is measured
+ * @param referencePoint The point with respect to which the parameters are measured
+ * @param charge The charge of the Particle that created the Track
+ * @return A new NewTrFastMCTrackct with the desired properties
+ */
+ public Track getTrack(SpaceVector momentum, SpacePoint location, SpacePoint referencePoint, int charge) {
+ return getTrack(momentum, location, referencePoint, charge, new Random());
+ }
+
+ /**
+ * This version is only to be used in unit tests.
+ *
+ * @param momentum The momentum at a given location
+ * @param location The location where the momentum is measured
+ * @param referencePoint The point with respect to which the parameters are measured
+ * @param charge The charge of the Particle that created the Track
+ * @param random A random generator instance
+ * @param shouldISmear This parameter switches smearing on/off. It should always be true except in Unit tests.
+ * @return A new NewTracFastMCTrack with the desired properties
+ */
+ public Track getTrack(SpaceVector momentum, SpacePoint location, SpacePoint referencePoint, int charge, Random random, boolean shouldISmear) {
+ _swimmer.setTrack(momentum, location, charge);
+ double alpha = _swimmer.getTrackLengthToPoint(referencePoint);
+ SpacePoint poca = _swimmer.getPointAtLength(alpha);
+ SpaceVector momentumAtPoca = _swimmer.getMomentumAtLength(alpha);
+ LCIOTrackParameters parameters = LCIOTrackParameters.SpaceMomentum2Parameters(poca, momentumAtPoca, referencePoint, charge, _Bz);
+ SymmetricMatrix errorMatrix = new SymmetricMatrix(5);
+ // this sets the measurement error
+ double cosTheta = abs(momentumAtPoca.cosTheta());
+ double p_mag = momentumAtPoca.magnitude();
+ ResolutionTable table = cosTheta < _tables.getPolarInner() ? _tables.getBarrelTable() : _tables
+ .getEndcapTable();
+ for (int i = 0; i < 5; i++ ) {
+ for (int j = 0; j <= i; j++ ) {
+ double iVal = table.findTable(i, j).interpolateVal(cosTheta, p_mag);
+ errorMatrix.setElement(i, j, iVal);
+ }
+ }
+ // it's a bit inefficient to always have this condition here, although it's only used in tests.
+ LCIOTrackParameters smearParams = shouldISmear
+ ? smearParameters(parameters, errorMatrix, random)
+ : parameters;
+
+// System.out.println("Charge: " + charge);
+// System.out.println("TrackFactory: POCA " + poca);
+// System.out.println("TrackFactory: Momentum " + momentumAtPoca);
+// System.out.println("TrackFactory: Parameters: " + smearParams);
+// System.out.println("TrackFactory: POCA from parameters: " + LCIOTrackParameters.Parameters2Position(smearParams, referencePoint));
+// System.out.println("TrackFactory: Parameters from POCA: " + LCIOTrackParameters.SpaceMomentum2Parameters(poca, momentumAtPoca, referencePoint, charge, _Bz));
+ return new FastMCTrack(referencePoint, smearParams, errorMatrix, charge);
+ }
+
+ /**
+ * Returns a new Track object initialized with the given values, and with its parameters smeared according to the
+ * Tables that are read from the detector. This method can take a random seed
+ *
+ * @param momentum The momentum at a given location
+ * @param location The location where the momentum is measured
+ * @param referencePoint The point with respect to which the parameters are measured
+ * @param charge The charge of the Particle that created the Track
+ * @param random A random generator instance
+ * @return A new NewTraFastMCTrackt with the desired properties
+ */
+ public Track getTrack(SpaceVector momentum, SpacePoint location, SpacePoint referencePoint, int charge, Random random) {
+ return getTrack(momentum, location, referencePoint, charge, random, true);
+ }
+
+ public Track getTrack(Hep3Vector momentum, Hep3Vector location, int charge) {
+ return getTrack(new SpaceVector(momentum), new SpacePoint(location), new SpacePoint(), charge, new Random());
+ }
+
+ /**
+ * Swims the Track to a new reference point and calculates the parameters anew.
+ * It has to be done here, because it involves swimming, which has to be done outside the track
+ * @param track The track to be swum
+ * @param referencePoint The new reference point for the track to swim to
+ */
+ public void setNewReferencePoint(Track track, SpacePoint referencePoint) {
+ _swimmer.setTrack(track);
+ double alpha = _swimmer.getTrackLengthToPoint(referencePoint);
+
+ // TODO this involves transportation of the full covariance matrix.
+ // See Paul Avery's notes for details.
+ throw new RuntimeException("not yet implemented !");
+ }
+
+ /**
+ * Smears the measurement matrix with a Gaussian error
+ * @param oldParams The unsmeared Parameters
+ * @param errorMatrix The measurement error matrix
+ * @param random A random generator
+ * @return A new set of smeared parameters
+ */
+ private static LCIOTrackParameters smearParameters(LCIOTrackParameters oldParams, SymmetricMatrix sm, Random random) {
+ Matrix errorMatrix = Maths.toJamaMatrix(sm);
+ EigenvalueDecomposition eigen = errorMatrix.eig();
+ double[] realEigen = eigen.getRealEigenvalues();
+ double[] imaginaryEigen = eigen.getImagEigenvalues();
+ Matrix eigenValues = eigen.getV();
+ if (eigenValues.det() == 0) {
+ throw new RuntimeException("ErrorMatrix does not have orthogonal basis");
+ }
+ for (int i = 0; i < imaginaryEigen.length; i++ ) {
+ if (imaginaryEigen[i] != 0)
+ throw new RuntimeException("ErrorMatrix has imaginary eigenvalues");
+ }
+ Matrix x = new Matrix(5, 1);
+ for (int i = 0; i < 5; i++ ) {
+ if (realEigen[i] <= 0)
+ throw new RuntimeException("non-positive eigenvalue encountered");
+ x.set(i, 0, sqrt(realEigen[i]) * random.nextGaussian());
+ }
+ Matrix shift = eigenValues.times(x);
+ Matrix params = new Matrix(oldParams.values, 5);
+ // calculate the new parameters
+ double[] parameters = params.plus(shift).getColumnPackedCopy();
+ double pt = oldParams.pt * oldParams.get(omega) / parameters[omega.ordinal()];
+ // adjust the new parameters if necessary
+ if (parameters[phi0.ordinal()] > PI) {
+ parameters[phi0.ordinal()] -= 2 * PI;
+ } else if (parameters[phi0.ordinal()] < -PI) {
+ parameters[phi0.ordinal()] += 2 * PI;
+ }
+ return new LCIOTrackParameters(parameters, pt);
+ }
+}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -N NewTrack.java
--- NewTrack.java 28 Oct 2006 00:48:38 -0000 1.11
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-/**
- * @version $Id: NewTrack.java,v 1.11 2006/10/28 00:48:38 jstrube Exp $
- */
-package org.lcsim.contrib.JanStrube.tracking;
-
-import hep.physics.matrix.SymmetricMatrix;
-
-import org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName;
-import org.lcsim.spacegeom.CartesianPoint;
-import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.spacegeom.SpaceVector;
-import static java.lang.Math.sqrt;
-
-
-/**
- * @author jstrube
- * The class to store the measurement information of the track of a charged particle in a magnetic field.
- * This class represents the FastMC simulation.
- * An invariant of this class is that the "origin" is the point of closest approach to the reference point.
- */
-public class NewTrack implements Track {
- protected LCIOTrackParameters _parameters;
- protected SymmetricMatrix _errorMatrix;
- protected SpacePoint _referencePoint;
- protected int _charge;
-
- protected NewTrack() {
- _parameters = new LCIOTrackParameters();
- _errorMatrix = new SymmetricMatrix(5);
- }
-
- public NewTrack(org.lcsim.event.Track t) {
- double[] p = t.getMomentum();
- double pt = sqrt(p[0]*p[0] + p[1]*p[1]);
- _parameters = new LCIOTrackParameters(t.getTrackParameters(), pt);
- _errorMatrix = t.getErrorMatrix();
- _referencePoint = new CartesianPoint(t.getReferencePoint());
- _charge = t.getCharge();
- }
-
- protected NewTrack(SpacePoint refPoint, LCIOTrackParameters parameters, SymmetricMatrix errorMatrix, int charge) {
- _referencePoint = refPoint;
- _parameters = parameters;
- _charge = charge;
- _errorMatrix = errorMatrix;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.contrib.JanStrube.tracking.Track#getParameter(org.lcsim.contrib.JanStrube.tracking.NewTrack.ParameterName)
- */
- public double getParameter(ParameterName name) {
- return _parameters.get(name);
- }
- /* (non-Javadoc)
- * @see org.lcsim.contrib.JanStrube.tracking.Track#getParameters()
- */
- public LCIOTrackParameters getParameters() {
- return _parameters;
- }
- /* (non-Javadoc)
- * @see org.lcsim.contrib.JanStrube.tracking.Track#getPt()
- */
- public double getPt() {
- return _parameters.pt;
- }
- /* (non-Javadoc)
- * @see org.lcsim.contrib.JanStrube.tracking.Track#getCharge()
- */
- public int getCharge() {
- return _charge;
- }
- /* (non-Javadoc)
- * @see org.lcsim.contrib.JanStrube.tracking.Track#getReferencePoint()
- */
- public SpacePoint getReferencePoint() {
- return _referencePoint;
- }
- /* (non-Javadoc)
- * @see org.lcsim.contrib.JanStrube.tracking.Track#getErrorMatrix()
- */
- public SymmetricMatrix getErrorMatrix() {
- return _errorMatrix;
- }
-
- public SpacePoint getPosition() {
- return LCIOTrackParameters.Parameters2Position(_parameters, _referencePoint);
- }
-
- public SpaceVector getMomentum() {
- return LCIOTrackParameters.Parameters2Momentum(_parameters);
- }
-}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -N NewFastMCTrackFactory.java
--- NewFastMCTrackFactory.java 28 Oct 2006 00:48:40 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,232 +0,0 @@
-/**
- * @version $Id: NewFastMCTrackFactory.java,v 1.13 2006/10/28 00:48:40 jstrube Exp $
- */
-package org.lcsim.contrib.JanStrube.tracking;
-
-import Jama.util.Maths;
-import hep.physics.matrix.SymmetricMatrix;
-import static java.lang.Math.PI;
-import static java.lang.Math.abs;
-import static java.lang.Math.atan2;
-import static java.lang.Math.sqrt;
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.omega;
-import static org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters.ParameterName.phi0;
-
-import hep.physics.vec.Hep3Vector;
-
-import java.io.IOException;
-import java.util.Random;
-
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.conditions.ConditionsSet;
-import org.lcsim.event.EventHeader;
-import org.lcsim.mc.fast.tracking.ResolutionTable;
-import org.lcsim.mc.fast.tracking.SimpleTables;
-import org.lcsim.mc.fast.tracking.TrackResolutionTables;
-import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.spacegeom.SpaceVector;
-
-import Jama.EigenvalueDecomposition;
-import Jama.Matrix;
-
-/**
- * @author jstrube
- * This class creates a new FastMC Track. It is used as the interface between the track measurement and
- * the detector. Since Track doesn't know anything about the magnetic field, and the material, it cannot
- * transport its own parameters. Changing the reference point of a track requires swimming; it is therefore done
- * in this class.
- *
- */
-public class NewFastMCTrackFactory {
- private TrackResolutionTables _tables;
- private SimpleTables _simpleTables;
- private ConditionsManager _manager;
- private double _Bz;
- private HelixSwimmer _swimmer;
-
- /**
- * This constructor obtains the necessary information for construction like the field and the resolution tables from
- * the event.
- *
- * @param event The current event
- * @param beamConstraint A switch to obtain the resolution tables with or without beamconstraint
- */
- public NewFastMCTrackFactory(EventHeader event, boolean beamConstraint) {
- this(event.getDetectorName(), event.getDetector().getFieldMap().getField(new double[3])[2], beamConstraint);
- }
-
- /**
- * This constructor is only to be used by unit tests. It will instantiate the Factory with a detector name and a
- * field.
- *
- */
- NewFastMCTrackFactory(String detectorName, double field, boolean beamConstraint) {
- _Bz = field;
- _manager = ConditionsManager.defaultInstance();
- try {
- _manager.setDetector(detectorName, 0);
- } catch (ConditionsManager.ConditionsNotFoundException e) {
- }
- ConditionsSet trackParameters = _manager.getConditions("TrackParameters");
- ConditionsSet simpleTrack = _manager.getConditions("SimpleTrack");
- try {
- _tables = new TrackResolutionTables(trackParameters, beamConstraint);
- _simpleTables = new SimpleTables(simpleTrack);
- } catch (IOException e) {
- }
- _swimmer = new HelixSwimmer(field);
- }
-
- /**
- * Creates a new Track with the given parameters.
- * See #{@link #getTrack(SpacePoint, SpacePoint, SpacePoint, int, Random)} for details.
- * @param momentum The momentum at a given location
- * @param location The location where the momentum is measured
- * @param charge The charge of the Particle that created the Track
- * @return A new NewTrack object with the desired properties
- */
- public Track getTrack(SpaceVector momentum, SpacePoint location, int charge) {
- return getTrack(momentum, location, new SpacePoint(), charge, new Random());
- }
-
- /**
- * Creates a new Track with the given parameters.
- * See #{@link #getTrack(SpacePoint, SpacePoint, SpacePoint, int, Random)} for details.
- * @param momentum The momentum at a given location
- * @param location The location where the momentum is measured
- * @param charge The charge of the Particle that created the Track
- * @param random A random generator instance
- * @return A new NewTrack object with the desired properties
- */
- public Track getTrack(SpaceVector momentum, SpacePoint location, int charge, Random random) {
- return getTrack(momentum, location, new SpacePoint(), charge, random);
- }
-
- /**
- * Creates a new Track with the given parameters.
- * See #{@link #getTrack(SpacePoint, SpacePoint, SpacePoint, int, Random)} for details.
- * @param momentum The momentum at a given location
- * @param location The location where the momentum is measured
- * @param referencePoint The point with respect to which the parameters are measured
- * @param charge The charge of the Particle that created the Track
- * @return A new NewTrack object with the desired properties
- */
- public Track getTrack(SpaceVector momentum, SpacePoint location, SpacePoint referencePoint, int charge) {
- return getTrack(momentum, location, referencePoint, charge, new Random());
- }
-
- /**
- * This version is only to be used in unit tests.
- * @param momentum The momentum at a given location
- * @param location The location where the momentum is measured
- * @param referencePoint The point with respect to which the parameters are measured
- * @param charge The charge of the Particle that created the Track
- * @param random A random generator instance
- * @param shouldISmear This parameter switches smearing on/off. It should always be true except in Unit tests.
- * @return A new NewTrack object with the desired properties
- */
- public Track getTrack(SpaceVector momentum, SpacePoint location, SpacePoint referencePoint, int charge, Random random, boolean shouldISmear) {
- _swimmer.setTrack(momentum, location, charge);
- double alpha = _swimmer.getTrackLengthToPoint(referencePoint);
- SpacePoint poca = _swimmer.getPointAtLength(alpha);
- SpaceVector momentumAtPoca = _swimmer.getMomentumAtLength(alpha);
- LCIOTrackParameters parameters = LCIOTrackParameters.SpaceMomentum2Parameters(poca, momentumAtPoca, referencePoint, charge, _Bz);
- SymmetricMatrix errorMatrix = new SymmetricMatrix(5);
- // this sets the measurement error
- double cosTheta = abs(momentumAtPoca.cosTheta());
- double p_mag = momentumAtPoca.magnitude();
- ResolutionTable table = cosTheta < _tables.getPolarInner() ? _tables.getBarrelTable() : _tables
- .getEndcapTable();
- for (int i = 0; i < 5; i++ ) {
- for (int j = 0; j <= i; j++ ) {
- double iVal = table.findTable(i, j).interpolateVal(cosTheta, p_mag);
- errorMatrix.setElement(i, j, iVal);
- }
- }
- // it's a bit inefficient to always have this condition here, although it's only used in tests.
- LCIOTrackParameters smearParams = shouldISmear
- ? smearParameters(parameters, errorMatrix, random)
- : parameters;
-
-// System.out.println("Charge: " + charge);
-// System.out.println("TrackFactory: POCA " + poca);
-// System.out.println("TrackFactory: Momentum " + momentumAtPoca);
-// System.out.println("TrackFactory: Parameters: " + smearParams);
-// System.out.println("TrackFactory: POCA from parameters: " + LCIOTrackParameters.Parameters2Position(smearParams, referencePoint));
-// System.out.println("TrackFactory: Parameters from POCA: " + LCIOTrackParameters.SpaceMomentum2Parameters(poca, momentumAtPoca, referencePoint, charge, _Bz));
- return new NewTrack(referencePoint, smearParams, errorMatrix, charge);
- }
-
- /**
- * Returns a new Track object initialized with the given values, and with its parameters smeared according to the
- * Tables that are read from the detector. This method can take a random seed
- * @param momentum The momentum at a given location
- * @param location The location where the momentum is measured
- * @param referencePoint The point with respect to which the parameters are measured
- * @param charge The charge of the Particle that created the Track
- * @param random A random generator instance
- * @return A new NewTrack object with the desired properties
- */
- public Track getTrack(SpaceVector momentum, SpacePoint location, SpacePoint referencePoint, int charge, Random random) {
- return getTrack(momentum, location, referencePoint, charge, random, true);
- }
-
- public Track getTrack(Hep3Vector momentum, Hep3Vector location, int charge) {
- return getTrack(new SpaceVector(momentum), new SpacePoint(location), new SpacePoint(), charge, new Random());
- }
-
- /**
- * Swims the Track to a new reference point and calculates the parameters anew.
- * It has to be done here, because it involves swimming, which has to be done outside the track
- * @param track The track to be swum
- * @param referencePoint The new reference point for the track to swim to
- */
- public void setNewReferencePoint(Track track, SpacePoint referencePoint) {
- _swimmer.setTrack(track);
- double alpha = _swimmer.getTrackLengthToPoint(referencePoint);
-
- // TODO this involves transportation of the full covariance matrix.
- // See Paul Avery's notes for details.
- throw new RuntimeException("not yet implemented !");
- }
-
- /**
- * Smears the measurement matrix with a Gaussian error
- * @param oldParams The unsmeared Parameters
- * @param errorMatrix The measurement error matrix
- * @param random A random generator
- * @return A new set of smeared parameters
- */
- private static LCIOTrackParameters smearParameters(LCIOTrackParameters oldParams, SymmetricMatrix sm, Random random) {
- Matrix errorMatrix = Maths.toJamaMatrix(sm);
- EigenvalueDecomposition eigen = errorMatrix.eig();
- double[] realEigen = eigen.getRealEigenvalues();
- double[] imaginaryEigen = eigen.getImagEigenvalues();
- Matrix eigenValues = eigen.getV();
- if (eigenValues.det() == 0) {
- throw new RuntimeException("ErrorMatrix does not have orthogonal basis");
- }
- for (int i = 0; i < imaginaryEigen.length; i++ ) {
- if (imaginaryEigen[i] != 0)
- throw new RuntimeException("ErrorMatrix has imaginary eigenvalues");
- }
- Matrix x = new Matrix(5, 1);
- for (int i = 0; i < 5; i++ ) {
- if (realEigen[i] <= 0)
- throw new RuntimeException("non-positive eigenvalue encountered");
- x.set(i, 0, sqrt(realEigen[i]) * random.nextGaussian());
- }
- Matrix shift = eigenValues.times(x);
- Matrix params = new Matrix(oldParams.values, 5);
- // calculate the new parameters
- double[] parameters = params.plus(shift).getColumnPackedCopy();
- double pt = oldParams.pt * oldParams.get(omega) / parameters[omega.ordinal()];
- // adjust the new parameters if necessary
- if (parameters[phi0.ordinal()] > PI) {
- parameters[phi0.ordinal()] -= 2 * PI;
- } else if (parameters[phi0.ordinal()] < -PI) {
- parameters[phi0.ordinal()] += 2 * PI;
- }
- return new LCIOTrackParameters(parameters, pt);
- }
-}
lcsim/src/org/lcsim/contrib/JanStrube/tracking
diff -N NewMCFastTrackDriver.java
--- NewMCFastTrackDriver.java 1 Dec 2006 00:10:51 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,112 +0,0 @@
-/**
- * @version $Id: NewMCFastTrackDriver.java,v 1.5 2006/12/01 00:10:51 jstrube Exp $
- */
-package org.lcsim.contrib.JanStrube.tracking;
-
-import hep.physics.particle.Particle;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.lcsim.conditions.ConditionsEvent;
-import org.lcsim.conditions.ConditionsListener;
-import org.lcsim.conditions.ConditionsSet;
-import org.lcsim.event.EventHeader;
-import org.lcsim.mc.fast.tracking.SimpleTables;
-import org.lcsim.mc.fast.tracking.TrackResolutionTables;
-import org.lcsim.util.Driver;
-
-/**
- * A replacement for the current FastMC Tracks.
- * The simple tables are currently not implemented
- * @author jstrube
- *
- */
-public class NewMCFastTrackDriver extends Driver implements ConditionsListener {
- private TrackResolutionTables parm;
- private SimpleTables SmTbl;
- private boolean beamSpotConstraint;
- private boolean simple;
- private final static double[] IP = { 0, 0, 0 };
-
- public NewMCFastTrackDriver(boolean beamSpotConstraint)
- {
- this.beamSpotConstraint = beamSpotConstraint;
- }
-
- public NewMCFastTrackDriver() {
- this(false);
- }
-
- protected void process(EventHeader event) {
- if (parm == null) {
- ConditionsSet conditions = getConditionsManager().getConditions("TrackParameters");
- conditions.addConditionsListener(this);
- parm = setTrackResolutionTables(conditions, beamSpotConstraint);
- }
-
- if (SmTbl == null) {
- ConditionsSet conditions = getConditionsManager().getConditions("SimpleTrack");
- conditions.addConditionsListener(this);
- SmTbl = new SimpleTables(conditions);
- }
-
- NewFastMCTrackFactory factory = new NewFastMCTrackFactory(event, beamSpotConstraint);
-
- double bField = event.getDetector().getFieldMap().getField(IP)[2];
- boolean hist = getHistogramLevel() > 0;
-
- List<org.lcsim.event.Track> trackList = new ArrayList<org.lcsim.event.Track>();
- List<Track> newTrackList = new ArrayList<Track>();
- for (Particle p : event.getMCParticles()) {
- // filter for FINAL_STATE
- if (p.getGeneratorStatus() != Particle.FINAL_STATE) {
- continue;
- }
- double pCharge = p.getCharge();
- if (pCharge == 0
- || Double.isNaN(pCharge)
- || pCharge == Double.NEGATIVE_INFINITY
- || pCharge == Double.POSITIVE_INFINITY) {
- continue;
- }
-
- double[] momentum = p.getMomentum().v();
- double pt2 = (momentum[0] * momentum[0]) + (momentum[1] * momentum[1]);
- double pt = Math.sqrt(pt2);
- double ptot = Math.sqrt(pt2 + (momentum[2] * momentum[2]));
- double cosTheta = momentum[2] / ptot;
-
- // within acceptance
- if (pt < parm.getPtMin()) {
- continue;
- }
- if (Math.abs(cosTheta) > parm.getPolarOuter()) {
- continue;
- }
-
- Track t = factory.getTrack(p.getMomentum(), p.getOrigin(), (int)p.getCharge());
- org.lcsim.event.Track passpartout = new TransitionalTrack(t);
- trackList.add(passpartout);
- newTrackList.add(t);
- }
- event.put(EventHeader.TRACKS, newTrackList, Track.class, 0);
- }
-
- public void conditionsChanged(ConditionsEvent event) {
- ConditionsSet conditions = getConditionsManager().getConditions("TrackParameters");
- ConditionsSet simpleconditions = getConditionsManager().getConditions("SimpleTrack");
- parm = setTrackResolutionTables(conditions, beamSpotConstraint);
- SmTbl = new SimpleTables(simpleconditions);
- }
-
- private TrackResolutionTables setTrackResolutionTables(ConditionsSet conditions, boolean beamSpotConstraint) {
- try {
- return new TrackResolutionTables(conditions, beamSpotConstraint);
- } catch (IOException x) {
- throw new RuntimeException("Error reading track resolution tables", x);
- }
- }
-
-}
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.2 -r1.3
--- NickTrackVtxFitter.java 7 Dec 2006 06:11:24 -0000 1.2
+++ NickTrackVtxFitter.java 19 Feb 2007 21:07:56 -0000 1.3
@@ -5,7 +5,7 @@
import org.lcsim.event.util.*;
import org.lcsim.event.base.*;
import org.lcsim.geometry.Detector;
-import org.lcsim.contrib.JanStrube.tracking.NewTrack;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrack;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.contrib.NickSinev.tracking.wmfitter.*;
import org.lcsim.contrib.NickSinev.tracking.util.*;
@@ -288,7 +288,7 @@
System.out.println(" Event " + evnum + " track " + tn
+ " has chi2: " + chi2);
tn++;
- vtxCandidate.add(new NewTrack(track));
+ vtxCandidate.add(new FastMCTrack(track));
}
}
for (MCParticle part : event.getMCParticles()) {
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.2 -r1.3
--- PrimaryParticleDaughterFitter.java 14 Oct 2006 08:45:21 -0000 1.2
+++ PrimaryParticleDaughterFitter.java 19 Feb 2007 21:07:56 -0000 1.3
@@ -1,5 +1,5 @@
/**
- * @version $Id: PrimaryParticleDaughterFitter.java,v 1.2 2006/10/14 08:45:21 jstrube Exp $
+ * @version $Id: PrimaryParticleDaughterFitter.java,v 1.3 2007/02/19 21:07:56 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.standalone;
@@ -8,7 +8,7 @@
import hep.physics.particle.Particle;
-import org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.contrib.JanStrube.vtxFitter.Fitter;
import org.lcsim.contrib.JanStrube.vtxFitter.Vertex;
@@ -38,7 +38,7 @@
public void process(EventHeader event) {
Particle part = (Particle) event.get("primaryParticle");
List<Track> tracks = new ArrayList<Track>();
- NewFastMCTrackFactory factory = new NewFastMCTrackFactory(event, false);
+ FastMCTrackFactory factory = new FastMCTrackFactory(event, false);
for (Object o : part.getDaughters()) {
Particle daughter = (Particle) o;
tracks.add(factory.getTrack(daughter.getMomentum(), daughter.getOrigin(), (int) daughter.getCharge()));
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.8 -r1.9
--- FitterTestDriver.java 31 Jan 2007 02:05:40 -0000 1.8
+++ FitterTestDriver.java 19 Feb 2007 21:07:56 -0000 1.9
@@ -6,7 +6,7 @@
import java.util.Random;
import org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters;
-import org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.contrib.JanStrube.vtxFitter.Fitter;
import org.lcsim.contrib.JanStrube.vtxFitter.Vertex;
@@ -36,7 +36,7 @@
if (count % 500 == 0)
System.out.printf("Processing event %d\n", count);
// beamconstraint when smearing the tracks ?
- NewFastMCTrackFactory tf = new NewFastMCTrackFactory(event, false);
+ FastMCTrackFactory tf = new FastMCTrackFactory(event, false);
for (MCParticle part : event.getMCParticles()) {
// K0: 310, J/Psi: 443
if (abs(part.getPDGID()) != 443)
lcsim/src/org/lcsim/contrib/JanStrube/standalone
diff -u -r1.1 -r1.2
--- NickTrack_FastMCTrackComparison.java 7 Dec 2006 06:11:24 -0000 1.1
+++ NickTrack_FastMCTrackComparison.java 19 Feb 2007 21:07:56 -0000 1.2
@@ -6,8 +6,8 @@
import org.lcsim.event.base.*;
import org.lcsim.geometry.Detector;
import org.lcsim.contrib.JanStrube.tracking.HelixSwimmer;
-import org.lcsim.contrib.JanStrube.tracking.NewFastMCTrackFactory;
-import org.lcsim.contrib.JanStrube.tracking.NewTrack;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrackFactory;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrack;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.contrib.NickSinev.tracking.wmfitter.*;
import org.lcsim.contrib.NickSinev.tracking.util.*;
@@ -80,7 +80,7 @@
}
public void process(EventHeader event) {
- NewFastMCTrackFactory factory = new NewFastMCTrackFactory(event, false);
+ FastMCTrackFactory factory = new FastMCTrackFactory(event, false);
if (!((evnum > firstev - 1) && (evnum < lastev + 1)))
return;
if (evnum % 100 == 0) {
@@ -343,7 +343,7 @@
// System.out.println(" Event " + evnum + " track " + tn
// + " has chi2: " + chi2);
tn++;
- vtxCandidate.add(new NewTrack(track));
+ vtxCandidate.add(new FastMCTrack(track));
}
}
evnum++;
lcsim/src/org/lcsim/contrib/JanStrube/vtxFitter
diff -u -r1.3 -r1.4
--- VtxTrack.java 28 Oct 2006 00:48:32 -0000 1.3
+++ VtxTrack.java 19 Feb 2007 21:07:56 -0000 1.4
@@ -2,14 +2,14 @@
import hep.physics.matrix.SymmetricMatrix;
import org.lcsim.contrib.JanStrube.tracking.LCIOTrackParameters;
-import org.lcsim.contrib.JanStrube.tracking.NewTrack;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrack;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.spacegeom.SpacePoint;
import org.lcsim.spacegeom.SpaceVector;
import Jama.Matrix;
-public class VtxTrack extends NewTrack {
+public class VtxTrack extends FastMCTrack {
/*
* Copy constructor. The members of Track have to be cloned,
lcsim/src/org/lcsim/contrib/JanStrube/zvtop
diff -u -r1.1 -r1.2
--- ZvTrack.java 9 Oct 2006 17:25:27 -0000 1.1
+++ ZvTrack.java 19 Feb 2007 21:07:56 -0000 1.2
@@ -1,9 +1,9 @@
/**
- * @version $Id: ZvTrack.java,v 1.1 2006/10/09 17:25:27 jstrube Exp $
+ * @version $Id: ZvTrack.java,v 1.2 2007/02/19 21:07:56 jstrube Exp $
*/
package org.lcsim.contrib.JanStrube.zvtop;
-import org.lcsim.contrib.JanStrube.tracking.NewTrack;
+import org.lcsim.contrib.JanStrube.tracking.FastMCTrack;
import org.lcsim.contrib.JanStrube.tracking.Track;
import org.lcsim.spacegeom.SpacePoint;
CVSspam 0.2.8