Print

Print


Commit in lcsim/src/org/lcsim/contrib/uiowa/structural on MAIN
HighHitDensityDecision.java+80added 1.1
A decision maker to look for hits with a high local hit density

lcsim/src/org/lcsim/contrib/uiowa/structural
HighHitDensityDecision.java added at 1.1
diff -N HighHitDensityDecision.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HighHitDensityDecision.java	19 Oct 2005 19:42:09 -0000	1.1
@@ -0,0 +1,80 @@
+package structural;
+
+import java.lang.String;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import java.util.HashMap;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.Cluster;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.geometry.IDDecoder;
+
+import util.decision.*; //import org.lcsim.util.decision.*;
+
+/**
+ * A DecisionMaker for CalorimeterHit objects which requires them to
+ * have a high local hit density. Right now the values are hard-coded.
+ * Eventually this should be made more flexible and moved outside
+ * the "structural" package.
+ *
+ * @version $Id: HighHitDensityDecision.java,v 1.1 2005/10/19 19:42:09 mcharles Exp $
+ */
+
+public class HighHitDensityDecision implements DecisionMakerSingle<CalorimeterHit> 
+{
+    /**
+     * Constructor. 
+     *
+     * @param hits The list of hits to be used for the local density calcualtion
+     */
+    public HighHitDensityDecision(List<CalorimeterHit> hits) {
+	m_unusedHits = hits;
+    }
+    
+    /**
+     * Check if the CalorimeterHit has a high local hit density.
+     * Currently hard-coded to look in a 5x5x3 grid and require
+     * at least 6 other hits present.
+     */
+    public boolean valid(CalorimeterHit seedHit) 
+    {
+	// Find hits within m_dist:
+	org.lcsim.geometry.IDDecoder id = seedHit.getIDDecoder();
+	org.lcsim.geometry.CalorimeterIDDecoder idCAL = (org.lcsim.geometry.CalorimeterIDDecoder) (id);
+	idCAL.setID(seedHit.getCellID());
+	if (!idCAL.supportsNeighbours()) {
+	    throw new AssertionError("Can't get neighbours!");
+	} else {
+	    // Parameters (hard-coded for now);
+	    int deltaLayer = 1;
+	    int deltaTheta = 2;
+	    int deltaPhi = 2;
+	    int minNeighbours = 6;
+	    // Find all hits from [unusedHits] within range:
+	    long[] neighbourIDs = idCAL.getNeighbourIDs(deltaLayer, deltaTheta, deltaPhi);
+	    List<CalorimeterHit> neighbourHits = new Vector<CalorimeterHit>();
+	    for (long neighbourID : neighbourIDs) {
+		for (CalorimeterHit unusedHit : m_unusedHits) {
+		    if (unusedHit.getCellID() == neighbourID) {
+			neighbourHits.add(unusedHit);
+			break;
+		    }
+		}
+	    }
+	    // Were there enough?
+	    if (neighbourHits.size() >= minNeighbours) {
+		// Accept this
+		return true;
+	    } else {
+		// Reject this
+		return false;
+	    }
+	}
+    }
+    
+    protected List<CalorimeterHit> m_unusedHits = null;
+}
CVSspam 0.2.8