BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
HoughStereo Class Reference

#include <HoughStereo.h>

Public Member Functions

 HoughStereo (double bunchTime, Hough2D *circle, HoughRecHit *rechit)
void setAmb (int i)
int cald ()
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)
void setRecHit ()
void print ()
Hough2DgetCircle () const
HoughRecHitgetRecHit () const
double getlLeft () const
double getlRight () const
double getzLeft () const
double getzRight () const

Static Public Attributes

static int m_debug = 0

Detailed Description

Definition at line 9 of file HoughStereo.h.

Constructor & Destructor Documentation

◆ HoughStereo()

HoughStereo::HoughStereo ( double bunchTime,
Hough2D * circle,
HoughRecHit * rechit )

Definition at line 9 of file HoughStereo.cxx.

10 : _bunchTime( bunchTime ), _circle( circle ), _rechit( rechit ) {
11 _lleft = -99;
12 _zleft = -99;
13 _lright = -99;
14 _zright = -99;
15 _ambig = 0;
16 _charge = circle->getCharge();
17}
int getCharge() const
Definition Hough2D.h:39

Member Function Documentation

◆ calcu()

void 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 )

Definition at line 130 of file HoughStereo.cxx.

132 {
133 // rphi -> sz
134 if ( xc == 0 || x1 - xc == 0 ) { theta = 0; }
135 else
136 {
137 theta = M_PI - atan2( y1 - yc, x1 - xc ) + atan2( yc, xc );
138 if ( theta > 2 * M_PI ) { theta = theta - 2 * M_PI; }
139 if ( theta < 0 ) { theta = theta + 2 * M_PI; }
140 }
141 if ( _charge == 1 ) theta = 2 * M_PI - theta;
142
143 double d1 = sqrt( ( x1 - x_west ) * ( x1 - x_west ) + ( y1 - y_west ) * ( y1 - y_west ) );
144 double d2 = sqrt( ( x_east - x_west ) * ( x_east - x_west ) +
145 ( y_east - y_west ) * ( y_east - y_west ) );
146 // cout<<"d1/d2 "<<d1/d2<<" "<<d1<<" "<<d2<<endl;
147 // cout<<"zw ze "<<z_west<<" "<<z_east<<endl;
148 z = z_west - ( z_west - z_east ) * d1 / d2;
149 l = rc * theta;
150}
#define M_PI
Definition TConstant.h:4

Referenced by cald().

◆ cald()

int HoughStereo::cald ( )

Definition at line 23 of file HoughStereo.cxx.

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;
32 double xeast = _rechit->getEastPoint().x();
33 double xwest = _rechit->getWestPoint().x();
34 double yeast = _rechit->getEastPoint().y();
35 double ywest = _rechit->getWestPoint().y();
36 double zeast = _rechit->getEastPoint().z();
37 double zwest = _rechit->getWestPoint().z();
38 // cout<<"xeast xwest "<<xeast<<" "<<xwest<<endl;
39 double k = ( ywest - yeast ) / ( xwest - xeast );
40 double b = -k * xeast + yeast;
41 // cout<<" k b "<<k<<" "<<b<<endl;
42 double xc = _circle->getCirX();
43 double yc = _circle->getCirY();
44 double rc = _circle->getCirR();
45 // cout<<"xc yc rc "<<xc<<" "<<yc<<" "<<rc<<endl;
46 double drift = _rechit->getDriftDist();
47 // double drift = _rechit->getDriftDistTruth();
48 // cout<<"drift "<<_rechit->getDriftDist()<<endl;
49 // cout<<"driftTruth "<<_rechit->getDriftDistTruth()<<endl;
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 // cout<<"(b1*b1-4*a*c1) "<<(b1*b1-4*a*c1)<<endl;
61 // cout<<"(b1*b1-4*a*c2) "<<(b1*b1-4*a*c2)<<endl;
62 if ( delta1 >= 0 )
63 {
64 double x1_0 = ( -b1 + sqrt( delta1 ) ) / ( 2 * a );
65 double x1_1 = ( -b1 - sqrt( delta1 ) ) / ( 2 * a );
66 // cout<<"x1 0 1 "<<x1_0<<" "<<x1_1<<endl;
67 if ( ( xeast >= x1_0 && xwest <= x1_0 ) or ( xeast <= x1_0 && xwest >= x1_0 ) )
68 ok[0][0] = true;
69 if ( ( xeast >= x1_1 && xwest <= x1_1 ) or ( xeast <= x1_1 && xwest >= x1_1 ) )
70 ok[0][1] = true;
71 if ( ok[0][0] == true && ok[0][1] == false ) x1 = x1_0;
72 if ( ok[0][0] == false && ok[0][1] == true ) x1 = x1_1;
73 if ( ok[0][0] == true && ok[0][1] == true )
74 {
75 x1 = x1_0; //??good
76 // cout<<" error both ok "<<endl;
77 }
78 if ( ok[0][0] == false && ok[0][1] == false ) ok_ambig[0] = false;
79 y1 = k * x1 + b;
80 double theta1 = 0;
81 double l1 = 0;
82 double z1 = 0;
83 if ( ok_ambig[0] == true )
84 {
85 calcu( x1, y1, xc, yc, rc, xeast, yeast, zeast, xwest, ywest, zwest, theta1, l1, z1 );
86 if ( m_debug > 0 ) cout << " theta1 l1 z1 " << theta1 << " " << l1 << " " << z1 << endl;
87 _zleft = z1;
88 _lleft = l1;
89 }
90 }
91
92 if ( delta2 >= 0 )
93 {
94 double x2_0 = ( -b1 + sqrt( delta2 ) ) / ( 2 * a );
95 double x2_1 = ( -b1 - sqrt( delta2 ) ) / ( 2 * a );
96 // cout<<"x2 0 1 "<<x2_0<<" "<<x2_1<<endl;
97 if ( ( xeast >= x2_0 && xwest <= x2_0 ) or ( xeast <= x2_0 && xwest >= x2_0 ) )
98 ok[1][0] = true;
99 if ( ( xeast >= x2_1 && xwest <= x2_1 ) or ( xeast <= x2_1 && xwest >= x2_1 ) )
100 ok[1][1] = true;
101 if ( ok[1][0] == true && ok[1][1] == false ) x2 = x2_0;
102 if ( ok[1][0] == false && ok[1][1] == true ) x2 = x2_1;
103 if ( ok[1][0] == true && ok[1][1] == true )
104 {
105 x2 = x2_0;
106 // cout<<" error both ok "<<endl;
107 }
108 if ( ok[1][0] == false && ok[1][1] == false ) ok_ambig[1] = false;
109 y2 = k * x2 + b;
110 double theta2 = 0;
111 double l2 = 0;
112 double z2 = 0;
113 if ( ok_ambig[1] == true )
114 {
115 calcu( x2, y2, xc, yc, rc, xeast, yeast, zeast, xwest, ywest, zwest, theta2, l2, z2 );
116 if ( m_debug > 0 ) cout << " theta2 l2 z2 " << theta2 << " " << l2 << " " << z2 << endl;
117 _zright = z2;
118 _lright = l2;
119 }
120 }
121 if ( ok_ambig[0] == true && ok_ambig[1] == false ) return -1;
122 if ( ok_ambig[0] == false && ok_ambig[1] == true ) return 1;
123 if ( ok_ambig[0] == true && ok_ambig[1] == true ) return 2;
124 if ( ok_ambig[0] == false && ok_ambig[1] == false ) return 0;
125 // cout<<" ztruth : "<<_rechit->getZTruth()<<endl;
126 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
127 exit( 1 );
128}
static int m_debug
Definition HoughStereo.h:27
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)

Referenced by HoughTrack::calzs().

◆ getCircle()

Hough2D * HoughStereo::getCircle ( ) const
inline

Definition at line 21 of file HoughStereo.h.

21{ return _circle; }

◆ getlLeft()

double HoughStereo::getlLeft ( ) const
inline

Definition at line 23 of file HoughStereo.h.

23{ return _lleft; }

◆ getlRight()

double HoughStereo::getlRight ( ) const
inline

Definition at line 24 of file HoughStereo.h.

24{ return _lright; }

◆ getRecHit()

HoughRecHit * HoughStereo::getRecHit ( ) const
inline

Definition at line 22 of file HoughStereo.h.

22{ return _rechit; }

◆ getzLeft()

double HoughStereo::getzLeft ( ) const
inline

Definition at line 25 of file HoughStereo.h.

25{ return _zleft; }

◆ getzRight()

double HoughStereo::getzRight ( ) const
inline

Definition at line 26 of file HoughStereo.h.

26{ return _zright; }

◆ print()

void HoughStereo::print ( )

Definition at line 283 of file HoughStereo.cxx.

283 {
284 cout << "Hit"
285 << "(" << _rechit->getLayerId() << "," << _rechit->getWireId() << ") "
286 << _rechit->getStyle() << endl;
287 cout << " left: " << _lleft << "," << _zleft << endl;
288 cout << " right: " << _lright << "," << _zright << endl;
289}

Referenced by HoughTrack::calzs().

◆ setAmb()

void HoughStereo::setAmb ( int i)

Definition at line 18 of file HoughStereo.cxx.

18 {
19 // initial
20 _ambig = i;
21}

◆ setRecHit()

void HoughStereo::setRecHit ( )

Definition at line 277 of file HoughStereo.cxx.

277 {
278 _rechit->setzAmb( 0, _zleft );
279 _rechit->setsAmb( 0, _lleft );
280 _rechit->setzAmb( 1, _zright );
281 _rechit->setsAmb( 1, _lright );
282}

Referenced by HoughTrack::calzs().

Member Data Documentation

◆ m_debug

int HoughStereo::m_debug = 0
static

Definition at line 27 of file HoughStereo.h.

Referenced by cald(), and MdcHoughFinder::initialize().


The documentation for this class was generated from the following files: