23 {
24 bool ok_ambig[2];
25 bool ok[2][2];
26 ok_ambig[0]=true;
27 ok_ambig[1]=true;
28 ok[0][0]=false;
29 ok[0][1]=false;
30 ok[1][0]=false;
31 ok[1][1]=false;
38
39 double k = (ywest-yeast)/(xwest-xeast);
40 double b = -k*xeast+yeast;
41
45
47
48
49
50 double x1(999),y1(999);
51 double x2(999),y2(999);
52 double a = k*k+1;
53 double b1 = -2*(xc+k*yc-k*b);
54 double c1 = xc*xc+(yc-b)*(yc-b)-(rc+drift)*(rc+drift);
55 double c2 = xc*xc+(yc-b)*(yc-b)-(rc-drift)*(rc-drift);
56 double delta1 = (b1*b1-4*a*c1);
57 double delta2 = (b1*b1-4*a*c2);
58 if( delta1 <0 ) ok_ambig[0] = false;
59 if( delta2 <0 ) ok_ambig[1] = false;
60
61
62 if( delta1>=0 ) {
63 double x1_0 = ( -b1+sqrt(delta1) ) /(2*a);
64 double x1_1 = ( -b1-sqrt(delta1) ) /(2*a);
65
66 if( (xeast>=x1_0 && xwest<=x1_0) or (xeast<=x1_0 && xwest>=x1_0) ) ok[0][0] = true;
67 if ( (xeast>=x1_1 && xwest<=x1_1) or (xeast<=x1_1 && xwest>=x1_1) ) ok[0][1]=true;
68 if( ok[0][0] == true && ok[0][1]==false ) x1 = x1_0;
69 if( ok[0][0] == false && ok[0][1]==true ) x1 = x1_1;
70 if( ok[0][0] == true && ok[0][1]==true ) {
71 x1 = x1_0;
72
73 }
74 if( ok[0][0] == false && ok[0][1]==false ) ok_ambig[0] = false;
75 y1 = k*x1+b;
77 double l1= 0;
78 double z1= 0;
79 if(ok_ambig[0]==true) {
80 calcu(x1,y1,xc,yc,rc,xeast,yeast,zeast,xwest,ywest,zwest,
theta1,l1,z1);
81 if(
m_debug>0) cout<<
" theta1 l1 z1 "<<
theta1<<
" "<<l1<<
" "<<z1<<endl;
82 _zleft = z1;
83 _lleft = l1;
84 }
85 }
86
87 if( delta2>=0){
88 double x2_0 = ( -b1+sqrt(delta2) ) /(2*a);
89 double x2_1 = ( -b1-sqrt(delta2) ) /(2*a);
90
91 if( (xeast>=x2_0 && xwest<=x2_0) or (xeast<=x2_0 && xwest>=x2_0) ) ok[1][0] = true;
92 if ( (xeast>=x2_1 && xwest<=x2_1) or (xeast<=x2_1 && xwest>=x2_1) ) ok[1][1]=true;
93 if( ok[1][0] == true && ok[1][1]==false ) x2 = x2_0;
94 if( ok[1][0] == false && ok[1][1]==true ) x2 = x2_1;
95 if( ok[1][0] == true && ok[1][1]==true ) {
96 x2 = x2_0;
97
98 }
99 if( ok[1][0] == false && ok[1][1]==false ) ok_ambig[1] = false;
100 y2 = k*x2+b;
102 double l2= 0;
103 double z2= 0;
104 if(ok_ambig[1]==true) {
105 calcu(x2,y2,xc,yc,rc,xeast,yeast,zeast,xwest,ywest,zwest,
theta2,l2,z2);
106 if(
m_debug>0) cout<<
" theta2 l2 z2 "<<
theta2<<
" "<<l2<<
" "<<z2<<endl;
107 _zright = z2;
108 _lright = l2;
109 }
110 }
111 if( ok_ambig[0] == true && ok_ambig[1] == false ) return -1;
112 if( ok_ambig[0] == false && ok_ambig[1] == true ) return 1;
113 if( ok_ambig[0] == true && ok_ambig[1] == true ) return 2;
114 if( ok_ambig[0] == false && ok_ambig[1] == false ) return 0;
115
116}
double getDriftDist() const
HepPoint3D getWestPoint() const
HepPoint3D getEastPoint() const
void calcu(double x1, double y1, double xc, double yc, double rc, double x_east, double y_east, double z_east, double x_west, double y_west, double z_west, double &theta, double &l, double &z)