lcsim/src/org/lcsim/recon/cluster/mst
diff -u -r1.3 -r1.4
--- MSTClusterDriver.java 17 Feb 2006 00:48:04 -0000 1.3
+++ MSTClusterDriver.java 21 Jun 2006 00:43:51 -0000 1.4
@@ -9,15 +9,16 @@
import org.lcsim.event.CalorimeterHit;
import org.lcsim.recon.cluster.util.*;
+import org.lcsim.recon.cluster.util.Clusterer;
import org.lcsim.util.decision.*;
import org.lcsim.util.hitmap.HitMap;
/**
* A convenience class which wraps the MSTClusterBuilder in a Driver.
*
- * @version $Id: MSTClusterDriver.java,v 1.3 2006/02/17 00:48:04 mcharles Exp $
+ * @version $Id: MSTClusterDriver.java,v 1.4 2006/06/21 00:43:51 mcharles Exp $
*/
-public class MSTClusterDriver extends Driver {
+public class MSTClusterDriver extends Driver implements Clusterer {
protected double threshold = 30.0;
protected String clusterName;
@@ -94,6 +95,51 @@
}
}
+ /** Ron's Clusterer interface */
+ public List<Cluster> createClusters(Map<Long,CalorimeterHit> map) {
+ Collection<CalorimeterHit> inputHits = new Vector<CalorimeterHit>();
+ inputHits.addAll(map.values());
+ // We're using a Vector, which can safely be cast to a List
+ List<CalorimeterHit> inputHitList = (List<CalorimeterHit>) (inputHits);
+ // Pass it to the other method (to keep the code flow to a single path)
+ return createClusters(inputHitList);
+ }
+
+ /** Ron's Clusterer interface */
+ public List<Cluster> createClusters(List<CalorimeterHit> hits) {
+ try {
+ ObjectToClusterWrapper wrap = new BasicObjectToClusterWrapper();
+ List<Cluster> wrappedList = wrap.wrapListOfObjects(hits);
+ List<Cluster> outputList = subProcess(wrappedList, null);
+ return outputList;
+ } catch (UnwrappableObjectException x) {
+ // We fed it an object it didn't understand
+ throw new AssertionError(x);
+ }
+ }
+
+ /**
+ * Common denominator/backend of clustering methods
+ */
+ protected List<Cluster> subProcess(List<Cluster> inputList, EventHeader thisEvent)
+ {
+ // Apply prefilter:
+ ListFilter<Cluster> filter = new ListFilter<Cluster> (inputDecision);
+ List<Cluster> list = filter.filterList(inputList);
+
+ // Make the clusterer:
+ MSTClusterBuilder clusterBuilder = new MSTClusterBuilder( list, thisEvent );
+ clusterBuilder.registerMetrics(metrics);
+ clusterBuilder.setThreshold(threshold);
+ clusterBuilder.setSeedDecision(seedDecision);
+ clusterBuilder.setPairDecision(pairDecision);
+ clusterBuilder.setOutputDecision(outputDecision);
+
+ // Run the clusterer
+ List<Cluster> outputList = clusterBuilder.doClustering();
+ return outputList;
+ }
+
/**
* Process one event.
*/
@@ -133,20 +179,9 @@
}
}
- // Apply prefilter:
- ListFilter<Cluster> filter = new ListFilter<Cluster> (inputDecision);
- List<Cluster> list = filter.filterList(inputList);
-
- // Make the clusterer:
- MSTClusterBuilder clusterBuilder = new MSTClusterBuilder( list, event );
- clusterBuilder.registerMetrics(metrics);
- clusterBuilder.setThreshold(threshold);
- clusterBuilder.setSeedDecision(seedDecision);
- clusterBuilder.setPairDecision(pairDecision);
- clusterBuilder.setOutputDecision(outputDecision);
+ List<Cluster> outputList = subProcess(inputList, event);
- // Cluster & write out cluster list:
- List<Cluster> outputList = clusterBuilder.doClustering();
+ // Write out cluster list:
if (clusterName != null) {
event.put(clusterName, outputList );
}