lcsim/src/org/lcsim/recon/pfa/identifier
diff -N DualActionTrackClusterMatcher.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DualActionTrackClusterMatcher.java 19 Nov 2007 20:28:35 -0000 1.1
@@ -0,0 +1,55 @@
+package org.lcsim.recon.pfa.identifier;
+
+import java.util.*;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.mipfinder.*;
+
+/**
+ * A utility class for matching tracks to clusters.
+ *
+ * This class doesn't do the clustering itself -- instead, it takes two other
+ * TrackClusterMatchers and delegates to them. It first tries to match the
+ * track to a MIP cluster using the first TrackClusterMatcher; if that fails,
+ * it will try to match the track to any cluster using the second
+ * TrackClusterMatcher.
+ *
+ * For now, MIPs are identified by checking whether the Cluster is an instance
+ * of org.lcsim.recon.cluster.mipfinder.MIPCluster
+ *
+ * @author Mat Charles
+ * @version $Id: DualActionTrackClusterMatcher.java,v 1.1 2007/11/19 20:28:35 mcharles Exp $
+ */
+
+public class DualActionTrackClusterMatcher implements TrackClusterMatcher {
+
+ TrackClusterMatcher m_mipTrackClusterMatcher;
+ TrackClusterMatcher m_genericTrackClusterMatcher;
+
+ /** Constructor: Supply the two TrackClusterMatchers that the matching is delegated to. */
+ public DualActionTrackClusterMatcher(TrackClusterMatcher mipTrackClusterMatcher, TrackClusterMatcher genericTrackClusterMatcher) {
+ m_mipTrackClusterMatcher = mipTrackClusterMatcher;
+ m_genericTrackClusterMatcher = genericTrackClusterMatcher;
+ }
+
+ /** Main interface. */
+ public Cluster matchTrackToCluster(Track tr, List<Cluster> clusters) {
+ // First try the MIPs...
+ List<Cluster> mipClusters = new Vector<Cluster>();
+ for (Cluster clus : clusters) {
+ // This is a bit of an ugly cross-check... would be better to be given a list
+ // of clusters, or to pull one down from the event by name.
+ if (clus instanceof MIPCluster) {
+ mipClusters.add(clus);
+ }
+ }
+
+ Cluster matchedMIP = m_mipTrackClusterMatcher.matchTrackToCluster(tr, mipClusters);
+ if (matchedMIP != null) {
+ return matchedMIP;
+ }
+
+ // That didn't work -- now try generic match
+ Cluster matchedClus = m_genericTrackClusterMatcher.matchTrackToCluster(tr, clusters);
+ return matchedClus;
+ }
+}
lcsim/src/org/lcsim/recon/pfa/identifier
diff -N SequentialTrackClusterMatcher.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SequentialTrackClusterMatcher.java 19 Nov 2007 20:28:35 -0000 1.1
@@ -0,0 +1,44 @@
+package org.lcsim.recon.pfa.identifier;
+
+import java.util.*;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.mipfinder.*;
+
+/**
+ * A utility class for matching tracks to clusters.
+ *
+ * This class doesn't do the clustering itself -- instead, it takes other
+ * TrackClusterMatchers and delegates to them, trying to match the
+ * track to a cluster using them in sequence.
+ *
+ * @author Mat Charles
+ * @version $Id: SequentialTrackClusterMatcher.java,v 1.1 2007/11/19 20:28:35 mcharles Exp $
+ */
+
+public class SequentialTrackClusterMatcher implements TrackClusterMatcher {
+
+ List<TrackClusterMatcher> m_matchers = null;
+
+ /** Simple constructor. */
+ public SequentialTrackClusterMatcher() {
+ m_matchers = new Vector<TrackClusterMatcher>();
+ }
+
+ /** Main interface. */
+ public Cluster matchTrackToCluster(Track tr, List<Cluster> clusters) {
+ for (TrackClusterMatcher matcher : m_matchers) {
+ Cluster matchedCluster = matcher.matchTrackToCluster(tr, clusters);
+ if (matchedCluster != null) {
+ // Found a match
+ return matchedCluster;
+ }
+ }
+ // Nothing found
+ return null;
+ }
+
+ /** Add a TrackClusterMatcher to the end of the list to use. */
+ public void addMatcher(TrackClusterMatcher matcher) {
+ m_matchers.add(matcher);
+ }
+}