From 7a02191bd21a39e806e627f11b4ee1d76c3f0592 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Thu, 20 Feb 2025 15:51:26 -0600 Subject: [PATCH 01/20] refactor: generic method for clustering different types of hits, method to chose the threshold for matching --- .../jlab/rec/atof/cluster/ClusterFinder.java | 232 ++++++++++-------- 1 file changed, 129 insertions(+), 103 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java index 2444afec86..cd599a14ee 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java @@ -11,8 +11,7 @@ * The {@code ClusterFinder} class builds clusters in the atof * *

- * Uses found hits information. - * Creates a {@link ATOFCluster} matching them. + * Uses found hits information. Creates a {@link ATOFCluster} matching them. *

* * @author pilleux @@ -28,7 +27,7 @@ public class ClusterFinder { * Sets the list of clusters. * * @param clusters a {@link ArrayList} of {@link ATOFCluster}. - * + * */ public void setClusters(ArrayList clusters) { this.clusters = clusters; @@ -38,31 +37,123 @@ public void setClusters(ArrayList clusters) { * Gets the list of clusters. * * @return a {@link ArrayList} of {@link ATOFCluster}. - * + * */ public ArrayList getClusters() { return clusters; } /** - * Builds clusters in the {@link DateEvent} using hits found and - * stored in a {@link HitFinder}. + * Computes the module difference between two {@link ATOFHit}. + * + * @param hit the first {@link ATOFHit}. + * + * @param otherhit the second {@link ATOFHit}. + * + */ + public int computeDeltaModule(ATOFHit hit, ATOFHit otherhit) { + int delta_module = Math.abs(hit.computeModuleIndex() - otherhit.computeModuleIndex()); + if (delta_module > 30) { + delta_module = 60 - delta_module; + } + return delta_module; + } + + /** + * Cluster hits around a given hit, based on the time and geometric + * proximity. + * + * Hits are compared based on their module difference, z difference, which + * is distance in mm or component difference for wedge hits, and time + * difference. + * + * If the hit satisfies all conditions, it is marked as clustered and added + * to the cluster hit list. + * + * + * @param The type of the hit objects, which must extend + * {@link ATOFHit}. This allows the method to work with different types of + * hits that are subclasses of {@link ATOFHit} (e.g., {@link BarHit}). + * @param i The index from which hits are read in the list to compare + * against the current hit. + * @param hits The list of hits to be clustered, can be any subclass of + * {@link ATOFHit}. + * @param this_hit The hit currently being considered for clustering. + * @param sigma_module The threshold for the module difference between the + * hits. If the difference exceeds this value, the hits are not clustered. + * @param sigma_z The threshold for the z-distance [mm] (or component + * difference for "wedge" type hits) between the hits. + * @param sigma_t The threshold for the time difference [ns] between the + * hits. + * @param cluster_id The ID of the cluster being formed. + * @param this_cluster_hits The list that will store the clustered hits. + * This list can accept hits of type ATOFHit or BarHit. Clustered hits are + * added to this list. + * + */ + public void clusterHits(int i, ArrayList hits, ATOFHit this_hit, double sigma_module, Number sigma_z, double sigma_t, int cluster_id, ArrayList this_cluster_hits) { + // Loop through less energetic clusters + for (int j = i + 1; j < hits.size(); j++) { + System.out.print("Getting other hit \n"); + T other_hit = hits.get(j); + // Skip already clustered hits + if (other_hit.getIsInACluster()) { + continue; + } + // Check the distance between the hits + int delta_module = computeDeltaModule(this_hit, other_hit); + double delta_T = Math.abs(this_hit.getTime() - other_hit.getTime()); + //The z distance can be a distance in mm or a difference in components for wedge hits + Boolean condition_z; + if ("wedge".equals(this_hit.getType()) & "wedge".equals(other_hit.getType())) { + int delta_Z = Math.abs(this_hit.getComponent() - other_hit.getComponent()); + condition_z = (delta_Z <= sigma_z.intValue()); + } else { + double delta_Z = Math.abs(this_hit.getZ() - other_hit.getZ()); + condition_z = (delta_Z <= sigma_z.doubleValue()); + } + //If hit is within limits, it is clustered + if (delta_module <= sigma_module) { + if (condition_z) { + if (delta_T < sigma_t) { + System.out.print("Clustered \n"); + other_hit.setIsInACluster(true); + other_hit.setAssociatedClusterIndex(cluster_id); + this_cluster_hits.add(other_hit); + } + } + } + } + } + + /** + * Builds clusters in the {@link DateEvent} using hits found and stored in a + * {@link HitFinder}. * * @param event the {@link DataEvent} containing the clusters to be built - * - * @param hitfinder the {@link HitFinder} containing the hits that were found - * + * + * @param hitfinder the {@link HitFinder} containing the hits that were + * found + * + * @param sigma_module the tolerance for clustering between modules + * + * @param sigma_component the tolerance for clustering between components + * + * @param sigma_z the tolerance for clustering in z [mm] + * + * @param sigma_t the tolerance for clustering in time [ns] + * */ - public void makeClusters(DataEvent event, HitFinder hitfinder) { + public void makeClusters(DataEvent event, HitFinder hitfinder, double sigma_module, double sigma_component, double sigma_z, double sigma_t) { //A list of clusters is built for each event clusters.clear(); int cluster_id = 1; - + //Getting the list of hits, they must have been ordered by energy already ArrayList wedge_hits = hitfinder.getWedgeHits(); ArrayList bar_hits = hitfinder.getBarHits(); - + //Looping through wedge hits first for (int i_wedge = 0; i_wedge < wedge_hits.size(); i_wedge++) { ATOFHit this_wedge_hit = wedge_hits.get(i_wedge); @@ -82,73 +173,18 @@ public void makeClusters(DataEvent event, HitFinder hitfinder) { this_cluster_wedge_hits.add(this_wedge_hit); //Check if other wedge hits should be clustered with the current one - //Start from the index of the current one and look at less energetic hits - for (int j_wedge = i_wedge + 1; j_wedge < wedge_hits.size(); j_wedge++) { - ATOFHit other_wedge_hit = wedge_hits.get(j_wedge); - //If that other hit is already involved in a cluster, skip it - if (other_wedge_hit.getIsInACluster()) { - continue; - } - //Check the distance between the hits - //For now we use phi module and z component differences from what is observed in simu - int delta_module = Math.abs(this_wedge_hit.computeModuleIndex() - other_wedge_hit.computeModuleIndex()); - if (delta_module > 30) { - delta_module = 60 - delta_module; - } - int delta_component = Math.abs(this_wedge_hit.getComponent() - other_wedge_hit.getComponent()); - //Later we could use z and phi threshold - //double delta_Phi = Math.abs(this_wedge_hit.getPhi() - other_wedge_hit.getPhi()); - //double delta_Z = Math.abs(this_wedge_hit.getZ() - other_wedge_hit.getZ()); - //Time matching - double delta_T = Math.abs(this_wedge_hit.getTime() - other_wedge_hit.getTime()); - - if (delta_module <= Parameters.SIGMA_MODULE_CLUSTERING) { - if (delta_component <= Parameters.SIGMA_COMPONENT_CLUSTERING)//delta_Z <= sigma_Z) - { - if (delta_T < Parameters.SIGMA_T_CLUSTERING) { - other_wedge_hit.setIsInACluster(true); - other_wedge_hit.setAssociatedClusterIndex(cluster_id); - this_cluster_wedge_hits.add(other_wedge_hit); - } - } - } - } - + clusterHits(i_wedge, wedge_hits, this_wedge_hit, sigma_module, sigma_component, sigma_t, cluster_id, this_cluster_wedge_hits); //After clustering wedge hits, check if bar hits should be clustered with them - for (int j_bar = 0; j_bar < bar_hits.size(); j_bar++) { - BarHit other_bar_hit = bar_hits.get(j_bar); - //Skip already clustered hits - if (other_bar_hit.getIsInACluster()) { - continue; - } - //Check the distance between the hits - //For now we use phi module difference from what is observed in simu - int delta_module = Math.abs(this_wedge_hit.computeModuleIndex() - other_bar_hit.computeModuleIndex()); - if (delta_module > 30) { - delta_module = 60 - delta_module; - } - //Later we could use phi threshold - //double delta_Phi = Math.abs(this_wedge_hit.getPhi() - other_wedge_hit.getPhi()); - double delta_Z = Math.abs(this_wedge_hit.getZ() - other_bar_hit.getZ()); - //Time matching - double delta_T = Math.abs(this_wedge_hit.getTime() - other_bar_hit.getTime()); - if (delta_module <= Parameters.SIGMA_MODULE_CLUSTERING) { - if (delta_Z < Parameters.SIGMA_Z_CLUSTERING) { - if (delta_T < Parameters.SIGMA_T_CLUSTERING) { - other_bar_hit.setIsInACluster(true); - other_bar_hit.setAssociatedClusterIndex(cluster_id); - this_cluster_bar_hits.add(other_bar_hit); - } - } - } - }//End loop bar hits - + //We start from the beginning of the bar hit list, hence i=-1 to start at 0. + clusterHits(-1, bar_hits, this_wedge_hit, sigma_module, sigma_z, sigma_t, cluster_id, this_cluster_bar_hits); + //After all wedge and bar hits have been grouped, build the cluster ATOFCluster cluster = new ATOFCluster(this_cluster_bar_hits, this_cluster_wedge_hits, event); //And add it to the list of clusters clusters.add(cluster); cluster_id++; }//End loop on all wedge hits + //Now make clusters from bar hits that are not associated with wedge hits //Loop through all bar hits for (int i_bar = 0; i_bar < bar_hits.size(); i_bar++) { @@ -164,36 +200,9 @@ public void makeClusters(DataEvent event, HitFinder hitfinder) { this_bar_hit.setAssociatedClusterIndex(cluster_id); this_cluster_bar_hits.add(this_bar_hit); - //Loop through less energetic clusters - for (int j_bar = i_bar + 1; j_bar < bar_hits.size(); j_bar++) { - BarHit other_bar_hit = bar_hits.get(j_bar); - //Skip already clustered hits - if (other_bar_hit.getIsInACluster()) { - continue; - } + //Matching bar hits in clusters + clusterHits(i_bar, bar_hits, this_bar_hit, sigma_module, sigma_z, sigma_t, cluster_id, this_cluster_bar_hits); - //Check the distance between the hits - //For now we use phi module difference from what is observed in simu - int delta_module = Math.abs(this_bar_hit.computeModuleIndex() - other_bar_hit.computeModuleIndex()); - if (delta_module > 30) { - delta_module = 60 - delta_module; - } - //Later we could use phi threshold - //double delta_Phi = Math.abs(this_wedge_hit.getPhi() - other_wedge_hit.getPhi()); - double delta_Z = Math.abs(this_bar_hit.getZ() - other_bar_hit.getZ()); - //Time matching - double delta_T = Math.abs(this_bar_hit.getTime() - other_bar_hit.getTime()); - - if (delta_module <= Parameters.SIGMA_MODULE_CLUSTERING) { - if (delta_Z < Parameters.SIGMA_Z_CLUSTERING) { - if (delta_T < Parameters.SIGMA_T_CLUSTERING) { - other_bar_hit.setIsInACluster(true); - other_bar_hit.setAssociatedClusterIndex(cluster_id); - this_cluster_bar_hits.add(other_bar_hit); - } - } - } - } ATOFCluster cluster = new ATOFCluster(this_cluster_bar_hits, this_cluster_wedge_hits, event); clusters.add(cluster); cluster_id++; @@ -201,8 +210,25 @@ public void makeClusters(DataEvent event, HitFinder hitfinder) { } /** - * Default constructor that initializes the list clusters as new empty - * list. + * Builds clusters in the {@link DateEvent} using hits found and stored in a + * {@link HitFinder}. + * + * @param event the {@link DataEvent} containing the clusters to be built + * + * @param hitfinder the {@link HitFinder} containing the hits that were + * found + * + */ + public void makeClusters(DataEvent event, HitFinder hitfinder) { + makeClusters(event, hitfinder, + Parameters.SIGMA_MODULE_CLUSTERING, + Parameters.SIGMA_COMPONENT_CLUSTERING, + Parameters.SIGMA_Z_CLUSTERING, + Parameters.SIGMA_T_CLUSTERING); + } + + /** + * Default constructor that initializes the list clusters as new empty list. */ public ClusterFinder() { clusters = new ArrayList<>(); From 9ff65b0e761919022455b3d3a88dd58cc643e707 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Thu, 20 Feb 2025 16:29:54 -0600 Subject: [PATCH 02/20] refactor: moving folders/packages for more generic alert features --- .../{atof/trackMatch => alert/projections}/TrackProjection.java | 2 +- .../{atof/trackMatch => alert/projections}/TrackProjector.java | 2 +- .../src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java | 2 +- .../alert/src/main/java/org/jlab/rec/service/ATOFEngine.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename reconstruction/alert/src/main/java/org/jlab/rec/{atof/trackMatch => alert/projections}/TrackProjection.java (99%) rename reconstruction/alert/src/main/java/org/jlab/rec/{atof/trackMatch => alert/projections}/TrackProjector.java (99%) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/trackMatch/TrackProjection.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java similarity index 99% rename from reconstruction/alert/src/main/java/org/jlab/rec/atof/trackMatch/TrackProjection.java rename to reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java index f6da1eacf3..d69cf3e2ef 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/trackMatch/TrackProjection.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java @@ -1,4 +1,4 @@ -package org.jlab.rec.atof.trackMatch; +package org.jlab.rec.alert.projections; import org.jlab.geom.prim.Point3D; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/trackMatch/TrackProjector.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java similarity index 99% rename from reconstruction/alert/src/main/java/org/jlab/rec/atof/trackMatch/TrackProjector.java rename to reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java index 6db18a154d..3cb4fbcaf4 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/trackMatch/TrackProjector.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java @@ -1,4 +1,4 @@ -package org.jlab.rec.atof.trackMatch; +package org.jlab.rec.alert.projections; import java.util.ArrayList; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java index 6ffd59309b..b5fa2e014d 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java @@ -6,7 +6,7 @@ import org.jlab.rec.atof.cluster.ATOFCluster; import org.jlab.rec.atof.hit.ATOFHit; import org.jlab.rec.atof.hit.BarHit; -import org.jlab.rec.atof.trackMatch.TrackProjection; +import org.jlab.rec.alert.projections.TrackProjection; /** * The {@code RecoBankWriter} writes the banks needed for the atof diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java b/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java index 117af7ba61..c43bf59381 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java @@ -18,7 +18,7 @@ import org.jlab.rec.atof.hit.ATOFHit; import org.jlab.rec.atof.hit.BarHit; import org.jlab.rec.atof.hit.HitFinder; -import org.jlab.rec.atof.trackMatch.TrackProjector; +import org.jlab.rec.alert.projections.TrackProjector; /** * Service to return reconstructed ATOF hits and clusters From 3e6381c7d58a163af079f9db747b75b827d94681 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Fri, 21 Feb 2025 17:08:12 -0600 Subject: [PATCH 03/20] feat: putting back cluster path length information, now handling cases were no tracks were matched by assigning a straight track --- .../jlab/rec/atof/banks/RecoBankWriter.java | 2 + .../jlab/rec/atof/cluster/ATOFCluster.java | 132 ++++++++++++++---- .../jlab/rec/atof/cluster/ClusterFinder.java | 12 +- 3 files changed, 111 insertions(+), 35 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java index b5fa2e014d..1e5cf33fb3 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java @@ -85,6 +85,8 @@ public static DataBank fillATOFClusterBank(DataEvent event, ArrayList { sigma_phi = Parameters.SIGMA_PHI_TRACK_MATCHING_BAR; @@ -217,18 +222,84 @@ public int matchTrack(DataEvent event) { } Point3D projection_point = new Point3D(xt, yt, zt); double delta_phi = Math.abs(this.getPhi() - projection_point.toVector3D().phi()); - if(delta_phi > Math.PI) delta_phi = Math.PI - delta_phi; - if (delta_phi < sigma_phi) { - if (Math.abs(this.getZ() - projection_point.z()) < sigma_z) { - this.setPathLength(path); - this.setInPathLength(inpath); - } + if (delta_phi > Math.PI) { + delta_phi = Math.PI - delta_phi; } - } + if (delta_phi < sigma_phi && Math.abs(this.getZ() - projection_point.z()) < sigma_z) { + //If a track is matched, write the path lengths + this.setPathLength(path); + this.setInPathLength(inpath); + } else { + //If no track is matched, assign a straight track + this.makeStraightTrack(); + } + } } return 0; } + /** + * Build a straight track from the vertex to this cluster. + * + * Sets the cluster path length and length through the atof from it. + * + */ + public void makeStraightTrack() { + double vx = 0, vy = 0, vz = 0;//Here we should read vertex info + Line3D vertexToCluster = new Line3D(vx, vy, vz, this.x, this.y, this.z); + double straightPath = vertexToCluster.length(); + this.setPathLength(straightPath); + this.setInPathLength(getDistanceStraightInATOF(vx, vy, vz)); + } + + /** + * Computes the distance a straight track goes through the ATOF. + * The intersection point between a straight track from the vertex + * to the cluster and the ATOF inner cylinder is computed to that end. + * + * @param vx, the x coordinate of the vertex + * @param vy, the y coordinate of the vertex + * @param vz, the z coordinate of the vertex + * + * @return the distance the straight track went through in the ATOF + * + */ + public double getDistanceStraightInATOF(double vx, double vy, double vz) { + //Solving the equation (X,Y,Z) = t*((x-vx),(y-vy),(z-vz)) + (vx,vy,vz) + //Such as sqr(X)+sqr(Y)=sqr(R) + double a = Math.pow((this.x - vx), 2) + Math.pow((this.y - vy), 2); + double b = 2 * (vx * (x - vx) + vy * (y - vy)); + double c = vx * vx + vy * vy - Parameters.BAR_INNER_RADIUS * Parameters.BAR_INNER_RADIUS; + double d = b * b - 4 * a * c; + double t1 = (-b - Math.sqrt(d)) / (2 * a); + double t2 = (-b + Math.sqrt(d)) / (2 * a); + //Intersection points between the line and the inner surface of the ATOF + double X1 = t1 * (this.x - vx) + vx; + double Y1 = t1 * (this.y - vy) + vy; + double Z1 = t1 * (this.z - vz) + vz; + double X2 = t2 * (this.x - vx) + vx; + double Y2 = t2 * (this.y - vy) + vy; + double Z2 = t2 * (this.z - vz) + vz; + //Distance between these and the cluster is the length through the detector + Point3D p1 = new Point3D(X1, Y1, Z1); + Point3D p2 = new Point3D(X2, Y2, Z2); + Point3D cluster = new Point3D(this.x, this.y, this.z); + double d1 = cluster.distance(p1); + double d2 = cluster.distance(p2); + //Returning the smallest distance, the other one is the opposite side + if (d1 > d2) { + return d2; + } else { + return d1; + } + } + + /** + * Computes the energy deposited in the wedges. + * + * @return the energy deposited in the wedges. + * + */ public double getEdepWedge() { double energy = 0; for (int i = 0; i < this.wedgeHits.size(); i++) { @@ -238,6 +309,12 @@ public double getEdepWedge() { return energy; } + /** + * Computes the energy deposited in the bars. + * + * @return the energy deposited in the bars. + * + */ public double getEdepBar() { double energy = 0; for (int i = 0; i < this.barHits.size(); i++) { @@ -251,7 +328,7 @@ public double getEdepBar() { * Compute the cluster phi angle in radians. * * @return a double that is angle in radians - * + * */ public double getPhi() { return Math.atan2(this.y, this.x); @@ -261,9 +338,9 @@ public double getPhi() { * Compute the cluster beta from the path length and time. * * @return a double that is beta - * + * * - TO DO: Change to non-hardcoded value for c - * + * */ public double getBeta() { //Need to change to non hardcoded value @@ -273,24 +350,25 @@ public double getBeta() { /** * Constructor that initializes the list of bar hits and list of wedge hits * and computes the cluster properties. - * + * * @param bar_hits a {@link ArrayList} of {@link BarHit}. * @param wedge_hits a {@link ArrayList} of {@link ATOFHit}. - * + * */ public ATOFCluster(ArrayList bar_hits, ArrayList wedge_hits) { this.barHits = bar_hits; this.wedgeHits = wedge_hits; this.computeClusterProperties(); } - + /** * Constructor that initializes the list of bar hits and list of wedge hits * and computes the cluster properties. - * + * * @param bar_hits a {@link ArrayList} of {@link BarHit}. * @param wedge_hits a {@link ArrayList} of {@link ATOFHit}. - * + * @param event a {@link DataEvent} with which track matching will be done. + * */ public ATOFCluster(ArrayList bar_hits, ArrayList wedge_hits, DataEvent event) { this.barHits = bar_hits; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java index cd599a14ee..e5deeb71db 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ClusterFinder.java @@ -94,7 +94,6 @@ public int computeDeltaModule(ATOFHit hit, ATOFHit otherhit) { public void clusterHits(int i, ArrayList hits, ATOFHit this_hit, double sigma_module, Number sigma_z, double sigma_t, int cluster_id, ArrayList this_cluster_hits) { // Loop through less energetic clusters for (int j = i + 1; j < hits.size(); j++) { - System.out.print("Getting other hit \n"); T other_hit = hits.get(j); // Skip already clustered hits if (other_hit.getIsInACluster()) { @@ -116,7 +115,6 @@ public void clusterHits(int i, ArrayList hits, ATOFHit th if (delta_module <= sigma_module) { if (condition_z) { if (delta_T < sigma_t) { - System.out.print("Clustered \n"); other_hit.setIsInACluster(true); other_hit.setAssociatedClusterIndex(cluster_id); this_cluster_hits.add(other_hit); @@ -130,8 +128,6 @@ public void clusterHits(int i, ArrayList hits, ATOFHit th * Builds clusters in the {@link DateEvent} using hits found and stored in a * {@link HitFinder}. * - * @param event the {@link DataEvent} containing the clusters to be built - * * @param hitfinder the {@link HitFinder} containing the hits that were * found * @@ -144,7 +140,7 @@ public void clusterHits(int i, ArrayList hits, ATOFHit th * @param sigma_t the tolerance for clustering in time [ns] * */ - public void makeClusters(DataEvent event, HitFinder hitfinder, double sigma_module, double sigma_component, double sigma_z, double sigma_t) { + public void makeClusters(HitFinder hitfinder, double sigma_module, double sigma_component, double sigma_z, double sigma_t, DataEvent event) { //A list of clusters is built for each event clusters.clear(); @@ -179,7 +175,7 @@ public void makeClusters(DataEvent event, HitFinder hitfinder, double sigma_modu clusterHits(-1, bar_hits, this_wedge_hit, sigma_module, sigma_z, sigma_t, cluster_id, this_cluster_bar_hits); //After all wedge and bar hits have been grouped, build the cluster - ATOFCluster cluster = new ATOFCluster(this_cluster_bar_hits, this_cluster_wedge_hits, event); + ATOFCluster cluster = new ATOFCluster(this_cluster_bar_hits, this_cluster_wedge_hits,event); //And add it to the list of clusters clusters.add(cluster); cluster_id++; @@ -220,11 +216,11 @@ public void makeClusters(DataEvent event, HitFinder hitfinder, double sigma_modu * */ public void makeClusters(DataEvent event, HitFinder hitfinder) { - makeClusters(event, hitfinder, + makeClusters(hitfinder, Parameters.SIGMA_MODULE_CLUSTERING, Parameters.SIGMA_COMPONENT_CLUSTERING, Parameters.SIGMA_Z_CLUSTERING, - Parameters.SIGMA_T_CLUSTERING); + Parameters.SIGMA_T_CLUSTERING, event); } /** From 4bc755d8e1f195f88e3a65e2aa266c180be3780b Mon Sep 17 00:00:00 2001 From: N-Plx Date: Fri, 21 Feb 2025 18:05:08 -0600 Subject: [PATCH 04/20] feat: handling track-cluster matching for events with more than one track, track projection indices in the out banks --- etc/bankdefs/hipo4/alert.json | 12 +++- .../jlab/rec/atof/banks/RecoBankWriter.java | 6 +- .../jlab/rec/atof/cluster/ATOFCluster.java | 68 +++++++++++++------ 3 files changed, 62 insertions(+), 24 deletions(-) diff --git a/etc/bankdefs/hipo4/alert.json b/etc/bankdefs/hipo4/alert.json index 4f3d8b9f13..af209ec718 100644 --- a/etc/bankdefs/hipo4/alert.json +++ b/etc/bankdefs/hipo4/alert.json @@ -6,10 +6,14 @@ "info": "Track Projections to ATOF", "entries": [ { + "name": "id", + "type": "S", + "info": "projection id" + }, { "name": "x_at_bar", "type": "F", "info": "x position at atof bar (middle surface) in mm" - }, { + },{ "name": "y_at_bar", "type": "F", "info": "y position at atof bar (middle surface) in mm" @@ -91,7 +95,7 @@ "info": "deposited energy in MeV" },{ "name": "clusterid", - "type": "I", + "type": "S", "info": "id of cluster to which the hit was associated" } ] @@ -141,6 +145,10 @@ "name": "inpathlength", "type": "F", "info": "path length inside the detector in mm" + },{ + "name": "projID", + "type": "S", + "info": "id of the projected track matched. it is -1 if a straight track was assigned." } ] },{ diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java index 1e5cf33fb3..e3976a6099 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java @@ -43,7 +43,7 @@ public static DataBank fillATOFHitBank(DataEvent event, ArrayList wedge for (int i = 0; i < hitList.size(); i++) { bank.setShort("id", i, (short) (i + 1)); - bank.setInt("clusterid", i, (int) hitList.get(i).getAssociatedClusterIndex()); + bank.setShort("clusterid", i, (short) hitList.get(i).getAssociatedClusterIndex()); bank.setInt("sector", i, (int) hitList.get(i).getSector()); bank.setInt("layer", i, (int) hitList.get(i).getLayer()); bank.setInt("component", i, (int) hitList.get(i).getComponent()); @@ -86,7 +86,8 @@ public static DataBank fillATOFClusterBank(DataEvent event, ArrayList getBarHits() { return barHits; @@ -117,6 +118,14 @@ public String getTypeMaxHit() { public void setTypeMaxHit(String typeMaxHit) { this.typeMaxHit = typeMaxHit; } + + public int getIProj() { + return iProj; + } + + public void setIProj(int iProj) { + this.iProj = iProj; + } /** * Compute the cluster properties. @@ -171,22 +180,32 @@ public final void computeClusterProperties() { * */ public int matchTrack(DataEvent event) { + + //This cluster point in space + Point3D cluster = new Point3D(this.x, this.y, this.z); + //Bank to be read String track_bank_name = "ALERT::Projections"; - if (event == null) { // check if there is an event - //System.out.print(" no event \n"); + //Checking if there is an event + if (event == null) { return 1; } else if (event.hasBank(track_bank_name) == false) { - // check if there are ahdc tracks in the event - //System.out.print("no tracks \n"); + //Check if there are tracks in the event //If it is not the case, assign a straight track this.makeStraightTrack(); return 1; } else { + //There are tracks in the event DataBank track_bank = event.getBank(track_bank_name); int nt = track_bank.rows(); // number of tracks double sigma_phi = 0; double sigma_z = 0; + //This will help decide which track to consider + //when more than one are matched to the same cluster + double distanceMinBetweenTrackAndCluster = 999; + + //Check if a track was matched + Boolean foundMatch = false; //Looping through all tracks for (int i = 0; i < nt; i++) { Float xt = null, yt = null, zt = null, path = null, inpath = null; @@ -222,25 +241,32 @@ public int matchTrack(DataEvent event) { } Point3D projection_point = new Point3D(xt, yt, zt); double delta_phi = Math.abs(this.getPhi() - projection_point.toVector3D().phi()); - if (delta_phi > Math.PI) { - delta_phi = Math.PI - delta_phi; - } + if (delta_phi > Math.PI) delta_phi = Math.PI - delta_phi; + //Geometrical match if (delta_phi < sigma_phi && Math.abs(this.getZ() - projection_point.z()) < sigma_z) { - //If a track is matched, write the path lengths - this.setPathLength(path); - this.setInPathLength(inpath); - } else { + foundMatch=true; + //If a track is matched, we look at the distance between it and the cluster + double distance = cluster.distance(projection_point); + //We only consider the minimal distance track + if (distance < distanceMinBetweenTrackAndCluster) { + distanceMinBetweenTrackAndCluster = distance; + this.setPathLength(path); + this.setInPathLength(inpath); + this.setIProj(track_bank.getInt("id", i)); + } + } + } + if(!foundMatch) { //If no track is matched, assign a straight track this.makeStraightTrack(); } - } } return 0; } /** * Build a straight track from the vertex to this cluster. - * + * * Sets the cluster path length and length through the atof from it. * */ @@ -250,17 +276,19 @@ public void makeStraightTrack() { double straightPath = vertexToCluster.length(); this.setPathLength(straightPath); this.setInPathLength(getDistanceStraightInATOF(vx, vy, vz)); + //ID indicating no track was matched + this.setIProj(-1); } /** - * Computes the distance a straight track goes through the ATOF. - * The intersection point between a straight track from the vertex - * to the cluster and the ATOF inner cylinder is computed to that end. - * + * Computes the distance a straight track goes through the ATOF. The + * intersection point between a straight track from the vertex to the + * cluster and the ATOF inner cylinder is computed to that end. + * * @param vx, the x coordinate of the vertex * @param vy, the y coordinate of the vertex * @param vz, the z coordinate of the vertex - * + * * @return the distance the straight track went through in the ATOF * */ @@ -296,7 +324,7 @@ public double getDistanceStraightInATOF(double vx, double vy, double vz) { /** * Computes the energy deposited in the wedges. - * + * * @return the energy deposited in the wedges. * */ @@ -311,7 +339,7 @@ public double getEdepWedge() { /** * Computes the energy deposited in the bars. - * + * * @return the energy deposited in the bars. * */ From cd9acdcb0eb0203ee0443e09e66b693b65d09bc6 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Fri, 21 Feb 2025 18:27:56 -0600 Subject: [PATCH 05/20] feat: saving track ID in projection bank --- etc/bankdefs/hipo4/alert.json | 4 ++ .../alert/projections/TrackProjection.java | 10 ++++ .../rec/alert/projections/TrackProjector.java | 52 +++++++++---------- .../jlab/rec/atof/banks/RecoBankWriter.java | 2 +- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/etc/bankdefs/hipo4/alert.json b/etc/bankdefs/hipo4/alert.json index af209ec718..611babce13 100644 --- a/etc/bankdefs/hipo4/alert.json +++ b/etc/bankdefs/hipo4/alert.json @@ -9,6 +9,10 @@ "name": "id", "type": "S", "info": "projection id" + },{ + "name": "trackID", + "type": "S", + "info": "id of the track that was projected" }, { "name": "x_at_bar", "type": "F", diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java index d69cf3e2ef..d1e577ec91 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjection.java @@ -42,6 +42,8 @@ public class TrackProjection { */ Float wedgeInPathLength; + int trackID; + /** * Default constructor that initializes the intersection points and path lengths to {@code NaN}. @@ -165,6 +167,14 @@ public void setWedgeInPathLength(Float WedgeInPathLength) { this.wedgeInPathLength = WedgeInPathLength; } + public void setTrackID(int trackID) { + this.trackID = trackID; + } + + public int getTrackID() { + return trackID; + } + /** * testing purposes. * diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java index 3cb4fbcaf4..4113857968 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java @@ -30,7 +30,7 @@ public class TrackProjector { * projections of tracks. */ private ArrayList projections; - + /** * solenoid magnitude */ @@ -54,8 +54,8 @@ public TrackProjector() { public ArrayList getProjections() { return projections; } - - /** + + /** * Gets the solenoid magnitude * * @return solenoid magnitude @@ -72,8 +72,8 @@ public Double getB() { public void setProjections(ArrayList Projections) { this.projections = Projections; } - - /** + + /** * Sets the solenoid magnitude. * * @param B a double. @@ -91,9 +91,8 @@ public void setB(Double B) { public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) { projections.clear(); - - String track_bank_name = "AHDC::Track"; + String track_bank_name = "AHDC::Track"; if (event == null) { // check if there is an event //System.out.print(" no event \n"); } else if (event.hasBank(track_bank_name) == false) { @@ -104,13 +103,13 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) int nt = bank.rows(); // number of tracks TrackProjection projection = new TrackProjection(); for (int i = 0; i < nt; i++) { - double x = bank.getFloat("x", i); double y = bank.getFloat("y", i); double z = bank.getFloat("z", i); double px = bank.getFloat("px", i); double py = bank.getFloat("py", i); double pz = bank.getFloat("pz", i); + int id = nt + 1;//To be replaced by track id if it is added to the out bank int q = -1; //need the charge sign from tracking @@ -120,7 +119,7 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) double yb = 0; //momenta must be in GeV for the helix class - Helix helix = new Helix(x, y, z, px/1000., py/1000., pz/1000., q, b, xb, yb, units); + Helix helix = new Helix(x, y, z, px / 1000., py / 1000., pz / 1000., q, b, xb, yb, units); //Intersection points with the middle of the bar or wedge projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); @@ -129,25 +128,26 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) //Path length to the middle of the bar or wedge projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS))); projection.setWedgePathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_INNER_RADIUS))); - + //Path length from the inner radius to the middle radius projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength()); projection.setWedgeInPathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_MIDDLE_RADIUS)) - projection.getWedgePathLength()); + projection.setTrackID(id); projections.add(projection); } + } } - + /** - * Projects the MC particles onto the atof using a {@link Helix} - * model. + * Projects the MC particles onto the atof using a {@link Helix} model. * * @param event the {@link DataEvent} containing track data to be projected. */ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) { projections.clear(); - + String track_bank_name = "MC::Particle"; if (event == null) { // check if there is an event //System.out.print(" no event \n"); @@ -168,15 +168,14 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd double px = bank.getFloat("px", i); double py = bank.getFloat("py", i); double pz = bank.getFloat("pz", i); - + int id = bank.getShort("id", i); //Put everything in MM + x = x * 10; + y = y * 10; + z = z * 10; - x = x*10; - y = y*10; - z = z*10; + Units units = Units.MM; - Units units = Units.MM; - int q = -1; //need the charge sign from tracking double xb = 0; @@ -186,24 +185,23 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd Helix helix = new Helix(x, y, z, px, py, pz, q, b, xb, yb, units); //Intersection points with the middle of the bar or wedge - projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); + projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); //Path length to the middle of the bar or wedge - - projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS))); + projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS))); projection.setWedgePathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_INNER_RADIUS))); - - //Path length from the inner radius to the middle radius - projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength()); + //Path length from the inner radius to the middle radius + projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength()); projection.setWedgeInPathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_MIDDLE_RADIUS)) - projection.getWedgePathLength()); + projection.setTrackID(id); projections.add(projection); } } } public static void main(String arg[]) { - + } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java index e3976a6099..b903b71f57 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java @@ -111,10 +111,10 @@ public static DataBank fillProjectionsBank(DataEvent event, ArrayList Date: Tue, 25 Feb 2025 10:35:58 -0600 Subject: [PATCH 06/20] feat: ignoring double barhits --- .../java/org/jlab/rec/atof/hit/HitFinder.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java index 4a9592cb21..e7bd0ef38b 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java @@ -8,13 +8,13 @@ /** * The {@code HitFinder} class finds hits in the atof. - * + * *

- * Uses atof tdc bank information - * - * Creates a {@link ArrayList} of {@link BarHit} for bar hits read. - * Creates a {@link ArrayList} of {@link ATOFHit} for wedge hits read. - * + * Uses atof tdc bank information + * + * Creates a {@link ArrayList} of {@link BarHit} for bar hits read. Creates a + * {@link ArrayList} of {@link ATOFHit} for wedge hits read. + * *

* * @author pilleux @@ -31,8 +31,7 @@ public class HitFinder { private ArrayList wedgeHits; /** - * Default constructor that initializes the list of hits as new empty - * lists. + * Default constructor that initializes the list of hits as new empty lists. */ public HitFinder() { this.barHits = new ArrayList<>(); @@ -57,8 +56,8 @@ public void setWedgeHits(ArrayList wedge_hits) { } /** - * Find hits in the event, matches them to tracks found in the ahdc - * and build their properties. + * Find hits in the event, matches them to tracks found in the ahdc and + * build their properties. * * @param event the {@link DataEvent} containing hits. * @param atof the {@link Detector} representing the atof geometry to match @@ -74,6 +73,7 @@ public void findHits(DataEvent event, Detector atof) { //Hits in the bar downstream and upstream will be matched ArrayList hit_up = new ArrayList<>(); ArrayList hit_down = new ArrayList<>(); + //Looping through all hits for (int i = 0; i < nt; i++) { //Getting their properties @@ -83,11 +83,13 @@ public void findHits(DataEvent event, Detector atof) { int order = bank.getInt("order", i); int tdc = bank.getInt("TDC", i); int tot = bank.getInt("ToT", i); + //Building a Hit ATOFHit hit = new ATOFHit(sector, layer, component, order, tdc, tot, atof); if (hit.getEnergy() < 0.01) { continue; //energy threshold } + //Sorting the hits into wedge, upstream and downstream bar hits //Lists are built for up/down bar to match them after //Wedge hits are mayched to ahdc tracks and listed @@ -111,14 +113,21 @@ public void findHits(DataEvent event, Detector atof) { //Starting loop through up hits in the bar for (int i_up = 0; i_up < hit_up.size(); i_up++) { ATOFHit this_hit_up = hit_up.get(i_up); + int countMatches = 0; //Starting loop through down hits in the bar for (int i_down = 0; i_down < hit_down.size(); i_down++) { ATOFHit this_hit_down = hit_down.get(i_down); //Matching the hits: if same module and different order, they make up a bar hit if (this_hit_up.matchBar(this_hit_down)) { //Bar hits are matched to ahdc tracks and listed - BarHit this_bar_hit = new BarHit(this_hit_up, this_hit_down); + if (countMatches > 0) { + //If the up hit was already involved in a match, do not make an additionnal match + //Chosing to ignore double matches for now because it happened for <1% of events in cosmic runs + continue; + } + BarHit this_bar_hit = new BarHit(this_hit_down, this_hit_up); this.barHits.add(this_bar_hit); + countMatches++; } } } From db708bdff02f32909ba10afa2e768ce5c51776b8 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Tue, 25 Feb 2025 15:14:28 -0600 Subject: [PATCH 07/20] feat: computing helix path length between points on the helix --- .../jlab/clas/tracking/trackrep/Helix.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/trackrep/Helix.java b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/trackrep/Helix.java index 1351a9f8c5..172e39b070 100644 --- a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/trackrep/Helix.java +++ b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/trackrep/Helix.java @@ -412,6 +412,39 @@ public Vector3D getMomentumAtZ(double z) { return new Vector3D(getPx(getB(),l),getPy(getB(),l),getPz(getB())); } + /** + * Computes the path length between to points at radius rMin and rMax of the + * helix. + * + * @param rMin the radius of the point from which to measure. + * @param rMax the radius of the point to which to measure. + * + * helix parametrization is X(l) = xc - s*R*sin(phi0+omega*l) Y(l) = yc + + * s*R*cos(phi0+omega*l) Z(l) = z0 - l*tanL + * + * d^2 = (dX/dl)^2 + (dY/dl)^2 + (dZ/dl)^2 + * + * pathlength = integral of d(l) from l(rMin) to l(rMax) pathlength = + * sqrt(R^2omega^2+tanL^2)*(l(rMax)-l(rMin)) + * + * @author pilleux + * + */ + public double getPathLength(double rMin, double rMax) { + + double s = (double) -KFitter.polarity * getTurningSign(); + + if (rMax <= rMin) { + System.out.print("Cannot compute path length, max radius smaller than min radius ! \n"); + return 0; + } + double l0 = this.getLAtR(rMin); + double l1 = this.getLAtR(rMax); + double term1 = this.getOmega() * s * this.getR(); + double term2 = this.getTanL(); + return Math.abs((l1 - l0) * Math.sqrt(term1 * term1 + term2 * term2)); + } + @Override public String toString() { String s = String.format(" drho=%.4f phi0=%.4f radius=%.4f z0=%.4f tanL=%.4f B=%.4f\n", this._d0, this._phi0, this._R, this._z0, this._tanL, this._B); From 9a071b4f2cff404050cb4270311ab7e032f1df71 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Tue, 25 Feb 2025 15:30:55 -0600 Subject: [PATCH 08/20] fix: correct path length definition --- .../rec/alert/projections/TrackProjector.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java index 4113857968..4807be813f 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java @@ -1,7 +1,6 @@ package org.jlab.rec.alert.projections; import java.util.ArrayList; - import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.clas.tracking.trackrep.Helix; @@ -91,7 +90,6 @@ public void setB(Double B) { public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) { projections.clear(); - String track_bank_name = "AHDC::Track"; if (event == null) { // check if there is an event //System.out.print(" no event \n"); @@ -125,13 +123,14 @@ public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); - //Path length to the middle of the bar or wedge - projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS))); - projection.setWedgePathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_INNER_RADIUS))); + double rVertex = Math.sqrt(x * x + y * y); + //Path length to the middle of the bar or wedge + projection.setBarPathLength((float) helix.getPathLength(rVertex, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgePathLength((float) helix.getPathLength(rVertex, Parameters.WEDGE_MIDDLE_RADIUS)); //Path length from the inner radius to the middle radius - projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength()); - projection.setWedgeInPathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_MIDDLE_RADIUS)) - projection.getWedgePathLength()); + projection.setBarInPathLength((float) helix.getPathLength(Parameters.BAR_INNER_RADIUS, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgeInPathLength((float) helix.getPathLength(Parameters.WEDGE_INNER_RADIUS, Parameters.WEDGE_MIDDLE_RADIUS)); projection.setTrackID(id); projections.add(projection); } @@ -158,7 +157,6 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd DataBank bank = event.getBank(track_bank_name); int nt = bank.rows(); // number of tracks TrackProjection projection = new TrackProjection(); - DataBank outputBank = event.createBank("ALERT::Projections", nt); for (int i = 0; i < nt; i++) { @@ -188,13 +186,15 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); - //Path length to the middle of the bar or wedge - projection.setBarPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_INNER_RADIUS))); - projection.setWedgePathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_INNER_RADIUS))); + double rVertex = Math.sqrt(x * x + y * y); + //Path length to the middle of the bar or wedge + projection.setBarPathLength((float) helix.getPathLength(rVertex, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgePathLength((float) helix.getPathLength(rVertex, Parameters.WEDGE_MIDDLE_RADIUS)); //Path length from the inner radius to the middle radius - projection.setBarInPathLength((float) Math.abs(helix.getLAtR(Parameters.BAR_MIDDLE_RADIUS)) - projection.getBarPathLength()); - projection.setWedgeInPathLength((float) Math.abs(helix.getLAtR(Parameters.WEDGE_MIDDLE_RADIUS)) - projection.getWedgePathLength()); + projection.setBarInPathLength((float) helix.getPathLength(Parameters.BAR_INNER_RADIUS, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgeInPathLength((float) helix.getPathLength(Parameters.WEDGE_INNER_RADIUS, Parameters.WEDGE_MIDDLE_RADIUS)); + projection.setTrackID(id); projections.add(projection); } From cf43a11da6b446236c64bc5a420afd5efb577088 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Wed, 26 Feb 2025 15:20:40 -0600 Subject: [PATCH 09/20] feat: computing maximal energy hit in clusters --- .../jlab/rec/atof/cluster/ATOFCluster.java | 119 ++++++++++++++++-- 1 file changed, 106 insertions(+), 13 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java index 4b8f9e93cb..e04ccee1e3 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java @@ -32,11 +32,12 @@ public class ATOFCluster { /** * cluster properties:position [cm], time [ns], energy[MeV], path length * [cm] and length through the atof [cm], type of the maximum hit (to set - * resolutions). + * resolutions) and index of the maximum hit. */ double x, y, z, time, energy; double pathLength, inPathLength; String typeMaxHit; + int indexMaxHit; int iProj; public ArrayList getBarHits() { @@ -118,7 +119,7 @@ public String getTypeMaxHit() { public void setTypeMaxHit(String typeMaxHit) { this.typeMaxHit = typeMaxHit; } - + public int getIProj() { return iProj; } @@ -127,6 +128,14 @@ public void setIProj(int iProj) { this.iProj = iProj; } + public int getIndexMaxHit() { + return indexMaxHit; + } + + public void setIndexMaxHit(int indexMaxHit) { + this.indexMaxHit = indexMaxHit; + } + /** * Compute the cluster properties. * @@ -180,13 +189,13 @@ public final void computeClusterProperties() { * */ public int matchTrack(DataEvent event) { - + //This cluster point in space Point3D cluster = new Point3D(this.x, this.y, this.z); //Bank to be read String track_bank_name = "ALERT::Projections"; //Checking if there is an event - if (event == null) { + if (event == null) { return 1; } else if (event.hasBank(track_bank_name) == false) { //Check if there are tracks in the event @@ -203,7 +212,7 @@ public int matchTrack(DataEvent event) { //This will help decide which track to consider //when more than one are matched to the same cluster double distanceMinBetweenTrackAndCluster = 999; - + //Check if a track was matched Boolean foundMatch = false; //Looping through all tracks @@ -241,10 +250,12 @@ public int matchTrack(DataEvent event) { } Point3D projection_point = new Point3D(xt, yt, zt); double delta_phi = Math.abs(this.getPhi() - projection_point.toVector3D().phi()); - if (delta_phi > Math.PI) delta_phi = Math.PI - delta_phi; + if (delta_phi > Math.PI) { + delta_phi = Math.PI - delta_phi; + } //Geometrical match if (delta_phi < sigma_phi && Math.abs(this.getZ() - projection_point.z()) < sigma_z) { - foundMatch=true; + foundMatch = true; //If a track is matched, we look at the distance between it and the cluster double distance = cluster.distance(projection_point); //We only consider the minimal distance track @@ -254,12 +265,12 @@ public int matchTrack(DataEvent event) { this.setInPathLength(inpath); this.setIProj(track_bank.getInt("id", i)); } - } - } - if(!foundMatch) { - //If no track is matched, assign a straight track - this.makeStraightTrack(); } + } + if (!foundMatch) { + //If no track is matched, assign a straight track + this.makeStraightTrack(); + } } return 0; } @@ -277,7 +288,7 @@ public void makeStraightTrack() { this.setPathLength(straightPath); this.setInPathLength(getDistanceStraightInATOF(vx, vy, vz)); //ID indicating no track was matched - this.setIProj(-1); + this.setIProj(-1); } /** @@ -375,6 +386,66 @@ public double getBeta() { return (this.pathLength / this.time) / (2.9979 * Math.pow(10, 2)); } + /** + * Retrieve the hit with maximal energy in the cluster. It must have been + * computed previously. + * + * @return a ATOFHit that is the maximal energy hit in the cluster + * + */ + public final ATOFHit getMaxHit() { + if (this.typeMaxHit == null) { + System.out.print("You did not compute the maximal hit! \n"); + return null; + } + if (null == this.typeMaxHit) { + System.out.print("Unrecognized type! \n"); + return null; + } else { + switch (this.typeMaxHit) { + case "wedge" -> { + return this.wedgeHits.get(this.indexMaxHit); + } + case "bar" -> { + return this.barHits.get(this.indexMaxHit); + } + default -> { + System.out.print("Unrecognized type! \n"); + return null; + } + } + } + } + + /** + * Computes the sum of TOT in the cluster. + * + * @return an int representing the summed TOT + * + */ + public int getTot() { + int tot = 0; + for (int i = 0; i < this.wedgeHits.size(); i++) { + ATOFHit this_hit = this.wedgeHits.get(i); + tot += this_hit.getTot(); + } + for (int i = 0; i < this.barHits.size(); i++) { + BarHit this_hit = this.barHits.get(i); + tot += this_hit.getTot(); + } + return tot; + } + + /** + * Returns the TDC of the maximal hit in the cluster. + * + * @return an int representing the TDC of the maximal hit. + * + */ + public int getTdc() { + return this.getMaxHit().getTdc(); + } + /** * Constructor that initializes the list of bar hits and list of wedge hits * and computes the cluster properties. @@ -405,6 +476,28 @@ public ATOFCluster(ArrayList bar_hits, ArrayList wedge_hits, Da this.matchTrack(event); } + /** + * Computes the wedge hit with maximal energy in the cluster. + * + * @return a ATOFHit that is the maximal energy hit in the wedges in the + * cluster. + * + */ + public final ATOFHit getMaxWedgeHit() { + double max_energy = -1; + ATOFHit max_energy_hit = new ATOFHit(); + + for (int i_wedge = 0; i_wedge < this.wedgeHits.size(); i_wedge++) { + ATOFHit this_wedge_hit = this.wedgeHits.get(i_wedge); + double this_energy = this_wedge_hit.getEnergy(); + if (this_energy > max_energy) { + max_energy_hit = this_wedge_hit; + max_energy = this_energy; + } + } + return max_energy_hit; + } + /** * @param args the command line arguments */ From f0db0a46be41e02f06ec4826774eb1c6349622c1 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Wed, 26 Feb 2025 15:21:35 -0600 Subject: [PATCH 10/20] feat: tdc entry id matched to hit --- .../java/org/jlab/rec/atof/hit/ATOFHit.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java index 06e530d1df..122c4c7f2d 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java @@ -21,6 +21,7 @@ public class ATOFHit { private String type; private boolean isInACluster; private int associatedClusterIndex; + int idTDC; public int getSector() { return sector; @@ -125,7 +126,7 @@ public boolean getIsInACluster() { public void setIsInACluster(boolean is_in_a_cluster) { this.isInACluster = is_in_a_cluster; } - + public int getAssociatedClusterIndex() { return associatedClusterIndex; } @@ -134,6 +135,14 @@ public void setAssociatedClusterIndex(int index) { this.associatedClusterIndex = index; } + public int getIdTDC() { + return idTDC; + } + + public void setIdTDC(int index) { + this.idTDC = index; + } + /** * Computes the module index for the hit. * @@ -143,7 +152,7 @@ public int computeModuleIndex() { return 4 * this.sector + this.layer; } - /** + /** * Assigns a type to the hit. * */ @@ -300,8 +309,8 @@ public final int convertSLCToXYZ(Detector atof) { * returns {@code false}. *
  • If either hit is not in the bar (component must be 10), the method * returns {@code false}.
  • - *
  • If both hits are in the same SiPM (i.e., their order is the same), - * or have incorrect order, the method returns {@code false}.
  • + *
  • If both hits are in the same SiPM (i.e., their order is the same), or + * have incorrect order, the method returns {@code false}.
  • * * If none of these conditions are violated, the method returns * {@code true}, indicating the two hits match. @@ -312,16 +321,16 @@ public final int convertSLCToXYZ(Detector atof) { public boolean matchBar(ATOFHit hit2match) { if (this.getSector() != hit2match.getSector()) { //Two hits in different sectors - return false; + return false; } else if (this.getLayer() != hit2match.getLayer()) { //Two hits in different layers - return false; + return false; } else if (this.getComponent() != 10 || hit2match.getComponent() != 10) { //At least one hit not in the bar - return false; + return false; } else if (this.getOrder() > 1 || hit2match.getOrder() > 1) { //At least one hit has incorrect order - return false; + return false; } else { //Match if one is order 0 and the other is order 1 return this.getOrder() != hit2match.getOrder(); @@ -366,9 +375,9 @@ public ATOFHit(int sector, int layer, int component, int order, int tdc, int tot this.convertSLCToXYZ(atof); } - public ATOFHit(){ + public ATOFHit() { } - + /** * @param args the command line arguments */ From 9a2c6fe48d87f2de6eff91087712074ff18877de Mon Sep 17 00:00:00 2001 From: N-Plx Date: Wed, 26 Feb 2025 15:22:42 -0600 Subject: [PATCH 11/20] feat: tdc and tot are filled for barhits --- .../alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java index bbd8fd5316..87b186eb50 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java @@ -91,6 +91,8 @@ public BarHit(ATOFHit hit_down, ATOFHit hit_up) { this.computeZ(); this.computeTime(); this.computeEnergy(); + this.setTdc((hit_down.getTdc() + hit_up.getTdc())/2); + this.setTot((hit_down.getTot() + hit_up.getTot())); } public BarHit() { From 449b00a58e44eb42f064d5cd08ef689684b926d0 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Wed, 26 Feb 2025 18:22:47 -0600 Subject: [PATCH 12/20] feat: new engine and new banks for atof tests --- etc/bankdefs/hipo4/alert.json | 104 +++++++++++++++++ .../jlab/rec/atof/banks/TestBankWriter.java | 109 ++++++++++++++++++ .../org/jlab/rec/service/ATOFTestEngine.java | 105 +++++++++++++++++ .../service => service/atof}/ATOFEngine.java | 0 4 files changed, 318 insertions(+) create mode 100644 reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java create mode 100644 reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java rename reconstruction/alert/src/main/java/org/jlab/{rec/service => service/atof}/ATOFEngine.java (100%) diff --git a/etc/bankdefs/hipo4/alert.json b/etc/bankdefs/hipo4/alert.json index 611babce13..2fead678ae 100644 --- a/etc/bankdefs/hipo4/alert.json +++ b/etc/bankdefs/hipo4/alert.json @@ -103,6 +103,62 @@ "info": "id of cluster to which the hit was associated" } ] + },{ + "name": "ATOF::testhits", + "group": 22500, + "item": 31, + "info": "Reconstructed ATOF hits", + "entries": [ + { + "name": "id", + "type": "S", + "info": "hit id" + }, { + "name": "sector", + "type": "I", + "info": "atof sector" + }, { + "name": "layer", + "type": "I", + "info": "atof layer" + },{ + "name": "component", + "type": "I", + "info": "atof component" + },{ + "name": "time", + "type": "F", + "info": "time in ns" + },{ + "name": "TDC", + "type": "I", + "info": "TDC" + },{ + "name": "x", + "type": "F", + "info": "x position in mm" + }, { + "name": "y", + "type": "F", + "info": "y position in mm" + }, { + "name": "z", + "type": "F", + "info": "z position in mm" + },{ + "name": "energy", + "type": "F", + "info": "deposited energy in MeV" + },{ + "name": "TOT", + "type": "I", + "info": "TOT" + },{ + "name": "clusterid", + "type": "S", + "info": "id of cluster to which the hit was associated" + } + ] },{ "name": "ATOF::clusters", "group": 22500, @@ -155,6 +211,54 @@ "info": "id of the projected track matched. it is -1 if a straight track was assigned." } ] + },{ + "name": "ATOF::testclusters", + "group": 22500, + "item": 32, + "info": "Clusters in ATOF", + "entries": [ + { + "name": "id", + "type": "S", + "info": "hit id" + }, { + "name": "N_bar", + "type": "I", + "info": "number of hits from the bars" + }, { + "name": "N_wedge", + "type": "I", + "info": "number of hits from the wedges" + },{ + "name": "time", + "type": "F", + "info": "time in ns" + },{ + "name": "TDC", + "type": "I", + "info": "TDC" + },{ + "name": "x", + "type": "F", + "info": "x position in mm" + }, { + "name": "y", + "type": "F", + "info": "y position in mm" + }, { + "name": "z", + "type": "F", + "info": "z position in mm" + },{ + "name": "energy", + "type": "F", + "info": "energy in MeV" + },{ + "name": "TOT", + "type": "I", + "info": "TOT" + } + ] },{ "name": "AHDC::Hits", "group": 23000, diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java new file mode 100644 index 0000000000..f1a975ff3b --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java @@ -0,0 +1,109 @@ +package org.jlab.rec.atof.banks; + +import java.util.ArrayList; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.atof.cluster.ATOFCluster; +import org.jlab.rec.atof.hit.ATOFHit; +import org.jlab.rec.atof.hit.BarHit; + +/** + * The {@code RecoBankWriter} writes the banks needed for the atof + * testing: hits and clusters info. + * + * @author pilleux + */ +public class TestBankWriter { + + + public static DataBank fillATOFTestHitBank(DataEvent event, ArrayList wedgeHits, ArrayList barHits) { + ArrayList hitList = new ArrayList<>(); + hitList.addAll(wedgeHits); + hitList.addAll(barHits); + DataBank bank = event.createBank("ATOF::testhits", hitList.size()); + if (bank == null) { + System.err.println("COULD NOT CREATE A ATOF::testhits BANK!!!!!!"); + return null; + } + + for (int i = 0; i < hitList.size(); i++) { + bank.setShort("id", i, (short) (i + 1)); + bank.setShort("clusterid", i, (short) hitList.get(i).getAssociatedClusterIndex()); + bank.setInt("sector", i, (int) hitList.get(i).getSector()); + bank.setInt("layer", i, (int) hitList.get(i).getLayer()); + bank.setInt("component", i, (int) hitList.get(i).getComponent()); + bank.setInt("TDC", i, (int) hitList.get(i).getTdc()); + bank.setFloat("time", i, (float) hitList.get(i).getTime()); + bank.setFloat("x", i, (float) (hitList.get(i).getX())); + bank.setFloat("y", i, (float) (hitList.get(i).getY())); + bank.setFloat("z", i, (float) (hitList.get(i).getZ())); + bank.setInt("TOT", i, (int) hitList.get(i).getTot()); + bank.setFloat("energy", i, (float) hitList.get(i).getEnergy()); + } + return bank; + } + + public static DataBank fillATOFTestClusterBank(DataEvent event, ArrayList clusterList) { + + DataBank bank = event.createBank("ATOF::testclusters", clusterList.size()); + + if (bank == null) { + System.err.println("COULD NOT CREATE A ATOF::testclusters BANK!!!!!!"); + return null; + } + + for (int i = 0; i < clusterList.size(); i++) { + bank.setShort("id", i, (short) (i + 1)); + bank.setInt("N_bar", i, (int) clusterList.get(i).getBarHits().size()); + bank.setInt("N_wedge", i, (int) clusterList.get(i).getWedgeHits().size()); + bank.setInt("TDC", i, (int) clusterList.get(i).getTdc()); + bank.setFloat("time", i, (float) clusterList.get(i).getTime()); + bank.setFloat("x", i, (float) (clusterList.get(i).getX())); + bank.setFloat("y", i, (float) (clusterList.get(i).getY())); + bank.setFloat("z", i, (float) (clusterList.get(i).getZ())); + bank.setInt("TOT", i, (int) clusterList.get(i).getTot()); + bank.setFloat("energy", i, (float) clusterList.get(i).getEnergy()); + } + return bank; + } + + /** + * Appends the atof banks to an event. + * + * @param event the {@link DataEvent} in which to append the banks + * @param clusterList the {@link ArrayList} of {@link ATOFCluster} + * containing the clusters info to be added to the bank + * @param wedgeHits the {@link ArrayList} of {@link ATOFHit} containing the + * wedge hits info to be added + * @param barHits the {@link ArrayList} of {@link BarHit} containing the bar + * hits info to be added + * + * @return 0 if it worked, 1 if it failed + * + */ + public int appendATOFBanks(DataEvent event, ArrayList wedgeHits, ArrayList barHits, ArrayList clusterList) { + + DataBank hitbank = this.fillATOFTestHitBank(event, wedgeHits, barHits); + if (hitbank != null) { + event.appendBank(hitbank); + } else { + return 1; + } + + DataBank clusterbank = fillATOFTestClusterBank(event, clusterList); + if (clusterbank != null) { + event.appendBank(clusterbank); + } else { + return 1; + } + + return 0; + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } + +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java b/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java new file mode 100644 index 0000000000..5ed64a5f76 --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java @@ -0,0 +1,105 @@ +package org.jlab.rec.service; + +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; + +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; + +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.geom.base.Detector; +import org.jlab.geom.detector.alert.ATOF.AlertTOFFactory; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.rec.atof.banks.TestBankWriter; +import org.jlab.rec.atof.cluster.ATOFCluster; +import org.jlab.rec.atof.cluster.ClusterFinder; +import org.jlab.rec.atof.constants.Parameters; +import org.jlab.rec.atof.hit.ATOFHit; +import org.jlab.rec.atof.hit.BarHit; +import org.jlab.rec.atof.hit.HitFinder; + +/** + * Service to return ATOF test hits and clusters + * + * @author npilleux + * + */ +public class ATOFTestEngine extends ReconstructionEngine { + + public ATOFTestEngine() { + super("ATOFTest", "pilleux", "1.0"); + } + + TestBankWriter rbc; + + private Detector ATOF; + + public void setATOF(Detector ATOF) { + this.ATOF = ATOF; + } + + public Detector getATOF() { + return ATOF; + } + + @Override + public boolean processDataEvent(DataEvent event) { + + if (!event.hasBank("RUN::config")) { + return true; + } + + DataBank bank = event.getBank("RUN::config"); + + int newRun = bank.getInt("run", 0); + if (newRun == 0) { + return true; + } + + //Hit finder init + HitFinder hitfinder = new HitFinder(); + hitfinder.findHits(event, ATOF); + + ArrayList WedgeHits = hitfinder.getWedgeHits(); + ArrayList BarHits = hitfinder.getBarHits(); + + //Exit if hit lists are empty + if (WedgeHits.isEmpty() && BarHits.isEmpty()) { + // System.out.println("No hits : "); + // event.show(); + return true; + } + + ClusterFinder clusterFinder = new ClusterFinder(); + int sigma_module = 5; + int sigma_component = 11; + double sigma_z = 5*Parameters.LENGTH_ATOF; + double sigma_t = 100; + + clusterFinder.makeClusters(hitfinder, sigma_module, sigma_component, sigma_z, sigma_t, event); + ArrayList Clusters = clusterFinder.getClusters(); + + if (WedgeHits.size() != 0 || BarHits.size() != 0) { + rbc.appendATOFBanks(event, WedgeHits, BarHits, Clusters); + } + return true; + } + + @Override + public boolean init() { + rbc = new TestBankWriter(); + + AlertTOFFactory factory = new AlertTOFFactory(); + DatabaseConstantProvider cp = new DatabaseConstantProvider(11, "default"); + this.ATOF = factory.createDetectorCLAS(cp); + this.registerOutputBank("ATOF::testhits", "ATOF::testclusters"); + + return true; + } + + public static void main(String arg[]) { + } +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java similarity index 100% rename from reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java rename to reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java From c6cde02ccd1d5f9b32670a35a44ab4d8a63b2de8 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Thu, 27 Feb 2025 10:26:15 -0600 Subject: [PATCH 13/20] feat: new engine and new banks for atof tests with effective velocity --- etc/bankdefs/hipo4/alert.json | 32 ++++++- .../jlab/rec/atof/banks/TestBankWriter.java | 39 +++++++- .../jlab/rec/atof/veff/VeffCalibration.java | 60 +++++++++++++ .../jlab/rec/atof/veff/VeffCalibrator.java | 89 +++++++++++++++++++ .../org/jlab/rec/service/ATOFTestEngine.java | 11 +-- 5 files changed, 220 insertions(+), 11 deletions(-) create mode 100644 reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibration.java create mode 100644 reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java diff --git a/etc/bankdefs/hipo4/alert.json b/etc/bankdefs/hipo4/alert.json index 2fead678ae..a740b49389 100644 --- a/etc/bankdefs/hipo4/alert.json +++ b/etc/bankdefs/hipo4/alert.json @@ -49,10 +49,38 @@ "name": "L_at_wedge", "type": "F", "info": "path length at atof wedge (inner surface) in mm" + } + ] + },{ + "name": "ATOF::testVeff", + "group": 23000, + "item": 35, + "info": "veff test for ATOF", + "entries": [ + { + "name": "id", + "type": "S", + "info": "calib id" },{ - "name": "L_in_wedge", + "name": "iCluster", + "type": "S", + "info": "id of the cluster" + },{ + "name": "iBar", + "type": "S", + "info": "id bar hit" + },{ + "name": "ldiff", + "type": "F", + "info": "length diff mm" + }, { + "name": "tdiff", "type": "F", - "info": "path length inside atof wedge in mm" + "info": "time diff ns" + },{ + "name": "module", + "type": "S", + "info": "module" } ] },{ diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java index f1a975ff3b..cb0c73574f 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/TestBankWriter.java @@ -6,16 +6,16 @@ import org.jlab.rec.atof.cluster.ATOFCluster; import org.jlab.rec.atof.hit.ATOFHit; import org.jlab.rec.atof.hit.BarHit; +import org.jlab.rec.atof.veff.VeffCalibration; /** - * The {@code RecoBankWriter} writes the banks needed for the atof - * testing: hits and clusters info. + * The {@code RecoBankWriter} writes the banks needed for the atof testing: hits + * and clusters info. * * @author pilleux */ public class TestBankWriter { - public static DataBank fillATOFTestHitBank(DataEvent event, ArrayList wedgeHits, ArrayList barHits) { ArrayList hitList = new ArrayList<>(); hitList.addAll(wedgeHits); @@ -42,7 +42,7 @@ public static DataBank fillATOFTestHitBank(DataEvent event, ArrayList w } return bank; } - + public static DataBank fillATOFTestClusterBank(DataEvent event, ArrayList clusterList) { DataBank bank = event.createBank("ATOF::testclusters", clusterList.size()); @@ -67,6 +67,25 @@ public static DataBank fillATOFTestClusterBank(DataEvent event, ArrayList calibrations) { + + DataBank bank = event.createBank("ATOF::testVeff", calibrations.size()); + + if (bank == null) { + System.err.println("COULD NOT CREATE A ATOF::testclusters BANK!!!!!!"); + return null; + } + for (int i = 0; i < calibrations.size(); i++) { + bank.setShort("id", i, (short) (i + 1)); + bank.setShort("iCluster", i, (short) calibrations.get(i).getICluster()); + bank.setShort("iBar", i, (short) calibrations.get(i).getIBarHit()); + bank.setFloat("ldiff", i, (float) calibrations.get(i).getLdiff()); + bank.setFloat("tdiff", i, (float) calibrations.get(i).getTdiff()); + bank.setShort("module", i, (short) calibrations.get(i).getModule()); + } + return bank; + } + /** * Appends the atof banks to an event. * @@ -100,6 +119,18 @@ public int appendATOFBanks(DataEvent event, ArrayList wedgeHits, ArrayL return 0; } + public int appendVeffBanks(DataEvent event, ArrayList calibrations) { + + DataBank veffbank = fillATOFTestVeff(event, calibrations); + if (veffbank != null) { + event.appendBank(veffbank); + } else { + return 1; + } + + return 0; + } + /** * @param args the command line arguments */ diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibration.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibration.java new file mode 100644 index 0000000000..660d33ad2e --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibration.java @@ -0,0 +1,60 @@ +package org.jlab.rec.atof.veff; + +public class VeffCalibration { + double ldiff, tdiff; + int iCluster, iBarHit, module; + + public double getLdiff() { + return ldiff; + } + + public void setLdiff(double ldiff) { + this.ldiff = ldiff; + } + + public double getTdiff() { + return tdiff; + } + + public void setTdiff(double tdiff) { + this.tdiff = tdiff; + } + + // Getter and Setter for iCluster + public int getICluster() { + return iCluster; + } + + public void setICluster(int iCluster) { + this.iCluster = iCluster; + } + + // Getter and Setter for iBarHit + public int getIBarHit() { + return iBarHit; + } + + public void setIBarHit(int iBarHit) { + this.iBarHit = iBarHit; + } + + // Getter and Setter for module + public int getModule() { + return module; + } + + public void setModule(int module) { + this.module = module; + } + + VeffCalibration(int module, double ldiff, double tdiff, int iCluster, int iBarHit){ + this.module=module; + this.ldiff = ldiff; + this.tdiff = tdiff; + this.iCluster = iCluster; + this.iBarHit = iBarHit; + } + + public static void main(String[] args) { + } +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java new file mode 100644 index 0000000000..bad90edcd5 --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java @@ -0,0 +1,89 @@ +package org.jlab.rec.atof.veff; + +import java.util.ArrayList; +import org.jlab.rec.atof.cluster.ATOFCluster; +import org.jlab.rec.atof.constants.Parameters; +import org.jlab.rec.atof.hit.ATOFHit; +import org.jlab.rec.atof.hit.BarHit; + +/** + * + * @author npilleux + */ +public class VeffCalibrator { + + private final ArrayList calibs = new ArrayList<>(); + + public ArrayList getCalibs() { + return calibs; + } + + public void setCalibs(ArrayList calibs) { + this.calibs.clear(); + if (calibs != null) { + this.calibs.addAll(calibs); + } + } + + public boolean computeCalib(ArrayList Clusters) { + calibs.clear(); + for (int i_c = 0; i_c < Clusters.size(); i_c++) { + ATOFCluster cluster = Clusters.get(i_c); + ArrayList WedgeHits = cluster.getWedgeHits(); + if (WedgeHits.size() < 1) { + continue; + } + double zFromWedge = cluster.getMaxWedgeHit().getZ(); + double Lup = -Parameters.LENGTH_ATOF / 2 + zFromWedge; + double Ldown = Parameters.LENGTH_ATOF / 2 - zFromWedge; + ArrayList BarHits = cluster.getBarHits(); + for (int i_b = 0; i_b < BarHits.size(); i_b++) { + BarHit barhit = BarHits.get(i_b); + double uphit_time = barhit.getHitUp().getTime(); + double downhit_time = barhit.getHitDown().getTime(); + calibs.add(new VeffCalibration(barhit.computeModuleIndex(),(Lup - Ldown),(uphit_time - downhit_time),i_c,i_b)); + } + } + return true; + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + /* + String input = "/Users/npilleux/Desktop/alert/atof-reconstruction/coatjava/rec_ahdc_alert_020797_small_updated_for_test.hipo"; + HipoDataSource reader = new HipoDataSource(); + reader.open(input); + VeffCalibration en = new VeffCalibration(); + en.init(); + String fileName_veff = "/Users/npilleux/Desktop/alert/atof-reconstruction/coatjava/veff_test.csv"; + try ( + PrintWriter writer = new PrintWriter(new FileWriter(fileName_veff))) { + int event_number = 0; + writer.printf("event_number,i_cluster,i_bar,module,Ldiff,tdiff%n"); + while (reader.hasEvent()) { + { + event_number++; + DataEvent event = (DataEvent) reader.getNextEvent(); + en.processDataEvent(event, writer, event_number); + System.out.print("------ \n"); + } + + } + JFrame frame = new JFrame("tsum"); + frame.setSize(2500, 800); + EmbeddedCanvas canvas = new EmbeddedCanvas(); + canvas.cd(0); + canvas.draw(en.h_veff); + frame.add(canvas); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + writer.flush(); + } catch (IOException e) { + System.err.println("An error occurred while writing the file: " + e.getMessage()); + } + */ + } +} + diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java b/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java index 5ed64a5f76..586786ad75 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFTestEngine.java @@ -1,8 +1,5 @@ package org.jlab.rec.service; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; import java.util.ArrayList; import org.jlab.clas.reco.ReconstructionEngine; @@ -12,7 +9,6 @@ import org.jlab.detector.calib.utils.DatabaseConstantProvider; import org.jlab.geom.base.Detector; import org.jlab.geom.detector.alert.ATOF.AlertTOFFactory; -import org.jlab.io.hipo.HipoDataSource; import org.jlab.rec.atof.banks.TestBankWriter; import org.jlab.rec.atof.cluster.ATOFCluster; import org.jlab.rec.atof.cluster.ClusterFinder; @@ -20,6 +16,7 @@ import org.jlab.rec.atof.hit.ATOFHit; import org.jlab.rec.atof.hit.BarHit; import org.jlab.rec.atof.hit.HitFinder; +import org.jlab.rec.atof.veff.VeffCalibrator; /** * Service to return ATOF test hits and clusters @@ -76,14 +73,18 @@ public boolean processDataEvent(DataEvent event) { ClusterFinder clusterFinder = new ClusterFinder(); int sigma_module = 5; int sigma_component = 11; - double sigma_z = 5*Parameters.LENGTH_ATOF; + double sigma_z = 5 * Parameters.LENGTH_ATOF; double sigma_t = 100; clusterFinder.makeClusters(hitfinder, sigma_module, sigma_component, sigma_z, sigma_t, event); ArrayList Clusters = clusterFinder.getClusters(); + VeffCalibrator calibrator = new VeffCalibrator(); + calibrator.computeCalib(Clusters); + if (WedgeHits.size() != 0 || BarHits.size() != 0) { rbc.appendATOFBanks(event, WedgeHits, BarHits, Clusters); + rbc.appendVeffBanks(event, calibrator.getCalibs()); } return true; } From fad27d8bf38ad79c8178ea21385a7f768f8a7af4 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Thu, 27 Feb 2025 14:31:35 -0600 Subject: [PATCH 14/20] fix: correct distances --- .../main/java/org/jlab/rec/atof/veff/VeffCalibrator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java index bad90edcd5..7847dc3f13 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java @@ -34,8 +34,12 @@ public boolean computeCalib(ArrayList Clusters) { continue; } double zFromWedge = cluster.getMaxWedgeHit().getZ(); - double Lup = -Parameters.LENGTH_ATOF / 2 + zFromWedge; + System.out.print(zFromWedge + " z \n"); + double Lup = Parameters.LENGTH_ATOF / 2 + zFromWedge; double Ldown = Parameters.LENGTH_ATOF / 2 - zFromWedge; + System.out.print(Lup + " lup \n"); + System.out.print(Ldown + " ldown \n"); + System.out.print(Lup+Ldown + " sum\n"); ArrayList BarHits = cluster.getBarHits(); for (int i_b = 0; i_b < BarHits.size(); i_b++) { BarHit barhit = BarHits.get(i_b); From 0fc8196aef3fe9d3ee5a424377e9a0d9849bd23d Mon Sep 17 00:00:00 2001 From: N-Plx Date: Thu, 27 Feb 2025 14:48:27 -0600 Subject: [PATCH 15/20] style: clean up --- .../src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java index 7847dc3f13..bdbb42cfef 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java @@ -34,12 +34,8 @@ public boolean computeCalib(ArrayList Clusters) { continue; } double zFromWedge = cluster.getMaxWedgeHit().getZ(); - System.out.print(zFromWedge + " z \n"); double Lup = Parameters.LENGTH_ATOF / 2 + zFromWedge; double Ldown = Parameters.LENGTH_ATOF / 2 - zFromWedge; - System.out.print(Lup + " lup \n"); - System.out.print(Ldown + " ldown \n"); - System.out.print(Lup+Ldown + " sum\n"); ArrayList BarHits = cluster.getBarHits(); for (int i_b = 0; i_b < BarHits.size(); i_b++) { BarHit barhit = BarHits.get(i_b); From 20362f00e5a80158e73ea9a76d3461e446563e80 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Fri, 28 Feb 2025 10:53:31 -0600 Subject: [PATCH 16/20] fix: simplifying --- .../src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java index bdbb42cfef..e26c08e675 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/veff/VeffCalibrator.java @@ -34,14 +34,12 @@ public boolean computeCalib(ArrayList Clusters) { continue; } double zFromWedge = cluster.getMaxWedgeHit().getZ(); - double Lup = Parameters.LENGTH_ATOF / 2 + zFromWedge; - double Ldown = Parameters.LENGTH_ATOF / 2 - zFromWedge; ArrayList BarHits = cluster.getBarHits(); for (int i_b = 0; i_b < BarHits.size(); i_b++) { BarHit barhit = BarHits.get(i_b); double uphit_time = barhit.getHitUp().getTime(); double downhit_time = barhit.getHitDown().getTime(); - calibs.add(new VeffCalibration(barhit.computeModuleIndex(),(Lup - Ldown),(uphit_time - downhit_time),i_c,i_b)); + calibs.add(new VeffCalibration(barhit.computeModuleIndex(),(2*zFromWedge),(uphit_time - downhit_time),i_c,i_b)); } } return true; From b9d726b278db6b5a5723ff19285954694db4dd08 Mon Sep 17 00:00:00 2001 From: Noemie Pilleux Date: Fri, 28 Feb 2025 12:48:08 -0500 Subject: [PATCH 17/20] fix:order definition --- .../alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java index 122c4c7f2d..f1ce4751d9 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java @@ -160,9 +160,9 @@ public final String makeType() { //Type of hit can be wedge, bar up, bar down or bar. //Avoids testing components and order every time. String itype = "undefined"; - if (this.component == 10 && this.order == 1) { + if (this.component == 10 && this.order == 0) { itype = "bar down"; - } else if (this.component == 10 && this.order == 0) { + } else if (this.component == 10 && this.order == 1) { itype = "bar up"; } else if (this.component < 10) { itype = "wedge"; From aaa62ff2ac8fa47a94a16b64141f1e14ad2fa963 Mon Sep 17 00:00:00 2001 From: N-Plx <66355299+N-Plx@users.noreply.github.com> Date: Tue, 1 Apr 2025 12:54:31 -0500 Subject: [PATCH 18/20] Merging development in ATOF testing (#526) * DC v2: includes TFLight fix and new dc beta time walk with constants from /calibration/dc/v2 (#494) * fix issue for path length in FD tracking * fix issue for coordinate transformation from global to tilted sector coordinate * add comments to explain transition of starting point for path length * T2D with beta dependence. Fixes in interpolation. * Fix for instances where the t2d function turns over. * Fix in last interpolation step. More validation plots. * Fix table filling * B-field interpolation test interpolation in B instead of B^2. More plots * Added modularity for calibration use * version bump * switch to use new dc/v2 tables * switch to use new dc/v2 for ref_pressure too --------- Co-authored-by: tongtongcao Co-authored-by: ziegler * Update DC reconstruction at the denoisinng level (#499) * cancel SNR and change limit of total DC hits from raw hits to hits after denoising * remove unused codes * reset limit for prob in DC clustering and cancel requirement that no skipped layer for cluster candidates from splitter (#500) * pass 2 additional values * fix data type * feat: pre-commit hook to update banks README (#505) * Change the option to select the track finding to a enum. Now this option can be setup from the yaml file with the option Mode: ``` ALERT: Mode: "AI_Track_Finding" ``` Add a cut on the number of hits to rely on the conventional track finding with there is more than 300 hits. * Change the default options for DJL: - Use a single thread for the inference. - Remove waring about the graph executor optimization * Modification of the track candidates generation * Improve the function to get all the track candidates. * Update AHDCEngine to initialize model conditionally and adjust prediction threshold * New features for ALERT Kalman filter+optimized parameters (#445) * Optimization of Kalman Filter: * adjusted number of filtering iterations from 10 to 5; * adjusted step size dx for calculation of ddoca/dx from 10^8 to 10^5; * Added AHDC hits residuals (post-fit and pre-fit) in the output: * residuals in the AHDC::Hits list in the alert.json file; * filling the hits residuals in the RecoBankWriter; * added residual and residual_prefit in ahdc/Hit/Hit.java * added a identification flag to match ahdc/KalmanFilter/Hit.java to ahdc/Hit/Hit.java * Successfully affected the calculated hit residual to the correct AHDC::Hit. * Fixed and improved the calculation of the post-fit residuals: * affecting the track parameters to the KFTrack right after the fit; * redo a forward indicators pass without correction; * * Cleaning the Kalman filter code: - removed all "cylindrical coordinates" vector and measurement functions; - renamed all preexisting vector and measurement function with their original name. - removed many commented printouts. * Attempt to include hit "sign" / left-right disambiguation: * added "virtual wires" located at the distance-of-closest-approach of the actual wire, on each side of the wire; * added hit sign parameter in KalmanFilter/Hit class; * added a new distance function to KalmanFilter/Hit class calculate the distance of a point to the correct virtual wire depending on the sign; * attempt to modify the "h" function to call new distance function * Fix of a parameter modified by mistake. * Added a second definition of BackwardIndicators in AHDC/KalmanFilter to be able to initialize a vertex. * Added a flag setDefinedVertex to AHDC/KalmanFilter and KFitter to define "hit_beam" vertex. * Reset Niter and ddoca step size parameters to 10, 1.e-8 respectively. * Added reading of wire ADC from the AHDC HitReader, and functions to access ADC for AHDC/Hit/Hit and AHDC/KalmanFilter/Hit. Added filtering of two hits on same superlayer/layer based on ADC (largest ADC is kept) and use info to determine the hit sign. * Added an option to build the initial track with just the hits combination and preset fixed parameters in AHDCEngine. Added a function in AHDC/KalmanFilter/Hit.java to calculate the measurement vector if we have a sign. * Substituted call of default hit vector and hit measurement functions with hit vector and measurement functions that handle hit left/right disambiguation. * Started to reintroduce the hit sign. * Save state: back to status quo before revising sign. * Added variable measurement error for hits with sign defined, with tracks on the wrong side. * Implemented varaible measurement error for signed hits: * if track on right side of wire, normal error; * if track on wrong side of wire, inflated error; Ensured reordering of hits by increasing phi; added exception for "rollover" around phi = pi; * fixed once and for all the convention for hit sign: sign >0 if phi_expected state > phi_wire * Tried to introduce a "pull" to the track on the correct sign of a wire by setting the measurement on the correct "virtual wire" with a larger error. * Revert "Tried to introduce a "pull" to the track on the correct sign of a wire by setting the measurement on the correct "virtual wire" with a larger error." This reverts commit 9bf47151d3dca0bd710e2f45a056c0a3c53966a1. * Fixed the convention for the "virtual wires": wire "minus" ("plus") at +deltaphi (-deltaphi) since wire x, y position depend on -R*sin(phi), -R cos(phi) respectively. * Improved the functions to calculate hit vector: returns doca if sign is 0 or if sign is good. * Added a hit distance function with goodsign as input, and H (measurement matrix) function with goodsign as an input. * Added (commented) calls of functions with sign. * Added a simple handle to disable reading of MC variables. * Rerolled to fitting with no double hit. * Harmonized simulation flag: - one simulation flag is declared in AHDCengine and defined as false; - it is now propagated into KalmanFilter. * Added a check to read MC hits in AHDC_engine. --------- Co-authored-by: Mathieu Ouillon <67646911+mathieuouillon@users.noreply.github.com> * Petiroc timestamps2 (#512) * Added petiroc board timestamps * Adding CI stuff that is for gitlab modified: common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java modified: common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java modified: common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java modified: etc/bankdefs/hipo4/data.json --------- Co-authored-by: Whitney Armstrong * bump version * version bump * create a method to decode evio events in a single line to simplify usage in mon12 and ced * new DCRB firmware (#509) * implemented decoding of new DCRB banks with ToT and order labeling of DC hit to use the first in time * removed anused code * printingg exception from DC banks decoding --------- Co-authored-by: Nathan Baltzell * fix: remove `jdtls` files * fix: ignore `jdtls` files * Use pulse time and hide MVTFitter * Change samplingTime * Fix issue * version bump --------- Co-authored-by: raffaelladevita Co-authored-by: tongtongcao Co-authored-by: ziegler Co-authored-by: baltzell Co-authored-by: Christopher Dilks Co-authored-by: MathieuOuillon Co-authored-by: efuchey Co-authored-by: Mathieu Ouillon <67646911+mathieuouillon@users.noreply.github.com> Co-authored-by: Whitney Armstrong Co-authored-by: Whitney Armstrong Co-authored-by: Felix Touchte Codjo Co-authored-by: Nathan Baltzell --- .containers/coatjava.Dockerfile | 3 +- .containers/coatjava.def | 14 + .../make_banks_readme.rb | 9 +- .github/make_banks_readme_precommit.sh | 2 + .gitignore | 6 + .gitlab-ci.yml | 14 + .pre-commit-config.yaml | 8 + README.md | 3 + common-tools/clara-io/pom.xml | 4 +- common-tools/clas-analysis/pom.xml | 20 +- common-tools/clas-detector/pom.xml | 10 +- .../java/org/jlab/detector/banks/RawBank.java | 6 +- .../jlab/detector/decode/CLASDecoder4.java | 42 +- .../detector/decode/CodaEventDecoder.java | 90 +++- .../detector/decode/DetectorDataDgtz.java | 22 +- .../detector/decode/DetectorEventDecoder.java | 49 +- .../jlab/detector/pulse/HipoExtractor.java | 12 +- .../org/jlab/detector/pulse/IExtractor.java | 2 +- .../java/org/jlab/detector/pulse/Mode3.java | 4 +- .../java/org/jlab/detector/pulse/Mode7.java | 4 +- .../org/jlab/detector/pulse/ModeAHDC.java | 59 +-- common-tools/clas-geometry/pom.xml | 4 +- common-tools/clas-io/pom.xml | 8 +- common-tools/clas-jcsg/pom.xml | 8 +- common-tools/clas-logging/pom.xml | 4 +- common-tools/clas-math/pom.xml | 4 +- common-tools/clas-physics/pom.xml | 4 +- common-tools/clas-reco/pom.xml | 16 +- common-tools/clas-tracking/pom.xml | 6 +- .../kalmanfilter/zReference/KFitter.java | 22 +- .../zReference/KFitterStraight.java | 12 +- .../kalmanfilter/zReference/StateVecs.java | 100 +++- common-tools/clas-utils/pom.xml | 6 +- common-tools/cnuphys/apache/.classpath | 6 - common-tools/cnuphys/apache/.project | 17 - .../.settings/org.eclipse.jdt.core.prefs | 12 - common-tools/cnuphys/magfield/pom.xml | 2 +- .../cnuphys/magfield/src/main/java/.classpath | 7 - .../cnuphys/magfield/src/main/java/.project | 17 - .../src/main/java/cnuphys/bin/.classpath | 7 - .../src/main/java/cnuphys/bin/.project | 17 - common-tools/cnuphys/numRec/.classpath | 7 - common-tools/cnuphys/numRec/.project | 17 - common-tools/cnuphys/numRec/bin/.classpath | 6 - common-tools/cnuphys/numRec/bin/.project | 17 - common-tools/cnuphys/numRec/src/.classpath | 6 - common-tools/cnuphys/numRec/src/.project | 17 - .../cnuphys/snr/src/main/java/.classpath | 6 - .../cnuphys/snr/src/main/java/.project | 17 - .../snr/src/main/java/cnuphys/bin/.classpath | 6 - .../snr/src/main/java/cnuphys/bin/.project | 17 - common-tools/cnuphys/splot/.classpath | 8 - common-tools/cnuphys/splot/.project | 17 - .../cnuphys/splot/src/main/java/.classpath | 12 - .../cnuphys/splot/src/main/java/.project | 17 - .../.settings/org.eclipse.jdt.core.prefs | 11 - common-tools/cnuphys/swimmer/pom.xml | 2 +- .../cnuphys/swimmer/src/main/java/.classpath | 14 - .../cnuphys/swimmer/src/main/java/.project | 17 - .../src/main/java/cnuphys/bin/.classpath | 14 - .../src/main/java/cnuphys/bin/.project | 17 - common-tools/coat-lib/deployDistribution.sh | 2 +- common-tools/coat-lib/pom.xml | 24 +- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 +- common-tools/swim-tools/pom.xml | 6 +- etc/bankdefs/hipo4/README.md | 26 +- etc/bankdefs/hipo4/alert.json | 8 + etc/bankdefs/hipo4/data.json | 10 +- parent/pom.xml | 2 +- pom.xml | 4 +- reconstruction/alert/pom.xml | 10 +- .../main/java/org/jlab/rec/ahdc/AI/Model.java | 3 + .../rec/ahdc/AI/PreclusterSuperlayer.java | 4 + .../jlab/rec/ahdc/AI/TrackConstruction.java | 186 +++++-- .../jlab/rec/ahdc/Banks/RecoBankWriter.java | 2 + .../main/java/org/jlab/rec/ahdc/Hit/Hit.java | 27 +- .../java/org/jlab/rec/ahdc/Hit/HitReader.java | 5 +- .../org/jlab/rec/ahdc/KalmanFilter/Hit.java | 132 +++-- .../jlab/rec/ahdc/KalmanFilter/Hit_beam.java | 2 +- .../jlab/rec/ahdc/KalmanFilter/KFitter.java | 154 +++--- .../rec/ahdc/KalmanFilter/KalmanFilter.java | 232 ++++----- .../src/main/java/org/jlab/rec/ahdc/Mode.java | 5 + .../java/org/jlab/rec/ahdc/Track/Track.java | 10 +- .../java/org/jlab/rec/service/AHDCEngine.java | 54 +- reconstruction/band/pom.xml | 4 +- reconstruction/bg/pom.xml | 8 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 6 +- reconstruction/dc/pom.xml | 14 +- .../main/java/org/jlab/rec/dc/Constants.java | 24 +- .../java/org/jlab/rec/dc/banks/HitReader.java | 66 +-- .../dc/cluster/ClusterCleanerUtilities.java | 40 +- .../jlab/rec/dc/cluster/ClusterFinder.java | 3 +- .../java/org/jlab/rec/dc/hit/FittedHit.java | 43 +- .../rec/dc/timetodistance/T2DFunctions.java | 2 +- .../rec/dc/timetodistance/TableLoader.java | 493 ++++++++++++------ .../TimeToDistanceEstimator.java | 381 ++++++++------ .../rec/dc/track/TrackCandListFinder.java | 28 +- .../org/jlab/service/dc/DCHBClustering.java | 29 +- .../java/org/jlab/service/dc/DCHBEngine.java | 45 +- .../java/org/jlab/service/dc/DCTBEngine.java | 35 +- reconstruction/eb/pom.xml | 10 +- reconstruction/ec/pom.xml | 6 +- reconstruction/fmt/pom.xml | 6 +- reconstruction/ft/pom.xml | 4 +- reconstruction/htcc/pom.xml | 4 +- reconstruction/htcc/src/main/java/.classpath | 11 - reconstruction/htcc/src/main/java/.project | 17 - reconstruction/ltcc/pom.xml | 4 +- reconstruction/mc/pom.xml | 4 +- reconstruction/mltn/pom.xml | 6 +- reconstruction/pom.xml | 4 +- reconstruction/postproc/pom.xml | 8 +- reconstruction/raster/pom.xml | 4 +- reconstruction/rich/pom.xml | 6 +- reconstruction/rtpc/pom.xml | 6 +- reconstruction/swaps/pom.xml | 8 +- reconstruction/tof/pom.xml | 4 +- reconstruction/urwell/pom.xml | 6 +- reconstruction/vtx/pom.xml | 6 +- 121 files changed, 1730 insertions(+), 1438 deletions(-) create mode 100644 .containers/coatjava.def rename etc/bankdefs/util/dumpBankIDs.rb => .github/make_banks_readme.rb (92%) create mode 100755 .github/make_banks_readme_precommit.sh create mode 100644 .pre-commit-config.yaml delete mode 100644 common-tools/cnuphys/apache/.classpath delete mode 100644 common-tools/cnuphys/apache/.project delete mode 100644 common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs delete mode 100644 common-tools/cnuphys/magfield/src/main/java/.classpath delete mode 100644 common-tools/cnuphys/magfield/src/main/java/.project delete mode 100644 common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath delete mode 100644 common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project delete mode 100644 common-tools/cnuphys/numRec/.classpath delete mode 100644 common-tools/cnuphys/numRec/.project delete mode 100644 common-tools/cnuphys/numRec/bin/.classpath delete mode 100644 common-tools/cnuphys/numRec/bin/.project delete mode 100644 common-tools/cnuphys/numRec/src/.classpath delete mode 100644 common-tools/cnuphys/numRec/src/.project delete mode 100644 common-tools/cnuphys/snr/src/main/java/.classpath delete mode 100644 common-tools/cnuphys/snr/src/main/java/.project delete mode 100644 common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath delete mode 100644 common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project delete mode 100644 common-tools/cnuphys/splot/.classpath delete mode 100644 common-tools/cnuphys/splot/.project delete mode 100644 common-tools/cnuphys/splot/src/main/java/.classpath delete mode 100644 common-tools/cnuphys/splot/src/main/java/.project delete mode 100644 common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs delete mode 100644 common-tools/cnuphys/swimmer/src/main/java/.classpath delete mode 100644 common-tools/cnuphys/swimmer/src/main/java/.project delete mode 100644 common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath delete mode 100644 common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project create mode 100644 reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java delete mode 100644 reconstruction/htcc/src/main/java/.classpath delete mode 100644 reconstruction/htcc/src/main/java/.project diff --git a/.containers/coatjava.Dockerfile b/.containers/coatjava.Dockerfile index dbe73116a0..513e16c0a1 100644 --- a/.containers/coatjava.Dockerfile +++ b/.containers/coatjava.Dockerfile @@ -22,4 +22,5 @@ ARG REF_NAME=development # build coatjava RUN java --version && cd /opt && \ git clone https://code.jlab.org/hallb/alert/coatjava.git && cd coatjava && \ - git fetch origin && git checkout ${REF_NAME} && ./build-coatjava.sh --quiet + git fetch origin && git checkout ${REF_NAME} && ./build-coatjava.sh --quiet && \ + ./install-clara /opt/clara diff --git a/.containers/coatjava.def b/.containers/coatjava.def new file mode 100644 index 0000000000..8dc1962ac8 --- /dev/null +++ b/.containers/coatjava.def @@ -0,0 +1,14 @@ +Bootstrap: docker +From: codecr.jlab.org/hallb/alert/coatjava/coatjava:{{ REF_NAME }} + + +%environment + export CLAS12DIR=/opt/coatjava/coatjava + +%help + This is a clas12 coatjava container used to run coatjava on HPC systems + and do rapid development. + +%labels + Author Whitney Armstrong warmstrong@anl.gov + REF_NAME {{ REF_NAME }} diff --git a/etc/bankdefs/util/dumpBankIDs.rb b/.github/make_banks_readme.rb similarity index 92% rename from etc/bankdefs/util/dumpBankIDs.rb rename to .github/make_banks_readme.rb index 1f6ac8dc5f..ca67af8768 100755 --- a/etc/bankdefs/util/dumpBankIDs.rb +++ b/.github/make_banks_readme.rb @@ -51,13 +51,8 @@ # dump a table puts """# Bank Group and Item IDs -This file was generated by -```bash -#{$0} #{ARGV.join ' '} -``` - -> [!IMPORTANT] -> Please re-run this script if you modify any of the bank definitions. +> [!NOTE] +> Iguana banks, which are defined in the Iguana repository, use group number 30000. """ diff --git a/.github/make_banks_readme_precommit.sh b/.github/make_banks_readme_precommit.sh new file mode 100755 index 0000000000..d2fed8649f --- /dev/null +++ b/.github/make_banks_readme_precommit.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +.github/make_banks_readme.rb etc/bankdefs/hipo4 > etc/bankdefs/hipo4/README.md diff --git a/.gitignore b/.gitignore index 77c0fd6ff3..900361e56b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,12 @@ hs_err_pid* *.iml .idea +# eclipse JDT language server +.classpath +.factorypath +.project +.settings + # no log files: *.log *.evio diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da31aa64a8..db9ad01fa8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ workflow: variables: KUBERNETES_MEMORY_LIMIT: "8Gi" + REF_NAME: ${CI_COMMIT_REF_NAME} default: image: ubuntu:noble @@ -69,3 +70,16 @@ shared_for_alert_tests: project: hallb/alert/atof/shared_for_alert strategy: depend +coatjava:singularity: + image: eicweb.phy.anl.gov:4567/containers/image_recipes/ubuntu_dind:latest + tags: + - silicon + allow_failure: true + script: + - apptainer build --build-arg REF_NAME=${REF_NAME} coatjava.sif .containers/coatjava.def + - ls -lrth + artifacts: + paths: + - coatjava.sif + + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..a482a3ca64 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: +- repo: local + hooks: + - id: make_banks_readme + name: make banks readme + entry: .github/make_banks_readme_precommit.sh + language: script + pass_filenames: false diff --git a/README.md b/README.md index 932aa457cd..6d5f89bd5e 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,6 @@ http://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of- --> + +[Coatjava Apptainer](https://code.jlab.org/hallb/alert/coatjava/-/jobs/artifacts/development/raw/coatjava.sif?job=coatjava%3Asingularity) + diff --git a/common-tools/clara-io/pom.xml b/common-tools/clara-io/pom.xml index 829ad4a1bd..4655074b88 100644 --- a/common-tools/clara-io/pom.xml +++ b/common-tools/clara-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clara-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index fd3f5efb02..1d6ea9031e 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,63 +3,63 @@ 4.0.0 org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index 635bc38466..f8ec3304fb 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,21 +3,21 @@ 4.0.0 org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -29,13 +29,13 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java index fffc360b58..19482d6005 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java @@ -74,9 +74,9 @@ public static enum OrderType { BGADDED_NOISE1 ( 70), // background hits retained by level-1 denoising BGADDED_NOISE2 ( 80), // background hits retained by level-2 denoising BGADDED_NOISE3 ( 90), // background hits retained by level-3 denoising - USER1 (100), - USER2 (110), - USER3 (120); + DECREMOVED (100), // hits removed during decoding + USER1 (110), + USER2 (120); private final int rawOrderId; private OrderType(int id){ rawOrderId = id; } public int getTypeId() { return rawOrderId; } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java index 763042a2d4..9db665354f 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java @@ -139,6 +139,7 @@ public void initEvent(DataEvent event){ detectorDecoder.translate(dataList); detectorDecoder.fitPulses(dataList); + detectorDecoder.filterTDCs(dataList); if(this.decoderDebugMode>0){ System.out.println("\n>>>>>>>>> TRANSLATED data"); for(DetectorDataDgtz data : dataList){ @@ -260,6 +261,7 @@ public Bank getDataBankWF(String name, DetectorType type) { b.putShort("component", i, (short) a.get(i).getDescriptor().getComponent()); b.putByte("order", i, (byte) a.get(i).getDescriptor().getOrder()); b.putLong("timestamp", i, a.get(i).getADCData(0).getTimeStamp()); + b.putInt("time", i, (int)a.get(i).getADCData(0).getTime()); DetectorDataDgtz.ADCData xxx = a.get(i).getADCData(0); for (int j=0; j getDataEntries_57622(Integer crate, EvioNode node } } } catch (EvioException ex) { - //Logger.getLogger(EvioRawDataSource.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); } catch (IndexOutOfBoundsException ex){ - //System.out.println("[ERROR] ----> ERROR DECODING COMPOSITE DATA FOR ONE EVENT"); + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + + } + return entries; + } + + /** + * Bank TAG=57648 used for DC (Drift Chambers) TDC and ToT values. + * @param crate + * @param node + * @param event + * @return + */ + public List getDataEntries_57648(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57648){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + //List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + int totalSize = cdataitems.size(); + int position = 0; + while( (position + 4) < totalSize){ + Byte slot = (Byte) cdataitems.get(position); + //Integer trig = (Integer) cdataitems.get(position+1); + Long time = (Long) cdataitems.get(position+2); + Integer nchannels = (Integer) cdataitems.get(position+3); + int counter = 0; + position = position + 4; + while(counter getDataEntries_57657(Integer crate, EvioNode node int position = 0; while(position -> "bank" DetectorDataDgtz -> "tdc" TDCData + // there is a redundancy in timestamp: the same value is stored in TDCData and the DetectorDataDgz + // + bank.setTimeStamp(time_stamp); + bank.setTrigger(trig_num);; + TDCData tdc_data = new TDCData(tdc, tot); + tdc_data.setTimeStamp(time_stamp).setOrder(counter); + bank.addTDC(tdc_data); entries.add(bank); - position += 3; + position += 3; // channel,tdc,tot counter++; //System.err.println("event: " + bank.toString()); } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java index 375c322b3d..ebc0a1957f 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorDescriptor; import org.jlab.detector.base.DetectorType; import org.jlab.detector.helicity.HelicityBit; @@ -14,12 +15,14 @@ */ public class DetectorDataDgtz implements Comparable { - private final List adcStore = new ArrayList<>(); - private final List tdcStore = new ArrayList<>(); - private final List vtpStore = new ArrayList<>(); - private final List scalerStore = new ArrayList<>(); - private Long timeStamp = 0L; + private final List adcStore = new ArrayList<>(); + private final List tdcStore = new ArrayList<>(); + private final List vtpStore = new ArrayList<>(); + private final List scalerStore = new ArrayList<>(); + private Long timeStamp = 0L; + private int trigger = 0; // Trigger number ( usually only 1 trigger due to rol2(?) ); + private final DetectorDescriptor descriptor = new DetectorDescriptor(); public DetectorDataDgtz(){ @@ -66,6 +69,9 @@ public long getTimeStamp(){ public DetectorDescriptor getDescriptor(){ return this.descriptor; } + + public int getTrigger() { return trigger;} + public DetectorDataDgtz setTrigger(int trig) { trigger = trig;return this;} @Override public String toString(){ @@ -333,6 +339,8 @@ public static class TDCData implements Comparable{ private int tdcOrder = 0; // Used for sorting private int tdcTime = 0; private int tdcToT = 0; // Time over threshold + private Long timeStamp = 0L; + private OrderType tdcType = OrderType.NOMINAL; public TDCData() {} public TDCData(int time) { this.tdcTime = time;} @@ -340,9 +348,13 @@ public TDCData() {} public int getTime() { return this.tdcTime;} public int getToT() { return this.tdcToT;} public int getOrder() { return tdcOrder;} + public long getTimeStamp(){ return this.timeStamp; } + public OrderType getType() { return tdcType;} public TDCData setOrder(int order) { tdcOrder = order;return this;} public TDCData setTime(short time) { tdcTime = time;return this;} public TDCData setToT(short ToT) { tdcToT = ToT;return this;} + public TDCData setTimeStamp(long time){ timeStamp = time;return this; } + public TDCData setType(OrderType type) { tdcType = type; return this;} @Override public String toString(){ diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java index 09a4ad7bf5..da36a07577 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java @@ -1,7 +1,12 @@ package org.jlab.detector.decode; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.detector.decode.DetectorDataDgtz.ADCData; @@ -21,6 +26,7 @@ public class DetectorEventDecoder { List keysTrans = null; List tablesFitter = null; List keysFitter = null; + List keysFilter = null; private int runNumber = 10; @@ -109,6 +115,9 @@ public final void initDecoder(){ }); fitterManager.init(keysFitter, tablesFitter); + // Data filter list + keysFilter = Arrays.asList(new String[]{"DC"}); + scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); } @@ -159,7 +168,7 @@ public void fitPulses(List detectorData){ //custom MM fitter if( ( (table.equals("BMT"))&&(data.getDescriptor().getType().getName().equals("BMT")) ) || ( (table.equals("FMT"))&&(data.getDescriptor().getType().getName().equals("FMT")) ) - || ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) + //|| ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) || ( (table.equals("FTTRK"))&&(data.getDescriptor().getType().getName().equals("FTTRK")) ) ){ IndexedTable daq = fitterManager.getConstants(runNumber, table); short adcOffset = (short) daq.getDoubleValue("adc_offset", 0, 0, 0); @@ -211,4 +220,42 @@ public void fitPulses(List detectorData){ } } } + + + public void filterTDCs(List detectorData){ + int maxMultiplicity = 1; + for(String table : keysFilter){ + Map> filteredData = new HashMap<>(); + for(DetectorDataDgtz data : detectorData){ + if(data.getDescriptor().getType()==DetectorType.getType(table)) { + int key = data.getDescriptor().getHashCode(); + if(!filteredData.containsKey(key)) + filteredData.put(key, new ArrayList<>()); + filteredData.get(key).add(data); + } + } + for(int key : filteredData.keySet()) { + filteredData.get(key).sort(new TDCComparator()); + if(filteredData.get(key).size()>maxMultiplicity) + for(int i=maxMultiplicity; i { + + // override the compare() method + public int compare(DetectorDataDgtz s1, DetectorDataDgtz s2) + { + if(s1.getTDCSize()>0 && s2.getTDCSize()>0) + return s1.getTDCData(0).getTime()0) + return 1; + else if(s2.getTDCSize()>0) + return -1; + else + return 0; + } + } } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java index c833e875a3..146b087449 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java @@ -129,8 +129,10 @@ protected List getPulses(int n, IndexedTable it, DataBank wfBank) { for (int i=0; i p = it==null ? extract(null, i, samples) : - extract(it.getNamedEntry(getIndices(wfBank,i)), i, samples); + long timestamp = wfBank.getLong("timestamp",i); + int time = wfBank.getInt("time",i); + List p = it==null ? extract(null, i, timestamp, time, samples) : + extract(it.getNamedEntry(getIndices(wfBank,i)), i, timestamp, time, samples); if (p!=null && !p.isEmpty()) { if (pulses == null) pulses = new ArrayList<>(); pulses.addAll(p); @@ -147,8 +149,10 @@ protected List getPulses(int n, IndexedTable it, Bank wfBank) { samples[j] = wfBank.getShort(String.format("s%d",j+1), i); // FIXME: Can speed this up (but looks like not for DataBank?): //samples[j] = wfBank.getShort(String.format(5+j,j+1), i); - List p = it==null ? extract(null, i, samples) : - extract(it.getNamedEntry(getIndices(wfBank,i)), i, samples); + int time = wfBank.getInt("time",i); + long timestamp = wfBank.getLong("timestamp",i); + List p = it==null ? extract(null, i, timestamp, time, samples) : + extract(it.getNamedEntry(getIndices(wfBank,i)), i, timestamp, time, samples); if (p!=null && !p.isEmpty()) { if (pulses == null) pulses = new ArrayList<>(); pulses.addAll(p); diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java index bfa765d84e..fac170f6b8 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java @@ -5,6 +5,6 @@ public interface IExtractor { - public List extract(NamedEntry pars, int id, short... samples); + public List extract(NamedEntry pars, int id, long par1, long par2, short... samples); } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java index bf4049f60a..23e1289606 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java @@ -20,11 +20,13 @@ public class Mode3 extends HipoExtractor { /** * @param pars CCDB row * @param id link to row in source bank + * @param par1 + * @param par2 * @param samples ADC samples * @return extracted pulses */ @Override - public List extract(NamedEntry pars, int id, short... samples) { + public List extract(NamedEntry pars, int id, long par1, long par2, short... samples) { List pulses = null; diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java index b7f58f2c70..883b150aa2 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java @@ -29,8 +29,8 @@ private static float calculateTime(int t0, float ped, short... samples) { } @Override - public List extract(NamedEntry pars, int id, short... samples) { - List pulses = super.extract(pars, id, samples); + public List extract(NamedEntry pars, int id, long par1, long par2, short... samples) { + List pulses = super.extract(pars, id, par1, par2, samples); for (Pulse p : pulses) p.time = calculateTime((int)p.time, p.pedestal, samples); return pulses; diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java index 26038aa226..80395d2b58 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java @@ -5,18 +5,14 @@ import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.jnp.hipo4.data.Bank; -import org.jlab.jnp.hipo4.data.Event; -import org.jlab.jnp.hipo4.data.SchemaFactory; import org.jlab.utils.groups.IndexedTable; - -import net.jcip.annotations.GuardedBy; import org.jlab.utils.groups.NamedEntry; /** * A new extraction method dedicated to the AHDC signal waveform * - * Some blocks of code are inspired by MVTFitter.java + * Some blocks of code are inspired by MVTFitter.java and Bonus12 (`createBonusBank()`) * * @author ftouchte */ @@ -29,15 +25,15 @@ public class ModeAHDC extends HipoExtractor { * * @param pars CCDB row * @param id link to row in source bank + * @param timestamp ... + * @param time time (exprimed in bin) of the first channel of the AHDC pulse (after or not zero suppress; if ZS=0, time == 0) * @param samples ADC samples */ @Override - public List extract(NamedEntry pars, int id, short... samples){ + public List extract(NamedEntry pars, int id, long timestamp, long time, short... samples){ // Settings parameters (they can be initialised by a CCDB) - float samplingTime = 44; - int sparseSample = 0; - short adcOffset = 0; - long timeStamp = 0; + float samplingTime = 50.0f; + short adcOffset = 0; ///< pedestal of the pulse float fineTimeStampResolution = 0; float amplitudeFractionCFA = 0.5f; @@ -46,11 +42,9 @@ public List extract(NamedEntry pars, int id, short... samples){ // Calculation intermediaries int binMax = 0; //Bin of the max ADC over the pulse - int binOffset = 0; //Offset due to sparse sample float adcMax = 0; //Max value of ADC over the pulse (fitted) float timeMax =0; //Time of the max ADC over the pulse (fitted) float integral = 0; //Sum of ADCs over the pulse (not fitted) - long timestamp = 0; short[] samplesCorr; //Waveform after offset (pedestal) correction int binNumber = 0; //Number of bins in one waveform @@ -62,7 +56,7 @@ public List extract(NamedEntry pars, int id, short... samples){ /// ///////////////////////// // Begin waveform correction /// //////////////////////// - //waveformCorrection(samples,adcOffset,samplingTime,sparseSample, binMax, adcMax, integral, samplesCorr[], binOffset, timeMax); + //waveformCorrection(samples,adcOffset,samplingTime, binMax, adcMax, integral, samplesCorr[], time, timeMax); /** * This method subtracts the pedestal (noise) from samples and stores it in : samplesCorr * It also computes a first value for : adcMax, binMax, timeMax and integral @@ -70,9 +64,8 @@ public List extract(NamedEntry pars, int id, short... samples){ * @param samples ADC samples * @param adcOffset pedestal or noise level * @param samplingTime time between two adc bins - * @param sparseSample used to define binOffset */ - //private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int sparseSample, int binMax, int adcMax, int integral, short samplesCorr[], int binOffset, int timeMax){ + //private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int binMax, int adcMax, int integral, short samplesCorr[], int time, int timeMax){ binNumber = samples.length; binMax = 0; if (binNumber >= 5) { @@ -106,8 +99,7 @@ public List extract(NamedEntry pars, int id, short... samples){ } binMax = (binMax + binMax2)/2; } - binOffset = sparseSample*binMax; - timeMax = (binMax + binOffset)*samplingTime; + timeMax = (binMax + time)*samplingTime; //} /// ///////////////////////// @@ -155,7 +147,7 @@ public List extract(NamedEntry pars, int id, short... samples){ if (binRise + 1 <= binNumber-1) slopeRise = samplesCorr[binRise+1] - samplesCorr[binRise]; float fittedBinRise = (slopeRise == 0) ? binRise : binRise + (threshold - samplesCorr[binRise])/slopeRise; - leadingEdgeTime = (fittedBinRise + binOffset)*samplingTime; // binOffset is determined in wavefromCorrection() // must be the same for all time ? // or must be defined using fittedBinRise*sparseSample + leadingEdgeTime = (fittedBinRise + time)*samplingTime; // trailingEdgeTime int binFall = binMax; @@ -172,7 +164,7 @@ public List extract(NamedEntry pars, int id, short... samples){ if (binFall - 1 >= 0) slopeFall = samplesCorr[binFall] - samplesCorr[binFall-1]; float fittedBinFall = (slopeFall == 0) ? binFall : binFall-1 + (threshold - samplesCorr[binFall-1])/slopeFall; - trailingEdgeTime = (fittedBinFall + binOffset)*samplingTime; + trailingEdgeTime = (fittedBinFall + time)*samplingTime; // timeOverThreshold timeOverThreshold = trailingEdgeTime - leadingEdgeTime; @@ -217,29 +209,10 @@ public List extract(NamedEntry pars, int id, short... samples){ if (binZero + 1 <= binNumber) slopeCFD = signal[binZero+1] - signal[binZero]; float fittedBinZero = (slopeCFD == 0) ? binZero : binZero + (0 - signal[binZero])/slopeCFD; - constantFractionTime = (fittedBinZero + binOffset)*samplingTime; + constantFractionTime = (fittedBinZero + time)*samplingTime; //} - /// ///////////////////////// - // Begin fineTimeStampCorrection - /// //////////////////////// - //fineTimeStampCorrection(timeStamp,fineTimeStampResolution); - /** - * From MVTFitter.java - * Make fine timestamp correction (using dream (=electronic chip) clock) - * @param timeStamp timing informations (used to make fine corrections) - * @param fineTimeStampResolution precision of dream clock (usually 8) - */ - //private void fineTimeStampCorrection (long timeStamp, float fineTimeStampResolution) { - //this.timestamp = timeStamp; - String binaryTimeStamp = Long.toBinaryString(timeStamp); //get 64 bit timestamp in binary format - if (binaryTimeStamp.length()>=3){ - byte fineTimeStamp = Byte.parseByte(binaryTimeStamp.substring(binaryTimeStamp.length()-3,binaryTimeStamp.length()),2); //fineTimeStamp : keep and convert last 3 bits of binary timestamp - timeMax += (float) ((fineTimeStamp+0.5) * fineTimeStampResolution); //fineTimeStampCorrection - // Question : I wonder if I have to do the same thing of all time quantities that the extract() methods compute. - } - //} // output Pulse pulse = new Pulse(); pulse.id = id; @@ -252,19 +225,11 @@ public List extract(NamedEntry pars, int id, short... samples){ pulse.timeOverThreshold = timeOverThreshold; pulse.constantFractionTime = constantFractionTime; //pulse.binMax = binMax; - //pulse.binOffset = binOffset; pulse.pedestal = adcOffset; List output = new ArrayList<>(); output.add(pulse); return output; } - /** - * Fit the max of the pulse using parabolic fit, this method updates the timeMax and adcMax values - * @param samplingTime time between 2 ADC bins - */ - private void fitParabolic(float samplingTime) { - - } @Override public void update(int n, IndexedTable it, DataEvent event, String wfBankName, String adcBankName) { diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 6dc61e0065..308912accb 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 3b1e1e0e21..d9d85f77a8 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -90,13 +90,13 @@ org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT compile diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 7a059f995c..583fd9a1fa 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -27,12 +27,12 @@ org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT java3d diff --git a/common-tools/clas-logging/pom.xml b/common-tools/clas-logging/pom.xml index 0066ae526e..d3548b1a32 100644 --- a/common-tools/clas-logging/pom.xml +++ b/common-tools/clas-logging/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index f4630287b2..127660462a 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index a40eb684fb..71ebc4db78 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,14 +4,14 @@ org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index 49da337693..2fbc765629 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -42,37 +42,37 @@ org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/clas-tracking/pom.xml b/common-tools/clas-tracking/pom.xml index 54afb47497..14af5e6a8a 100644 --- a/common-tools/clas-tracking/pom.xml +++ b/common-tools/clas-tracking/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -22,7 +22,7 @@ org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar diff --git a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitter.java b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitter.java index c723fb2a3f..cfdce11c30 100644 --- a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitter.java +++ b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitter.java @@ -708,7 +708,9 @@ private boolean filter(int k, boolean forward, double annealingFactor) { return false; } } - + + // Since no vertex inforamtion, the starting point for path length is the final point at the last layer. + // After vertex information is obtained, transition for the starting point from the final point to vertex will be taken. private boolean filter(int k, boolean forward) { StateVec sVec = sv.transported(forward).get(k); org.jlab.clas.tracking.kalmanfilter.AMeasVecs.MeasVec mVec = mv.measurements.get(k); @@ -857,7 +859,9 @@ public Matrix filterCovMat(double[] H, Matrix Ci, double V) { private void calcFinalChisq(int sector) { calcFinalChisq(sector, false); } - + + // Since no vertex inforamtion, the starting point for path length is the final point at the last layer. + // After vertex information is obtained, transition for the starting point from the final point to vertex will be taken. private void calcFinalChisq(int sector, boolean nofilter) { int k = svzLength - 1; this.chi2 = 0; @@ -880,9 +884,9 @@ private void calcFinalChisq(int sector, boolean nofilter) { sv.transport(sector, k, 0, sVec, mv, this.getSwimmer(), forward); StateVec svc = sv.transported(forward).get(0); - path += svc.deltaPath; + path += (forward ? 1 : -1) * svc.deltaPath; svc.setPathLength(path); - + double V0 = mv.measurements.get(0).surface.unc[0]; Point3D point = new Point3D(svc.x, svc.y, mv.measurements.get(0).surface.measPoint.z()); @@ -922,7 +926,7 @@ private void calcFinalChisq(int sector, boolean nofilter) { double h = mv.hDoca(point, mv.measurements.get(k1 + 1).surface.wireLine[0]); svc = sv.transported(forward).get(k1 + 1); - path += svc.deltaPath; + path += (forward ? 1 : -1) * svc.deltaPath; svc.setPathLength(path); svc.setProjector(mv.measurements.get(k1 + 1).surface.wireLine[0].origin().x()); svc.setProjectorDoca(h); @@ -975,7 +979,7 @@ private void calcFinalChisqDAF(int sector, boolean nofilter) { sv.transport(sector, k, 0, sVec, mv, this.getSwimmer(), forward); StateVec svc = sv.transported(forward).get(0); - path += svc.deltaPath; + path += (forward ? 1 : -1) * svc.deltaPath; svc.setPathLength(path); Point3D point = new Point3D(svc.x, svc.y, mv.measurements.get(0).surface.measPoint.z()); @@ -1047,7 +1051,7 @@ private void calcFinalChisqDAF(int sector, boolean nofilter) { } svc = sv.transported(forward).get(k1 + 1); - path += svc.deltaPath; + path += (forward ? 1 : -1) * svc.deltaPath; svc.setPathLength(path); point = new Point3D(sv.transported(forward).get(k1 + 1).x, sv.transported(forward).get(k1 + 1).y, mv.measurements.get(k1 + 1).surface.measPoint.z()); @@ -1116,6 +1120,10 @@ private void calcFinalChisqDAF(int sector, boolean nofilter) { public Matrix propagateToVtx(int sector, double Zf) { return sv.transport(sector, finalStateVec.k, Zf, finalStateVec, mv, this.getSwimmer()); } + + public double getDeltaPathToVtx(int sector, double Zf) { + return sv.getDeltaPath(sector, finalStateVec.k, Zf, finalStateVec, mv, this.getSwimmer()); + } //Todo: apply the common funciton to replace current function above @Override diff --git a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitterStraight.java b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitterStraight.java index 232bcaa7d0..fb563fcc8b 100644 --- a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitterStraight.java +++ b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/KFitterStraight.java @@ -406,6 +406,8 @@ private void calcFinalChisq(int sector) { calcFinalChisq(sector, false); } + // Since no vertex inforamtion, the starting point for path length is the final point at the last layer. + // After vertex information is obtained, transition for the starting point from the final point to vertex will be taken. private void calcFinalChisq(int sector, boolean nofilter) { int k = svzLength - 1; this.chi2 = 0; @@ -426,11 +428,11 @@ private void calcFinalChisq(int sector, boolean nofilter) { kfStateVecsAlongTrajectory = new ArrayList<>(); if (sVec != null && sVec.CM != null) { - boolean forward = false; + boolean forward = false; sv.transport(sector, k, 0, sVec, mv, this.getSwimmer(), forward); StateVec svc = sv.transported(forward).get(0); - path += svc.deltaPath; + path += (forward ? 1 : -1) * svc.deltaPath; svc.setPathLength(path); double V0 = mv.measurements.get(0).surface.unc[0]; @@ -473,7 +475,7 @@ private void calcFinalChisq(int sector, boolean nofilter) { double h = mv.hDoca(point, mv.measurements.get(k1 + 1).surface.wireLine[0]); svc = sv.transported(forward).get(k1+1); - path += svc.deltaPath; + path += (forward ? 1 : -1) * svc.deltaPath; svc.setPathLength(path); svc.setProjector(mv.measurements.get(k1 + 1).surface.wireLine[0].origin().x()); svc.setProjectorDoca(h); @@ -504,6 +506,10 @@ public Matrix propagateToVtx(int sector, double Zf) { return sv.transport(sector, finalStateVec.k, Zf, finalStateVec, mv, this.getSwimmer()); } + public double getDeltaPathToVtx(int sector, double Zf) { + return sv.getDeltaPath(sector, finalStateVec.k, Zf, finalStateVec, mv, this.getSwimmer()); + } + @Override public void runFitter(AStateVecs sv, AMeasVecs mv) { throw new UnsupportedOperationException("Not supported yet."); diff --git a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/StateVecs.java b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/StateVecs.java index f69dd0bfc9..269e966c21 100644 --- a/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/StateVecs.java +++ b/common-tools/clas-tracking/src/main/java/org/jlab/clas/tracking/kalmanfilter/zReference/StateVecs.java @@ -53,7 +53,7 @@ public void initFromHB(StateVec initSV, double beta) { this.trackTrajS.clear(); this.trackTrajT.put(0, new StateVec(initSV)); } - + /** * * @param sector @@ -150,6 +150,104 @@ public Matrix transport(int sector, int i, double Zf, StateVec iVec, AMeasVecs m return fVec.CM; + } + + /** + * + * @param sector + * @param i initial state vector index + * @param Zf + * @param iVec state vector at the initial index + * @param mv measurements + */ + public double getDeltaPath(int sector, int i, double Zf, StateVec iVec, AMeasVecs mv, Swim swimmer) { // s = signed step-size + + double stepSize = 1.0; + StateVec fVec = new StateVec(0); + fVec.x = iVec.x; + fVec.y = iVec.y; + fVec.z = iVec.z; + fVec.tx = iVec.tx; + fVec.ty = iVec.ty; + fVec.Q = iVec.Q; + fVec.B = iVec.B; + Matrix5x5.copy(iVec.CM, fVec.CM); + + double s = 0; + double zInit = mv.measurements.get(i).surface.measPoint.z(); + double BatMeas = iVec.B; + + double z = zInit; + + while (Math.signum(Zf - zInit) * z < Math.signum(Zf - zInit) * Zf) { + z = fVec.z; + if (z == Zf) { + break; + } + + double x = fVec.x; + double y = fVec.y; + double tx = fVec.tx; + double ty = fVec.ty; + double Q = fVec.Q; + double dPath = fVec.deltaPath; + Matrix cMat = new Matrix(); + Matrix5x5.copy(fVec.CM, cMat); + s = Math.signum(Zf - zInit) * stepSize; + + // LOGGER.log(Level.FINE, " from "+(float)Z[i]+" to "+(float)Z[f]+" at "+(float)z+" By is "+bf[1]+" B is "+Math.sqrt(bf[0]*bf[0]+bf[1]*bf[1]+bf[2]*bf[2])/Bmax+" stepSize is "+s); + if (Math.signum(Zf - zInit) * (z + s) > Math.signum(Zf - zInit) * Zf) { + s = Math.signum(Zf - zInit) * Math.abs(Zf - z); + } + + //rk.RK4transport(sector, Q, x, y, z, tx, ty, s, swimmer, cMat, fVec, dPath); + rk.RK4transport(sector, s, swimmer, cMat, fVec); + + // Q process noise matrix estimate + double p = Math.abs(1. / iVec.Q); + + double X0 = this.getX0(mv.measurements.get(i).surface, z, Z); + double t_ov_X0 = Math.abs(s) / X0;//path length in radiation length units = t/X0 [true path length/ X0] ; Ar radiation length = 14 cm + + double beta = this.beta; + if (beta > 1.0 || beta <= 0) { + beta = 1.0; + } + + double sctRMS = 0; + + ////// Todo: Modify multi-scattering or remove it; After update, some parameters, like iteration termintion chonditions, may need to be updated. + // Speed of light should be 1 + // From one measurement site to another, F and Q should be calculated separaetely with multiple steps; and then C' = FTCF + Q + if (Math.abs(s) > 0) { + sctRMS = ((0.0136) / (beta * PhysicsConstants.speedOfLight() * p)) * Math.sqrt(t_ov_X0) + * (1 + 0.038 * Math.log(t_ov_X0)); + } + + double cov_txtx = (1 + tx * tx) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + double cov_tyty = (1 + ty * ty) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + double cov_txty = tx * ty * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + + fMS.set( + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, cov_txtx, cov_txty, 0, + 0, 0, cov_txty, cov_tyty, 0, + 0, 0, 0, 0, 0 + ); + + Matrix5x5.copy(fVec.CM, copyMatrix); + Matrix5x5.add(copyMatrix, fMS, fVec.CM); + + if (Math.abs(fVec.B - BatMeas) < 0.0001) { + stepSize *= 2; + } + + BatMeas = fVec.B; + } + + return fVec.deltaPath; + } /** diff --git a/common-tools/clas-utils/pom.xml b/common-tools/clas-utils/pom.xml index 8a5af26906..8606193c04 100644 --- a/common-tools/clas-utils/pom.xml +++ b/common-tools/clas-utils/pom.xml @@ -3,21 +3,21 @@ 4.0.0 org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.apache.commons diff --git a/common-tools/cnuphys/apache/.classpath b/common-tools/cnuphys/apache/.classpath deleted file mode 100644 index 6ae56430f7..0000000000 --- a/common-tools/cnuphys/apache/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/apache/.project b/common-tools/cnuphys/apache/.project deleted file mode 100644 index c79ffc7af2..0000000000 --- a/common-tools/cnuphys/apache/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - apache - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs b/common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 6d08f8e4e5..0000000000 --- a/common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Thu Oct 18 15:20:29 EDT 2012 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/common-tools/cnuphys/magfield/pom.xml b/common-tools/cnuphys/magfield/pom.xml index 7457f062fe..716b81d3d6 100644 --- a/common-tools/cnuphys/magfield/pom.xml +++ b/common-tools/cnuphys/magfield/pom.xml @@ -23,7 +23,7 @@ org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/cnuphys/magfield/src/main/java/.classpath b/common-tools/cnuphys/magfield/src/main/java/.classpath deleted file mode 100644 index 737dc4026a..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/common-tools/cnuphys/magfield/src/main/java/.project b/common-tools/cnuphys/magfield/src/main/java/.project deleted file mode 100644 index 65d79e0096..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - magfield - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath b/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath deleted file mode 100644 index 737dc4026a..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project b/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project deleted file mode 100644 index 65d79e0096..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - magfield - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/numRec/.classpath b/common-tools/cnuphys/numRec/.classpath deleted file mode 100644 index 4ce1143c36..0000000000 --- a/common-tools/cnuphys/numRec/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/common-tools/cnuphys/numRec/.project b/common-tools/cnuphys/numRec/.project deleted file mode 100644 index e9bd6eb16c..0000000000 --- a/common-tools/cnuphys/numRec/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - numericalRec - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/numRec/bin/.classpath b/common-tools/cnuphys/numRec/bin/.classpath deleted file mode 100644 index 233be1d2c4..0000000000 --- a/common-tools/cnuphys/numRec/bin/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/numRec/bin/.project b/common-tools/cnuphys/numRec/bin/.project deleted file mode 100644 index 848f89238f..0000000000 --- a/common-tools/cnuphys/numRec/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - numRecip - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/numRec/src/.classpath b/common-tools/cnuphys/numRec/src/.classpath deleted file mode 100644 index 233be1d2c4..0000000000 --- a/common-tools/cnuphys/numRec/src/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/numRec/src/.project b/common-tools/cnuphys/numRec/src/.project deleted file mode 100644 index 848f89238f..0000000000 --- a/common-tools/cnuphys/numRec/src/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - numRecip - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/snr/src/main/java/.classpath b/common-tools/cnuphys/snr/src/main/java/.classpath deleted file mode 100644 index c1248cd1ab..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/snr/src/main/java/.project b/common-tools/cnuphys/snr/src/main/java/.project deleted file mode 100644 index 95191682a3..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - snr - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath b/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath deleted file mode 100644 index c1248cd1ab..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project b/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project deleted file mode 100644 index 95191682a3..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - snr - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/splot/.classpath b/common-tools/cnuphys/splot/.classpath deleted file mode 100644 index 748dc76710..0000000000 --- a/common-tools/cnuphys/splot/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/common-tools/cnuphys/splot/.project b/common-tools/cnuphys/splot/.project deleted file mode 100644 index 1d5b581255..0000000000 --- a/common-tools/cnuphys/splot/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - splot - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/splot/src/main/java/.classpath b/common-tools/cnuphys/splot/src/main/java/.classpath deleted file mode 100644 index 8320dcd5ac..0000000000 --- a/common-tools/cnuphys/splot/src/main/java/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/common-tools/cnuphys/splot/src/main/java/.project b/common-tools/cnuphys/splot/src/main/java/.project deleted file mode 100644 index 1d5b581255..0000000000 --- a/common-tools/cnuphys/splot/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - splot - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs b/common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab1683..0000000000 --- a/common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/common-tools/cnuphys/swimmer/pom.xml b/common-tools/cnuphys/swimmer/pom.xml index 1ce598917b..701aec7e85 100644 --- a/common-tools/cnuphys/swimmer/pom.xml +++ b/common-tools/cnuphys/swimmer/pom.xml @@ -35,7 +35,7 @@ org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/cnuphys/swimmer/src/main/java/.classpath b/common-tools/cnuphys/swimmer/src/main/java/.classpath deleted file mode 100644 index 74825a682b..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/common-tools/cnuphys/swimmer/src/main/java/.project b/common-tools/cnuphys/swimmer/src/main/java/.project deleted file mode 100644 index 049cf6453d..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - swimmer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath deleted file mode 100644 index 74825a682b..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project deleted file mode 100644 index 049cf6453d..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - swimmer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/coat-lib/deployDistribution.sh b/common-tools/coat-lib/deployDistribution.sh index 82f60669c1..0ba9881890 100755 --- a/common-tools/coat-lib/deployDistribution.sh +++ b/common-tools/coat-lib/deployDistribution.sh @@ -8,7 +8,7 @@ cd `dirname $0` # Script is exporting existing Jar files to repository #------------------------------------------------------------------------------------------------- -VERSION=11.1.2 +VERSION=12.0.1t mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file \ -Dfile=target/coat-libs-${VERSION}-SNAPSHOT.jar \ diff --git a/common-tools/coat-lib/pom.xml b/common-tools/coat-lib/pom.xml index 19adba8240..7022cba272 100644 --- a/common-tools/coat-lib/pom.xml +++ b/common-tools/coat-lib/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.jlab.clas coat-libs - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT pom @@ -94,67 +94,67 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clara-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/parent/pom.xml b/common-tools/parent/pom.xml index 2b2f55a848..233bc82357 100644 --- a/common-tools/parent/pom.xml +++ b/common-tools/parent/pom.xml @@ -3,7 +3,7 @@ org.jlab.clas common-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT pom diff --git a/common-tools/pom.xml b/common-tools/pom.xml index 818a5f5b0d..9c7236d6c0 100644 --- a/common-tools/pom.xml +++ b/common-tools/pom.xml @@ -2,14 +2,14 @@ 4.0.0 org.jlab.clas common-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT pom org.jlab.clas clas12rec ../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/common-tools/swim-tools/pom.xml b/common-tools/swim-tools/pom.xml index ea39341ec5..ef3ea08e74 100644 --- a/common-tools/swim-tools/pom.xml +++ b/common-tools/swim-tools/pom.xml @@ -3,21 +3,21 @@ 4.0.0 org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/etc/bankdefs/hipo4/README.md b/etc/bankdefs/hipo4/README.md index 8b0eac1a24..cf2881f836 100644 --- a/etc/bankdefs/hipo4/README.md +++ b/etc/bankdefs/hipo4/README.md @@ -1,12 +1,7 @@ # Bank Group and Item IDs -This file was generated by -```bash -etc/bankdefs/util/dumpBankIDs.rb etc/bankdefs/hipo4 -``` - -> [!IMPORTANT] -> Please re-run this script if you modify any of the bank definitions. +> [!NOTE] +> Iguana banks, which are defined in the Iguana repository, use group number 30000. ## Group 40 @@ -381,13 +376,24 @@ etc/bankdefs/util/dumpBankIDs.rb etc/bankdefs/hipo4 | Item ID | Name | Description | | --- | --- | --- | -| 12 | `AHDC::tdc` | TDC bank for the ALERT Wire Chamber | +| 10 | `AHDC::wf` | Waveform bank for the AHDC | +| 11 | `AHDC::adc` | ADC bank for the ALERT Wire Chamber | ## Group 22500 | Item ID | Name | Description | | --- | --- | --- | -| 11 | `ATOF::adc` | ADC bank for the ALERT time-of-flight detector | +| 12 | `ATOF::tdc` | TDC bank for the ALERT TOF | +| 21 | `ATOF::hits` | Reconstructed ATOF hits | +| 22 | `ATOF::clusters` | Clusters in ATOF | + +## Group 22600 + +| Item ID | Name | Description | +| --- | --- | --- | +| 21 | `RECOIL::hits` | RECOIL hits | +| 22 | `RECOIL::clusters` | reconstructed clusters from RECOIL | +| 23 | `RECOIL::crosses` | reconstructed crosses from RECOIL | ## Group 23000 @@ -399,3 +405,5 @@ etc/bankdefs/util/dumpBankIDs.rb etc/bankdefs/hipo4 | 24 | `AHDC::PreClusters` | Pre Clusters info | | 25 | `AHDC::Clusters` | Clusters info | | 26 | `AHDC::KFTrack` | Reco Kalman Filter Tracks | +| 30 | `AHDC_AI::Prediction` | Prediction given by AI | +| 31 | `ALERT::Projections` | Track Projections to ATOF | diff --git a/etc/bankdefs/hipo4/alert.json b/etc/bankdefs/hipo4/alert.json index a740b49389..5efaaa8f6f 100644 --- a/etc/bankdefs/hipo4/alert.json +++ b/etc/bankdefs/hipo4/alert.json @@ -313,6 +313,14 @@ "name": "Doca", "type": "D", "info": "distance od closest approch (mm)" + }, { + "name": "residual", + "type": "D", + "info": "residual (mm)" + }, { + "name": "residual_prefit", + "type": "D", + "info": "residual pre-fit (mm)" } ] }, { diff --git a/etc/bankdefs/hipo4/data.json b/etc/bankdefs/hipo4/data.json index 5ccc2696e4..9f42279e5d 100644 --- a/etc/bankdefs/hipo4/data.json +++ b/etc/bankdefs/hipo4/data.json @@ -73,7 +73,8 @@ { "name":"s61" , "type":"S", "info":""}, { "name":"s62" , "type":"S", "info":""}, { "name":"s63" , "type":"S", "info":""}, - { "name":"s64" , "type":"S", "info":""} + { "name":"s64" , "type":"S", "info":""}, + { "name":"time" , "type":"I", "info":"for fine time correction"} ] }, { @@ -107,7 +108,9 @@ { "name":"component" , "type":"S", "info":"signal (1-2)"}, { "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"}, { "name":"TDC" , "type":"I", "info":"TDC value"}, - { "name":"ToT" , "type":"I", "info":"Time Over Threshold"} + { "name":"ToT" , "type":"I", "info":"Time Over Threshold"}, + { "name":"timestamp" , "type":"L", "info":"timestamp"}, + { "name":"trigger" , "type":"I", "info":"trigger number"} ] }, { @@ -209,7 +212,8 @@ { "name":"layer" , "type":"B", "info":"layer (1..36)"}, { "name":"component" , "type":"S", "info":"wire number (1..112)"}, { "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"}, - { "name":"TDC" , "type":"I", "info":"TDC value"} + { "name":"TDC" , "type":"I", "info":"TDC value"}, + { "name":"ToT" , "type":"S", "info":"Time Over Threshold"} ] }, { diff --git a/parent/pom.xml b/parent/pom.xml index 7ec68aacdb..866c403634 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -3,7 +3,7 @@ org.jlab.clas clas12rec - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT pom diff --git a/pom.xml b/pom.xml index dfa7482c60..a4d40c561c 100644 --- a/pom.xml +++ b/pom.xml @@ -2,14 +2,14 @@ 4.0.0 org.jlab.clas clas12 - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT pom org.jlab.clas clas12rec parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/alert/pom.xml b/reconstruction/alert/pom.xml index a6e4c5cf61..366b085ee5 100644 --- a/reconstruction/alert/pom.xml +++ b/reconstruction/alert/pom.xml @@ -13,31 +13,31 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT compile org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT compile org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT compile diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java index a558763d78..3f196db93c 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java @@ -34,6 +34,9 @@ public NDList processInput(TranslatorContext translatorContext, float[] floats) return new NDList(samples); } }; + System.setProperty("ai.djl.pytorch.num_interop_threads", "1"); + System.setProperty("ai.djl.pytorch.num_threads", "1"); + System.setProperty("ai.djl.pytorch.graph_optimizer", "false"); String path = CLASResources.getResourcePath("etc/nnet/ALERT/model_AHDC/"); Criteria my_model = Criteria.builder().setTypes(float[].class, Float.class) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java index ecab32728c..f1773e73e9 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java @@ -39,6 +39,10 @@ public double getY() { return y; } + public int getSuperlayer() { + return this.preclusters.get(0).get_Super_layer(); + } + public String toString() { return "PreCluster{" + "X: " + this.x + " Y: " + this.y + " phi: " + Math.atan2(this.y, this.x) + "}\n"; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java index dce5414001..d88ee4a661 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java @@ -1,5 +1,6 @@ package org.jlab.rec.ahdc.AI; +import org.apache.commons.lang3.mutable.MutableBoolean; import org.jlab.rec.ahdc.Hit.Hit; import java.io.File; @@ -7,9 +8,31 @@ import java.io.IOException; import java.util.*; +/** + * The TrackConstruction class is responsible for constructing all possible track + * candidates from a set of superpreclusters. + */ public class TrackConstruction { + private int max_number_of_track_candidates = 10000; + private double max_angle = Math.toRadians(60); + + /** + * Default constructor. + */ public TrackConstruction() {} + /** + * Computes the modulo operation, which returns the remainder of the division + * of one number by another. This method handles floating-point edge cases + * to ensure accurate results within the expected range. + * + * @param x The dividend. + * @param y The divisor. If y is 0, the method returns x. + * @return The result of x modulo y. The result is in the range: + * - [0..y) if y > 0 + * - (y..0] if y < 0 + * Special cases are handled to avoid floating-point inaccuracies. + */ private double mod(double x, double y) { if (0. == y) return x; @@ -33,74 +56,135 @@ private double mod(double x, double y) { return m; } + + /** + * Wraps an angle to the range [0, 2Ï€). + * + * @param angle The angle to wrap. + * @return The angle wrapped to the range [0, 2Ï€). + */ private double warp_zero_two_pi(double angle) { return mod(angle, 2. * Math.PI); } + /** + * Checks if an angle is within a specified range. + * + * @param angle The angle to check. + * @param lower The lower bound of the range. + * @param upper The upper bound of the range. + * @return {@code true} if the angle is within the range, {@code false} otherwise. + */ private boolean angle_in_range(double angle, double lower, double upper) { return warp_zero_two_pi(angle - lower) <= warp_zero_two_pi(upper - lower); } + /** + * Computes the Cartesian product of two lists of integers, ensuring the number of track candidates + * does not exceed the maximum allowed limit. + * + * @param v1 The first list of integer combinations. + * @param v2 The second list of integers to combine with the first list. + * @param too_much_track_candidates A mutable boolean that is set to {@code true} if the number of track candidates exceeds the maximum limit. + * @param number_of_track_candidates The current count of track candidates. + * @return A list of all possible combinations of integers from {@code v1} and {@code v2}. + */ + private ArrayList> cartesian_product(ArrayList> v1, ArrayList v2, MutableBoolean too_much_track_candidates, int number_of_track_candidates) { + ArrayList> result = new ArrayList<>(); + for (ArrayList i : v1) { + if (too_much_track_candidates.booleanValue()) break; + for (int j : v2) { + if (too_much_track_candidates.booleanValue()) break; + ArrayList n = new ArrayList<>(i); + n.add(j); + result.add(n); + + if (number_of_track_candidates + result.size() >= max_number_of_track_candidates) { + too_much_track_candidates.setValue(true); + break; + } + } + - public ArrayList> get_all_possible_track(ArrayList preclusterSuperlayers) { - - // Get seeds to start the track finding algorithm - ArrayList seeds = new ArrayList<>(); - for (PreclusterSuperlayer precluster : preclusterSuperlayers) { - if (precluster.getPreclusters().get(0).get_hits_list().get(0).getSuperLayerId() == 1) seeds.add(precluster); } - seeds.sort(new Comparator() { - @Override - public int compare(PreclusterSuperlayer a1, PreclusterSuperlayer a2) { - return Double.compare(Math.atan2(a1.getY(), a1.getX()), Math.atan2(a2.getY(), a2.getX())); + return result; + } + + public boolean get_all_possible_track(ArrayList preclusterSuperlayers, ArrayList> all_track_candidates) { + + /* + Identify all superpreclusters located in the first superlayer. + These superpreclusters serve as seeds for constructing track candidates. + A track candidate always starts from a seed. + */ + ArrayList seed_index = new ArrayList<>(); + for (int i = 0; i < preclusterSuperlayers.size(); i++) { + if (!preclusterSuperlayers.get(i).getPreclusters().isEmpty() && + preclusterSuperlayers.get(i).getSuperlayer() == 1) { + seed_index.add(i); } - }); - // System.out.println("seeds: " + seeds); + } - // Get all possible tracks ---------------------------------------------------------------- - double max_angle = Math.toRadians(60); - ArrayList> all_combinations = new ArrayList<>(); - for (PreclusterSuperlayer seed : seeds) { - double phi_seed = warp_zero_two_pi(Math.atan2(seed.getY(), seed.getX())); + boolean sucess = true; + int number_of_track_candidates = 0; - ArrayList track = new ArrayList<>(); - for (PreclusterSuperlayer p : preclusterSuperlayers) { - double phi_p = warp_zero_two_pi(Math.atan2(p.getY(), p.getX())); - if (angle_in_range(phi_p, phi_seed - max_angle, phi_seed + max_angle)) track.add(p); - } - // System.out.println("track: " + track.size()); - - ArrayList> combinations = new ArrayList<>(List.of(new ArrayList<>(List.of(seed)))); - // System.out.println("combinations: " + combinations); - - for (int i = 1; i < 5; ++i) { - ArrayList> new_combinations = new ArrayList<>(); - for (ArrayList combination : combinations) { - - for (PreclusterSuperlayer precluster : track) { - if (precluster.getPreclusters().get(0).get_hits_list().get(0).getSuperLayerId() == seed.getPreclusters().get(0).get_hits_list().get(0).getSuperLayerId() + i) { - // System.out.printf("Good Precluster x: %.2f, y: %.2f, r: %.2f%n", precluster.getX(), precluster.getY(), Math.hypot(precluster.getX(), precluster.getY())); - // System.out.println("combination: " + combination); - - ArrayList new_combination = new ArrayList<>(combination); - new_combination.add(precluster); - // System.out.println("new_combination: " + new_combination); - new_combinations.add(new_combination); - } - } - for (ArrayList c : new_combinations) { - // System.out.println("c.size: " + c.size() + ", c: " + c); - } + // Loop over all seeds to construct track candidates + for (int s : seed_index) { + // Check if the number of track candidates exceeds the maximum limit if so, stop the loop + if (!sucess) break; + // Find all superpreclusters that have a phi angle within phi angle of the seed +/- 60 degrees + // The goal is to reduce the number of superpreclusters to loop over + double phi_seed = warp_zero_two_pi(Math.atan2(preclusterSuperlayers.get(s).getY(), preclusterSuperlayers.get(s).getX())); // phi angle of the seed + ArrayList all_superpreclusters = new ArrayList<>(); // all superpreclusters that are within phi angle of the seed + for (int i = 0; i < preclusterSuperlayers.size(); ++i) { + double phi_p = warp_zero_two_pi(Math.atan2(preclusterSuperlayers.get(i).getY(), preclusterSuperlayers.get(i).getX())); + if (angle_in_range(phi_p, phi_seed - max_angle, phi_seed + max_angle)) { + all_superpreclusters.add(i); } - combinations = new_combinations; - if (combinations.size() > 10000) break; } - for (ArrayList combination : combinations) { - if (combination.size() == 5) { - all_combinations.add(combination); + + + // Sort the superpreclusters by superlayer to have a simpler loops after + ArrayList superpreclusters_s1 = new ArrayList<>(List.of(s)); + ArrayList superpreclusters_s3 = new ArrayList<>(); + ArrayList superpreclusters_s4 = new ArrayList<>(); + ArrayList superpreclusters_s2 = new ArrayList<>(); + ArrayList superpreclusters_s5 = new ArrayList<>(); + + for (int i = 0; i < all_superpreclusters.size(); i++) { + if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 2) + superpreclusters_s2.add(all_superpreclusters.get(i)); + else if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 3) + superpreclusters_s3.add(all_superpreclusters.get(i)); + else if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 4) + superpreclusters_s4.add(all_superpreclusters.get(i)); + else if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 5) + superpreclusters_s5.add(all_superpreclusters.get(i)); + } + + MutableBoolean too_much_track_candidates = new MutableBoolean(); // Need to be a mutable boolean to be able to change it in the cartesian_product method + too_much_track_candidates.setFalse(); + + // Find all possible combinations of superpreclusters on different superlayers + ArrayList> combinations_s1_s2 = cartesian_product(new ArrayList<>(List.of(superpreclusters_s1)), superpreclusters_s2, too_much_track_candidates, number_of_track_candidates); + ArrayList> combinations_s1_s2_s3 = cartesian_product(combinations_s1_s2, superpreclusters_s3, too_much_track_candidates, number_of_track_candidates); + ArrayList> combinations_s1_s2_s3_s4 = cartesian_product(combinations_s1_s2_s3, superpreclusters_s4, too_much_track_candidates, number_of_track_candidates); + ArrayList> combinations_s1_s2_s3_s4_s5 = cartesian_product(combinations_s1_s2_s3_s4, superpreclusters_s5, too_much_track_candidates, number_of_track_candidates); + + // Keep track of the number of track candidates + number_of_track_candidates += combinations_s1_s2_s3_s4_s5.size(); + if (too_much_track_candidates.booleanValue()) sucess = false; // If the number of track candidates exceeds the maximum limit, set success to false + + // Add all track candidates to the list of all track candidates + // And switch back from index to superprecluster + for (ArrayList combination : combinations_s1_s2_s3_s4_s5) { + ArrayList track_candidate = new ArrayList<>(); + for (int index : combination) { + track_candidate.add(preclusterSuperlayers.get(index)); } + all_track_candidates.add(track_candidate); } } - return all_combinations; + return sucess; } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java index 72b9b5f2fe..16e880dcb2 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java @@ -24,6 +24,8 @@ public DataBank fillAHDCHitsBank(DataEvent event, ArrayList hitList) { bank.setByte("superlayer", i, (byte) hitList.get(i).getSuperLayerId()); bank.setInt("wire", i, hitList.get(i).getWireId()); bank.setDouble("Doca", i, hitList.get(i).getDoca()); + bank.setDouble("residual", i, hitList.get(i).getResidual()); + bank.setDouble("residual_prefit", i, hitList.get(i).getResidualPrefit()); } return bank; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/Hit.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/Hit.java index 6ee4bab6a0..9182365273 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/Hit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/Hit.java @@ -9,6 +9,7 @@ public class Hit implements Comparable { private final int layerId; private final int wireId; private final double doca; + private final double adc; private double phi; private double radius; @@ -16,14 +17,20 @@ public class Hit implements Comparable { private boolean use = false; private double x; private double y; + private double residual_prefit; + private double residual; - public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca) { + //updated constructor with ADC + public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca, double _ADC) { this.id = _Id; this.superLayerId = _Super_layer; this.layerId = _Layer; this.wireId = _Wire; this.doca = _Doca; + this.adc = _ADC; wirePosition(); + this.residual_prefit = 0.0; + this.residual = 0.0; } private void wirePosition() { @@ -130,4 +137,22 @@ public double getY() { } public double getPhi() {return phi;} + + public double getADC() {return adc;} + + public double getResidual() { + return residual; + } + + public double getResidualPrefit() { + return residual_prefit; + } + + public void setResidual(double resid) { + this.residual = resid; + } + + public void setResidualPrefit(double resid) { + this.residual_prefit = resid; + } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java index cef052afef..91e7a1daad 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java @@ -32,9 +32,10 @@ public void fetch_AHDCHits(DataEvent event) { int layer = number % 10; int superlayer = (int) (number % 100) / 10; int wire = bankDGTZ.getShort("component", i); + double adc = bankDGTZ.getInt("ADC", i); double doca = bankDGTZ.getShort("ped", i) / 1000.0; - hits.add(new Hit(id, superlayer, layer, wire, doca)); + hits.add(new Hit(id, superlayer, layer, wire, doca, adc)); } } this.set_AHDCHits(hits); @@ -75,4 +76,4 @@ public void set_TrueAHDCHits(ArrayList _TrueAHDCHits) { this._TrueAHDCHits = _TrueAHDCHits; } -} \ No newline at end of file +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java index fa4d1dc477..a07e4299df 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java @@ -19,13 +19,17 @@ public class Hit implements Comparable { private final double r; private final double phi; private final double doca; - private final double adc; + private double adc; private final double numWires; private final Line3D line3D; - - // Comparison with: common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java - // here, SuperLayer, Layer, Wire, start from 1 - // in AlertDCFactory, same variables start from 1 + private final Line3D line3D_plus; + private final Line3D line3D_minus; + private int hitidx; + private int hitsign; + + // Comparison with: common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java + // here, SuperLayer, Layer, Wire, start from 1 + // in AlertDCFactory, same variables start from 1 public Hit(int superLayer, int layer, int wire, int numWire, double r, double doca) { this.superLayer = superLayer; this.layer = layer; @@ -34,6 +38,8 @@ public Hit(int superLayer, int layer, int wire, int numWire, double r, double do this.doca = doca; this.numWires = numWire; this.adc = 0;//placeholder + this.hitidx = -1; + this.hitsign = 0; final double DR_layer = 4.0;//OK final double round = 360.0;//OK @@ -104,42 +110,65 @@ public Hit(int superLayer, int layer, int wire, int numWire, double r, double do Line3D wireLine = new Line3D(lPoint, rPoint); //wireLine.show(); this.line3D = wireLine; - } - - //hit measurement vector in cylindrical coordinates: r, phi, z - public RealVector get_Vector() { - // final double costhster = Math.cos(thster); - // final double sinthster = Math.cos(thster); - RealVector wire_meas = new ArrayRealVector(new double[]{this.r(), this.phi(), 0}); - // Array2DRowRealMatrix stereo_rotation = new Array2DRowRealMatrix(new double[][]{{1, 0.0, 0.0}, {0, costhster, -sinthster}, {0, sinthster, costhster}});//rotation of wire: needed? - return wire_meas;//.multiply(stereo_rotation); + + //calculate the "virtual" left and right wires accounting for the DOCA + double deltaphi = Math.asin(this.doca/R_layer); + double wx_plus = -R_layer * Math.sin( alphaW_layer * (this.wire-1) - deltaphi );//OK + double wy_plus = -R_layer * Math.cos( alphaW_layer * (this.wire-1) - deltaphi );//OK + + double wx_plus_end = -R_layer * Math.sin( alphaW_layer * (this.wire-1) + thster * (Math.pow(-1, this.superLayer-1)) - deltaphi );//OK + double wy_plus_end = -R_layer * Math.cos( alphaW_layer * (this.wire-1) + thster * (Math.pow(-1, this.superLayer-1)) - deltaphi );//OK + + line = new Line3D(wx_plus, wy_plus, -zl/2, wx_plus_end, wy_plus_end, zl/2); + lPoint = new Point3D(); + rPoint = new Point3D(); + lPlane.intersection(line, lPoint); + rPlane.intersection(line, rPoint); + + wireLine = new Line3D(lPoint, rPoint); + this.line3D_plus = wireLine; + + double wx_minus = -R_layer * Math.sin( alphaW_layer * (this.wire-1) + deltaphi );//OK + double wy_minus = -R_layer * Math.cos( alphaW_layer * (this.wire-1) + deltaphi );//OK + + double wx_minus_end = -R_layer * Math.sin( alphaW_layer * (this.wire-1) + thster * (Math.pow(-1, this.superLayer-1)) + deltaphi );//OK + double wy_minus_end = -R_layer * Math.cos( alphaW_layer * (this.wire-1) + thster * (Math.pow(-1, this.superLayer-1)) + deltaphi );//OK + + line = new Line3D(wx_minus, wy_minus, -zl/2, wx_minus_end, wy_minus_end, zl/2); + lPoint = new Point3D(); + rPoint = new Point3D(); + lPlane.intersection(line, lPoint); + rPlane.intersection(line, rPoint); + + wireLine = new Line3D(lPoint, rPoint); + this.line3D_minus = wireLine; + } - //hit measurement vector in 1 dimension: minimize distance - doca - public RealVector get_Vector_simple() { + //hit measurement vector in 1 dimension: minimize distance - doca + public RealVector get_Vector() { return new ArrayRealVector(new double[]{this.doca}); } - //hit measurement vector in 1 dimension: minimize distance - doca - adds hit "sign" - public RealVector get_Vector_sign(int sign) { - // Attempt: multiply doca by sign - return new ArrayRealVector(new double[]{sign*this.doca}); + //hit measurement vector in 1 dimension with sign: if sign = 0, return doca, otherwise return 0 + public RealVector get_Vector(int sign, boolean goodsign) { + if(sign == 0 || goodsign){ + return new ArrayRealVector(new double[]{this.doca}); + }else{ + return new ArrayRealVector(new double[]{0.0}); + } } - public RealMatrix get_MeasurementNoise() { - final double costhster = Math.cos(thster); - final double sinthster = Math.cos(thster); - //dR = 0.1m dphi = pi dz = L/2 - Array2DRowRealMatrix wire_noise = new Array2DRowRealMatrix(new double[][]{{0.1, 0.0, 0.0}, {0.0, Math.atan(0.1/this.r), 0.0}, {0.0, 0.0, 150.0/costhster}});//uncertainty matrix in wire coordinates - Array2DRowRealMatrix stereo_rotation = new Array2DRowRealMatrix(new double[][]{{1, 0.0, 0.0}, {0, costhster, -sinthster}, {0, sinthster, costhster}});//rotation of wire - wire_noise.multiply(stereo_rotation); - - return wire_noise.multiply(wire_noise); - // + public RealMatrix get_MeasurementNoise() { + return new Array2DRowRealMatrix(new double[][]{{0.0225}}); } - - public RealMatrix get_MeasurementNoise_simple() { - return new Array2DRowRealMatrix(new double[][]{{0.01}}); + + public RealMatrix get_MeasurementNoise(boolean goodsign) { + if(goodsign){ + return new Array2DRowRealMatrix(new double[][]{{0.0225}}); + }else{ + return new Array2DRowRealMatrix(new double[][]{{2*this.doca*this.doca}}); + } } public double doca() { @@ -151,8 +180,6 @@ public double doca() { public double phi() {return phi;}//at z = 0; public double phi(double z) { - // double x_0 = r*sin(phi); - // double y_0 = r*cos(phi); double x_z = r*Math.sin( phi + thster * z/(zl*0.5) * (Math.pow(-1, this.superLayer-1)) ); double y_z = r*Math.cos( phi + thster * z/(zl*0.5) * (Math.pow(-1, this.superLayer-1)) ); return Math.atan2(x_z, y_z); @@ -161,10 +188,16 @@ public double phi(double z) { public Line3D line() {return line3D;} public double distance(Point3D point3D) { - //System.out.println("Calculating distance: "); - //this.line3D.show(); - //point3D.show(); - //System.out.println(" d = " + this.line3D.distance(point3D).length()); + return this.line3D.distance(point3D).length(); + } + + public double distance(Point3D point3D, int sign, boolean goodsign) { + //if(sign!=0) + //System.out.println(" r " + this.r + " phi " + this.phi + " doca " + this.doca + " sign " + sign + " distance " + this.line3D.distance(point3D).length() + " (sign 0) " + this.line3D_plus.distance(point3D).length() + " (sign+) " + this.line3D_minus.distance(point3D).length() + " (sign-) "); + if(!goodsign){ + if(sign>0)return this.line3D_plus.distance(point3D).length(); + if(sign<0)return this.line3D_minus.distance(point3D).length(); + } return this.line3D.distance(point3D).length(); } @@ -211,6 +244,10 @@ public double getADC() { return adc; } + public void setADC(double _adc) { + this.adc = _adc; + } + public Line3D getLine3D() { return line3D; } @@ -218,5 +255,22 @@ public Line3D getLine3D() { public double getNumWires() { return numWires; } + + public int getHitIdx() { + return hitidx; + } + + public void setHitIdx(int idx) { + this.hitidx = idx; + } + + public int getSign() { + return hitsign; + } + + public void setSign(int sign) { + this.hitsign = sign; + } + } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java index e1160642e4..d3221b2939 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java @@ -9,7 +9,7 @@ public class Hit_beam extends Hit { double r,phi; public Hit_beam(int superLayer, int layer, int wire, int numWire, double doca, double x, double y , double z) { - super(0, 0, 0, 0, Math.hypot(x,y), 0); + super(0, 0, 0, 0, Math.hypot(x,y), 0); this.x = x; this.y = y; this.z = z; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java index 3feddf5b27..1a184bf5dc 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java @@ -17,7 +17,7 @@ public class KFitter { // masses/energies in MeV private final double electron_mass_c2 = PhysicsConstants.massElectron() * 1000; private final double proton_mass_c2 = PhysicsConstants.massProton() * 1000; - + private boolean isvertexdefined = false; public KFitter(final RealVector initialStateEstimate, final RealMatrix initialErrorCovariance, final Stepper stepper, final Propagator propagator) { this.stateEstimation = initialStateEstimate; @@ -73,39 +73,39 @@ public void predict(Indicator indicator) throws Exception { } public void correct(Indicator indicator) { - //System.out.println(" state before: (" + stateEstimation.getEntry(0) + ", " + stateEstimation.getEntry(1) + ", " + stateEstimation.getEntry(2) + ", " + stateEstimation.getEntry(3) + ", " + stateEstimation.getEntry(4) + ", " + stateEstimation.getEntry(5) + ");" ); - //System.out.println(" state radius before: " + Math.sqrt( Math.pow(stateEstimation.getEntry(0), 2) + Math.pow(stateEstimation.getEntry(1), 2) ) ); RealVector z, z_plus, z_minus; RealMatrix measurementNoise; RealMatrix measurementMatrix; RealVector h; if (indicator.R == 0.0 && !indicator.direction) { + double z_beam_res_sq = 1.e10;//in mm + if(isvertexdefined)z_beam_res_sq = 4.0;//assuming 2. mm resolution measurementNoise = new Array2DRowRealMatrix( new double[][]{ - // {9.00, 0.0000, 0.0000}, - // {0.00, 1e10, 0.0000}, - // {0.00, 0.0000, 1e10} {0.09, 0.0000, 0.0000}, - {0.00, 1.e10, 0.0000}, - {0.00, 0.0000, 1.e10} + {0.00, 1e10, 0.0000}, + {0.00, 0.0000, z_beam_res_sq} });//3x3 measurementMatrix = H_beam(stateEstimation);//6x3 h = h_beam(stateEstimation);//3x1 z = indicator.hit.get_Vector_beam();//0! } else { - measurementNoise = indicator.hit.get_MeasurementNoise_simple();//1x1 - measurementMatrix = H_simple(stateEstimation, indicator);//6x1 - h = h_simple(stateEstimation, indicator);//.multiply(wire_sign_mat(indicator));//1x1 - z = indicator.hit.get_Vector_simple();//1x1 - - // measurementNoise = indicator.hit.get_MeasurementNoise();//3x3 - // measurementMatrix = H(stateEstimation, indicator);//6x3 - // h = h(stateEstimation, indicator);//3x1 - // z = indicator.hit.get_Vector();//3x1 - - //System.out.println(" h: r " + h.getEntry(0) + " phi " + h.getEntry(1) + " h z " + h.getEntry(2) + " z: r " + z.getEntry(0) + " phi " + z.getEntry(1) + " z " + z.getEntry(2) ); - + //System.out.println(" hit r " + indicator.hit.r() + " hit phi " + indicator.hit.phi() + " phi wire (-zl/2) " + indicator.hit.phi(-150.0) + " phi wire (0) " + indicator.hit.phi(0.0) + " phi wire (+zl/2) " + indicator.hit.phi(150.) + " state x " + stateEstimation.getEntry(0) + " state y " + stateEstimation.getEntry(1) + " state z " + stateEstimation.getEntry(2) ); + boolean goodsign = true; + if(indicator.hit.getSign()!=0){ + double dphi = Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0))-indicator.hit.phi(stateEstimation.getEntry(2)); + if(dphi*indicator.hit.getSign()<0)goodsign = false; + //System.out.println(" hit r " + indicator.hit.r() + " phi wire (z) " + indicator.hit.phi(stateEstimation.getEntry(2)) + " phi state " + Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0)) + " sign " + indicator.hit.getSign() + " good? " + goodsign ); + } + //measurementNoise = indicator.hit.get_MeasurementNoise();//1x1 + measurementNoise = indicator.hit.get_MeasurementNoise(goodsign);//1x1 + measurementMatrix = H(stateEstimation, indicator);//6x1 + //measurementMatrix = H(stateEstimation, indicator, goodsign);//6x1 + h = h(stateEstimation, indicator);//1x1 + //h = h(stateEstimation, indicator, goodsign);//1x1 + z = indicator.hit.get_Vector();//1x1 + //z = indicator.hit.get_Vector(indicator.hit.getSign(), goodsign);//1x1 } RealMatrix measurementMatrixT = measurementMatrix.transpose(); @@ -128,7 +128,6 @@ public void correct(Indicator indicator) { RealMatrix tmpMatrix = identity.subtract(kalmanGain.multiply(measurementMatrix)); errorCovariance = tmpMatrix.multiply(errorCovariance.multiply(tmpMatrix.transpose())).add(kalmanGain.multiply(measurementNoise.multiply(kalmanGain.transpose()))); - //System.out.println(" state after: (" + stateEstimation.getEntry(0) + ", " + stateEstimation.getEntry(1) + ", " + stateEstimation.getEntry(2) + ", " + stateEstimation.getEntry(3) + ", " + stateEstimation.getEntry(4) + ", " + stateEstimation.getEntry(5) + ");" ); // Give back to the stepper the new stateEstimation stepper.y = stateEstimation.toArray(); } @@ -138,20 +137,21 @@ public double residual(Indicator indicator) { return indicator.hit.doca()-d; } - public double wire_sign(Indicator indicator) {//let's decide: positive when (phi state - phi wire) > 0 + //function for left-right disambiguation + public int wire_sign(Indicator indicator) {//let's decide: positive when (phi state - phi wire) > 0 double phi_state = Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0)); double phi_wire = indicator.hit.phi(stateEstimation.getEntry(2)); - //System.out.println(" phi state " + phi_state + " phi wire " + phi_wire);// + " phi state alt? " + Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0))); - return (phi_state-phi_wire)/Math.abs(phi_state-phi_wire) ; + if( (phi_state-phi_wire)/Math.abs(phi_state-phi_wire)>0 ){ + return +1; + }else{ + return -1; + } } - // public RealMatrix wire_sign_mat(Indicator indicator) {//let's decide: positive when (phi state - phi wire) > 0 - // double phi_state = Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0)); - // double phi_wire = indicator.hit.phi(stateEstimation.getEntry(2)); - // System.out.println(" phi state " + phi_state + " phi wire " + phi_wire);// + " phi state alt? " + Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0))); - // return MatrixUtils.createRealMatrix(new double[][]{{(phi_state-phi_wire)/Math.abs(phi_state-phi_wire)}}); - // } - + public void ResetErrorCovariance(final RealMatrix initialErrorCovariance){ + this.errorCovariance = initialErrorCovariance; + } + private RealMatrix F(Indicator indicator, Stepper stepper1) throws Exception { double[] dfdx = subfunctionF(indicator, stepper1, 0); @@ -166,7 +166,7 @@ private RealMatrix F(Indicator indicator, Stepper stepper1) throws Exception { } double[] subfunctionF(Indicator indicator, Stepper stepper1, int i) throws Exception { - double h = 1e-8; + double h = 1e-8;// in mm Stepper stepper_plus = new Stepper(stepper1.y); Stepper stepper_minus = new Stepper(stepper1.y); @@ -189,57 +189,20 @@ private RealMatrix F(Indicator indicator, Stepper stepper1) throws Exception { return new double[]{dxdi, dydi, dzdi, dpxdi, dpydi, dpzdi}; } - //measurement matrix in cylindrical coordinates: r, phi, z + //measurement matrix in 1 dimension: minimize distance - doca private RealVector h(RealVector x, Indicator indicator) { - //As per my understanding: d -> r wire; phi -> phi wire, z unconstrained - double xx = x.getEntry(0); - double yy = x.getEntry(1); - return MatrixUtils.createRealVector(new double[]{Math.hypot(xx, yy), Math.atan2(yy, xx), x.getEntry(2)}); - } - - //measurement matrix in 1 dimension: minimize distance - doca - private RealVector h_simple(RealVector x, Indicator indicator) { double d = indicator.hit.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2))); - return MatrixUtils.createRealVector(new double[]{d});//would need to have this 3x3 + //double d = indicator.hit.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2)), indicator.hit.getSign()); + return MatrixUtils.createRealVector(new double[]{d}); } - //measurement noise matrix in cylindrical coordinates: r, phi, z - private RealMatrix H(RealVector x, Indicator indicator) { - // dphi/dx - double xx = x.getEntry(0); - double yy = x.getEntry(1); - - double drdx = (xx) / (Math.hypot(xx, yy)); - double drdy = (yy) / (Math.hypot(xx, yy)); - double drdz = 0.0; - double drdpx = 0.0; - double drdpy = 0.0; - double drdpz = 0.0; - - double dphidx = -(yy) / (xx * xx + yy * yy); - double dphidy = (xx) / (xx * xx + yy * yy); - double dphidz = 0.0; - double dphidpx = 0.0; - double dphidpy = 0.0; - double dphidpz = 0.0; - - double dzdx = 0.0; - double dzdy = 0.0; - double dzdz = 1.0; - double dzdpx = 0.0; - double dzdpy = 0.0; - double dzdpz = 0.0; - - return MatrixUtils.createRealMatrix( - new double[][]{ - {drdx, drdy, drdz, drdpx, drdpy, drdpz}, - {dphidx, dphidy, dphidz, dphidpx, dphidpy, dphidpz}, - {dzdx, dzdy, dzdz, dzdpx, dzdpy, dzdpz} - }); + private RealVector h(RealVector x, Indicator indicator, boolean goodsign) { + double d = indicator.hit.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2)), indicator.hit.getSign(), goodsign); + return MatrixUtils.createRealVector(new double[]{d}); } - //measurement matrix in 1 dimension: minimize distance - doca - private RealMatrix H_simple(RealVector x, Indicator indicator) { + //measurement matrix in 1 dimension: minimize distance - doca + private RealMatrix H(RealVector x, Indicator indicator) { double ddocadx = subfunctionH(x, indicator, 0); double ddocady = subfunctionH(x, indicator, 1); @@ -254,15 +217,44 @@ private RealMatrix H_simple(RealVector x, Indicator indicator) { } double subfunctionH(RealVector x, Indicator indicator, int i) { - double h = 1e-8; + double h = 1e-8;// in mm RealVector x_plus = x.copy(); RealVector x_minus = x.copy(); x_plus.setEntry(i, x_plus.getEntry(i) + h); x_minus.setEntry(i, x_minus.getEntry(i) - h); - double doca_plus = h_simple(x_plus, indicator).getEntry(0); - double doca_minus = h_simple(x_minus, indicator).getEntry(0); + double doca_plus = h(x_plus, indicator).getEntry(0); + double doca_minus = h(x_minus, indicator).getEntry(0); + + return (doca_plus - doca_minus) / (2 * h); + } + + //measurement matrix in 1 dimension: minimize distance - doca + private RealMatrix H(RealVector x, Indicator indicator, boolean goodsign) { + + double ddocadx = subfunctionH(x, indicator, 0, goodsign); + double ddocady = subfunctionH(x, indicator, 1, goodsign); + double ddocadz = subfunctionH(x, indicator, 2, goodsign); + double ddocadpx = subfunctionH(x, indicator, 3, goodsign); + double ddocadpy = subfunctionH(x, indicator, 4, goodsign); + double ddocadpz = subfunctionH(x, indicator, 5, goodsign); + + // As per my understanding: ddocadx,y,z -> = dr/dx,y,z, etc + return MatrixUtils.createRealMatrix(new double[][]{ + {ddocadx, ddocady, ddocadz, ddocadpx, ddocadpy, ddocadpz}}); + } + + double subfunctionH(RealVector x, Indicator indicator, int i, boolean goodsign) { + double h = 1e-8;// in mm + RealVector x_plus = x.copy(); + RealVector x_minus = x.copy(); + + x_plus.setEntry(i, x_plus.getEntry(i) + h); + x_minus.setEntry(i, x_minus.getEntry(i) - h); + + double doca_plus = h(x_plus, indicator, goodsign).getEntry(0); + double doca_minus = h(x_minus, indicator, goodsign).getEntry(0); return (doca_plus - doca_minus) / (2 * h); } @@ -332,4 +324,6 @@ public double getMomentum() { return Math.sqrt(stateEstimation.getEntry(3) * stateEstimation.getEntry(3) + stateEstimation.getEntry(4) * stateEstimation.getEntry(4) + stateEstimation.getEntry(5) * stateEstimation.getEntry(5)); } + public void setVertexDefined(boolean isvtxdef) {isvertexdefined = isvtxdef;} + } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java index 2cd0bc5593..85d23fedef 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java @@ -31,46 +31,42 @@ public class KalmanFilter { - public KalmanFilter(ArrayList tracks, DataEvent event) {propagation(tracks, event);} + public KalmanFilter(ArrayList tracks, DataEvent event, boolean IsMC) {propagation(tracks, event, IsMC);} - private void propagation(ArrayList tracks, DataEvent event) { + private final int Niter = 10; + private final boolean IsVtxDefined = false; + + private void propagation(ArrayList tracks, DataEvent event, boolean IsMC) { try { - //If simulation read MC::Particle Bank ------------------------------------------------ - DataBank bankParticle = event.getBank("MC::Particle"); - double vxmc = bankParticle.getFloat("vx", 0)*10;//mm - double vymc = bankParticle.getFloat("vy", 0)*10;//mm - double vzmc = bankParticle.getFloat("vz", 0)*10;//mm - double pxmc = bankParticle.getFloat("px", 0)*1000;//MeV - double pymc = bankParticle.getFloat("py", 0)*1000;//MeV - double pzmc = bankParticle.getFloat("pz", 0)*1000;//MeV - double p_mc = java.lang.Math.sqrt(pxmc*pxmc+pymc*pymc+pzmc*pzmc); - //System.out.println("MC track: vz: " + vzmc*10 + " px: " + pxmc*1000 + " py: " + pymc*1000 + " pz: " + pzmc*1000 + "; p = " + p_mc*1000);//convert p to MeV, v to mm - - ArrayList sim_hits = new ArrayList<>(); - sim_hits.add(new Point3D(0, 0, vzmc)); - - DataBank bankMC = event.getBank("MC::True"); - for (int i = 0; i < bankMC.rows(); i++) { - if (bankMC.getInt("pid", i) == 2212) { - float x = bankMC.getFloat("avgX", i); - float y = bankMC.getFloat("avgY", i); - float z = bankMC.getFloat("avgZ", i); - // System.out.println("r_sim = " + Math.hypot(x, y)); - sim_hits.add(new Point3D(x, y, z)); + double vz_constraint; + if(IsMC) {//If simulation read MC::Particle Bank ------------------------------------------------ + DataBank bankParticle = event.getBank("MC::Particle"); + double vxmc = bankParticle.getFloat("vx", 0)*10;//mm + double vymc = bankParticle.getFloat("vy", 0)*10;//mm + double vzmc = bankParticle.getFloat("vz", 0)*10;//mm + double pxmc = bankParticle.getFloat("px", 0)*1000;//MeV + double pymc = bankParticle.getFloat("py", 0)*1000;//MeV + double pzmc = bankParticle.getFloat("pz", 0)*1000;//MeV + double p_mc = java.lang.Math.sqrt(pxmc*pxmc+pymc*pymc+pzmc*pzmc); + //System.out.println("MC track: vz: " + vzmc*10 + " px: " + pxmc*1000 + " py: " + pymc*1000 + " pz: " + pzmc*1000 + "; p = " + p_mc*1000);//convert p to MeV, v to mm + + ArrayList sim_hits = new ArrayList<>(); + sim_hits.add(new Point3D(0, 0, vzmc)); + + DataBank bankMC = event.getBank("MC::True"); + for (int i = 0; i < bankMC.rows(); i++) { + if (bankMC.getInt("pid", i) == 2212) { + float x = bankMC.getFloat("avgX", i); + float y = bankMC.getFloat("avgY", i); + float z = bankMC.getFloat("avgZ", i); + // System.out.println("r_sim = " + Math.hypot(x, y)); + sim_hits.add(new Point3D(x, y, z)); + } } + vz_constraint = vzmc; } - - /* - Writer hitsWriter = new FileWriter("hits.dat"); - for (Point3D p : sim_hits) { - hitsWriter.write("" + p.x() + ", " + p.y() + ", " + p.z() + '\n'); - } - hitsWriter.close(); - */ - - // Initialization --------------------------------------------------------------------- final double magfield = +50; final PDGParticle proton = PDGDatabase.getParticleById(2212); @@ -90,46 +86,62 @@ private void propagation(ArrayList tracks, DataEvent event) { //final double py0 = tracks.get(0).get_py(); final double pz0 = tracks.get(0).get_pz(); - final double p_init = java.lang.Math.sqrt(px0*px0+py0*py0+pz0*pz0); + //final double p_init = java.lang.Math.sqrt(px0*px0+py0*py0+pz0*pz0); double[] y = new double[]{x0, y0, z0, px0, py0, pz0}; - //System.out.println("y = " + x0 + ", " + y0 + ", " + z0 + ", " + px0 + ", " + py0 + ", " + pz0 + "; p = " + p_init); // EPAF: *the line below is for TEST ONLY!!!* //double[] y = new double[]{vxmc, vymc, vzmc, pxmc, pymc, pzmc}; - //System.out.println("y = " + vxmc + ", " + vymc + ", " + vzmc + ", " + pxmc + ", " + pymc + ", " + pzmc + "; p = " + java.lang.Math.sqrt(pxmc*pxmc+pymc*pymc+pzmc*pzmc)); - // Initialization hit - //System.out.println("tracks = " + tracks); ArrayList AHDC_hits = tracks.get(0).getHits(); ArrayList KF_hits = new ArrayList<>(); + //System.out.println(" px " + y[3] + " py " + y[4] +" pz " + y[5] +" vz " + y[2] + " number of hits: " + AHDC_hits.size() + " MC hits? " + sim_hits.size()); for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits) { - //System.out.println("Superlayer = " + AHDC_hit.getSuperLayerId() + ", Layer " + AHDC_hit.getLayerId() + ", Wire " + AHDC_hit.getWireId() + ", Nwires " + AHDC_hit.getNbOfWires() + ", Radius " + AHDC_hit.getRadius() + ", DOCA " + AHDC_hit.getDoca()); Hit hit = new Hit(AHDC_hit.getSuperLayerId(), AHDC_hit.getLayerId(), AHDC_hit.getWireId(), AHDC_hit.getNbOfWires(), AHDC_hit.getRadius(), AHDC_hit.getDoca()); - + hit.setADC(AHDC_hit.getADC()); + hit.setHitIdx(AHDC_hit.getId()); + hit.setSign(0); + //System.out.println( " r = " + hit.r() + " hit.phi " + hit.phi() +" hit.doca = " + hit.getDoca() ); // Do delete hit with same radius - // boolean aleardyHaveR = false; - // for (Hit o: KF_hits){ - // if (o.r() == hit.r()){ - // aleardyHaveR = true; - // } + boolean phi_rollover = false; + boolean aleardyHaveR = false; + for (Hit o: KF_hits){ + if (o.r() == hit.r()){ + aleardyHaveR = true; + // //sign+ means (phi track - phi wire) > 0 + // if(o.phi()>hit.phi()){ + // if(Math.abs(o.phi()-hit.phi())< 2*Math.toRadians(360./o.getNumWires()) ){ + // o.setSign(-1); + // hit.setSign(+1); + // }else{ + // phi_rollover = true; + // hit.setSign(-1); + // o.setSign(+1); + // } + // }else{ + // if(Math.abs(o.phi()-hit.phi())< 2*Math.toRadians(360./o.getNumWires()) ){ + // hit.setSign(-1); + // o.setSign(+1); + // }else{ + // phi_rollover = true; + // o.setSign(-1); + // hit.setSign(+1); + // } + // } + // //System.out.println( " r = " + o.r() + " o.phi = " + o.phi() + " o.doca = " + o.getDoca()*o.getSign() + " hit.phi " + hit.phi() +" hit.doca = " + hit.getDoca()*hit.getSign() + " angle between wires: " + Math.toRadians(360./hit.getNumWires()) + " >= ? angle covered by docas: " + Math.atan( (o.getDoca()+hit.getDoca())/o.r() ) ); + } + } + if(!aleardyHaveR)KF_hits.add(hit); + // if (phi_rollover){ + // KF_hits.add(KF_hits.size()-1, hit); + // }else{ + // KF_hits.add(hit); // } - // if (!aleardyHaveR) - KF_hits.add(hit); - } - - - /* - Writer hitsWiresWriter = new FileWriter("hits_wires.dat"); - for (Hit h : KF_hits) { - hitsWiresWriter.write("" + h.getSuperLayer() + ", " + h.getLayer() + ", " + h.getWire() + ", " + h.getDoca() + ", " + h.getNumWires() + ", " + h.getR() + '\n'); } - hitsWiresWriter.close(); - */ - - //System.out.println("KF_hits = " + KF_hits); + double zbeam = 0; + if(IsVtxDefined)zbeam = vz_constraint;//test final ArrayList forwardIndicators = forwardIndicators(KF_hits, materialHashMap); - final ArrayList backwardIndicators = backwardIndicators(KF_hits, materialHashMap); - + final ArrayList backwardIndicators = backwardIndicators(KF_hits, materialHashMap, zbeam); + // Start propagation Stepper stepper = new Stepper(y); RungeKutta4 RK4 = new RungeKutta4(proton, numberOfVariables, B); @@ -141,87 +153,48 @@ private void propagation(ArrayList tracks, DataEvent event) { RealVector initialStateEstimate = new ArrayRealVector(stepper.y); //first 3 lines in cm^2; last 3 lines in MeV^2 RealMatrix initialErrorCovariance = MatrixUtils.createRealMatrix(new double[][]{{1.00, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 1.00, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 25.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.00, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 1.00, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0, 25.0}}); - KFitter kFitter = new KFitter(initialStateEstimate, initialErrorCovariance, stepper, propagator); - - /* - Stepper stepper_fisrt = new Stepper(y); - Writer writer_first = new FileWriter("track_first.dat"); - for (Indicator indicator : forwardIndicators) { - stepper_fisrt.initialize(indicator); - propagator.propagateAndWrite(stepper_fisrt, indicator, writer_first); - } - writer_first.close(); - - - - System.out.println("--------- BackWard propagation !! ---------"); - - Writer writer_back = new FileWriter("track_back.dat"); - for (Indicator indicator : backwardIndicators) { - stepper.initialize(indicator); - propagator.propagateAndWrite(stepper, indicator, writer_back); - } - writer_back.close(); - */ - - //Print out hit residuals *before* fit: - // for (Indicator indicator : forwardIndicators) { - // kFitter.predict(indicator); - // if (indicator.haveAHit()) { - // System.out.println(" Pre-fit: indicator R " + indicator.R + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum() + " residual: " + kFitter.residual(indicator) + " sign " + kFitter.wire_sign(indicator) ); - // } - // } - - for (int k = 0; k < 10; k++) { - - //System.out.println("--------- ForWard propagation !! ---------"); - + kFitter.setVertexDefined(IsVtxDefined); + + for (int k = 0; k < Niter; k++) { + //System.out.println("--------- ForWard propagation !! ---------"); + //Reset error covariance: + //kFitter.ResetErrorCovariance(initialErrorCovariance); for (Indicator indicator : forwardIndicators) { kFitter.predict(indicator); - //System.out.println("indicator R " + indicator.R + " h " + indicator.h + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); if (indicator.haveAHit()) { - //System.out.println("Superlayer = " + indicator.hit.getSuperLayer() + ", Layer " + indicator.hit.getLayer() + ", Wire " + indicator.hit.getWire() + ", Nwires " + indicator.hit.getNumWires() + ", Radius " + indicator.hit.getR() + ", DOCA " + indicator.hit.getDoca()); - kFitter.correct(indicator); - //System.out.println("y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); + if( k==0 && indicator.hit.getHitIdx()>0){ + for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits){ + if(AHDC_hit.getId()==indicator.hit.getHitIdx())AHDC_hit.setResidualPrefit(kFitter.residual(indicator)); + } + } + kFitter.correct(indicator); } } //System.out.println("--------- BackWard propagation !! ---------"); - for (Indicator indicator : backwardIndicators) { kFitter.predict(indicator); - //System.out.println("indicator R " + indicator.R + " h " + indicator.h + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); if (indicator.haveAHit()) { - //System.out.println("Superlayer = " + indicator.hit.getSuperLayer() + ", Layer " + indicator.hit.getLayer() + ", Wire " + indicator.hit.getWire() + ", Nwires " + indicator.hit.getNumWires() + ", Radius " + indicator.hit.getR() + ", DOCA " + indicator.hit.getDoca()); kFitter.correct(indicator); - //System.out.println("y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); } } } - // //Print out residuals *after* fit: - // for (Indicator indicator : forwardIndicators) { - // kFitter.predict(indicator); - // if (indicator.haveAHit()) { - // System.out.println(" Post-fit: indicator R " + indicator.R + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum() + " residual: " + kFitter.residual(indicator) + " sign " + kFitter.wire_sign(indicator) ); - // } - // } - - /* - Writer writer_last = new FileWriter("track_last.dat"); - for (Indicator indicator : forwardIndicators) { - stepper.initialize(indicator); - propagator.propagateAndWrite(stepper, indicator, writer_last); - } - writer_last.close(); - */ - - RealVector x_out = kFitter.getStateEstimationVector(); tracks.get(0).setPositionAndMomentumForKF(x_out); - //System.out.println("y_final = " + x_out + " p_final = " + kFitter.getMomentum()); + //Residual calcuation post fit: + for (Indicator indicator : forwardIndicators) { + kFitter.predict(indicator); + if (indicator.haveAHit()) { + if( indicator.hit.getHitIdx()>0){ + for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits){ + if(AHDC_hit.getId()==indicator.hit.getHitIdx())AHDC_hit.setResidual(kFitter.residual(indicator)); + } + } + } + } } catch (Exception e) { // e.printStackTrace(); } @@ -301,4 +274,17 @@ ArrayList backwardIndicators(ArrayList hitArrayList, HashMap backwardIndicators(ArrayList hitArrayList, HashMap materialHashMap, double vz) { + ArrayList backwardIndicators = new ArrayList<>(); + //R, h, defined in mm! + for (int i = hitArrayList.size() - 2; i >= 0; i--) { + backwardIndicators.add(new Indicator(hitArrayList.get(i).r(), 0.1, hitArrayList.get(i), false, materialHashMap.get("BONuS12Gas"))); + } + backwardIndicators.add(new Indicator(3.060, 1, null, false, materialHashMap.get("BONuS12Gas"))); + backwardIndicators.add(new Indicator(3.0, 0.001, null, false, materialHashMap.get("Kapton"))); + Hit hit = new Hit_beam(0, 0, 0, 0, 0, 0, 0, vz); + backwardIndicators.add(new Indicator(0.0, 0.2, hit, false, materialHashMap.get("deuteriumGas"))); + return backwardIndicators; + } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java new file mode 100644 index 0000000000..1278ddae4c --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java @@ -0,0 +1,5 @@ +package org.jlab.rec.ahdc; + +public enum Mode { + AI_Track_Finding, CV_Track_Finding; +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java index 8a968ba512..1e9ace5a68 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java @@ -15,7 +15,6 @@ public class Track { private List _Clusters = new ArrayList<>(); private boolean _Used = false; private final ArrayList hits = new ArrayList<>(); - ; private double x0 = 0; private double y0 = 0; @@ -64,6 +63,15 @@ public void setPositionAndMomentum(HelixFitObject helixFitObject) { this.pz0 = helixFitObject.get_pz(); } + public void setPositionAndMomentumVec(double[] x) { + this.x0 = x[0]; + this.y0 = x[1]; + this.z0 = x[2]; + this.px0 = x[3]; + this.py0 = x[4]; + this.pz0 = x[5]; + } + public void setPositionAndMomentumForKF(RealVector x) { this.x0_kf = x.getEntry(0); this.y0_kf = x.getEntry(1); diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java b/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java index 5dab3df8f9..d57a6b2bec 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java @@ -21,6 +21,7 @@ import org.jlab.rec.ahdc.PreCluster.PreCluster; import org.jlab.rec.ahdc.PreCluster.PreClusterFinder; import org.jlab.rec.ahdc.Track.Track; +import org.jlab.rec.ahdc.Mode; import java.io.File; import java.util.*; @@ -28,11 +29,12 @@ public class AHDCEngine extends ReconstructionEngine { private boolean simulation; - private boolean use_AI_for_trackfinding; private String findingMethod; private HashMap materialMap; private Model model; + private Mode mode = Mode.CV_Track_Finding; + public AHDCEngine() { super("ALERT", "ouillon", "1.0.1"); } @@ -41,13 +43,23 @@ public AHDCEngine() { public boolean init() { simulation = false; findingMethod = "distance"; - use_AI_for_trackfinding = true; if (materialMap == null) { materialMap = MaterialMap.generateMaterials(); } - model = new Model(); + if(this.getEngineConfigString("Mode")!=null) { + if (Objects.equals(this.getEngineConfigString("Mode"), Mode.AI_Track_Finding.name())) + mode = Mode.AI_Track_Finding; + + if (Objects.equals(this.getEngineConfigString("Mode"), Mode.CV_Track_Finding.name())) + mode = Mode.CV_Track_Finding; + + } + + if (mode == Mode.AI_Track_Finding) { + model = new Model(); + } return true; } @@ -79,7 +91,9 @@ public boolean processDataEvent(DataEvent event) { HitReader hitRead = new HitReader(event, simulation); ArrayList AHDC_Hits = hitRead.get_AHDCHits(); - ArrayList TrueAHDC_Hits = hitRead.get_TrueAHDCHits(); + if(simulation){ + ArrayList TrueAHDC_Hits = hitRead.get_TrueAHDCHits(); + } //System.out.println("AHDC_Hits size " + AHDC_Hits.size()); // II) Create PreCluster @@ -89,8 +103,6 @@ public boolean processDataEvent(DataEvent event) { AHDC_PreClusters = preclusterfinder.get_AHDCPreClusters(); //System.out.println("AHDC_PreClusters size " + AHDC_PreClusters.size()); - - // III) Create Cluster ClusterFinder clusterfinder = new ClusterFinder(); clusterfinder.findCluster(AHDC_PreClusters); @@ -101,7 +113,10 @@ public boolean processDataEvent(DataEvent event) { ArrayList AHDC_Tracks = new ArrayList<>(); ArrayList predictions = new ArrayList<>(); - if (use_AI_for_trackfinding == false) { + // If there is too much hits, we rely on to the conventional track finding + if (AHDC_Hits.size() > 300) mode = Mode.CV_Track_Finding; + + if (mode == Mode.CV_Track_Finding) { if (findingMethod.equals("distance")) { // IV) a) Distance method //System.out.println("using distance"); @@ -116,7 +131,7 @@ public boolean processDataEvent(DataEvent event) { AHDC_Tracks = houghtransform.get_AHDCTracks(); } } - else { + if (mode == Mode.AI_Track_Finding) { // AI --------------------------------------------------------------------------------- AHDC_Hits.sort(new Comparator() { @Override @@ -128,8 +143,13 @@ public int compare(Hit a1, Hit a2) { ArrayList preClustersAI = preClustering.find_preclusters_for_AI(AHDC_Hits); ArrayList preclusterSuperlayers = preClustering.merge_preclusters(preClustersAI); TrackConstruction trackConstruction = new TrackConstruction(); - ArrayList> tracks = trackConstruction.get_all_possible_track(preclusterSuperlayers); + ArrayList> tracks = new ArrayList<>(); + boolean sucess = trackConstruction.get_all_possible_track(preclusterSuperlayers, tracks); + if (!sucess) { + System.err.println("Too much tracks candidates, exit"); + return false; + } try { AIPrediction aiPrediction = new AIPrediction(); @@ -139,7 +159,7 @@ public int compare(Hit a1, Hit a2) { } for (TrackPrediction t : predictions) { - if (t.getPrediction() > 0.5) + if (t.getPrediction() > 0.2) AHDC_Tracks.add(new Track(t.getClusters())); } } @@ -148,7 +168,7 @@ public int compare(Hit a1, Hit a2) { //Temporary track method ONLY for MC with no background; //AHDC_Tracks.add(new Track(AHDC_Hits)); - + // V) Global fit for (Track track : AHDC_Tracks) { int nbOfPoints = track.get_Clusters().size(); @@ -165,12 +185,15 @@ public int compare(Hit a1, Hit a2) { HelixFitJava h = new HelixFitJava(); track.setPositionAndMomentum(h.HelixFit(nbOfPoints, szPos, 1)); + // double p = 150.0;//MeV/c + // double phi = Math.atan2(szPos[0][1], szPos[0][0]); + // double x_0[] = {0.0, 0.0, 0.0, p*Math.sin(phi), p*Math.cos(phi), 0.0}; + // track.setPositionAndMomentumVec(x_0); } // VI) Kalman Filter // System.out.println("AHDC_Tracks = " + AHDC_Tracks); - KalmanFilter kalmanFitter = new KalmanFilter(AHDC_Tracks, event); - + KalmanFilter kalmanFitter = new KalmanFilter(AHDC_Tracks, event, simulation); // VII) Write bank RecoBankWriter writer = new RecoBankWriter(); @@ -192,6 +215,7 @@ public int compare(Hit a1, Hit a2) { DataBank recoMCBank = writer.fillAHDCMCTrackBank(event); event.appendBank(recoMCBank); } + } return true; @@ -202,9 +226,9 @@ public static void main(String[] args) { double starttime = System.nanoTime(); int nEvent = 0; - int maxEvent = 1000; + int maxEvent = 10; int myEvent = 3; - String inputFile = "alert_out_update.hipo"; + String inputFile = "merged_10.hipo"; String outputFile = "output.hipo"; if (new File(outputFile).delete()) System.out.println("output.hipo is delete."); diff --git a/reconstruction/band/pom.xml b/reconstruction/band/pom.xml index 6d8fe0fb4f..8795e19aff 100644 --- a/reconstruction/band/pom.xml +++ b/reconstruction/band/pom.xml @@ -13,14 +13,14 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/bg/pom.xml b/reconstruction/bg/pom.xml index 195842c21e..58129ffdbe 100644 --- a/reconstruction/bg/pom.xml +++ b/reconstruction/bg/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,19 +21,19 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/cnd/pom.xml b/reconstruction/cnd/pom.xml index 0e5c074050..3b8b3712a1 100644 --- a/reconstruction/cnd/pom.xml +++ b/reconstruction/cnd/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/cvt/pom.xml b/reconstruction/cvt/pom.xml index 9c8d67d3d5..58b7e06a7f 100644 --- a/reconstruction/cvt/pom.xml +++ b/reconstruction/cvt/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -47,7 +47,7 @@ org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/dc/pom.xml b/reconstruction/dc/pom.xml index 9f352b167e..e1d60bc008 100644 --- a/reconstruction/dc/pom.xml +++ b/reconstruction/dc/pom.xml @@ -14,7 +14,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -28,25 +28,25 @@ org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -75,13 +75,13 @@ org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java index d020322477..25473ca915 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java @@ -94,7 +94,7 @@ public static Constants getInstance() { public int SECTORSELECT = 0; public int NSUPERLAYERTRACKING = 5; private boolean USETSTART = true; - private boolean USETIMETBETA = false; + //private boolean USETIMETBETA = false; private boolean CHECKBETA = false; private int T2D = 1; // 1=polynomial, 0=exponential private boolean USEDOUBLETS = false; @@ -105,10 +105,10 @@ public static Constants getInstance() { public static final String TT = "/daq/tt/dc"; public static final String DOCARES = "/calibration/dc/signal_generation/doca_resolution"; public static final String TIME2DIST = "/calibration/dc/time_to_distance/time2dist"; - public static final String T2DPRESSURE = "/calibration/dc/time_to_distance/t2d_pressure"; + public static final String T2DPRESSURE = "/calibration/dc/v2/t2d_pressure"; public static final String PRESSURE = "/hall/weather/pressure"; - public static final String T2DPRESSUREREF = "/calibration/dc/time_to_distance/ref_pressure"; - public static final String T0CORRECTION = "/calibration/dc/time_corrections/T0Corrections"; + public static final String T2DPRESSUREREF = "/calibration/dc/v2/ref_pressure"; + public static final String T0CORRECTION = "/calibration/dc/v2/t0"; public static final String TDCTCUTS = "/calibration/dc/time_corrections/tdctimingcuts"; public static final String WIRESTAT = "/calibration/dc/tracking/wire_status"; public static final String TIMEJITTER = "/calibration/dc/time_jitter"; @@ -296,13 +296,13 @@ public void setUSETSTART(boolean usetstart) { USETSTART = usetstart; } - public boolean useUSETIMETBETA() { - return USETIMETBETA; - } - - public void setUSETIMETBETA(boolean usetimebeta) { - USETIMETBETA = usetimebeta; - } +// public boolean useUSETIMETBETA() { +// return USETIMETBETA; +// } +// +// public void setUSETIMETBETA(boolean usetimebeta) { +// USETIMETBETA = usetimebeta; +// } public double getWIREDIST() { return WIREDIST; @@ -429,7 +429,7 @@ public void printConfig(String engine) { LOGGER.log(Level.INFO, "["+engine+"] run with wire ministagger = " + MINISTAGGERSTATUS.getName()); LOGGER.log(Level.INFO, "["+engine+"] run with wire feedthroughs = " + FEEDTHROUGHSSTATUS.getName()); LOGGER.log(Level.INFO, "["+engine+"] run with wire distortions = " + ENDPLATESBOWING); - LOGGER.log(Level.INFO, "["+engine+"] run with with time Beta correction (is false for doca Beta correction) = " + USETIMETBETA); + //LOGGER.log(Level.INFO, "["+engine+"] run with with time Beta correction (is false for doca Beta correction) = " + USETIMETBETA); LOGGER.log(Level.INFO, "["+engine+"] run with with Beta cut = " + CHECKBETA); LOGGER.log(Level.INFO, "["+engine+"] run with time to distance function set to exponential/polynomial (0/1) = " + T2D); LOGGER.log(Level.INFO, "["+engine+"] run with with hit doublets recovery = " + USEDOUBLETS); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java index faa907a8cf..49adb67ff1 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java @@ -205,65 +205,24 @@ private int getJitter(int sector, int layer, int wire, int order) { } return jitter; } - - public void fetch_DCHits(DataEvent event, Clas12NoiseAnalysis noiseAnalysis, - NoiseReductionParameters parameters, - Clas12NoiseResult results) { - this.initialize(event); - this.fetch_DCHits(noiseAnalysis, parameters, results); - } - + /** * reads the hits using clas-io methods to get the EvioBank for the DC and * fill the values to instantiate the DChit and MChit classes.This methods * fills the DChit list of hits. - * - * @param noiseAnalysis - * @param parameters - * @param results */ - private void fetch_DCHits(Clas12NoiseAnalysis noiseAnalysis, - NoiseReductionParameters parameters, - Clas12NoiseResult results) { - - _DCHits = new ArrayList<>(); - - IndexedList noise = new IndexedList<>(4); + public void fetch_DCHits(DataEvent event) { + this.initialize(event); - RawDataBank bankDGTZ = new RawDataBank(bankNames.getTdcBank(), OrderGroups.NODENOISE); - bankDGTZ.read(event); - - // event selection, including cut on max number of hits - if( run <= 0 || - tiTimeStamp < 0 || - bankDGTZ.rows()==0 || bankDGTZ.rows()>Constants.MAXHITS ) { - return; - } - else { - int rows = bankDGTZ.rows(); - int[] sector = new int[rows]; - int[] layer = new int[rows]; - int[] superlayer = new int[rows]; - int[] wire = new int[rows]; - for (int i = 0; i < rows; i++) { - sector[i] = bankDGTZ.getByte("sector", i); - layer[i] = (bankDGTZ.getByte("layer", i)-1)%6 + 1; - superlayer[i] = (bankDGTZ.getByte("layer", i)-1)/6 + 1; - wire[i] = bankDGTZ.getShort("component", i); - } - results.clear(); - noiseAnalysis.clear(); - noiseAnalysis.findNoise(sector, superlayer, layer, wire, results); - for(int i=0; i(); this.getDCRBJitters(Constants.getInstance().isSWAPDCRBBITS()); RawDataBank bankFiltered = new RawDataBank(bankNames.getTdcBank(), rawBankOrders); bankFiltered.read(event); + + if(run <= 0 || tiTimeStamp < 0 || bankFiltered.rows() > Constants.MAXHITS) return; + this.set_NumTDCBankRows(bankFiltered.rows()); for (int i = 0; i < bankFiltered.rows(); i++) { int sector = bankFiltered.getByte("sector", i); @@ -279,12 +238,7 @@ private void fetch_DCHits(Clas12NoiseAnalysis noiseAnalysis, if (wirestat != null) { if (wirestat.getIntValue("status", sector, layer+(superlayer-1)*6, wire) != 0) passHit = false; - } - - if(noise.hasItem(sector, superlayer, layer, wire)) { - if(noise.getItem(sector, superlayer, layer, wire)) - passHit = false; - } + } if (passHit && wire != -1 && !(superlayer == 0)) { @@ -791,8 +745,8 @@ private double[] getT0(int sector, int superlayer, int cable = this.getCableID1to6(layer, wire); int slot = this.getSlotID1to7(wire); - double t0 = t0Table.getDoubleValue("T0Correction", sector, superlayer, slot, cable); - double t0E = t0Table.getDoubleValue("T0Error", sector, superlayer, slot, cable); + double t0 = t0Table.getDoubleValue("t0correction", sector, superlayer, slot, cable); + double t0E = t0Table.getDoubleValue("t0error", sector, superlayer, slot, cable); T0Corr[0] = t0; T0Corr[1] = t0E; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java index b2b37c20f1..6ab72f997e 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java @@ -188,34 +188,20 @@ public List ClusterSplitter(FittedCluster clus, int nextClsStartI } } } - //no gaps - List contigArrayOfHits = new ArrayList<>(); //contiguous cluster - - boolean passCluster = true; - for (int l = 1; l <= Constants.NLAYR; l++) { - for (int i = 0; i < newClus.size(); i++) { - if (newClus.get(i).get_Layer() == l) { - contigArrayOfHits.add(newClus.get(i)); - } - } - } - for (int i = 0; i < contigArrayOfHits.size() - 1; i++) { //if there is a gap do not include in list - if (contigArrayOfHits.get(i + 1).get_Layer() - contigArrayOfHits.get(i).get_Layer() > 1) { - passCluster = false; + + //Limits for cluster candiates + boolean passCluster = false; + int nLayers = count_nlayers_in_cluster(newClus); + if((!isExceptionalCluster(newClus) && nLayers >= Constants.DC_MIN_NLAYERS) + || (isExceptionalCluster(newClus) && nLayers >= Constants.DC_MIN_NLAYERS - 1)) { + //require consistency with line + cf.SetFitArray(newClus, "LC"); + cf.Fit(newClus, true); + if ((nLayers == 6 && newClus.get_fitProb() > 0.9) || (nLayers == 5 && newClus.get_fitProb() > 0.85) + || (nLayers == 4 && newClus.get_fitProb() > 0.75) || (nLayers == 3 && newClus.get_fitProb() > 0.65)) { + passCluster = true; } } - //require 4 layers to make a cluster - if ((!isExceptionalCluster(contigArrayOfHits) && count_nlayers_in_cluster(contigArrayOfHits) < Constants.DC_MIN_NLAYERS) - || (isExceptionalCluster(contigArrayOfHits) && count_nlayers_in_cluster(contigArrayOfHits) < Constants.DC_MIN_NLAYERS - 1)) { - passCluster = false; - } - - //require consistency with line - cf.SetFitArray(newClus, "LC"); - cf.Fit(newClus, true); - if (newClus.get_fitProb() < 0.9) { - passCluster = false; - } if (!(splitclusters.contains(newClus)) && passCluster) { splitclusters.add(newClus); @@ -314,7 +300,7 @@ public int count_nlayers_hit(Hit[] hits_inlayer) { * @param hitsInClus the hits in a cluster * @return the number of layers in a cluster */ - int count_nlayers_in_cluster(List hitsInClus) { + int count_nlayers_in_cluster(List hitsInClus) { // count hits in each layer int nlayr = 6; int[] nlayers = new int[nlayr]; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java index d9b8eb2ab8..a2d1b735fe 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java @@ -236,7 +236,8 @@ public List FindHitBasedClusters(List allhits, ClusterCleane int idSharedHits = numTDCBankRows + 10000; for (FittedCluster clus : fittedClusList) { if (clus != null && ((!ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS) || - (ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS-1)) && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB) { + (ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS-1)) + && ((ct.count_nlayers_in_cluster(clus) < Constants.DC_MIN_NLAYERS && clus.get_fitProb() > 0.4) || (ct.count_nlayers_in_cluster(clus) >= Constants.DC_MIN_NLAYERS && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB))) { // update the hits for (FittedHit fhit : clus) { diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 36e802de15..19f27b1c50 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -385,27 +385,28 @@ public void set_TimeToDistance(DataEvent event, double trkAngle, double B, Index double deltatime_beta = 0; double deltadoca_beta = 0; - if(Constants.getInstance().useUSETIMETBETA()==true) { - deltatime_beta = calcDeltaTimeBetaTFCN(this.get_Time(), tab, beta); - } - - if(event.hasBank("MC::Particle")==false) { - distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), - this.getCorrectedTime(this.get_Time(), deltatime_beta), - secIdx, slIdx); - } else { - distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), - this.getCorrectedTime(this.get_Time(), 0), - secIdx, slIdx) ; - } - //get deltadoca - if(Constants.getInstance().useUSETIMETBETA()==false) { - deltadoca_beta = calcDeltaDocaBeta(distance, tab, beta); - } - - distance -=deltadoca_beta; - this.set_DeltaTimeBeta(deltatime_beta); - this.set_DeltaDocaBeta(deltadoca_beta); +// if(Constants.getInstance().useUSETIMETBETA()==true) { +// deltatime_beta = calcDeltaTimeBetaTFCN(this.get_Time(), tab, beta); +// } +// +// if(event.hasBank("MC::Particle")==false) { +// distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), +// this.getCorrectedTime(this.get_Time(), deltatime_beta), +// secIdx, slIdx); +// } else { +// distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), +// this.getCorrectedTime(this.get_Time(), 0), +// secIdx, slIdx) ; +// } +// //get deltadoca +// if(Constants.getInstance().useUSETIMETBETA()==false) { +// deltadoca_beta = calcDeltaDocaBeta(distance, tab, beta); +// } +// +// distance -=deltadoca_beta; + //this.set_DeltaTimeBeta(deltatime_beta); + //this.set_DeltaDocaBeta(deltadoca_beta); + distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), beta, this.get_Time(), secIdx, slIdx); } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java index 9a863dbcce..4892d5ceb8 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java @@ -321,7 +321,7 @@ public static double polyFcnMac(double x, double alpha, double bfield, double v_ double time = 0; // alpha correction double cos30minusalpha=Math.cos(Math.toRadians(30.-alpha)); - double dmaxalpha = dmax*cos30minusalpha; + double dmaxalpha = dmax*cos30minusalpha; double xhatalpha = x/dmaxalpha; // rcapital is an intermediate parameter double rcapital = R*dmax; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java index 1ae2e32755..1309a42012 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java @@ -1,10 +1,21 @@ package org.jlab.rec.dc.timetodistance; -import java.math.RoundingMode; -import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import org.jlab.detector.base.DetectorType; +import org.jlab.detector.base.GeometryFactory; +import org.jlab.geom.base.ConstantProvider; +import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; +import org.jlab.groot.math.Func1D; +import org.jlab.groot.ui.TCanvas; import org.jlab.rec.dc.Constants; +import static org.jlab.rec.dc.timetodistance.T2DFunctions.polyFcnMac; +import org.jlab.service.dc.DCEngine; import org.jlab.utils.groups.IndexedTable; @@ -17,8 +28,8 @@ public TableLoader() { private static boolean T2DLOADED = false; - private static final int NBINST=2000; - + public static final int NBINST=2000; + public static final double[] betaValues = new double[] {0.6, 0.7, 0.8, 0.9, 1.0}; public static final double[] BfieldValues = new double[]{0.0000, 1.0000, 1.4142, 1.7321, 2.0000, 2.2361, 2.4495, 2.6458}; public static int minBinIdxB = 0; public static int maxBinIdxB = BfieldValues.length-1; @@ -28,39 +39,185 @@ public TableLoader() { private static final double[][] AlphaBounds = new double[6][2]; public static int minBinIdxT = 0; public static final int[][][][] maxBinIdxT = new int[6][6][8][6]; - public static double[][][][][] DISTFROMTIME = new double[6][6][maxBinIdxB+1][maxBinIdxAlpha+1][NBINST]; // sector slyr alpha Bfield time bins [s][r][ibfield][icosalpha][tbin] + public static double[][][][][][] DISTFROMTIME = new double[6][6][maxBinIdxB+1][maxBinIdxAlpha+1][betaValues.length][NBINST]; // sector slyr alpha Bfield time bins [s][r][ibfield][icosalpha][tbin] + public static int timeBinWidth = 2; //ns public static int maxTBin = -1; - //public static double[] distbetaValues = new double[]{0.16, 0.16, 0.08, 0.08, 0.08, 0.08}; - /* - * - */ + public static void main(String[] args) { + DCEngine dce = new DCEngine("test"); + dce.setVariation("default"); + dce.LoadTables(); + ConstantProvider provider = GeometryFactory.getConstants(DetectorType.DC, 11, "default"); + for(int l=0; l<6; l++) { + Constants.getInstance().wpdist[l] = provider.getDouble("/geometry/dc/superlayer/wpdist", l); + } + int run = 18331; + TableLoader.Fill(dce.getConstantsManager().getConstants(run, Constants.T2DPRESSURE), + dce.getConstantsManager().getConstants(run, Constants.T2DPRESSUREREF), + dce.getConstantsManager().getConstants(run, Constants.PRESSURE)); + TableLoader.Fill(dce.getConstantsManager().getConstants(run, Constants.T2DPRESSURE), + dce.getConstantsManager().getConstants(run, Constants.T2DPRESSUREREF), + dce.getConstantsManager().getConstants(run, Constants.PRESSURE)); + test(); + } + public static void test(){ - TimeToDistanceEstimator tde = new TimeToDistanceEstimator(); - for(int s = 0; s<1; s++ ){ // loop over sectors - for(int r = 4; r<5; r++ ){ //loop over slys - for(int ibfield =0; ibfield<1; ibfield++) { - for (int tb = 250; tb< 300; tb++) { - LOGGER.log(Level.FINE, " NEW TIME BIN "); - for(int icosalpha =0; icosalpha hts = new ArrayList<>(); //histo to check table and interp. from time to idistance (by interpolation) + //to calculated time (from dist.to t) in seconds; as a function of time + List hds = new ArrayList<>(); //histo to check table and interp. from distance to calculated time (from dist.to t) + //to idistance (by interpolation) in microns; as a function of distance + List hdsSL3 = new ArrayList<>(); //histo to check table and interp. from distance to calculated time (from dist.to t) + //for various values of B-field + List hdsSL4 = new ArrayList<>(); //histo to check table and interp. from distance to calculated time (from dist.to t) + //for various values of B-field + List hd2s = new ArrayList<>();// as s function of distance + List ht2d = new ArrayList<>();// time to distance from interpolation + for(int r = 0; r<6; r++ ){ //loop over slys + hts.add(new H1F("ht"+(r+1), "time resolution (ns)", "Counts/0.1 ns", 400, -20.0,20.0)); + hds.add(new H1F("hd"+(r+1), "doca resolution (um)", "Counts/0.1 um", 400, -20.0,20.0)); + //public H2F(String name, String title, int bx, double xmin, double xmax, int by, double ymin, double ymax) + hd2s.add(new H2F("hd2"+(r+1), "doca resolution (um) vs doca (cm)", (int)(hdmax[r]*100), 0, hdmax[r], 400, -20.0,20.0)); + ht2d.add(new H2F("ht2d"+(r+1), "doca (cm) vs time(time (ns)", (int)htmax[r], 0, htmax[r], (int)(hdmax[r]*100), 0, hdmax[r])); + } + for (int b =0; b3) maxBidx=1; + for(int ibfield =0; ibfield fmap = new HashMap<>(); + for (int i = 0; i < 6; i++) { + CanD2T.cd(i); + double[] pars = new double[11]; + pars[0] = TableLoader.v0[0][i]; + pars[1] = TableLoader.vmid[0][i]; + pars[2] = TableLoader.FracDmaxAtMinVel[0][i]; + pars[3] = TableLoader.Tmax[0][i]; + pars[4] = TableLoader.distbeta[0][i]; + pars[5] = TableLoader.delta_bfield_coefficient[0][i]; + pars[6] = TableLoader.b1[0][i]; + pars[7] = TableLoader.b2[0][i]; + pars[8] = TableLoader.b3[0][i]; + pars[9] = TableLoader.b4[0][i]; + pars[10] = 2.*Constants.getInstance().wpdist[i];//fix dmax + + for(int j =0; j0 && (i<2 || i>3) ) continue; + String name = "f"; + name+=i; + name+="."; + name+=j; + name+="."; + name+=k; + fmap.put(name, new FitLine(name, 0, pars[10], 0, i, 3, alpha, BfieldValues[k])); + fmap.get(name).setLineWidth(2); + fmap.get(name).setLineColor(k+1); + fmap.get(name).setRange(0, pars[10]); + fmap.get(name).getAttributes().setTitleX("doca (cm)"); + fmap.get(name).getAttributes().setTitleY("time (ns)"); + CanD2T.draw(fmap.get(name), "same"); + } + } + } + } private static int getAlphaBin(double Alpha) { @@ -93,148 +250,135 @@ private static synchronized void FillAlpha() { AlphaBounds[0][0] = 0; AlphaBounds[5][1] = 30; } - public static synchronized void Fill(IndexedTable t2dPressure, IndexedTable t2dPressRef, IndexedTable pressure) { - if (T2DLOADED) return; - - + public static boolean useP = true; + public static synchronized void getConstants(IndexedTable t2dPressure, IndexedTable t2dPressRef, IndexedTable pressure){ double p_ref = t2dPressRef.getDoubleValue("pressure", 0,0,0); double p = pressure.getDoubleValue("value", 0,0,3); double dp = p - p_ref; + double dp2scale = 0; + double dpscale = 1; + + if(!useP) + dpscale = 0; for(int s = 0; s<6; s++ ){ // loop over sectors for(int r = 0; r<6; r++ ){ //loop over slys // Fill constants FracDmaxAtMinVel[s][r] = t2dPressure.getDoubleValue("c1_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("c1_a1", s+1,r+1,0)*dp; + +t2dPressure.getDoubleValue("c1_a1", s+1,r+1,0)*dp*dpscale; v0[s][r] = t2dPressure.getDoubleValue("v0_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("v0_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("v0_a2", s+1,r+1,0)*dp*dp; + +t2dPressure.getDoubleValue("v0_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("v0_a2", s+1,r+1,0)*dp*dp*dp2scale; vmid[s][r] = t2dPressure.getDoubleValue("vmid_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("vmid_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("vmid_a2", s+1,r+1,0)*dp*dp; - delta_bfield_coefficient[s][r] = t2dPressure.getDoubleValue("delta_bfield_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("delta_bfield_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("delta_bfield_a2", s+1,r+1,0)*dp*dp; - b1[s][r] = t2dPressure.getDoubleValue("b1_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b1_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("b1_a2", s+1,r+1,0)*dp*dp; - b2[s][r] = t2dPressure.getDoubleValue("b2_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b2_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("b2_a2", s+1,r+1,0)*dp*dp; - b3[s][r] = t2dPressure.getDoubleValue("b3_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b3_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("b3_a2", s+1,r+1,0)*dp*dp; - b4[s][r] = t2dPressure.getDoubleValue("b4_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b4_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("b4_a2", s+1,r+1,0)*dp*dp; + +t2dPressure.getDoubleValue("vmid_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("vmid_a2", s+1,r+1,0)*dp*dp*dp2scale; + distbeta[s][r] = t2dPressure.getDoubleValue("distbeta_a0", s+1,r+1,0) + +t2dPressure.getDoubleValue("distbeta_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("distbeta_a2", s+1,r+1,0)*dp*dp*dp2scale; + if(r>1 && r<4) { + delta_bfield_coefficient[s][r] = t2dPressure.getDoubleValue("delta_bfield_a0", s+1,r+1,0) + +t2dPressure.getDoubleValue("delta_bfield_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("delta_bfield_a2", s+1,r+1,0)*dp*dp*dp2scale + +t2dPressure.getDoubleValue("delta_bfield_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("delta_bfield_a2", s+1,r+1,0)*dp*dp*dp2scale; + b1[s][r] = t2dPressure.getDoubleValue("b1_a0", s+1,r+1,0) + +t2dPressure.getDoubleValue("b1_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("b1_a2", s+1,r+1,0)*dp*dp*dp2scale; + b2[s][r] = t2dPressure.getDoubleValue("b2_a0", s+1,r+1,0) + +t2dPressure.getDoubleValue("b2_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("b2_a2", s+1,r+1,0)*dp*dp*dp2scale; + b3[s][r] = t2dPressure.getDoubleValue("b3_a0", s+1,r+1,0) + +t2dPressure.getDoubleValue("b3_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("b3_a2", s+1,r+1,0)*dp*dp*dp2scale; + b4[s][r] = t2dPressure.getDoubleValue("b4_a0", s+1,r+1,0) + +t2dPressure.getDoubleValue("b4_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("b4_a2", s+1,r+1,0)*dp*dp*dp2scale; + } Tmax[s][r] = t2dPressure.getDoubleValue("tmax_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("tmax_a1", s+1,r+1,0)*dp - +t2dPressure.getDoubleValue("tmax_a2", s+1,r+1,0)*dp*dp; - + +t2dPressure.getDoubleValue("tmax_a1", s+1,r+1,0)*dp*dpscale + +t2dPressure.getDoubleValue("tmax_a2", s+1,r+1,0)*dp*dp*dp2scale; } } - Fill(); } - public static synchronized void Fill(IndexedTable tab) { - //CCDBTables 0 = "/calibration/dc/signal_generation/doca_resolution"; - //CCDBTables 1 = "/calibration/dc/time_to_distance/t2d"; - //CCDBTables 2 = "/calibration/dc/time_corrections/T0_correction"; - if (T2DLOADED) return; - + public static synchronized void FillTable() { + double stepSize = 0.00010; for(int s = 0; s<6; s++ ){ // loop over sectors - for(int r = 0; r<6; r++ ){ //loop over slys - // Fill constants - delta_T0[s][r] = tab.getDoubleValue("delta_T0", s+1,r+1,0); - FracDmaxAtMinVel[s][r] = tab.getDoubleValue("c1", s+1,r+1,0);//use same table. names strings - deltanm[s][r] = tab.getDoubleValue("deltanm", s+1,r+1,0); - v0[s][r] = tab.getDoubleValue("v0", s+1,r+1,0); - vmid[s][r] = tab.getDoubleValue("c2", s+1,r+1,0); - delta_bfield_coefficient[s][r] = tab.getDoubleValue("delta_bfield_coefficient", s+1,r+1,0); - b1[s][r] = tab.getDoubleValue("b1", s+1,r+1,0); - b2[s][r] = tab.getDoubleValue("b2", s+1,r+1,0); - b3[s][r] = tab.getDoubleValue("b3", s+1,r+1,0); - b4[s][r] = tab.getDoubleValue("b4", s+1,r+1,0); - Tmax[s][r] = tab.getDoubleValue("tmax", s+1,r+1,0); - // end fill constants + //System.out.println("sector "+(s+1)+" sly "+(r+1)+" v0 "+v0[s][r]+" vmid "+vmid[s][r]+" R "+FracDmaxAtMinVel[s][r]); + double dmax = 2.*Constants.getInstance().wpdist[r]; + //double tmax = CCDBConstants.getTMAXSUPERLAYER()[s][r]; + for(int ibfield =0; ibfieldmaxTime) + maxTime=timebfield; + + //System.out.println("T "+timebfield+" maxT "+maxTime+" x "+x); + int tbin = (int) Math.floor(timebfield/2); + if(tbin<0 || tbin>NBINST-1) { + //System.err.println("Problem with tbin"); + continue; + } + if(tbin>maxTBin) + maxTBin = tbin; + + if(timebfielddmax) { + DISTFROMTIME[s][r][ibfield][icosalpha][ibeta][tbin]=dmax; + idist=nxmax; + } + } + } + } + } } } - Fill(); - } - public static synchronized void Fill() { + TableLoader.fillMissingTableBins(); + } + public static synchronized void Fill(IndexedTable t2dPressure, IndexedTable t2dPressRef, IndexedTable pressure) { + //CCDBTables 0 = "/calibration/dc/signal_generation/doca_resolution"; //CCDBTables 1 = "/calibration/dc/time_to_distance/t2d"; //CCDBTables 2 = "/calibration/dc/time_corrections/T0_correction"; - - double stepSize = 0.0010; + if (T2DLOADED) return; FillAlpha(); + getConstants(t2dPressure, t2dPressRef, pressure); + FillTable(); - for(int s = 0; s<6; s++ ){ // loop over sectors - - for(int r = 0; r<6; r++ ){ //loop over slys - - // constants filled - //LOGGER.log(Level.FINE, v0[s][r]+" "+vmid[s][r]+" "+FracDmaxAtMinVel[s][r]); - double dmax = 2.*Constants.getInstance().wpdist[r]; - //double tmax = CCDBConstants.getTMAXSUPERLAYER()[s][r]; - for(int ibfield =0; ibfieldNBINST-1) { - //System.err.println("Problem with tbin"); - continue; - } - if(tbin>maxTBin) - maxTBin = tbin; - //if(tbin>maxBinIdxT[s][r][ibfield][icosalpha]) { - //maxBinIdxT[s][r][ibfield][icosalpha] = NBINST; - //} //LOGGER.log(Level.FINE, "tbin "+tbin+" tmax "+tmax+ "s "+s+" sl "+r ); - if(DISTFROMTIME[s][r][ibfield][icosalpha][tbin]==0) { - // firstbin = bi - // bincount = 0; - DISTFROMTIME[s][r][ibfield][icosalpha][tbin]=x; - } else { - // test for getting center of the bin (to be validated): - //double prevTime = calc_Time(x-stepSize, alpha, bfield, s+1, r+1); - //if(x>DISTFROMTIME[s][r][ibfield][icosalpha][tbin] - // && Math.abs((double)(2.*tbin+1)-timebfield)<=Math.abs((double)(2.*tbin+1)-prevTime)) { - // DISTFROMTIME[s][r][ibfield][icosalpha][tbin]=x; - //} - // bincount++; - DISTFROMTIME[s][r][ibfield][icosalpha][tbin]+=stepSize; - } - - /* if(timebfield>timebfield_max) { - DISTFROMTIME[s][r][ibfield][icosalpha][tbin]=x-stepSize*0.5; - if(DISTFROMTIME[s][r][ibfield][icosalpha][tbin]>dmax) - DISTFROMTIME[s][r][ibfield][icosalpha][tbin] = dmax; - } */ - } - } - } - } - } - TableLoader.fillMissingTableBins(); - //TableLoader.test(); + System.out.println(" T2D TABLE FILLED....."); T2DLOADED = true; - } + } - private static synchronized void fillMissingTableBins() { + private static void fillMissingTableBins() { for(int s = 0; s<6; s++ ){ // loop over sectors @@ -244,17 +388,21 @@ private static synchronized void fillMissingTableBins() { for(int icosalpha =0; icosalphadmax) x=dmax; - - if(Constants.getInstance().getT2D()==0) { - - return T2DFunctions.ExpoFcn(x, alpha, bfield, v0[s][r], deltanm[s][r], 0.615, - tmax, dmax, delBf, Bb1, Bb2, Bb3, Bb4, superlayer) + delta_T0[s][r]; - } else { - return T2DFunctions.polyFcnMac(x, alpha, bfield, v0[s][r], vmid[s][r], FracDmaxAtMinVel[s][r], + return polyFcnMac(x, alpha, bfield, v0[s][r], vmid[s][r], FracDmaxAtMinVel[s][r], tmax, dmax, delBf, Bb1, Bb2, Bb3, Bb4, superlayer) ; - } + + } + + public static synchronized double getDeltaTimeBeta(double x, double beta, double distbeta, double v_0) { + + double value = (0.5*Math.pow(beta*beta*distbeta,3)*x/(Math.pow(beta*beta*distbeta,3)+x*x*x))/v_0; + + return value; } + public static double[][] delta_T0 = new double[6][6]; public static double[][] delta_bfield_coefficient = new double[6][6]; - public static double[][] deltanm = new double[6][6]; + public static double[][] distbeta = new double[6][6]; public static double[][] vmid = new double[6][6]; public static double[][] v0 = new double[6][6]; public static double[][] b1 = new double[6][6]; @@ -297,6 +447,31 @@ public static synchronized double calc_Time(double x, double alpha, double bfiel public static double[][] b3 = new double[6][6]; public static double[][] b4 = new double[6][6]; public static double[][] Tmax = new double[6][6]; - public static double[][] FracDmaxAtMinVel = new double[6][6]; // fraction of dmax corresponding to the point in the cell where the velocity is minimal + public static double[][] FracDmaxAtMinVel = new double[6][6]; + private static class FitLine extends Func1D { + + public FitLine(String name, double min, double max, + int s, int r, int ibeta, double alpha, double bfield) { + super(name, min, max); + this.s = s; + this.r = r; + this.ibeta = ibeta; + this.alpha = alpha; + this.bfield = bfield; + } + private final double alpha; + private final double bfield; + private final int ibeta; + private final int s; + private final int r; + + @Override + public double evaluate(double x) { + double timebfield = calc_Time( x, alpha, bfield, s+1, r+1) ; + double deltatime_beta = getDeltaTimeBeta(x,betaValues[ibeta],distbeta[s][r],v0[s][r]); + timebfield+=deltatime_beta; + return timebfield; + } + } } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java index 141a631ed3..998541d165 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java @@ -1,17 +1,19 @@ package org.jlab.rec.dc.timetodistance; -import java.math.RoundingMode; -import java.text.DecimalFormat; import java.util.logging.Level; import java.util.logging.Logger; +import org.jlab.rec.dc.Constants; +import static org.jlab.rec.dc.timetodistance.TableLoader.BfieldValues; +import static org.jlab.rec.dc.timetodistance.TableLoader.calc_Time; public class TimeToDistanceEstimator { + public TimeToDistanceEstimator() { + // TODO Auto-generated constructor stub } - - private static final Logger LOGGER = Logger.getLogger(TimeToDistanceEstimator.class.getName()); + public boolean t2DPrecisionImprov=false; /** * * @param x value on grid @@ -27,104 +29,224 @@ private double interpolateLinear(double x0, double xa, double xb, double ya, dou x=xb; if(xTableLoader.NBINST-1) { + tHi=TableLoader.NBINST-1; + } + } + double timeLo=2*tLo+1; + double timeHi=2*tHi+1; + //get the beta bins + int binBeta = this.getBetaIdx(beta); + int betaLo = 0; + int betaHi = 0; + double betaCent = TableLoader.betaValues[binBeta]; + if(betaTableLoader.betaValues.length-1) { + betaHi=TableLoader.betaValues.length-1; + } + } + double betaValueLo = TableLoader.betaValues[betaLo]; + double betaValueHigh = TableLoader.betaValues[betaHi]; + //get the Bfield bins double B = Math.abs(Bf); - - int binlowB = this.getBIdx(B); - int binhighB = binlowB + 1; - - if(binhighB > TableLoader.maxBinIdxB) { - binhighB = TableLoader.maxBinIdxB; + int binB = this.getBIdx(B); + double BfCen = BfieldValues[binB]; + int BfLo=0; + int BfHi=0; + if(BTableLoader.BfieldValues.length-1) { + BfHi=TableLoader.BfieldValues.length-1; + } } - - double B1 = TableLoader.BfieldValues[binlowB]; - double B2 = TableLoader.BfieldValues[binhighB]; - - // for alpha ranges - int binlowAlpha = this.getAlphaIdx(alpha); - int binhighAlpha = binlowAlpha + 1; - - if(binhighAlpha > TableLoader.maxBinIdxAlpha) { - binhighAlpha = TableLoader.maxBinIdxAlpha; + double BLo = BfieldValues[BfLo]; + double BHi = BfieldValues[BfHi]; + // get the alpha bins + int alphaBin = this.getAlphaIdx(alpha); + int alphaLo = 0; + int alphaHi = 0; + double alphaCenValue = this.getAlphaFromAlphaIdx(alphaBin); + if(alpha TableLoader.maxBinIdxAlpha) { + alphaHi = TableLoader.maxBinIdxAlpha; + } } - //if(binhighAlpha==binlowAlpha) { - // binlowAlpha=binhighAlpha-1; - //} - - double alpha1 = this.getAlphaFromAlphaIdx(binlowAlpha); - double alpha2 = this.getAlphaFromAlphaIdx(binhighAlpha); + double alphaValueLo = this.getAlphaFromAlphaIdx(alphaLo); + double alphaValueHi = this.getAlphaFromAlphaIdx(alphaHi); // interpolate in B: - double f_B_alpha1_t1 = interpolateLinear(B*B, B1*B1, B2*B2, - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)], - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)]); - double f_B_alpha2_t1 = interpolateLinear(B*B, B1*B1, B2*B2, - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)], - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)]); - double f_B_alpha1_t2 = interpolateLinear(B*B, B1*B1, B2*B2, - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binlowAlpha][this.getTimeNextIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)], - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binlowAlpha][this.getTimeNextIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)]); - double f_B_alpha2_t2 = interpolateLinear(B*B, B1*B1, B2*B2, - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binhighAlpha][this.getTimeNextIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)], - TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binhighAlpha][this.getTimeNextIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)]); - // interpolate in d for 2 values of alpha: - double f_B_alpha1_t = interpolateLinear(t, this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)*2., this.getTimeNextIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)*2., f_B_alpha1_t1, f_B_alpha1_t2); - double f_B_alpha2_t = interpolateLinear(t, this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)*2., this.getTimeNextIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)*2., f_B_alpha2_t1, f_B_alpha2_t2); - //LOGGER.log(Level.FINE, TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)]); - //LOGGER.log(Level.FINE, SlyrIdx+" binlowB "+binlowB+" binlowAlpha "+binlowAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)+" time "+t); - //LOGGER.log(Level.FINE, TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)]); - //LOGGER.log(Level.FINE, SlyrIdx+" binlowB "+binlowB+" binhighAlpha "+binhighAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)+" time "+t); - //LOGGER.log(Level.FINE, TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)]); - //LOGGER.log(Level.FINE, SlyrIdx+" binhighB "+binhighB+" binlowAlpha "+binlowAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)+" time "+t); - //LOGGER.log(Level.FINE, TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)]); - //LOGGER.log(Level.FINE, SlyrIdx+" binhighB "+binhighB+" binhighAlpha "+binhighAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)+" time "+t); - //LOGGER.log(Level.FINE, " f_B_alpha1_t1 "+f_B_alpha1_t1+" f_B_alpha2_t1 "+f_B_alpha2_t1 - // +" f_B_alpha1_t2 "+f_B_alpha1_t2+" f_B_alpha2_t2 "+f_B_alpha2_t2 - // +" f_B_alpha1_t "+f_B_alpha1_t+" f_B_alpha2_t "+f_B_alpha2_t); + double Bfc = B*B; + double Bfa = BLo*BLo; + double Bfb = BHi*BHi; + double f_B_alpha1_beta1_t1 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaLo][betaLo][tLo], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaLo][betaLo][tLo]); + double f_B_alpha2_beta1_t1 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaHi][betaLo][tLo], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaHi][betaLo][tLo]); + double f_B_alpha1_beta1_t2 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaLo][betaLo][tHi], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaLo][betaLo][tHi]); + double f_B_alpha2_beta1_t2 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaHi][betaLo][tHi], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaHi][betaLo][tHi]); + double f_B_alpha1_beta2_t1 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaLo][betaHi][tLo], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaLo][betaHi][tLo]); + double f_B_alpha2_beta2_t1 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaHi][betaHi][tLo], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaHi][betaHi][tLo]); + double f_B_alpha1_beta2_t2 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaLo][betaHi][tHi], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaLo][betaHi][tHi]); + double f_B_alpha2_beta2_t2 = interpolateLinear(Bfc, Bfa, Bfb, + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfLo][alphaHi][betaHi][tHi], + TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][BfHi][alphaHi][betaHi][tHi]); - // interpolate in alpha: (cos30-cosA) - double f_B_alpha_t = interpolateLinear(Math.cos(Math.toRadians(30.))-Math.cos(Math.toRadians(alpha)), - Math.cos(Math.toRadians(30.))-Math.cos(Math.toRadians(alpha1)), - Math.cos(Math.toRadians(30.))-Math.cos(Math.toRadians(alpha2)), f_B_alpha1_t, f_B_alpha2_t); + //interpolate in alpha + double f_B_alpha_beta1_t1 = interpolateLinear(alpha, alphaValueLo, alphaValueHi, f_B_alpha1_beta1_t1, f_B_alpha2_beta1_t1); + double f_B_alpha_beta2_t1 = interpolateLinear(alpha, alphaValueLo, alphaValueHi, f_B_alpha1_beta2_t1, f_B_alpha2_beta2_t1); + double f_B_alpha_beta1_t2 = interpolateLinear(alpha, alphaValueLo, alphaValueHi, f_B_alpha1_beta1_t2, f_B_alpha2_beta1_t2); + double f_B_alpha_beta2_t2 = interpolateLinear(alpha, alphaValueLo, alphaValueHi, f_B_alpha1_beta2_t2, f_B_alpha2_beta2_t2); + //interpolate in beta + double f_B_alpha_beta_t1 = interpolateLinear(beta, betaValueLo, betaValueHigh,f_B_alpha_beta1_t1,f_B_alpha_beta2_t1); + double f_B_alpha_beta_t2 = interpolateLinear(beta, betaValueLo, betaValueHigh,f_B_alpha_beta1_t2,f_B_alpha_beta2_t2); + //interpolate in time + double f_B_alpha_beta_t = interpolateLinear(t, timeLo, timeHi, f_B_alpha_beta_t1, f_B_alpha_beta_t2); + + double x = f_B_alpha_beta_t; +// String st =new String(); +// st +="time "+t+" beta "+beta+" BETA: ["+betaValueLo+" "+betaCent+" "+betaValueHigh+"]"+" alpha "+alpha+"\n"; +// st +=(" f_B_alpha1_beta1_t1 "+f_B_alpha1_beta1_t1+" f_B_alpha2_beta1_t1 "+f_B_alpha2_beta1_t1+"\n"); +// st +=(" f_B_alpha1_beta2_t1 "+f_B_alpha1_beta2_t1+" f_B_alpha2_beta2_t1 "+f_B_alpha2_beta2_t1+"\n"); +// st +=(" f_B_alpha1_beta1_t2 "+f_B_alpha1_beta1_t2+" f_B_alpha2_beta1_t2 "+f_B_alpha2_beta1_t2+"\n"); +// st +=(" f_B_alpha1_beta2_t2 "+f_B_alpha1_beta2_t2+" f_B_alpha2_beta2_t2 "+f_B_alpha2_beta2_t2+"\n"); +// st +=(" f_B_alpha_beta1_t1 "+f_B_alpha_beta1_t1+" f_B_alpha_beta2_t1 "+f_B_alpha_beta2_t1+"\n"); +// st +=(" f_B_alpha_beta1_t2 "+f_B_alpha_beta1_t2+" f_B_alpha_beta2_t2 "+f_B_alpha_beta2_t2+"\n"); +// st +=(" f_B_alpha_beta_t1 "+f_B_alpha_beta_t1+" f_B_alpha_beta_t2 "+f_B_alpha_beta_t2+"\n"); +// st +=(" f_B_alpha_t "+f_B_alpha_beta_t+"\n"); + + double dmax = 2.*Constants.getInstance().wpdist[SlyrIdx]; +// st +=(" x "+x+" dmax "+dmax+"\n"); + + if(x>dmax) { +// setDebug(st); + return dmax; + } + if(!this.t2DPrecisionImprov) return x; + //Reolution improvement to compensate for non-linearity accross bin not accounted for in interpolation + double calctime = calc_Time( x, alpha, B, SecIdx+1, SlyrIdx+1) ; + double deltatime_beta = TableLoader.getDeltaTimeBeta(x,beta,TableLoader.distbeta[SecIdx][SlyrIdx],TableLoader.v0[SecIdx][SlyrIdx]); + calctime+=deltatime_beta; +// st +=(" t "+t+" calctime "+calctime+" deltatime_beta "+deltatime_beta+"\n"); + if(calctime>t) { + double tref=0; + for(int i = 1; i<100; i++) { + x-=0.0001*i; + if(x<0) return x; + calctime = calc_Time( x, alpha, B, SecIdx+1, SlyrIdx+1) ; + deltatime_beta = TableLoader.getDeltaTimeBeta(x,beta,TableLoader.distbeta[SecIdx][SlyrIdx],TableLoader.v0[SecIdx][SlyrIdx]); + calctime+=deltatime_beta; +// st +=(i+"] x "+x+" t "+t+" calct "+calctime+"\n"); + if(calctimecalctime) { + double tref=0; + for(int i = 1; i<100; i++) { + x+=0.0001*i; + calctime = calc_Time( x, alpha, B, SecIdx+1, SlyrIdx+1) ; + deltatime_beta = TableLoader.getDeltaTimeBeta(x,beta,TableLoader.distbeta[SecIdx][SlyrIdx],TableLoader.v0[SecIdx][SlyrIdx]); + calctime+=deltatime_beta; +// st +=(i+"] x "+x+" t "+t+" calct "+calctime+"\n"); + if(x>dmax) { +// setDebug(st); + return dmax; + } + if(tTableLoader.maxTBin) { - binIdx = TableLoader.maxTBin ; - } - - return binIdx; + public int getTimeIdx(double t1) { + int idx=(int) Math.floor(t1 / TableLoader.timeBinWidth); + if(idx<0) idx=0; + return idx; } + /** * * @param b1 bfield value in T * @return B field bin */ - public int getBIdx(double b1) { - -// int binIdx = (int) ((1+b1)*2) -2; -// if(binIdx<0) { -// binIdx = TableLoader.minBinIdxB; -// } -// if(binIdx>TableLoader.maxBinIdxB) { -// binIdx = TableLoader.maxBinIdxB; -// } + public int getBIdx(double b1) { + int binIdx = (int) Math.floor(b1*b1); int maxBinIdxB = TableLoader.BfieldValues.length-1; - DecimalFormat df = new DecimalFormat("#"); - df.setRoundingMode(RoundingMode.CEILING); - - int binIdx =0; - try{ - binIdx = Integer.parseInt(df.format(b1*b1) ) -1; - } catch (NumberFormatException e) { - LOGGER.log(Level.WARNING, " field bin error "+b1+" "); - } + if(binIdx<0) { binIdx = 0; } if(binIdx>maxBinIdxB) binIdx = maxBinIdxB; + return binIdx; } /** @@ -220,34 +311,18 @@ private int getAlphaIdx(double alpha) { } return binIdx; } - - private int getTimeNextIdx(double t, int SecIdx, int SlyrIdx, int binlowB, int binlowAlpha) { - int binlowT = this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha); - int binhighT = binlowT + 1; - - if(binhighT>TableLoader.maxBinIdxT[SecIdx][SlyrIdx][binlowB][binlowAlpha]) { - binhighT=TableLoader.maxBinIdxT[SecIdx][SlyrIdx][binlowB][binlowAlpha]; - } - return binhighT; - } - /** - * @param slyIdx superlayer index - * @param time - * @return test doca corr - */ - public double addDOCACorr(double time, int slyIdx) { - double dDoca = 0; - if(slyIdx+1 == 5 || slyIdx+1 ==6) { - if(time>600) { - dDoca = 0.15; - } else { - dDoca = (7.6e-3 - 2.4e-4*time +9.8e-3*time*time - 3.8e-6*time*time*time)*5.5410595e-05; + private int getBetaIdx(double beta) { + if(beta>=1.0) return TableLoader.betaValues.length-1; + int value = TableLoader.betaValues.length-1; + for(int i = 0; i=TableLoader.betaValues[i] && beta findStraightTracks(CrossList crossList, DCGeant4Factory DcDe continue; } - List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef); - StateVec fn = new StateVec(); if (!kFZRef.setFitFailed && kFZRef.finalStateVec != null) { fn.set(kFZRef.finalStateVec.x, kFZRef.finalStateVec.y, kFZRef.finalStateVec.tx, kFZRef.finalStateVec.ty); @@ -927,6 +925,11 @@ private List findStraightTracks(CrossList crossList, DCGeant4Factory DcDe cand.set_FitConvergenceStatus(kFZRef.ConvStatus); cand.set_Id(cands.size() + 1); cand.set_CovMat(kFZRef.finalStateVec.CM); + + Point3D VTCS = cand.get(cand.size()-1).getCoordsInTiltedSector(cand.get_Vtx0().x(), cand.get_Vtx0().y(), cand.get_Vtx0().z()); + double deltaPathToVtx = kFZRef.getDeltaPathToVtx(cand.get(cand.size()-1).get_Sector(), VTCS.z()); + + List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef, deltaPathToVtx); cand.setStateVecs(kfStateVecsAlongTrajectory); // add candidate to list of tracks @@ -1071,7 +1074,6 @@ private List findCurvedTracks(CrossList crossList, DCGeant4Factory DcDete kFZRef.init(measSurfaces, initSV); kFZRef.runFitter(); - List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef); if (kFZRef.finalStateVec == null) { continue; @@ -1093,15 +1095,21 @@ private List findCurvedTracks(CrossList crossList, DCGeant4Factory DcDete cand.set_FitNDF(kFZRef.NDF); cand.set_FitConvergenceStatus(kFZRef.ConvStatus); - cand.set_CovMat(kFZRef.finalStateVec.CM); - cand.setStateVecs(kfStateVecsAlongTrajectory); - + cand.set_CovMat(kFZRef.finalStateVec.CM); + cand.setFinalStateVec(fitStateVec); cand.set_Id(cands.size() + 1); this.setTrackPars(cand, traj, trjFind, fitStateVec, fitStateVec.getZ(), DcDetector, dcSwim); + + Point3D VTCS = cand.get(cand.size()-1).getCoordsInTiltedSector(cand.get_Vtx0().x(), cand.get_Vtx0().y(), cand.get_Vtx0().z()); + double deltaPathToVtx = kFZRef.getDeltaPathToVtx(cand.get(cand.size()-1).get_Sector(), VTCS.z()); + + List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef, deltaPathToVtx); + cand.setStateVecs(kfStateVecsAlongTrajectory); + // add candidate to list of tracks if (cand.fit_Successful = true) { cands.add(cand); @@ -1117,7 +1125,7 @@ private List findCurvedTracks(CrossList crossList, DCGeant4Factory DcDete return cands; } - public List setKFStateVecsAlongTrajectory(KFitter kFZRef) { + public List setKFStateVecsAlongTrajectory(KFitter kFZRef, double deltaPathToVtx) { List kfStateVecsAlongTrajectory = new ArrayList<>(); for(int i = 0; i < kFZRef.kfStateVecsAlongTrajectory.size(); i++) { @@ -1125,7 +1133,7 @@ public List setKFStateVecsAlongTrajectory(K org.jlab.rec.dc.trajectory.StateVec sv = new org.jlab.rec.dc.trajectory.StateVec(svc.x, svc.y, svc.tx, svc.ty); sv.setZ(svc.z); sv.setB(svc.B); - sv.setPathLength(svc.getPathLength()); + sv.setPathLength(svc.getPathLength() + deltaPathToVtx); // Transition for the starting point from the final point at the last layer to vertex sv.setProjector(svc.getProjector()); sv.setProjectorDoca(svc.getProjectorDoca()); kfStateVecsAlongTrajectory.add(sv); @@ -1134,7 +1142,7 @@ public List setKFStateVecsAlongTrajectory(K return kfStateVecsAlongTrajectory; } - public List setKFStateVecsAlongTrajectory(KFitterStraight kFZRef) { + public List setKFStateVecsAlongTrajectory(KFitterStraight kFZRef, double deltaPathToVtx) { List kfStateVecsAlongTrajectory = new ArrayList<>(); for(int i = 0; i < kFZRef.kfStateVecsAlongTrajectory.size(); i++) { @@ -1142,7 +1150,7 @@ public List setKFStateVecsAlongTrajectory(K org.jlab.rec.dc.trajectory.StateVec sv = new org.jlab.rec.dc.trajectory.StateVec(svc.x, svc.y, svc.tx, svc.ty); sv.setZ(svc.z); sv.setB(svc.B); - sv.setPathLength(svc.getPathLength()); + sv.setPathLength(svc.getPathLength() + deltaPathToVtx); // Transition for the starting point from the final point at the last layer to vertex sv.setProjector(svc.getProjector()); sv.setProjectorDoca(svc.getProjectorDoca()); kfStateVecsAlongTrajectory.add(sv); diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java index 978ae61e2f..f6d0e5f7ab 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java @@ -1,9 +1,5 @@ package org.jlab.service.dc; -import cnuphys.snr.NoiseReductionParameters; -import cnuphys.snr.clas12.Clas12NoiseAnalysis; -import cnuphys.snr.clas12.Clas12NoiseResult; - import java.util.List; import org.jlab.clas.swimtools.Swim; import org.jlab.io.base.DataEvent; @@ -45,27 +41,16 @@ public boolean processDataEvent(DataEvent event) { // get Field Swim dcSwim = new Swim(); /* 2 */ - // init SNR - Clas12NoiseResult results = new Clas12NoiseResult(); + ClusterFitter cf = new ClusterFitter(); /* 3 */ - Clas12NoiseAnalysis noiseAnalysis = new Clas12NoiseAnalysis(); + ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); /* 4 */ - NoiseReductionParameters parameters = - new NoiseReductionParameters( - 2, - Constants.SNR_LEFTSHIFTS, - Constants.SNR_RIGHTSHIFTS); + RecoBankWriter rbc = new RecoBankWriter(this.getBanks()); /* 5 */ - ClusterFitter cf = new ClusterFitter(); + HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector); /* 6 */ - ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); + hitRead.fetch_DCHits(event); /* 7 */ - RecoBankWriter rbc = new RecoBankWriter(this.getBanks()); - /* 8 */ - HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector); - /* 9 */ - hitRead.fetch_DCHits(event, noiseAnalysis, parameters, results); - /* 10 */ //I) get the hits List hits = hitRead.get_DCHits(Constants.getInstance().SECTORSELECT); //II) process the hits @@ -73,7 +58,7 @@ public boolean processDataEvent(DataEvent event) { if (hits.isEmpty()) { return true; } - /* 11 */ + /* 8 */ //2) find the clusters from these hits ClusterFinder clusFinder = new ClusterFinder(); List clusters = clusFinder.FindHitBasedClusters(hits, @@ -84,7 +69,7 @@ public boolean processDataEvent(DataEvent event) { return true; } else { List fhits = rbc.createRawHitList(hits); - /* 13 */ + /* 9 */ rbc.updateListsWithClusterInfo(fhits, clusters); event.appendBanks(rbc.fillHitsBank(event, fhits), rbc.fillHBClustersBank(event, clusters) diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java index eae796665e..c25bc4f479 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java @@ -1,9 +1,5 @@ package org.jlab.service.dc; -import cnuphys.snr.NoiseReductionParameters; -import cnuphys.snr.clas12.Clas12NoiseAnalysis; -import cnuphys.snr.clas12.Clas12NoiseResult; - import java.util.ArrayList; import java.util.List; @@ -69,28 +65,17 @@ public boolean processDataEvent(DataEvent event) { // get Field Swim dcSwim = new Swim(); /* 2 */ - // init SNR - Clas12NoiseResult results = new Clas12NoiseResult(); - /* 3 */ - Clas12NoiseAnalysis noiseAnalysis = new Clas12NoiseAnalysis(); - /* 4 */ - NoiseReductionParameters parameters = - new NoiseReductionParameters( - 2, - Constants.SNR_LEFTSHIFTS, - Constants.SNR_RIGHTSHIFTS); - /* 5 */ ClusterFitter cf = new ClusterFitter(); - /* 6 */ + /* 3 */ ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); - /* 7 */ + /* 4 */ RecoBankWriter rbc = new RecoBankWriter(this.getBanks()); - /* 8 */ + /* 5 */ HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector); - /* 9 */ - hitRead.fetch_DCHits(event, noiseAnalysis, parameters, results); + /* 6 */ + hitRead.fetch_DCHits(event); - /* 10 */ + /* 7 */ //I) get the hits List hits = hitRead.get_DCHits(); //II) process the hits @@ -98,7 +83,7 @@ public boolean processDataEvent(DataEvent event) { if (hits.isEmpty()) { return true; } - /* 11 */ + /* 8 */ //2) find the clusters from these hits ClusterFinder clusFinder = new ClusterFinder(); List clusters = clusFinder.FindHitBasedClusters(hits, @@ -108,17 +93,17 @@ public boolean processDataEvent(DataEvent event) { if (clusters.isEmpty()) { return true; } - /* 12 */ + /* 9 */ List fhits = rbc.createRawHitList(hits); - /* 13 : assign cluster IDs to hits: if hit is associated to two clusters, the second survives*/ + /* 10 : assign cluster IDs to hits: if hit is associated to two clusters, the second survives*/ rbc.updateListsWithClusterInfo(fhits, clusters); - /* 14 */ + /* 11 */ //3) find the segments from the fitted clusters SegmentFinder segFinder = new SegmentFinder(); List segments = segFinder.get_Segments(clusters, event, Constants.getInstance().dcDetector, false); - /* 15 */ + /* 12 */ // need 6 segments to make a trajectory if (segments.isEmpty()) { rbc.fillAllHBBanks(event, @@ -142,7 +127,7 @@ public boolean processDataEvent(DataEvent event) { } } segments.removeAll(rmSegs); - /* 16 */ + /* 13 */ CrossMaker crossMake = new CrossMaker(); List crosses = crossMake.find_Crosses(segments, Constants.getInstance().dcDetector); if (crosses.isEmpty()) { @@ -154,7 +139,7 @@ public boolean processDataEvent(DataEvent event) { null); return true; } - /* 17 */ + /* 14 */ CrossListFinder crossLister = new CrossListFinder(); CrossList crosslist = crossLister.candCrossLists(event, crosses, @@ -163,14 +148,14 @@ public boolean processDataEvent(DataEvent event) { Constants.getInstance().dcDetector, null, dcSwim, false); - /* 18 */ + /* 15 */ //6) find the list of track candidates TrackCandListFinder trkcandFinder = new TrackCandListFinder(Constants.HITBASE); List trkcands = trkcandFinder.getTrackCands(crosslist, Constants.getInstance().dcDetector, Swimmer.getTorScale(), dcSwim, false); - /* 19 */ + /* 16 */ // track found int trkId = 1; diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index 2bd9d1e9f9..5ecf48569d 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -90,13 +90,13 @@ public boolean processDataEvent(DataEvent event) { Swim dcSwim = new Swim(); // fill T2D table - if(Constants.getInstance().getT2D()==0) { - TableLoader.Fill(this.getConstantsManager().getConstants(run, Constants.TIME2DIST)); - } else { +// if(Constants.getInstance().getT2D()==0) { +// TableLoader.Fill(this.getConstantsManager().getConstants(run, Constants.TIME2DIST)); +// } else { TableLoader.Fill(this.getConstantsManager().getConstants(run, Constants.T2DPRESSURE), this.getConstantsManager().getConstants(run, Constants.T2DPRESSUREREF), this.getConstantsManager().getConstants(run, Constants.PRESSURE)); - } +// } ClusterFitter cf = new ClusterFitter(); ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); @@ -235,7 +235,6 @@ public boolean processDataEvent(DataEvent event) { getInitState(TrackArray1, measSurfaces.get(0).measPoint.z(), initSV, kFZRef, dcSwim, new float[3]); kFZRef.initFromHB(measSurfaces, initSV, TrackArray1.get(0).get(0).get(0).get_Beta()); kFZRef.runFitter(); - List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef); StateVec fn = new StateVec(); if (kFZRef.setFitFailed==false && kFZRef.finalStateVec!=null) { @@ -253,15 +252,18 @@ public boolean processDataEvent(DataEvent event) { TrackArray1.set_FitChi2(kFZRef.chi2); TrackArray1.set_FitNDF(kFZRef.NDF); - TrackArray1.setStateVecs(kfStateVecsAlongTrajectory); TrackArray1.set_FitConvergenceStatus(kFZRef.ConvStatus); if (TrackArray1.get_Vtx0().toVector3D().mag() > 500) { continue; } - + // get CovMat at vertex - Point3D VTCS = crosses.get(0).getCoordsInSector(TrackArray1.get_Vtx0().x(), TrackArray1.get_Vtx0().y(), TrackArray1.get_Vtx0().z()); + Point3D VTCS = crosses.get(0).getCoordsInTiltedSector(TrackArray1.get_Vtx0().x(), TrackArray1.get_Vtx0().y(), TrackArray1.get_Vtx0().z()); TrackArray1.set_CovMat(kFZRef.propagateToVtx(crosses.get(0).get_Sector(), VTCS.z())); + + double deltaPathToVtx = kFZRef.getDeltaPathToVtx(TrackArray1.get(TrackArray1.size()-1).get_Sector(), VTCS.z()); + List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef, deltaPathToVtx); + TrackArray1.setStateVecs(kfStateVecsAlongTrajectory); if (TrackArray1.isGood()) { trkcands.add(TrackArray1); @@ -277,8 +279,6 @@ public boolean processDataEvent(DataEvent event) { kFZRef.initFromHB(measSurfaces, initSV, TrackArray1.get(0).get(0).get(0).get_Beta(), useDAF); kFZRef.runFitter(useDAF); - List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef); - StateVec fn = new StateVec(); if (kFZRef.setFitFailed==false && kFZRef.finalStateVec!=null) { // set the state vector at the last measurement site @@ -296,15 +296,18 @@ public boolean processDataEvent(DataEvent event) { TrackArray1.set_FitChi2(kFZRef.chi2); TrackArray1.set_FitNDF(kFZRef.NDF); TrackArray1.set_NDFDAF(kFZRef.getNDFDAF()); - TrackArray1.setStateVecs(kfStateVecsAlongTrajectory); TrackArray1.set_FitConvergenceStatus(kFZRef.ConvStatus); if (TrackArray1.get_Vtx0().toVector3D().mag() > 500) { continue; } // get CovMat at vertex - Point3D VTCS = crosses.get(0).getCoordsInSector(TrackArray1.get_Vtx0().x(), TrackArray1.get_Vtx0().y(), TrackArray1.get_Vtx0().z()); + Point3D VTCS = crosses.get(0).getCoordsInTiltedSector(TrackArray1.get_Vtx0().x(), TrackArray1.get_Vtx0().y(), TrackArray1.get_Vtx0().z()); TrackArray1.set_CovMat(kFZRef.propagateToVtx(crosses.get(0).get_Sector(), VTCS.z())); + + double deltaPathToVtx = kFZRef.getDeltaPathToVtx(TrackArray1.get(TrackArray1.size()-1).get_Sector(), VTCS.z()); + List kfStateVecsAlongTrajectory = setKFStateVecsAlongTrajectory(kFZRef, deltaPathToVtx); + TrackArray1.setStateVecs(kfStateVecsAlongTrajectory); if (TrackArray1.isGood()) { trkcands.add(TrackArray1); @@ -361,7 +364,7 @@ public boolean processDataEvent(DataEvent event) { return true; } - public List setKFStateVecsAlongTrajectory(KFitter kFZRef) { + public List setKFStateVecsAlongTrajectory(KFitter kFZRef, double deltaPathToVtx) { List kfStateVecsAlongTrajectory = new ArrayList<>(); for(int i = 0; i < kFZRef.kfStateVecsAlongTrajectory.size(); i++) { @@ -369,7 +372,7 @@ public List setKFStateVecsAlongTrajectory(K org.jlab.rec.dc.trajectory.StateVec sv = new org.jlab.rec.dc.trajectory.StateVec(svc.x, svc.y, svc.tx, svc.ty); sv.setZ(svc.z); sv.setB(svc.B); - sv.setPathLength(svc.getPathLength()); + sv.setPathLength(svc.getPathLength() + deltaPathToVtx); // Transition for the starting point from the final point at the last layer to vertex sv.setProjector(svc.getProjector()); sv.setProjectorDoca(svc.getProjectorDoca()); sv.setDAFWeight(svc.getFinalDAFWeight()); @@ -380,7 +383,7 @@ public List setKFStateVecsAlongTrajectory(K return kfStateVecsAlongTrajectory; } - public List setKFStateVecsAlongTrajectory(KFitterStraight kFZRef) { + public List setKFStateVecsAlongTrajectory(KFitterStraight kFZRef, double deltaPathToVtx) { List kfStateVecsAlongTrajectory = new ArrayList<>(); for(int i = 0; i < kFZRef.kfStateVecsAlongTrajectory.size(); i++) { @@ -388,7 +391,7 @@ public List setKFStateVecsAlongTrajectory(K org.jlab.rec.dc.trajectory.StateVec sv = new org.jlab.rec.dc.trajectory.StateVec(svc.x, svc.y, svc.tx, svc.ty); sv.setZ(svc.z); sv.setB(svc.B); - sv.setPathLength(svc.getPathLength()); + sv.setPathLength(svc.getPathLength() + deltaPathToVtx); // Transition for the starting point from the final point at the last layer to vertex sv.setProjector(svc.getProjector()); sv.setProjectorDoca(svc.getProjectorDoca()); kfStateVecsAlongTrajectory.add(sv); diff --git a/reconstruction/eb/pom.xml b/reconstruction/eb/pom.xml index 08a26dcc77..48b03d607b 100644 --- a/reconstruction/eb/pom.xml +++ b/reconstruction/eb/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,25 +21,25 @@ org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/ec/pom.xml b/reconstruction/ec/pom.xml index b70658b6aa..d7a4535c35 100644 --- a/reconstruction/ec/pom.xml +++ b/reconstruction/ec/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,13 +21,13 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/fmt/pom.xml b/reconstruction/fmt/pom.xml index 8aa1df07eb..e6e973f607 100644 --- a/reconstruction/fmt/pom.xml +++ b/reconstruction/fmt/pom.xml @@ -15,21 +15,21 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/ft/pom.xml b/reconstruction/ft/pom.xml index 9a18c45343..8b771b8026 100644 --- a/reconstruction/ft/pom.xml +++ b/reconstruction/ft/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/htcc/pom.xml b/reconstruction/htcc/pom.xml index 3412c49c2b..a2b697d6ff 100644 --- a/reconstruction/htcc/pom.xml +++ b/reconstruction/htcc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/htcc/src/main/java/.classpath b/reconstruction/htcc/src/main/java/.classpath deleted file mode 100644 index 3da7f1474e..0000000000 --- a/reconstruction/htcc/src/main/java/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/reconstruction/htcc/src/main/java/.project b/reconstruction/htcc/src/main/java/.project deleted file mode 100644 index b4155c2226..0000000000 --- a/reconstruction/htcc/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - HTCCReco - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/reconstruction/ltcc/pom.xml b/reconstruction/ltcc/pom.xml index 6454000c7e..b6aae818ca 100644 --- a/reconstruction/ltcc/pom.xml +++ b/reconstruction/ltcc/pom.xml @@ -13,14 +13,14 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/mc/pom.xml b/reconstruction/mc/pom.xml index f590eceb3b..ebc1cf3c4a 100644 --- a/reconstruction/mc/pom.xml +++ b/reconstruction/mc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/mltn/pom.xml b/reconstruction/mltn/pom.xml index 95bf0ab6d0..d4ebf5cc87 100644 --- a/reconstruction/mltn/pom.xml +++ b/reconstruction/mltn/pom.xml @@ -14,7 +14,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -34,13 +34,13 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/pom.xml b/reconstruction/pom.xml index 76ed7aa839..e636255c75 100644 --- a/reconstruction/pom.xml +++ b/reconstruction/pom.xml @@ -3,14 +3,14 @@ org.jlab.clas reconstruction - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT pom org.jlab.clas clas12rec ../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/postproc/pom.xml b/reconstruction/postproc/pom.xml index 6c561dfefb..98c91b4982 100644 --- a/reconstruction/postproc/pom.xml +++ b/reconstruction/postproc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,19 +21,19 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/raster/pom.xml b/reconstruction/raster/pom.xml index 2c248ac363..99c05ceda1 100644 --- a/reconstruction/raster/pom.xml +++ b/reconstruction/raster/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/rich/pom.xml b/reconstruction/rich/pom.xml index 58a9573c34..8d03b1128d 100644 --- a/reconstruction/rich/pom.xml +++ b/reconstruction/rich/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,13 +21,13 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/rtpc/pom.xml b/reconstruction/rtpc/pom.xml index 66340c0618..fb63378d97 100644 --- a/reconstruction/rtpc/pom.xml +++ b/reconstruction/rtpc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,12 +21,12 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT compile diff --git a/reconstruction/swaps/pom.xml b/reconstruction/swaps/pom.xml index e09381c4dc..0851f48dd0 100644 --- a/reconstruction/swaps/pom.xml +++ b/reconstruction/swaps/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,19 +21,19 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/tof/pom.xml b/reconstruction/tof/pom.xml index ce99a611c0..8cdbfde992 100644 --- a/reconstruction/tof/pom.xml +++ b/reconstruction/tof/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/urwell/pom.xml b/reconstruction/urwell/pom.xml index ccb5251a2c..871a35057b 100644 --- a/reconstruction/urwell/pom.xml +++ b/reconstruction/urwell/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -21,13 +21,13 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT diff --git a/reconstruction/vtx/pom.xml b/reconstruction/vtx/pom.xml index 98c454538c..8aaa56821a 100644 --- a/reconstruction/vtx/pom.xml +++ b/reconstruction/vtx/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT @@ -33,13 +33,13 @@ org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.1t-SNAPSHOT jar From d596173868bf1e8d87ff53728c7b5a100ed0fe88 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 17:54:41 +0000 Subject: [PATCH 19/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- etc/bankdefs/hipo4/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etc/bankdefs/hipo4/README.md b/etc/bankdefs/hipo4/README.md index cf2881f836..270e947e30 100644 --- a/etc/bankdefs/hipo4/README.md +++ b/etc/bankdefs/hipo4/README.md @@ -386,6 +386,8 @@ | 12 | `ATOF::tdc` | TDC bank for the ALERT TOF | | 21 | `ATOF::hits` | Reconstructed ATOF hits | | 22 | `ATOF::clusters` | Clusters in ATOF | +| 31 | `ATOF::testhits` | Reconstructed ATOF hits | +| 32 | `ATOF::testclusters` | Clusters in ATOF | ## Group 22600 @@ -407,3 +409,4 @@ | 26 | `AHDC::KFTrack` | Reco Kalman Filter Tracks | | 30 | `AHDC_AI::Prediction` | Prediction given by AI | | 31 | `ALERT::Projections` | Track Projections to ATOF | +| 35 | `ATOF::testVeff` | veff test for ATOF | From bd117d6856ba89ebf84cc4de8ccc3649a0826a5e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 19:27:15 +0000 Subject: [PATCH 20/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- etc/bankdefs/hipo4/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/etc/bankdefs/hipo4/README.md b/etc/bankdefs/hipo4/README.md index 1a9d52e386..270e947e30 100644 --- a/etc/bankdefs/hipo4/README.md +++ b/etc/bankdefs/hipo4/README.md @@ -389,7 +389,6 @@ | 31 | `ATOF::testhits` | Reconstructed ATOF hits | | 32 | `ATOF::testclusters` | Clusters in ATOF | - ## Group 22600 | Item ID | Name | Description | @@ -411,4 +410,3 @@ | 30 | `AHDC_AI::Prediction` | Prediction given by AI | | 31 | `ALERT::Projections` | Track Projections to ATOF | | 35 | `ATOF::testVeff` | veff test for ATOF | -