1111
1212public class Hit implements Comparable <Hit > {
1313
14- private final double thster = Math .toRadians (20.0 );
15- private final double zl = 300.0 ;//OK
1614 private final int superLayer ;
1715 private final int layer ;
1816 private final int wire ;
@@ -30,118 +28,31 @@ public class Hit implements Comparable<Hit> {
3028 // Comparison with: common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java
3129 // here, SuperLayer, Layer, Wire, start from 1
3230 // in AlertDCFactory, same variables start from 1
33- public Hit (int superLayer , int layer , int wire , int numWire , double r , double doca ) {
31+ public Hit (int superLayer , int layer , int wire , int numWire , Line3D line , double doca ) {
3432 this .superLayer = superLayer ;
3533 this .layer = layer ;
3634 this .wire = wire ;
37- this .r = r ;
35+ this .r = line . end (). distance ( 0 , 0 , line . end (). z ()) ;
3836 this .doca = doca ;
3937 this .numWires = numWire ;
4038 this .adc = 0 ;//placeholder
4139 this .hitidx = -1 ;
4240 this .hitsign = 0 ;
4341
44- final double DR_layer = 4.0 ;//OK
45- final double round = 360.0 ;//OK
46- final double thster = Math .toRadians (20.0 );//OK
47-
48- double numWires = 32.0 ;
49- double R_layer = 47.0 ;
50-
51- double zoff1 = -zl /2 ;//OK
52- double zoff2 = +zl /2 ;//OK
53- Point3D p1 = new Point3D (R_layer , 0 , zoff1 );
54- Vector3D n1 = new Vector3D (0 , 0 , 1 );
55- //n1.rotateY(-thopen);
56- //n1.rotateZ(thtilt);
57- Plane3D lPlane = new Plane3D (p1 , n1 );//OK
58-
59- Point3D p2 = new Point3D (R_layer , 0 , zoff2 );
60- Vector3D n2 = new Vector3D (0 , 0 , 1 );
61- //n2.rotateY(thopen);
62- //n2.rotateZ(thtilt);
63- Plane3D rPlane = new Plane3D (p2 , n2 );//OK
64-
65- switch (this .superLayer ) {//OK
66- case 1 :
67- numWires = 47.0 ;
68- R_layer = 32.0 ;
69- break ;
70- case 2 :
71- numWires = 56.0 ;
72- R_layer = 38.0 ;
73- break ;
74- case 3 :
75- numWires = 72.0 ;
76- R_layer = 48.0 ;
77- break ;
78- case 4 :
79- numWires = 87.0 ;
80- R_layer = 58.0 ;
81- break ;
82- case 5 :
83- numWires = 99.0 ;
84- R_layer = 68.0 ;
85- break ;
86- }
87-
88-
89- R_layer = R_layer + DR_layer * (this .layer -1 );//OK
90- double alphaW_layer = Math .toRadians (round / (numWires ));//OK
91- double wx = -R_layer * Math .sin (alphaW_layer * (this .wire -1 ));//OK
92- double wy = -R_layer * Math .cos (alphaW_layer * (this .wire -1 ));//OK
93-
94- double wx_end = -R_layer * Math .sin (alphaW_layer * (this .wire -1 ) + thster * (Math .pow (-1 , this .superLayer -1 )));//OK
95- double wy_end = -R_layer * Math .cos (alphaW_layer * (this .wire -1 ) + thster * (Math .pow (-1 , this .superLayer -1 )));//OK
96-
97- this .phi = Math .atan2 ( (wy +wy_end )*0.5 , (wx +wx_end )*0.5 );
42+ this .phi = line .midpoint ().vectorFrom (0 ,0 ,0 ).phi ();
9843 //System.out.println(" superlayer " + this.superLayer + " layer " + this.layer + " wire " + this.wire + " wx " + wx + " wy " + wy + " wx_end " + wx_end + " wy_end " + wy_end + " phi " + this.phi);
9944
100- Line3D line = new Line3D (wx , wy , -zl /2 , wx_end , wy_end , zl /2 );
101- Point3D lPoint = new Point3D ();
102- Point3D rPoint = new Point3D ();
103- lPlane .intersection (line , lPoint );
104- rPlane .intersection (line , rPoint );
105- //lPoint.setZ(-zl/2);
106- //rPoint.setZ(zl/2);
107- //lPoint.show();
108- //rPoint.show();
109- // All wire go from left to right
110- Line3D wireLine = new Line3D (lPoint , rPoint );
111- //wireLine.show();
112- this .line3D = wireLine ;
45+ this .line3D = line ;
11346
11447 //calculate the "virtual" left and right wires accounting for the DOCA
115- double deltaphi = Math .asin (this .doca /R_layer );
116- double wx_plus = -R_layer * Math .sin ( alphaW_layer * (this .wire -1 ) - deltaphi );//OK
117- double wy_plus = -R_layer * Math .cos ( alphaW_layer * (this .wire -1 ) - deltaphi );//OK
118-
119- double wx_plus_end = -R_layer * Math .sin ( alphaW_layer * (this .wire -1 ) + thster * (Math .pow (-1 , this .superLayer -1 )) - deltaphi );//OK
120- double wy_plus_end = -R_layer * Math .cos ( alphaW_layer * (this .wire -1 ) + thster * (Math .pow (-1 , this .superLayer -1 )) - deltaphi );//OK
121-
122- line = new Line3D (wx_plus , wy_plus , -zl /2 , wx_plus_end , wy_plus_end , zl /2 );
123- lPoint = new Point3D ();
124- rPoint = new Point3D ();
125- lPlane .intersection (line , lPoint );
126- rPlane .intersection (line , rPoint );
127-
128- wireLine = new Line3D (lPoint , rPoint );
129- this .line3D_plus = wireLine ;
130-
131- double wx_minus = -R_layer * Math .sin ( alphaW_layer * (this .wire -1 ) + deltaphi );//OK
132- double wy_minus = -R_layer * Math .cos ( alphaW_layer * (this .wire -1 ) + deltaphi );//OK
133-
134- double wx_minus_end = -R_layer * Math .sin ( alphaW_layer * (this .wire -1 ) + thster * (Math .pow (-1 , this .superLayer -1 )) + deltaphi );//OK
135- double wy_minus_end = -R_layer * Math .cos ( alphaW_layer * (this .wire -1 ) + thster * (Math .pow (-1 , this .superLayer -1 )) + deltaphi );//OK
136-
137- line = new Line3D (wx_minus , wy_minus , -zl /2 , wx_minus_end , wy_minus_end , zl /2 );
138- lPoint = new Point3D ();
139- rPoint = new Point3D ();
140- lPlane .intersection (line , lPoint );
141- rPlane .intersection (line , rPoint );
142-
143- wireLine = new Line3D (lPoint , rPoint );
144- this .line3D_minus = wireLine ;
48+ double deltaphi = Math .asin (this .doca /r );
49+ this .line3D_plus = new Line3D ();
50+ this .line3D_plus .copy (line );
51+ this .line3D_plus .rotateZ (deltaphi );
52+
53+ this .line3D_minus = new Line3D ();
54+ this .line3D_minus .copy (line );
55+ this .line3D_minus .rotateZ (deltaphi );
14556
14657 }
14758
@@ -180,9 +91,7 @@ public double doca() {
18091 public double phi () {return phi ;}//at z = 0;
18192
18293 public double phi (double z ) {
183- double x_z = r *Math .sin ( phi + thster * z /(zl *0.5 ) * (Math .pow (-1 , this .superLayer -1 )) );
184- double y_z = r *Math .cos ( phi + thster * z /(zl *0.5 ) * (Math .pow (-1 , this .superLayer -1 )) );
185- return Math .atan2 (x_z , y_z );
94+ return this .line3D .lerpPoint ((z -line3D .origin ().z ())/line3D .length ()).vectorFrom (0 ,0 ,0 ).phi ();
18695 }
18796
18897 public Line3D line () {return line3D ;}
@@ -216,10 +125,6 @@ public RealVector get_Vector_beam() {
216125 return null ;
217126 }
218127
219- public double getThster () {
220- return thster ;
221- }
222-
223128 public int getSuperLayer () {
224129 return superLayer ;
225130 }
0 commit comments