lcsim/src/org/lcsim/contrib/seedtracker/analysis
diff -N AnalysisUtils.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AnalysisUtils.java 4 Aug 2008 18:43:20 -0000 1.1
@@ -0,0 +1,80 @@
+/*
+ * AnalysisUtils.java
+ *
+ * Created on August 4, 2008, 11:00 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.seedtracker.analysis;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.event.MCParticle;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
+
+/**
+ * This class contains utilities useful for seedtracker performance studies
+ * @author Richard Partridge
+ * @version 1.0
+ */
+public class AnalysisUtils {
+
+ /** Creates a new instance of AnalysisUtils */
+ public AnalysisUtils() {
+ }
+
+ /**
+ * Finds those MCParticles that are associated with every hit in a list of
+ * HelicalTrackHits. A list of size 0 is returned if there are no MCParticles
+ * that are associated with all hits.
+ * @param hitlist List of hits to be checked
+ * @return List of MCParticles that are associated with all hits
+ */
+ public static List<MCParticle> FindMCParticleInAllHits(List<HelicalTrackHit> hitlist) {
+
+ // Create a list for MCParticles that are in all hits
+ List<MCParticle> mcplist = new ArrayList<MCParticle>();
+
+ // If there are 0 hits, return an empty list
+ if (hitlist.size() == 0) return mcplist;
+
+ // Loop over the MCParticles in the first hit
+ for (MCParticle mcp : hitlist.get(0).getMCParticles()) {
+
+ // The boolean good will remain true as long as the MCParticle is in each hit checked
+ boolean good = true;
+ // Loop over the rest of the hits in the input list
+ for (int i = 1; i < hitlist.size(); i++) {
+
+ // The boolean match will be set true if we find the matching MCParticle in the current hit
+ boolean match = false;
+ // Loop over MCParticles in the current hit
+ for (MCParticle mcp2 : hitlist.get(i).getMCParticles()) {
+ // Check for a match
+ if (mcp.equals(mcp2)) {
+ // Found a match - signal it and we can quit checking
+ match = true;
+ break;
+ }
+ }
+
+ // If this hit did not have a match, the MCParticle being checked is not in all hits
+ if (match == false) {
+ good = false;
+ break;
+ }
+ }
+
+ // If we finish looping through all hits and find the MCParticle being checked is in all
+ // hits, add it to the list of MCParticles that are in all hits
+ if (good) mcplist.add(mcp);
+ }
+
+ // Done looping over all MCParticle candidates - return the list with any matches that were found
+ return mcplist;
+ }
+}
\ No newline at end of file