Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/util on MAIN
ClusterIDCheater.java+69added 1.1
Class to return a cheated ID for a cluster

lcsim/src/org/lcsim/recon/cluster/util
ClusterIDCheater.java added at 1.1
diff -N ClusterIDCheater.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ClusterIDCheater.java	8 Nov 2007 23:14:52 -0000	1.1
@@ -0,0 +1,69 @@
+/*
+ * ClusterIDCheater.java
+ *
+ * Created on March 27, 2007, 6:02 AM
+ *
+ * Assigns a cluster to the maximum fs particle contributor
+ */
+
+package org.lcsim.recon.cluster.util;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.contrib.Cassell.recon.Cheat.TraceOrigin;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ *
+ * @author cassell
+ */
+public class ClusterIDCheater
+{
+    
+    /** Creates a new instance of ClusterIDCheater */
+    public ClusterIDCheater()
+    {
+    }
+    public MCParticle getMCID(List<MCParticle> fs,Cluster c)
+    {
+        TraceOrigin to = new TraceOrigin(fs);
+        MCParticle ret = null;
+        Map<MCParticle,Double> Emap = new HashMap<MCParticle,Double>();
+        for(CalorimeterHit ch:c.getCalorimeterHits())
+        {
+            SimCalorimeterHit h = (SimCalorimeterHit) ch;
+            int nc = h.getMCParticleCount();
+            double fac = h.getCorrectedEnergy()/h.getRawEnergy();
+            for(int i=0;i<nc;i++)
+            {
+                MCParticle mcp = h.getMCParticle(i);
+                MCParticle p = to.traceit(mcp);
+                if(p == null)p = mcp;
+                double E = fac*h.getContributedEnergy(i);
+                if(Emap.containsKey(p))
+                {
+                    E += Emap.get(p).doubleValue();
+                    Emap.remove(p);
+                }
+                Emap.put(p, new Double(E));
+            }
+        }
+        double maxE = 0.;
+        for (Entry<MCParticle,Double> entry : Emap.entrySet())
+        {
+            double E = entry.getValue().doubleValue();
+            if(E > maxE)
+            {
+                ret = entry.getKey();
+                maxE = E;
+            }
+        }
+        return ret;
+    }
+    
+}
CVSspam 0.2.8