From e9a4487d28f0f1617a0c6435f791b3c7e5bc0a29 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 15 Oct 2026 15:07:17 -0400 Subject: [PATCH 1/4] remove extra ArrayList --- .../jlab/rec/cvt/cluster/ClusterFinder.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) 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..9dbe876ae7 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,48 @@ 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 clust = 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 (clust == null) { + Hit seed = HitArray[si][l][s]; + clust = new Cluster(seed.getDetector(), seed.getType(), seed.getSector(), l + 1, cid++); + clust.setId(clusters.size() + 1); + } + clust.add(HitArray[si][l][s]); } si++; } + + if (clust == null) break; - // 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 Date: Thu, 15 Oct 2026 15:08:31 -0400 Subject: [PATCH 2/4] back to original name --- .../jlab/rec/cvt/cluster/ClusterFinder.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 9dbe876ae7..4a0a7ff56a 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 @@ -65,47 +65,47 @@ public ArrayList findClusters(List hits2) // the number of strips // 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)) { - Cluster clust = null; + 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 - if (clust == null) { + if (this_cluster == null) { Hit seed = HitArray[si][l][s]; - clust = new Cluster(seed.getDetector(), seed.getType(), seed.getSector(), l + 1, cid++); - clust.setId(clusters.size() + 1); + this_cluster = new Cluster(seed.getDetector(), seed.getType(), seed.getSector(), l + 1, cid++); + this_cluster.setId(clusters.size() + 1); } - clust.add(HitArray[si][l][s]); + this_cluster.add(HitArray[si][l][s]); } si++; } - if (clust == null) break; + if (this_cluster == null) break; - if (clust.size() > 2) { - for(int hi = 1; hi 2) { + for(int hi = 1; hi Date: Thu, 15 Oct 2026 15:13:48 -0400 Subject: [PATCH 3/4] continue --- .../src/main/java/org/jlab/rec/cvt/cluster/ClusterFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4a0a7ff56a..2d54f77221 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 @@ -81,7 +81,7 @@ public ArrayList findClusters(List hits2) // the number of strips si++; } - if (this_cluster == null) break; + if (this_cluster == null) continue; if (this_cluster.size() > 2) { for(int hi = 1; hi Date: Thu, 15 Oct 2026 15:18:10 -0400 Subject: [PATCH 4/4] preserve logic --- .../jlab/rec/cvt/cluster/ClusterFinder.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) 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 2d54f77221..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 @@ -81,31 +81,32 @@ public ArrayList findClusters(List hits2) // the number of strips si++; } - if (this_cluster == null) continue; + if (this_cluster != null) { - if (this_cluster.size() > 2) { - for(int hi = 1; hi 2) { + for(int hi = 1; hi