Print

Print


Commit in lcsim/src/org/lcsim/contrib/uiowa/template on MAIN
EnergySumPlotter.java+25-41.1 -> 1.2
Add a second (ICloud1D) plot

lcsim/src/org/lcsim/contrib/uiowa/template
EnergySumPlotter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- EnergySumPlotter.java	4 Feb 2006 01:24:24 -0000	1.1
+++ EnergySumPlotter.java	8 Feb 2006 19:05:46 -0000	1.2
@@ -2,6 +2,7 @@
 
 import java.io.IOException; 
 import java.util.List;
+import java.util.Vector;
 import java.lang.String;
 import hep.aida.ITree;
 import hep.aida.IAnalysisFactory; 
@@ -11,6 +12,7 @@
 import org.lcsim.event.EventHeader;
 import org.lcsim.util.Driver;
 
+import hep.physics.particle.Particle;
 import org.lcsim.event.ReconstructedParticle;
 
 public class EnergySumPlotter extends Driver
@@ -23,6 +25,7 @@
 	    m_tree = af.createTreeFactory().create(filename,"xml",false,true); 
 	    IHistogramFactory histoFactory = af.createHistogramFactory(m_tree); 
 	    m_histo = histoFactory.createHistogram1D("EnergySum", 60, 60.0, 120.0);
+	    m_cloud = histoFactory.createCloud1D("EnergySumCloud");
 	} catch (IOException ioe1) {
             ioe1.printStackTrace(); 
         }
@@ -32,21 +35,38 @@
     public void process(EventHeader event) 
     {
 	// Read in the clusters:
-	List<ReconstructedParticle> inputParticleList;
-
+	List inputList;
 	try {
-	    inputParticleList = event.get(ReconstructedParticle.class, m_inputParticleListName);
+	    inputList = (List) (event.get(m_inputParticleListName));
 	} catch (java.lang.IllegalArgumentException x) {
 	    System.out.println("WARNING: Particle list ["+m_inputParticleListName+"] not found.");
 	    return;
 	}
 
+	List<Particle> inputParticleList = new Vector<Particle>();
+	List<ReconstructedParticle> inputReconstructedParticleList = new Vector<ReconstructedParticle> ();
+	for (Object obj : inputList) {
+	    if (obj instanceof ReconstructedParticle) {
+		inputReconstructedParticleList.add( (ReconstructedParticle)(obj) );
+	    } else {
+		inputParticleList.add( (Particle)(obj) );
+	    }
+	}
+
+	if (inputReconstructedParticleList.size() * inputParticleList.size() != 0) {
+	    throw new AssertionError("Mixed list!");
+	}
+
 	double energySum = 0.0;
-	for (ReconstructedParticle part : inputParticleList) {
+	for (Particle part : inputParticleList) {
+	    energySum += part.getEnergy();
+	}
+	for (ReconstructedParticle part : inputReconstructedParticleList) {
 	    energySum += part.getEnergy();
 	}
 	
 	m_histo.fill(energySum);
+	m_cloud.fill(energySum);
     }
 
     public void suspend() {
@@ -60,5 +80,6 @@
 
     ITree m_tree = null;
     IHistogram1D m_histo;
+    ICloud1D m_cloud;
     String m_inputParticleListName;
 }
CVSspam 0.2.8