lcsim/src/org/lcsim/contrib/uiowa
diff -N VetoHitsFromClusters.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ VetoHitsFromClusters.java 13 Oct 2008 07:16:38 -0000 1.1
@@ -0,0 +1,49 @@
+package org.lcsim.contrib.uiowa;
+
+import java.util.*;
+import org.lcsim.util.Driver;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.*;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+public class VetoHitsFromClusters extends Driver
+{
+ protected String m_inputClusterListName;
+ protected String m_inputMapName;
+ protected String m_outputClusterListName;
+
+ public VetoHitsFromClusters(String inputClusterList, String inputMap, String outputClusterList) {
+ m_inputClusterListName = inputClusterList;
+ m_inputMapName = inputMap;
+ m_outputClusterListName = outputClusterList;
+ }
+
+ public void process(EventHeader event) {
+ // Which hits will we veto on?
+ Map<Track,Cluster> inputMap = (Map<Track,Cluster>)(event.get(m_inputMapName));
+ Set<CalorimeterHit> vetoHits = new HashSet<CalorimeterHit>();
+ for (Cluster clus : inputMap.values()) {
+ vetoHits.addAll(clus.getCalorimeterHits());
+ }
+ // Remove any cluster that contains any of the vetoHits:
+ List<Cluster> inputClusterList = event.get(Cluster.class, m_inputClusterListName);
+ List<Cluster> outputClusterList = new Vector<Cluster>();
+ for (Cluster inputClus : inputClusterList) {
+ boolean foundVetoHit = false;
+ for (CalorimeterHit hit : inputClus.getCalorimeterHits()) {
+ if (vetoHits.contains(hit)) {
+ // VETO
+ foundVetoHit = true;
+ break;
+ }
+ }
+ if (!foundVetoHit) {
+ // Didn't find any hits in the "veto" list => keep this cluster
+ outputClusterList.add(inputClus);
+ }
+ }
+ // Write out
+ event.put(m_outputClusterListName, outputClusterList);
+ }
+}