Commit in lcsim/src/org/lcsim/recon/cluster/mipfinder on MAIN
MIPCluster.java+1-341.1 -> 1.2
MIPClusterBuilder.java+63-31.1 -> 1.2
+64-37
2 modified files
Moved check on goodness of MIP from MIPCluster to MIPClusterBuilder; also changed List to Collection at one spot to make interface more general

lcsim/src/org/lcsim/recon/cluster/mipfinder
MIPCluster.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MIPCluster.java	2 Jan 2006 21:45:19 -0000	1.1
+++ MIPCluster.java	16 Jan 2006 21:04:40 -0000	1.2
@@ -9,7 +9,7 @@
 /**
    Class for Cluster Candidates
 
-   @version $Id: MIPCluster.java,v 1.1 2006/01/02 21:45:19 mcharles Exp $
+   @version $Id: MIPCluster.java,v 1.2 2006/01/16 21:04:40 mcharles Exp $
    @author [log in to unmask]
 */
 
@@ -37,13 +37,6 @@
 	}
     }
     
-    public boolean isGoodMIP(){
-	boolean lIsGoodMIP = true; 
-	lIsGoodMIP = lIsGoodMIP && hits.size() >= 3; 
-	lIsGoodMIP = lIsGoodMIP && numberOfHitsInSeedLayers(); 
-	return lIsGoodMIP; 
-    }
-
     public boolean doesFork(){
 	/**
 	   Returns <tt>true</tt> or <tt>false</tt> depending on
@@ -58,32 +51,6 @@
 	lFork = b; 
     }
 
-    private boolean numberOfHitsInSeedLayers(){
-	int[] nHits = new int[nSeedLayers]; 
-	
-	int j=0; 
-	for (CalorimeterHit hit : hits) {
-	    IDDecoder id = hit.getIDDecoder();
-	    id.setID(hit.getCellID());
-	    int layer = id.getLayer(); 
-
-	    if ( j < nSeedLayers ) {
-		nHits[j]++; 
-	    }
-	    j++; 
-	}
-
-	int nHSum = 0; 
-	boolean lNOH = true; 
-	for ( int i=0; i<nSeedLayers; i++ ){
-	    lNOH = lNOH && nHits[i] <= 1; 
-	    nHSum += nHits[i];
-	}
-	
-	lNOH = lNOH && nHSum <= nSeedLayers && nHSum >= nSeedLayers-1; 
-	return lNOH; 
-    }
-
     private int firstLayer = 0; 
     private int nSeedLayers = 4; 
     private int direction = +1; 

lcsim/src/org/lcsim/recon/cluster/mipfinder
MIPClusterBuilder.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MIPClusterBuilder.java	2 Jan 2006 21:45:19 -0000	1.1
+++ MIPClusterBuilder.java	16 Jan 2006 21:04:40 -0000	1.2
@@ -6,6 +6,7 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Set;
+import java.util.Collection;
 
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.geometry.IDDecoder;
@@ -116,7 +117,8 @@
 		flash.remove(hit); 
 		
 		extend(cluster,hit,flash); 
-		if ( cluster.isGoodMIP() ) {
+		//if ( cluster.isGoodMIP() ) {
+		if (isGoodMIP(cluster)) {
 //
 // See if MIP forks. Criterion is two SingeHits in the same Layer
 //
@@ -234,10 +236,10 @@
     private List<AbstractHitType> hitTypes;
 
     private Flash flash; 
-    private List<CalorimeterHit> nucleii = new Vector<CalorimeterHit>(); 
+    private Collection<CalorimeterHit> nucleii = new Vector<CalorimeterHit>(); 
     private boolean lUserNucleii = false; 
 
-    public void provideNucleii(List<CalorimeterHit> v){
+    public void provideNucleii(Collection<CalorimeterHit> v){
 	nucleii = v; 
 	lUserNucleii = true; 
     }
@@ -245,6 +247,64 @@
     private double eMin = 0.; 
     private double eMax = 1000.; 
 
+    /**
+     * Check whether this is a valid MIP cluster. Requirements are:
+     *   (1) At least 3 hits
+     *   (2) <=1 hit in each seed layer
+     *   (3) Hits in all or all-but-one of the seed layers
+     */
+    protected boolean isGoodMIP(Cluster clus) 
+    {
+	// First, do the easy check on the # of hits:
+	if (clus.getCalorimeterHits().size()<3) {
+	    return false;
+	}
+
+	// Second, check the number of hits in each seed layer.
+	// There are [nSeedLayers] seed layers, starting at
+	// [firstLayer] and moving in [direction].
+	//
+	// For this check, we use an array to convert from the
+	// logical layer (0,1,2,...,nSeedLayers-1) to the physical
+	// layer (e.g. 29,28,27,...,25).
+	int[] layer = new int[nSeedLayers];
+	int[] hitCount = new int[nSeedLayers]; // Hits in each logical layer
+	for (int i=0; i<nSeedLayers; i++) {
+	    layer[i] = firstLayer + direction*i;
+	}
+	// For each hit, find the physical layer and work back
+	// to the logical layer.
+	for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+	    IDDecoder id = hit.getIDDecoder();
+	    id.setID(hit.getCellID());
+	    int thisHitLayer = id.getLayer();
+	    for (int i=0; i<layer.length; i++) {
+		if (layer[i] == thisHitLayer) {
+		    hitCount[i]++; // Found a hit in this logical layer
+		}
+	    }
+	}
+
+	// Verify <=1 hit in each seed layer
+	for (int i=0; i<layer.length; i++) {
+	    if (hitCount[i] > 1) { 
+		return false;
+	    }
+	}
+	
+	// Verify hits in all or all-but-one of the seed layers
+	int seedHitCount = 0;
+	for (int i=0; i<layer.length; i++) {
+	    seedHitCount += hitCount[i];
+	}
+	if (seedHitCount < layer.length-1) {
+	    return false;
+	}
+
+	// Passed all checks
+	return true;
+    }
+
     public void setMinimumHitEnergy(double v){
 	eMin = v; 
     }
CVSspam 0.2.8