lcsim/src/org/lcsim/contrib/Cassell/recon/analysis
diff -N ClusterPurityPlots.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClusterPurityPlots.java 24 Apr 2008 17:41:59 -0000 1.1
@@ -0,0 +1,87 @@
+/*
+ * ClusterPurityPlots.java
+ *
+ * Created on November 20, 2007, 11:20 AM
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package org.lcsim.contrib.Cassell.recon.analysis;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author cassell
+ */
+public class ClusterPurityPlots
+{
+ private AIDA aida = AIDA.defaultInstance();
+ Map<MCParticle,List<Cluster>> mcclmap;
+ CalClusterComposition ccc;
+ ParticleType pt;
+ String[] type;
+ String[] rtype;
+ double[] binEmax = {.1,.25,.5,1.,3.,7.,13.,27.,63.,137.,5000.};
+ String[] binName = {"E<.1",".1<E<.25",".25<E<.5",".5<E<1.","1<E<3","3<E<7",
+ "7<E<13","13<E<27","27<E<63","63<E<137","E>137"};
+ int nmax = 100000000;
+ /** Creates a new instance of ClusterPurityPlots */
+ public ClusterPurityPlots(List<MCParticle> fsp,List<MCParticle> fst)
+ {
+ ccc = new CalClusterComposition(fsp, fst);
+ pt = new ParticleType(fst);
+ type = pt.getTypes();
+ rtype = pt.getRTypes();
+ }
+ public void makePlots(String pre,List<Cluster> cl)
+ {
+ mcclmap = new HashMap<MCParticle,List<Cluster>>();
+ for(Cluster c:cl)
+ {
+ ccc.decomposeCluster(c);
+ MCParticle p = ccc.getMaxParticle();
+ int itype = pt.mapTypeToRType(pt.getType(p));
+ double clE = c.getEnergy();
+ double purity = ccc.getMaxParticleE()/clE;
+ double meanEperhit = clE/c.getCalorimeterHits().size();
+ if((clE > .5)&&(c.getCalorimeterHits().size() > 2))
+ aida.cloud2D(pre+"/"+rtype[itype]+"/meanEperhit vs E",nmax).fill(clE,meanEperhit);
+ if(mcclmap.containsKey(p))
+ {
+ mcclmap.get(p).add(c);
+ }
+ else
+ {
+ List<Cluster> cll = new ArrayList<Cluster>();
+ cll.add(c);
+ mcclmap.put(p,cll);
+ }
+ aida.histogram1D(pre+"/All clusters/Max contributor Purity", 101, 0., 1.01).fill(purity);
+ aida.histogram1D(pre+"/"+rtype[itype]+"/Max contributor Purity", 101, 0., 1.01).fill(purity);
+ aida.histogram1D(pre+"/All clusters/Max contributor wted Purity", 101, 0., 1.01).fill(purity,clE);
+ aida.histogram1D(pre+"/"+rtype[itype]+"/Max contributor wted Purity", 101, 0., 1.01).fill(purity,clE);
+ int ebin = 0;
+ for(int i=0;i<binEmax.length;i++)
+ {
+ if(clE < binEmax[i])break;
+ ebin++;
+ }
+ aida.histogram1D(pre+"/All clusters/"+binName[ebin]+"/Max contributor Purity", 101, 0., 1.01).fill(purity);
+ aida.histogram1D(pre+"/"+rtype[itype]+"/"+binName[ebin]+"/Max contributor Purity", 101, 0., 1.01).fill(purity);
+ aida.histogram1D(pre+"/All clusters/"+binName[ebin]+"/Max contributor wted Purity", 101, 0., 1.01).fill(purity,clE);
+ aida.histogram1D(pre+"/"+rtype[itype]+"/"+binName[ebin]+"/Max contributor wted Purity", 101, 0., 1.01).fill(purity, clE);
+ }
+ }
+ public Map<MCParticle,List<Cluster>> getMap()
+ {
+ return mcclmap;
+ }
+}