Commit in lcsim/src/org/lcsim/recon/cluster/clumpfinder on MAIN
AlternateClumpFinder.java+88added 1.1
MJC: Rework clump-finder a little, including an option to apply the DirectedTree clusterer to the clumps

lcsim/src/org/lcsim/recon/cluster/clumpfinder
AlternateClumpFinder.java added at 1.1
diff -N AlternateClumpFinder.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AlternateClumpFinder.java	19 Nov 2007 22:00:34 -0000	1.1
@@ -0,0 +1,88 @@
+package org.lcsim.recon.cluster.clumpfinder;
+
+import java.util.*;
+import org.lcsim.event.*;
+import org.lcsim.util.*;
+import org.lcsim.recon.cluster.directedtree.*;
+import org.lcsim.util.decision.*;
+import org.lcsim.util.hitmap.*;
+import org.lcsim.util.lcio.LCIOConstants;
+
+/**
+  * Another way of clump-finding -- this adds an extra step which is to apply
+  * the DirectedTreeClusterer to the reconstructed clump. The idea is to split
+  * up clusters which have multiple local maxima in energy since that may indicate
+  * that we actually have two separate showers/clusters.
+  *
+  * @version $Id: AlternateClumpFinder.java,v 1.1 2007/11/19 22:00:34 mcharles Exp $
+  */
+
+public class AlternateClumpFinder extends ClumpFinder
+{
+    public AlternateClumpFinder(String inputHitMap, String outputClusterList, String outputHitMap) {
+	super(inputHitMap, outputClusterList, outputHitMap);
+    }
+
+    // Over-ride parent method (quite a bit of code duplication here)
+    public void process(EventHeader event) 
+    {
+	// Set up "loader" for DirectedTree
+	LoadMyCalorimeterHit loader = LoadMyCalorimeterHit.getInstance();
+	loader.setDefaultDensities();
+
+	// Read in the inputs
+	HitMap inputHitMap = (HitMap) (event.get(m_inputHitMapName));
+
+	// Outputs:
+	Vector<Cluster> outputClusterList = new Vector<Cluster>();
+	HitMap outputHitMap = new HitMap(inputHitMap); // initially cloned
+
+	// Clone the input hitmap to give a list of unused hits we can edit:
+	ListFilter<CalorimeterHit> hitFilter = new ListFilter<CalorimeterHit> (m_hitDecision);
+	List<CalorimeterHit> inputHits = hitFilter.filterList(inputHitMap.values());
+	// Filter these again, require high local density:
+	ListFilter<CalorimeterHit> densityFilter = new ListFilter<CalorimeterHit> (new HighHitDensityDecision(inputHits));
+	List<CalorimeterHit> unusedHits = densityFilter.filterList(inputHits);
+	// Apply some pre-filtering on these with a ListFilter to get a list of seeds
+	ListFilter<CalorimeterHit> seedFilter = new ListFilter<CalorimeterHit> (m_seedDecision);
+	List<CalorimeterHit> seedHits = seedFilter.filterList(unusedHits);
+
+	// For each seed hit, try to make a clump
+	for (CalorimeterHit seedHit : seedHits) {
+	    // This seed hit might already have been removed if it was used in a previous
+	    // clump, so we need to verify it's still there.
+	    if (unusedHits.contains(seedHit)) {
+		List<Cluster> treeClumps = makeTreeClumps(seedHit, unusedHits);
+		for (Cluster clump : treeClumps) {
+		    if (m_clumpDecision.valid(clump)) {
+			// Accept this clump -- add it to the output list and remove its hits from consideration
+			outputClusterList.add(clump);
+			for (CalorimeterHit hitInClump : clump.getCalorimeterHits()) {
+			    unusedHits.remove(hitInClump);
+			    outputHitMap.remove(hitInClump.getCellID());
+			}
+		    }
+		}
+	    }
+	}
+
+	// Write out:
+	event.put(m_outputHitMapName, outputHitMap);
+	int flag = 1<<LCIOConstants.CLBIT_HITS; // needed to make sure that hits appear when read back in
+	event.put(m_outputClusterListName, outputClusterList, Cluster.class, flag);
+    }
+
+    // Over-ride parent algorithm
+    protected List<Cluster> makeTreeClumps(CalorimeterHit seedHit, List<CalorimeterHit> unusedHits) {
+        // Start with parent output:
+	Cluster wholeClumpMadeByParent = makeClump(seedHit, unusedHits);
+
+	// Prep for DTree
+	DirectedTreeClusterer localClusterer = new DirectedTreeClusterer();
+	List<Cluster> subClusters = localClusterer.createClusters(wholeClumpMadeByParent.getCalorimeterHits());
+	return subClusters;
+    }
+
+}
+
+    
CVSspam 0.2.8