Skip to content

Commit b819ade

Browse files
zyzhangjlabZeyu ZhangZeyu Zhang
authored
correct the calculation of z positions of clusters and docaclusters (#1165)
* correct the calculation of z positions of clusters and docaclusters * calculate stereoangle with line information * remove unused variables --------- Co-authored-by: Zeyu Zhang <[email protected]> Co-authored-by: Zeyu Zhang <[email protected]>
1 parent d76194d commit b819ade

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Cluster/Cluster.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
import org.jlab.rec.ahdc.PreCluster.PreCluster;
55

66
import java.util.ArrayList;
7+
import org.jlab.geom.detector.alert.AHDC.AlertDCFactory;
8+
import org.jlab.geom.prim.Line3D;
9+
import org.jlab.geom.prim.Point3D;
710

811
/**
912
* Cluster are compose by 2 PreCluster on layer with a different stereo angle
1013
*/
1114
public class Cluster {
1215

1316
private int _trackId = -1;
14-
private double _StereoAngle = 20.0;
15-
private double _DeltaZ = 300.0;
16-
private double _Zoffset = 150.0;
17-
1817
private double _Radius;
1918
private double _Phi;
2019
private double _Z;
@@ -26,14 +25,46 @@ public class Cluster {
2625
private double _V;
2726
private ArrayList<PreCluster> _PreClusters_list;
2827

28+
private static Line3D representativeLine(PreCluster pc) {
29+
if (pc == null || pc.get_hits_list() == null || pc.get_hits_list().isEmpty()) {
30+
return null;
31+
}
32+
Hit h = pc.get_hits_list().get(0);
33+
return h.getLine();
34+
}
35+
private static double wrapPi(double a) {
36+
while (a > Math.PI) a -= 2.0 * Math.PI;
37+
while (a < -Math.PI) a += 2.0 * Math.PI;
38+
return a;
39+
}
40+
private static double stereoTwistFromLine(Line3D line) {
41+
if (line == null) {
42+
return 0.0;
43+
}
44+
45+
Point3D p0 = line.origin();
46+
Point3D p1 = line.end();
47+
48+
double phi0 = Math.atan2(p0.y(), p0.x());
49+
double phi1 = Math.atan2(p1.y(), p1.x());
2950

51+
return wrapPi(phi1 - phi0);
52+
}
3053
public Cluster(PreCluster precluster, PreCluster other_precluster) {
3154
this._PreClusters_list = new ArrayList<>();
3255
_PreClusters_list.add(precluster);
3356
_PreClusters_list.add(other_precluster);
3457
this._Radius = (precluster.get_Radius() + other_precluster.get_Radius()) / 2;
3558

36-
this._Z = ((other_precluster.get_Phi() - precluster.get_Phi()) / (Math.toRadians(_StereoAngle) * Math.pow(-1, precluster.get_Super_layer()-1) - Math.toRadians(_StereoAngle) * Math.pow(-1, other_precluster.get_Super_layer()-1))) * _DeltaZ - _Zoffset;
59+
Line3D line1 = representativeLine(precluster);
60+
Line3D line2 = representativeLine(other_precluster);
61+
Point3D end1 = line1.end();
62+
Point3D start1 = line1.origin();
63+
double DeltaZ = end1.z()-start1.z();
64+
double Zref = end1.z();
65+
double StereoAnglep = stereoTwistFromLine(line1);
66+
double StereoAngleo = stereoTwistFromLine(line2);
67+
this._Z = ((precluster.get_Phi() - other_precluster.get_Phi()) / (StereoAnglep - StereoAngleo)) * DeltaZ + Zref;
3768

3869
double x1 = -precluster.get_Radius() * Math.sin(precluster.get_Phi());
3970
double y1 = -precluster.get_Radius() * Math.cos(precluster.get_Phi());

reconstruction/alert/src/main/java/org/jlab/rec/ahdc/DocaCluster/DocaClusterRefiner.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,10 @@ private static Line3D buildShiftedWireLine(Hit h, Vec2 tangentXY) {
209209
double dz = e.z() - o.z();
210210

211211
// New origin: (tangent.x, tangent.y, original_z)
212-
Point3D oShift = new Point3D(tangentXY.x, tangentXY.y, o.z());
213-
Point3D eShift = new Point3D(oShift.x() + dx, oShift.y() + dy, oShift.z() + dz);
214-
212+
//Point3D oShift = new Point3D(tangentXY.x, tangentXY.y, o.z());
213+
//Point3D eShift = new Point3D(oShift.x() + dx, oShift.y() + dy, oShift.z() + dz);
214+
Point3D eShift = new Point3D(tangentXY.x, tangentXY.y, e.z());
215+
Point3D oShift = new Point3D(tangentXY.x - dx, tangentXY.y - dy, e.z() - dz);
215216
return new Line3D(oShift, eShift);
216217
}
217218

0 commit comments

Comments
 (0)