39 double k = (ywest-yeast)/(xwest-xeast);
40 double b = -k*xeast+yeast;
50 double x1(999),y1(999);
51 double x2(999),y2(999);
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;
63 double x1_0 = ( -b1+sqrt(delta1) ) /(2*a);
64 double x1_1 = ( -b1-sqrt(delta1) ) /(2*a);
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 ) {
74 if( ok[0][0] ==
false && ok[0][1]==
false ) ok_ambig[0] =
false;
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;
88 double x2_0 = ( -b1+sqrt(delta2) ) /(2*a);
89 double x2_1 = ( -b1-sqrt(delta2) ) /(2*a);
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 ) {
99 if( ok[1][0] ==
false && ok[1][1]==
false ) ok_ambig[1] =
false;
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;
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;
119void HoughStereo::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){
125 theta=
M_PI-atan2(y1-yc,x1-xc)+atan2(yc,xc);
133 if(_charge == 1 ) theta = 2*
M_PI-theta;
135 double d1=sqrt((x1-x_west)*(x1-x_west)+(y1-y_west)*(y1-y_west));
136 double d2=sqrt((x_east-x_west)*(x_east-x_west)+(y_east-y_west)*(y_east-y_west));
139 z = z_west-(z_west-z_east)*d1/d2;
272 _rechit->
setzAmb( 1 , _zright);
273 _rechit->
setsAmb( 1 , _lright);
277 cout<<
" left: "<<_lleft<<
","<<_zleft<<endl;
278 cout<<
" right: "<<_lright<<
","<<_zright<<endl;
double getDriftDist() const
HepPoint3D getWestPoint() const
HepPoint3D getEastPoint() const
void setzAmb(int i, double zPos)
void setsAmb(int i, double sPos)
HoughStereo(double bunchTime, Hough2D *circle, HoughRecHit *rechit)
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)