GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.2 -r1.3
--- HPSEcal.java 17 May 2011 23:10:46 -0000 1.2
+++ HPSEcal.java 25 May 2011 20:55:09 -0000 1.3
@@ -1,7 +1,9 @@
package org.lcsim.geometry.subdetector;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.jdom.Element;
@@ -10,7 +12,9 @@
import org.lcsim.geometry.util.IDEncoder;
/**
- * @author jeremym
+ * Reconstruction version of HPS ECal with crystal array.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
*/
public class HPSEcal extends AbstractSubdetector
{
@@ -19,6 +23,7 @@
private double beamgap;
private double dface;
private boolean oddX;
+ private HashMap<Long,Set<Long>> neighborsMap = null;
HPSEcal(Element node) throws JDOMException
{
@@ -255,4 +260,46 @@
{
return ny;
}
+
+ /**
+ * Create a map of crystal IDs to the <code>Set</code> of neighbor crystal IDs.
+ * @return A map of neighbors for each crystal ID.
+ */
+ public Map<Long,Set<Long>> makeNeighborsMap()
+ {
+ Map<Long,Set<Long>> neighborsMap = new HashMap<Long,Set<Long>>();
+
+ IDDecoder dec = getIDDecoder();
+ IDEncoder enc = new IDEncoder(dec.getIDDescription());
+
+ int nfields = dec.getFieldCount();
+ int[] vals = new int[nfields];
+
+ vals[dec.getFieldIndex("system")] = getSystemID();
+
+ int idxx = dec.getFieldIndex("ix");
+ int idxy = dec.getFieldIndex("iy");
+
+ for (int side=-1; side <=1; side++)
+ {
+ vals[dec.getFieldIndex("side")] = side;
+ if (side == 0) continue;
+ for (int iy=1; iy<=ny; iy++)
+ {
+ for (int ix=0; ix<=nx; ix++)
+ {
+ vals[idxx] = ix;
+ vals[idxy] = iy;
+
+ Long id = enc.setValues(vals);
+
+ Set<Long> neighbors = getNeighbors(id);
+
+ neighborsMap.put(id, neighbors);
+ }
+ }
+ }
+
+ return neighborsMap;
+ }
}
\ No newline at end of file