lcsim/src/org/lcsim/recon/cluster/nn
diff -u -r1.4 -r1.5
--- NearestNeighborClusterer.java 2 May 2005 22:11:31 -0000 1.4
+++ NearestNeighborClusterer.java 23 Jun 2005 23:26:17 -0000 1.5
@@ -17,7 +17,7 @@
* A simple driver which applies a nearest neighbor clustering algorithm
* to calorimeter cell collections contained in the event.
*
- * @author Norman A. Graf
+ * @author Norman A. Graf with additions of threshold code by Eric J. Benavidez ([log in to unmask])
*/
public class NearestNeighborClusterer extends Driver
{
@@ -30,29 +30,49 @@
private int _dV;
// the neighborood in layers to search
private int _dLayer;
+ // energy threshold
+ private double _thresh;
/**
- * Creates a new instance of NearestNeighborClusterer with a domain of (1,1,1).
+ * Creates a new instance of NearestNeighborClusterer with a domain of (1,1,1)
+ * and no threshold.
* @param ncells The minimum number of cells required to constitute a cluster.
*/
public NearestNeighborClusterer(int ncells)
{
- this(1, 1, 1, ncells);
+ this(1, 1, 1, ncells, 0);
}
/**
* Creates a new instance of NearestNeighborClusterer
* @param dU The extent in the U coordinate which defines a neighborhood.
- * @param dV The extent in the U coordinate which defines a neighborhood.
- * @param dLayer The extent in the U coordinate which defines a neighborhood.
+ * @param dV The extent in the V coordinate which defines a neighborhood.
+ * @param dLayer The extent in the layer which defines a neighborhood.
* @param ncells The minimum number of cells required to constitute a cluster.
+ * @param threshold The energy threshold that must be met or exceeded in order
+ * to be considered in the cluster.
*/
- public NearestNeighborClusterer(int dU, int dV, int dLayer, int ncells)
+ public NearestNeighborClusterer(int dU, int dV, int dLayer, int ncells,
+ double threshold)
{
_dU = dU;
_dV = dV;
_dLayer = dLayer;
_minNcells = ncells;
+ _thresh = threshold;
+ }
+
+ /**
+ * Creates a new NearestNeighborClusterer with no energy threshold applied.
+ * @param dU The extent in the U coordinate which defines a neighborhood.
+ * @param dV The extent in the V coordinate which defines a neighborhood.
+ * @param dLayer The extent in the layer which defines a neighborhood.
+ * @param ncells The minimum number of cells required to constitute a cluster.
+ */
+
+ public NearestNeighborClusterer(int dU, int dV, int dLayer, int ncells)
+ {
+ this(dU, dV, dLayer, ncells, 0);
}
/**
@@ -79,20 +99,22 @@
long id = hit.getCellID();
hitmap.put(id, hit);
}
- for(;;)
+ while (!hitmap.isEmpty())
{
- if (hitmap.isEmpty()) break;
Long k = hitmap.keySet().iterator().next();
CalorimeterHit hit = hitmap.get(k);
// start a cluster, constructor will aggregate remaining hits unto itself
- NearestNeighborCluster nnclus = new NearestNeighborCluster(decoder, hitmap, hit, k, _dU, _dV, _dLayer);
+ // 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);
}
}
String name = event.getMetaData(collection).getName();
- if (clusters.size() > 0) event.put(name+"NNClusters",clusters);
+ if (clusters.size() > 0)
+ event.put(name+"NNClusters",clusters);
}
}