24 #include "Stl3Util/ftf/FtfTrack.h"
25 #include "Stl3Util/ftf/FtfHit.h"
36 void FtfTrack::add (
FtfHit *thisHit,
int way )
45 if ( way < 0 || nHits == 1 ) {
46 if ( nHits > 1 ) ((
FtfBaseHit *)lastHit)->nextTrackHit = thisHit ;
53 ((
FtfBaseHit *)thisHit)->nextTrackHit = firstHit ;
60 thisHit->setStatus (
this ) ;
64 if ( nHits < getPara()->minHitsForFit ) return ;
69 s11Xy = s11Xy + thisHit->wxy ;
70 s12Xy = s12Xy + thisHit->wxy * thisHit->xp ;
71 s22Xy = s22Xy + thisHit->wxy * square(thisHit->xp) ;
72 g1Xy = g1Xy + thisHit->wxy * thisHit->yp ;
73 g2Xy = g2Xy + thisHit->wxy * thisHit->xp * thisHit->yp ;
76 if ( nHits > getPara()->minHitsForFit )
78 ddXy = s11Xy * s22Xy - square ( s12Xy ) ;
80 a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
81 a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
84 if ( getPara()->infoLevel > 0 ) {
85 ftfLog (
"FtfTrack:add: ddXy = 0 \n" ) ;
92 if ( getPara()->szFitFlag ) {
93 s11Sz = s11Sz + thisHit->wz ;
94 s12Sz = s12Sz + thisHit->wz * thisHit->s ;
95 s22Sz = s22Sz + thisHit->wz * thisHit->s * thisHit->s ;
96 g1Sz = g1Sz + thisHit->wz * thisHit->z ;
97 g2Sz = g2Sz + thisHit->wz * thisHit->s * thisHit->z ;
99 if ( nHits > getPara()->minHitsForFit ) {
101 ddSz = s11Sz * s22Sz - s12Sz * s12Sz ;
103 a1Sz = ( g1Sz * s22Sz - g2Sz * s12Sz ) / ddSz ;
104 a2Sz = ( g2Sz * s11Sz - g1Sz * s12Sz ) / ddSz ;
108 if ( getPara()->infoLevel > 0 ) {
109 ftfLog (
"FtfTrack:add: ddSz = 0 \n" ) ;
118 void FtfTrack::add (
FtfTrack *piece )
123 s11Xy += piece->s11Xy ;
124 s12Xy += piece->s12Xy ;
125 s22Xy += piece->s22Xy ;
126 g1Xy += piece->g1Xy ;
127 g2Xy += piece->g2Xy ;
129 ddXy = s11Xy * s22Xy - square ( s12Xy ) ;
130 a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
131 a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
135 if ( getPara()->szFitFlag ) {
136 double det1 = s11Sz * s22Sz - s12Sz * s12Sz ;
137 dtanl = (double) ( s11Sz / det1 );
138 dz0 = (double) ( s22Sz / det1 );
140 double det2 = piece->s11Sz * piece->s22Sz - piece->s12Sz * piece->s12Sz ;
141 piece->dtanl = (double) ( piece->s11Sz / det2 );
142 piece->dz0 = (double) ( piece->s22Sz / det2 );
144 double weight1 = 1./(dtanl*dtanl);
145 double weight2 = 1./(piece->dtanl*piece->dtanl);
146 double weight = (weight1+weight2);
147 tanl = ( weight1 * tanl + weight2 * piece->tanl ) / weight ;
149 weight1 = 1./(dz0*dz0);
150 weight2 = 1./(piece->dz0*piece->dz0);
151 weight = (weight1+weight2);
152 z0 = ( weight1 * z0 + weight2 * piece->z0 ) / weight ;
159 if ( piece->outerMostRow < outerMostRow ){
160 if ( lastHit != NULL ) {
162 for ( currentHit = piece->firstHit ;
163 currentHit != 0 && counter < piece->nHits ;
164 currentHit = ((
FtfBaseHit *)currentHit)->nextTrackHit ) {
168 ((
FtfBaseHit *)lastHit)->nextTrackHit = piece->firstHit ;
169 lastHit = piece->lastHit ;
171 piece->firstHit = 0 ;
172 innerMostRow = piece->innerMostRow ;
173 xLastHit = piece->xLastHit ;
174 yLastHit = piece->yLastHit ;
177 if ( piece->lastHit != NULL ) {
179 for ( currentHit = (
FtfHit *)piece->firstHit ;
180 currentHit != 0 && counter < piece->nHits ;
181 currentHit = ((
FtfBaseHit *)currentHit)->nextTrackHit ) {
185 ((
FtfBaseHit *)piece->lastHit)->nextTrackHit = firstHit ;
186 firstHit = piece->firstHit ;
188 outerMostRow = piece->outerMostRow ;
189 piece->firstHit = 0 ;
193 nHits += piece->nHits ;
194 chi2[0] += piece->chi2[0] ;
195 chi2[1] += piece->chi2[1] ;
200 getPara()->szFitFlag = 0 ;
201 if ( getPara()->fillTracks ) fill ( ) ;
202 getPara()->szFitFlag = 1 ;
217 add ( frstHit, GO_DOWN ) ;
221 if ( !segment ( volume, GO_DOWN ) )
return 0 ;
225 int rowToStop = getPara()->rowInnerMost ;
226 if ( !follow ( volume, GO_DOWN, rowToStop ) )
return 0 ;
230 if ( getPara()->goBackwards ) follow ( volume, GO_UP, getPara()->rowOuterMost ) ;
234 if ( getPara()->fillTracks )
245 void FtfTrack::dEdx ( ){
248 int nTruncate = max(1,
249 getPara()->dEdxNTruncate*nHits/100) ;
250 nTruncate = min(nHits/2,nTruncate) ;
254 double *de =
new double[nTruncate] ;
259 memset ( de, 0, nTruncate*
sizeof(
double) ) ;
263 for ( nextHit = (
FtfHit *)firstHit ;
265 nextHit = (
FtfHit *)nextHit->nextTrackHit) {
269 if ( nextHit->q < de[0] ) continue ;
271 for ( i = nTruncate-1 ; i>=0 ; i-- ){
272 if ( nextHit->q > de[i] ){
273 for ( j=0 ; j<i ; j++ ) de[j] = de[j+1] ;
282 for ( i=0 ; i<nTruncate ; i++ ) dedx -= de[i] ;
283 dedx = dedx / length ;
290 void FtfTrack::deleteCandidate(
void)
295 debugDeleteCandidate ( ) ;
297 while ( curentHit != 0 )
299 nextHit = (
FtfHit *)curentHit->nextTrackHit;
300 curentHit->nextTrackHit = 0 ;
305 curentHit->setStatus ( 0 ) ;
312 void FtfTrack::fill ( ) {
319 double rc = sqrt ( a2Xy * a2Xy + 1 ) / ( 2 * fabs(a1Xy) ) ;
321 double field = getPara()->bField;
324 pt = (double)(bFactor * field * 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 ;
407 if ( d_angle < -pi ) d_angle += twoPi ;
409 q = ( ( d_angle < 0 ) ? 1 : -1 ) ;
410 r0 = ::sqrt(xPar*xPar+yPar*yPar) ;
411 phi0 = atan2(yPar,xPar) ;
412 if ( phi0 < 0 ) phi0 += 2. * M_PI ;
413 psi = (double)(angle_vertex - q * 0.5F * pi) ;
414 if ( psi < 0 ) psi = (double)(psi + twoPi );
415 if ( psi > twoPi ) psi = (double)(psi - twoPi );
419 if ( getPara()->szFitFlag == 1 ){
420 tanl = -(double)a2Sz ;
421 z0 = (double)(a1Sz + a2Sz * ( length - rc * d_angle * q ) );
423 else if ( getPara()->szFitFlag == 2 ) {
432 eta = seta(1.,tanl ) ;
444 void FtfTrack::fillSecondary (
double &xc,
double &yc,
445 double xPar,
double yPar )
450 double dx1 = ((
FtfBaseHit *)firstHit)->x - xc ;
451 double dy1 = ((
FtfBaseHit *)firstHit)->y - yc ;
452 double angle1 = atan2 ( dy1, dx1 ) ;
453 if ( angle1 < 0. ) angle1 = angle1 + twoPi ;
455 double dx2 = xLastHit - xc ;
456 double dy2 = yLastHit - yc ;
457 double angle2 = atan2 ( dy2, dx2 ) ;
458 if ( angle2 < 0. ) angle2 = angle2 + twoPi ;
462 double dangle = angle2 - angle1 ;
464 if ( dangle < -pi ) dangle = dangle + twoPi ;
466 q = ( ( dangle > 0 ) ? 1 : -1 ) ;
467 r0 = ((
FtfHit *)lastHit)->r ;
468 phi0 = ((
FtfHit *)lastHit)->phi ;
469 psi = (double)(angle2 - q * piHalf );
470 if ( psi < 0 ) psi = (double)(psi + twoPi );
474 if ( getPara()->szFitFlag ){
475 tanl = -(double)a2Sz ;
476 z0 = (double)(a1Sz + a2Sz * length );
487 eta = seta(1., tanl ) ;
500 int FtfTrack::follow (
FtfContainer *volume,
int way,
int ir_stop ) {
505 nextHit = (
FtfHit *)lastHit ;
507 nextHit = (
FtfHit *)firstHit ;
509 if ( getPara()->trackDebug && getPara()->debugLevel >= 2 )
510 ftfLog (
"FtfTrack::follow: ===> Going into Track extension <===\n" );
515 double xyChi2 = chi2[0] ;
516 double szChi2 = chi2[1] ;
522 while ( way * nextHit->row < way * ir_stop ) {
526 chi2[0] = getPara()->hitChi2Cut ;
528 nextHit = seekNextHit ( volume, nextHit, way*getPara()->trackRowSearchRange, USE_FOLLOW ) ;
531 if ( getPara()->trackDebug && getPara()->debugLevel >= 1 ){
533 ftfLog (
"FtfTrack::follow: Search succesful, hit selected %d\n",
538 ftfLog (
"FtfTrack::follow: Search unsuccesful\n" );
539 if ( chi2[0]+chi2[1] > getPara()->hitChi2Cut )
540 ftfLog (
" hit chi2 %f larger than cut %f ", chi2[0]+chi2[1],
541 getPara()->hitChi2Cut ) ;
549 if ( nextHit == 0 ) break ;
553 double lxyChi2 = chi2[0]-chi2[1] ;
555 nextHit->xyChi2 = lxyChi2 ;
559 if ( getPara()->szFitFlag ) {
560 length = nextHit->s ;
562 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 ){
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 = length + sqrt ( dx * dx + dy * dy ) ;
645 temp = (a2Sz * slocal - candidateHit->z + a1Sz) ;
646 dsz = temp * temp / ( a2Sz * a2Sz + 1 ) ;
650 lszChi2 = dsz * candidateHit->wz ;
659 if ( lchi2 < chi2[0] ) {
660 chi2[0] = (double)lchi2 ;
661 chi2[1] = (double)lszChi2 ;
663 if ( getPara()->szFitFlag ) candidateHit->s = (
double)slocal ;
667 if ( lchi2 < getPara()->goodHitChi2 )
return 2 ;
681 register int areaIndex ;
689 if ( flag != 1 )
return 0 ;
693 i_phi = (int)(( psi - getPara()->phiMinTrack ) / getPara()->phiSliceTrack + 1 );
695 ftfLog (
" Track phi index too low %d \n", i_phi ) ;
698 if ( i_phi >= getPara()->nPhiTrackPlusOne ) {
699 ftfLog (
" Track phi index too high %d \n", i_phi ) ;
700 i_phi = getPara()->nPhiTrack ;
705 i_eta = (int)(( eta - getPara()->etaMinTrack ) / getPara()->etaSliceTrack + 1 );
707 ftfLog (
" Track eta index too low %d \n", i_eta ) ;
710 if ( i_eta >= getPara()->nEtaTrackPlusOne ) {
711 ftfLog (
" Track eta index too high %d \n", i_eta ) ;
712 i_eta = getPara()->nEtaTrack ;
718 for ( ip = max(i_phi-1,1) ; ip < min(i_phi+2,getPara()->nPhiTrackPlusOne) ; ip++ ) {
719 for ( ie = max(i_eta-1,1) ; ie < min(i_eta+2,getPara()->nEtaTrackPlusOne) ; ie++ ) {
720 areaIndex = ip * getPara()->nEtaTrackPlusOne + ie ;
724 for ( i_track = (
FtfTrack *)trackArea[areaIndex].first ;
726 i_track = i_track->getNextTrack() ) {
730 if ( i_track->flag < 0 ) continue ;
735 short delta1 = i_track->outerMostRow - outerMostRow ;
736 short delta2 = i_track->innerMostRow - innerMostRow ;
737 if ( delta1 * delta2 <= 0 ) continue ;
741 if ( fabs(eta-i_track->eta) > getPara()->detaMerge )
continue ;
742 delta_psi = (double)fabs(psi - i_track->psi) ;
743 if ( delta_psi > getPara()->dphiMerge && delta_psi < twoPi - getPara()->dphiMerge )
continue ;
745 i_track->add (
this ) ;
747 if ( getPara()->debugLevel > 1 )
748 ftfLog (
" \n Track %d merge into %d ", this->
id, i_track->id ) ;
758 if ( track_merged == 0 ) {
759 areaIndex = i_phi * getPara()->nEtaTrackPlusOne + i_eta ;
760 if ( trackArea[areaIndex].first == 0 )
761 trackArea[areaIndex].first =
762 trackArea[areaIndex].last = (
void *)
this ;
764 ((
FtfTrack *)trackArea[areaIndex].last)->nxatrk = this ;
765 trackArea[areaIndex].last = (
void *)
this ;
768 return track_merged ;
773 void FtfTrack::reset (
void)
779 flag = getPara()->primaries ;
788 if ( getPara()->szFitFlag )
810 int which_function ) {
812 int loop_eta[N_LOOP] = { 0, 0, 0,-1,-1,-1, 1, 1, 1 } ;
813 int loop_phi[N_LOOP] = { 0,-1, 1, 0,-1, 1, 0,-1, 1 };
816 int ir, irp, ipp, itp, k;
817 register int areaIndex ;
823 int initialRow, way ;
824 if ( n_r_steps < 0 ) {
825 initialRow = max(1, (baseHit->row - getPara()->rowInnerMost)/getPara()->modRow);
826 n_r_steps = min(initialRow,-n_r_steps ) ;
830 initialRow = max(1, (baseHit->row - getPara()->rowInnerMost + 2)/getPara()->modRow);
831 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 ftfLog (
"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 ) ;
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 ftfLog (
"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 ftfLog (
"FtfTrack::segment: Search succesful, hit %d selected\n",
954 ftfLog (
"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 ftfLog (
"FtfTrack::segmentHitSelection:\n");
1041 ftfLog (
"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 ftfLog (
"Best point, keep it !!!\n" );
1046 ftfLog (
"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 ftfLog (
"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 ftfLog (
"FtfTrack::debugAsk: Debug Level %d\n", getPara()->debugLevel ) ;
1103 void FtfTrack::debugDeleteCandidate(
void)
1105 if ( getPara()->trackDebug == 0 || getPara()->debugLevel < 1 ) return ;
1110 ftfLog (
"FtfTrack::debugDeleteCandidate: Track %d has %d hits <==\n"
1112 ftfLog (
"FtfTrack::debugDeleteCandidate: Minimum is %d, delete it \n",
1113 getPara()->minHitsPerTrack );
1120 void FtfTrack::debugFill ( )
1122 if ( getPara()->trackDebug && getPara()->debugLevel >= 1 ) {
1123 ftfLog (
"\n ===> Track %d added <=== ",
id+1 );
1130 void FtfTrack::debugFollowCandidate (
FtfHit* candidateHit )
1132 if ( !getPara()->trackDebug || getPara()->debugLevel >= 4 ) return ;
1143 ftfLog (
"FtfTrack::debugFollowCandidate ===> Extension in Follow <===\n" ) ;
1146 ftfLog (
"FtfTrack::debugFollowCandidate: Try hit %d\n", candidateHit->id ) ;
1147 candidateHit->print ( 11 ) ;
1151 if ( candidateHit->track != 0 )
1153 ftfLog (
"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 ftfLog (
" \n ------------------------------------- " ) ;
1177 if ( lchi2 < chi2_min ){
1178 ftfLog (
"FtfTrack::debugFollowSuccess: %f Best Chi2, keep point !!!\n",
1180 if ( lchi2 < getPara()->goodHitChi2 ){
1181 ftfLog (
"This Chi2 is better than the good cut %f\n",
1182 lchi2, getPara()->goodHitChi2 );
1183 ftfLog (
"Stop search !!! " );
1187 ftfLog (
"FtfTrack::debugFollowSuccess: Hit %d worse than previous, forget it !! ",
1193 ftfLog (
" \n ------------------------------------- " ) ;
1197 if ( getPara()->debugLevel > 2 ) {
1198 ftfLog (
"FtfTrack::debugFollowSuccess:\n");
1199 ftfLog (
"dis_xy dis_sz %7.2e %7.2e\n ", dxy, dsz );
1200 ftfLog (
"Error xy sz %7.2e %7.2e\n ",
1201 candidateHit->wxy, candidateHit->wz );
1202 ftfLog (
"xy:a1,a2;sz:a1,a2 %7.2f %7.2f %7.2f %7.2f\n",
1203 a1Xy, a2Xy, a1Sz, a2Sz );
1204 ftfLog (
"ch2:xy sz tot min %7.2f %7.2f %7.2f %7.2f\n",
1205 lxyChi2,lszChi2, lchi2, chi2_min );
1214 void FtfTrack::debugInVolume (
FtfHit *baseHit,
FtfHit *candidateHit )
1217 if ( getPara()->trackDebug && getPara()->debugLevel >= 2 ) {
1229 if ( nHits > getPara()->nHitsForSegment+1 ) Print ( 31 ) ;
1231 ftfLog (
"FtfTrack:debugInVolume: Try hit %d\n", candidateHit->id ) ;
1232 candidateHit->print ( 11 ) ;
1236 if ( candidateHit->track != 0 ) {
1237 ftfLog (
"FtfTrack:debugInVolume: hit %d used in track %d\n",
1238 candidateHit->id,
id+1 );
1242 double dphi = (double)fabs(baseHit->phi - candidateHit->phi) ;
1244 if ( baseHit->dz < 1000 && candidateHit->dz < 1000 )
1245 deta = (double)fabs(baseHit->eta - candidateHit->eta) ;
1249 if ( dphi > getPara()->dphi )
1250 ftfLog (
"FtfTrack:debugInVolume: Hits too far apart in phi: %f \n",
1252 if ( deta > getPara()->deta )
1253 ftfLog (
"FtfTrack:debugInVolume: Hits too far apart in eta: %f \n",
1262 void FtfTrack::debugNew ( )
1265 if ( firstHit->id == getPara()->hitDebug ) getPara()->trackDebug = 1 ;
1266 if ( getPara()->trackDebug && getPara()->debugLevel >= 1 )
1268 ftfLog (
"================================================ \n" );
1269 ftfLog (
"FtfTrack::debugNew:Starting track %d from point %d\n",
1271 ftfLog (
"================================================ \n" );