hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.4 -r1.5
--- HPSEcalClusterer.java 24 May 2011 19:31:04 -0000 1.4
+++ HPSEcalClusterer.java 25 May 2011 20:55:36 -0000 1.5
@@ -12,7 +12,6 @@
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.IDDecoder;
import org.lcsim.geometry.subdetector.HPSEcal;
-import org.lcsim.geometry.subdetector.HPSEcal.XYSide;
import org.lcsim.geometry.util.IDEncoder;
import org.lcsim.recon.cluster.util.BasicCluster;
import org.lcsim.util.Driver;
@@ -24,7 +23,7 @@
* Clustering algorithm is from pages 83 and 84 of the HPS Proposal.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: HPSEcalClusterer.java,v 1.4 2011/05/24 19:31:04 jeremy Exp $
+ * @version $Id: HPSEcalClusterer.java,v 1.5 2011/05/25 20:55:36 jeremy Exp $
*/
public class HPSEcalClusterer extends Driver
{
@@ -43,6 +42,8 @@
// Odd or even number of crystals in X.
boolean oddX;
+ Map<Long,Set<Long>> neighborsMap = null;
+
public HPSEcalClusterer()
{}
@@ -88,6 +89,8 @@
public void detectorChanged(Detector detector)
{
ecal = (HPSEcal)detector.getSubdetector(ecalName);
+
+ neighborsMap = ecal.makeNeighborsMap();
System.out.println(ecal.getName());
System.out.println(" nx="+ecal.nx());
@@ -113,10 +116,7 @@
dec.setID(hit.getCellID());
hitMap.put(hit.getCellID(), hit);
}
-
- // Setup an encoder from the decoder.
- IDEncoder enc = new IDEncoder(dec.getIDDescription());
-
+
// Cluster list to be added to event.
List<Cluster> clusters = new ArrayList<Cluster>();
@@ -127,35 +127,15 @@
if (hit.getRawEnergy() < seedEMin)
continue;
- // Set decoder's ID.
- dec.setID(hit.getCellID());
-
- // Get ID values.
- int ix = dec.getValue("ix");
- int iy = dec.getValue("iy");
- int side = dec.getValue("side");
-
- // Get neighboring crystals to hit.
- Set<XYSide> neighbors = ecal.getNeighbors(ix, iy, side);
-
- //System.out.println("neighbors of " + ix + ", " + iy + ", " + side);
-
- int[] buffer = new int[dec.getFieldCount()];
- dec.getValues(buffer);
-
+ // Get neighbor crystal IDs.
+ Set<Long> neighbors = ecal.getNeighbors(hit.getCellID());
+
// Loop over neighbors.
List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>();
+
boolean isSeed = true;
- for (XYSide neighbor : neighbors)
- {
- buffer[dec.getFieldIndex("ix")] = neighbor.x();
- buffer[dec.getFieldIndex("iy")] = neighbor.y();
- buffer[dec.getFieldIndex("side")] = neighbor.side();
-
- // Create ID for this crystal.
- // FIXME This is redundant and inefficient.
- long neighborId = enc.setValues(buffer);
-
+ for (Long neighborId : neighbors)
+ {
// Find neighbor hit if it exists.
CalorimeterHit neighborHit = hitMap.get(neighborId);
@@ -174,7 +154,8 @@
neighborHits.add(neighborHit);
}
}
-
+
+ // Did we find a seed?
if (isSeed)
{
// Make cluster.