lcsim/src/org/lcsim/recon/tracking/seedtracker
diff -u -r1.8.4.1 -r1.8.4.2
--- SeedTrackerTrackStateDriver.java 14 Feb 2012 21:51:38 -0000 1.8.4.1
+++ SeedTrackerTrackStateDriver.java 21 Feb 2012 23:22:16 -0000 1.8.4.2
@@ -10,6 +10,8 @@
import org.lcsim.event.EventHeader;
import org.lcsim.event.GenericObject;
import org.lcsim.event.Track;
+import org.lcsim.event.base.BaseTrack;
+import org.lcsim.event.base.BaseTrackState;
import org.lcsim.fit.helicaltrack.HelicalTrackCross;
import org.lcsim.fit.helicaltrack.HelicalTrackFit;
import org.lcsim.fit.helicaltrack.HelicalTrackHit;
@@ -34,7 +36,7 @@
* @author Jeremy McCormick
* @author Norman Graf
*
- * @version $Id: SeedTrackerTrackStateDriver.java,v 1.8.4.1 2012/02/14 21:51:38 jeremy Exp $
+ * @version $Id: SeedTrackerTrackStateDriver.java,v 1.8.4.2 2012/02/21 23:22:16 ngraf Exp $
*/
public class SeedTrackerTrackStateDriver extends Driver
{
@@ -242,4 +244,131 @@
TrackState ecalState = new TrackState(ecalPos.x(), ecalPos.y(), ecalPos.z(), ecalMom.x(), ecalMom.y(), ecalMom.z());
// Hmmm...now to recover the track parameters here!
}
+
+ void setTrackStates(Track track)
+ {
+ // we need to populate track states at the following four
+ // canonical locations:
+ // AtIP
+ // AtFirstHit
+ // AtLastHit
+ // AtCalorimeter
+ //
+ List<BaseTrackState> trackStates = new ArrayList<BaseTrackState>();
+ SeedTrack strk = (SeedTrack) track;
+ SeedCandidate scand = strk.getSeedCandidate();
+ HelicalTrackFit helixfit = scand.getHelix();
+
+ // AtIP should be where this track is already defined, but double-check anyway
+
+ int trackStateLocation = BaseTrackState.AtIP;
+ double[] parameters = strk.getTrackParameters();
+ double[] covMatrix = strk.getErrorMatrix().asPackedArray(true);
+ double[] referencePoint = strk.getReferencePoint();
+
+ trackStates.add(new BaseTrackState(parameters, covMatrix, referencePoint, trackStateLocation));
+
+ // at first and last hits...
+
+ double smax = -9999.;
+ double smin = 9999.;
+ HelicalTrackHit lastHit = null;
+ HelicalTrackHit firstHit = null;
+
+ //loop over this hits on this track and get the first and last
+ for (HelicalTrackHit hit : scand.getHits())
+ {
+ double s = helixfit.PathMap().get(hit);
+ if (s > smax)
+ {
+ smax = s;
+ lastHit = hit;
+ }
+ if(s < smin)
+ {
+ smin = s;
+ firstHit = hit;
+ }
+ }
+
+ // AtFirstHit
+ trackStateLocation = BaseTrackState.AtFirstHit;
+ referencePoint = HelixUtils.PointOnHelix(helixfit, smin).v();
+ // by definition, z0 and d0 are zero at this point
+ parameters[BaseTrack.D0] = 0.;
+ parameters[BaseTrack.Z0] = 0.;
+ // This is the helical track fit
+ // There is no energy loss so omega does not change with state location
+ parameters[BaseTrack.OMEGA] = strk.getTrackParameter(BaseTrack.OMEGA);
+ // There is no multiple scattering, so tan(lambda) does not change
+ parameters[BaseTrack.TANLAMBDA] = strk.getTrackParameter(BaseTrack.TANLAMBDA);
+ // only phi changes as we progress along the helix
+ parameters[BaseTrack.PHI] = helixfit.phi0()-smin/helixfit.R();
+
+ // TODO calculate correct covariance matrix at this point...
+ double[] emptyCovarianceMatrix = new double[15];
+ trackStates.add(new BaseTrackState(parameters, emptyCovarianceMatrix, referencePoint, trackStateLocation));
+
+
+ //AtlastHit
+ trackStateLocation = BaseTrackState.AtLastHit;
+ referencePoint = HelixUtils.PointOnHelix(helixfit, smax).v();
+ // only phi changes as we progress along the helix
+ parameters[BaseTrack.PHI] = helixfit.phi0()-smax/helixfit.R();
+
+ // TODO calculate correct covariance matrix at this point...
+ trackStates.add(new BaseTrackState(parameters, emptyCovarianceMatrix, referencePoint, trackStateLocation));
+
+
+ //AtCalorimeter
+ trackStateLocation = BaseTrackState.AtCalorimeter;
+
+ // start at the last hit position and extrapolate to the
+ // face of the ECal.
+
+ TrackDirection trkdir = HelixUtils.CalculateTrackDirection(helixfit, smax);
+ Hep3Vector lastHitPosition = null;
+
+ if (lastHit instanceof HelicalTrackCross)
+ {
+ HelicalTrackCross cross = (HelicalTrackCross) lastHit;
+ cross.setTrackDirection(trkdir, helixfit.covariance());
+ lastHitPosition = cross.getCorrectedPosition();
+ }
+ else
+ {
+ lastHitPosition = lastHit.getCorrectedPosition();
+ }
+
+ // Set the End TrackState to the point of closest approach to the last hit.
+ swimmer.setTrack(track);
+ double s = swimmer.getDistanceToPoint(lastHitPosition);
+ Hep3Vector corPos = swimmer.getPointAtLength(s);
+
+ // Set the ECal TrackState by propagating from the point on the helix
+ // closest to the outermost hit on the fitted 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); ?????
+ }
+ referencePoint = HelixUtils.PointOnHelix(helixfit, s).v();
+ // only phi changes as we progress along the helix
+ parameters[BaseTrack.PHI] = helixfit.phi0()-s/helixfit.R();
+
+ // TODO calculate correct covariance matrix at this point...
+ trackStates.add(new BaseTrackState(parameters, emptyCovarianceMatrix, referencePoint, trackStateLocation));
+
+ }
}