Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/util on MAIN
IsolatedHitDecision.java+68added 1.1
MJC: Added a simple class to check whether a hit has neighbours

lcsim/src/org/lcsim/recon/cluster/util
IsolatedHitDecision.java added at 1.1
diff -N IsolatedHitDecision.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ IsolatedHitDecision.java	20 Sep 2007 21:09:00 -0000	1.1
@@ -0,0 +1,68 @@
+package org.lcsim.recon.cluster.util;
+
+import org.lcsim.util.*;
+import org.lcsim.event.*;
+import org.lcsim.util.decision.DecisionMakerSingle;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.util.hitmap.HitMap;
+import org.lcsim.event.CalorimeterHit;
+
+/**
+ * Check whether a hit in the calorimeter is isolated.
+ * Here, "isolated" means that there is no other nearby hit
+ * within (dU, dV, dLayer). By default, the class searches
+ * for other hits within dU=1, dV=1, dLayer=1.
+ *
+ * In order to scan for nearby hits, the class needs to know
+ * what HitMap the hit is drawn from. This is supplied by name
+ * in the constuctor, and is picked up on an event-by-event
+ * basis from EventHeader (class must be added as a Driver).
+ *
+ * @version $Id: IsolatedHitDecision.java,v 1.1 2007/09/20 21:09:00 mcharles Exp $
+ */
+
+public class IsolatedHitDecision extends Driver implements DecisionMakerSingle<CalorimeterHit> 
+{
+
+    /** Constructor. Takes name of hit map to scan for neighbours as an argument. */
+    public IsolatedHitDecision(String hitMap) {
+	m_hitMapName = hitMap;
+    }
+
+    /** Check whether the hit is isolated. */
+    public boolean valid(CalorimeterHit hit) {
+	// Pick up geometry information
+	IDDecoder decoder = hit.getIDDecoder();
+	decoder.setID(hit.getCellID());
+	// Scan neighbours for live hit
+	long[] neighbors = decoder.getNeighbourIDs(m_dLayer, m_dU, m_dV);
+	for (long id : neighbors) {
+	    CalorimeterHit h = m_hitmap.get(id);
+	    if (h != null) {
+		// Neighbour found => not isolated
+		return false;
+	    }
+	}
+	// No hit found => isolated
+	return true;
+    }
+
+    /** Pick up per-event information. */
+    public void process(EventHeader event) {
+	m_hitmap = (HitMap) (event.get(m_hitMapName));
+    }
+
+    /** Optionally, change dU, dV, dLayer from defaults. */
+    public void setIsolationCriteria(int dU, int dV, int dLayer) {
+	m_dU = dU;
+	m_dV = dV;
+	m_dLayer = dLayer;
+    }
+
+    String m_hitMapName = null;
+    HitMap m_hitmap = null;
+    int m_dU = 1;
+    int m_dV = 1;
+    int m_dLayer = 1;
+}
+    
CVSspam 0.2.8