186 float& sigmaIntercept,
float& chisq,
int& ndof ) {
188 if ( m_pHits.size() > 100 )
190 cout <<
"MucRec2DRoad: too many hits in this track!" << endl;
199 vector<MucRecHit*>::const_iterator iHit;
207 for (
int i = 0; i < m_pHits.size(); i++ )
211 for (
int j = 0; j < m_pHits.size(); j++ )
214 if ( j == i )
continue;
215 if ( m_pHits[i]->Part() == m_pHits[j]->Part() &&
216 m_pHits[i]->Seg() == m_pHits[j]->Seg() && m_pHits[i]->Gap() == m_pHits[j]->Gap() )
218 int deltaStrip = fabs( m_pHits[i]->Strip() - m_pHits[j]->Strip() );
222 if ( deltaStrip == 0 ) { cout <<
"deltaStrip == 0 ? check it" << endl; }
223 else {
weight[i] *= ( deltaStrip + 1 ) * ( deltaStrip + 1 ); }
228 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++ )
249 Hep3Vector center = ( *iHit )->GetCenterPos();
250 Hep3Vector sigma = ( *iHit )->GetCenterSigma();
257 px[npoints] = center.z();
258 py[npoints] = sqrt( center.x() * center.x() + center.y() * center.y() );
260 py[npoints] = center.y();
263 pw[npoints] = 4.0 * 1.0 / ( sigma.y() * sigma.y() ) /
weight[npoints];
267 px[npoints] = center.x();
268 py[npoints] = center.y();
269 pw[npoints] = 4.0 * 1.0 / ( sigma.x() * sigma.x() ) /
weight[npoints];
276 px[npoints] = center.z();
277 py[npoints] = center.y();
278 pw[npoints] = 4.0 * 1.0 / ( sigma.y() * sigma.y() ) /
weight[npoints];
282 px[npoints] = center.z();
283 py[npoints] = center.x();
284 pw[npoints] = 4.0 * 1.0 / ( sigma.x() * sigma.x() ) /
weight[npoints];
295 cout <<
"MucRec2DRoad: to many hits in this track, ignore it!" << endl;
329 if ( ndof < 0 )
return -1;
337 px[npoints] = m_VertexPos.z();
339 sqrt( m_VertexPos.x() * m_VertexPos.x() + m_VertexPos.y() * m_VertexPos.y() );
340 if ( m_Seg == 2 ) py[npoints] = m_VertexPos.y();
344 px[npoints] = m_VertexPos.x();
345 py[npoints] = m_VertexPos.y();
352 px[npoints] = m_VertexPos.z();
353 py[npoints] = m_VertexPos.y();
357 px[npoints] = m_VertexPos.z();
358 py[npoints] = m_VertexPos.x();
366 if ( npoints == 0 ) {
return -1; }
371 int status = fit.
LineFit( px, py, pw, npoints, &slope, &intercept, &chisq, &sigmaSlope,
374 float tempslope, tempintercept, tempchisq, tempsigmaslope, sigmaPos;
375 int status4 = fit.
LineFit( px, py, pw, m_Part, m_Seg, m_Orient, npoints, &tempslope,
376 &tempintercept, &tempchisq, &tempsigmaslope, &sigmaPos );
379 float quad_a, quad_b, quad_c, sigmaquad_a, sigmaquad_b, sigmaquad_c, chisq_quad;
380 int whichhalf, status2 = 0;
382 if ( m_fittingMethod == 2 )
384 status2 = quadfit.
QuadFit( px, py, pw, npoints, &quad_a, &quad_b, &quad_c, &whichhalf,
385 &chisq_quad, &sigmaquad_a, &sigmaquad_b, &sigmaquad_c );
389 if ( slope > 1.0e10 || slope < -1.0e10 )
391 if ( m_Seg > 4 ) slope *= -1.0;
394 m_SimpleSlope = slope;
395 m_SimpleSlopeSigma = sigmaSlope;
396 m_SimpleIntercept = intercept;
397 m_SimpleInterceptSigma = sigmaIntercept;
398 m_SimplePosSigma = sigmaPos;
399 m_SimpleChi2 = chisq;
401 m_SimpleFitOK = ( status == 0 ) && ( chisq < 1000.0 );
402 m_QuadFitOK = ( status2 == 1 );
404 m_SimpleQuad_a = quad_a;
405 m_SimpleQuad_b = quad_b;
406 m_SimpleQuad_c = quad_c;
407 m_SimpleQuad_whichhalf = whichhalf;
408 m_SimpleQuad_aSigma = sigmaquad_a;
409 m_SimpleQuad_bSigma = sigmaquad_b;
410 m_SimpleQuad_cSigma = sigmaquad_c;
418 float& sigmaSlope,
float& sigmaIntercept,
419 float& chisq,
int& ndof ) {
428 vector<MucRecHit*>::const_iterator iHit;
431 for (
int i = 0; i < 100; i++ )
437 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++ )
441 if ( ( *iHit )->Gap() == currentgap )
continue;
443 Hep3Vector center = ( *iHit )->GetCenterPos();
444 Hep3Vector sigma = ( *iHit )->GetCenterSigma();
451 px[npoints] = center.z();
452 py[npoints] = sqrt( center.x() * center.x() + center.y() * center.y() );
454 py[npoints] = center.y();
457 pw[npoints] = 1.0 / ( sigma.y() * sigma.y() ) / pw2[npoints] / pw2[npoints];
461 px[npoints] = center.x();
462 py[npoints] = center.y();
463 pw[npoints] = 1.0 / ( sigma.x() * sigma.x() ) / pw2[npoints] / pw2[npoints];
470 px[npoints] = center.z();
471 py[npoints] = center.y();
472 pw[npoints] = 1.0 / ( sigma.y() * sigma.y() ) / pw2[npoints] / pw2[npoints];
476 px[npoints] = center.z();
477 py[npoints] = center.x();
478 pw[npoints] = 1.0 / ( sigma.x() * sigma.x() ) / pw2[npoints] / pw2[npoints];
491 cout <<
"MucRec2DRoad: to many hits in this track, ignore it!" << endl;
498 if ( ndof < 0 )
return -1;
506 px[npoints] = m_VertexPos.z();
508 sqrt( m_VertexPos.x() * m_VertexPos.x() + m_VertexPos.y() * m_VertexPos.y() );
509 if ( m_Seg == 2 ) py[npoints] = m_VertexPos.y();
513 px[npoints] = m_VertexPos.x();
514 py[npoints] = m_VertexPos.y();
521 px[npoints] = m_VertexPos.z();
522 py[npoints] = m_VertexPos.y();
526 px[npoints] = m_VertexPos.z();
527 py[npoints] = m_VertexPos.x();
535 if ( npoints == 0 ) {
return -1; }
540 int status = fit.
LineFit( px, py, pw, npoints, &slope, &intercept, &chisq, &sigmaSlope,
544 float quad_a, quad_b, quad_c, sigmaquad_a, sigmaquad_b, sigmaquad_c, chisq_quad;
545 int whichhalf, status2 = 0;
547 if ( m_fittingMethod == 2 )
549 status2 = quadfit.
QuadFit( px, py, pw, npoints, &quad_a, &quad_b, &quad_c, &whichhalf,
550 &chisq_quad, &sigmaquad_a, &sigmaquad_b, &sigmaquad_c );
554 if ( slope > 1.0e10 || slope < -1.0e10 )
556 if ( m_Seg > 4 ) slope *= -1.0;
560 m_SimpleSlope = slope;
561 m_SimpleSlopeSigma = sigmaSlope;
562 m_SimpleIntercept = intercept;
563 m_SimpleInterceptSigma = sigmaIntercept;
565 m_SimpleChi2 = chisq;
567 m_SimpleFitOK = ( status == 0 ) && ( chisq < 1000.0 );
568 m_QuadFitOK = ( status2 == 1 );
570 m_SimpleQuad_a = quad_a;
571 m_SimpleQuad_b = quad_b;
572 m_SimpleQuad_c = quad_c;
573 m_SimpleQuad_whichhalf = whichhalf;
574 m_SimpleQuad_aSigma = sigmaquad_a;
575 m_SimpleQuad_bSigma = sigmaquad_b;
576 m_SimpleQuad_cSigma = sigmaquad_c;
586 float& intercept,
float& sigmaSlope,
float& sigmaIntercept,
587 float& chisq,
int& ndof ) {
591 if ( !m_SimpleFitOK )
594 float a, sa, b, sb, chi;
626 vector<MucRecHit*>::const_iterator iHit;
634 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++ )
639 Hep3Vector center = ( *iHit )->GetCenterPos();
640 Hep3Vector sigma = ( *iHit )->GetCenterSigma();
646 px[npoints] = center.z();
647 dx = px[npoints] - z;
648 py[npoints] = sqrt( center.x() * center.x() + center.y() * center.y() );
650 py[npoints] = center.y();
652 dy = py[npoints] - sqrt( x * x + y * y );
656 px[npoints] = center.x();
657 dx = px[npoints] - x;
658 py[npoints] = center.y();
659 dy = py[npoints] - y;
666 px[npoints] = center.z();
667 dx = px[npoints] - z;
668 py[npoints] = center.y();
669 dy = py[npoints] - y;
673 px[npoints] = center.z();
674 dx = px[npoints] - z;
675 py[npoints] = center.x();
676 dy = py[npoints] - x;
680 dr = sqrt( dx * dx + dy * dy );
693 cout <<
"MucRec2DRoad: to many hits in this track, ignore it!" << endl;
707 px[npoints] = m_VertexPos.z();
709 sqrt( m_VertexPos.x() * m_VertexPos.x() + m_VertexPos.y() * m_VertexPos.y() );
710 if ( m_Seg == 2 ) py[npoints] = m_VertexPos.y();
714 px[npoints] = m_VertexPos.x();
715 py[npoints] = m_VertexPos.y();
722 px[npoints] = m_VertexPos.z();
723 py[npoints] = m_VertexPos.y();
727 px[npoints] = m_VertexPos.z();
728 py[npoints] = m_VertexPos.x();
736 if ( npoints == 0 ) {
return -1; }
741 status = fit.
LineFit( px, py, pw, npoints, &slope, &intercept, &chisq, &sigmaSlope,
757 float sigmaX, sigmaY, sigmaZ;
771 cout <<
"MucRec2DRoad::Project-E1 invalid gap = " << gap << endl;
776 float x0, y0, z0, sigmaX0, sigmaY0, sigmaZ0;
777 float phi = m_Seg * 0.25 *
kPi;
785 m_SimpleSlope *
sin( phi ), 1.0, m_SimpleIntercept *
cos( phi ),
786 m_SimpleIntercept *
sin( phi ), 0.0, m_SimpleSlopeSigma, 0.0,
787 0.0, m_SimpleInterceptSigma, 0.0, 0.0, x0, y0, z0, sigmaX0,
790 if ( m_SimpleSlope > 10000 )
794 m_SimpleSlope *
sin( phi ), 1.0, 0.0, 0.0, m_SimpleIntercept,
795 m_SimpleSlopeSigma, 0.0, 0.0, m_SimpleInterceptSigma, 0.0, 0.0,
796 x0, y0, z0, sigmaX0, sigmaY0, sigmaZ0 );
802 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
803 m_SimpleInterceptSigma, 0.0, x0, y0, z0, sigmaX0, sigmaY0,
812 geom->
FindIntersection( m_Part, m_Seg, gap, m_SimpleSlope, m_SimpleSlope, 1.0, 0.0,
813 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
814 m_SimpleInterceptSigma, 0.0, x0, y0, z0, sigmaX0, sigmaY0,
819 geom->
FindIntersection( m_Part, m_Seg, gap, m_SimpleSlope, m_SimpleSlope, 1.0,
820 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
821 m_SimpleInterceptSigma, 0.0, 0.0, x0, y0, z0, sigmaX0, sigmaY0,
834 float a, b, sa, sb, chi2;
837 int status =
Fit( x0, y0, z0, a, b, sa, sb, chi2, ndof );
856 b *
cos( phi ), b *
sin( phi ), 0.0, sa, 0.0, 0.0, sb, 0.0, 0.0,
857 x, y, z, sigmaX, sigmaY, sigmaZ );
859 if ( fabs( a ) > 10000 )
865 sa, 0.0, 0.0, sb, 0.0, 0.0, x, y, z, sigmaX, sigmaY, sigmaZ );
870 geom->
FindIntersection( m_Part, m_Seg, gap, 1.0, a, 0.0, 0.0, b, 0.0, 0.0, sa, 0.0, 0.0,
871 sb, 0.0, x, y, z, sigmaX, sigmaY, sigmaZ );
873 if ( m_fittingMethod == 2 && m_QuadFitOK )
876 float sa, sb, sc, chi2x;
884 whichhalf, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, x, y, z, x2, y2, z2,
885 sigmaX, sigmaY, sigmaZ );
893 geom->
FindIntersection( m_Part, m_Seg, gap, a, a, 1.0, 0.0, b, 0.0, 0.0, sa, 0.0, 0.0,
894 sb, 0.0, x, y, z, sigmaX, sigmaY, sigmaZ );
898 geom->
FindIntersection( m_Part, m_Seg, gap, a, a, 1.0, b, 0.0, 0.0, sa, 0.0, 0.0, sb,
899 0.0, 0.0, x, y, z, sigmaX, sigmaY, sigmaZ );
1210 cout <<
"MucRec2DRoad::GetSearchWindowSize-E1 invalid gap = " << gap << endl;
1221 float x1, y1, z1, x2, y2, z2, dx, dy, dr;
1222 float sigmaX, sigmaY, sigmaZ;
1226 if ( m_Orient == 0 )
1228 geom->
FindIntersection( m_Part, 0, m_LastGap, 1.0, m_SimpleSlope, 0.0, 0.0,
1229 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
1230 m_SimpleInterceptSigma, 0.0, x1, y1, z1, sigmaX, sigmaY,
1232 geom->
FindIntersection( m_Part, 0, gap, 1.0, m_SimpleSlope, 0.0, 0.0, m_SimpleIntercept,
1233 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0, m_SimpleInterceptSigma,
1234 0.0, x2, y2, z2, sigmaX, sigmaY, sigmaZ );
1236 dy = sqrt( x2 * x2 + y2 * y2 ) - sqrt( x1 * x1 + y1 * y1 );
1241 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
1242 m_SimpleInterceptSigma, 0.0, 0.0, x1, y1, z1, sigmaX, sigmaY,
1244 geom->
FindIntersection( m_Part, m_Seg, gap, m_SimpleSlope, 0.0, 1.0, m_SimpleIntercept,
1245 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0, m_SimpleInterceptSigma,
1246 0.0, 0.0, x2, y2, z2, sigmaX, sigmaY, sigmaZ );
1253 if ( m_Orient == 0 )
1255 geom->
FindIntersection( m_Part, m_Seg, m_LastGap, 0.0, m_SimpleSlope, 1.0, 0.0,
1256 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
1257 m_SimpleInterceptSigma, 0.0, x1, y1, z1, sigmaX, sigmaY,
1260 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
1261 m_SimpleInterceptSigma, 0.0, x2, y2, z2, sigmaX, sigmaY,
1269 m_SimpleIntercept, 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0,
1270 m_SimpleInterceptSigma, 0.0, 0.0, x1, y1, z1, sigmaX, sigmaY,
1272 geom->
FindIntersection( m_Part, m_Seg, gap, m_SimpleSlope, 0.0, 1.0, m_SimpleIntercept,
1273 0.0, 0.0, m_SimpleSlopeSigma, 0.0, 0.0, m_SimpleInterceptSigma,
1274 0.0, 0.0, x2, y2, z2, sigmaX, sigmaY, sigmaZ );
1280 dr = sqrt( dx * dx + dy * dy );