lcsim/src/org/lcsim/recon/cluster/nn
diff -u -r1.6 -r1.7
--- NearestNeighborClusterDriver.java 1 Jul 2006 21:56:52 -0000 1.6
+++ NearestNeighborClusterDriver.java 8 Nov 2007 23:16:40 -0000 1.7
@@ -25,138 +25,136 @@
*/
public class NearestNeighborClusterDriver extends Driver
{
- // the minimum number of cells to qualify as a cluster
- private int _minNcells;
-
- // the neighborhood in u to search
- private int _dU;
- // the neighborhood in v to search
- private int _dV;
- // the neighborood in layers to search
- private int _dLayer;
- // energy threshold
- private double _thresh;
- // Create clusters class
- private NearestNeighborClusterer _clusterer;
- // extension of collection name for writing clusters to event
- private String _nameExt;
- // flag to cluster all collections
- private boolean _doall;
- // list of collections to cluster
- private String[] _collNames;
-
- /**
- * Creates a new instance of NearestNeighborClusterDriver with a domain of (1,1,1)
- * and no threshold.
- * @param ncells The minimum number of cells required to constitute a cluster.
- */
- public NearestNeighborClusterDriver(int ncells)
- {
- this(1, 1, 1, ncells, 0);
- }
-
- /**
- * Creates a new instance of NearestNeighborClusterDriver
- * @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.
- * @param threshold The energy threshold that must be met or exceeded in order
- * to be considered in the cluster.
- */
- public NearestNeighborClusterDriver(int dU, int dV, int dLayer, int ncells,
- double threshold)
- {
- _dU = dU;
- _dV = dV;
- _dLayer = dLayer;
- _minNcells = ncells;
- _thresh = threshold;
- _nameExt = "NNClusters";
- _doall = true;
- _clusterer = new NearestNeighborClusterer(_dU,_dV,_dLayer,_minNcells,_thresh);
- }
-
- /**
- * Creates a new NearestNeighborClusterDriver 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 NearestNeighborClusterDriver(int dU, int dV, int dLayer, int ncells)
- {
- this(dU, dV, dLayer, ncells, 0);
- }
-
- /**
- * Process an event. Extract calorimeter cells from collections contained in the
- * event, cluster the cells using a nearest-neighbor algorithm, and add these
- * cluster containers back to the event.
- *
- * @param event
- */
- protected void process(EventHeader event)
- {
- //First look for clusters in individual collections
-
- List<List<CalorimeterHit>> collections = event.get(CalorimeterHit.class);
- for (List<CalorimeterHit> collection: collections)
- {
- String name = event.getMetaData(collection).getName();
- boolean doit = false;
- if(_doall)
- {
- doit = true;
- }
- else
- {
- for(int i=0;i<_collNames.length;i++)
- {
- if(name.compareTo(_collNames[i]) == 0)
- {
- doit = true;
- break;
- }
- }
- }
- if(doit)
- {
- List<Cluster> clusters = _clusterer.createClusters(collection);
-
- if (clusters.size() > 0) {
- int flag = 1 << LCIOConstants.CLBIT_HITS;
- event.put(name+_nameExt,clusters,Cluster.class,(1<<31));
- }
- }
- }
- }
- /**
- * Set the extension of the hit collection name to use
- * when writing the cluster collection to event
- *
- * @param ext - the extension to add to the hit collection name
- */
- public void setClusterNameExtension(String ext)
- {
- _nameExt = ext;
- }
- /**
- * Set the names of the CalorimeterHit collections to cluster
- *
- * @param names - an array of Strings containing the names of the
- * hit collections to cluster
- */
- public void setCollectionNames(String[] names)
- {
- _collNames = names;
- _doall = false;
- }
-
- public String toString()
- {
- return "NearestNeighborClusterDriver with clusterer "+_clusterer;
- }
-
+ // the minimum number of cells to qualify as a cluster
+ private int _minNcells;
+
+ // the neighborhood in u to search
+ private int _dU;
+ // the neighborhood in v to search
+ private int _dV;
+ // the neighborood in layers to search
+ private int _dLayer;
+ // energy threshold
+ private double _thresh;
+ // Create clusters class
+ private NearestNeighborClusterer _clusterer;
+ // extension of collection name for writing clusters to event
+ private String _nameExt;
+ // flag to cluster all collections
+ private boolean _doall;
+ // list of collections to cluster
+ private String[] _collNames;
+
+ /**
+ * Creates a new instance of NearestNeighborClusterDriver with a domain of (1,1,1)
+ * and no threshold.
+ * @param ncells The minimum number of cells required to constitute a cluster.
+ */
+ public NearestNeighborClusterDriver(int ncells)
+ {
+ this(1, 1, 1, ncells, 0);
+ }
+
+ /**
+ * Creates a new instance of NearestNeighborClusterDriver
+ * @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.
+ * @param threshold The energy threshold that must be met or exceeded in order
+ * to be considered in the cluster.
+ */
+ public NearestNeighborClusterDriver(int dU, int dV, int dLayer, int ncells,
+ double threshold)
+ {
+ _dU = dU;
+ _dV = dV;
+ _dLayer = dLayer;
+ _minNcells = ncells;
+ _thresh = threshold;
+ _nameExt = "NNClusters";
+ _doall = true;
+ _clusterer = new NearestNeighborClusterer(_dU,_dV,_dLayer,_minNcells,_thresh);
+ }
+
+ /**
+ * Creates a new NearestNeighborClusterDriver 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 NearestNeighborClusterDriver(int dU, int dV, int dLayer, int ncells)
+ {
+ this(dU, dV, dLayer, ncells, 0);
+ }
+
+ /**
+ * Process an event. Extract calorimeter cells from collections contained in the
+ * event, cluster the cells using a nearest-neighbor algorithm, and add these
+ * cluster containers back to the event.
+ *
+ * @param event
+ */
+ protected void process(EventHeader event)
+ {
+ //First look for clusters in individual collections
+
+ List<List<CalorimeterHit>> collections = event.get(CalorimeterHit.class);
+ for (List<CalorimeterHit> collection: collections)
+ {
+ String name = event.getMetaData(collection).getName();
+ boolean doit = false;
+ if(_doall)
+ {
+ doit = true;
+ }
+ else
+ {
+ for(int i=0;i<_collNames.length;i++)
+ {
+ if(name.compareTo(_collNames[i]) == 0)
+ {
+ doit = true;
+ break;
+ }
+ }
+ }
+ if(doit)
+ {
+ List<Cluster> clusters = _clusterer.createClusters(collection);
+
+ int flag = 1 << LCIOConstants.CLBIT_HITS;
+ event.put(name+_nameExt,clusters,Cluster.class,flag);
+ }
+ }
+ }
+ /**
+ * Set the extension of the hit collection name to use
+ * when writing the cluster collection to event
+ *
+ * @param ext - the extension to add to the hit collection name
+ */
+ public void setClusterNameExtension(String ext)
+ {
+ _nameExt = ext;
+ }
+ /**
+ * Set the names of the CalorimeterHit collections to cluster
+ *
+ * @param names - an array of Strings containing the names of the
+ * hit collections to cluster
+ */
+ public void setCollectionNames(String[] names)
+ {
+ _collNames = names;
+ _doall = false;
+ }
+
+ public String toString()
+ {
+ return "NearestNeighborClusterDriver with clusterer "+_clusterer;
+ }
+
}