27 _circleR = other._circleR;
28 _circleX = other._circleX;
29 _circleY = other._circleY;
32 _omega = other._omega;
33 _charge = other._charge;
36 _chi2_aver2D = other._chi2_aver2D;
37 _bunchT0 = other._bunchT0;
40 _recHitVec = other._recHitVec;
86 int hitCandiSize = _recHitVec.size();
87 if ( hitCandiSize >= 3 )
89 for (
int i = 0; i < hitCandiSize; i++ )
94 x_sum = x_sum + ( _recHitVec[i].getMidX() );
95 y_sum = y_sum + ( _recHitVec[i].getMidY() );
96 x2_sum = x2_sum + ( _recHitVec[i].getMidX() ) * ( _recHitVec[i].getMidX() );
97 y2_sum = y2_sum + ( _recHitVec[i].getMidY() ) * ( _recHitVec[i].getMidY() );
98 x3_sum = x3_sum + ( _recHitVec[i].getMidX() ) * ( _recHitVec[i].getMidX() ) *
99 ( _recHitVec[i].getMidX() );
100 y3_sum = y3_sum + ( _recHitVec[i].getMidY() ) * ( _recHitVec[i].getMidY() ) *
101 ( _recHitVec[i].getMidY() );
102 x2y_sum = x2y_sum + ( _recHitVec[i].getMidX() ) * ( _recHitVec[i].getMidX() ) *
103 ( _recHitVec[i].getMidY() );
104 xy2_sum = xy2_sum + ( _recHitVec[i].getMidX() ) * ( _recHitVec[i].getMidY() ) *
105 ( _recHitVec[i].getMidY() );
106 xy_sum = xy_sum + ( _recHitVec[i].getMidX() ) * ( _recHitVec[i].getMidY() );
109 a1 = x2_sum - x_sum * x_sum / hitCandiSize;
110 a2 = xy_sum - x_sum * y_sum / hitCandiSize;
112 b2 = y2_sum - y_sum * y_sum / hitCandiSize;
113 c1 = ( x3_sum + xy2_sum - x_sum * ( x2_sum + y2_sum ) / hitCandiSize ) / 2.;
114 c2 = ( y3_sum + x2y_sum - y_sum * ( x2_sum + y2_sum ) / hitCandiSize ) / 2.;
120 _circleX = ( b1 * c2 - b2 * c1 ) / ( b1 * b1 - a1 * b2 );
121 _circleY = ( b1 * c1 - a1 * c2 ) / ( b1 * b1 - a1 * b2 );
122 _circleR = sqrt( ( x2_sum + y2_sum - 2 * _circleX * x_sum - 2 * _circleY * y_sum ) /
124 _circleX * _circleX + _circleY * _circleY );
128 _d0 = sqrt( _circleX * _circleX + _circleY * _circleY ) - _circleR;
129 _phi0 = atan2( _circleY, _circleX ) +
M_PI / 2.;
130 _omega = 1 / _circleR;
131 double pt_temp = _circleR / 333.567;
132 if (
m_debug > 0 ) cout <<
" pt: " << pt_temp << endl;
133 if (
m_debug > 0 ) cout <<
"par: (" << _d0 <<
"," << _phi0 <<
"," << _omega <<
")" << endl;
136 _circleX_least = ( b1 * c2 - b2 * c1 ) / ( b1 * b1 - a1 * b2 );
137 _circleY_least = ( b1 * c1 - a1 * c2 ) / ( b1 * b1 - a1 * b2 );
138 _circleR_least = sqrt( ( x2_sum + y2_sum - 2 * _circleX * x_sum - 2 * _circleY * y_sum ) /
140 _circleX * _circleX + _circleY * _circleY );
160 cout <<
"q d0 phi0 omega: " << _charge <<
" " << _d0 <<
" " << _phi0 <<
" " << _omega
165 bool permitFlips =
true;
166 bool lPickHits =
true;
167 circlefactory.
setFlipAndDrop( *newTrack, permitFlips, lPickHits );
171 vector<MdcHit*> t_hitCol;
172 std::vector<HoughRecHit>::iterator
iter = _recHitVec.begin();
173 for ( ;
iter != _recHitVec.end();
iter++, digiId++ )
175 if ( ( *iter ).getflag() != 0 )
continue;
178 const MdcDigi* aDigi = ( *iter ).digi();
184 t_hitCol.push_back( hit );
197 newhot->
setFltLen( ( *iter ).getRet().second );
198 double distoTrack = ( *iter ).getDisToTrack();
203 if ( hit->
driftTime( _bunchT0, 0 ) > 1000 ) use_in2d = 0;
204 if ( hit->
driftDist( _bunchT0, 0 ) > ddCut ) use_in2d = 0;
207 std::cout <<
" (" << layer <<
"," << wire <<
",rt " << hit->
rawTime() <<
",dt "
211 <<
"dist: " << hit->
driftDist( _bunchT0, 0 ) <<
" disToTrk " << distoTrack
212 <<
" use?: " << use_in2d << endl;
213 if ( use_in2d == 0 )
continue;
220 const TrkFit* newFit = newTrack->fitResult();
221 int nActiveHit = newTrack->hots()->
nActive();
222 int fit_stat =
false;
228 cout <<
" global 2d fit failed ";
229 if ( newFit ) cout <<
" nAct " << newFit->
nActive();
230 cout <<
"ERR1 failure =" << err.
failure() << endl;
237 if (
abs( 1 / ( par.
omega() ) ) > 0.03 )
240 chi2 = newFit->
chisq();
241 if (
m_debug > 0 ) cout <<
"chi2 " << chi2 << endl;
249 bool badQuality =
false;
254 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by chi2 " << chi2 <<
" > "
263 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by d0 " << par.
d0() <<
" > "
272 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by chi2/ndf"
282 std::cout << __FILE__ <<
" " << __LINE__ <<
" drop track by nhit" << nActiveHit
287 if ( badQuality ) fit_stat = 0;
293 cout <<
" global 2d fit success" << endl;
294 cout << __FILE__ << __LINE__ <<
"AFTER fit 2d " << endl;
295 newTrack->print( std::cout );
298 double d0 = par.
d0();
299 double phi0 = par.
phi0();
300 double omega = par.
omega();
301 double r_temp = -1. / par.
omega();
302 double x_cirtemp =
sin( par.
phi0() ) * ( par.
d0() + 1 / par.
omega() ) *
304 double y_cirtemp = -1. *
cos( par.
phi0() ) * ( par.
d0() + 1 / par.
omega() ) * -1;
307 cout <<
" circle after globle 2d: "
308 <<
"(" << x_cirtemp <<
"," << y_cirtemp <<
"," << r_temp <<
")" << endl;
309 cout <<
"pt_rec: " << 1. / omega / 333.567 << endl;
311 _pt = 1. / omega / 333.567;
312 _circleX = x_cirtemp;
313 _circleY = y_cirtemp;
314 _circleR = _charge / omega;
317 _omega = par.
omega();
320 if (
m_debug > 1 ) cout <<
" hot list:" << endl;
322 int lay = ( (
MdcHit*)( hotIter->
hit() ) )->layernumber();
323 int wir = ( (
MdcHit*)( hotIter->
hit() ) )->wirenumber();
324 int hittemp = lay * 1000 + wir;
329 cout <<
"(" << ( (
MdcHit*)( hotIter->
hit() ) )->layernumber() <<
","
333 if ( hotIter->
isActive() == 1 ) nfit2d++;
338 _chi2_aver2D = chi2 / _nfit;
340 for (
int i = 0; i < t_hitCol.size(); i++ ) {
delete t_hitCol[i]; }
343 if (
m_debug > 0 ) cout <<
" in 2D fit number of Active hits : " << _nfit << endl;