Print

Print


Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
CheckSkeletonsForMultipleTracks.java+18-141.1 -> 1.2
MJC: Make CheckSkeletonsForMultipleTracks able to use other kinds of track-cluster matching besides custom helix method

lcsim/src/org/lcsim/contrib/uiowa
CheckSkeletonsForMultipleTracks.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- CheckSkeletonsForMultipleTracks.java	16 May 2007 20:58:13 -0000	1.1
+++ CheckSkeletonsForMultipleTracks.java	21 Sep 2007 01:01:18 -0000	1.2
@@ -10,6 +10,7 @@
 import org.lcsim.event.util.*;
 import org.lcsim.recon.cluster.structural.likelihood.*;
 import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.recon.pfa.identifier.TrackClusterMatcher;
 
 public class CheckSkeletonsForMultipleTracks extends Driver {
 
@@ -20,13 +21,15 @@
     protected String m_mipsListName;
     protected String m_clumpsListName;
     protected LikelihoodEvaluator m_eval = null;
-    public CheckSkeletonsForMultipleTracks(LikelihoodEvaluator eval, String inputTrackList, String inputSkeletonClusterList, String outputSkeletonClusterList, String mips, String clumps) {
+    protected TrackClusterMatcher m_clusterMatcher = null;
+    public CheckSkeletonsForMultipleTracks(LikelihoodEvaluator eval, String inputTrackList, String inputSkeletonClusterList, String outputSkeletonClusterList, String mips, String clumps, TrackClusterMatcher clusterMatcher) {
 	m_eval = eval;
 	m_inputSkeletonClusterListName = inputSkeletonClusterList;
 	m_outputSkeletonClusterListName = outputSkeletonClusterList;
 	m_inputTrackListName = inputTrackList;
 	m_mipsListName = mips;
 	m_clumpsListName = clumps;
+	m_clusterMatcher = clusterMatcher;
     }
 
     public void process(EventHeader event) {
@@ -44,11 +47,8 @@
 	// and we don't want to be confused by a nearby track that shouldn't be
 	// hooked up to any of these.
 	Map<Cluster,List<Track>> map = new HashMap<Cluster,List<Track>> ();
-	LocalHelixExtrapolationTrackClusterMatcher tmpExtrap = new LocalHelixExtrapolationTrackClusterMatcher();
-	tmpExtrap.process(event);
-	tmpExtrap.setCutSeparation(14.0); // about two cells
 	for (Track tr : inputTracks) {
-	    Cluster matchedCluster = tmpExtrap.matchTrackToCluster(tr, inputSkeletons);
+	    Cluster matchedCluster = m_clusterMatcher.matchTrackToCluster(tr, inputSkeletons);
 	    if (map.get(matchedCluster) == null) { map.put(matchedCluster, new Vector<Track>()); }
 	    map.get(matchedCluster).add(tr);
 	}
@@ -69,16 +69,16 @@
 		// Check for pathological case where >1 track hits the same subcluster
 		List<Link> confirmedLinks = new Vector<Link>(); // empty
 		List<Cluster> initialSkeletonList = assembleClusters(confirmedLinks, vClumpsAndMIPs);
-		boolean testInitiallyOK = checkUniqueTrackAssignments(tmpExtrap, initialSkeletonList, tracksForThisCluster);
+		boolean testInitiallyOK = checkUniqueTrackAssignments(m_clusterMatcher, initialSkeletonList, tracksForThisCluster);
 		while (!testInitiallyOK) { 
 		    // Pathological case. Only way out is to drop 1 (or more) tracks...
 		    if (m_debug) { System.out.println("Warning! In initial pass > 1 track already matched to a cluster segment. Trying to fix..."); }
-		    Track trackToRemove = findMultiplyAssignedTrack(tmpExtrap, initialSkeletonList, tracksForThisCluster);
+		    Track trackToRemove = findMultiplyAssignedTrack(m_clusterMatcher, initialSkeletonList, tracksForThisCluster);
 		    List<Track> newTracksForThisCluster = new Vector<Track>();
 		    newTracksForThisCluster.addAll(tracksForThisCluster);
 		    newTracksForThisCluster.remove(trackToRemove);
 		    tracksForThisCluster = newTracksForThisCluster;
-		    testInitiallyOK = checkUniqueTrackAssignments(tmpExtrap, initialSkeletonList, tracksForThisCluster);
+		    testInitiallyOK = checkUniqueTrackAssignments(m_clusterMatcher, initialSkeletonList, tracksForThisCluster);
 		}
 
 		// Compute likelihood of each pairwise link
@@ -157,15 +157,19 @@
 		    }
 		    // Assemble clusters with old link set (sanity check)
 		    List<Cluster> previousSkeletonList = assembleClusters(confirmedLinks, vClumpsAndMIPs);
-		    boolean testPreviousOK = checkUniqueTrackAssignments(tmpExtrap, previousSkeletonList, tracksForThisCluster);
-		    if (!testPreviousOK) { throw new AssertionError("Internal consistency failure"); }
+		    boolean testPreviousOK = checkUniqueTrackAssignments(m_clusterMatcher, previousSkeletonList, tracksForThisCluster);
+		    if (!testPreviousOK) { 
+			// This can happen if the track-matching behaviour depends on
+			// the other clusters present.
+			System.out.println("WARNING: Internal consistency failure"); 
+		    }
 		    // Assemble clusters with new link added
 		    List<Link> testLinkList = new Vector<Link>();
 		    testLinkList.addAll(confirmedLinks);
 		    testLinkList.add(bestLink);
 		    List<Cluster> updatedSkeletonList = assembleClusters(testLinkList, vClumpsAndMIPs);
 		    // Verify no double tracks
-		    boolean verified = checkUniqueTrackAssignments(tmpExtrap, updatedSkeletonList, tracksForThisCluster);
+		    boolean verified = checkUniqueTrackAssignments(m_clusterMatcher, updatedSkeletonList, tracksForThisCluster);
 		    if (verified) {
 			confirmedLinks.add(bestLink);
 			potentialTrackToTrackLinks.remove(bestLink);
@@ -185,7 +189,7 @@
 		    Map<Cluster, List<Track>> mapClustersToTracks = new HashMap<Cluster, List<Track>>();
 		    for (Track tr : tracksForThisCluster) {
 			if (tr == null) { throw new AssertionError("Null track!"); }
-			Cluster matchedCluster = tmpExtrap.matchTrackToCluster(tr, updatedSkeletonList);
+			Cluster matchedCluster = m_clusterMatcher.matchTrackToCluster(tr, updatedSkeletonList);
 			if (mapClustersToTracks.get(matchedCluster) == null) { mapClustersToTracks.put(matchedCluster, new Vector<Track>()); }
 			mapClustersToTracks.get(matchedCluster).add(tr);
 		    }
@@ -255,7 +259,7 @@
 	}
     }
 
-    boolean checkUniqueTrackAssignments(LocalHelixExtrapolationTrackClusterMatcher extrap, List<Cluster> clusters, List<Track> tracks) {
+    boolean checkUniqueTrackAssignments(TrackClusterMatcher extrap, List<Cluster> clusters, List<Track> tracks) {
 	Track duplicateTrack = findMultiplyAssignedTrack(extrap, clusters, tracks);
 	return (duplicateTrack == null);
     }
@@ -321,7 +325,7 @@
     }
 
     // Kind of hackish
-    Track findMultiplyAssignedTrack(LocalHelixExtrapolationTrackClusterMatcher extrap, List<Cluster> clusters, List<Track> tracks) {
+    Track findMultiplyAssignedTrack(TrackClusterMatcher extrap, List<Cluster> clusters, List<Track> tracks) {
 	Map<Cluster, List<Track>> mapClustersToTracks = new HashMap<Cluster, List<Track>>();
 	for (Track tr : tracks) {
 	    if (tr == null) { throw new AssertionError("Null track!"); }
CVSspam 0.2.8