49 for (
int iline = 0; iline < 8; iline++ )
51 linefit[iline].
_pointCol.push_back( *( _recStereoHit[0] ) );
52 linefit[iline].
_pointCol.push_back( *( _recStereoHit[1] ) );
53 linefit[iline].
_pointCol.push_back( *( _recStereoHit[2] ) );
57 for (
int i = 0; i < 3; i++ )
59 cout <<
" the first 3 hits (" << i <<
" " << _recStereoHit[i]->getLayerId() <<
","
60 << _recStereoHit[i]->getWireId() <<
")" << endl;
61 cout <<
" left " << ( _recStereoHit[i] )->getsAmb( 0 ) <<
" "
62 << ( _recStereoHit[i] )->getzAmb( 0 ) << endl;
63 cout <<
" right " << ( _recStereoHit[i] )->getsAmb( 1 ) <<
" "
64 << ( _recStereoHit[i] )->getzAmb( 1 ) << endl;
100 for (
int i = 0; i < 8; i++ )
102 linefit[i].
_ambig.push_back( linefit[i]._pointCol[0].getAmbig() );
103 linefit[i].
_ambig.push_back( linefit[i]._pointCol[1].getAmbig() );
104 linefit[i].
_ambig.push_back( linefit[i]._pointCol[2].getAmbig() );
105 if (
m_debug > 0 ) cout <<
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^begin line " << i << endl;
109 for (
int j = 3; j < _hitSize; j++ )
111 double chi_last = linefit[i].
_chi;
112 double k_last = linefit[i].
_k;
113 double b_last = linefit[i].
_b;
115 cout <<
"last " << j <<
" chi k b " << chi_last <<
" " << k_last <<
" " << b_last
117 linefit[i].
_pointCol.push_back( *( _recStereoHit[j] ) );
122 linefit[i].
_pointCol[line_size].setAmb( 0 );
124 cout <<
"Add point left "
125 <<
"(" << linefit[i].
_pointCol[line_size].getLayerId() <<
","
126 << linefit[i].
_pointCol[line_size].getWireId() <<
") "
127 << linefit[i].
_pointCol[line_size].getStyle() <<
" "
128 << linefit[i].
_pointCol[line_size].getsPos() <<
" "
129 << linefit[i].
_pointCol[line_size].getzPos() << endl;
130 leastFit( linefit[i], line_size + 1 );
131 double chil = linefit[i].
_chi;
132 double kl = linefit[i].
_k;
133 double bl = linefit[i].
_b;
134 if ( linefit[i]._pointCol[line_size].getsPos() == -99 ) { chil = 9999; }
136 cout <<
"left " << line_size <<
" chi k b " << chil <<
" " << kl <<
" " << bl << endl;
138 linefit[i].
_pointCol[line_size].setAmb( 1 );
140 cout <<
"Add point right "
141 <<
"(" << linefit[i].
_pointCol[line_size].getLayerId() <<
","
142 << linefit[i].
_pointCol[line_size].getWireId() <<
") "
143 << linefit[i].
_pointCol[line_size].getStyle() <<
" "
144 << linefit[i].
_pointCol[line_size].getsPos() <<
" "
145 << linefit[i].
_pointCol[line_size].getzPos() << endl;
146 leastFit( linefit[i], line_size + 1 );
147 double chir = linefit[i].
_chi;
148 double kr = linefit[i].
_k;
149 double br = linefit[i].
_b;
150 if ( linefit[i]._pointCol[line_size].getsPos() == -99 ) { chir = 9999; }
152 cout <<
"right " << line_size <<
" chi k b " << chir <<
" " << kr <<
" " << br << endl;
156 linefit[i].
_pointCol[line_size].setAmb( 0 );
157 linefit[i].
_chi = chil;
160 linefit[i].
_ambig.push_back( 0 );
163 else linefit[i].
_ambig.push_back( 1 );
168 for (
int ihit = 0; ihit < line_size; ihit++ )
170 int ambighit = linefit[i].
_pointCol[ihit].getAmbig();
171 int ambigTruth = linefit[i].
_pointCol[ihit].getLrTruth();
172 int layer = linefit[i].
_pointCol[ihit].getLayerId();
173 int wire = linefit[i].
_pointCol[ihit].getWireId();
182 double dChi = chi_last - linefit[i].
_chi;
183 double dChi_n = ( linefit[i].
_chi ) / ( line_size - 1 ) - ( chi_last / line_size );
184 if (
m_debug > 0 ) cout <<
"dChi: " << dChi << endl;
185 if (
m_debug > 0 ) cout <<
"dChi/n: " << dChi_n << endl;
186 if (
m_debug > 0 ) cout << endl;
188 if ( fabs( dChi_n ) > 25. )
194 linefit[i].
_chi = chi_last;
195 linefit[i].
_k = k_last;
196 linefit[i].
_b = b_last;
197 linefit[i].
_ambig.at( j ) = -999;
202 if ( ( linefit[i]._pointCol[0].getsPos() == -99 ) ||
203 ( linefit[i]._pointCol[1].getsPos() == -99 ) ||
204 ( linefit[i]._pointCol[2].getsPos() == -99 ) )
205 { linefit[i].
_chi = 99999; }
208 for (
int i = 0; i < 8; i++ )
211 cout <<
"Line :" << i <<
" chis: " << linefit[i].
_chi <<
" k,b: " << linefit[i].
_k <<
" "
212 << linefit[i].
_b << endl;
213 int ambig_correct = 0;
214 for (
int j = 0; j < _hitSize; j++ )
216 int ambig = linefit[i].
_ambig.at( j );
217 int layer = _recStereoHit.at( j )->getLayerId();
218 int wire = _recStereoHit.at( j )->getWireId();
219 int style = _recStereoHit.at( j )->getStyle();
221 if ( ambig != -999 ) l = _recStereoHit.at( j )->getsAmb( ambig );
223 if ( ambig != -999 ) z = _recStereoHit.at( j )->getzAmb( ambig );
226 if ( l == -99 && z == -99 ) ambig = -999;
228 cout <<
"(" << layer <<
" ," << wire <<
") style " << style <<
" ambig " << ambig
229 <<
" s " << l <<
" z " << z << endl;
232 _recStereoHit[j]->setAmb( ambig );
233 if ( ambig == -999 ) _recStereoHit[j]->setflag( -999 );
234 int ambigTruth = _recStereoHit.at( j )->getLrTruth();
235 if ( ambigTruth == -1 ) ambigTruth = 1;
236 else if ( ambigTruth == 1 ) ambigTruth = 0;
237 if ( ambig == ambigTruth ) ambig_correct++;
239 _pro_correct = (double)ambig_correct / (
double)_hitSize;
243 _tanl = linefit[0].
_k;
245 if (
m_debug > 0 ) cout <<
"z0 tanl : " << _z0 <<
" " << _tanl << endl;
379 for (
int i = 0; i < nhit; i++ )
381 x_sum = x_sum + x[i];
382 y_sum = y_sum + y[i];
383 x2_sum = x2_sum + x[i] * x[i];
384 y2_sum = y2_sum + y[i] * y[i];
385 xy_sum = xy_sum + x[i] * y[i];
387 b = ( x2_sum * y_sum - xy_sum * x_sum ) / ( nhit * x2_sum - x_sum * x_sum );
388 k = ( nhit * xy_sum - x_sum * y_sum ) / ( nhit * x2_sum - x_sum * x_sum );
390 double yE[
const_cast<int&
>( nhit )];
391 for (
int i = 0; i < nhit; i++ )
393 yE[i] = k * x[i] + b;
396 if ( yE[i] != 0 ) chi2_temp = ( y[i] - yE[i] ) * ( y[i] - yE[i] ) / yE[i] * yE[i];