Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/ecal on MAIN
HPSEcal1BitClusterVetoClusterer.java+47-481.2 -> 1.3
HPSEcal1BitClusterer.java+312-3161.18 -> 1.19
HPSEcal1BitEventVetoClusterer.java+44-451.2 -> 1.3
+403-409
3 modified files
crystals can now be turned off in steering file

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcal1BitClusterVetoClusterer.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HPSEcal1BitClusterVetoClusterer.java	21 Oct 2011 19:54:08 -0000	1.2
+++ HPSEcal1BitClusterVetoClusterer.java	21 Oct 2011 20:32:15 -0000	1.3
@@ -14,66 +14,65 @@
  * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc.
  *
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcal1BitClusterVetoClusterer.java,v 1.2 2011/10/21 19:54:08 meeg Exp $
+ * @version $Id: HPSEcal1BitClusterVetoClusterer.java,v 1.3 2011/10/21 20:32:15 meeg Exp $
  */
 public class HPSEcal1BitClusterVetoClusterer extends HPSEcal1BitClusterer {
 
-    public HPSEcal1BitClusterVetoClusterer() {
-    }
+	public HPSEcal1BitClusterVetoClusterer() {
+	}
+
+	public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
+		// Hit map.
+		hitMap = new HashMap<Long, CalorimeterHit>();
+
+		hitCounts = new HashMap<Long, Integer>();
+		// Loop over ECal hits to count hit towers
+		for (CalorimeterHit hit : hits) {
+			dec.setID(hit.getCellID());
+			int ix = dec.getValue("ix");
+			if (ix >= xMin && ix <= xMax)
+				continue;
+
+			// Make a hit map for quick lookup by ID.
+			hitMap.put(hit.getCellID(), hit);
 
-    public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
-        // Hit map.
-        hitMap = new HashMap<Long, CalorimeterHit>();
-
-	hitCounts = new HashMap<Long, Integer>();
-        // Loop over ECal hits to count hit towers
-        for (CalorimeterHit hit : hits) {
-		dec.setID(hit.getCellID());
-		int ix = dec.getValue("ix");
-		int iy = dec.getValue("iy");
-		if (ix>0 && ix<=4/* && Math.abs(iy)<=2*/) continue;
-		if (ix<0 && ix>=-5/* && Math.abs(iy)<=2*/) continue;
-		//if (Math.abs(ix)<=2 && Math.abs(iy)<=2) continue;
-	   // Make a hit map for quick lookup by ID.
-            hitMap.put(hit.getCellID(), hit);
-
-            // Get neighbor crystal IDs.
-            Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
-            if (neighbors == null) {
-                throw new RuntimeException("Oops!  Set of neighbors is null!");
-            }
-
-            Integer hitCount = hitCounts.get(hit.getCellID());
-            if (hitCount == null)
-                hitCounts.put(hit.getCellID(), 1);
-            else
-                hitCounts.put(hit.getCellID(), hitCount + 1);
-
-            // Loop over neighbors to make hit list for cluster.
-            for (Long neighborId : neighbors) {
-                hitCount = hitCounts.get(neighborId);
-                if (hitCount == null)
-                    hitCounts.put(neighborId, 1);
-                else
-                    hitCounts.put(neighborId, hitCount + 1);
-            }
-        }
-	if (vetoHits!=null) {
-		for (CalorimeterHit hit : vetoHits) {
-			//Get neighbor crystal IDs.
+			// Get neighbor crystal IDs.
 			Set<Long> neighbors = neighborMap.get(hit.getCellID());
 
 			if (neighbors == null) {
 				throw new RuntimeException("Oops!  Set of neighbors is null!");
 			}
 
-			// Veto the hit towers for the vetoed crystal and all neighbors.
-			hitCounts.remove(hit.getCellID());
+			Integer hitCount = hitCounts.get(hit.getCellID());
+			if (hitCount == null)
+				hitCounts.put(hit.getCellID(), 1);
+			else
+				hitCounts.put(hit.getCellID(), hitCount + 1);
+
+			// Loop over neighbors to make hit list for cluster.
 			for (Long neighborId : neighbors) {
-				hitCounts.remove(neighborId);
+				hitCount = hitCounts.get(neighborId);
+				if (hitCount == null)
+					hitCounts.put(neighborId, 1);
+				else
+					hitCounts.put(neighborId, hitCount + 1);
+			}
+		}
+		if (vetoHits != null) {
+			for (CalorimeterHit hit : vetoHits) {
+				//Get neighbor crystal IDs.
+				Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+				if (neighbors == null) {
+					throw new RuntimeException("Oops!  Set of neighbors is null!");
+				}
+
+				// Veto the hit towers for the vetoed crystal and all neighbors.
+				hitCounts.remove(hit.getCellID());
+				for (Long neighborId : neighbors) {
+					hitCounts.remove(neighborId);
+				}
 			}
 		}
 	}
-    }
 }

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcal1BitClusterer.java 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- HPSEcal1BitClusterer.java	21 Oct 2011 19:54:08 -0000	1.18
+++ HPSEcal1BitClusterer.java	21 Oct 2011 20:32:16 -0000	1.19
@@ -1,7 +1,6 @@
 package org.lcsim.hps.recon.ecal;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -25,325 +24,322 @@
  * @author Jeremy McCormick <[log in to unmask]>
  * @author Tim Nelson <[log in to unmask]>
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcal1BitClusterer.java,v 1.18 2011/10/21 19:54:08 meeg Exp $
+ * @version $Id: HPSEcal1BitClusterer.java,v 1.19 2011/10/21 20:32:16 meeg Exp $
  */
 public class HPSEcal1BitClusterer extends Driver {
-    HPSEcal3 ecal;
+
+	HPSEcal3 ecal;
 	IDDecoder dec;
-    String ecalName;
-    String ecalCollectionName;
-    String vetoCollectionName;
-    String clusterCollectionName = "EcalClusters";
-    // Threshold E for discriminator.
-    //double hitEMin = .05;
-    //double hitEMax = 100.0;
-    Map<Long, Integer> hitCounts = null;
-    Map<Long, CalorimeterHit> hitMap = null;
-    // Threshold hit count for cluster. Cluster must have more than this many hits.
-    int clusterThreshold = 5;
-    // Map of crystals to their neighbors.
-    NeighborMap neighborMap = null;
-
-    public HPSEcal1BitClusterer() {
-    }
-
-    public void setClusterCollectionName(String clusterCollectionName) {
-        this.clusterCollectionName = clusterCollectionName;
-    }
-
-    public void setEcalCollectionName(String ecalCollectionName) {
-        this.ecalCollectionName = ecalCollectionName;
-    }
-
-    public void setVetoCollectionName(String vetoCollectionName) {
-        this.vetoCollectionName = vetoCollectionName;
-    }
-
-    /*
-    public void setHitEMin(double hitEMin) {
-        this.hitEMin = hitEMin;
-    }
-
-    public void setHitEMax(double hitEMax) {
-        this.hitEMax = hitEMax;
-    }
-    */
-
-    public void setClusterThreshold(int clusterThreshold) {
-        this.clusterThreshold = clusterThreshold;
-    }
-
-    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);
-
-        // Get the decoder for the ECal IDs.
-        dec = ecal.getIDDecoder();
-
-        // 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!");
-	List<CalorimeterHit> vetoHits = null;
-
-        // Get the list of raw ECal hits.
-	if (vetoCollectionName!=null) {
-		vetoHits = event.get(CalorimeterHit.class, vetoCollectionName);
-		if (vetoHits == null)
-		    throw new RuntimeException("Event is missing ECal veto hits collection!");
-	}
-
-	countHits(hits, vetoHits);
-
-        // Put Cluster collection into event.
-        int flag = 1 << LCIOConstants.CLBIT_HITS;
-        event.put(clusterCollectionName, createClusters(), Cluster.class, flag);
-    }
-
-    public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
-        // Hit map.
-        hitMap = new HashMap<Long, CalorimeterHit>();
-        HashMap<Long, CalorimeterHit> vetoMap = new HashMap<Long, CalorimeterHit>();
-
-	if (vetoHits!=null) {
-		for (CalorimeterHit hit : vetoHits) {
-		    vetoMap.put(hit.getCellID(), hit);
+	String ecalName;
+	String ecalCollectionName;
+	String vetoCollectionName;
+	String clusterCollectionName = "EcalClusters";
+	//set bounds for a range of crystals to turn off in the clusterer
+	int xMin = 0;
+	int xMax = 0;
+	Map<Long, Integer> hitCounts = null;
+	Map<Long, CalorimeterHit> hitMap = null;
+	// Threshold hit count for cluster. Cluster must have more than this many hits.
+	int clusterThreshold = 5;
+	// Map of crystals to their neighbors.
+	NeighborMap neighborMap = null;
+
+	public HPSEcal1BitClusterer() {
+	}
+
+	public void setClusterCollectionName(String clusterCollectionName) {
+		this.clusterCollectionName = clusterCollectionName;
+	}
+
+	public void setEcalCollectionName(String ecalCollectionName) {
+		this.ecalCollectionName = ecalCollectionName;
+	}
+
+	public void setVetoCollectionName(String vetoCollectionName) {
+		this.vetoCollectionName = vetoCollectionName;
+	}
+
+	public void setxMax(int xMax) {
+		this.xMax = xMax;
+	}
+
+	public void setxMin(int xMin) {
+		this.xMin = xMin;
+	}
+
+	public void setClusterThreshold(int clusterThreshold) {
+		this.clusterThreshold = clusterThreshold;
+	}
+
+	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);
+
+		// Get the decoder for the ECal IDs.
+		dec = ecal.getIDDecoder();
+
+		// 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!");
+		List<CalorimeterHit> vetoHits = null;
+
+		// Get the list of raw ECal hits.
+		if (vetoCollectionName != null) {
+			vetoHits = event.get(CalorimeterHit.class, vetoCollectionName);
+			if (vetoHits == null)
+				throw new RuntimeException("Event is missing ECal veto hits collection!");
+		}
+
+		countHits(hits, vetoHits);
+
+		// Put Cluster collection into event.
+		int flag = 1 << LCIOConstants.CLBIT_HITS;
+		event.put(clusterCollectionName, createClusters(), Cluster.class, flag);
 	}
 
-	hitCounts = new HashMap<Long, Integer>();
-        // Loop over ECal hits to count hit towers
-        for (CalorimeterHit hit : hits) {
-		if (vetoMap.get(hit.getCellID())!=null)
-			continue;
-
-		dec.setID(hit.getCellID());
-		int ix = dec.getValue("ix");
-		int iy = dec.getValue("iy");
-		if (ix>0 && ix<=4/* && Math.abs(iy)<=2*/) continue;
-		if (ix<0 && ix>=-5/* && Math.abs(iy)<=2*/) continue;
-		//if (Math.abs(ix)<=2 && Math.abs(iy)<=2) continue;
-
-	   // Make a hit map for quick lookup by ID.
-            hitMap.put(hit.getCellID(), hit);
-
-            // Get neighbor crystal IDs.
-            Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
-            if (neighbors == null) {
-                throw new RuntimeException("Oops!  Set of neighbors is null!");
-            }
-
-            Integer hitCount = hitCounts.get(hit.getCellID());
-            if (hitCount == null)
-                hitCounts.put(hit.getCellID(), 1);
-            else
-                hitCounts.put(hit.getCellID(), hitCount + 1);
-
-            // Loop over neighbors to make hit list for cluster.
-            for (Long neighborId : neighbors) {
-                hitCount = hitCounts.get(neighborId);
-                if (hitCount == null)
-                    hitCounts.put(neighborId, 1);
-                else
-                    hitCounts.put(neighborId, hitCount + 1);
-            }
-        }
-    }
-
-    public List<Cluster> createClusters() {
-        // New Cluster list to be added to event.
-        List<Cluster> clusters = new ArrayList<Cluster>();
-
-        //for each crystal with a nonzero hit count, test for cluster
-        for (Long possibleCluster : hitCounts.keySet()) {
-            //System.out.printf("%d, %d hits\n",possibleCluster,hitCounts.get(possibleCluster));
-            if (hitCounts.get(possibleCluster) <= clusterThreshold) {
-                continue;
-            }
-
-            // Get neighbor crystal IDs.
-            Set<Long> neighbors = neighborMap.get(possibleCluster);
-
-            if (neighbors == null) {
-                throw new RuntimeException("Oops!  Set of neighbors is null!");
-            }
-
-            //Apply peak detector scheme.
-            // Set the ID.
-            dec.setID(possibleCluster);
-            // Get ID field values.
-            int x1 = dec.getValue("ix");
-            int y1 = dec.getValue("iy");
-            Integer hitCount = hitCounts.get(possibleCluster);
-
-            //System.out.printf("Possible cluster: x: %d, y: %d, hits: %d\n",x1,y1,hitCount);
-            boolean isCluster = true;
-            for (Long neighborId : neighbors) {
-                // Set the ID.
-                dec.setID(neighborId);
-                Integer neighborHitCount = hitCounts.get(neighborId);
-                if (neighborHitCount == null)
-                    continue;
-                // Get ID field values.
-                int x2 = dec.getValue("ix");
-                int y2 = dec.getValue("iy");
-                if (y1 > 0) {
-                    if (x1 > 0) {
-                        //quadrant 1
-                        if (x1 == 1) {
-                            //special case: left edge of quadrant
-                            if (x1 > x2 && y1 < y2) {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            } else if (x1 > x2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else if (x1 < x2) {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            } else if (y1 < y2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            }
-                        } else {
-                            if (x1 > x2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else if (x1 < x2) {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            } else if (y1 < y2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            }
-                        }
-                    } else {
-                        //quadrant 2
-                        if (y1 > y2) {
-                            if (hitCount >= neighborHitCount)
-                                continue;
-                        } else if (y1 < y2) {
-                            if (hitCount > neighborHitCount)
-                                continue;
-                        } else if (x1 > x2) {
-                            if (hitCount >= neighborHitCount)
-                                continue;
-                        } else {
-                            if (hitCount > neighborHitCount)
-                                continue;
-                        }
-                    }
-                } else {
-                    if (x1 < 0) {
-                        //quadrant 3
-                        if (x1 == 1) {
-                            //special case: left edge of quadrant
-                            if (x1 < x2 && y1 > y2) {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            } else if (x1 < x2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else if (x1 > x2) {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            } else if (y1 > y2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            }
-                        } else {
-                            if (x1 < x2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else if (x1 > x2) {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            } else if (y1 > y2) {
-                                if (hitCount >= neighborHitCount)
-                                    continue;
-                            } else {
-                                if (hitCount > neighborHitCount)
-                                    continue;
-                            }
-                        }
-                    } else {
-                        //quadrant 4
-                        if (y1 < y2) {
-                            if (hitCount >= neighborHitCount)
-                                continue;
-                        } else if (y1 > y2) {
-                            if (hitCount > neighborHitCount)
-                                continue;
-                        } else if (x1 < x2) {
-                            if (hitCount >= neighborHitCount)
-                                continue;
-                        } else {
-                            if (hitCount > neighborHitCount)
-                                continue;
-                        }
-                    }
-                }
-                isCluster = false;
-                break;
-            }
-
-            if (isCluster) {
-                //System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount);
-                HPSEcalCluster cluster = new HPSEcalCluster(possibleCluster);
-                CalorimeterHit hit = hitMap.get(possibleCluster);
-                if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) {
-                    cluster.addHit(hit);
-                }
-
-                for (Long neighborId : neighbors) {
-                    // Find the neighbor hit in the event if it exists.
-                    hit = hitMap.get(neighborId);
-                    if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) {
-                        cluster.addHit(hit);
-                    }
-                }
-                clusters.add(cluster);
-            }
-        }
-        return clusters;
-    }
+	public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
+		// Hit map.
+		hitMap = new HashMap<Long, CalorimeterHit>();
+		HashMap<Long, CalorimeterHit> vetoMap = new HashMap<Long, CalorimeterHit>();
+
+		if (vetoHits != null) {
+			for (CalorimeterHit hit : vetoHits) {
+				vetoMap.put(hit.getCellID(), hit);
+			}
+		}
+
+		hitCounts = new HashMap<Long, Integer>();
+		// Loop over ECal hits to count hit towers
+		for (CalorimeterHit hit : hits) {
+			if (vetoMap.get(hit.getCellID()) != null)
+				continue;
+
+			dec.setID(hit.getCellID());
+			int ix = dec.getValue("ix");
+			if (ix >= xMin && ix <= xMax)
+				continue;
+
+			// Make a hit map for quick lookup by ID.
+			hitMap.put(hit.getCellID(), hit);
+
+			// Get neighbor crystal IDs.
+			Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+			if (neighbors == null) {
+				throw new RuntimeException("Oops!  Set of neighbors is null!");
+			}
+
+			Integer hitCount = hitCounts.get(hit.getCellID());
+			if (hitCount == null)
+				hitCounts.put(hit.getCellID(), 1);
+			else
+				hitCounts.put(hit.getCellID(), hitCount + 1);
+
+			// Loop over neighbors to make hit list for cluster.
+			for (Long neighborId : neighbors) {
+				hitCount = hitCounts.get(neighborId);
+				if (hitCount == null)
+					hitCounts.put(neighborId, 1);
+				else
+					hitCounts.put(neighborId, hitCount + 1);
+			}
+		}
+	}
+
+	public List<Cluster> createClusters() {
+		// New Cluster list to be added to event.
+		List<Cluster> clusters = new ArrayList<Cluster>();
+
+		//for each crystal with a nonzero hit count, test for cluster
+		for (Long possibleCluster : hitCounts.keySet()) {
+			//System.out.printf("%d, %d hits\n",possibleCluster,hitCounts.get(possibleCluster));
+			if (hitCounts.get(possibleCluster) <= clusterThreshold) {
+				continue;
+			}
+
+			// Get neighbor crystal IDs.
+			Set<Long> neighbors = neighborMap.get(possibleCluster);
+
+			if (neighbors == null) {
+				throw new RuntimeException("Oops!  Set of neighbors is null!");
+			}
+
+			//Apply peak detector scheme.
+			// Set the ID.
+			dec.setID(possibleCluster);
+			// Get ID field values.
+			int x1 = dec.getValue("ix");
+			int y1 = dec.getValue("iy");
+			Integer hitCount = hitCounts.get(possibleCluster);
+
+			//System.out.printf("Possible cluster: x: %d, y: %d, hits: %d\n",x1,y1,hitCount);
+			boolean isCluster = true;
+			for (Long neighborId : neighbors) {
+				// Set the ID.
+				dec.setID(neighborId);
+				Integer neighborHitCount = hitCounts.get(neighborId);
+				if (neighborHitCount == null)
+					continue;
+				// Get ID field values.
+				int x2 = dec.getValue("ix");
+				int y2 = dec.getValue("iy");
+				if (y1 > 0) {
+					if (x1 > 0) {
+						//quadrant 1
+						if (x1 == 1) {
+							//special case: left edge of quadrant
+							if (x1 > x2 && y1 < y2) {
+								if (hitCount > neighborHitCount)
+									continue;
+							} else if (x1 > x2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else if (x1 < x2) {
+								if (hitCount > neighborHitCount)
+									continue;
+							} else if (y1 < y2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else {
+								if (hitCount > neighborHitCount)
+									continue;
+							}
+						} else {
+							if (x1 > x2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else if (x1 < x2) {
+								if (hitCount > neighborHitCount)
+									continue;
+							} else if (y1 < y2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else {
+								if (hitCount > neighborHitCount)
+									continue;
+							}
+						}
+					} else {
+						//quadrant 2
+						if (y1 > y2) {
+							if (hitCount >= neighborHitCount)
+								continue;
+						} else if (y1 < y2) {
+							if (hitCount > neighborHitCount)
+								continue;
+						} else if (x1 > x2) {
+							if (hitCount >= neighborHitCount)
+								continue;
+						} else {
+							if (hitCount > neighborHitCount)
+								continue;
+						}
+					}
+				} else {
+					if (x1 < 0) {
+						//quadrant 3
+						if (x1 == 1) {
+							//special case: left edge of quadrant
+							if (x1 < x2 && y1 > y2) {
+								if (hitCount > neighborHitCount)
+									continue;
+							} else if (x1 < x2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else if (x1 > x2) {
+								if (hitCount > neighborHitCount)
+									continue;
+							} else if (y1 > y2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else {
+								if (hitCount > neighborHitCount)
+									continue;
+							}
+						} else {
+							if (x1 < x2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else if (x1 > x2) {
+								if (hitCount > neighborHitCount)
+									continue;
+							} else if (y1 > y2) {
+								if (hitCount >= neighborHitCount)
+									continue;
+							} else {
+								if (hitCount > neighborHitCount)
+									continue;
+							}
+						}
+					} else {
+						//quadrant 4
+						if (y1 < y2) {
+							if (hitCount >= neighborHitCount)
+								continue;
+						} else if (y1 > y2) {
+							if (hitCount > neighborHitCount)
+								continue;
+						} else if (x1 < x2) {
+							if (hitCount >= neighborHitCount)
+								continue;
+						} else {
+							if (hitCount > neighborHitCount)
+								continue;
+						}
+					}
+				}
+				isCluster = false;
+				break;
+			}
+
+			if (isCluster) {
+				//System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount);
+				HPSEcalCluster cluster = new HPSEcalCluster(possibleCluster);
+				CalorimeterHit hit = hitMap.get(possibleCluster);
+				if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) {
+					cluster.addHit(hit);
+				}
+
+				for (Long neighborId : neighbors) {
+					// Find the neighbor hit in the event if it exists.
+					hit = hitMap.get(neighborId);
+					if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) {
+						cluster.addHit(hit);
+					}
+				}
+				clusters.add(cluster);
+			}
+		}
+		return clusters;
+	}
 }

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcal1BitEventVetoClusterer.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HPSEcal1BitEventVetoClusterer.java	21 Oct 2011 19:54:08 -0000	1.2
+++ HPSEcal1BitEventVetoClusterer.java	21 Oct 2011 20:32:16 -0000	1.3
@@ -14,53 +14,52 @@
  * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc.
  *
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcal1BitEventVetoClusterer.java,v 1.2 2011/10/21 19:54:08 meeg Exp $
+ * @version $Id: HPSEcal1BitEventVetoClusterer.java,v 1.3 2011/10/21 20:32:16 meeg Exp $
  */
 public class HPSEcal1BitEventVetoClusterer extends HPSEcal1BitClusterer {
 
-    public HPSEcal1BitEventVetoClusterer() {
-    }
+	public HPSEcal1BitEventVetoClusterer() {
+	}
 
-    public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
-        // Hit map.
-        hitMap = new HashMap<Long, CalorimeterHit>();
-
-	hitCounts = new HashMap<Long, Integer>();
-	if (vetoHits!=null && !vetoHits.isEmpty()) return;
-
-        // Loop over ECal hits to count hit towers
-        for (CalorimeterHit hit : hits) {
-		dec.setID(hit.getCellID());
-		int ix = dec.getValue("ix");
-		int iy = dec.getValue("iy");
-		if (ix>0 && ix<=4/* && Math.abs(iy)<=2*/) continue;
-		if (ix<0 && ix>=-5/* && Math.abs(iy)<=2*/) continue;
-		//if (Math.abs(ix)<=2 && Math.abs(iy)<=2) continue;
-
-		// Make a hit map for quick lookup by ID.
-            hitMap.put(hit.getCellID(), hit);
-
-            // Get neighbor crystal IDs.
-            Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
-            if (neighbors == null) {
-                throw new RuntimeException("Oops!  Set of neighbors is null!");
-            }
-
-            Integer hitCount = hitCounts.get(hit.getCellID());
-            if (hitCount == null)
-                hitCounts.put(hit.getCellID(), 1);
-            else
-                hitCounts.put(hit.getCellID(), hitCount + 1);
-
-            // Loop over neighbors to make hit list for cluster.
-            for (Long neighborId : neighbors) {
-                hitCount = hitCounts.get(neighborId);
-                if (hitCount == null)
-                    hitCounts.put(neighborId, 1);
-                else
-                    hitCounts.put(neighborId, hitCount + 1);
-            }
-        }
-    }
+	public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
+		// Hit map.
+		hitMap = new HashMap<Long, CalorimeterHit>();
+
+		hitCounts = new HashMap<Long, Integer>();
+		if (vetoHits != null && !vetoHits.isEmpty())
+			return;
+
+		// Loop over ECal hits to count hit towers
+		for (CalorimeterHit hit : hits) {
+			dec.setID(hit.getCellID());
+			int ix = dec.getValue("ix");
+			if (ix >= xMin && ix <= xMax)
+				continue;
+
+			// Make a hit map for quick lookup by ID.
+			hitMap.put(hit.getCellID(), hit);
+
+			// Get neighbor crystal IDs.
+			Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+			if (neighbors == null) {
+				throw new RuntimeException("Oops!  Set of neighbors is null!");
+			}
+
+			Integer hitCount = hitCounts.get(hit.getCellID());
+			if (hitCount == null)
+				hitCounts.put(hit.getCellID(), 1);
+			else
+				hitCounts.put(hit.getCellID(), hitCount + 1);
+
+			// Loop over neighbors to make hit list for cluster.
+			for (Long neighborId : neighbors) {
+				hitCount = hitCounts.get(neighborId);
+				if (hitCount == null)
+					hitCounts.put(neighborId, 1);
+				else
+					hitCounts.put(neighborId, hitCount + 1);
+			}
+		}
+	}
 }
CVSspam 0.2.8