From d3924c8d9784baa76a9e4edc34891d56d9f350f4 Mon Sep 17 00:00:00 2001 From: Veronique Ziegler Date: Thu, 7 Dec 2017 19:41:00 -0500 Subject: [PATCH] Bug fix in pattern recognition (FindSeedClustersFixedBin) --- .../java/org/jlab/rec/cvt/svt/Geometry.java | 2 +- .../org/jlab/rec/cvt/track/TrackSeeder.java | 130 ++++++++---------- .../rec/cvt/trajectory/TrajectoryFinder.java | 2 + .../jlab/rec/cvt/trajectory/TrkSwimmer.java | 3 +- 4 files changed, 63 insertions(+), 74 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/Geometry.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/Geometry.java index f0bd198d19..bf0681e7d5 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/Geometry.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/Geometry.java @@ -568,7 +568,7 @@ public double planeNormDotTrkDir(int sector, int layer, Point3D trkDir, double s //*** public Point3D intersectionOfHelixWithPlane(int layer, int sector, Helix helix) { - + int[] rm = SVTConstants.convertLayer2RegionModule(layer-1); int nstep = 1; diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/track/TrackSeeder.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/track/TrackSeeder.java index 9cd91eadb1..b72483865b 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/track/TrackSeeder.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/track/TrackSeeder.java @@ -16,6 +16,14 @@ public class TrackSeeder { public TrackSeeder() { + sortedClusters = new ArrayList>>(); + + for(int b =0; b<36; b++) { + sortedClusters.add(b, new ArrayList>() ); + for(int l =0; l<6; l++) { + sortedClusters.get(b).add(l,new ArrayList() ); + } + } } private List> seedClusters = new ArrayList>(); @@ -24,9 +32,9 @@ public TrackSeeder() { public void FindSeedClusters(List SVTclusters) { - seedClusters.clear(); - for(int si1 = 0; si1> phi0 = FindSeedClustersFixedBin(SVTclusters, phiShift[0]); @@ -47,96 +55,74 @@ public void FindSeedClusters(List SVTclusters) { } } } + + List>> sortedClusters; public List> FindSeedClustersFixedBin(List SVTclusters, double phiShift) { - - int NbLayers = Constants.NLAYR; - Collections.sort(SVTclusters); - - int[] L = new int[6]; - List> inseedClusters = new ArrayList>(); - - List> sortedClusters = new ArrayList>(); - List> inputClusters = new ArrayList>(); - for(int l =0; l<6; l++) { - sortedClusters.add(l,new ArrayList() ); + for(int b =0; b<36; b++) { + for(int l =0; l<6; l++) { + sortedClusters.get(b).get(l).clear(); + } } - + List> inseedClusters = new ArrayList>(); + int[][] LPhi = new int[36][6]; for (int i = 0; i < SVTclusters.size(); i++) { - sortedClusters.get(SVTclusters.get(i).get_Layer() - 1).add(SVTclusters.get(i)); - L[SVTclusters.get(i).get_Layer() - 1]++; - } - for(int l =0; l<6; l++) { - if(L[l]==0) - L[l]=1; + double phi = Math.toDegrees(SVTclusters.get(i).get(0).get_Strip().get_ImplantPoint().toVector3D().phi()); + + phi += phiShift; + if (phi < 0) { + phi += 360; + } + + int binIdx = (int) (phi / 36); + sortedClusters.get(binIdx).get(SVTclusters.get(i).get_Layer() - 1).add(SVTclusters.get(i)); + LPhi[binIdx][SVTclusters.get(i).get_Layer() - 1]++; } - for(int l1 =0; l1 listClusters = new ArrayList(); - if(sortedClusters.get(0).size()>0 && sortedClusters.get(0).get(l1)!=null) - listClusters.add(sortedClusters.get(0).get(l1)); - if(sortedClusters.get(1).size()>0 && sortedClusters.get(1).get(l2)!=null) - listClusters.add(sortedClusters.get(1).get(l2)); - if(sortedClusters.get(2).size()>0 && sortedClusters.get(2).get(l3)!=null) - listClusters.add(sortedClusters.get(2).get(l3)); - if(sortedClusters.get(3).size()>0 && sortedClusters.get(3).get(l4)!=null) - listClusters.add(sortedClusters.get(3).get(l4)); - if(sortedClusters.get(4).size()>0 && sortedClusters.get(4).get(l5)!=null) - listClusters.add(sortedClusters.get(4).get(l5)); - if(sortedClusters.get(5).size()>0 && sortedClusters.get(5).get(l6)!=null) - listClusters.add(sortedClusters.get(5).get(l6)); - if(listClusters.size()>0) { - inputClusters.add(listClusters); - } - } - int nphiBins = 36; - for(int g =0; g0) + max_layers++; } - - for (int b = 0; b < nphiBins; b++) { - - if (ClsArray[b] != null) { - ArrayList hits = new ArrayList(); - + if (sortedClusters.get(b) != null && max_layers>3) { + double SumLyr=0; + while(LPhi[b][0]+LPhi[b][1]+ LPhi[b][2]+LPhi[b][3]+ LPhi[b][4]+ LPhi[b][5]>=max_layers) { + if(SumLyr!=LPhi[b][0]+LPhi[b][1]+ LPhi[b][2]+LPhi[b][3]+ LPhi[b][4]+ LPhi[b][5]) { + SumLyr = LPhi[b][0]+LPhi[b][1]+ LPhi[b][2]+LPhi[b][3]+ LPhi[b][4]+ LPhi[b][5]; + } + ArrayList hits = new ArrayList(); for (int la = 0; la < 6; la++) { - if (ClsArray[b][la] != null) { - hits.add(ClsArray[b][la]); + if (sortedClusters.get(b).get(la) != null && LPhi[b][la]>0) { + if (sortedClusters.get(b).get(la).get(LPhi[b][la]-1) != null && sortedClusters.get(b).get(la).get(LPhi[b][la]-1).size()>0) { + hits.add(sortedClusters.get(b).get(la).get(LPhi[b][la]-1)); + + if(LPhi[b][la]>1) + LPhi[b][la]--; + if(SumLyr==max_layers) + LPhi[b][la]=0; + } } } + if (hits.size() > 3) { inseedClusters.add(hits); } + } + } } + return inseedClusters; - } + + + + private List Xs = new ArrayList(); private List Ys = new ArrayList(); private List Ws = new ArrayList(); diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrajectoryFinder.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrajectoryFinder.java index 76fba262fc..a0713d63b6 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrajectoryFinder.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrajectoryFinder.java @@ -33,6 +33,8 @@ public TrajectoryFinder() { * @return a trajectory object */ public Trajectory findTrajectory(int id, Helix helix, ArrayList candCrossList, org.jlab.rec.cvt.svt.Geometry svt_geo, org.jlab.rec.cvt.bmt.Geometry bmt_geo, String isFinal) { + if(helix ==null) + return null; Trajectory traj = new Trajectory(helix); if (isFinal == "final") { traj.isFinal = true; diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrkSwimmer.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrkSwimmer.java index 4a8acdddac..916c1ab274 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrkSwimmer.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/trajectory/TrkSwimmer.java @@ -74,7 +74,8 @@ public void SetSwimParameters(double x0, double y0, double z0, double px, double public void SetSwimParameters(Helix helix, double maxPathLength, int charge, double p) { - + if(helix==null) + return; _maxPathLength = maxPathLength; _charge = charge; _phi = Math.toDegrees(helix.get_phi_at_dca());