1#include "MdcHoughFinder/HoughRecHit.h"
2#include "MdcHoughFinder/HoughStereo.h"
37 theta=
M_PI-atan2(y1-yc,x1-xc)+atan2(yc,xc);
45 if(_charge == 1 ) theta = 2*
M_PI-theta;
75 double k = (ywest-yeast)/(xwest-xeast);
76 double b = -k*xeast+yeast;
87 double x1(999),y1(999);
88 double x2(999),y2(999);
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;
100 double x1_0 = ( -b1+sqrt(delta1) ) /(2*a);
101 double x1_1 = ( -b1-sqrt(delta1) ) /(2*a);
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 ) {
112 if( ok[0][0] ==
false && ok[0][1]==
false ) ok_ambig[0] =
false;
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;
127 double x2_0 = ( -b1+sqrt(delta2) ) /(2*a);
128 double x2_1 = ( -b1-sqrt(delta2) ) /(2*a);
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 ) {
138 if( ok[1][0] ==
false && ok[1][1]==
false ) ok_ambig[1] =
false;
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;
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;
164void 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){
170 theta=
M_PI-atan2(y1-yc,x1-xc)+atan2(yc,xc);
178 if(_charge == 1 ) theta = 2*
M_PI-theta;
180 double d1=sqrt((x1-x_west)*(x1-x_west)+(y1-y_west)*(y1-y_west));
181 double d2=sqrt((x_east-x_west)*(x_east-x_west)+(y_east-y_west)*(y_east-y_west));
185 z = z_west-(z_west-z_east)*d1/d2;
318 _rechit->
setzAmb( 1 , _zright);
319 _rechit->
setsAmb( 1 , _lright);
323 cout<<
" left: "<<_lleft<<
" , "<<_zleft<<endl;
324 cout<<
" right: "<<_lright<<
" , "<<_zright<<endl;
325 double xc = _circle->
getCirX();
326 double yc = _circle->
getCirY();
327 double rc = _circle->
getCirR();
331 double l(0),theta(0);
336 theta=
M_PI-atan2(y1-yc,x1-xc)+atan2(yc,xc);
344 if(_charge == 1 ) theta = 2*
M_PI-theta;
346 cout<<
" truth: "<<l<<
" , "<<z1<<endl;
347 cout<<
"truth x y z "<<x1<<
" "<<y1<<
" "<<z1<<endl;
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 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)