9 added files
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N CalorimeterHitCollectionDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitCollectionDriver.java 2 Oct 2009 01:10:02 -0000 1.1
@@ -0,0 +1,72 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.util.Driver;
+
+/**
+ * Combines a number of CalorimeterHit collections into a single output collection.
+ * @author jeremym
+ */
+public class CalorimeterHitCollectionDriver extends Driver
+{
+ List<String> collections = new ArrayList<String>();
+ String outputCollection = "CalorimeterHits";
+
+ public CalorimeterHitCollectionDriver()
+ {}
+
+ public void setInputCollections(String collections[])
+ {
+ this.collections.addAll(Arrays.asList(collections));
+ }
+
+ public void setInputCollection(String collection)
+ {
+ this.collections.add(collection);
+ }
+
+ public void setOutputCollection(String outputCollection)
+ {
+ this.outputCollection = outputCollection;
+ }
+
+ public void process(EventHeader event)
+ {
+ // Combine hits into single collection.
+ List<CalorimeterHit> combinedCollection = new ArrayList<CalorimeterHit>();
+
+ // Specified collections.
+ if (collections.size() != 0)
+ {
+ for (String collection : collections)
+ {
+ List<CalorimeterHit> hits = event.get(CalorimeterHit.class, collection);
+ combinedCollection.addAll(hits);
+ }
+ }
+ // All calorimeter collections.
+ else
+ {
+ for (List<CalorimeterHit> collection : event.get(CalorimeterHit.class))
+ {
+ for (CalorimeterHit hit : collection)
+ {
+ combinedCollection.add(hit);
+ }
+ }
+ }
+
+ // Get flags from first hit.
+ LCMetaData meta = combinedCollection.get(0).getMetaData();
+ int flags = meta.getFlags();
+
+ // Add combined collection to event.
+ event.put(outputCollection, combinedCollection, CalorimeterHit.class, flags, null);
+ }
+}
\ No newline at end of file
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N CalorimeterHitMapDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalorimeterHitMapDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,33 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import java.util.List;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.hitmap.HitMap;
+
+public class CalorimeterHitMapDriver
+{
+ String inputCollection = "CalorimeterHits";
+ String hitMapName = "CalorimeterHitMap";
+
+ public CalorimeterHitMapDriver()
+ {}
+
+ public void setInputCollection(String inputCollection)
+ {
+ this.inputCollection = inputCollection;
+ }
+
+ public void setHitMapName(String hitMapName)
+ {
+ this.hitMapName = hitMapName;
+ }
+
+ public void process(EventHeader event)
+ {
+ List<CalorimeterHit> collection = event.get(CalorimeterHit.class, inputCollection);
+ HitMap hitMap = new HitMap(collection);
+ event.put(hitMapName, hitMap);
+ }
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N FinalStateMCParticleDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FinalStateMCParticleDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,43 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.Driver;
+
+public class FinalStateMCParticleDriver extends Driver
+{
+ String initialParticleCollection = EventHeader.MC_PARTICLES;
+ String finalStateParticleCollection = "FinalState" + EventHeader.MC_PARTICLES;
+
+ public FinalStateMCParticleDriver()
+ {}
+
+ public void setInitialParticleCollection(String initialParticleCollection)
+ {
+ this.initialParticleCollection = initialParticleCollection;
+ }
+
+ public void setFinalStateParticleCollection(String finalStateParticleCollection)
+ {
+ this.finalStateParticleCollection = finalStateParticleCollection;
+ }
+
+ public void process(EventHeader event)
+ {
+ List<MCParticle> finalCollection = new ArrayList<MCParticle>();
+ List<MCParticle> initialCollection = event.get(MCParticle.class, initialParticleCollection);
+ for (MCParticle particle : initialCollection)
+ {
+ if (particle.getGeneratorStatus() == MCParticle.FINAL_STATE)
+ {
+ finalCollection.add(particle);
+ }
+ }
+ event.put(finalStateParticleCollection, finalCollection);
+ event.getMetaData(event.get(MCParticle.class,finalStateParticleCollection)).setSubset(true);
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N PerfectChargedHadronClusteringDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PerfectChargedHadronClusteringDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,24 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import org.lcsim.event.MCParticle;
+import static org.lcsim.event.util.ParticleTypeClassifier.isHadron;
+
+public class PerfectChargedHadronClusteringDriver extends PerfectClusteringDriver
+{
+ public PerfectChargedHadronClusteringDriver()
+ {
+ this.setClusterOutputCollection("PerfectChargedHadronClusters");
+ }
+
+ public boolean handles(MCParticle particle)
+ {
+ if (isHadron(particle.getPDGID()) && particle.getCharge() != 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
\ No newline at end of file
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N PerfectClusteringDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PerfectClusteringDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,198 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.util.Driver;
+
+/**
+ * Creates CalorimeterHit clusters with perfect efficiency and purity
+ * from the MCParticle contribution information in the hits.
+ * @author jeremym
+ */
+public class PerfectClusteringDriver extends Driver
+{
+ String finalStateParticleCollection = "FinalState" + EventHeader.MC_PARTICLES;
+ String calorimeterHitCollection = "CalorimeterHits";
+ String clusterCollection = "PerfectClusters";
+ boolean removeHits = true;
+ boolean removeParticles = false;
+ List<Integer> pdgids = new ArrayList<Integer>();
+ int minHits = 3;
+
+ public PerfectClusteringDriver()
+ {}
+
+ public void setRemoveHits(boolean removeHits)
+ {
+ this.removeHits = removeHits;
+ }
+
+ public void setRemoveParticles(boolean removeParticles)
+ {
+ this.removeParticles = removeParticles;
+ }
+
+ /**
+ * Override if a generalized condition is needed such
+ * as checking for a large range or set of PDG ids that
+ * are not defined in the pdgids list.
+ * @param pdgid
+ * @return
+ */
+ public boolean handles(MCParticle particle)
+ {
+ // If the set of PDG ids is not set, assume all FS particles
+ // should be processed.
+ if (pdgids.size() == 0)
+ return true;
+
+ // Check if non-empty PDG list contains this id.
+ if (pdgids.contains(particle.getPDGID()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public void setParticleId(int pdg)
+ {
+ this.pdgids.add(pdg);
+ }
+
+ public void setParticleIds(int pdgs[])
+ {
+ // FIXME: Use Arrays util. (how?)
+ for (int i=0; i<pdgs.length; i++)
+ {
+ pdgids.add(pdgs[i]);
+ }
+ }
+
+ public void setClusterOutputCollection(String clusterCollection)
+ {
+ this.clusterCollection = clusterCollection;
+ }
+
+ public void setCalorimeterHitInputCollection(String hitCollection)
+ {
+ this.calorimeterHitCollection = hitCollection;
+ }
+
+ public void process(EventHeader event)
+ {
+ // Find the output cluster collection.
+ boolean newClusterCollection = false;
+ List<Cluster> outputCollection = null;
+ if (event.hasCollection(Cluster.class, clusterCollection))
+ {
+ outputCollection = event.get(Cluster.class, clusterCollection);
+ }
+ else
+ {
+ outputCollection = new ArrayList<Cluster>();
+ newClusterCollection = true;
+ }
+
+ // Find the required FS MCParticle collection.
+ List<MCParticle> finalStateParticles = null;
+ if (event.hasCollection(MCParticle.class, finalStateParticleCollection))
+ {
+ finalStateParticles = event.get(MCParticle.class, finalStateParticleCollection);
+ }
+ else
+ {
+ throw new RuntimeException("The final state MCParticle collection " + this.finalStateParticleCollection + " does not exist!");
+ }
+
+ // Find the CalorimeterHit input collection.
+ List<CalorimeterHit> hits = null;
+ if (event.hasCollection(CalorimeterHit.class, this.calorimeterHitCollection))
+ {
+ hits = event.get(CalorimeterHit.class, this.calorimeterHitCollection);
+ }
+ else
+ {
+ throw new RuntimeException("The CalorimeterHit collection " + this.calorimeterHitCollection + " does not exist!");
+ }
+
+ List<MCParticle> particleRemove = new ArrayList<MCParticle>();
+
+ // Process final state particles.
+ for (MCParticle particle : finalStateParticles)
+ {
+ // List of hits for the new cluster.
+ List<CalorimeterHit> contribHits = new ArrayList<CalorimeterHit>();
+
+ // Use this particle if applicable.
+ if (handles(particle))
+ {
+ // Process all the CalorimeterHits.
+ for (CalorimeterHit hit : hits)
+ {
+ // Find contributions from this particle.
+ SimCalorimeterHit simhit = (SimCalorimeterHit)hit;
+ for (int i=0; i<simhit.getMCParticleCount(); i++)
+ {
+ MCParticle contrib = simhit.getMCParticle(i);
+ if (contrib == particle)
+ {
+ // Add contributing hit to list.
+ contribHits.add(simhit);
+ }
+ }
+ }
+ // Add to particle remove list.
+ if (removeParticles)
+ particleRemove.add(particle);
+ }
+
+ // Remove hits from collection.
+ if (removeHits)
+ {
+ for (CalorimeterHit hit : contribHits)
+ {
+ hits.remove(hit);
+ }
+ }
+
+ // Make cluster if greater hits than min.
+ if (contribHits.size() >= this.minHits)
+ {
+ // Create a new cluster.
+ BasicCluster perfectCluster = new BasicCluster();
+
+ // Add contributing hit list to cluster.
+ for (CalorimeterHit hit : contribHits)
+ {
+ perfectCluster.addHit(hit);
+ }
+
+ outputCollection.add(perfectCluster);
+ }
+ }
+
+ // Remove particles.
+ if (removeParticles)
+ {
+ for (MCParticle removeP : particleRemove)
+ {
+ finalStateParticles.remove(removeP);
+ }
+ }
+
+ // Add new cluster to collection if it is new. Otherwise, we modified
+ // an existing collection in the event.
+ if (newClusterCollection)
+ event.put(this.clusterCollection, outputCollection);
+ }
+}
\ No newline at end of file
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N PerfectMuonClusteringDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PerfectMuonClusteringDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,24 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import org.lcsim.event.MCParticle;
+import static org.lcsim.event.util.ParticleTypeClassifier.isMuon;
+
+public class PerfectMuonClusteringDriver extends PerfectClusteringDriver
+{
+ public PerfectMuonClusteringDriver()
+ {
+ this.setClusterOutputCollection("PerfectMuonClusters");
+ }
+
+ public boolean handles(MCParticle particle)
+ {
+ if (isMuon(particle.getPDGID()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N PerfectNeutralHadronClusteringDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PerfectNeutralHadronClusteringDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,25 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import org.lcsim.event.MCParticle;
+import static org.lcsim.event.util.ParticleTypeClassifier.isHadron;
+
+public class PerfectNeutralHadronClusteringDriver extends PerfectClusteringDriver
+{
+ public PerfectNeutralHadronClusteringDriver()
+ {
+ this.setClusterOutputCollection("PerfectNeutralHadronClusters");
+ }
+
+ public boolean handles(MCParticle particle)
+ {
+ if (isHadron(particle.getPDGID()) && (particle.getCharge() == 0))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N PerfectPhotonClusteringDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PerfectPhotonClusteringDriver.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,10 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+public class PerfectPhotonClusteringDriver extends PerfectClusteringDriver
+{
+ int photonIds[] = {21};
+ public PerfectPhotonClusteringDriver()
+ {
+ setParticleIds(photonIds);
+ }
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/jeremym/pfa/cheat
diff -N SimpleAnalysis.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SimpleAnalysis.java 2 Oct 2009 01:10:03 -0000 1.1
@@ -0,0 +1,62 @@
+package org.lcsim.contrib.jeremym.pfa.cheat;
+
+import java.io.IOException;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class SimpleAnalysis extends Driver
+{
+ String particleCollection = "CheatReconParticles";
+ String filename = "SimpleAnalysis.aida";
+ AIDA aida = AIDA.defaultInstance();
+
+ public SimpleAnalysis()
+ {}
+
+ public void setParticleCollection(String particleCollection)
+ {
+ this.particleCollection = particleCollection;
+ }
+
+ public void setFileName(String filename)
+ {
+ this.filename = filename;
+ }
+
+ public void process(EventHeader event)
+ {
+ double massSum = 0.;
+ double energySum = 0.;
+ int nparticles = 0;
+ int nclusters = 0;
+ int ntracks = 0;
+ for (ReconstructedParticle p : event.get(ReconstructedParticle.class, particleCollection))
+ {
+ massSum += p.getMass();
+ energySum += p.getEnergy();
+ ++nparticles;
+ nclusters += p.getClusters().size();
+ ntracks += p.getTracks().size();
+ }
+ aida.cloud1D("Mass").fill(massSum);
+ aida.cloud1D("Energy").fill(energySum);
+ aida.cloud1D("Number of Particles").fill(nparticles);
+ aida.cloud1D("Number of Clusters").fill(nclusters);
+ aida.cloud1D("Number of Tracks").fill(ntracks);
+ }
+
+ public void endOfData()
+ {
+ try
+ {
+ aida.saveAs(filename);
+ }
+ catch (IOException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
+}
CVSspam 0.2.8