lcsim/src/org/lcsim/event/util
diff -N MCParticleClassifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MCParticleClassifier.java 17 Aug 2005 23:46:18 -0000 1.1
@@ -0,0 +1,83 @@
+package org.lcsim.event.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.lcsim.event.MCParticle;
+
+/**
+ * MCPClassifier has a single method, getClassification(MCParticle), that returns
+ * an enum classifying the particle.
+ *
+ * Possible return values are:
+ *
+ * GEN_INITIAL -> Generator particle the simulator never saw
+ *
+ * GEN_PREDECAY -> Generator particle passed to the simulator along with a
+ * predecay, and the simulator generated the decay products.
+ *
+ * GEN_FINAL_STATE -> Generator final state particle: either FinalState in the
+ * input file, or intermediate passed to the Simulator with a
+ * predecay that never happened.
+ *
+ * SIM_BACKSCATTER -> Simulator particle produced as a result of backscatter from
+ * a non-tracking region.
+ *
+ * SIM_VERTEX_NOT_PARENT_ENDPOINT -> Simulator particle produced without destroying parent.
+ *
+ * SIM_INTERACTED_OR_DECAYED -> Simulator particle produced as a result of an interaction or
+ * decay in a tracking region.
+ */
+public class MCPClassifier
+{
+ public enum MCPClass
+ {
+ GEN_INITIAL,
+ GEN_PREDECAY,
+ GEN_FINAL_STATE,
+ SIM_BACKSCATTER,
+ SIM_VERTEX_NOT_PARENT_ENDPOINT,
+ SIM_INTERACTED_OR_DECAYED
+ };
+
+ public static MCPClass getClassification(MCParticle p)
+ {
+ if(p.getGeneratorStatus() > 0)
+ {
+ boolean hasGeneratorDaughters = false;
+ List<MCParticle> daughters = p.getDaughters();
+ for(MCParticle d : daughters)
+ {
+ if(d.getGeneratorStatus() > 0)hasGeneratorDaughters = true;
+ }
+
+ if (!hasGeneratorDaughters)
+ {
+ return MCPClass.GEN_FINAL_STATE;
+ }
+
+ if(p.getSimulatorStatus().isDecayedInTracker() |
+ p.getSimulatorStatus().isDecayedInCalorimeter())
+ {
+ return MCPClass.GEN_PREDECAY;
+ }
+
+ return MCPClass.GEN_INITIAL;
+ }
+ else
+ {
+ if (p.getSimulatorStatus().isBackscatter())
+ {
+ return MCPClass.SIM_BACKSCATTER;
+ }
+
+ if(p.getSimulatorStatus().vertexIsNotEndpointOfParent())
+ {
+ return MCPClass.SIM_VERTEX_NOT_PARENT_ENDPOINT;
+ }
+
+ return MCPClass.SIM_INTERACTED_OR_DECAYED;
+ }
+ }
+}
\ No newline at end of file