23 {
31
32 double l(0),theta(0);
33 if(xc==0||x1-xc==0){
34 theta=0;
35 }
36 else{
37 theta=
M_PI-atan2(y1-yc,x1-xc)+atan2(yc,xc);
40 }
41 if(theta<0){
43 }
44 }
45 if(_charge == 1 ) theta = 2*
M_PI-theta;
46 l = rc*theta;
47 _lleft=l;
48 _zleft=z1;
49 _lright=l;
50 _zright=z1;
55 return -2;
56 }else{
57 bool ok_ambig[2];
58 bool ok[2][2];
59 ok_ambig[0]=true;
60 ok_ambig[1]=true;
61 ok[0][0]=false;
62 ok[0][1]=false;
63 ok[1][0]=false;
64 ok[1][1]=false;
74
75 double k = (ywest-yeast)/(xwest-xeast);
76 double b = -k*xeast+yeast;
77
81
82
84
85
86
87 double x1(999),y1(999);
88 double x2(999),y2(999);
89 double a = k*k+1;
90 double b1 = -2*(xc+k*yc-k*b);
91 double c1 = xc*xc+(yc-b)*(yc-b)-(rc+drift)*(rc+drift);
92 double c2 = xc*xc+(yc-b)*(yc-b)-(rc-drift)*(rc-drift);
93 double delta1 = (b1*b1-4*a*
c1);
94 double delta2 = (b1*b1-4*a*c2);
95 if( delta1 <0 ) ok_ambig[0] = false;
96 if( delta2 <0 ) ok_ambig[1] = false;
97
98
99 if( delta1>=0 ) {
100 double x1_0 = ( -b1+sqrt(delta1) ) /(2*a);
101 double x1_1 = ( -b1-sqrt(delta1) ) /(2*a);
102
103
104 if( (xeast>=x1_0 && xwest<=x1_0) or (xeast<=x1_0 && xwest>=x1_0) ) ok[0][0] = true;
105 if ( (xeast>=x1_1 && xwest<=x1_1) or (xeast<=x1_1 && xwest>=x1_1) ) ok[0][1]=true;
106 if( ok[0][0] == true && ok[0][1]==false ) x1 = x1_0;
107 if( ok[0][0] == false && ok[0][1]==true ) x1 = x1_1;
108 if( ok[0][0] == true && ok[0][1]==true ) {
109 x1 = x1_0;
110
111 }
112 if( ok[0][0] == false && ok[0][1]==false ) ok_ambig[0] = false;
113 y1 = k*x1+b;
115 double l1= 0;
116 double z1= 0;
117 if(ok_ambig[0]==true) {
118 calcu(x1,y1,xc,yc,rc,xeast,yeast,zeast,xwest,ywest,zwest,
theta1,l1,z1);
119 if(
m_debug>0) cout<<
" theta1 l1 z1 "<<
theta1<<
" "<<l1<<
" "<<z1<<endl;
120 _zleft = z1;
121 _lleft = l1;
122 }
123
124 }
125
126 if( delta2>=0){
127 double x2_0 = ( -b1+sqrt(delta2) ) /(2*a);
128 double x2_1 = ( -b1-sqrt(delta2) ) /(2*a);
129
130 if( (xeast>=x2_0 && xwest<=x2_0) or (xeast<=x2_0 && xwest>=x2_0) ) ok[1][0] = true;
131 if ( (xeast>=x2_1 && xwest<=x2_1) or (xeast<=x2_1 && xwest>=x2_1) ) ok[1][1]=true;
132 if( ok[1][0] == true && ok[1][1]==false ) x2 = x2_0;
133 if( ok[1][0] == false && ok[1][1]==true ) x2 = x2_1;
134 if( ok[1][0] == true && ok[1][1]==true ) {
135 x2 = x2_0;
136
137 }
138 if( ok[1][0] == false && ok[1][1]==false ) ok_ambig[1] = false;
139 y2 = k*x2+b;
141 double l2= 0;
142 double z2= 0;
143 if(ok_ambig[1]==true) {
144 calcu(x2,y2,xc,yc,rc,xeast,yeast,zeast,xwest,ywest,zwest,
theta2,l2,z2);
145 if(
m_debug>0) cout<<
" theta2 l2 z2 "<<
theta2<<
" "<<l2<<
" "<<z2<<endl;
146 _zright = z2;
147 _lright = l2;
148 }
149
150 }
155 if( ok_ambig[0] == true && ok_ambig[1] == false ) return -1;
156 if( ok_ambig[0] == false && ok_ambig[1] == true ) return 1;
157 if( ok_ambig[0] == true && ok_ambig[1] == true ) return 2;
158 if( ok_ambig[0] == false && ok_ambig[1] == false ) return 0;
159 }
160
161}
double getDriftDist() const
HepPoint3D setRightPoint(HepPoint3D p)
HepPoint3D getWestPoint() const
HepPoint3D setLeftPoint(HepPoint3D p)
HepPoint3D getEastPoint() const
HepPoint3D getPointTruth() const
detectorType getDetectorType() const
HepPoint3D getMidPoint() 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)