Commit in lcsim/src/org/lcsim/recon/cluster/nn on MAIN
NearestNeighborCluster.java+491.8 -> 1.9
NearestNeighborClusterer.java+271.7 -> 1.8
+76
2 modified files
Added cluster metod which does not require an iddecoder. Will deprecate old method once I have modified all the remaining code examples.

lcsim/src/org/lcsim/recon/cluster/nn
NearestNeighborCluster.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- NearestNeighborCluster.java	2 Aug 2005 17:18:04 -0000	1.8
+++ NearestNeighborCluster.java	4 Aug 2005 08:06:03 -0000	1.9
@@ -74,6 +74,55 @@
     }
     
     /**
+     * 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(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);
+        // fetch the decoder
+        CalorimeterIDDecoder decoder = (CalorimeterIDDecoder)hit.getIDDecoder();
+        // 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();
+    }    
+    
+    
+    /**
      * String representation of this object.
      * @return A String representation of this object
      */

lcsim/src/org/lcsim/recon/cluster/nn
NearestNeighborClusterer.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- NearestNeighborClusterer.java	18 Jul 2005 03:06:19 -0000	1.7
+++ NearestNeighborClusterer.java	4 Aug 2005 08:06:03 -0000	1.8
@@ -86,6 +86,33 @@
         }
         return clusters;
     }
+    
+    public List<BasicCluster> findClusters(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);
+        }
+        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(hitmap, hit, k, _dU, _dV, _dLayer, _thresh);
+            if(nnclus.getCalorimeterHits().size()>_minNcells)
+            {
+                clusters.add(nnclus);
+            }
+        }
+        return clusters;
+    }    
+    
  
    public String toString()
    {
CVSspam 0.2.8