Commit in hps-java/src/main on MAIN
java/org/lcsim/hps/recon/ecal/HPSFADCTriggerDriver.java+341added 1.1
                             /HPS1BitTriggerDriver.java+42added 1.1
                             /HPSFADCClusterer.java+5-1111.1 -> 1.2
                             /HPSTriggerDriver.java+5-261.2 -> 1.3
                             /HPSEcalClusterer.java+139-1431.14 -> 1.15
                             /HPSEcalFlashTrigger.java+2-21.3 -> 1.4
                             /HPSEcalCluster.java+2-11.2 -> 1.3
resources/org/lcsim/hps/steering/ecal_1bit_bkgd.lcsim+55-551.4 -> 1.5
                                /ecal_1bit_ap.lcsim+55-551.3 -> 1.4
+646-393
2 added + 7 modified, total 9 files
add FADC trigger; add abstract trigger driver; fix a bug in HPSEcalCluster where seed hit energy wasn't being added; update steering files

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSFADCTriggerDriver.java added at 1.1
diff -N HPSFADCTriggerDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HPSFADCTriggerDriver.java	17 Nov 2011 01:43:26 -0000	1.1
@@ -0,0 +1,341 @@
+package org.lcsim.hps.recon.ecal;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+
+/**
+ * Reads clusters and makes trigger decision using opposite quadrant criterion.
+ * Prints triggers to file if file path specified.
+ *
+ * @author Omar Moreno <[log in to unmask]>
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: HPSFADCTriggerDriver.java,v 1.1 2011/11/17 01:43:26 meeg Exp $
+ */
+public class HPSFADCTriggerDriver extends HPSTriggerDriver {
+
+	// A list to contain all cluster pairs in an event
+	List<HPSEcalCluster[]> clusterPairs;
+	int nTriggers;
+	int totalEvents;
+	private double clusterEnergyHigh = 1.85; // GeV
+	private double clusterEnergyLow = .1;    // GeV
+	private double energySumThreshold = 2.2;  // GeV
+	private double energyDifferenceThreshold = 1.5; // GeV
+	private double maxCoplanarityAngle = 35; // degrees
+	double crystalX = (13.3 + 16.0) / 2;
+	double crystalY = (13.3 + 16.0) / 2;
+	double beamGap = 20.0;
+	int oppositeQuadrantCount;
+	int clusterEnergyCount;
+	int energySumCount;
+	int energyDifferenceCount;
+	int energyDistanceCount;
+	int coplanarityCount;
+	int nonuniqueTriggerCount;
+
+	public HPSFADCTriggerDriver() {
+		clusterPairs = new LinkedList<HPSEcalCluster[]>();
+	}
+
+	public void startOfData() {
+		if (clusterCollectionName == null) {
+			throw new RuntimeException("The parameter ecalCollectionName was not set!");
+		}
+
+		if (ecalName == null) {
+			throw new RuntimeException("The parameter ecalName was not set!");
+		}
+
+		if (outputFileName != null) {
+			try {
+				outputStream = new PrintWriter(outputFileName);
+			} catch (IOException ex) {
+				throw new RuntimeException("Invalid outputFilePath!");
+			}
+		}
+
+		numTriggers = 0;
+
+		oppositeQuadrantCount = 0;
+		clusterEnergyCount = 0;
+		energySumCount = 0;
+		energyDifferenceCount = 0;
+		energyDistanceCount = 0;
+		coplanarityCount = 0;
+		nonuniqueTriggerCount = 0;
+	}
+
+	public boolean testTrigger(List<HPSEcalCluster> clusters) {
+		boolean trigger = false;
+
+		getClusterPairs(clusters);
+
+		//--- Apply Trigger Cuts ---//
+
+		// Iterate through all cluster pairs present in the event.  If at least
+		// one of the cluster pairs satisfies all of the trigger conditions,
+		// a trigger signal is sent to all other detectors.
+		for (HPSEcalCluster[] clusterPair : clusterPairs) {
+
+			// Require that the event have at least two clusters in opposite
+			// quadrants
+			if (!oppositeQuadrantsCut(clusterPair))
+				continue;
+			oppositeQuadrantCount++;
+
+			// Require the componets of a cluster pair to have an energy in
+			// the range of 100 MeV to 1.85 GeV
+			if (!clusterECut(clusterPair))
+				continue;
+			clusterEnergyCount++;
+
+			// Require the sum of the energies of the components of the
+			// cluster pair to be less than the
+			// (Beam Energy)*(Sampling Fraction) ( 2 GeV for the Test Run )
+			if (!energySum(clusterPair))
+				continue;
+			energySumCount++;
+
+			// Require the difference in energy of the components of the
+			// cluster pair to be less than 1.5 GeV
+			if (!energyDifference(clusterPair))
+				continue;
+			energyDifferenceCount++;
+
+			// Apply a low energy cluster vs. distance cut of the form
+			// E_low + .0032 GeV/mm < .8 GeV
+			if (!energyDistanceCut(clusterPair))
+				continue;
+			energyDistanceCount++;
+
+			// Require that the two clusters are coplanar with the beam within
+			// 35 degrees
+			if (!coplanarityCut(clusterPair))
+				continue;
+			coplanarityCount++;
+			nonuniqueTriggerCount++;
+
+			// If all cuts are pased, we have a trigger
+			trigger = true;
+		}
+		return trigger;
+	}
+
+	public void endOfData() {
+		if (outputStream != null) {
+			outputStream.printf("Number of cluster pairs after successive trigger conditions:\n");
+			outputStream.printf("Opposite quadrants: %d\n", oppositeQuadrantCount);
+			outputStream.printf("Cluster energy: %d\n", clusterEnergyCount);
+			outputStream.printf("Energy sum: %d\n", energySumCount);
+			outputStream.printf("Energy difference: %d\n", energyDifferenceCount);
+			outputStream.printf("Energy-distance cut: %d\n", energyDistanceCount);
+			outputStream.printf("Coplanarity: %d\n", coplanarityCount);
+			outputStream.printf("Final count of passing cluster pairs: %d\n", nonuniqueTriggerCount);
+			outputStream.printf("Trigger count: %d\n", numTriggers);
+			outputStream.close();
+		}
+		System.out.printf("Number of cluster pairs after successive trigger conditions:\n");
+		System.out.printf("Opposite quadrants: %d\n", oppositeQuadrantCount);
+		System.out.printf("Cluster energy: %d\n", clusterEnergyCount);
+		System.out.printf("Energy sum: %d\n", energySumCount);
+		System.out.printf("Energy difference: %d\n", energyDifferenceCount);
+		System.out.printf("Energy-distance cut: %d\n", energyDistanceCount);
+		System.out.printf("Coplanarity: %d\n", coplanarityCount);
+		System.out.printf("Final count of passing cluster pairs: %d\n", nonuniqueTriggerCount);
+		System.out.printf("Trigger count: %d\n", numTriggers);
+	}
+
+	/**
+	 * Get a list of all unique cluster pairs in the event
+	 *
+	 * @param ecalClusters : List of ECal clusters
+	 * @return true if there are any cluster pairs
+	 */
+	public boolean getClusterPairs(List<HPSEcalCluster> ecalClusters) {
+		// Create a list which will hold all neighboring cluster to the cluster
+		// of interest
+		List< HPSEcalCluster> ecalClusterNeighbors = new LinkedList< HPSEcalCluster>();
+		ecalClusterNeighbors.addAll(ecalClusters);
+
+		// Clear the list of cluster pairs
+		clusterPairs.clear();
+
+		for (HPSEcalCluster ecalCluster : ecalClusters) {
+			// Create a list of neighbors to the cluster of interest
+			ecalClusterNeighbors.remove(ecalCluster);
+
+			// Loop over all neigboring clusters and check to see if there is
+			// any which lie in opposing quadrants to the cluster of interest.
+			// If so, add them to the list of cluster pairs
+			for (HPSEcalCluster ecalClusterNeighbor : ecalClusterNeighbors) {
+				HPSEcalCluster[] clusterPair = {ecalCluster, ecalClusterNeighbor};
+				clusterPairs.add(clusterPair);
+			}
+		}
+
+		return !clusterPairs.isEmpty();
+	}
+
+	/**
+	 * Checks if the ECal clusters making up a cluster pair lie in opposite quadrants
+	 *
+	 * @param clusterPair : pair of clusters
+	 * @return  true if opposite quadrants, false otherwise
+	 */
+	public boolean oppositeQuadrantsCut(HPSEcalCluster[] clusterPair) {
+		int quad1 = getECalQuadrant(clusterPair[0]);
+		int quad2 = getECalQuadrant(clusterPair[1]);
+
+		//if clusters are in the same quadrant, they're not opposite quadrants
+		if (quad1 == quad2)
+			return false;
+		//opposite pairs of quadrants are either both even (2 and 4) or both off (1 and 3)
+		else
+			return ((quad1 & 1) == (quad2 & 1));
+	}
+
+	/**
+	 *  Returns the quadrant which contains the ECal cluster
+	 *
+	 * @param ecalCluster : ECal cluster
+	 * @return Quadrant number
+	 */
+	public int getECalQuadrant(HPSEcalCluster ecalCluster) {
+		dec.setID(ecalCluster.getSeedHit().getCellID());
+		int ix = dec.getValue("ix");
+		int iy = dec.getValue("iy");
+		if (ix > 0) {
+			if (iy > 0) {
+				return 1;
+			} else {
+				return 4;
+			}
+		} else {
+			if (iy > 0) {
+				return 2;
+			} else {
+				return 3;
+			}
+		}
+	}
+
+	/**
+	 * Checks if the ECal clusters making up a cluster pair lie above the low
+	 * energy threshold and below the high energy threshold
+	 *
+	 * @param clusterPair : pair of clusters
+	 * @return  true if a pair is found, false otherwise
+	 */
+	public boolean clusterECut(HPSEcalCluster[] clusterPair) {
+		return (clusterPair[0].getEnergy() < clusterEnergyHigh
+				&& clusterPair[1].getEnergy() < clusterEnergyHigh
+				&& clusterPair[0].getEnergy() > clusterEnergyLow
+				&& clusterPair[1].getEnergy() > clusterEnergyLow);
+	}
+
+	/**
+	 * Checks if the sum of the energies of ECal clusters making up a cluster
+	 * pair is below an energy sum threshold
+	 *
+	 * @param clusterPair : pair of clusters
+	 * @return true if a pair is found, false otherwise
+	 */
+	public boolean energySum(Cluster[] clusterPair) {
+		double clusterESum = clusterPair[0].getEnergy()
+				+ clusterPair[1].getEnergy();
+		return (clusterESum < energySumThreshold);
+	}
+
+	/**
+	 * Checks if the energy difference between the ECal clusters making up
+	 * a cluster pair is below an energy difference threshold
+	 *
+	 * @param clusterPair : pair of clusters
+	 * @return  true if pair is found, false otherwise
+	 */
+	public boolean energyDifference(HPSEcalCluster[] clusterPair) {
+		double clusterEDifference = Math.abs(clusterPair[0].getEnergy()
+				- clusterPair[1].getEnergy());
+
+		return (clusterEDifference < energyDifferenceThreshold);
+	}
+
+	/**
+	 * Require that the distance from the beam of the lowest energy cluster
+	 * in a cluster pair satisfies the following
+	 * E_low + d_b*.0032 GeV/mm < .8 GeV
+	 *
+	 * @param clusterPair : pair of clusters
+	 * @return  true if pair is found, false otherwise
+	 */
+	public boolean energyDistanceCut(HPSEcalCluster[] clusterPair) {
+		HPSEcalCluster lowEnergyCluster;
+
+		// Obtain the lowest energy cluster
+		if (clusterPair[0].getEnergy() < clusterPair[1].getEnergy())
+			lowEnergyCluster = clusterPair[0];
+		else
+			lowEnergyCluster = clusterPair[1];
+
+		double lowEClusterPosition[] = hitPosition(lowEnergyCluster.getSeedHit());
+		// Calculate its position
+		double lowEClusterDistance = Math.sqrt(Math.pow(lowEClusterPosition[0], 2)
+				+ Math.pow(lowEClusterPosition[1], 2));
+
+		double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * (0.0032);
+
+		if (clusterDistvsE > .8 /* GeV */)
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Checks if a cluster pair is coplanar to the beam within a given
+	 * angle
+	 *
+	 * @param clusterPair : pair of clusters
+	 * @return true if pair is found, false otherwise
+	 */
+	public boolean coplanarityCut(HPSEcalCluster[] clusterPair) {
+		double cluster1Position[] = hitPosition(clusterPair[0].getSeedHit());
+		double cluster2Position[] = hitPosition(clusterPair[1].getSeedHit());
+		// Find the distance of both clusters from the origin
+		double cluster1Dist = Math.sqrt(Math.pow(cluster1Position[0], 2)
+				+ Math.pow(cluster1Position[1], 2));
+		double cluster2Dist = Math.sqrt(Math.pow(cluster2Position[0], 2)
+				+ Math.pow(cluster2Position[1], 2));
+
+		// Calculate the dot product between the distance vectors of
+		// each cluster in the cluster pair
+		double clusterDot = cluster1Position[0] * cluster2Position[0]
+				+ cluster1Position[1] * cluster2Position[1];
+
+		// Find the angle between clusters in the pair
+		double cosphi = clusterDot / (cluster1Dist * cluster2Dist);
+		double phi = Math.toDegrees(Math.acos(cosphi));
+
+		return ((180 - phi) < maxCoplanarityAngle);
+	}
+
+	/**
+	 * Finds position of an ECal hit using the crystal ID
+	 * @param hit : ECal hit
+	 * @return [x,y] of crystal center in units of mm
+	 */
+	public double[] hitPosition(CalorimeterHit hit) {
+		dec.setID(hit.getCellID());
+		int ix = dec.getValue("ix");
+		int iy = dec.getValue("iy");
+		double position[] = new double[2];
+		position[0] = crystalX * ix;
+		position[1] = crystalY * iy + beamGap * Math.signum(iy);
+
+		return position;
+	}
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPS1BitTriggerDriver.java added at 1.1
diff -N HPS1BitTriggerDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HPS1BitTriggerDriver.java	17 Nov 2011 01:43:26 -0000	1.1
@@ -0,0 +1,42 @@
+package org.lcsim.hps.recon.ecal;
+
+import java.util.List;
+
+/**
+ * Reads clusters and makes trigger decision using opposite quadrant criterion.
+ * Prints triggers to file if file path specified.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: HPS1BitTriggerDriver.java,v 1.1 2011/11/17 01:43:26 meeg Exp $
+ */
+public class HPS1BitTriggerDriver extends HPSTriggerDriver {
+	public HPS1BitTriggerDriver() {
+	}
+
+	public boolean testTrigger(List<HPSEcalCluster> clusters) {
+
+		boolean quadrants[] = new boolean[4];
+
+		for (HPSEcalCluster clus : clusters) {
+			dec.setID(clus.getSeedHit().getCellID());
+			int ix = dec.getValue("ix");
+			int iy = dec.getValue("iy");
+			//System.out.printf("ix = %d, iy = %d\n", ix, iy);
+
+			if (ix > 0) {
+				if (iy > 0) {
+					quadrants[0] = true;
+				} else {
+					quadrants[3] = true;
+				}
+			} else {
+				if (iy > 0) {
+					quadrants[1] = true;
+				} else {
+					quadrants[2] = true;
+				}
+			}
+		}
+		return (quadrants[0] && quadrants[2]) || (quadrants[1] && quadrants[3]);
+	}
+}
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSFADCClusterer.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HPSFADCClusterer.java	4 Nov 2011 00:51:19 -0000	1.1
+++ HPSFADCClusterer.java	17 Nov 2011 01:43:26 -0000	1.2
@@ -1,21 +1,16 @@
 package org.lcsim.hps.recon.ecal;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawCalorimeterHit;
 import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap;
 import org.lcsim.geometry.subdetector.HPSEcal3;
-import org.lcsim.util.Driver;
 import org.lcsim.util.lcio.LCIOConstants;
 
 /**
@@ -26,23 +21,11 @@
  *
  * @author Sho Uemura <[log in to unmask]>
  *
- * @version $Id: HPSFADCClusterer.java,v 1.1 2011/11/04 00:51:19 meeg Exp $
+ * @version $Id: HPSFADCClusterer.java,v 1.2 2011/11/17 01:43:26 meeg Exp $
  */
-public class HPSFADCClusterer extends Driver {
+public class HPSFADCClusterer extends HPSEcalClusterer {
 
-	HPSEcal3 ecal;
 	HPSEcalConverter converter = null;
-	String ecalCollectionName;
-	String ecalName;
-	String clusterCollectionName = "EcalClusters";
-	// Minimum E for cluster seed.
-	double seedEMin = .05;
-	// Minimum E to add hit to cluster.
-	double addEMin = .03;
-	// Odd or even number of crystals in X.
-	boolean oddX;
-	// Map of crystals to their neighbors.
-	NeighborMap neighborMap = null;
 	int coincidenceWindow = 2;
 	LinkedList<RawCalorimeterHit> buffer = new LinkedList<RawCalorimeterHit>();
 	int currentTime;
@@ -50,38 +33,10 @@
 	public HPSFADCClusterer() {
 	}
 
-	public void setClusterCollectionName(String clusterCollectionName) {
-		this.clusterCollectionName = clusterCollectionName;
-	}
-
-	public void setSeedEMin(double seedEMin) {
-		this.seedEMin = seedEMin;
-	}
-
-	public void setAddEMin(double addEMin) {
-		this.addEMin = addEMin;
-	}
-
 	public void setCoincidenceWindow(int coincidenceWindow) {
 		this.coincidenceWindow = coincidenceWindow;
 	}
 
-	public void setEcalCollectionName(String ecalCollectionName) {
-		this.ecalCollectionName = ecalCollectionName;
-	}
-
-	public void setEcalName(String ecalName) {
-		this.ecalName = ecalName;
-	}
-
-	public void startOfData() {
-		if (ecalCollectionName == null)
-			throw new RuntimeException("The parameter ecalCollectionName was not set!");
-
-		if (ecalName == null)
-			throw new RuntimeException("The parameter ecalName was not set!");
-	}
-
 	public void detectorChanged(Detector detector) {
 		// Get the Subdetector.
 		ecal = (HPSEcal3) detector.getSubdetector(ecalName);
@@ -108,12 +63,6 @@
 		if (hits == null)
 			throw new RuntimeException("Event is missing ECal raw hits collection!");
 
-		// Put Cluster collection into event.
-		int flag = 1 << LCIOConstants.CLBIT_HITS;
-		event.put(clusterCollectionName, createClusters(hits), Cluster.class, flag);
-	}
-
-	public List<Cluster> createClusters(List<HPSFADCCalorimeterHit> hits) {
 		buffer.addAll(hits);
 		// Make a hit map for quick lookup by ID.
 		Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>();
@@ -129,63 +78,8 @@
 			}
 		}
 
-		return createClusters(hitMap);
-	}
-
-	public List<Cluster> createClusters(Map<Long, CalorimeterHit> map) {
-
-		// New Cluster list to be added to event.
-		List<Cluster> clusters = new ArrayList<Cluster>();
-
-		Collection<CalorimeterHit> hits = map.values();
-
-		// Loop over ECal hits to find cluster seeds.
-		for (CalorimeterHit hit : hits) {
-			// Cut on min seed E.
-			if (hit.getRawEnergy() < seedEMin)
-				continue;
-
-			// Get neighbor crystal IDs.
-			Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
-			if (neighbors == null)
-				throw new RuntimeException("Oops!  Set of neighbors is null!");
-
-			// List for neighboring hits.
-			List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>();
-
-			// Loop over neighbors to make hit list for cluster.
-			boolean isSeed = true;
-			for (Long neighborId : neighbors) {
-				// Find the neighbor hit in the event if it exists.
-				CalorimeterHit neighborHit = map.get(neighborId);
-
-				// Was this neighbor cell hit?
-				if (neighborHit != null) {
-					// Check if neighbor cell has more energy.
-					if (neighborHit.getRawEnergy() > hit.getRawEnergy()) {
-						// Neighbor has more energy, so cell is not a seed.
-						isSeed = false;
-						break;
-					}
-
-					// Add to cluster if above min E.
-					if (neighborHit.getRawEnergy() >= addEMin) {
-						neighborHits.add(neighborHit);
-					}
-				}
-			}
-
-			// Did we find a seed?
-			if (isSeed) {
-				// Make a cluster from the hit list.
-				HPSEcalCluster cluster = new HPSEcalCluster(hit);
-				for (CalorimeterHit clusHit : neighborHits) {
-					cluster.addHit(clusHit);
-				}
-				clusters.add(cluster);
-			}
-		}
-		return clusters;
+		// Put Cluster collection into event.
+		int flag = 1 << LCIOConstants.CLBIT_HITS;
+		event.put(clusterCollectionName, createClusters(hitMap), Cluster.class, flag);
 	}
 }
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSTriggerDriver.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HPSTriggerDriver.java	21 Oct 2011 19:54:08 -0000	1.2
+++ HPSTriggerDriver.java	17 Nov 2011 01:43:26 -0000	1.3
@@ -16,9 +16,9 @@
  * Prints triggers to file if file path specified.
  *
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSTriggerDriver.java,v 1.2 2011/10/21 19:54:08 meeg Exp $
+ * @version $Id: HPSTriggerDriver.java,v 1.3 2011/11/17 01:43:26 meeg Exp $
  */
-public class HPSTriggerDriver extends Driver {
+public abstract class HPSTriggerDriver extends Driver {
 
     Subdetector ecal;
     String ecalName;
@@ -79,30 +79,7 @@
         if (clusters == null)
             throw new RuntimeException("Event is missing ECal clusters collection!");
 
-        boolean quadrants[] = new boolean[4];
-
-        for (HPSEcalCluster clus : clusters) {
-            dec.setID(clus.getSeedHit().getCellID());
-            int ix = dec.getValue("ix");
-            int iy = dec.getValue("iy");
-            //System.out.printf("ix = %d, iy = %d\n", ix, iy);
-
-            if (ix > 0) {
-                if (iy > 0) {
-                    quadrants[0] = true;
-                } else {
-                    quadrants[3] = true;
-                }
-            } else {
-                if (iy > 0) {
-                    quadrants[1] = true;
-                } else {
-                    quadrants[2] = true;
-                }
-            }
-        }
-
-        if ((quadrants[0] && quadrants[2]) || (quadrants[1] && quadrants[3])) {
+        if (testTrigger(clusters)) {
             numTriggers++;
             if (outputStream != null)
                 outputStream.printf("Trigger on event %d\n", event.getEventNumber());
@@ -110,6 +87,8 @@
         }
     }
 
+	public abstract boolean testTrigger(List<HPSEcalCluster> clusters);
+
     public void endOfData() {
         if (outputStream != null) {
             outputStream.printf("Trigger count: %d\n", numTriggers);

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcalClusterer.java 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- HPSEcalClusterer.java	30 Sep 2011 23:31:27 -0000	1.14
+++ HPSEcalClusterer.java	17 Nov 2011 01:43:26 -0000	1.15
@@ -26,149 +26,145 @@
  * @author Jeremy McCormick <[log in to unmask]>
  * @author Tim Nelson <[log in to unmask]>
  *
- * @version $Id: HPSEcalClusterer.java,v 1.14 2011/09/30 23:31:27 meeg Exp $
+ * @version $Id: HPSEcalClusterer.java,v 1.15 2011/11/17 01:43:26 meeg Exp $
  */
-public class HPSEcalClusterer extends Driver implements Clusterer {
+public class HPSEcalClusterer extends Driver {
 
-    HPSEcal3 ecal;
-    String ecalCollectionName;
-    String ecalName;
-    String clusterCollectionName = "EcalClusters";
-    // Minimum E for cluster seed.
-    double seedEMin = .05;
-    // Minimum E to add hit to cluster.
-    double addEMin = .03;
-    // Odd or even number of crystals in X.
-    boolean oddX;
-    // Map of crystals to their neighbors.
-    NeighborMap neighborMap = null;
-
-    public HPSEcalClusterer() {
-    }
-
-    public void setClusterCollectionName(String clusterCollectionName) {
-        this.clusterCollectionName = clusterCollectionName;
-    }
-
-    public void setSeedEMin(double seedEMin) {
-        this.seedEMin = seedEMin;
-    }
-
-    public void setAddEMin(double addEMin) {
-        this.addEMin = addEMin;
-    }
-
-    public void setEcalCollectionName(String ecalCollectionName) {
-        this.ecalCollectionName = ecalCollectionName;
-    }
-
-    public void setEcalName(String ecalName) {
-        this.ecalName = ecalName;
-    }
-
-    public void startOfData() {
-        if (ecalCollectionName == null)
-            throw new RuntimeException("The parameter ecalCollectionName was not set!");
-
-        if (ecalName == null)
-            throw new RuntimeException("The parameter ecalName was not set!");
-    }
-
-    public void detectorChanged(Detector detector) {
-        // Get the Subdetector.
-        ecal = (HPSEcal3) detector.getSubdetector(ecalName);
-
-        // Cache ref to neighbor map.
-        neighborMap = ecal.getNeighborMap();
-
-        //System.out.println(ecal.getName());
-        //System.out.println("  nx="+ecal.nx());
-        //System.out.println("  ny="+ecal.ny());
-        //System.out.println("  beamgap="+ecal.beamGap());
-        //System.out.println("  dface="+ecal.distanceToFace());
-
-        //System.out.println(neighborMap.toString());
-    }
-
-    public void process(EventHeader event) {
-        //System.out.println(this.getClass().getCanonicalName() + " - process");
-
-        // Get the list of raw ECal hits.
-        List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
-        if (hits == null)
-            throw new RuntimeException("Event is missing ECal raw hits collection!");
-
-        // Put Cluster collection into event.
-        int flag = 1 << LCIOConstants.CLBIT_HITS;
-        event.put(clusterCollectionName, createClusters(hits), Cluster.class, flag);
-    }
-
-    public List<Cluster> createClusters(List<CalorimeterHit> hits) {
-        // Hit map.
-        Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>();
-
-        // Make a hit map for quick lookup by ID.
-        for (CalorimeterHit hit : hits) {
-            hitMap.put(hit.getCellID(), hit);
-        }
-
-        return createClusters(hitMap);
-    }
-
-    public List<Cluster> createClusters(Map<Long, CalorimeterHit> map) {
-
-        // New Cluster list to be added to event.
-        List<Cluster> clusters = new ArrayList<Cluster>();
-
-        Collection<CalorimeterHit> hits = map.values();
-
-        // Loop over ECal hits to find cluster seeds.
-        for (CalorimeterHit hit : hits) {
-            // Cut on min seed E.
-            if (hit.getRawEnergy() < seedEMin)
-                continue;
-
-            // Get neighbor crystal IDs.
-            Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
-            if (neighbors == null)
-                throw new RuntimeException("Oops!  Set of neighbors is null!");
-
-            // List for neighboring hits.
-            List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>();
-
-            // Loop over neighbors to make hit list for cluster.
-            boolean isSeed = true;
-            for (Long neighborId : neighbors) {
-                // Find the neighbor hit in the event if it exists.
-                CalorimeterHit neighborHit = map.get(neighborId);
-
-                // Was this neighbor cell hit?
-                if (neighborHit != null) {
-                    // Check if neighbor cell has more energy.
-                    if (neighborHit.getRawEnergy() > hit.getRawEnergy()) {
-                        // Neighbor has more energy, so cell is not a seed.
-                        isSeed = false;
-                        break;
-                    }
-
-                    // Add to cluster if above min E.
-                    if (neighborHit.getRawEnergy() >= addEMin) {
-                        neighborHits.add(neighborHit);
-                    }
-                }
-            }
-
-            // Did we find a seed?
-            if (isSeed) {
-                // Make a cluster from the hit list.
-                HPSEcalCluster cluster = new HPSEcalCluster(hit);
-                for (CalorimeterHit clusHit : neighborHits) {
-                    cluster.addHit(clusHit);
-                }
-                clusters.add(cluster);
-            }
-        }
-        return clusters;
-    }
+	HPSEcal3 ecal;
+	String ecalCollectionName;
+	String ecalName;
+	String clusterCollectionName = "EcalClusters";
+	// Minimum E for cluster seed.
+	double seedEMin = .05;
+	// Minimum E to add hit to cluster.
+	double addEMin = .03;
+	// Odd or even number of crystals in X.
+	boolean oddX;
+	// Map of crystals to their neighbors.
+	NeighborMap neighborMap = null;
+
+	public HPSEcalClusterer() {
+	}
+
+	public void setClusterCollectionName(String clusterCollectionName) {
+		this.clusterCollectionName = clusterCollectionName;
+	}
+
+	public void setSeedEMin(double seedEMin) {
+		this.seedEMin = seedEMin;
+	}
+
+	public void setAddEMin(double addEMin) {
+		this.addEMin = addEMin;
+	}
+
+	public void setEcalCollectionName(String ecalCollectionName) {
+		this.ecalCollectionName = ecalCollectionName;
+	}
+
+	public void setEcalName(String ecalName) {
+		this.ecalName = ecalName;
+	}
+
+	public void startOfData() {
+		if (ecalCollectionName == null)
+			throw new RuntimeException("The parameter ecalCollectionName was not set!");
+
+		if (ecalName == null)
+			throw new RuntimeException("The parameter ecalName was not set!");
+	}
+
+	public void detectorChanged(Detector detector) {
+		// Get the Subdetector.
+		ecal = (HPSEcal3) detector.getSubdetector(ecalName);
+
+		// Cache ref to neighbor map.
+		neighborMap = ecal.getNeighborMap();
+
+		//System.out.println(ecal.getName());
+		//System.out.println("  nx="+ecal.nx());
+		//System.out.println("  ny="+ecal.ny());
+		//System.out.println("  beamgap="+ecal.beamGap());
+		//System.out.println("  dface="+ecal.distanceToFace());
+
+		//System.out.println(neighborMap.toString());
+	}
+
+	public void process(EventHeader event) {
+		//System.out.println(this.getClass().getCanonicalName() + " - process");
+
+		// Get the list of raw ECal hits.
+		List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
+		if (hits == null)
+			throw new RuntimeException("Event is missing ECal raw hits collection!");
+
+		// Hit map.
+		Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>();
+
+		// Make a hit map for quick lookup by ID.
+		for (CalorimeterHit hit : hits) {
+			hitMap.put(hit.getCellID(), hit);
+		}
+
+		// Put Cluster collection into event.
+		int flag = 1 << LCIOConstants.CLBIT_HITS;
+		event.put(clusterCollectionName, createClusters(hitMap), Cluster.class, flag);
+	}
+
+	public List<Cluster> createClusters(Map<Long, CalorimeterHit> map) {
+
+		// New Cluster list to be added to event.
+		List<Cluster> clusters = new ArrayList<Cluster>();
+
+		Collection<CalorimeterHit> hits = map.values();
+
+		// Loop over ECal hits to find cluster seeds.
+		for (CalorimeterHit hit : hits) {
+			// Cut on min seed E.
+			if (hit.getRawEnergy() < seedEMin)
+				continue;
+
+			// Get neighbor crystal IDs.
+			Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+			if (neighbors == null)
+				throw new RuntimeException("Oops!  Set of neighbors is null!");
+
+			// List for neighboring hits.
+			List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>();
+
+			// Loop over neighbors to make hit list for cluster.
+			boolean isSeed = true;
+			for (Long neighborId : neighbors) {
+				// Find the neighbor hit in the event if it exists.
+				CalorimeterHit neighborHit = map.get(neighborId);
+
+				// Was this neighbor cell hit?
+				if (neighborHit != null) {
+					// Check if neighbor cell has more energy.
+					if (neighborHit.getRawEnergy() > hit.getRawEnergy()) {
+						// Neighbor has more energy, so cell is not a seed.
+						isSeed = false;
+						break;
+					}
+
+					// Add to cluster if above min E.
+					if (neighborHit.getRawEnergy() >= addEMin) {
+						neighborHits.add(neighborHit);
+					}
+				}
+			}
+
+			// Did we find a seed?
+			if (isSeed) {
+				// Make a cluster from the hit list.
+				HPSEcalCluster cluster = new HPSEcalCluster(hit);
+				for (CalorimeterHit clusHit : neighborHits) {
+					cluster.addHit(clusHit);
+				}
+				clusters.add(cluster);
+			}
+		}
+		return clusters;
+	}
 }
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcalFlashTrigger.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- HPSEcalFlashTrigger.java	11 Oct 2011 17:07:12 -0000	1.3
+++ HPSEcalFlashTrigger.java	17 Nov 2011 01:43:26 -0000	1.4
@@ -16,7 +16,7 @@
  * Heavy Photon Search ECal Flash Trigger
  *
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSEcalFlashTrigger.java,v 1.3 2011/10/11 17:07:12 omoreno Exp $
+ * @version $Id: HPSEcalFlashTrigger.java,v 1.4 2011/11/17 01:43:26 meeg Exp $
  */
 public class HPSEcalFlashTrigger extends Driver
 {
@@ -129,7 +129,7 @@
 
         System.out.println( "Total Number of Triggers: " + nTriggers );
         System.out.println( "The Trigger Rate: "
-            + (( double ) (nTriggers/totalEvents))*100. +  "%" );
+            + ( (( double )nTriggers/( double )totalEvents))*100. +  "%" );
     }
 
     /**

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcalCluster.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HPSEcalCluster.java	30 Sep 2011 23:31:27 -0000	1.2
+++ HPSEcalCluster.java	17 Nov 2011 01:43:26 -0000	1.3
@@ -11,7 +11,7 @@
 /**
  * Cluster with position defined by seed hit (for 1-bit trigger)
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalCluster.java,v 1.2 2011/09/30 23:31:27 meeg Exp $
+ * @version $Id: HPSEcalCluster.java,v 1.3 2011/11/17 01:43:26 meeg Exp $
  */
 public class HPSEcalCluster extends BasicCluster {
     CalorimeterHit seedHit = null;
@@ -24,6 +24,7 @@
     public HPSEcalCluster(CalorimeterHit seedHit) {
         this.seedHit = seedHit;
         this.cellID = seedHit.getCellID();
+		this.addHit(seedHit);
     }
 
     public CalorimeterHit getSeedHit() {

hps-java/src/main/resources/org/lcsim/hps/steering
ecal_1bit_bkgd.lcsim 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- ecal_1bit_bkgd.lcsim	21 Oct 2011 19:54:08 -0000	1.4
+++ ecal_1bit_bkgd.lcsim	17 Nov 2011 01:43:27 -0000	1.5
@@ -1,70 +1,70 @@
 <!--
     Example LCSim steering file to run simple HPS ECal clustering and analysis.
     @author Sho Uemura <[log in to unmask]>
-    @version $Id: ecal_1bit_bkgd.lcsim,v 1.4 2011/10/21 19:54:08 meeg Exp $
+    @version $Id: ecal_1bit_bkgd.lcsim,v 1.5 2011/11/17 01:43:27 meeg Exp $
 
 -->
 <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
-    <inputFiles>
-        <file>${inputFile}.slcio</file>
-    </inputFiles>
-    <control>
-        <numberOfEvents>-1</numberOfEvents>
-        <printInputFiles>true</printInputFiles>
-    </control>
-    <classpath>
-        <jar>~/.m2/repository/org/lcsim/hps-java/1.0-SNAPSHOT/hps-java-1.0-SNAPSHOT.jar</jar>
-    </classpath>
-    <execute>
-        <driver name="EventMarkerDriver"/>
-        <driver name="EcalReadout"/>
-        <driver name="EcalClusterer"/>
-        <driver name="EcalTrigger"/>
-        <driver name="EcalPlots"/>
-        <driver name="Writer"/>
-        <driver name="AidaSaveDriver"/>
-        <driver name="ClockDriver"/>
-    </execute>
-    <drivers>
-        <driver name="Writer"
+	<inputFiles>
+		<file>${inputFile}.slcio</file>
+	</inputFiles>
+	<control>
+		<numberOfEvents>-1</numberOfEvents>
+		<printInputFiles>true</printInputFiles>
+	</control>
+	<classpath>
+		<jar>~/.m2/repository/org/lcsim/hps-java/1.0-SNAPSHOT/hps-java-1.0-SNAPSHOT.jar</jar>
+	</classpath>
+	<execute>
+		<driver name="EventMarkerDriver"/>
+		<driver name="EcalReadout"/>
+		<driver name="EcalClusterer"/>
+		<driver name="EcalTrigger"/>
+		<driver name="EcalPlots"/>
+		<driver name="Writer"/>
+		<driver name="AidaSaveDriver"/>
+		<driver name="ClockDriver"/>
+	</execute>
+	<drivers>
+		<driver name="Writer"
                 type="org.lcsim.util.loop.LCIODriver">
-            <outputFilePath>${inputFile}_ecalClusters</outputFilePath>
-        </driver>
-        <driver name="EcalReadout"
+			<outputFilePath>${inputFile}_ecalClusters</outputFilePath>
+		</driver>
+		<driver name="EcalReadout"
                 type="org.lcsim.hps.recon.ecal.HPSEcalDiscriminatorReadoutDriver">
-            <readoutPeriod>15.0</readoutPeriod>
-            <ecalName>Ecal</ecalName>
-            <ecalCollectionName>EcalHits</ecalCollectionName>
-            <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName>
-            <threshold>0.2</threshold>
-        </driver>
-        <driver name="EcalClusterer"
+			<readoutPeriod>15.0</readoutPeriod>
+			<ecalName>Ecal</ecalName>
+			<ecalCollectionName>EcalHits</ecalCollectionName>
+			<ecalRawCollectionName>EcalRawHits</ecalRawCollectionName>
+			<threshold>0.2</threshold>
+		</driver>
+		<driver name="EcalClusterer"
                 type="org.lcsim.hps.recon.ecal.HPSEcal1BitClusterer">
-            <clusterThreshold>0</clusterThreshold>
-            <ecalName>Ecal</ecalName>
-            <ecalCollectionName>EcalRawHits</ecalCollectionName>
-        </driver>
-        <driver name="EcalTrigger"
-                type="org.lcsim.hps.recon.ecal.HPSTriggerDriver">
-            <clusterCollectionName>EcalClusters</clusterCollectionName>
-            <outputFileName>${inputFile}_triggers</outputFileName>
-            <ecalName>Ecal</ecalName>
-        </driver>
-        <driver name="EcalPlots"
+			<clusterThreshold>0</clusterThreshold>
+			<ecalName>Ecal</ecalName>
+			<ecalCollectionName>EcalRawHits</ecalCollectionName>
+		</driver>
+		<driver name="EcalTrigger"
+                type="org.lcsim.hps.recon.ecal.HPS1BitTriggerDriver">
+			<clusterCollectionName>EcalClusters</clusterCollectionName>
+			<outputFileName>${inputFile}_triggers</outputFileName>
+			<ecalName>Ecal</ecalName>
+		</driver>
+		<driver name="EcalPlots"
                 type="org.lcsim.hps.analysis.ecal.HPSEcalPlotsDriver">
-            <ecalCollectionName>EcalRawHits</ecalCollectionName>
-        </driver>
-        <driver name="EventMarkerDriver"
+			<ecalCollectionName>EcalRawHits</ecalCollectionName>
+		</driver>
+		<driver name="EventMarkerDriver"
                 type="org.lcsim.job.EventMarkerDriver">
-            <eventInterval>100</eventInterval>
-        </driver>
-        <driver name="AidaSaveDriver"
+			<eventInterval>100</eventInterval>
+		</driver>
+		<driver name="AidaSaveDriver"
                 type="org.lcsim.job.AidaSaveDriver">
-            <outputFileName>${inputFile}_ecalPlots</outputFileName>
-        </driver>
-        <driver name="ClockDriver"
+			<outputFileName>${inputFile}_ecalPlots</outputFileName>
+		</driver>
+		<driver name="ClockDriver"
                 type="org.lcsim.hps.util.ClockDriver">
-        </driver>
-    </drivers>
+		</driver>
+	</drivers>
 </lcsim>

hps-java/src/main/resources/org/lcsim/hps/steering
ecal_1bit_ap.lcsim 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- ecal_1bit_ap.lcsim	21 Oct 2011 19:54:08 -0000	1.3
+++ ecal_1bit_ap.lcsim	17 Nov 2011 01:43:27 -0000	1.4
@@ -1,69 +1,69 @@
 <!--
     Example LCSim steering file to run simple HPS ECal clustering and analysis.
     @author Sho Uemura <[log in to unmask]>
-    @version $Id: ecal_1bit_ap.lcsim,v 1.3 2011/10/21 19:54:08 meeg Exp $
+    @version $Id: ecal_1bit_ap.lcsim,v 1.4 2011/11/17 01:43:27 meeg Exp $
 -->
 <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
-    <inputFiles>
-        <file>${inputFile}.slcio</file>
-    </inputFiles>
-    <control>
-        <numberOfEvents>-1</numberOfEvents>
-        <printInputFiles>true</printInputFiles>
-    </control>
-    <classpath>
-        <jar>~/.m2/repository/org/lcsim/hps-java/1.0-SNAPSHOT/hps-java-1.0-SNAPSHOT.jar</jar>
-    </classpath>
-    <execute>
-        <driver name="EventMarkerDriver"/>
-        <driver name="EcalReadout"/>
-        <driver name="EcalClusterer"/>
-        <driver name="EcalTrigger"/>
-        <driver name="EcalPlots"/>
-        <driver name="Writer"/>
-        <driver name="AidaSaveDriver"/>
-        <driver name="ClockDriver"/>
-    </execute>
-    <drivers>
-        <driver name="Writer"
+	<inputFiles>
+		<file>${inputFile}.slcio</file>
+	</inputFiles>
+	<control>
+		<numberOfEvents>-1</numberOfEvents>
+		<printInputFiles>true</printInputFiles>
+	</control>
+	<classpath>
+		<jar>~/.m2/repository/org/lcsim/hps-java/1.0-SNAPSHOT/hps-java-1.0-SNAPSHOT.jar</jar>
+	</classpath>
+	<execute>
+		<driver name="EventMarkerDriver"/>
+		<driver name="EcalReadout"/>
+		<driver name="EcalClusterer"/>
+		<driver name="EcalTrigger"/>
+		<driver name="EcalPlots"/>
+		<driver name="Writer"/>
+		<driver name="AidaSaveDriver"/>
+		<driver name="ClockDriver"/>
+	</execute>
+	<drivers>
+		<driver name="Writer"
                 type="org.lcsim.util.loop.LCIODriver">
-            <outputFilePath>${inputFile}_ecalClusters</outputFilePath>
-        </driver>
-        <driver name="EcalReadout"
+			<outputFilePath>${inputFile}_ecalClusters</outputFilePath>
+		</driver>
+		<driver name="EcalReadout"
                 type="org.lcsim.hps.recon.ecal.HPSEcalSimpleReadoutDriver">
-            <readoutCycle>1</readoutCycle>
-            <ecalName>Ecal</ecalName>
-            <ecalCollectionName>EcalHits</ecalCollectionName>
-            <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName>
-            <threshold>0.2</threshold>
-        </driver>
-        <driver name="EcalClusterer"
+			<readoutCycle>1</readoutCycle>
+			<ecalName>Ecal</ecalName>
+			<ecalCollectionName>EcalHits</ecalCollectionName>
+			<ecalRawCollectionName>EcalRawHits</ecalRawCollectionName>
+			<threshold>0.2</threshold>
+		</driver>
+		<driver name="EcalClusterer"
                 type="org.lcsim.hps.recon.ecal.HPSEcal1BitClusterer">
-            <clusterThreshold>0</clusterThreshold>
-            <ecalName>Ecal</ecalName>
-            <ecalCollectionName>EcalRawHits</ecalCollectionName>
-        </driver>
-        <driver name="EcalTrigger"
-                type="org.lcsim.hps.recon.ecal.HPSTriggerDriver">
-            <clusterCollectionName>EcalClusters</clusterCollectionName>
-            <outputFileName>${inputFile}_triggers</outputFileName>
-            <ecalName>Ecal</ecalName>
-        </driver>
-        <driver name="EcalPlots"
+			<clusterThreshold>0</clusterThreshold>
+			<ecalName>Ecal</ecalName>
+			<ecalCollectionName>EcalRawHits</ecalCollectionName>
+		</driver>
+		<driver name="EcalTrigger"
+                type="org.lcsim.hps.recon.ecal.HPS1BitTriggerDriver">
+			<clusterCollectionName>EcalClusters</clusterCollectionName>
+			<outputFileName>${inputFile}_triggers</outputFileName>
+			<ecalName>Ecal</ecalName>
+		</driver>
+		<driver name="EcalPlots"
                 type="org.lcsim.hps.analysis.ecal.HPSEcalPlotsDriver">
-            <ecalCollectionName>EcalRawHits</ecalCollectionName>
-        </driver>
-        <driver name="EventMarkerDriver"
+			<ecalCollectionName>EcalRawHits</ecalCollectionName>
+		</driver>
+		<driver name="EventMarkerDriver"
                 type="org.lcsim.job.EventMarkerDriver">
-            <eventInterval>100</eventInterval>
-        </driver>
-        <driver name="AidaSaveDriver"
+			<eventInterval>100</eventInterval>
+		</driver>
+		<driver name="AidaSaveDriver"
                 type="org.lcsim.job.AidaSaveDriver">
-            <outputFileName>${inputFile}_ecalPlots</outputFileName>
-        </driver>
-        <driver name="ClockDriver"
+			<outputFileName>${inputFile}_ecalPlots</outputFileName>
+		</driver>
+		<driver name="ClockDriver"
                 type="org.lcsim.hps.util.ClockDriver">
-        </driver>
-    </drivers>
+		</driver>
+	</drivers>
 </lcsim>
CVSspam 0.2.8