Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/cheat on MAIN
PerfectClusterer.java+30-41.1 -> 1.2
Map --> HitMap; option not to allow hit sharing added

lcsim/src/org/lcsim/recon/cluster/cheat
PerfectClusterer.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- PerfectClusterer.java	22 Jun 2006 01:18:55 -0000	1.1
+++ PerfectClusterer.java	4 Jul 2006 23:47:54 -0000	1.2
@@ -2,6 +2,7 @@
 
 import java.util.*;
 
+import org.lcsim.util.hitmap.HitMap;
 import org.lcsim.event.EventHeader;
 import org.lcsim.util.Driver;
 import org.lcsim.event.Cluster;
@@ -13,7 +14,7 @@
 /**
  * A clusterer with perfect pattern recognition
  *
- * @version $Id: PerfectClusterer.java,v 1.1 2006/06/22 01:18:55 mcharles Exp $
+ * @version $Id: PerfectClusterer.java,v 1.2 2006/07/04 23:47:54 mcharles Exp $
  */
 
 public class PerfectClusterer extends Driver
@@ -28,13 +29,18 @@
      * Process one event, separating the input hits into
      * clusters as perfectly as possible based on the
      * MC truth list.
+     *
+     * Optionally, clusters may share a hit if more than one
+     * particle contributed to it.
+     *
+     * @version $Id: PerfectClusterer.java,v 1.2 2006/07/04 23:47:54 mcharles Exp $
      */
     public void process(EventHeader event) 
     {
 	List<MCParticle> mcList = event.get(MCParticle.class, m_mcName);
-	Map<Long, CalorimeterHit> inputHitMap = (Map<Long, CalorimeterHit>) (event.get(m_inputHitMapName));
+	HitMap inputHitMap = (HitMap) (event.get(m_inputHitMapName));
 	
-	Map<Long, CalorimeterHit> outputHitMap = new HashMap<Long, CalorimeterHit>(inputHitMap); // initially cloned
+	HitMap outputHitMap = new HitMap(inputHitMap); // initially cloned
 	Collection<CalorimeterHit> hits = inputHitMap.values(); // initially full
 	Map<MCParticle, BasicCluster> particleToClusterMap = new HashMap<MCParticle, BasicCluster>(); // initially empty
 	
@@ -44,6 +50,21 @@
 	    //   (1) More than one particle deposits energy in the cell
 	    //   (2) The list of MC particles is ambiguous
 	    Set<MCParticle> truthParticles = findMCParticles(hit, mcList);
+	    if (!m_allowHitSharing) {
+		// We disallow hit sharing => only take the particle with
+		// the biggest contribution.
+		MCParticle biggestContributor = null;
+		double biggestContribution = 0.0;
+		for (MCParticle part : truthParticles) {
+		    double contribution = findContributionByMCParticle(hit, mcList, part);
+		    if (contribution > biggestContribution || biggestContributor == null) {
+			biggestContributor = part;
+			biggestContribution = contribution;
+		    }
+		}
+		truthParticles = new HashSet<MCParticle>();
+		truthParticles.add(biggestContributor);
+	    }
 	    for (MCParticle part : truthParticles) {
 		BasicCluster clus = particleToClusterMap.get(part);
 		if (clus == null) {
@@ -154,9 +175,14 @@
     public void setMCParticleList(String name) {
 	m_mcName = name;
     }
-    
+    /** Set whether or not hits may be shared among clusters. */
+    public void allowHitSharing(boolean allow) {
+	m_allowHitSharing = allow;
+    }
+
     String m_inputHitMapName;
     String m_outputHitMapName;
     String m_outputClusterListName;
     String m_mcName;
+    boolean m_allowHitSharing = true;
 }
CVSspam 0.2.8