lcsim/src/org/lcsim/contrib/uiowa
diff -N FlushReconstructedParticlesDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FlushReconstructedParticlesDriver.java 27 Aug 2007 20:16:51 -0000 1.1
@@ -0,0 +1,76 @@
+package org.lcsim.contrib.uiowa;
+
+import java.util.*;
+import org.lcsim.event.*;
+import org.lcsim.event.util.*;
+import org.lcsim.event.base.*;
+import org.lcsim.util.lcio.LCIOConstants;
+import org.lcsim.util.Driver;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+/**
+ * This class is designed to take a list of ReconstructedParticle
+ * objects, as generated by some arbitrary reconstruction code,
+ * and massage them so that they can be written out and read back
+ * by LCIO successfully.
+ *
+ * This is still a work in progress.
+ *
+ * Things that do work:
+ * + Clusters can be read back in with the correct # of calorimeter hits
+ * + Cluster energy
+ * + Particle energy
+ * + Tracks can be read back in (but see below)
+ *
+ * Things that don't work (not exhaustive!):
+ * + Momentum of track is null
+ * + PID is null
+ */
+
+
+public class FlushReconstructedParticlesDriver extends Driver {
+
+ public FlushReconstructedParticlesDriver(String inputParticleList, String outputParticleList, String outputClusterList) {
+ m_inputParticleListName = inputParticleList;
+ m_outputParticleListName = outputParticleList;
+ m_outputClusterListName = outputClusterList;
+ }
+
+ public void process(EventHeader event) {
+ List<ReconstructedParticle> inputList = event.get(ReconstructedParticle.class, m_inputParticleListName);
+ Vector<ReconstructedParticle> outputList = new Vector<ReconstructedParticle>();
+ Vector<Cluster> outputClusterList = new Vector<Cluster>();
+ for (ReconstructedParticle inputPart : inputList) {
+ Set<CalorimeterHit> hits = new HashSet<CalorimeterHit>();
+ for (Cluster clus : inputPart.getClusters()) {
+ hits.addAll(clus.getCalorimeterHits());
+ }
+ BasicCluster outputCluster = new BasicCluster();
+ for (CalorimeterHit hit : hits) {
+ outputCluster.addHit(hit);
+ }
+ BaseReconstructedParticle outputPart = new BaseReconstructedParticle();
+ outputPart.addCluster(outputCluster);
+ outputClusterList.add(outputCluster);
+ for (Track tr : inputPart.getTracks()) {
+ outputPart.addTrack(tr);
+ }
+ // Finalize other properties
+ outputPart.setCharge(inputPart.getCharge());
+ outputPart.set4Vector(inputPart.asFourVector());
+ outputPart.setMass(inputPart.getMass());
+ outputPart.setParticleIdUsed(inputPart.getParticleIDUsed());
+ outputPart.setReferencePoint(inputPart.getReferencePoint());
+ outputList.add(outputPart);
+ }
+ // Write out clusters
+ int flag = 1<<LCIOConstants.CLBIT_HITS;
+ event.put(m_outputClusterListName, outputClusterList, Cluster.class, flag);
+ // Write out particles
+ event.put(m_outputParticleListName, outputList, ReconstructedParticle.class, 0);
+ }
+
+ String m_inputParticleListName;
+ String m_outputParticleListName;
+ String m_outputClusterListName;
+}
lcsim/src/org/lcsim/contrib/uiowa
diff -u -r1.13 -r1.14
--- NonTrivialPFA.java 21 Aug 2007 02:08:58 -0000 1.13
+++ NonTrivialPFA.java 27 Aug 2007 20:16:51 -0000 1.14
@@ -361,6 +361,10 @@
addHadronFinders(prefixHadronsMain, eventOutputParticles, fragID, fragMerge, eventMips, eventHaloMinusPhotonClusters, eventSmallClustersNotPhotons, trackList, eventSmallPhotonParticles, largePhotonParticleList, ronNeutralHadronCalib, ronChargedHadronCalib, true);
}
+ // Flush the output list to make sure it's LCIO-compatible
+ String eventOutputParticlesFlushed = "PFAReconstructedParticlesFlushed";
+ add(new FlushReconstructedParticlesDriver(eventOutputParticles, eventOutputParticlesFlushed, "testClusters"));
+
// Optionally, other hadron finders with various calibrations etc:
//addHadronFinders("nomerge_ron_ron__", eventOutputParticles+"_noFragMerge", fragID, fragNoMerge, eventMips, eventHaloMinusPhotonClusters, eventSmallClustersNotPhotons, trackList, eventSmallPhotonParticles, largePhotonParticleList, ronNeutralHadronCalib, ronChargedHadronCalib, false);
//addHadronFinders("merge_ron_adhoc__", eventOutputParticles+"_adhocEoverP", fragID, fragMerge, eventMips, eventHaloMinusPhotonClusters, eventSmallClustersNotPhotons, trackList, eventSmallPhotonParticles, largePhotonParticleList, ronNeutralHadronCalib, adHocCalib, false);
@@ -378,6 +382,8 @@
// Book-keeping
// Need to be smarter about this bit:
accountant.addListOfNamedLists( new String[] { eventSmallPhotonParticles, largePhotonParticleList, "merge_ron_ron__neutralHadronParticles", "merge_ron_ron__chargedHadronParticlesAfterFragmentHandling" } );
+
+ accountant.addListOfNamedLists( new String[] { eventOutputParticlesFlushed } );
}
// Make sure the book-keeping is OK: