Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ public class ClusterCleanerUtilities {

private static final Logger LOGGER = Logger.getLogger(ClusterCleanerUtilities.class.getName());

private List<ArrayList<Hit>> sortedHits;

public ClusterCleanerUtilities() {
List<ArrayList<Hit>> sortdHits = new ArrayList<>();
for(int l = 0; l < 6; l++) {
sortdHits.add(new ArrayList<>());
}
sortedHits = sortdHits;
sortedHits = new ArrayList<>();
for(int l = 0; l < 6; l++) sortedHits.add(new ArrayList<>());
}
private List<ArrayList<Hit>> sortedHits = null;

/**
*
* Pattern Recognition step for identifying clusters in a clump: Find the
Expand Down Expand Up @@ -220,7 +219,6 @@ public List<FittedCluster> ClusterSplitter(FittedCluster clus, int nextClsStartI
FittedCluster bestCls = OverlappingClusterResolver(cluster, splitclusters);

if (bestCls != null) {

if (!(selectedClusList.contains(bestCls))) {
selectedClusList.add(bestCls);
}
Expand All @@ -237,7 +235,6 @@ public List<FittedCluster> ClusterSplitter(FittedCluster clus, int nextClsStartI
FittedCluster bestCls = OverlappingClusterResolver(cluster, selectedClusList);

if (bestCls != null) {

if (!(selectedClusList2.contains(bestCls))) {
selectedClusList2.add(bestCls);
}
Expand Down Expand Up @@ -283,12 +280,9 @@ public List<List<Hit>> byLayerListSorter(List<Hit> DCHits, int sector, int super
*/
public int count_nlayers_hit(Hit[] hits_inlayer) {
int nlayr = 6;
Hit[] allhits_inlayer = new Hit[nlayr];
allhits_inlayer = hits_inlayer;

int nlayers_hit = 0;
for (int la = 0; la < nlayr; la++) {
if (allhits_inlayer[la] != null) {
if (hits_inlayer[la] != null) {
nlayers_hit++;
}
}
Expand Down Expand Up @@ -341,7 +335,6 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus,
if (hit.get_LeftRightAmb() == 0) {
index++;
}

}
if (index == 0) {
return fClus; // cluster OK
Expand Down Expand Up @@ -445,7 +438,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus,
arrayOfClus.get(0).addAll(okClus);
arrayOfClus.get(1).addAll(okClus);
}
if (index == 2) {
else if (index == 2) {
for (int i1 = 0; i1 < totNotLRClus.size(); i1++) {
for (int i2 = 2; i2 < totNotLRClus.size(); i2++) {
if (totNotLRClus.get(i1).get_Id() == totNotLRClus.get(i2).get_Id()) {
Expand All @@ -459,8 +452,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus,
}
}
}

if (index == 3) {
else if (index == 3) {
for (int i1 = 0; i1 < totNotLRClus.size(); i1++) {
for (int i2 = 2; i2 < totNotLRClus.size(); i2++) {
for (int i3 = 4; i3 < totNotLRClus.size(); i3++) {
Expand All @@ -479,8 +471,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus,
}
}
}

if (index == 4) {
else if (index == 4) {
for (int i1 = 0; i1 < totNotLRClus.size(); i1++) {
for (int i2 = 2; i2 < totNotLRClus.size(); i2++) {
for (int i3 = 4; i3 < totNotLRClus.size(); i3++) {
Expand All @@ -505,8 +496,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus,
}
}
}

if (index == 5) {
else if (index == 5) {
for (int i1 = 0; i1 < totNotLRClus.size(); i1++) {
for (int i2 = 2; i2 < totNotLRClus.size(); i2++) {
for (int i3 = 4; i3 < totNotLRClus.size(); i3++) {
Expand Down Expand Up @@ -538,8 +528,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus,
}
}
}

if (index == 6) {
else if (index == 6) {
for (int i1 = 0; i1 < totNotLRClus.size(); i1++) {
for (int i2 = 2; i2 < totNotLRClus.size(); i2++) {
for (int i3 = 4; i3 < totNotLRClus.size(); i3++) {
Expand Down Expand Up @@ -613,14 +602,14 @@ public FittedCluster SecondariesRemover(DataEvent event, FittedCluster clus, Clu
if (hitsInLayer.isEmpty()) {
continue;
}
if (hitsInLayer.size() == 1) {
else if (hitsInLayer.size() == 1) {
baseClusterHits.addAll(hitsInLayer); // safe all good hits to base cluster
for (int j = 0; j < hitsInLayer.size(); j++) {
hitsInLayer.get(j).set_LeftRightAmb(0);
hitsInLayer.get(j).updateHitPositionWithTime(event, 1, hitsInLayer.get(j).getB(), tab, DcDetector, tde);
}
}
if (hitsInLayer.size() == 2) {
else if (hitsInLayer.size() == 2) {
double docaSum = 0;
for (int j = 0; j < hitsInLayer.size(); j++) {
docaSum += hitsInLayer.get(j).get_Doca();
Expand Down Expand Up @@ -665,7 +654,6 @@ public FittedCluster SecondariesRemover(DataEvent event, FittedCluster clus, Clu
}

if (nbLyr > 0) {

for (int[] get : Constants.getInstance().CombArray.get(nbLyr - 1)) {
ArrayList<FittedHit> hitsInClusterCand = new ArrayList<>();
hitsInClusterCand.addAll(baseClusterHits);
Expand All @@ -675,6 +663,7 @@ public FittedCluster SecondariesRemover(DataEvent event, FittedCluster clus, Clu
hitsInClusCandLists.add(hitsInClusterCand);
}
}

for (int i = 0; i < hitsInClusCandLists.size(); i++) {
FittedCluster newClus = new FittedCluster(clus.getBaseCluster());
for (int i1 = 0; i1 < newClus.size(); i1++) {
Expand Down Expand Up @@ -794,7 +783,7 @@ public List<Hit> HitListPruner(List<Hit> hits) {
rmHits.removeAll(kHits);
sortedHits.get(l).removeAll(rmHits);
}
if(sortedHits.get(l).size()>4 && sortedHits.get(l).size()<10) {
else if(sortedHits.get(l).size()>4 && sortedHits.get(l).size()<10) {
ArrayList<Hit> rmHits = (ArrayList<Hit>) sortedHits.get(l).clone();
ArrayList<Hit> kHits = new ArrayList<>();
kHits.add(sortedHits.get(l).get(0));
Expand All @@ -804,7 +793,7 @@ public List<Hit> HitListPruner(List<Hit> hits) {
rmHits.removeAll(kHits);
sortedHits.get(l).removeAll(rmHits);
}
if(sortedHits.get(l).size()>=10)
else if(sortedHits.get(l).size()>=10)
sortedHits.get(l).removeAll(sortedHits.get(l));

}
Expand Down Expand Up @@ -861,13 +850,13 @@ public FittedCluster IsolatedHitsPruner(FittedCluster clus) {
fcluster.add(clus.get(i));
}
}
if (layer == 6) // look of neighbor in previous layer
else if (layer == 6) // look of neighbor in previous layer
{
if (HitArray[layer - 2][wire - 1] != null || HitArray[layer - 2][wire - 2] != null || HitArray[layer - 2][wire] != null || HitArray[layer - 1][wire - 2] != null || HitArray[layer - 1][wire] != null) {
fcluster.add(clus.get(i));
}
}
if (layer > 1 && layer < 6) // look of neighbor in next and previous layers
else if (layer > 1 && layer < 6) // look of neighbor in next and previous layers
{
if (HitArray[layer][wire - 1] != null || HitArray[layer][wire - 2] != null || HitArray[layer][wire] != null || HitArray[layer - 2][wire - 1] != null || HitArray[layer - 2][wire - 2] != null || HitArray[layer - 2][wire] != null || HitArray[layer - 1][wire - 2] != null || HitArray[layer - 1][wire] != null) {
fcluster.add(clus.get(i));
Expand Down Expand Up @@ -929,7 +918,7 @@ public FittedCluster ClusterCleaner(FittedCluster clus, ClusterFitter cf, DCGean
baseClusterHits.addAll(hitsInLayer); // safe all good hits to base cluster

}
if (hitsInLayer.size() == 2) {
else if (hitsInLayer.size() == 2) {
double docaSum = 0;
for (int j = 0; j < hitsInLayer.size(); j++) {
docaSum += hitsInLayer.get(j).get_Residual();
Expand Down Expand Up @@ -963,7 +952,6 @@ public FittedCluster ClusterCleaner(FittedCluster clus, ClusterFitter cf, DCGean
}

if (nbLyr > 0) {

for (int[] get : Constants.getInstance().CombArray.get(nbLyr - 1)) {
ArrayList<FittedHit> hitsInClusterCand = new ArrayList<>();
hitsInClusterCand.addAll(baseClusterHits);
Expand All @@ -973,6 +961,7 @@ public FittedCluster ClusterCleaner(FittedCluster clus, ClusterFitter cf, DCGean
hitsInClusCandLists.add(hitsInClusterCand);
}
}

for (int i = 0; i < hitsInClusCandLists.size(); i++) {
FittedCluster newClus = new FittedCluster(clus.getBaseCluster());
for (int i1 = 0; i1 < newClus.size(); i1++) {
Expand All @@ -982,17 +971,7 @@ public FittedCluster ClusterCleaner(FittedCluster clus, ClusterFitter cf, DCGean
clusters.add(newClus);
}

// get the best cluster
//LOGGER.log(Level.INFO, " clusters for selection ");
//for(FittedCluster c : clusters) {
// LOGGER.log(Level.INFO, c.printInfo());
// for(FittedHit h : c)
// LOGGER.log(Level.INFO, h.printInfo());
//}
FittedCluster BestCluster = cf.BestClusterSelector(clusters, "LC");
//LOGGER.log(Level.INFO, " ---> selected cluster : ");
//for(FittedHit h : BestCluster)
// LOGGER.log(Level.INFO, h.printInfo());
return BestCluster;
}

Expand Down