lcsim/src/org/lcsim/util/hitmap
diff -N ClusterListToHitMapDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClusterListToHitMapDriver.java 2 Mar 2006 23:35:23 -0000 1.1
@@ -0,0 +1,61 @@
+package org.lcsim.util.hitmap;
+
+import java.util.List;
+import java.util.Vector;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+ /**
+ * This class takes in one or more List<Cluster> and adds all of the hits
+ * in the clusters to a new HitMap.
+ */
+
+public class ClusterListToHitMapDriver extends Driver
+{
+ /** Simple constructor */
+ public ClusterListToHitMapDriver() {
+ super();
+ }
+
+ /**
+ * Constructor with convenience arguments
+ *
+ * @param inputClusterList Name of an input List<Cluster> in the event
+ * @param outputHitMap Name to write output HitMap to in the event
+ */
+ public ClusterListToHitMapDriver(String inputClusterList, String outputHitMap) {
+ super();
+ m_inputClusterListNames.add(inputClusterList);
+ m_outputHitMapName = outputHitMap;
+ }
+
+ /** Process one event, performing conversion. */
+ public void process(EventHeader event)
+ {
+ HitMap outputHitMap = new HitMap();
+ for (String name : m_inputClusterListNames) {
+ List<Cluster> currentClusterList = event.get(Cluster.class, name);
+ for (Cluster clus : currentClusterList) {
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ // Put this hit in the hitmap:
+ Long cellID = hit.getCellID();
+ outputHitMap.put(cellID, hit);
+ }
+ }
+ }
+ event.put(m_outputHitMapName, outputHitMap);
+ }
+
+ /** Set the name under which to write the output HitMap to the event */
+ public void setOutputHitMap(String name) { m_outputHitMapName = name; }
+
+ /** Add a named List<Cluster> to read from the event */
+ public void addInputList(String name) { m_inputClusterListNames.add(name); }
+
+ protected List<String> m_inputClusterListNames;
+ protected String m_outputHitMapName;
+}