lcsim/src/org/lcsim/recon/cluster/nn
diff -u -r1.10 -r1.11
--- NearestNeighborCluster.java 19 Oct 2005 10:34:38 -0000 1.10
+++ NearestNeighborCluster.java 1 Jul 2006 21:56:52 -0000 1.11
@@ -9,73 +9,13 @@
/**
* Represents a cluster composed of calorimeter hits contiguous within the specified domain.
* @author Norman A. Graf with additions of threshold code by Eric J. Benavidez ([log in to unmask])
- * @version $Id: NearestNeighborCluster.java,v 1.10 2005/10/19 10:34:38 jstrube Exp $
+ * @version $Id: NearestNeighborCluster.java,v 1.11 2006/07/01 21:56:52 cassell Exp $
*/
public class NearestNeighborCluster extends BasicCluster
{
/**
* Construct a NearestNeighborCluster. Note that the constructor actually performs the
* clustering, given a seed hit.
- * @param decoder The CellID decoder appropriate for this collection of hits.
- * @param hitmap The list of hit calorimeter cells available for clustering.
- * This map will be zeroed on exit.
- * @param hit The seed calorimeter hit for this cluster.
- * @param key The key for the seed calorimeter hit.
- * @param threshold The energy threshold that must be met or exceeded in order
- * to be considered in the cluster.
- */
-
- public NearestNeighborCluster(CalorimeterIDDecoder decoder, Map<Long, CalorimeterHit> hitmap, CalorimeterHit hit, Long key, int dU, int dV, int dLayer, double threshold)
- {
- // start by adding this hit to the cluster
- addHit(hit);
-
- // set the decoder to this hit
- decoder.setID(key);
- // remove this hit from the map so it can't be used again
- hitmap.remove(key);
-
- // loop over the hits in the cluster and add all its neighbors
- // note that hits.size() grows as we add cells
- for(int i=0; i<hits.size(); ++i)
- {
- CalorimeterHit c = hits.get(i);
- decoder.setID(c.getCellID());
-
- long[] neighbors = decoder.getNeighbourIDs(dLayer, dU, dV);
- // loop over all neighboring cell Ids
- for (int j=0; j<neighbors.length; ++j)
- {
- CalorimeterHit h = hitmap.get(neighbors[j]);
- // is the neighboring cell id hit?
- // if so, does it meet or exceed threshold?
- if (h != null)
- {
- if (h.getRawEnergy() >= threshold)
- addHit(h);
- hitmap.remove(neighbors[j]);
- }
- }
- }
- // calculateDerivedQuantities();
- }
-
- /**
- * Construct a NearestNeighborCluster. Note that the constructor actually performs the
- * clustering, given a seed hit, without considering an energy threshold.
- * @param decoder The CellID decoder appropriate for this collection of hits.
- * @param hitmap The list of hit calorimeter cells available for clustering.
- * @param hit The seed calorimeter hit for this cluster.
- * @param key The key for the seed calorimeter hit.
- */
- public NearestNeighborCluster(CalorimeterIDDecoder decoder, Map<Long, CalorimeterHit> hitmap, CalorimeterHit hit, Long key, int dU, int dV, int dLayer)
- {
- this(decoder, hitmap, hit, key, dU, dV, dLayer, 0.0);
- }
-
- /**
- * Construct a NearestNeighborCluster. Note that the constructor actually performs the
- * clustering, given a seed hit.
* @param hitmap The list of hit calorimeter cells available for clustering.
* This map will be zeroed on exit.
* @param hit The seed calorimeter hit for this cluster.
lcsim/src/org/lcsim/recon/cluster/nn
diff -u -r1.5 -r1.6
--- NearestNeighborClusterDriver.java 14 Jan 2006 00:37:26 -0000 1.5
+++ NearestNeighborClusterDriver.java 1 Jul 2006 21:56:52 -0000 1.6
@@ -123,8 +123,7 @@
}
if(doit)
{
- CalorimeterIDDecoder decoder = (CalorimeterIDDecoder) event.getMetaData(collection).getIDDecoder();
- List<BasicCluster> clusters = _clusterer.findClusters(collection,decoder);
+ List<Cluster> clusters = _clusterer.createClusters(collection);
if (clusters.size() > 0) {
int flag = 1 << LCIOConstants.CLBIT_HITS;
lcsim/src/org/lcsim/recon/cluster/nn
diff -u -r1.8 -r1.9
--- NearestNeighborClusterer.java 4 Aug 2005 08:06:03 -0000 1.8
+++ NearestNeighborClusterer.java 1 Jul 2006 21:56:52 -0000 1.9
@@ -8,6 +8,7 @@
import java.util.Set;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
+import org.lcsim.event.Cluster;
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.geometry.CalorimeterIDDecoder;
import org.lcsim.recon.cluster.util.*;
@@ -17,7 +18,7 @@
* Class to create a list of of Nearest Neighbor clusters
* @author Norman A. Graf with additions of threshold code by Eric J. Benavidez ([log in to unmask])
*/
-public class NearestNeighborClusterer
+public class NearestNeighborClusterer implements Clusterer
{
// the minimum number of cells to qualify as a cluster
private int _minNcells;
@@ -61,42 +62,35 @@
{
_thresh = threshold;
}
- public List<BasicCluster> findClusters(List<CalorimeterHit> hitlist, CalorimeterIDDecoder decoder)
+ public List<Cluster> createClusters(List<CalorimeterHit> hitlist)
{
// create a map of cells keyed on their index
- List<BasicCluster> clusters = new ArrayList();
Map<Long, CalorimeterHit> hitmap = new HashMap<Long, CalorimeterHit>();
for (CalorimeterHit hit : hitlist)
{
long id = hit.getCellID();
hitmap.put(id, hit);
}
+ List<Cluster> clusters = createClustersFromTempMap(hitmap);
+ return clusters;
+ }
+ public List<Cluster> createClusters(Map<Long, CalorimeterHit> hitmap)
+ {
+ // create a temporary map of cells keyed on their index
+ Map<Long, CalorimeterHit> tempmap = new HashMap<Long, CalorimeterHit>();
while (!hitmap.isEmpty())
{
Long k = hitmap.keySet().iterator().next();
CalorimeterHit hit = hitmap.get(k);
- // start a cluster, constructor will aggregate remaining hits unto itself
- // NB : Must pass the threshold into the constructor, otherwise threshold
- // will not be used.
- NearestNeighborCluster nnclus = new NearestNeighborCluster(decoder, hitmap, hit, k, _dU, _dV, _dLayer, _thresh);
- if(nnclus.getCalorimeterHits().size()>_minNcells)
- {
- clusters.add(nnclus);
- }
+ tempmap.put(k, hit);
}
+ List<Cluster> clusters = createClustersFromTempMap(tempmap);
return clusters;
- }
-
- public List<BasicCluster> findClusters(List<CalorimeterHit> hitlist)
+ }
+ public List<Cluster> createClustersFromTempMap(Map<Long, CalorimeterHit> hitmap)
{
// create a map of cells keyed on their index
- List<BasicCluster> clusters = new ArrayList();
- Map<Long, CalorimeterHit> hitmap = new HashMap<Long, CalorimeterHit>();
- for (CalorimeterHit hit : hitlist)
- {
- long id = hit.getCellID();
- hitmap.put(id, hit);
- }
+ List<Cluster> clusters = new ArrayList();
while (!hitmap.isEmpty())
{
Long k = hitmap.keySet().iterator().next();