lcsim/src/org/lcsim/util/hitmap
diff -N HitListToHitMapDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HitListToHitMapDriver.java 17 Feb 2006 00:49:22 -0000 1.1
@@ -0,0 +1,56 @@
+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.CalorimeterHit;
+
+/**
+ * This class takes in a List<CalorimeterHit> and
+ * converts it to a HitMap
+ *
+ * @version $Id: HitListToHitMapDriver.java,v 1.1 2006/02/17 00:49:22 mcharles Exp $
+ */
+
+public class HitListToHitMapDriver extends Driver
+{
+ /** Simple constructor */
+ public HitListToHitMapDriver() {
+ super();
+ }
+
+ /** Process one event, performing conversion. */
+ public void process(EventHeader event)
+ {
+ // Here is the hitmap we'll write out to the event:
+ HitMap hitMap = new HitMap();
+
+ // Fill the hitmap with each input list in turn:
+ for (String inputName : m_inputLists) {
+ List<CalorimeterHit> inputList = event.get(CalorimeterHit.class, inputName);
+ for (CalorimeterHit hit : inputList) {
+ // Put this hit in the hitmap:
+ Long cellID = hit.getCellID();
+ hitMap.put(cellID, hit);
+ }
+ }
+
+ // All hits added; upload the hitmap to the event:
+ event.put(m_outputName, hitMap);
+ }
+
+ /** Add the name of a List<CalorimeterHit> to the list to read in from the event*/
+ public void addInputList(String name) { m_inputLists.add(name); }
+
+ /** Clear the list of input names */
+ public void clearInputLists() { m_inputLists.clear(); }
+
+ /** Set the name under which to write the output HitMap to the event */
+ public void setOutput(String name) { m_outputName = name; }
+
+ protected List<String> m_inputLists = new Vector<String>();
+ protected String m_outputName;
+}
+