Skip to content

Commit

Permalink
use wrapper to treat similar functions of isExceptionalCluster
Browse files Browse the repository at this point in the history
  • Loading branch information
tongtongcao authored and baltzell committed Feb 4, 2025
1 parent d205bd6 commit 93b8651
Showing 1 changed file with 35 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1010,73 +1010,53 @@ public FittedCluster ClusterCleaner(FittedCluster clus, ClusterFitter cf, DCGean
return BestCluster;
}

/**
*
* @param hitsInClus the hits in a cluster
* @return if one or more layers are skipped in the cluster
/**
* Check if one or more layers are skipped in the cluster
* @param hitsInClus the hits in a cluster (can be either Hit or FittedHit)
* @param nlayr the number of layers
* @return true if one or more layers are skipped in the cluster
*/
public boolean isExceptionalCluster(List<Hit> hitsInClus){
// count hits in each layer
int nlayr = 6;
private boolean isExceptionalClusterHelper(List<? extends Hit> hitsInClus, int nlayr) {
// Initialize array to count hits in each layer
int[] nlayers = new int[nlayr];
for (int l = 0; l < nlayr; l++) {
nlayers[l] = 0;
for (int h = 0; h < hitsInClus.size(); h++) {
if (hitsInClus.get(h).get_Layer() == l + 1) {
nlayers[l]++;
}

// Count hits for each layer in a single pass through the hits
for (Hit hit : hitsInClus) {
int layer = hit.get_Layer() - 1; // layer numbering starts from 1
if (layer >= 0 && layer < nlayr) {
nlayers[layer]++;
}
}

boolean flag_hasSkippedLayer = false;
if((nlayers[0] == 0 && nlayers[1] == 0) || (nlayers[4] == 0 && nlayers[5] == 0)){
flag_hasSkippedLayer = true;
// Check if the first or last two layerers are missed
if ((nlayers[0] == 0 && nlayers[1] == 0) || (nlayers[4] == 0 && nlayers[5] == 0)) {
return true;
}
else{
for (int l = 0; l < 4; l++) {
if (nlayers[l] > 0 && nlayers[l+1] == 0) {
flag_hasSkippedLayer = true;
break;
}

// Check if there is one or more skipped layers in the middle
for (int l = 0; l < 4; l++) {
if (nlayers[l] > 0 && nlayers[l + 1] == 0) {
return true;
}
}
return flag_hasSkippedLayer;

return false;
}

/*
* @param hitsInClus the hits in a cluster
* @return if one or more layers are skipped in the cluster
*/
public boolean isExceptionalFittedCluster(List<FittedHit> hitsInClus){
// count hits in each layer
int nlayr = 6;
int[] nlayers = new int[nlayr];
for (int l = 0; l < nlayr; l++) {
nlayers[l] = 0;
for (int h = 0; h < hitsInClus.size(); h++) {
if (hitsInClus.get(h).get_Layer() == l + 1) {
nlayers[l]++;
}
}
}

boolean flag_hasSkippedLayer = false;
if((nlayers[0] == 0 && nlayers[1] == 0) || (nlayers[4] == 0 && nlayers[5] == 0)){
flag_hasSkippedLayer = true;
}
else{
for (int l = 0; l < 4; l++) {
if (nlayers[l] > 0 && nlayers[l+1] == 0) {
flag_hasSkippedLayer = true;
break;
}
}
}

return flag_hasSkippedLayer;
/**
* Wrapper for checking if a cluster of Hit objects is exceptional.
*/
public boolean isExceptionalCluster(List hitsInClus) {
return isExceptionalClusterHelper(hitsInClus, 6); // 6 layers for Hit objects
}

/**
* Wrapper for checking if a cluster of FittedHit objects is exceptional.
*/
public boolean isExceptionalFittedCluster(List hitsInClus) {
return isExceptionalClusterHelper(hitsInClus, 6); // 6 layers for FittedHit objects
}

public Cluster ClusterSticher(Cluster thisclus, Cluster nextclus, int cid){
ClusterFitter cf = new ClusterFitter();

Expand Down

0 comments on commit 93b8651

Please sign in to comment.