Commit in lcsim on lcio_v2_branch
src/org/lcsim/event/TrackState.java+90added 1.1.2.1
                   /Track.java+3-11.11 -> 1.11.4.1
src/org/lcsim/event/base/BaseTrackState.java+239added 1.1.2.1
                        /BaseTrack.java+85-461.11 -> 1.11.4.1
src/org/lcsim/mc/fast/tracking/ReconTrack.java+9-21.10 -> 1.10.4.1
src/org/lcsim/mc/fast/tracking/fix/FastMCTrack.java+8-21.1 -> 1.1.4.1
src/org/lcsim/plugin/browser/TrackTableModel.java+27-51.3 -> 1.3.8.1
src/org/lcsim/recon/cat/GarfieldTrack.java+5-21.2 -> 1.2.6.1
src/org/lcsim/recon/cat/util/BasicTrack.java+6-11.3 -> 1.3.4.1
src/org/lcsim/recon/tracking/seedtracker/MakeTracks.java+4-71.4 -> 1.4.4.1
                                        /SeedTrackerTrackStateDriver.java+83-51.8 -> 1.8.4.1
src/org/lcsim/recon/vertexing/zvtop4/ZvTrack.java+11-91.24 -> 1.24.8.1
src/org/lcsim/recon/ztracking/AbstractTrack.java+51.3 -> 1.3.8.1
                             /FoundTrack.java+51.3 -> 1.3.10.1
src/org/lcsim/util/lcio/LCIOConstants.java+5-31.15 -> 1.15.4.1
                       /SIOTrack.java+175-1171.5 -> 1.5.6.1
test/org/lcsim/event/TrackStateTest.java+118added 1.1.2.1
+878-200
3 added + 14 modified, total 17 files
add changes for LCIO v2 in lcsim branch; add TrackStates to Track

lcsim/src/org/lcsim/event
TrackState.java added at 1.1.2.1
diff -N TrackState.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackState.java	14 Feb 2012 21:51:37 -0000	1.1.2.1
@@ -0,0 +1,90 @@
+package org.lcsim.event;
+
+/** 
+ * The LCIO TrackState interface.
+ * 
+ * @author gaede, engels
+ * @author Jeremy McCormick
+ * @version $Id: TrackState.java,v 1.1.2.1 2012/02/14 21:51:37 jeremy Exp $
+ */
+public interface TrackState 
+{
+    // TrackState location codes.
+    public final static int AtOther = 0;  // Any location other than the ones defined below. 
+    public final static int AtIP = 1;
+    public final static int AtFirstHit = 2;
+    public final static int AtLastHit = 3;
+    public final static int AtCalorimeter = 4;
+    public final static int AtVertex = 5;
+    public final static int LastLocation = AtVertex;
+    
+    /** 
+     * The location of the track state.
+     * Location can be set to: AtIP, AtFirstHit, AtLastHit, AtCalorimeter, AtVertex, AtOther
+     */
+    public int getLocation();
+
+    /** 
+     * Impact paramter of the track in (r-phi).
+     */
+    public double getD0();
+
+    /** 
+     * Phi of the track at the reference point.
+     * @see getReferencePoint
+     */
+    public double getPhi();
+
+    /** 
+     * Omega is the signed curvature of the track in [1/mm].
+     * The sign is that of the particle's charge.
+     */
+    public double getOmega();
+
+    /** 
+     * Impact paramter of the track in (r-z).
+     */
+    public double getZ0();
+
+    /** 
+     * Lambda is the dip angle of the track in r-z at the reference point. 
+     * @see getReferencePoint
+     */
+    public double getTanLambda();
+    
+    /**
+     * Get the ordered list of 5 LCIO track parameters.
+     * @return The track parameters as a double array of size 5.
+     */
+    public double[] getParameters();
+
+    /** 
+     * Covariance matrix of the track parameters. Stored as lower triangle matrix where
+     * the order of parameters is:   d0, phi, omega, z0, tan(lambda).
+     * So we have cov(d0,d0), cov( phi, d0 ), cov( phi, phi), ...
+     * @return A double array of size 15 containing the covariance matrix of the track parameters.
+     */
+    public double[] getCovMatrix();
+
+    /** 
+     * Reference point of the track parameters.
+     * The default for the reference point is the point of closest approach.
+     * @return The reference point of the track parameters as a double array of size 3.
+     */
+    public double[] getReferencePoint();
+    
+    public double[] getMomentum();
+    
+    /**
+     * Get an individual track parameter.
+     * They are returned by the following keys: 
+     * 0 = d0
+     * 1 = phi
+     * 2 = omega
+     * 3 = z0
+     * 4 = tanLambda
+     * This order is defined in BaseTrack. 
+     * @return The track parameters.
+     */
+    public double getParameter(int iparam);
+}
\ No newline at end of file

lcsim/src/org/lcsim/event
Track.java 1.11 -> 1.11.4.1
diff -u -r1.11 -r1.11.4.1
--- Track.java	23 May 2008 06:53:35 -0000	1.11
+++ Track.java	14 Feb 2012 21:51:37 -0000	1.11.4.1
@@ -9,7 +9,7 @@
  * Represents a found (reconstructed) track
  * 
  * @author tonyj
- * @version $Id: Track.java,v 1.11 2008/05/23 06:53:35 jeremy Exp $
+ * @version $Id: Track.java,v 1.11.4.1 2012/02/14 21:51:37 jeremy Exp $
  */
 
 public interface Track 
@@ -124,6 +124,8 @@
     List<TrackerHit> getTrackerHits();
 
     int getType();
+    
+    List<TrackState> getTrackStates();
 
     // double parameter(ParameterName n);
     // similar name is not a problem, because of different signature

lcsim/src/org/lcsim/event/base
BaseTrackState.java added at 1.1.2.1
diff -N BaseTrackState.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BaseTrackState.java	14 Feb 2012 21:51:37 -0000	1.1.2.1
@@ -0,0 +1,239 @@
+package org.lcsim.event.base;
+
+import static java.lang.Math.abs;
+
+import java.io.PrintStream;
+
+import org.lcsim.constants.Constants;
+import org.lcsim.event.TrackState;
+
+/**
+ * Implementation of the org.lcsim.event.TrackState interface.
+ * @author Jeremy McCormick
+ * @version $Id: BaseTrackState.java,v 1.1.2.1 2012/02/14 21:51:37 jeremy Exp $
+ */
+public class BaseTrackState implements TrackState
+{
+    public static final int PARAMETERS_SIZE  = 5; // Number of LCIO track parameters.
+    public static final int REF_POINT_SIZE   = 3; // Size of reference point (x, y, z).
+    public static final int MOMENTUM_SIZE    = 3; // Size of momentum array (px, py, pz).
+    public static final int COV_MATRIX_SIZE = 15; // Size of covariance matrix array.
+    
+    // Initialization here is wasteful, but it protects against users leaving these null.
+    private double[] parameters = new double[PARAMETERS_SIZE];     // Parameters array.
+    private double[] referencePoint = new double[REF_POINT_SIZE];  // Reference point.
+    private double[] covMatrix = new double[COV_MATRIX_SIZE];      // Covariance matrix.
+    private double[] momentum; 
+
+    // Location encoding.
+    private int location = TrackState.AtIP; // default location
+       
+    public BaseTrackState()
+    {}
+    
+    // Ctor with parameters and B-field.  
+    // The reference point, covariance matrix, and location can be set later.
+    public BaseTrackState(double[] parameters, double bfield)
+    {
+        setParameters(parameters, bfield);
+    }
+    
+    // Fully qualified constructor.
+    public BaseTrackState(double[] parameters, double[] referencePoint, double[] covMatrix, int location, double bfield)
+    {
+        setParameters(parameters, bfield);
+        setReferencePoint(referencePoint);
+        setCovMatrix(covMatrix);
+        setLocation(location);
+    }
+     
+    public int getLocation()
+    {
+        return location;
+    }
+    
+    public double[] getReferencePoint()
+    {
+        return referencePoint;
+    }
+
+    public double[] getCovMatrix()
+    {
+        return covMatrix;
+    }
+    
+    public double getD0()
+    {
+        return parameters[BaseTrack.D0];
+    }
+
+    public double getPhi()
+    {
+        return parameters[BaseTrack.PHI];
+    }
+
+    public double getZ0()
+    {
+        return parameters[BaseTrack.Z0];
+    }
+
+    public double getOmega()
+    {
+        return parameters[BaseTrack.OMEGA];
+    }
+
+    public double getTanLambda()
+    {
+        return parameters[BaseTrack.TANLAMBDA];
+    }
+    
+    public void setD0(double d0)
+    {
+        parameters[BaseTrack.D0] = d0;
+    }
+
+    public void setPhi(double phi)
+    {
+        parameters[BaseTrack.PHI] = phi;
+    }
+
+    public void setZ0(double z0)
+    {
+        parameters[BaseTrack.Z0] = z0;
+    }
+
+    public void setOmega(double d)
+    {
+        parameters[BaseTrack.OMEGA] = d;
+    }
+
+    public void setTanLambda(double d)
+    { 
+        parameters[BaseTrack.TANLAMBDA] = d;
+    }
+    
+    public void setLocation(int location)
+    {
+        if (location < 0 || location > TrackState.LastLocation)
+            throw new IllegalArgumentException("The location must be between 0 and " + TrackState.LastLocation);
+        this.location = location;
+    }
+
+    // FIXME Should be array copy?
+    public void setReferencePoint(double[] referencePoint)
+    {
+        if (referencePoint.length != REF_POINT_SIZE) throw new IllegalArgumentException("referencePoint.length != " + REF_POINT_SIZE);
+        this.referencePoint = referencePoint;
+    }
+    
+    // FIXME Should be array copy?
+    public void setCovMatrix(double[] covMatrix)
+    {
+        if (covMatrix.length != COV_MATRIX_SIZE) throw new IllegalArgumentException("covMatrix.length != " + COV_MATRIX_SIZE);
+        this.covMatrix = covMatrix;
+    }
+    
+    // If setParameters or a qualified constructor was not called, this could be null.
+    public double[] getMomentum()
+    {
+        return momentum;
+    }
+    
+    // Get a track parameter by ordinal.
+    public double getParameter(int param)
+    {   
+        if (param < 0 || param > (PARAMETERS_SIZE - 1))
+            throw new IllegalArgumentException("Parameter ordinal " + param + " is invalid.");
+        return parameters[param];
+    }
+    
+    // Get the parameters as a double array.  
+    // Use ordinals in BaseTrack for the index into the array.
+    public double[] getParameters()
+    {
+        return parameters;
+    }
+    
+    /**
+     * Set the track parameters.  Computes momentum and charge, also.
+     * @param p
+     * @param bfield
+     */
+    public void setParameters(double[] p, double bfield)
+    {
+        copyParameters(p, parameters);
+        computeMomentum(bfield);
+    }
+    
+    static final void copyParameters(double[] p1, double[] p2)
+    {
+        if (p1.length != 5)
+            throw new IllegalArgumentException("First array is not size " + PARAMETERS_SIZE);
+        if (p2.length != 5)
+            throw new IllegalArgumentException("Second aray is not size" + PARAMETERS_SIZE);
+        System.arraycopy(p1, 0, p2, 0, PARAMETERS_SIZE);
+    }
+    
+    /**
+     * Compute the momentum of this TrackState, setting the internal array containing (px,py,pz),
+     * and return the result.
+     * @param bz The B-field in Z.
+     * @return The computed momentum.
+     */
+    public double[] computeMomentum(double bz)
+    {
+        momentum = computeMomentum(this, bz);
+        return momentum;
+    }
+    
+    /**
+     * Compute the momentum of a TrackState, given a Bz field component.
+     * @param ts The TrackState.
+     * @param Bz The magnetic field component Bz.
+     * @return The momentum computed from the TrackState's parameters.
+     */
+    public static final double[] computeMomentum(TrackState ts, double magneticField)
+    {
+        double omega = ts.getOmega();
+        if(abs(omega) < 0.0000001) omega = 0.0000001;
+        double Pt = abs((1./omega) * magneticField * Constants.fieldConversion);  
+        double[] momentum = new double[3];
+        momentum[0] = Pt * Math.cos(ts.getPhi());
+        momentum[1] = Pt * Math.sin(ts.getPhi());
+        momentum[2] = Pt * ts.getTanLambda();
+        return momentum;
+    }
+    
+    /**
+     * Convert object to a String.
+     */
+    public String toString()
+    {
+        StringBuffer buff = new StringBuffer();
+        buff.append("location = " + getLocation() + "\n");
+        buff.append("D0 = " + getD0() + "\n");
+        buff.append("phi = " + getPhi() + "\n");
+        buff.append("Z0 = " + getZ0() + "\n");
+        buff.append("tanLambda = " + getTanLambda() + "\n");
+        buff.append("omega = " + getOmega() + "\n");
+        buff.append("referencePoint = " + referencePoint[0] + " " + referencePoint[1] + " " + referencePoint[2] + "\n");
+        buff.append("covarianceMatrix = ");
+        for (int i=0; i<covMatrix.length; i++) 
+        {
+            buff.append(covMatrix[i] + " ");
+        }
+        buff.append("\n");
+        buff.append("momentum = ");
+        for (int i=0; i<this.MOMENTUM_SIZE; i++)
+        {
+            buff.append(momentum[i] + " ");
+        }
+        buff.append("\n");
+        return buff.toString();
+    }
+    
+    public void printOut(PrintStream ps)
+    {
+        ps.println(toString());
+    }
+}
\ No newline at end of file

lcsim/src/org/lcsim/event/base
BaseTrack.java 1.11 -> 1.11.4.1
diff -u -r1.11 -r1.11.4.1
--- BaseTrack.java	29 Nov 2007 02:26:00 -0000	1.11
+++ BaseTrack.java	14 Feb 2012 21:51:37 -0000	1.11.4.1
@@ -1,62 +1,104 @@
-/*
- * BaseTrack.java
- *
- * Created on March 24, 2006, 9:18 PM
- *
- * $Id: BaseTrack.java,v 1.11 2007/11/29 02:26:00 jstrube Exp $
- */
-
 package org.lcsim.event.base;
 
+import static java.lang.Math.abs;
+import static java.lang.Math.signum;
 import hep.physics.matrix.SymmetricMatrix;
-import java.util.List;
+
 import java.util.ArrayList;
+import java.util.List;
+
 import org.lcsim.constants.Constants;
-import org.lcsim.event.LCIOParameters;
 import org.lcsim.event.LCIOParameters.ParameterName;
 import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
 
-import static java.lang.Math.abs;
-import static java.lang.Math.signum;
 /**
- *
+ * Base implementation of LCIO Track interface.  
+ * 
+ * Modified for LCIO v2 compatibility: added TrackStates.
+ * 
  * @author Norman Graf
+ * @author Jeremy McCormick
+ * @version $Id: BaseTrack.java,v 1.11.4.1 2012/02/14 21:51:37 jeremy Exp $
  */
+// FIXME: Needs to be made compatible with LCIO 2.0 which has TrackStates.
 public class BaseTrack implements Track
 {
+    // These three now stored in TrackStates but kept here for backward compatibility.
     protected double[] _refPoint = new double[3];
-    protected boolean _refPointIsDCA = true;
     protected double[] _parameters = new double[5];
     protected SymmetricMatrix _covMatrix = new SymmetricMatrix(5);
+    
     protected double[] _momentum = new double[3];
+    protected double _chi2;
+    protected boolean _refPointIsDCA = true;
     protected int _charge;
     protected boolean _fitSuccess = true;
-    protected double _chi2;
     protected int _ndf;
     protected double _dEdx;
     protected double _dEdxErr;
     protected double _innermostHitRadius = 9999.;
+    protected int _type;
     protected int[] _subdetId = new int[1];
+
+    // References to other objects.
     protected List<Track> _tracks;
     protected List<TrackerHit> _hits;
-    protected int _type;
+    protected List<TrackState> _trackStates;
     
+    // Parameter ordering.
     protected static final int D0 = ParameterName.d0.ordinal();
     protected static final int PHI = ParameterName.phi0.ordinal();
     protected static final int OMEGA = ParameterName.omega.ordinal();
     protected static final int TANLAMBDA = ParameterName.tanLambda.ordinal();
     protected static final int Z0 = ParameterName.z0.ordinal();
     
+    
     /** Creates a new instance of BaseTrack */
     public BaseTrack()
     {
         _tracks = new ArrayList<Track>();
         _hits = new ArrayList<TrackerHit>();
+        _trackStates = new ArrayList<TrackState>();
+    }
+
+    /**
+     * This gets the first TrackState as a BaseTrackState, so it can be modified.
+     * It will create this TrackState, if it doesn't exist already.
+     * @return The first TrackState.
+     */
+    private BaseTrackState getFirstTrackState()
+    {
+        if (_trackStates.size() == 0)
+        {
+            _trackStates.add(new BaseTrackState());
+        }
+        return (BaseTrackState)_trackStates.get(0);
     }
     
     // add following setters for subclasses.
     
+    public void setTrackParameters(double[] params, double magneticField)
+    {  
+        // Copy to this object's parameters array.
+        System.arraycopy(params, 0, _parameters, 0, 5);
+        
+        // Compute momentum from parameters and magnetic field.
+        double omega = _parameters[OMEGA];
+        if(abs(omega) < 0.0000001) omega=0.0000001;
+        double Pt = abs((1./omega) * magneticField* Constants.fieldConversion);
+        _momentum[0] = Pt * Math.cos(_parameters[PHI]);
+        _momentum[1] = Pt * Math.sin(_parameters[PHI]);
+        _momentum[2] = Pt * _parameters[TANLAMBDA];
+        
+        // Compute charge.
+        _charge = (int) signum(omega);
+        
+        // LCIO v2 ... setup a TrackState with full parameter list.
+        getFirstTrackState().setParameters(params, magneticField);
+    }
+    
     // TODO replace this with a SpacePoint
     /**
      * Set the reference point for this track. By default it is (0,0,0).
@@ -64,11 +106,26 @@
      * @param point The (x,y,z) reference point for this track.
      */
     public void setReferencePoint(double[] point)
-    {
-        _refPoint = point;
+    {        
+        this._refPoint = point;
+        
+        // Set the ref point on the first TrackState.
+        getFirstTrackState().setReferencePoint(point);
     }
     
     /**
+     * Set the covariance matrix for the track parameters.
+     * @param cov The covariance matrix as a SymetricMatrix.
+     */
+    public void setCovarianceMatrix(SymmetricMatrix cov)
+    {
+        _covMatrix = cov;
+        
+        // Set the covariance matrix on the TrackState, converting to a double array.
+        getFirstTrackState().setCovMatrix(_covMatrix.asPackedArray(true));
+    }
+         
+    /**
      * Sets whether the reference point is the distance of closest
      * approach to the origin.
      * @param isDCA true if the reference point is the dca.
@@ -92,38 +149,12 @@
     }
     
     /**
-     * Set the track parameters.
-     * @see LCIOParameters
-     * @param params The array of track parameters.
-     */
-    public void setTrackParameters(double[] params, double magneticField)
-    {
-        System.arraycopy(params, 0, _parameters, 0, 5);
-        double omega = _parameters[OMEGA];
-        if(abs(omega) < 0.0000001) omega=0.0000001;
-        double Pt = abs((1./omega) * magneticField* Constants.fieldConversion);
-        _momentum[0] = Pt * Math.cos(_parameters[PHI]);
-        _momentum[1] = Pt * Math.sin(_parameters[PHI]);
-        _momentum[2] = Pt * _parameters[TANLAMBDA];
-        _charge = (int) signum(omega);
-    }
-    
-    /**
-     * Set the covariance matrix for the track parameters.
-     * @param cov The covariance matrix as a double array.
-     */
-    public void setCovarianceMatrix(SymmetricMatrix cov)
-    {
-        _covMatrix = cov;
-    }
-    
-    /**
      * Set the chi-squared for the track fit.
      * Not defined whether this is the full or reduced chi-squared.
      * @param chisq The value of the track fit chi-squared.
      */
 // TODO verify if this is full or reduced chi-squared.
-    public void setChisq( double chisq)
+    public void setChisq(double chisq)
     {
         _chi2 = chisq;
     }
@@ -132,7 +163,7 @@
      * Set the number of degrees of freedom for this track fit.
      * @param n The number of degrees of freedom for this track fit.
      */
-    public void setNDF( int n)
+    public void setNDF(int n)
     {
         _ndf = n;
     }
@@ -400,4 +431,12 @@
     {
         return _type;
     }
+    /**
+     * Get the list of associated LCIO v2 TrackStates.
+     * @return The list of TrackStates.
+     */
+    public List<TrackState> getTrackStates()
+    {
+        return this._trackStates;
+    }
 }
\ No newline at end of file

lcsim/src/org/lcsim/mc/fast/tracking
ReconTrack.java 1.10 -> 1.10.4.1
diff -u -r1.10 -r1.10.4.1
--- ReconTrack.java	25 Apr 2008 06:13:09 -0000	1.10
+++ ReconTrack.java	14 Feb 2012 21:51:37 -0000	1.10.4.1
@@ -6,6 +6,8 @@
 import hep.physics.particle.Particle;
 import hep.physics.vec.Hep3Vector;
 import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
+
 import java.io.*;
 import java.util.Collections;
 import java.util.List;
@@ -19,7 +21,7 @@
  * are provided. <br>
  *
  * @author Tony Johnson, Wolfgang Walkowiak
- * @version $Id: ReconTrack.java,v 1.10 2008/04/25 06:13:09 timb Exp $
+ * @version $Id: ReconTrack.java,v 1.10.4.1 2012/02/14 21:51:37 jeremy Exp $
  */
 public class ReconTrack implements Track
 {
@@ -559,4 +561,9 @@
       }
       return errMatrix;
    }
-}
+   
+   public List<TrackState> getTrackStates()
+   {
+       return null;
+   }
+}
\ No newline at end of file

lcsim/src/org/lcsim/mc/fast/tracking/fix
FastMCTrack.java 1.1 -> 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- FastMCTrack.java	29 Nov 2007 21:29:35 -0000	1.1
+++ FastMCTrack.java	14 Feb 2012 21:51:37 -0000	1.1.4.1
@@ -1,5 +1,5 @@
 /**
- * @version $Id: FastMCTrack.java,v 1.1 2007/11/29 21:29:35 jstrube Exp $
+ * @version $Id: FastMCTrack.java,v 1.1.4.1 2012/02/14 21:51:37 jeremy Exp $
  */
 package org.lcsim.mc.fast.tracking.fix;
 
@@ -12,6 +12,7 @@
 import org.lcsim.event.LCIOParameters;
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
 import org.lcsim.event.LCIOParameters.ParameterName;
 import org.lcsim.spacegeom.CartesianPoint;
@@ -187,4 +188,9 @@
     public SpacePoint referencePoint() {
         return _referencePoint;
     }
-}
+    
+    public List<TrackState> getTrackStates()
+    {
+        return null;
+    }
+}
\ No newline at end of file

lcsim/src/org/lcsim/plugin/browser
TrackTableModel.java 1.3 -> 1.3.8.1
diff -u -r1.3 -r1.3.8.1
--- TrackTableModel.java	16 Aug 2007 21:06:58 -0000	1.3
+++ TrackTableModel.java	14 Feb 2012 21:51:37 -0000	1.3.8.1
@@ -8,18 +8,40 @@
  */
 class TrackTableModel extends GenericTableModel
 {
-   private static final String[] columns = {"Type","D0","Phi","Omega","Z0","TanLambda","Chi2","NDF","dEdx","Momentum"};
+   private static final String[] columns = {"Type", "D0", "Phi", "Omega", "Z0", "TanLambda", "Track States", "Momentum", "Chi2", "NDF", "dEdx"};
+       //, "Momentum"};
    private static Class klass = Track.class;
 
    TrackTableModel()
    {
-      super(klass,columns);
+       super(klass,columns);
    }
 
    public Object getValueAt(int row, int column)
    {
-      if (column > 0 && column <= 5) return ((Track) getData(row)).getTrackParameter(column-1);
-      else return super.getValueAt(row,column);
+       if (column == 0)
+       {
+           // Track type (???).
+           return ((Track)getData(row)).getType();
+       }
+       else if (column >= 1 && column <= 5)
+       {
+           // Displays data about first TrackState, only.
+           return ((Track)getData(row)).getTrackStates().get(0).getParameter(column-1);
+      }
+      else if (column == 6)
+      {
+          // Number of total TrackStates.
+          return ((Track)getData(row)).getTrackStates().size();
+      }
+      else if (column == 7)
+      {
+          return ((Track)getData(row)).getTrackStates().get(0).getMomentum();
+      }
+      else 
+      {
+          return super.getValueAt(row,column);
+      }
    }
    
    public Class getColumnClass(int column)
@@ -27,4 +49,4 @@
        if (column > 0 && column <= 5) return Double.class;
        else return super.getColumnClass(column);
    }
-}
+}
\ No newline at end of file

lcsim/src/org/lcsim/recon/cat
GarfieldTrack.java 1.2 -> 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- GarfieldTrack.java	21 Sep 2007 12:07:47 -0000	1.2
+++ GarfieldTrack.java	14 Feb 2012 21:51:37 -0000	1.2.6.1
@@ -25,7 +25,7 @@
  *
  * @author  E. von Toerne
  * @author  D. Onoprienko
- * @version $Id: GarfieldTrack.java,v 1.2 2007/09/21 12:07:47 onoprien Exp $
+ * @version $Id: GarfieldTrack.java,v 1.2.6.1 2012/02/14 21:51:37 jeremy Exp $
  */
 public class GarfieldTrack implements Track {
   
@@ -960,7 +960,10 @@
     return hel.base(2);
   }
   
-  
+  public List<TrackState> getTrackStates()
+  {
+      return null;
+  }
 }
 
 

lcsim/src/org/lcsim/recon/cat/util
BasicTrack.java 1.3 -> 1.3.4.1
diff -u -r1.3 -r1.3.4.1
--- BasicTrack.java	29 Nov 2007 02:25:59 -0000	1.3
+++ BasicTrack.java	14 Feb 2012 21:51:38 -0000	1.3.4.1
@@ -1,6 +1,7 @@
 package org.lcsim.recon.cat.util;
 
 import java.util.*;
+
 import org.lcsim.event.*;
 import org.lcsim.util.*;
 import hep.physics.matrix.SymmetricMatrix;
@@ -18,7 +19,7 @@
  * Includes method for initializing track parameters from momentum at a given point.
  *
  * @author D. Onoprienko
- * @version $Id: BasicTrack.java,v 1.3 2007/11/29 02:25:59 jstrube Exp $
+ * @version $Id: BasicTrack.java,v 1.3.4.1 2012/02/14 21:51:38 jeremy Exp $
  */
 public class BasicTrack implements Track {
 
@@ -186,4 +187,8 @@
     _conListener.conditionsChanged(null);
   }
   
+  public List<TrackState> getTrackStates()
+  {
+      return null;
+  }
 }

lcsim/src/org/lcsim/recon/tracking/seedtracker
MakeTracks.java 1.4 -> 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- MakeTracks.java	7 Aug 2009 23:33:17 -0000	1.4
+++ MakeTracks.java	14 Feb 2012 21:51:38 -0000	1.4.4.1
@@ -47,10 +47,7 @@
         List<Track> tracks = new ArrayList<Track>();
         
         //  Initialize the reference point to the origin
-        double[] ref = new double[3];
-        ref[0] = 0.;
-        ref[1] = 0.;
-        ref[2] = 0.;
+        double[] ref = new double[] {0., 0., 0.};
         
         //  Loop over the SeedCandidates that have survived
         for (SeedCandidate trackseed : seedlist) {
@@ -65,14 +62,14 @@
             
             //  Retrieve the helix and save the relevant bits of helix info
             HelicalTrackFit helix = trackseed.getHelix();
-            trk.setTrackParameters(helix.parameters(), bfield);
-            trk.setCovarianceMatrix(helix.covariance());
+            trk.setTrackParameters(helix.parameters(), bfield); // Sets first TrackState.
+            trk.setCovarianceMatrix(helix.covariance()); // Modifies first TrackState.
             trk.setChisq(helix.chisqtot());
             trk.setNDF(helix.ndf()[0]+helix.ndf()[1]);
             
             //  Flag that the fit was successful and set the reference point
             trk.setFitSuccess(true);
-            trk.setReferencePoint(ref);
+            trk.setReferencePoint(ref); // Modifies first TrackState.
             trk.setRefPointIsDCA(true);
             
             //  Set the strategy used to find this track

lcsim/src/org/lcsim/recon/tracking/seedtracker
SeedTrackerTrackStateDriver.java 1.8 -> 1.8.4.1
diff -u -r1.8 -r1.8.4.1
--- SeedTrackerTrackStateDriver.java	3 Dec 2010 21:12:26 -0000	1.8
+++ SeedTrackerTrackStateDriver.java	14 Feb 2012 21:51:38 -0000	1.8.4.1
@@ -30,11 +30,11 @@
  * work due to lost data and type information. And it must be run the
  * SeedTracker Driver.
  * 
- * @author richp
- * @author jeremym
- * @author ngraf
+ * @author Rich Partridge
+ * @author Jeremy McCormick
+ * @author Norman Graf
  * 
- * @version $Id: SeedTrackerTrackStateDriver.java,v 1.8 2010/12/03 21:12:26 ngraf Exp $
+ * @version $Id: SeedTrackerTrackStateDriver.java,v 1.8.4.1 2012/02/14 21:51:38 jeremy Exp $
  */
 public class SeedTrackerTrackStateDriver extends Driver
 {
@@ -80,7 +80,7 @@
     public void process(EventHeader event)
     {
         // Get the Tracks from the event. Collection name is SeedTracker's default.
-        List<Track> tracks = event.get(Track.class, "Tracks");
+        List<Track> tracks = event.get(Track.class, EventHeader.TRACKS);
 
         // TrackState lists.
         List<GenericObject> startObjs = new ArrayList<GenericObject>();
@@ -133,6 +133,7 @@
             // Calculate the Start state and add to list.
             double[] smom = ptrk.v();
             double[] spos = HelixUtils.PointOnHelix(helix, 0.).v();
+            
             TrackState startState = new TrackState(spos[0], spos[1], spos[2], smom[0], smom[1], smom[2]);
             startObjs.add(startState);
 
@@ -164,4 +165,81 @@
         event.put("StateAtECal", ecalObjs, GenericObject.class, 0);
         event.put("StateAtEnd", endObjs, GenericObject.class, 0);
     }
+    
+    private void setEcalTrackState(Track track)
+    {
+        SeedTrack strk = (SeedTrack) track;
+        SeedCandidate scand = strk.getSeedCandidate();
+        HelicalTrackFit helix = scand.getHelix();
+        Hep3Vector ptrk = new BasicHep3Vector(strk.getMomentum());
+        double smax = -9999.;
+        HelicalTrackHit last = null;
+        
+        for (HelicalTrackHit hit : scand.getHits())
+        {
+            double s = helix.PathMap().get(hit);
+            if (s > smax)
+            {
+                smax = s;
+                last = hit;
+            }
+        }
+        
+        TrackDirection trkdir = HelixUtils.CalculateTrackDirection(helix, smax);
+        
+        Hep3Vector dir = trkdir.Direction();
+        Hep3Vector pos = null;
+            
+        if (last instanceof HelicalTrackCross)    
+        {
+            HelicalTrackCross cross = (HelicalTrackCross) last;
+            cross.setTrackDirection(trkdir, helix.covariance());
+            pos = cross.getCorrectedPosition();
+        }
+        else
+        {
+            pos = last.getCorrectedPosition();
+        }
+
+        // Set the End TrackState from the outermost hit on the track.
+        Hep3Vector xmomentum = VecOp.mult(ptrk.magnitude(), dir);
+
+        // Set the End TrackState to the point of closest approach to the last hit.
+        swimmer.setTrack(track);
+        double s = swimmer.getDistanceToPoint(pos);
+        Hep3Vector corPos = swimmer.getPointAtLength(s);
+
+        // FIXME Set AtLastHit LCIO v2 TrackState here.
+        TrackState endState = new TrackState(corPos, xmomentum);
+
+        // Don't need start state anymore?????
+        // Calculate the Start state and add to list.
+        //double[] smom = ptrk.v();
+        //double[] spos = HelixUtils.PointOnHelix(helix, 0.).v();
+        //TrackState startState = new TrackState(spos[0], spos[1], spos[2], smom[0], smom[1], smom[2]);
+
+        // TODO Should set the ECal TrackState by propagating from the outermost hit on the track.
+        double sZ = swimmer.getDistanceToZ(ecalZ);
+        double sR = swimmer.getDistanceToPolyhedra(ecalRadius, ecalNumSides);
+        if (Double.isNaN(sR))
+        {
+            s = sZ;
+        }
+        else if (Double.isNaN(sZ))
+        {
+            s = sR;
+        }
+        else
+        {
+            s = Math.min(swimmer.getDistanceToZ(ecalZ), swimmer.getDistanceToPolyhedra(ecalRadius, ecalNumSides));
+            // Should this be changed to...
+            // s = Math.min(sZ, sR);   ?????
+        }
+        SpacePoint ecalPos = swimmer.getPointAtLength(s);
+        SpaceVector ecalMom = swimmer.getMomentumAtLength(s);
+
+        // FIXME Set AtCalorimeter state here.
+        TrackState ecalState = new TrackState(ecalPos.x(), ecalPos.y(), ecalPos.z(), ecalMom.x(), ecalMom.y(), ecalMom.z());
+        // Hmmm...now to recover the track parameters here!
+    }
 }

lcsim/src/org/lcsim/recon/vertexing/zvtop4
ZvTrack.java 1.24 -> 1.24.8.1
diff -u -r1.24 -r1.24.8.1
--- ZvTrack.java	23 Oct 2006 19:42:26 -0000	1.24
+++ ZvTrack.java	14 Feb 2012 21:51:38 -0000	1.24.8.1
@@ -1,5 +1,9 @@
 package org.lcsim.recon.vertexing.zvtop4;
 
+import static java.lang.Math.acos;
+import static java.lang.Math.cos;
+import static java.lang.Math.sin;
+import static java.lang.Math.sqrt;
 import hep.physics.matrix.SymmetricMatrix;
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
@@ -8,23 +12,16 @@
 import java.util.List;
 
 import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
-import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
 import org.lcsim.spacegeom.CartesianPoint;
 import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.util.swim.Helix;
-
-import static java.lang.Math.sqrt;
-import static java.lang.Math.cos;
-import static java.lang.Math.sin;
-import static java.lang.Math.acos;
-import static java.lang.Math.PI;
 
 /**
  * Representation of the Gaussian tubes
  * 
  * @author jstrube
- * @version $Id: ZvTrack.java,v 1.24 2006/10/23 19:42:26 tonyj Exp $
+ * @version $Id: ZvTrack.java,v 1.24.8.1 2012/02/14 21:51:38 jeremy Exp $
  */
 public class ZvTrack implements Track {
 
@@ -610,4 +607,9 @@
         t178 = Math.pow(-54 * t5 * t4 - 0.54e2 * t10 * t8 + 0.54e2 * t14 * t13 + 54 * z1 * t4 + 0.6e1 * t175, 0.1e1 / 0.3e1);
         return(t178 * t2 / 0.6e1 + 0.1e1 / t178 * t2 * (0.2e1 * t157 + 0.2e1 * t152 - t20 - 0.2e1 * t150 - 0.1e1));
     }
+    
+    public List<TrackState> getTrackStates()
+    {
+        return null;
+    }
 }

lcsim/src/org/lcsim/recon/ztracking
AbstractTrack.java 1.3 -> 1.3.8.1
diff -u -r1.3 -r1.3.8.1
--- AbstractTrack.java	23 Oct 2006 19:42:36 -0000	1.3
+++ AbstractTrack.java	14 Feb 2012 21:51:38 -0000	1.3.8.1
@@ -11,6 +11,7 @@
 
 import hep.physics.matrix.SymmetricMatrix;
 import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
 import java.util.ArrayList;
 import java.util.List;
@@ -37,4 +38,8 @@
     public List<Track> getTracks() { List<Track> list = new ArrayList<Track>(); return list; }
     public List<TrackerHit> getTrackerHits() { List<TrackerHit> list = new ArrayList<TrackerHit>(); return list; }
     public int getType() { return 0; }
+    public List<TrackState> getTrackStates()
+    {
+        return null;
+    }
 }

lcsim/src/org/lcsim/recon/ztracking
FoundTrack.java 1.3 -> 1.3.10.1
diff -u -r1.3 -r1.3.10.1
--- FoundTrack.java	5 Aug 2005 00:47:00 -0000	1.3
+++ FoundTrack.java	14 Feb 2012 21:51:38 -0000	1.3.10.1
@@ -10,6 +10,7 @@
 package org.lcsim.recon.ztracking;
 
 import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
 import java.util.ArrayList;
 import java.util.List;
@@ -36,4 +37,8 @@
     public double getPY() { return py; }
     public double getPZ() { return pz; }
     public double[] getMomentum() { return momentum; }
+    public List<TrackState> getTrackStates()
+    {
+        return null;
+    }
 }

lcsim/src/org/lcsim/util/lcio
LCIOConstants.java 1.15 -> 1.15.4.1
diff -u -r1.15 -r1.15.4.1
--- LCIOConstants.java	24 Aug 2011 18:51:18 -0000	1.15
+++ LCIOConstants.java	14 Feb 2012 21:51:38 -0000	1.15.4.1
@@ -6,9 +6,11 @@
  */
 public interface LCIOConstants
 {
-   int MAJORVERSION = 1;
-   int MINORVERSION = 60;
-   
+   //int MAJORVERSION = 1;
+   //int MINORVERSION = 60;
+   int MAJORVERSION = 2;
+   int MINORVERSION = 0;
+    
    // bits in flag words
    // SimCalorimeterHit (CH)
    int CHBIT_LONG = 31;

lcsim/src/org/lcsim/util/lcio
SIOTrack.java 1.5 -> 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- SIOTrack.java	17 Oct 2007 02:06:23 -0000	1.5
+++ SIOTrack.java	14 Feb 2012 21:51:38 -0000	1.5.6.1
@@ -3,134 +3,192 @@
 import hep.io.sio.SIOInputStream;
 import hep.io.sio.SIOOutputStream;
 import hep.io.sio.SIORef;
-import hep.physics.matrix.SymmetricMatrix;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
+
 import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
 import org.lcsim.event.TrackerHit;
 import org.lcsim.event.base.BaseTrack;
-
+import org.lcsim.event.base.BaseTrackState;
 
 /**
- *
+ * 
  * @author Tony Johnson
- * @version $Id: SIOTrack.java,v 1.5 2007/10/17 02:06:23 tonyj Exp $
+ * @author Jeremy McCormick
+ * @version $Id: SIOTrack.java,v 1.5.6.1 2012/02/14 21:51:38 jeremy Exp $
  */
 class SIOTrack extends BaseTrack
 {
-   private List<SIORef> tempHits;
-   private List<SIORef> tempTracks;
-   
-   SIOTrack(SIOInputStream in, int flag, int version, double bField) throws IOException
-   {
-      _type = in.readInt();
-      double[] parameters = new double[5];
-      for (int i=0; i<parameters.length; i++) parameters[i] = in.readFloat();
-      setTrackParameters(parameters,bField);
-      double[] covMatrix = new double[15];
-      for (int i=0; i<covMatrix.length; i++) covMatrix[i] = in.readFloat();
-      _covMatrix = new SymmetricMatrix(5,covMatrix,true);
-      _refPoint = new double[3];
-      _refPoint[0] = in.readFloat();
-      _refPoint[1] = in.readFloat();
-      _refPoint[2] = in.readFloat();
-      _chi2 = in.readFloat();
-      _ndf = in.readInt() ;
-      _dEdx = in.readFloat();
-      _dEdxErr = in.readFloat();
-      _innermostHitRadius = in.readFloat() ;
-      int nHitNumbers = in.readInt() ;
-      _subdetId = new int[nHitNumbers] ;
-      for (int i = 0; i < nHitNumbers; i++)
-      {
-         _subdetId[i] = in.readInt() ;
-      }
-      int nTracks = in.readInt();
-      tempTracks = new ArrayList(nTracks);
-      _tracks = null;
-      for (int i=0; i<nTracks; i++)
-      {
-         tempTracks.add(in.readPntr());
-      }
-      if (LCIOUtil.bitTest(flag,LCIOConstants.TRBIT_HITS))
-      {
-         int nHits = in.readInt();
-         tempHits = new ArrayList(nHits);
-         _hits = null;
-         for (int i = 0; i < nHits; i++)
-         {
-            tempHits.add(in.readPntr());
-         }
-      }
-      
-      in.readPTag(this);
-   }
-   static void write(Track track, SIOOutputStream out, int flag) throws IOException
-   {
-      out.writeInt(track.getType());
-      double[] parm = track.getTrackParameters();
-      for (int i=0; i<5; i++) out.writeFloat((float) parm[i]);
-      double[] covMatrix = track.getErrorMatrix().asPackedArray(true);
-      for (int i=0; i<15; i++) out.writeFloat((float) covMatrix[i]);
-      double[] referencePoint = track.getReferencePoint();
-      for (int i=0; i<3; i++) out.writeFloat((float) referencePoint[i]);
-      out.writeFloat((float) track.getChi2());
-      out.writeInt(track.getNDF());
-      out.writeFloat((float) track.getdEdx());
-      out.writeFloat((float) track.getdEdxError());
-      out.writeFloat((float) track.getRadiusOfInnermostHit()) ;
-      int[] hitNumbers = track.getSubdetectorHitNumbers();
-      out.writeInt( hitNumbers.length ) ;
-      for (int i = 0; i < hitNumbers.length; i++)
-      {
-         out.writeInt( hitNumbers[i] ) ;
-      }
-      List<Track> tracks = track.getTracks() ;
-      out.writeInt( tracks.size()  ) ;
-      for (Track t : tracks)
-      {
-         out.writePntr(t);
-      }
-      if(LCIOUtil.bitTest(flag,LCIOConstants.TRBIT_HITS))
-      {
-         List<TrackerHit> hits = track.getTrackerHits();
-         out.writeInt(hits.size());
-         for (TrackerHit hit : hits)
-         {
-            out.writePntr(hit);
-         }
-      }
-      out.writePTag(track);
-   }
-   
-   public List<TrackerHit> getTrackerHits()
-   {
-      if (_hits == null && tempHits != null)
-      {
-         _hits = new ArrayList<TrackerHit>(tempHits.size());
-         for (SIORef ref : tempHits)
-         {
-            _hits.add((TrackerHit) ref.getObject());
-         }
-         tempHits = null;
-      }
-      return _hits == null ? Collections.<TrackerHit>emptyList() : _hits;
-   }
-   
-   public List<Track> getTracks()
-   {
-      if (_tracks == null && tempTracks != null)
-      {
-         _tracks = new ArrayList<Track>(tempTracks.size());
-         for (SIORef ref : tempTracks)
-         {
-            _tracks.add((Track) ref.getObject());
-         }
-         tempTracks = null;
-      }
-      return _tracks == null ? Collections.<Track>emptyList() : _tracks;
-   }
-}
+    private List<SIORef> tempHits;
+    private List<SIORef> tempTracks;
+
+    SIOTrack(SIOInputStream in, int flag, int version, double bField) throws IOException
+    {
+        _type = in.readInt();
+
+        // read TrackStates
+        int nTrackStates = 1; // set to 1 per default for backwards compatibility
+
+        if (version>=2000)
+        {
+            nTrackStates = in.readInt();
+        }
+
+        for (int i = 0; i<nTrackStates; i++)
+        {
+            // TODO put this code into SIOTrackState.java ?
+            BaseTrackState ts = new BaseTrackState();
+
+            if (version>=2000)
+            {
+                ts.setLocation(in.readInt());
+            }
+
+            ts.setD0(in.readFloat());
+            ts.setPhi(in.readFloat());
+            ts.setOmega(in.readFloat());
+            ts.setZ0(in.readFloat());
+            ts.setTanLambda(in.readFloat());
+            
+            // Compute the momentum while we have access to the B-field.
+            ts.computeMomentum(bField);
+            
+            double[] covMatrix = new double[15]; // FIXME hardcoded 15
+            for (int j = 0; j<covMatrix.length; j++)
+                covMatrix[j] = in.readFloat();
+            ts.setCovMatrix(covMatrix);
+            double[] referencePoint = new double[3]; // FIXME hardcoded 3
+            for (int j = 0; j<referencePoint.length; j++)
+                referencePoint[j] = in.readFloat();
+            ts.setReferencePoint(referencePoint);
+
+            getTrackStates().add(ts);
+        }
+
+        _chi2 = in.readFloat();
+        _ndf = in.readInt();
+        _dEdx = in.readFloat();
+        _dEdxErr = in.readFloat();
+        _innermostHitRadius = in.readFloat();
+        
+        int nHitNumbers = in.readInt();
+        _subdetId = new int[nHitNumbers];
+        for (int i = 0; i<nHitNumbers; i++)
+        {
+            _subdetId[i] = in.readInt();
+        }
+        
+        int nTracks = in.readInt();
+        tempTracks = new ArrayList(nTracks);
+        _tracks = null;
+        for (int i = 0; i<nTracks; i++)
+        {
+            tempTracks.add(in.readPntr());
+        }
+        
+        if (LCIOUtil.bitTest(flag, LCIOConstants.TRBIT_HITS))
+        {
+            int nHits = in.readInt();
+            tempHits = new ArrayList(nHits);
+            _hits = null;
+            for (int i = 0; i<nHits; i++)
+            {
+                tempHits.add(in.readPntr());
+            }
+        }
+
+        in.readPTag(this);
+    }
+
+    static void write(Track track, SIOOutputStream out, int flag) throws IOException
+    {
+        out.writeInt(track.getType());
+
+        // write out TrackStates
+        List<TrackState> trackstates = track.getTrackStates();
+        out.writeInt(trackstates.size());
+
+        for (Iterator it = trackstates.iterator(); it.hasNext();)
+        {
+            TrackState trackstate = (TrackState) it.next();
+
+            // TODO put this code into SIOTrackState.java ?
+            out.writeInt(trackstate.getLocation());
+            out.writeFloat((float)trackstate.getD0());
+            out.writeFloat((float)trackstate.getPhi());
+            out.writeFloat((float)trackstate.getOmega());
+            out.writeFloat((float)trackstate.getZ0());
+            out.writeFloat((float)trackstate.getTanLambda());
+            double[] covMatrix = trackstate.getCovMatrix();
+            for (int i = 0; i<covMatrix.length; i++)
+                out.writeFloat((float)covMatrix[i]);
+            double[] referencePoint = trackstate.getReferencePoint();
+            for (int i = 0; i<referencePoint.length; i++)
+                out.writeFloat((float)referencePoint[i]);
+        }
+
+        out.writeFloat((float) track.getChi2());
+        out.writeInt(track.getNDF());
+        out.writeFloat((float) track.getdEdx());
+        out.writeFloat((float) track.getdEdxError());
+        out.writeFloat((float) track.getRadiusOfInnermostHit());
+        
+        int[] hitNumbers = track.getSubdetectorHitNumbers();
+        out.writeInt(hitNumbers.length);
+        for (int i = 0; i<hitNumbers.length; i++)
+        {
+            out.writeInt(hitNumbers[i]);
+        }
+        
+        List<Track> tracks = track.getTracks();
+        out.writeInt(tracks.size());
+        for (Track t: tracks)
+        {
+            out.writePntr(t);
+        }
+        
+        if (LCIOUtil.bitTest(flag, LCIOConstants.TRBIT_HITS))
+        {
+            List<TrackerHit> hits = track.getTrackerHits();
+            out.writeInt(hits.size());
+            for (TrackerHit hit: hits)
+            {
+                out.writePntr(hit);
+            }
+        }
+        out.writePTag(track);
+    }
+
+    public List<TrackerHit> getTrackerHits()
+    {
+        if (_hits==null && tempHits!=null)
+        {
+            _hits = new ArrayList<TrackerHit>(tempHits.size());
+            for (SIORef ref: tempHits)
+            {
+                _hits.add((TrackerHit) ref.getObject());
+            }
+            tempHits = null;
+        }
+        return _hits==null ? Collections.<TrackerHit> emptyList() : _hits;
+    }
+
+    public List<Track> getTracks()
+    {
+        if (_tracks==null && tempTracks!=null)
+        {
+            _tracks = new ArrayList<Track>(tempTracks.size());
+            for (SIORef ref: tempTracks)
+            {
+                _tracks.add((Track) ref.getObject());
+            }
+            tempTracks = null;
+        }
+        return _tracks==null ? Collections.<Track> emptyList() : _tracks;
+    }
+}
\ No newline at end of file

lcsim/test/org/lcsim/event
TrackStateTest.java added at 1.1.2.1
diff -N TrackStateTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackStateTest.java	14 Feb 2012 21:51:38 -0000	1.1.2.1
@@ -0,0 +1,118 @@
+package org.lcsim.event;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.lcsim.event.base.BaseLCSimEvent;
+import org.lcsim.event.base.BaseTrack;
+import org.lcsim.event.base.BaseTrackState;
+import org.lcsim.util.lcio.LCIOReader;
+import org.lcsim.util.lcio.LCIOWriter;
+import org.lcsim.util.loop.LCSimConditionsManagerImplementation;
+
+/**
+ * Tests that TrackStates can be written out and read back consistently by LCSim framework.
+ * @author Jeremy McCormick
+ */
+public class TrackStateTest extends TestCase
+{
+    public void testTrackStates() throws Exception
+    {
+        // Setup an event.
+        LCSimConditionsManagerImplementation.register(); // FIXME: Shouldn't this get setup automatically?
+        BaseLCSimEvent event = new BaseLCSimEvent(0, 0, "sidloi3");
+        
+        System.out.println("Making TrackStates for test...");
+        
+        // Create a dummy track with two TrackStates.
+        
+        BaseTrack track = new BaseTrack();
+        
+        // First test TrackState.
+        BaseTrackState ts1 = new BaseTrackState();
+        ts1.setLocation(TrackState.AtIP);
+        ts1.setD0(1.0);
+        ts1.setOmega(1.2345);
+        ts1.setTanLambda(5.6789);
+        ts1.setPhi(3.0);
+        ts1.setZ0(5.0);
+        double[] refPoint1 = {1.0, 2.0, 3.0};
+        ts1.setReferencePoint(refPoint1);
+        double[] cov = new double[15];
+        float c = 0f;
+        for (int i=0; i<15; i++) 
+        {
+            cov[i] = c;
+            c += 1.0;
+        }
+        ts1.setCovMatrix(cov);
+        ts1.printOut(System.out);
+        System.out.println("-------");
+        
+        // Second test TrackState.
+        BaseTrackState ts2 = new BaseTrackState();
+        ts2.setLocation(TrackState.AtFirstHit);
+        ts2.setD0(2.0);
+        double[] refPoint2 = {4.0, 5.0, 6.0};
+        ts2.setReferencePoint(refPoint2);
+        ts2.setCovMatrix(cov);
+        ts2.printOut(System.out);
+        System.out.println("-------");
+        
+        // Add TrackStates to Track.
+        track.getTrackStates().add(ts1);
+        track.getTrackStates().add(ts2);
+        
+        // Add Tracks to event.
+        List<Track> trackList = new ArrayList<Track>();
+        trackList.add(track);
+        event.put("TestTracks", trackList);
+        
+        // Write out the event with dummy Track collection.
+        File testFile = new File("TrackStateTest.slcio");
+        LCIOWriter writer = new LCIOWriter(testFile);
+        writer.write(event);
+        writer.close();
+        
+        // Read events back.
+        LCIOReader reader = new LCIOReader(testFile);
+        EventHeader readEvent = reader.read();
+        reader.close();
+        List<Track> readTrackList = readEvent.get(Track.class, "TestTracks");
+   
+        System.out.println("Reading back TrackStates for check...");
+        System.out.println("-------");
+        
+        // Check that there are two TrackStates with correct parameters.
+        
+        assertEquals(2, readTrackList.get(0).getTrackStates().size());
+        System.out.println("Successfully read 2 TrackStates from test event.");
+        TrackState checkts1 = readTrackList.get(0).getTrackStates().get(0);
+        ((BaseTrackState)checkts1).printOut(System.out);
+        
+        System.out.println("-------");
+        
+        // Check first TrackState.
+        assertEquals(TrackState.AtIP, checkts1.getLocation());
+        assertEquals(1.0, checkts1.getD0(), 1e-5);
+        for (int i=0; i<3; i++) {
+            assertEquals(refPoint1[i], checkts1.getReferencePoint()[i], 1e-5);
+        }
+        
+        // Check second TrackState.
+        TrackState checkts2 = readTrackList.get(0).getTrackStates().get(1);
+        ((BaseTrackState)checkts2).printOut(System.out);
+        assertEquals(TrackState.AtFirstHit, checkts2.getLocation());
+        assertEquals(2.0, checkts2.getD0(), 1e-5);
+        for (int i=0; i<3; i++) {
+            assertEquals(refPoint2[i], checkts2.getReferencePoint()[i], 1e-5);
+        }
+        
+        // TrackStates look good!
+        System.out.println("-------");
+        System.out.println("TrackState parameters look okay.");
+    }
+}
\ No newline at end of file
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1