39 void FtfTrack::add (
FtfHit *thisHit,
int way )
48 if ( way < 0 || nHits == 1 ) {
49 if ( nHits > 1 ) ((
FtfBaseHit *)lastHit)->nextTrackHit = thisHit ;
56 ((
FtfBaseHit *)thisHit)->nextTrackHit = firstHit ;
63 thisHit->setStatus (
this ) ;
67 if ( nHits < getPara()->minHitsForFit ) return ;
72 s11Xy = s11Xy + thisHit->wxy ;
73 s12Xy = s12Xy + thisHit->wxy * thisHit->xp ;
74 s22Xy = s22Xy + thisHit->wxy * square(thisHit->xp) ;
75 g1Xy = g1Xy + thisHit->wxy * thisHit->yp ;
76 g2Xy = g2Xy + thisHit->wxy * thisHit->xp * thisHit->yp ;
79 if ( nHits > getPara()->minHitsForFit )
81 ddXy = s11Xy * s22Xy - square ( s12Xy ) ;
83 a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
84 a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
87 if ( getPara()->infoLevel > 0 ) {
88 LOG(ERR,
"FtfTrack:add: ddXy = 0 \n" ) ;
95 if ( getPara()->szFitFlag ) {
96 s11Sz = s11Sz + thisHit->wz ;
97 s12Sz = s12Sz + thisHit->wz * thisHit->s ;
98 s22Sz = s22Sz + thisHit->wz * thisHit->s * thisHit->s ;
99 g1Sz = g1Sz + thisHit->wz * thisHit->z ;
100 g2Sz = g2Sz + thisHit->wz * thisHit->s * thisHit->z ;
102 if ( nHits > getPara()->minHitsForFit ) {
104 ddSz = s11Sz * s22Sz - s12Sz * s12Sz ;
106 a1Sz = ( g1Sz * s22Sz - g2Sz * s12Sz ) / ddSz ;
107 a2Sz = ( g2Sz * s11Sz - g1Sz * s12Sz ) / ddSz ;
111 if ( getPara()->infoLevel > 0 ) {
112 LOG(ERR,
"FtfTrack:add: ddSz = 0 \n" ) ;
121 void FtfTrack::add (
FtfTrack *piece )
126 s11Xy += piece->s11Xy ;
127 s12Xy += piece->s12Xy ;
128 s22Xy += piece->s22Xy ;
129 g1Xy += piece->g1Xy ;
130 g2Xy += piece->g2Xy ;
132 ddXy = s11Xy * s22Xy - square ( s12Xy ) ;
133 a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
134 a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
138 if ( getPara()->szFitFlag ) {
139 double det1 = s11Sz * s22Sz - s12Sz * s12Sz ;
140 dtanl = (double) ( s11Sz / det1 );
141 dz0 = (double) ( s22Sz / det1 );
143 double det2 = piece->s11Sz * piece->s22Sz - piece->s12Sz * piece->s12Sz ;
144 piece->dtanl = (double) ( piece->s11Sz / det2 );
145 piece->dz0 = (double) ( piece->s22Sz / det2 );
147 double weight1 = 1./(dtanl*dtanl);
148 double weight2 = 1./(piece->dtanl*piece->dtanl);
149 double weight = (weight1+weight2);
150 tanl = ( weight1 * tanl + weight2 * piece->tanl ) / weight ;
152 weight1 = 1./(dz0*dz0);
153 weight2 = 1./(piece->dz0*piece->dz0);
154 weight = (weight1+weight2);
155 z0 = ( weight1 * z0 + weight2 * piece->z0 ) / weight ;
162 if ( piece->outerMostRow < outerMostRow ){
163 if ( lastHit != NULL ) {
165 for ( currentHit = piece->firstHit ;
166 currentHit != 0 && counter < piece->nHits ;
167 currentHit = ((
FtfBaseHit *)currentHit)->nextTrackHit ) {
171 ((
FtfBaseHit *)lastHit)->nextTrackHit = piece->firstHit ;
172 lastHit = piece->lastHit ;
174 piece->firstHit = 0 ;
175 innerMostRow = piece->innerMostRow ;
176 xLastHit = piece->xLastHit ;
177 yLastHit = piece->yLastHit ;
180 if ( piece->lastHit != NULL ) {
182 for ( currentHit = (
FtfHit *)piece->firstHit ;
183 currentHit != 0 && counter < piece->nHits ;
184 currentHit = ((
FtfBaseHit *)currentHit)->nextTrackHit ) {
188 ((
FtfBaseHit *)piece->lastHit)->nextTrackHit = firstHit ;
189 firstHit = piece->firstHit ;
191 outerMostRow = piece->outerMostRow ;
192 piece->firstHit = 0 ;
196 nHits += piece->nHits ;
197 chi2[0] += piece->chi2[0] ;
198 chi2[1] += piece->chi2[1] ;
203 getPara()->szFitFlag = 0 ;
204 if ( getPara()->fillTracks ) fill ( ) ;
205 getPara()->szFitFlag = 1 ;
220 add ( frstHit, GO_DOWN ) ;
224 if ( !segment ( volume, GO_DOWN ) )
return 0 ;
228 int rowToStop = getPara()->rowInnerMost ;
229 if ( !follow ( volume, GO_DOWN, rowToStop ) )
return 0 ;
233 if ( getPara()->goBackwards ) {
234 follow ( volume, GO_UP, getPara()->rowOuterMost ) ;
239 if ( getPara()->fillTracks )
250 void FtfTrack::dEdx ( ){
253 int nTruncate = max(1,
254 getPara()->dEdxNTruncate*nHits/100) ;
255 nTruncate = min(nHits/2,nTruncate) ;
259 double *de =
new double[nTruncate] ;
264 memset ( de, 0, nTruncate*
sizeof(
double) ) ;
268 for ( nextHit = (
FtfHit *)firstHit ;
270 nextHit = (
FtfHit *)nextHit->nextTrackHit) {
274 if ( nextHit->q < de[0] ) continue ;
276 for ( i = nTruncate-1 ; i>=0 ; i-- ){
277 if ( nextHit->q > de[i] ){
278 for ( j=0 ; j<i ; j++ ) de[j] = de[j+1] ;
287 for ( i=0 ; i<nTruncate ; i++ ) dedx -= de[i] ;
288 dedx = dedx / length ;
295 void FtfTrack::deleteCandidate(
void)
300 debugDeleteCandidate ( ) ;
302 while ( curentHit != 0 )
304 nextHit = (
FtfHit *)curentHit->nextTrackHit;
305 curentHit->nextTrackHit = 0 ;
310 curentHit->setStatus ( 0 ) ;
317 void FtfTrack::fill ( ) {
323 double rc = sqrt ( a2Xy * a2Xy + 1 ) / ( 2 * fabs(a1Xy) ) ;
324 pt = (double)fabs(bFactor * getPara()->bField * rc );
325 double xParameters = 0.;
326 double yParameters = 0.;
328 if ( pt > getPara()->ptMinHelixFit ) {
329 double combinedChi2 = 0.5*(chi2[0]+chi2[1])/nHits ;
330 if ( getPara()->primaries && combinedChi2 < getPara()->maxChi2Primary )
331 getPara()->vertexConstrainedFit = 1 ;
333 getPara()->vertexConstrainedFit = 0 ;
338 if ( getPara()->vertexConstrainedFit && getPara()->parameterLocation ){
339 updateToRadius ( sqrt(xLastHit*xLastHit+yLastHit*yLastHit) ) ;
341 else if ( !getPara()->vertexConstrainedFit && !getPara()->parameterLocation ) {
342 updateToClosestApproach ( getPara()->xVertex, getPara()->yVertex, 2000. ) ;
349 if ( getPara()->primaries ){
351 fillPrimary ( xc, yc, rc, getPara()->xVertex, getPara()->yVertex ) ;
352 if ( getPara()->parameterLocation ) {
353 updateToRadius ( sqrt(xLastHit*xLastHit+yLastHit*yLastHit) ) ;
357 xc = - a2Xy / ( 2. * a1Xy ) + xRefHit ;
358 yc = - 1. / ( 2. * a1Xy ) + yRefHit ;
359 if ( getPara()->parameterLocation ) {
360 xParameters = xLastHit ;
361 yParameters = yLastHit ;
364 getClosest ( getPara()->xVertex, getPara()->yVertex,
365 rc, xc, yc, xParameters, yParameters ) ;
367 fillSecondary ( xc, yc, xParameters, yParameters ) ;
372 if ( getPara()->getErrors ) {
373 getErrorsCircleFit ( (
double)xc, (
double)yc, (
double)rc ) ;
374 double det = s11Sz * s22Sz - s12Sz * s12Sz ;
375 dtanl = (double) ( s11Sz / det );
376 dz0 = (double) ( s22Sz / det );
383 void FtfTrack::fillPrimary (
double &xc,
double &yc,
double &rc,
384 double xPar,
double yPar ) {
388 xc = getPara()->xVertex - a2Xy / ( 2. * a1Xy ) ;
389 yc = getPara()->yVertex - 1. / ( 2. * a1Xy ) ;
393 double angle_vertex = atan2 ( yPar-yc, xPar-xc ) ;
394 if ( angle_vertex < 0. ) angle_vertex = angle_vertex + twoPi ;
396 double dx_last = xLastHit - xc ;
397 double dy_last = yLastHit - yc ;
398 double angle_last = atan2 ( dy_last, dx_last ) ;
399 if ( angle_last < 0. ) angle_last = angle_last + twoPi ;
403 double d_angle = angle_last - angle_vertex ;
406 if ( d_angle < -pi ) d_angle += twoPi ;
408 q = getPara()->bFieldPolarity * ( ( d_angle < 0 ) ? 1 : -1 ) ;
409 r0 = sqrt(xPar*xPar+yPar*yPar) ;
410 phi0 = atan2(yPar,xPar) ;
411 if ( phi0 < 0 ) phi0 += 2. * M_PI ;
412 psi = (double)(angle_vertex - getPara()->bFieldPolarity*q * 0.5F * pi) ;
413 if ( psi < 0 ) psi = (double)(psi + twoPi );
414 if ( psi > twoPi ) psi = (double)(psi - twoPi );
418 if ( getPara()->szFitFlag == 1 ){
419 tanl = -(double)a2Sz ;
420 z0 = (double)(a1Sz + a2Sz * ( length - rc * d_angle * getPara()->bFieldPolarity*q ) );
422 else if ( getPara()->szFitFlag == 2 ) {
431 eta = seta(1.,tanl ) ;
443 void FtfTrack::fillSecondary (
double &xc,
double &yc,
444 double xPar,
double yPar )
449 double dx1 = ((
FtfBaseHit *)firstHit)->x - xc ;
450 double dy1 = ((
FtfBaseHit *)firstHit)->y - yc ;
451 double angle1 = atan2 ( dy1, dx1 ) ;
452 if ( angle1 < 0. ) angle1 = angle1 + twoPi ;
454 double dx2 = xLastHit - xc ;
455 double dy2 = yLastHit - yc ;
456 double angle2 = atan2 ( dy2, dx2 ) ;
457 if ( angle2 < 0. ) angle2 = angle2 + twoPi ;
461 double dangle = angle2 - angle1 ;
463 if ( dangle < -pi ) dangle = dangle + twoPi ;
465 q = getPara()->bFieldPolarity * ( ( dangle > 0 ) ? 1 : -1 ) ;
466 r0 = ((
FtfHit *)lastHit)->r ;
467 phi0 = ((
FtfHit *)lastHit)->phi ;
468 psi = (double)(angle2 - getPara()->bFieldPolarity * q * piHalf );
469 if ( psi < 0 ) psi = (double)(psi + twoPi );
473 if ( getPara()->szFitFlag ){
474 tanl = -(double)a2Sz ;
475 z0 = (double)(a1Sz + a2Sz * length );
486 eta = seta(1., tanl ) ;
499 int FtfTrack::follow (
FtfContainer *volume,
int way,
int ir_stop ) {
504 nextHit = (
FtfHit *)lastHit ;
506 nextHit = (
FtfHit *)firstHit ;
508 if ( getPara()->trackDebug && getPara()->debugLevel >= 2 )
509 LOG(ERR,
"FtfTrack::follow: ===> Going into Track extension <===\n" );
514 double xyChi2 = chi2[0] ;
515 double szChi2 = chi2[1] ;
521 while ( way * nextHit->row < way * ir_stop ) {
525 chi2[0] = getPara()->hitChi2Cut ;
527 nextHit = seekNextHit ( volume, nextHit, way*getPara()->trackRowSearchRange, USE_FOLLOW ) ;
530 if ( getPara()->trackDebug && getPara()->debugLevel >= 1 ){
532 LOG(ERR,
"FtfTrack::follow: Search succesful, hit selected %d\n",
537 LOG(ERR,
"FtfTrack::follow: Search unsuccesful\n" );
538 if ( chi2[0]+chi2[1] > getPara()->hitChi2Cut )
539 LOG(ERR,
" hit chi2 %f larger than cut %f ", chi2[0]+chi2[1],
540 getPara()->hitChi2Cut ) ;
548 if ( nextHit == 0 ) break ;
552 double lxyChi2 = chi2[0]-chi2[1] ;
554 nextHit->xyChi2 = lxyChi2 ;
558 if ( getPara()->szFitFlag ) {
559 length = nextHit->s ;
561 nextHit->szChi2 = chi2[1] ;
567 add ( nextHit, way ) ;
573 if ( nHits < getPara()->minHitsPerTrack )
return 0 ;
582 double normalized_chi2 = (chi2[0]+chi2[1])/nHits ;
583 if ( normalized_chi2 > getPara()->trackChi2Cut )
return 0 ;
590 int FtfTrack::followHitSelection (
FtfHit *baseHit,
FtfHit *candidateHit,
int way ){
594 double slocal=0, deta, dphi ;
595 double dx, dy, dxy, dsz, temp ;
600 deta = fabs((baseHit->eta)-(candidateHit->eta)) ;
601 if ( deta > getPara()->deta )
return 0 ;
607 dphi = fabs((baseHit->phi)-(candidateHit->phi)) ;
608 if ( dphi > getPara()->dphi && dphi < twoPi-getPara()->dphi )
return 0 ;
612 if ( getPara()->primaries == 0 ){
613 double xx = candidateHit->x - xRefHit ;
614 double yy = candidateHit->y - yRefHit ;
615 double rr = xx * xx + yy * yy ;
616 candidateHit->xp = xx / rr ;
617 candidateHit->yp = - yy / rr ;
619 candidateHit->wxy = rr * rr /
620 ( square(getPara()->xyErrorScale) *
621 ( square(candidateHit->dx) + square(candidateHit->dy) ) ) ;
626 temp = (a2Xy * candidateHit->xp - candidateHit->yp + a1Xy) ;
627 dxy = temp * temp / ( a2Xy * a2Xy + 1.F ) ;
631 lchi2 = (dxy * candidateHit->wxy) ;
633 if ( lchi2 > chi2[0] )
return 0 ;
637 if ( getPara()->szFitFlag ){
641 dx = baseHit->x - candidateHit->x ;
642 dy = baseHit->y - candidateHit->y ;
643 slocal = baseHit->s - way * sqrt ( dx * dx + dy * dy ) ;
645 temp = (a2Sz * slocal - candidateHit->z + a1Sz) ;
646 dsz = temp * temp / ( a2Sz * a2Sz + 1 ) ;
650 lszChi2 = dsz * candidateHit->wz ;
660 if ( lchi2 < chi2[0] ) {
661 chi2[0] = (double)lchi2 ;
662 chi2[1] = (double)lszChi2 ;
664 if ( getPara()->szFitFlag ) candidateHit->s = (
double)slocal ;
668 if ( lchi2 < getPara()->goodHitChi2 )
return 2 ;
682 register int areaIndex ;
690 if ( flag != 1 )
return 0 ;
694 i_phi = (int)(( psi - getPara()->phiMinTrack ) / getPara()->phiSliceTrack + 1 );
696 LOG(ERR,
" Track phi index too low %d \n", i_phi ) ;
699 if ( i_phi >= getPara()->nPhiTrackPlusOne ) {
700 LOG(ERR,
" Track phi index too high %d \n", i_phi ) ;
701 i_phi = getPara()->nPhiTrack ;
706 i_eta = (int)(( eta - getPara()->etaMinTrack ) / getPara()->etaSliceTrack + 1 );
708 LOG(ERR,
" Track eta index too low %d \n", i_eta ) ;
711 if ( i_eta >= getPara()->nEtaTrackPlusOne ) {
712 LOG(ERR,
" Track eta index too high %d \n", i_eta ) ;
713 i_eta = getPara()->nEtaTrack ;
719 for ( ip = max(i_phi-1,1) ; ip < min(i_phi+2,getPara()->nPhiTrackPlusOne) ; ip++ ) {
720 for ( ie = max(i_eta-1,1) ; ie < min(i_eta+2,getPara()->nEtaTrackPlusOne) ; ie++ ) {
721 areaIndex = ip * getPara()->nEtaTrackPlusOne + ie ;
725 for ( i_track = (
FtfTrack *)trackArea[areaIndex].first ;
727 i_track = i_track->getNextTrack() ) {
731 if ( i_track->flag < 0 ) continue ;
736 short delta1 = i_track->outerMostRow - outerMostRow ;
737 short delta2 = i_track->innerMostRow - innerMostRow ;
738 if ( delta1 * delta2 <= 0 ) continue ;
742 if ( fabs(eta-i_track->eta) > getPara()->detaMerge )
continue ;
743 delta_psi = (double)fabs(psi - i_track->psi) ;
744 if ( delta_psi > getPara()->dphiMerge && delta_psi < twoPi - getPara()->dphiMerge )
continue ;
746 i_track->add (
this ) ;
748 if ( getPara()->debugLevel > 1 )
749 LOG(ERR,
" \n Track %d merge into %d ", this->
id, i_track->id ) ;
759 if ( track_merged == 0 ) {
760 areaIndex = i_phi * getPara()->nEtaTrackPlusOne + i_eta ;
761 if ( trackArea[areaIndex].first == 0 )
762 trackArea[areaIndex].first =
763 trackArea[areaIndex].last = (
void *)
this ;
765 ((
FtfTrack *)trackArea[areaIndex].last)->nxatrk = this ;
766 trackArea[areaIndex].last = (
void *)
this ;
769 return track_merged ;
774 void FtfTrack::reset (
void)
780 flag = getPara()->primaries ;
789 if ( getPara()->szFitFlag )
811 int which_function ) {
813 int loop_eta[N_LOOP] = { 0, 0, 0,-1,-1,-1, 1, 1, 1 } ;
814 int loop_phi[N_LOOP] = { 0,-1, 1, 0,-1, 1, 0,-1, 1 };
817 int ir, irp, ipp, itp, k;
818 register int areaIndex ;
824 int initialRow, way ;
825 if ( n_r_steps < 0 ) {
826 initialRow = max(1, (baseHit->row - getPara()->rowInnerMost)/getPara()->modRow);
827 n_r_steps = min(initialRow,-n_r_steps ) ;
831 initialRow = max(1, (baseHit->row - getPara()->rowInnerMost + 2)/getPara()->modRow);
832 n_r_steps = min((getPara()->rowOuterMost-initialRow+1),n_r_steps) ;
836 FtfHit *selected_hit = 0 ;
840 for ( ir = 0 ; ir < n_r_steps ; ir++ ){
841 irp = initialRow + way * ir ;
842 for ( k=0; k< N_LOOP; k++){
843 ipp = baseHit->phiIndex + loop_phi[k];
848 if ( getPara()->phiClosed )
849 ipp = getPara()->nPhi + ipp ;
853 else if ( ipp > getPara()->nPhi ) {
854 if ( getPara()->phiClosed )
855 ipp = ipp - getPara()->nPhi ;
862 itp = baseHit->etaIndex + loop_eta[k];
863 if ( itp < 1 ) continue ;
864 if ( itp > getPara()->nEta ) continue ;
867 if ( getPara()->trackDebug && getPara()->debugLevel >= 4 )
868 LOG(ERR,
"FtfTrack::seekNextHit: search in row %d \n",irp ) ;
873 areaIndex = irp * getPara()->nPhiEtaPlusOne + ipp * getPara()->nEtaPlusOne + itp ;
874 for (
FtfHit *candidateHit = (
FtfHit *)volume[areaIndex].first ;
876 candidateHit = (
FtfHit *)candidateHit->nextVolumeHit ){
878 debugInVolume ( baseHit, candidateHit ) ;
883 if ( candidateHit->track != 0 ) continue ;
887 if ( which_function == USE_SEGMENT )
888 result = segmentHitSelection ( baseHit, candidateHit ) ;
890 result = followHitSelection ( baseHit, candidateHit, way ) ;
895 selected_hit = candidateHit ;
896 if ( result ==2 )
goto found ;
912 return selected_hit ;
931 nextHit = (
FtfHit *)lastHit ;
933 nextHit = (
FtfHit *)firstHit ;
935 if ( getPara()->trackDebug && getPara()->debugLevel >= 4 )
936 LOG(ERR,
"FtfTrack:segment: **** Trying to form segment ****\n" );
942 while ( nextHit != 0 && nHits < getPara()->nHitsForSegment ) {
943 chi2[0] = getPara()->maxDistanceSegment ; ;
944 nextHit = seekNextHit ( volume, nextHit, way*getPara()->segmentRowSearchRange,
947 if ( getPara()->trackDebug && getPara()->debugLevel > 0 ) {
948 if ( nextHit != 0 ) {
949 LOG(ERR,
"FtfTrack::segment: Search succesful, hit %d selected\n",
954 LOG(ERR,
"FtfTrack::segment: Search unsuccesful\n" );
965 if ( getPara()->szFitFlag ){
968 length += (double)sqrt ( dx * dx + dy * dy ) ;
969 nextHit->s = length ;
974 if ( getPara()->primaries == 0 ){
975 rr = square ( xRefHit - nextHit->x ) +
976 square ( yRefHit - nextHit->y ) ;
979 nextHit->xp = ( nextHit->x - xRefHit ) / rr ;
980 nextHit->yp = - ( nextHit->y - yRefHit ) / rr ;
981 nextHit->wxy = rr * rr / ( square(getPara()->xyErrorScale) *
982 square(nextHit->dx) + square(nextHit->dy) ) ;
987 add ( nextHit, way ) ;
993 if ( nHits == getPara()->nHitsForSegment )
1004 int FtfTrack::segmentHitSelection (
FtfHit *baseHit,
FtfHit *candidateHit ){
1006 double dx, dy, dr, d3, dangle ;
1013 dphi = (double)fabs((baseHit->phi) - (candidateHit->phi)) ;
1014 if ( dphi > pi ) dphi = (double)fabs( twoPi - dphi ) ;
1015 if ( dphi > getPara()->dphi && dphi < twoPi -getPara()->dphi )
return 0 ;
1019 if ( baseHit->dz < 1000. && candidateHit->dz < 1000. ){
1020 deta = (double)fabs((baseHit->eta) - (candidateHit->eta)) ;
1021 if ( deta > getPara()->deta )
return 0 ;
1025 dr = (double)fabs((
double)(baseHit->row - candidateHit->row));
1026 d3 = (double)(toDeg * dr * ( dphi + deta ) ) ;
1031 if ( getPara()->nHitsForSegment > 2 && nHits-1 < getPara()->nHitsForSegment ) {
1032 dx = candidateHit->x - baseHit->x ;
1033 dy = candidateHit->y - baseHit->y ;
1034 angle = (double)atan2 ( dy, dx ) ;
1035 if ( angle < 0 ) angle = angle + twoPi ;
1036 lastXyAngle = angle ;
1039 if ( getPara()->trackDebug && getPara()->debugLevel >= 3 ) {
1040 LOG(ERR,
"FtfTrack::segmentHitSelection:\n");
1041 LOG(ERR,
"dr,dphi,deta,distance, Min distance %7.2f %7.2f %7.2f %7.2f %7.2f\n",
1042 dr,dphi,deta,d3,chi2[0] ) ;
1044 LOG(ERR,
"Best point, keep it !!!\n" );
1046 LOG(ERR,
"Worse than previous, reject !!\n" );
1052 if ( d3 < chi2[0] ) {
1058 dx = candidateHit->x - baseHit->x ;
1059 dy = candidateHit->y - baseHit->y ;
1060 angle = (double)atan2 ( dy, dx ) ;
1061 if ( angle < 0 ) angle = angle + twoPi ;
1062 dangle = (double)fabs ( lastXyAngle - angle );
1063 lastXyAngle = angle ;
1064 if ( dangle > getPara()->segmentMaxAngle )
return 0 ;
1070 if ( d3 < getPara()->goodDistance )
return 2 ;
1082 void FtfTrack::debugAsk (
void)
1086 LOG(ERR,
"stop(s), continue (any other key)\n" );
1088 if ( cc ==
's' ) getPara()->trackDebug = 0 ;
1089 if ( cc ==
'1' ) getPara()->debugLevel = 1 ;
1090 if ( cc ==
'2' ) getPara()->debugLevel = 2 ;
1091 if ( cc ==
'3' ) getPara()->debugLevel = 3 ;
1092 if ( cc ==
'4' ) getPara()->debugLevel = 4 ;
1093 if ( cc ==
'5' ) getPara()->debugLevel = 5 ;
1094 if ( cc ==
'6' ) getPara()->debugLevel = 6 ;
1095 if ( cc ==
'7' ) getPara()->debugLevel = 7 ;
1097 LOG(ERR,
"FtfTrack::debugAsk: Debug Level %d\n", getPara()->debugLevel ) ;
1103 void FtfTrack::debugDeleteCandidate(
void)
1105 if ( getPara()->trackDebug == 0 || getPara()->debugLevel < 1 ) return ;
1110 LOG(ERR,
"FtfTrack::debugDeleteCandidate: Track %d has %d hits <==\n"
1112 LOG(ERR,
"FtfTrack::debugDeleteCandidate: Minimum is %d, delete it \n",
1113 getPara()->minHitsPerTrack );
1120 void FtfTrack::debugFill ( )
1122 if ( getPara()->trackDebug && getPara()->debugLevel >= 1 ) {
1123 LOG(ERR,
"\n ===> Track %d added <=== ",
id+1 );
1130 void FtfTrack::debugFollowCandidate (
FtfHit* candidateHit )
1132 if ( !getPara()->trackDebug || getPara()->debugLevel >= 4 ) return ;
1143 LOG(ERR,
"FtfTrack::debugFollowCandidate ===> Extension in Follow <===\n" ) ;
1146 LOG(ERR,
"FtfTrack::debugFollowCandidate: Try hit %d\n", candidateHit->id ) ;
1147 candidateHit->print ( 11 ) ;
1151 if ( candidateHit->track != 0 )
1153 LOG(ERR,
"FtfTrack::debugFollowCandidate: hit %d used in track %d\n",
1154 candidateHit->id,
id );
1157 candidateHit->print ( 3 ) ;
1163 void FtfTrack::debugFollowSuccess (
double dxy,
double dsz,
double lxyChi2,
1164 double lszChi2,
double chi2_min,
1169 if ( !getPara()->trackDebug ) return ;
1170 if ( getPara()->debugLevel < 2 ) return ;
1174 double lchi2 = lxyChi2 + lszChi2 ;
1176 LOG(ERR,
" \n ------------------------------------- " ) ;
1177 if ( lchi2 < chi2_min ){
1178 LOG(ERR,
"FtfTrack::debugFollowSuccess: %f Best Chi2, keep point !!!\n",
1180 if ( lchi2 < getPara()->goodHitChi2 ){
1181 LOG(ERR,
"This Chi2 is better than the good cut %f\n",
1182 lchi2, getPara()->goodHitChi2 );
1183 LOG(ERR,
"Stop search !!! " );
1187 LOG(ERR,
"FtfTrack::debugFollowSuccess: Hit %d worse than previous, forget it !! ",
1197 LOG(DBG,
"FtfTrack::debugFollowSuccess:\n");
1198 LOG(DBG,
"dis_xy dis_sz %7.2e %7.2e\n ", dxy, dsz );
1199 LOG(DBG,
"Error xy sz %7.2e %7.2e\n ",
1200 candidateHit->wxy, candidateHit->wz );
1201 LOG(DBG,
"xy:a1,a2;sz:a1,a2 %7.2f %7.2f %7.2f %7.2f\n",
1202 a1Xy, a2Xy, a1Sz, a2Sz );
1203 LOG(DBG,
"ch2:xy sz tot min %7.2f %7.2f %7.2f %7.2f\n",
1204 lxyChi2,lszChi2, lchi2, chi2_min );
1213 void FtfTrack::debugInVolume (
FtfHit *baseHit,
FtfHit *candidateHit )
1216 if ( getPara()->trackDebug && getPara()->debugLevel >= 2 ) {
1228 if ( nHits > getPara()->nHitsForSegment+1 ) Print ( 31 ) ;
1230 LOG(ERR,
"FtfTrack:debugInVolume: Try hit %d\n", candidateHit->id ) ;
1231 candidateHit->print ( 11 ) ;
1235 if ( candidateHit->track != 0 ) {
1236 LOG(ERR,
"FtfTrack:debugInVolume: hit %d used in track %d\n",
1237 candidateHit->id,
id+1 );
1241 double dphi = (double)fabs(baseHit->phi - candidateHit->phi) ;
1243 if ( baseHit->dz < 1000 && candidateHit->dz < 1000 )
1244 deta = (double)fabs(baseHit->eta - candidateHit->eta) ;
1248 if ( dphi > getPara()->dphi )
1249 LOG(ERR,
"FtfTrack:debugInVolume: Hits too far apart in phi: %f \n",
1251 if ( deta > getPara()->deta )
1252 LOG(ERR,
"FtfTrack:debugInVolume: Hits too far apart in eta: %f \n",
1261 void FtfTrack::debugNew ( )
1264 if ( firstHit->id == getPara()->hitDebug ) getPara()->trackDebug = 1 ;
1265 if ( getPara()->trackDebug && getPara()->debugLevel >= 1 )
1267 LOG(DBG,
"================================================ \n" );
1268 LOG(DBG,
"FtfTrack::debugNew:Starting track %d from point %d\n",
1270 LOG(DBG,
"================================================ \n" );