lcsim/src/org/lcsim/recon/cluster/util
diff -N CalorimeterHitTimeCutDecision.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitTimeCutDecision.java 22 Oct 2008 17:49:17 -0000 1.1
@@ -0,0 +1,25 @@
+package org.lcsim.recon.cluster.util;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.util.decision.DecisionMakerSingle;
+
+public class CalorimeterHitTimeCutDecision implements DecisionMakerSingle<CalorimeterHit>
+{
+ /** Constructor takes time cut-off as argument. */
+ public CalorimeterHitTimeCutDecision(double timeCut) {
+ m_timeCut = timeCut;
+ }
+
+ /**
+ * Check whether this hit is in ECAL.
+ * This implementation checks the string name of
+ * the subdetector, which is not very general or
+ * very efficient.
+ */
+ public boolean valid(CalorimeterHit hit) {
+ double t = hit.getTime();
+ return (t <= m_timeCut);
+ }
+
+ protected double m_timeCut;
+}
lcsim/src/org/lcsim/recon/cluster/util
diff -N RemoveHitsFromClusters.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ RemoveHitsFromClusters.java 22 Oct 2008 17:49:17 -0000 1.1
@@ -0,0 +1,92 @@
+package org.lcsim.recon.cluster.util;
+
+import java.util.*;
+import org.lcsim.util.Driver;
+import org.lcsim.util.hitmap.HitMap;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.*;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+/**
+ * Utility class to scan a list of clusters and remove any hits which
+ * match those in a specified HitMap. After removing the hits, all
+ * clusters which have at least one hit left are written out.
+ *
+ * Clusters which have not had any hits removed will be written out
+ * unedited. If a cluster has had some but not all of its hits removed,
+ * the original will be left unedited and a copy (BasicCluster) with
+ * the hits removed will be written out.
+ *
+ * @version $Id: RemoveHitsFromClusters.java,v 1.1 2008/10/22 17:49:17 mcharles Exp $
+ * @author [log in to unmask]
+ */
+
+public class RemoveHitsFromClusters extends Driver
+{
+ protected String m_inputClusterListName;
+ protected String m_inputMapName;
+ protected String m_outputClusterListName;
+
+ /**
+ * Constructor.
+ *
+ * @param inputClusterList Named list of clusters to read in and scan.
+ * @param inputMap Named HitMap to read in. These hits will be removed from clusters if any contain them.
+ * @param outputClusterList Output clusters will be written out under this name.
+ */
+ public RemoveHitsFromClusters(String inputClusterList, String inputMap, String outputClusterList) {
+ m_inputClusterListName = inputClusterList;
+ m_inputMapName = inputMap;
+ m_outputClusterListName = outputClusterList;
+ }
+
+ public void process(EventHeader event) {
+ // Which hits will we remove?
+ Map<Track,Cluster> inputMap = (Map<Track,Cluster>)(event.get(m_inputMapName));
+ Set<CalorimeterHit> hitsToRemove = new HashSet<CalorimeterHit>();
+ for (Cluster clus : inputMap.values()) {
+ hitsToRemove.addAll(clus.getCalorimeterHits());
+ }
+ // Remove those:
+ List<Cluster> inputClusterList = event.get(Cluster.class, m_inputClusterListName);
+ List<Cluster> outputClusterList = new Vector<Cluster>();
+ for (Cluster inputClus : inputClusterList) {
+ // Photons have a core & halo
+ Cluster oldCore = inputClus.getClusters().get(0);
+ Set<CalorimeterHit> oldCoreHits = new HashSet<CalorimeterHit>();
+ oldCoreHits.addAll(oldCore.getCalorimeterHits());
+ Set<CalorimeterHit> oldHaloHits = new HashSet<CalorimeterHit>();
+ oldHaloHits.addAll(inputClus.getCalorimeterHits());
+ oldHaloHits.removeAll(oldCoreHits);
+ if (oldCoreHits.size() + oldHaloHits.size() != inputClus.getCalorimeterHits().size()) { throw new AssertionError("Book-keeping error!"); }
+ // Remove hits as needed:
+ Set<CalorimeterHit> newCoreHits = new HashSet<CalorimeterHit>();
+ Set<CalorimeterHit> newHaloHits = new HashSet<CalorimeterHit>();
+ newCoreHits.addAll(oldCoreHits);
+ newHaloHits.addAll(oldHaloHits);
+ newCoreHits.removeAll(hitsToRemove);
+ newHaloHits.removeAll(hitsToRemove);
+ // Build output cluster -- must have at least one hit left in core.
+ if (newCoreHits.size() > 0) {
+ // Set up core & halo hits for new cluster:
+ BasicCluster outputCore = new BasicCluster();
+ BasicCluster outputClus = new BasicCluster();
+ for (CalorimeterHit hit : newCoreHits) {
+ outputCore.addHit(hit);
+ }
+ outputClus.addCluster(outputCore);
+ for (CalorimeterHit hit : newHaloHits) {
+ outputClus.addHit(hit);
+ }
+ // Sanity checks
+ if (outputClus.getCalorimeterHits().size() == 0) { throw new AssertionError("Book-keeping error!"); }
+ if (outputClus.getCalorimeterHits().size() > inputClus.getCalorimeterHits().size() ) { throw new AssertionError("Book-keeping error!"); }
+ // All good -- keep it
+ outputClusterList.add(outputClus);
+ }
+ }
+ // Write out
+ event.put(m_outputClusterListName, outputClusterList);
+ }
+}
lcsim/src/org/lcsim/recon/cluster/util
diff -N VetoHitsFromClusters.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ VetoHitsFromClusters.java 22 Oct 2008 17:49:17 -0000 1.1
@@ -0,0 +1,65 @@
+package org.lcsim.recon.cluster.util;
+
+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;
+
+/**
+ * Utility class to scan a list of clusters and veto any which
+ * contain hits from a specified HitMap. Only those clusters
+ * which don't contain any of these hits are written out.
+ *
+ * @version $Id: VetoHitsFromClusters.java,v 1.1 2008/10/22 17:49:17 mcharles Exp $
+ * @author [log in to unmask]
+ */
+
+public class VetoHitsFromClusters extends Driver
+{
+ protected String m_inputClusterListName;
+ protected String m_inputMapName;
+ protected String m_outputClusterListName;
+
+ /**
+ * Constructor.
+ *
+ * @param inputClusterList Named list of clusters to read in and scan.
+ * @param inputMap Named HitMap to read in. Any clusters containing hits in this HitMap will be vetoed.
+ * @param outputClusterList After the vetoing process, a list of remaining clusters will be written out under this name.
+ */
+ 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);
+ }
+}