Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/structural on MAIN
GenericStructuralDriver.java+27-281.2 -> 1.3
MJC: Refactor code a bit

lcsim/src/org/lcsim/recon/cluster/structural
GenericStructuralDriver.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- GenericStructuralDriver.java	2 Mar 2006 01:49:10 -0000	1.2
+++ GenericStructuralDriver.java	26 Apr 2007 17:16:52 -0000	1.3
@@ -19,7 +19,7 @@
  * track segments. See the process() description for more detail.
  *
  * @author Mat Charles <[log in to unmask]>
- * @version $Id: GenericStructuralDriver.java,v 1.2 2006/03/02 01:49:10 mcharles Exp $
+ * @version $Id: GenericStructuralDriver.java,v 1.3 2007/04/26 17:16:52 mcharles Exp $
  */
 
 public abstract class GenericStructuralDriver extends Driver 
@@ -125,36 +125,35 @@
      */
     protected boolean checkAssociationComponentToComponent(Cluster clus1, Cluster clus2) 
     {
-	// First make sure that the associator has been set up:
+	// Find the info for the two clusters:
+	ClusterMCPInfo info1 = findClusterTruthInfo(clus1);
+	ClusterMCPInfo info2 = findClusterTruthInfo(clus2);
+	// Use them to find the MCParticle that makes the biggest
+	// contribution to each cluster, and check if they match:
+	MCParticle max1 = info1.getMaxContributer();
+	MCParticle max2 = info2.getMaxContributer();
+	return (max1 == max2);
+    }
+
+    protected ClusterMCPInfo findClusterTruthInfo(Cluster clus) {
+	// Verify associator
 	if (m_clusterAssociator == null) {
 	    throw new java.lang.NullPointerException("ERROR: Tried to check association in class "+this.getClass().getName()+" but associator not initialized");
-	} else {
-	    // Check whether the event cache is out of date
-	    if (m_clusterAssociatorLastEvent != m_event) {
-		m_clusterAssociator.CreateLists(m_event);
-		m_clusterAssociatorLastEvent = m_event;
-	    }
-	    // Get the cluster info list
-	    List<ClusterMCPInfo> clusterInfoList = m_event.get(ClusterMCPInfo.class, m_clusterAssociatorOutputListClusterToMCParticle);
-	    // Find the info for the two clusters:
-	    ClusterMCPInfo info1 = null;
-	    ClusterMCPInfo info2 = null;
-	    for (ClusterMCPInfo info : clusterInfoList) {
-		Cluster clus = info.getCluster();
-		if (clus == clus1) { info1 = info; }
-		if (clus == clus2) { info2 = info; }
-	    }
-	    if (info1 == null || info2 == null) {
-		throw new java.lang.NullPointerException("ERROR: Info not found");
-	    } else {
-		// Found both info objects OK.
-		// Use them to find the MCParticle that makes the biggest
-		// contribution to each cluster, and check if they match:
-		MCParticle max1 = info1.getMaxContributer();
-		MCParticle max2 = info2.getMaxContributer();
-		return (max1 == max2);
-	    }
 	}
+	// Check whether the event cache is out of date
+	if (m_clusterAssociatorLastEvent != m_event) {
+	    m_clusterAssociator.CreateLists(m_event);
+	    m_clusterAssociatorLastEvent = m_event;
+	}
+	// Get the cluster info list
+	List<ClusterMCPInfo> clusterInfoList = m_event.get(ClusterMCPInfo.class, m_clusterAssociatorOutputListClusterToMCParticle);
+	// Find the info we're looking for
+	for (ClusterMCPInfo info : clusterInfoList) {
+	    Cluster currentClus = info.getCluster();
+	    if (clus == currentClus) { return info; }
+	}
+	// Failed to find info
+	return null;
     }
 
     /**
CVSspam 0.2.8