diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/cluster/ClusterFinder.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/cluster/ClusterFinder.java index ba1568e636..9617c13a58 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/cluster/ClusterFinder.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/cluster/ClusterFinder.java @@ -64,46 +64,49 @@ public ArrayList findClusters(List hits2) // the number of strips while (si < nstrip) { // if there's a hit, it's a cluster candidate if (HitArray[si][l][s] != null || (si < nstrip - 1 && HitArray[si + 1][l][s] != null)) { - // vector of hits in the cluster candidate - ArrayList hits = new ArrayList<>(); - + + Cluster this_cluster = null; + // adding all hits in this and all the subsequent // strip until there's a strip with no hit while ((si < nstrip - 1 && HitArray[si + 1][l][s] != null) || (HitArray[si][l][s] != null && si < nstrip)) { if (HitArray[si][l][s] != null) { // continue clustering skipping over bad hit - hits.add(HitArray[si][l][s]); + if (this_cluster == null) { + Hit seed = HitArray[si][l][s]; + this_cluster = new Cluster(seed.getDetector(), seed.getType(), seed.getSector(), l + 1, cid++); + this_cluster.setId(clusters.size() + 1); + } + this_cluster.add(HitArray[si][l][s]); } si++; } + + if (this_cluster != null) { - // define new cluster - Cluster this_cluster = new Cluster(hits.get(0).getDetector(), hits.get(0).getType(), hits.get(0).getSector(), l + 1, cid++); - this_cluster.setId(clusters.size() + 1); - // add hits to the cluster - this_cluster.addAll(hits); - if(hits.size()>2) { - for(int hi = 1; hi 2) { + for(int hi = 1; hi