lcsim/src/org/lcsim/recon/cluster/util
diff -u -r1.16 -r1.17
--- BasicCluster.java 12 Apr 2007 23:12:14 -0000 1.16
+++ BasicCluster.java 6 Mar 2009 17:48:24 -0000 1.17
@@ -1,14 +1,16 @@
package org.lcsim.recon.cluster.util;
import java.util.ArrayList;
-import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;
+
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.Cluster;
-import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.compact.Subdetector;
/**
@@ -352,4 +354,26 @@
if(phi<0) phi += 2*Math.PI;
return "BasicCluster w/ "+this.getSize()+" hits at theta="+theta*180/Math.PI+", phi="+phi*180/Math.PI;
}
+
+ /**
+ * Create and return a set of MCParticles from the hits of the cluster.
+ * Only looks at SimCalorimeterHits, as CalorimeterHits don't have MC information.
+ * @return The set of unique MCParticles associated with this cluster.
+ */
+ public Set<MCParticle> findUniqueMCParticlesFromHits()
+ {
+ Set<MCParticle> mcps = new HashSet<MCParticle>();
+ for (CalorimeterHit hit : getCalorimeterHits())
+ {
+ if (hit instanceof SimCalorimeterHit)
+ {
+ SimCalorimeterHit simhit = (SimCalorimeterHit)hit;
+ for (int i=0; i<simhit.getMCParticleCount(); i++)
+ {
+ mcps.add(simhit.getMCParticle(i));
+ }
+ }
+ }
+ return mcps;
+ }
}