4 added files
lcsim/src/org/lcsim/contrib/uiowa/template
diff -N ClusterListFilterDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClusterListFilterDriver.java 4 Feb 2006 01:24:24 -0000 1.1
@@ -0,0 +1,86 @@
+package template;
+
+import java.util.*;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.util.decision.*;
+
+public class ClusterListFilterDriver extends Driver
+{
+ public ClusterListFilterDriver() {};
+ public ClusterListFilterDriver(DecisionMakerSingle<Cluster> dec) { m_inputDecision = dec; }
+
+ public void process(EventHeader event)
+ {
+ List<Cluster> inputClusterList = event.get(Cluster.class, m_inputClusterListName);
+
+ // Which ones pass the filter?
+ // ---------------------------
+ ListFilter<Cluster> filter = new ListFilter<Cluster> (m_inputDecision);
+ List<Cluster> filteredInputList = filter.filterList(inputClusterList);
+ event.put(m_outputClusterPassName, filteredInputList);
+
+ // Which clusters fail the filter?
+ // -------------------------------
+ List<Cluster> failedClusterList = new Vector<Cluster>();
+ for (Cluster clus : inputClusterList) {
+ if ( !(filteredInputList.contains(clus)) ) {
+ failedClusterList.add(clus);
+ }
+ }
+ // Sanity check
+ if ( filteredInputList.size() + failedClusterList.size() != inputClusterList.size() ) {
+ throw new AssertionError("Bookkeeping error");
+ }
+ // Write out the list that fail
+ if (m_outputClusterFailName != null) {
+ event.put(m_outputClusterFailName, failedClusterList);
+ }
+
+ // Which hits pass the filter?
+ // ---------------------------
+ if (m_outputHitMapPassedName != null) {
+ Map<Long,CalorimeterHit> outputHitMapPassed = new HashMap<Long,CalorimeterHit> ();
+ for (Cluster clus : filteredInputList) {
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ Long id = new Long(hit.getCellID());
+ outputHitMapPassed.put(id,hit);
+ }
+ }
+ event.put(m_outputHitMapPassedName, outputHitMapPassed);
+ }
+
+ // Which hits fail the filter?
+ // ---------------------------
+ if (m_outputHitMapFailedName != null) {
+ Map<Long,CalorimeterHit> outputHitMapFailed = new HashMap<Long,CalorimeterHit> ();
+ for (Cluster clus : failedClusterList) {
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ Long id = new Long(hit.getCellID());
+ outputHitMapFailed.put(id,hit);
+ }
+ }
+ event.put(m_outputHitMapFailedName, outputHitMapFailed);
+ }
+ }
+
+ public void setInputClusterList (String name) {m_inputClusterListName = name;}
+ public void setOutputClusterListPass(String name) {m_outputClusterPassName = name;}
+ public void setOutputClusterListFail(String name) {m_outputClusterFailName = name;}
+ public void setOutputHitMapPass (String name) {m_outputHitMapPassedName= name;}
+ public void setOutputHitMapFail (String name) {m_outputHitMapFailedName= name;}
+ public void setInputDecision(DecisionMakerSingle<Cluster> dec) { m_inputDecision = dec; }
+
+ DecisionMakerSingle<Cluster> m_inputDecision;
+ String m_inputClusterListName;
+ String m_outputClusterPassName;
+ String m_outputClusterFailName;
+ String m_outputHitMapPassedName;
+ String m_outputHitMapFailedName;
+}
lcsim/src/org/lcsim/contrib/uiowa/template
diff -N VetoClustersFromParticles.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ VetoClustersFromParticles.java 4 Feb 2006 01:24:24 -0000 1.1
@@ -0,0 +1,52 @@
+package template;
+
+import java.util.*;
+import org.lcsim.util.*;
+import org.lcsim.event.*;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.util.decision.*;
+
+public class VetoClustersFromParticles extends Driver implements DecisionMakerSingle<Cluster>
+{
+ public VetoClustersFromParticles(String particleList) {
+ m_particleListName = particleList;
+ }
+
+ public boolean valid(Cluster objectToTest) {
+ List<ReconstructedParticle> particles = m_event.get(ReconstructedParticle.class, m_particleListName);
+ for (ReconstructedParticle part : particles) {
+ List<Cluster> subClusters = recursivelyFindSubClusters(part);
+ boolean clusterInParticle = (subClusters.contains(objectToTest));
+ if (clusterInParticle) { return false; }
+ }
+ // No match
+ return true;
+ }
+
+ public void process(EventHeader event) {
+ m_event = event;
+ }
+
+ protected List<Cluster> recursivelyFindSubClusters(ReconstructedParticle part)
+ {
+ List<Cluster> allSubClusters = new Vector<Cluster>();
+ for (Cluster clus : part.getClusters()) {
+ List<Cluster> subClusters = recursivelyFindSubClusters(clus);
+ allSubClusters.addAll(subClusters);
+ }
+ return allSubClusters;
+ }
+ protected List<Cluster> recursivelyFindSubClusters(Cluster clus)
+ {
+ List<Cluster> output = new Vector<Cluster>();
+ for (Cluster dau : clus.getClusters()) {
+ output.addAll(recursivelyFindSubClusters(dau));
+ }
+ output.add(clus);
+ return output;
+ }
+
+
+ EventHeader m_event;
+ String m_particleListName;
+}
lcsim/src/org/lcsim/contrib/uiowa/template
diff -N NeutralHadronIdentifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ NeutralHadronIdentifier.java 4 Feb 2006 01:24:24 -0000 1.1
@@ -0,0 +1,38 @@
+package template;
+
+import java.util.*;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.Cluster;
+
+import util.EnergyCalibration;
+import util.OldEnergyCalibration;
+
+public class NeutralHadronIdentifier extends Driver
+{
+ public NeutralHadronIdentifier() {
+ }
+ public void setInputClusterList(String name){ m_inputClusterListName = name; }
+ public void setOutputParticleList(String name){ m_outputParticleListName = name; }
+
+ public void process(EventHeader event)
+ {
+ // Input, output:
+ List<Cluster> inputClusterList = event.get(Cluster.class, m_inputClusterListName);
+ List<ReconstructedParticle> outputParticleList = new Vector<ReconstructedParticle>();
+
+ for (Cluster clus : inputClusterList) {
+ BasicReconstructedParticle part = new BasicReconstructedParticle();
+ part.addCluster(clus);
+ outputParticleList.add(part);
+ part.setEnergy(m_calibration.energy(clus));
+ }
+
+ event.put(m_outputParticleListName, outputParticleList);
+ }
+
+ String m_inputClusterListName;
+ String m_outputParticleListName;
+ EnergyCalibration m_calibration = new OldEnergyCalibration();
+}
lcsim/src/org/lcsim/contrib/uiowa/template
diff -N EnergySumPlotter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EnergySumPlotter.java 4 Feb 2006 01:24:24 -0000 1.1
@@ -0,0 +1,64 @@
+package template;
+
+import java.io.IOException;
+import java.util.List;
+import java.lang.String;
+import hep.aida.ITree;
+import hep.aida.IAnalysisFactory;
+import hep.aida.IHistogramFactory;
+import hep.aida.IHistogram1D;
+import hep.aida.ICloud1D;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+
+import org.lcsim.event.ReconstructedParticle;
+
+public class EnergySumPlotter extends Driver
+{
+ public EnergySumPlotter(String inputClusterListName, String filename)
+ {
+ m_inputParticleListName = inputClusterListName;
+ IAnalysisFactory af = IAnalysisFactory.create();
+ try {
+ 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);
+ } catch (IOException ioe1) {
+ ioe1.printStackTrace();
+ }
+
+ }
+
+ public void process(EventHeader event)
+ {
+ // Read in the clusters:
+ List<ReconstructedParticle> inputParticleList;
+
+ try {
+ inputParticleList = event.get(ReconstructedParticle.class, m_inputParticleListName);
+ } catch (java.lang.IllegalArgumentException x) {
+ System.out.println("WARNING: Particle list ["+m_inputParticleListName+"] not found.");
+ return;
+ }
+
+ double energySum = 0.0;
+ for (ReconstructedParticle part : inputParticleList) {
+ energySum += part.getEnergy();
+ }
+
+ m_histo.fill(energySum);
+ }
+
+ public void suspend() {
+ try {
+ m_tree.commit();
+ } catch(IOException ioe1) {
+ ioe1.printStackTrace();
+ }
+ super.suspend();
+ }
+
+ ITree m_tree = null;
+ IHistogram1D m_histo;
+ String m_inputParticleListName;
+}
CVSspam 0.2.8