Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/util on MAIN
VetoClustersFromParticles.java+77added 1.1
Filter out clusters which have already been used in a ReconstructedParticle.

lcsim/src/org/lcsim/recon/cluster/util
VetoClustersFromParticles.java added at 1.1
diff -N VetoClustersFromParticles.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ VetoClustersFromParticles.java	4 Jul 2006 21:20:13 -0000	1.1
@@ -0,0 +1,77 @@
+package org.lcsim.recon.cluster.util;
+
+import java.util.*; 
+import org.lcsim.util.*;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.util.decision.*;
+
+/**
+ * A DecisionMakerSingle which accepts clusters unless they are
+ * already part of a named list of ReconstructedParticles which is stored
+ * in the event. (This list of particles must be written to the
+ * event before using this DecisionMaker.)
+ *
+ * This is a Driver. It must be added to the event sequence in order
+ * to pick up the EventHeader object so that it can read in the list
+ * of particles on demand.
+ * 
+ * @version $Id: VetoClustersFromParticles.java,v 1.1 2006/07/04 21:20:13 mcharles Exp $
+ */
+
+public class VetoClustersFromParticles extends Driver implements DecisionMakerSingle<Cluster>
+{
+    /**
+     * Constructor.
+     *
+     * @param particleList  Named list of ReconstructedParticles to read in from the event.
+     */
+    public VetoClustersFromParticles(String particleList) {
+	m_particleListName = particleList;
+    }
+    
+    /**
+     * Check whether this cluster was already used in a ReconstructedParticle.
+     */
+    public boolean valid(Cluster objectToTest) {
+	List<ReconstructedParticle> particles = m_event.get(ReconstructedParticle.class, m_particleListName);
+	for (ReconstructedParticle part : particles) {
+	    List<Cluster> subClusters = recursivelyFindSubClusters(part);
+	    boolean clusterInParticle = (subClusters.contains(objectToTest));
+	    if (clusterInParticle) { return false; }
+	}
+	// No match
+	return true;
+    }
+    
+    /** 
+     * Pick up the event.
+     */
+    public void process(EventHeader event) {
+	m_event = event;
+    }
+
+    /** Internal utility routine */
+    protected List<Cluster> recursivelyFindSubClusters(ReconstructedParticle part) 
+    {
+        List<Cluster> allSubClusters = new Vector<Cluster>();
+        for (Cluster clus : part.getClusters()) {
+            List<Cluster> subClusters = recursivelyFindSubClusters(clus);
+            allSubClusters.addAll(subClusters);
+        }
+        return allSubClusters;
+    }
+    /** Internal utility routine */
+    protected List<Cluster> recursivelyFindSubClusters(Cluster clus) 
+    {
+        List<Cluster> output = new Vector<Cluster>();
+        for (Cluster dau : clus.getClusters()) {
+            output.addAll(recursivelyFindSubClusters(dau));
+        }
+        output.add(clus);
+        return output;
+    }
+
+    protected EventHeader m_event;
+    protected String m_particleListName;
+}
CVSspam 0.2.8