lcsim/src/org/lcsim/contrib/uiowa/structural
diff -N StructuralCheater.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StructuralCheater.java 9 Jan 2006 20:50:59 -0000 1.1
@@ -0,0 +1,61 @@
+package structural;
+
+import java.lang.String;
+import java.util.*;
+import org.lcsim.util.Driver;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+/**
+ * A cheater to replace the structural algorithm
+ *
+ * Input: A list of clusters
+ * Output: The same list, except that any clusters with contributions from 2+
+ * MC particles have been split up.
+ */
+
+public class StructuralCheater extends Driver
+{
+ public StructuralCheater(String inputListName, String outputListName) {
+ m_inputListName = inputListName;
+ m_outputListName = outputListName;
+ }
+
+ public void process(EventHeader event)
+ {
+ // Fetch input list
+ List<Cluster> inputClusterList = event.get(Cluster.class, m_inputListName);
+
+ // Output list
+ List<Cluster> outputClusterList = new Vector<Cluster> ();
+
+ // Loop over list, checking for impurities in each
+ for (Cluster clus : inputClusterList) {
+ List<CalorimeterHit> inputHitList = clus.getCalorimeterHits();
+ Map<MCParticle, BasicCluster> partMap = new HashMap<MCParticle, BasicCluster> ();
+ for (CalorimeterHit hit : inputHitList) {
+ SimCalorimeterHit simHit = (SimCalorimeterHit) (hit);
+ MCParticle part = simHit.getMCParticle(0); // Bit crude, but hits with contributions from many particles are rare
+ BasicCluster tmpList = partMap.get(part);
+ if (tmpList == null) {
+ tmpList = new BasicCluster ();
+ partMap.put(part, tmpList);
+ }
+ tmpList.addHit(hit);
+ }
+ // Add to output list:
+ Collection<BasicCluster> clustersToOutput = partMap.values();
+ for (Cluster subClus : clustersToOutput) {
+ outputClusterList.add(subClus);
+ }
+ }
+
+ // Write out:
+ event.put(m_outputListName, outputClusterList);
+ }
+
+
+ protected String m_inputListName;
+ protected String m_outputListName;
+
+}