Commit in lcsim/src/org/lcsim/recon/cluster/analysis on MAIN
MCPClusterInfo.java+224added 1.1
Class to hold Cluster information for a MCParticle. Initial version

lcsim/src/org/lcsim/recon/cluster/analysis
MCPClusterInfo.java added at 1.1
diff -N MCPClusterInfo.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MCPClusterInfo.java	5 Oct 2005 17:28:29 -0000	1.1
@@ -0,0 +1,224 @@
+package org.lcsim.recon.cluster.analysis;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.MCParticle;
+import org.lcsim.recon.cluster.util.*;
+
+/**
+ * Class to hold Cluster information about a MCParticle
+ * @author Ron Cassell 
+ */
+public class MCPClusterInfo
+{
+   private int NClusters;
+   private BasicCluster MaxCluster;
+   private double MaxEraw;
+   private double MaxEcorrected;
+   private int MaxNHits;
+   private List<BasicCluster> Clusters;
+   private List<Double> ErawContribution;
+   private List<Double> EcorrectedContribution;
+   private List<Integer> NhitContribution;
+   private List<SimCalorimeterHit> UnclusteredHits;
+   private int TotalHits;
+   private double TotalEraw;
+   private double TotalEcorrected;
+   private MCParticle part;
+   private boolean isFS;
+   private Map<MCParticle,MCParticle> fsmap;
+
+   /**
+    */
+   public MCPClusterInfo(MCParticle p,Map<MCParticle,MCParticle> FSmap)
+   {
+      part = p;
+      fsmap = FSmap;
+      isFS = (FSmap.get(p) == p);
+      NClusters = 0;
+      MaxCluster = null;
+      MaxEraw = 0.;
+      MaxEcorrected = 0.;
+      MaxNHits = 0;
+      TotalHits = 0;
+      TotalEraw = 0.;
+      TotalEcorrected = 0.;
+      Clusters = new ArrayList<BasicCluster>();
+      ErawContribution = new ArrayList<Double>();
+      EcorrectedContribution = new ArrayList<Double>();
+      NhitContribution = new ArrayList<Integer>();
+      UnclusteredHits = new ArrayList<SimCalorimeterHit>();
+   }
+   /**
+    * Add a cluster this particle contributes to
+    */
+   public void AddCluster(BasicCluster c)
+   {
+      Clusters.add(c);
+      NClusters++;
+      int nhits = 0;
+      double eraw = 0.;
+      double ecorr = 0.;
+      for(CalorimeterHit hit:c.getCalorimeterHits())
+      {
+         double thiseraw = 0.;
+         SimCalorimeterHit shit = (SimCalorimeterHit) hit;
+         boolean hashit = false;
+         for(int i=0;i<shit.getMCParticleCount();i++)
+         {
+            MCParticle thisp = fsmap.get(shit.getMCParticle(i));
+            if(thisp == null)thisp = shit.getMCParticle(i);
+            if(thisp == part)
+            {
+               hashit = true;
+               thiseraw += shit.getContributedEnergy(i);
+            }
+         }
+         if(hashit)nhits++;
+         ecorr += shit.getCorrectedEnergy()*thiseraw/shit.getRawEnergy();
+         eraw += thiseraw;
+      }
+      Integer nh = new Integer(nhits);
+      Double er = new Double(eraw);
+      Double ec = new Double(ecorr);
+      ErawContribution.add(er);
+      EcorrectedContribution.add(ec);
+      NhitContribution.add(nh);
+      TotalHits += nhits;
+      TotalEraw += eraw;
+      TotalEcorrected += ecorr;
+//
+// See if this is the maximum cluster contributing to this particle
+//
+      if(nhits > MaxNHits)
+      {
+         MaxNHits = nhits;
+         MaxCluster = c;
+         MaxEraw = eraw;
+         MaxEcorrected = ecorr;
+      }
+      else if(nhits == MaxNHits)
+      {
+         if(ecorr > MaxEcorrected)
+         {
+            MaxNHits = nhits;
+            MaxCluster = c;
+            MaxEraw = eraw;
+            MaxEcorrected = ecorr;
+         }
+      }
+   }
+   /**
+    * Add an unclustered hit this particle contributes to
+    */
+   public void AddUnclusteredHit(SimCalorimeterHit h)
+   {
+      TotalHits++;
+      UnclusteredHits.add(h);
+      double rawE = 0.;
+      for(int i=0;i<h.getMCParticleCount();i++)
+      {
+         if(fsmap.get(h.getMCParticle(i)) == part)
+         {
+            rawE += h.getContributedEnergy(i);
+         }
+      }
+      TotalEraw += rawE;
+      TotalEcorrected += h.getCorrectedEnergy()*rawE/h.getRawEnergy();
+   }
+   /**
+    * Return the MCParticle for which the cluster information is stored
+    */
+   public MCParticle getMCParticle(){return part;}
+   /**
+    * Return true if the MCParticle for which the cluster information is stored is a 
+    * final state particle
+    */
+   public boolean isFinalState(){return isFS;}
+   /**
+    * Return the number of clusters to which this MCParticle contributes
+    */
+   public int getNClusters(){return NClusters;}
+   /**
+    * Return the cluster with the maximum number of hits contributed by this particle 
+    */
+   public BasicCluster getMaxCluster(){return MaxCluster;}
+   /**
+    * Return the raw energy contributed by this particle to the cluster with the 
+    * maximum number of hits contributed by this particle 
+    */
+   public double getMaxEraw(){return MaxEraw;}
+   /**
+    * Return the corrected energy contributed by this particle to the cluster with the 
+    * maximum number of hits contributed by this particle 
+    */
+   public double getMaxEcorrected(){return MaxEcorrected;}
+   /**
+    * Return the number of hits contributed by this particle to the cluster with the 
+    * maximum number of hits contributed by this particle 
+    */
+   public int getMaxNHits(){return MaxNHits;}
+   /**
+    * Return the total number of hits in the CalorimeterHit collections contributed 
+    * by this particle 
+    */
+   public int getTotalHits(){return TotalHits;}
+   /**
+    * Return the total raw energy in the CalorimeterHit collections contributed 
+    * by this particle 
+    */
+   public double getTotalEraw(){return TotalEraw;}
+   /**
+    * Return the total corrected energy in the CalorimeterHit collections contributed 
+    * by this particle 
+    */
+   public double getTotalEcorrected(){return TotalEcorrected;}
+   /**
+    * Return a list of clusters to which this particle contributes
+    */
+   public List<BasicCluster> getClusters(){return Clusters;}
+   /**
+    * Return an array of raw energy contributions of this particle to the list of clusters
+    */
+   public double[] getErawContribution()
+   {
+      double[] ret = new double[ErawContribution.size()];
+      for(int i=0;i<ErawContribution.size();i++)
+      {
+         ret[i] = ErawContribution.get(i).doubleValue();
+      }
+      return ret;
+   }
+   /**
+    * Return an array of corrected energy contributions of this particle to the list of clusters
+    */
+   public double[] getEcorrectedContribution()
+   {
+      double[] ret = new double[EcorrectedContribution.size()];
+      for(int i=0;i<EcorrectedContribution.size();i++)
+      {
+         ret[i] = EcorrectedContribution.get(i).doubleValue();
+      }
+      return ret;
+   }
+   /**
+    * Return an array of number of hits contributed by this particle to the list of clusters
+    */
+   public int[] getNhitContribution()
+   {
+      int[] ret = new int[NhitContribution.size()];
+      for(int i=0;i<NhitContribution.size();i++)
+      {
+         ret[i] = NhitContribution.get(i).intValue();
+      }
+      return ret;
+   }
+   /**
+    * Return a list of unclustered hits contributed to by this particle
+    */
+   public List<SimCalorimeterHit> getUnclusteredHits(){return UnclusteredHits;}
+
+}
\ No newline at end of file
CVSspam 0.2.8