StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FtfTrack.cxx
1 //:>------------------------------------------------------------------
2 //: FILE: FtfTrack.cxx
3 //: HISTORY:
4 //: 28oct1996 version 1.00
5 //: 11aug1999 ppy primary flag fill in filling routines
6 //: 22aug1999 ppy fixing Debug routines (TRDEBUG flag on)
7 //: 23aug1999 ppy change loop order in seekNextHit
8 //: 29aug1999 ppy move fill tracks from follow to build
9 //: 19nov1999 ppy add maxChi2Primary to decide whether track is primary
10 //: 27jan2000 ppy refHit replaced by xRefHit and yRefHit
11 //: 27jan2000 VOLUME, ROW and AREA classes replaced by FtfContainer
12 //: 17feb2000 ddXy and ddSz trying to catch divisions by zero
13 //:
14 //:<------------------------------------------------------------------
15 //:>------------------------------------------------------------------
16 //: CLASS: FtfTrack
17 //: DESCRIPTION: Functions associated with this class
18 //: AUTHOR: ppy - Pablo Yepes, yepes@physics.rice.edu
19 //:>------------------------------------------------------------------
20 //#include <memory.h>
21 #include <stdio.h>
22 #include <math.h>
23 #include <cstring>
24 #include "Stl3Util/ftf/FtfTrack.h"
25 #include "Stl3Util/ftf/FtfHit.h"
26 
27 //extern FtfFinder tracker ;
28 
29 
30 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 // Add hits to track
32 // Arguments:
33 // thisHit: hit pointer
34 // way : >0 add at beginning, <0 at end
35 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 void FtfTrack::add ( FtfHit *thisHit, int way )
37 {
38 //
39 // Increment # hits in this track
40 //
41  nHits++ ;
42 //
43 // Update pointers
44 //
45  if ( way < 0 || nHits == 1 ) {
46  if ( nHits > 1 ) ((FtfBaseHit *)lastHit)->nextTrackHit = thisHit ;
47  lastHit = thisHit ;
48  innerMostRow = ((FtfBaseHit *)lastHit)->row ;
49  xLastHit = ((FtfBaseHit *)lastHit)->x ;
50  yLastHit = ((FtfBaseHit *)lastHit)->y ;
51  }
52  else {
53  ((FtfBaseHit *)thisHit)->nextTrackHit = firstHit ;
54  firstHit = thisHit ;
55  outerMostRow = ((FtfBaseHit *)firstHit)->row ;
56  }
57 //
58 // Declare hit as used and fill chi2
59 //
60  thisHit->setStatus ( this ) ;
61 //
62 // Check whether a fit update is needed
63 //
64  if ( nHits < getPara()->minHitsForFit ) return ;
65 //
66 // Include hit in xy fit parameter calculation
67 //
68 
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 ;
74 
75 
76  if ( nHits > getPara()->minHitsForFit )
77  {
78  ddXy = s11Xy * s22Xy - square ( s12Xy ) ;
79  if ( ddXy != 0 ) {
80  a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
81  a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
82  }
83  else {
84  if ( getPara()->infoLevel > 0 ) {
85  ftfLog ( "FtfTrack:add: ddXy = 0 \n" ) ;
86  }
87  }
88  }
89 //
90 // Now in the sz plane
91 //
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 ;
98 
99  if ( nHits > getPara()->minHitsForFit ) {
100 
101  ddSz = s11Sz * s22Sz - s12Sz * s12Sz ;
102  if ( ddSz != 0 ) {
103  a1Sz = ( g1Sz * s22Sz - g2Sz * s12Sz ) / ddSz ;
104  a2Sz = ( g2Sz * s11Sz - g1Sz * s12Sz ) / ddSz ;
105  }
106  else
107  {
108  if ( getPara()->infoLevel > 0 ) {
109  ftfLog ( "FtfTrack:add: ddSz = 0 \n" ) ;
110  }
111  }
112  }
113  }
114 }
115 //****************************************************************************
116 // Fill track information tables
117 //****************************************************************************
118 void FtfTrack::add ( FtfTrack *piece )
119 {
120 //
121 // Get circle parameters
122 //
123  s11Xy += piece->s11Xy ;
124  s12Xy += piece->s12Xy ;
125  s22Xy += piece->s22Xy ;
126  g1Xy += piece->g1Xy ;
127  g2Xy += piece->g2Xy ;
128 
129  ddXy = s11Xy * s22Xy - square ( s12Xy ) ;
130  a1Xy = ( g1Xy * s22Xy - g2Xy * s12Xy ) / ddXy ;
131  a2Xy = ( g2Xy * s11Xy - g1Xy * s12Xy ) / ddXy ;
132 //
133 // Now in the sz plane
134 //
135  if ( getPara()->szFitFlag ) {
136  double det1 = s11Sz * s22Sz - s12Sz * s12Sz ;
137  dtanl = (double) ( s11Sz / det1 );
138  dz0 = (double) ( s22Sz / det1 );
139 
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 );
143 
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 ;
148 
149  weight1 = 1./(dz0*dz0);
150  weight2 = 1./(piece->dz0*piece->dz0);
151  weight = (weight1+weight2);
152  z0 = ( weight1 * z0 + weight2 * piece->z0 ) / weight ;
153  }
154 
155 //
156 // Add space points to first track
157 //
158  int counter ;
159  if ( piece->outerMostRow < outerMostRow ){
160  if ( lastHit != NULL ) {
161  counter = 0 ;
162  for ( currentHit = piece->firstHit ;
163  currentHit != 0 && counter < piece->nHits ;
164  currentHit = ((FtfBaseHit *)currentHit)->nextTrackHit ) {
165  ((FtfBaseHit *)currentHit)->track = this ;
166  counter++ ;
167  }
168  ((FtfBaseHit *)lastHit)->nextTrackHit = piece->firstHit ;
169  lastHit = piece->lastHit ;
170  }
171  piece->firstHit = 0 ;
172  innerMostRow = piece->innerMostRow ;
173  xLastHit = piece->xLastHit ;
174  yLastHit = piece->yLastHit ;
175  }
176  else {
177  if ( piece->lastHit != NULL ) {
178  counter = 0 ;
179  for ( currentHit = (FtfHit *)piece->firstHit ;
180  currentHit != 0 && counter < piece->nHits ;
181  currentHit = ((FtfBaseHit *)currentHit)->nextTrackHit ) {
182  ((FtfBaseHit *)currentHit)->track = this ;
183  counter++;
184  }
185  ((FtfBaseHit *)piece->lastHit)->nextTrackHit = firstHit ;
186  firstHit = piece->firstHit ;
187  }
188  outerMostRow = piece->outerMostRow ;
189  piece->firstHit = 0 ;
190  }
191 //
192 //
193  nHits += piece->nHits ;
194  chi2[0] += piece->chi2[0] ;
195  chi2[1] += piece->chi2[1] ;
196 //
197 // Update track parameters
198 //
199 //
200  getPara()->szFitFlag = 0 ;
201  if ( getPara()->fillTracks ) fill ( ) ;
202  getPara()->szFitFlag = 1 ;
203 //
204 //
205 // Declare track 2 not to be used
206 //
207  piece->flag = -1 ;
208 }
209 
210 //****************************************************************************
211 // Control how the track gets built
212 //****************************************************************************
213 int FtfTrack::buildTrack ( FtfHit *frstHit, FtfContainer *volume ) {
214 //
215 // Add first hit to track
216 //
217  add ( frstHit, GO_DOWN ) ;
218 //
219 // Try to build a segment first
220 //
221  if ( !segment ( volume, GO_DOWN ) ) return 0 ;
222 //
223 // If segment build go for a real track with a fit
224 //
225  int rowToStop = getPara()->rowInnerMost ;
226  if ( !follow ( volume, GO_DOWN, rowToStop ) ) return 0 ;
227 //
228 // Now to extent track the other direction if requested
229 //
230  if ( getPara()->goBackwards ) follow ( volume, GO_UP, getPara()->rowOuterMost ) ;
231 //
232 // Fill tracks
233 //
234  if ( getPara()->fillTracks )
235  fill ( ) ;
236 #ifdef TRDEBUG
237  debugFill ( ) ;
238 #endif
239 
240  return 1 ;
241 }
242 //***************************************************************************
243 // Calculates dEdx
244 //***************************************************************************
245 void FtfTrack::dEdx ( ){
246  int i, j ;
247  FtfHit *nextHit ;
248  int nTruncate = max(1,
249  getPara()->dEdxNTruncate*nHits/100) ;
250  nTruncate = min(nHits/2,nTruncate) ;
251 //
252 // Define array to keep largest de's
253 //
254  double *de = new double[nTruncate] ;
255 //
256 // Reset
257 //
258  dedx = 0.F ;
259  memset ( de, 0, nTruncate*sizeof(double) ) ;
260 //
261 //
262 //
263  for ( nextHit = (FtfHit *)firstHit ;
264  nextHit != 0 ;
265  nextHit = (FtfHit *)nextHit->nextTrackHit) {
266 
267  dedx += nextHit->q ;
268 
269  if ( nextHit->q < de[0] ) continue ;
270 
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] ;
274  de[i] = nextHit->q ;
275  break ;
276  }
277  }
278  }
279 //
280 // Subtract largest de
281 //
282  for ( i=0 ; i<nTruncate ; i++ ) dedx -= de[i] ;
283  dedx = dedx / length ;
284 /* End track in required volume condition */
285 
286 }
287 //***********************************************************************
288 // Delete track candidate
289 //***********************************************************************
290 void FtfTrack::deleteCandidate(void)
291 {
292  FtfHit *curentHit = (FtfHit *)firstHit ;
293  FtfHit *nextHit ;
294 #ifdef TRDEBUG
295  debugDeleteCandidate ( ) ;
296 #endif
297  while ( curentHit != 0 )
298  {
299  nextHit = (FtfHit *)curentHit->nextTrackHit;
300  curentHit->nextTrackHit = 0 ;
301  curentHit->xyChi2 =
302  curentHit->szChi2 =
303  curentHit->s = 0.F ;
304 
305  curentHit->setStatus ( 0 ) ;
306  curentHit = nextHit;
307  }
308 }
309 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
310 // Fills track variables with or without fit
311 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
312 void FtfTrack::fill ( ) {
313 //
314 // Get circle parameters
315 //
316  // cout << "." << flush;
317  double xc, yc ;
318  //cout << ".( a1Xy = " << a1Xy << " )" << flush;
319  double rc = sqrt ( a2Xy * a2Xy + 1 ) / ( 2 * fabs(a1Xy) ) ;
320  //cout << "." << flush;
321  double field = getPara()->bField;
322  //cout << "." << endl;
323  //pt = (double)(bFactor * getPara()->bField * rc );
324  pt = (double)(bFactor * field * rc );
325  double xParameters = 0.;
326  double yParameters = 0.;
327 //
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 ;
332  else
333  getPara()->vertexConstrainedFit = 0 ;
334 
335  fitHelix ( ) ;
336 
337 // if ( id == 303) Print(31);
338  if ( getPara()->vertexConstrainedFit && getPara()->parameterLocation ){
339  updateToRadius ( ::sqrt(xLastHit*xLastHit+yLastHit*yLastHit) ) ;
340  }
341  else if ( !getPara()->vertexConstrainedFit && !getPara()->parameterLocation ) {
342  updateToClosestApproach ( getPara()->xVertex, getPara()->yVertex, 2000. ) ;
343  }
344 
345 // if ( id == 1 ) Print(30);
346  }
347  else{
348 
349  if ( getPara()->primaries ){
350 
351  fillPrimary ( xc, yc, rc, getPara()->xVertex, getPara()->yVertex ) ;
352  if ( getPara()->parameterLocation ) {// give track parameters at inner most point
353  updateToRadius ( ::sqrt(xLastHit*xLastHit+yLastHit*yLastHit) ) ;
354  }
355  }
356  else { // Secondaries now
357  xc = - a2Xy / ( 2. * a1Xy ) + xRefHit ;
358  yc = - 1. / ( 2. * a1Xy ) + yRefHit ;
359  if ( getPara()->parameterLocation ) { // give track parameters at inner most point
360  xParameters = xLastHit ;
361  yParameters = yLastHit ;
362  }
363  else { // give parameters at point of closest approach
364  getClosest ( getPara()->xVertex, getPara()->yVertex,
365  rc, xc, yc, xParameters, yParameters ) ;
366  }
367  fillSecondary ( xc, yc, xParameters, yParameters ) ;
368  }
369 //
370 // Get Errors
371 //
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 );
377  }
378  }
379 }
380 //****************************************************************************
381 // Fill track information variables
382 //****************************************************************************
383 void FtfTrack::fillPrimary ( double &xc, double &yc, double &rc,
384  double xPar, double yPar ) {
385 //
386 // Get circle parameters
387 //
388  xc = getPara()->xVertex - a2Xy / ( 2. * a1Xy ) ;
389  yc = getPara()->yVertex - 1. / ( 2. * a1Xy ) ;
390 //
391 // Get track parameters
392 //
393  double angle_vertex = atan2 ( yPar-yc, xPar-xc ) ;
394  if ( angle_vertex < 0. ) angle_vertex = angle_vertex + twoPi ;
395 
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 ;
400 //
401 // Get the rotation
402 //
403  double d_angle = angle_last - angle_vertex ;
404 // double d_angle = angle_vertex - angle_last ;
405 
406 // if ( d_angle > pi ) d_angle -= twoPi ;
407  if ( d_angle < -pi ) d_angle += twoPi ;
408 
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 );
416 //
417 // Get z parameters if needed
418 //
419  if ( getPara()->szFitFlag == 1 ){
420  tanl = -(double)a2Sz ;
421  z0 = (double)(a1Sz + a2Sz * ( length - rc * d_angle * q ) );
422  }
423  else if ( getPara()->szFitFlag == 2 ) {
424  tanl = ((FtfBaseHit *)firstHit)->z /
425  (double)sqrt ( ((FtfBaseHit *)firstHit)->x*((FtfBaseHit *)firstHit)->x +
426  ((FtfBaseHit *)firstHit)->y*((FtfBaseHit *)firstHit)->y ) ;
427  z0 = 0.F ;
428  }
429 //
430 // Store some more track info
431 //
432  eta = seta(1.,tanl ) ;
433 //
434 // Set primary track
435 //
436  flag = 1 ;
437 
438 }
439 //****************************************************************************
440 //
441 // Fill track information tables
442 //
443 //****************************************************************************
444 void FtfTrack::fillSecondary ( double &xc, double &yc,
445  double xPar, double yPar )
446 {
447 /*--------------------------------------------------------------------------
448  Get angles for initial and final points
449 ------------------------------------------------------------------------------*/
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 ;
454 
455  double dx2 = xLastHit - xc ;
456  double dy2 = yLastHit - yc ;
457  double angle2 = atan2 ( dy2, dx2 ) ;
458  if ( angle2 < 0. ) angle2 = angle2 + twoPi ;
459 /*--------------------------------------------------------------------------
460  Get the rotation
461 ------------------------------------------------------------------------------*/
462  double dangle = angle2 - angle1 ;
463  // if ( dangle > pi ) dangle = dangle - twoPi ;
464  if ( dangle < -pi ) dangle = dangle + twoPi ;
465 
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 );
471 //
472 // Get z parameters if needed
473 //
474  if ( getPara()->szFitFlag ){
475  tanl = -(double)a2Sz ;
476  z0 = (double)(a1Sz + a2Sz * length );
477  }
478  else{
479  tanl = ((FtfBaseHit *)firstHit)->z /
480  (double)sqrt ( ((FtfBaseHit *)firstHit)->x*((FtfBaseHit *)firstHit)->x +
481  ((FtfBaseHit *)firstHit)->y*((FtfBaseHit *)firstHit)->y ) ;
482  z0 = 0.F ;
483  }
484 //
485 //--> Store some more track info
486 //
487  eta = seta(1., tanl ) ;
488 //
489 // Set primary track flag
490 //
491  flag = 0 ;
492 }
493 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
494 // Adds hits to a track chosing the closest to fit
495 // Arguments:
496 // volume: volume pointer
497 // way : which way to procede in r (negative or positive)
498 // row_to_stop: row index where to stop
499 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
500 int FtfTrack::follow ( FtfContainer *volume, int way, int ir_stop ) {
501 
502  FtfHit *nextHit ;
503 
504  if ( way < 0 )
505  nextHit = (FtfHit *)lastHit ;
506  else
507  nextHit = (FtfHit *)firstHit ;
508 #ifdef TRDEBUG
509  if ( getPara()->trackDebug && getPara()->debugLevel >= 2 )
510  ftfLog ( "FtfTrack::follow: ===> Going into Track extension <===\n" );
511 #endif
512 //
513 // Define variables to keep total chi2
514 //
515  double xyChi2 = chi2[0] ;
516  double szChi2 = chi2[1] ;
517 
518 //
519 // Loop as long a a hit is found and the segment
520 // is shorter than n_hit_segm
521 //
522  while ( way * nextHit->row < way * ir_stop ) {
523 //
524 // Select next hit
525 //
526  chi2[0] = getPara()->hitChi2Cut ;
527 
528  nextHit = seekNextHit ( volume, nextHit, way*getPara()->trackRowSearchRange, USE_FOLLOW ) ;
529 
530 #ifdef TRDEBUG
531  if ( getPara()->trackDebug && getPara()->debugLevel >= 1 ){
532  if ( nextHit != 0 ){
533  ftfLog ( "FtfTrack::follow: Search succesful, hit selected %d\n",
534  nextHit->id );
535 // nextHit->Show ( getPara()->color_track ) ;
536  }
537  else{
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 ) ;
542  }
543  debugAsk () ;
544  }
545 #endif
546 //
547 // Stop if nothing found
548 //
549  if ( nextHit == 0 ) break ;
550 //
551 // Keep total chi2
552 //
553  double lxyChi2 = chi2[0]-chi2[1] ;
554  xyChi2 += lxyChi2 ;
555  nextHit->xyChi2 = lxyChi2 ;
556 //
557 // if sz fit update track length
558 //
559  if ( getPara()->szFitFlag ) {
560  length = nextHit->s ;
561  szChi2 += chi2[1] ;
562  nextHit->szChi2 = chi2[1] ;
563  }
564 //
565 // Add hit to track
566 //
567  add ( nextHit, way ) ;
568 
569  } // End while
570 //
571 // Check # hits
572 //
573  if ( nHits < getPara()->minHitsPerTrack ) return 0 ;
574 //
575 // Store track chi2
576 //
577  chi2[0] = xyChi2 ;
578  chi2[1] = szChi2 ;
579 //
580 // Check total chi2
581 //
582  double normalized_chi2 = (chi2[0]+chi2[1])/nHits ;
583  if ( normalized_chi2 > getPara()->trackChi2Cut ) return 0 ;
584 //
585  return 1 ;
586 }
587 /*******************************************************************************
588  Reconstructs tracks
589 *********************************************************************************/
590 int FtfTrack::followHitSelection ( FtfHit *baseHit, FtfHit *candidateHit ){
591 //
592  double lszChi2 = 0 ;
593  double lchi2 ;
594  double slocal=0, deta, dphi ;
595  double dx, dy, dxy, dsz, temp ;
596 //
597 // Check delta eta
598 //
599 // if ( baseHit->dz < 1000. && candidateHit->dz < 1000 ){
600  deta = fabs((baseHit->eta)-(candidateHit->eta)) ;
601  if ( deta > getPara()->deta ) return 0 ;
602 // }
603 // else deta = 0.F ;
604 //
605 // Check delta phi
606 //
607  dphi = fabs((baseHit->phi)-(candidateHit->phi)) ;
608  if ( dphi > getPara()->dphi && dphi < twoPi-getPara()->dphi ) return 0 ;
609 //
610 // If looking for secondaries calculate conformal coordinates
611 //
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 ;
618 
619  candidateHit->wxy = rr * rr /
620  ( square(getPara()->xyErrorScale) *
621  ( square(candidateHit->dx) + square(candidateHit->dy) ) ) ;
622  }
623 //
624 // Calculate distance in x and y
625 //
626  temp = (a2Xy * candidateHit->xp - candidateHit->yp + a1Xy) ;
627  dxy = temp * temp / ( a2Xy * a2Xy + 1.F ) ;
628 //
629 // Calculate chi2
630 //
631  lchi2 = (dxy * candidateHit->wxy) ;
632 
633  if ( lchi2 > chi2[0] ) return 0 ;
634 //
635 // Now in the sz plane
636 //
637  if ( getPara()->szFitFlag ){
638 //
639 // Get "s" and calculate distance hit-line
640 //
641  dx = baseHit->x - candidateHit->x ;
642  dy = baseHit->y - candidateHit->y ;
643  slocal = length + sqrt ( dx * dx + dy * dy ) ;
644 
645  temp = (a2Sz * slocal - candidateHit->z + a1Sz) ;
646  dsz = temp * temp / ( a2Sz * a2Sz + 1 ) ;
647 //
648 // Calculate chi2
649 //
650  lszChi2 = dsz * candidateHit->wz ;
651  lchi2 += lszChi2 ;
652  }
653  else {
654  lszChi2 = 0.F ;
655  }
656 //
657 // Check whether the chi2 square is better than previous one
658 //
659  if ( lchi2 < chi2[0] ) {
660  chi2[0] = (double)lchi2 ;
661  chi2[1] = (double)lszChi2 ;
662 
663  if ( getPara()->szFitFlag ) candidateHit->s = (double)slocal ;
664 //
665 // if a good chi2 is found let's stop here
666 //
667  if ( lchi2 < getPara()->goodHitChi2 ) return 2 ;
668 
669  return 1 ;
670  }
671 //
672 // Return the selected hit
673 //
674  return 0 ;
675 }
676 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
677 // Merges tracks
678 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
679 int FtfTrack::mergePrimary ( FtfContainer *trackArea ){
680  short track_merged ;
681  register int areaIndex ;
682  int i_phi, i_eta ;
683  FtfTrack *i_track = 0 ;
684  int ip, ie ;
685  double delta_psi ;
686 //
687 // Check Track is primary
688 //
689  if ( flag != 1 ) return 0 ;
690 //-
691 // Get track area
692 //
693  i_phi = (int)(( psi - getPara()->phiMinTrack ) / getPara()->phiSliceTrack + 1 );
694  if ( i_phi < 0 ) {
695  ftfLog ( " Track phi index too low %d \n", i_phi ) ;
696  i_phi = 1 ;
697  }
698  if ( i_phi >= getPara()->nPhiTrackPlusOne ) {
699  ftfLog ( " Track phi index too high %d \n", i_phi ) ;
700  i_phi = getPara()->nPhiTrack ;
701  }
702 //
703 // Now eta
704 //
705  i_eta = (int)(( eta - getPara()->etaMinTrack ) / getPara()->etaSliceTrack + 1 );
706  if ( i_eta <= 0 ) {
707  ftfLog ( " Track eta index too low %d \n", i_eta ) ;
708  i_eta = 1 ;
709  }
710  if ( i_eta >= getPara()->nEtaTrackPlusOne ) {
711  ftfLog ( " Track eta index too high %d \n", i_eta ) ;
712  i_eta = getPara()->nEtaTrack ;
713  }
714 //
715 // Loop around selected area
716 //
717  track_merged = 0 ;
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 ;
721 //
722 // Loop over tracks
723 //
724  for ( i_track = (FtfTrack *)trackArea[areaIndex].first ;
725  i_track != 0 ;
726  i_track = i_track->getNextTrack() ) {
727 //
728 // Reject track if it is not good
729 //
730  if ( i_track->flag < 0 ) continue ;
731 //
732 // Compare both tracks
733 //
734 // No overlapping tracks
735  short delta1 = i_track->outerMostRow - outerMostRow ;
736  short delta2 = i_track->innerMostRow - innerMostRow ;
737  if ( delta1 * delta2 <= 0 ) continue ;
738 //
739 // Tracks close enough
740 //
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 ;
744 
745  i_track->add ( this ) ;
746 #ifdef TRDEBUG
747  if ( getPara()->debugLevel > 1 )
748  ftfLog ( " \n Track %d merge into %d ", this->id, i_track->id ) ;
749 #endif
750  track_merged = 1 ;
751  break ;
752  }
753  }
754  }
755 //
756 //-> If track not matched add it
757 //
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 ;
763  else {
764  ((FtfTrack *)trackArea[areaIndex].last)->nxatrk = this ;
765  trackArea[areaIndex].last = (void *)this ;
766  }
767  }
768  return track_merged ;
769 }
770 /*************************************************************************
771  Recontruct primary tracks
772 *************************************************************************/
773 void FtfTrack::reset (void)
774 {
775 /*----------------------------------------------------------------------
776  Set fit parameters to zero
777 ----------------------------------------------------------------------*/
778 
779  flag = getPara()->primaries ;
780  nHits = 0 ;
781  s11Xy =
782  s12Xy =
783  s22Xy =
784  g1Xy =
785  g2Xy =
786  chi2[0] = 0.F ;
787  nxatrk = 0 ;
788  if ( getPara()->szFitFlag )
789  {
790  s11Sz =
791  s12Sz =
792  s22Sz =
793  g1Sz =
794  g2Sz =
795  chi2[1] =
796  length = 0.F ;
797  }
798 }
799 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
800 // Function to look for next hit
801 // Input: volume: Volume pointer
802 // baseHit: Last point in track
803 // n_r_steps: How many rows search and which way (up or down)
804 // which_function: Function to be used to decide whether the hit is good
805 // Returns: Selected hit
806 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
807 FtfHit *FtfTrack::seekNextHit ( FtfContainer *volume,
808  FtfHit *baseHit,
809  int n_r_steps,
810  int which_function ) {
811 #define N_LOOP 9
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 };
814 
815 
816  int ir, irp, ipp, itp, k;
817  register int areaIndex ;
818  int result ;
819 
820 //-------------------------------------------------------------------------------
821 // Calculate limits on the volume loop
822 //-----------------------------------------------------------------------------*/
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 ) ;
827  way = -1 ;
828  }
829  else {
830  initialRow = max(1, (baseHit->row - getPara()->rowInnerMost + 2)/getPara()->modRow);
831  n_r_steps = min((getPara()->rowOuterMost-initialRow+1),n_r_steps) ;
832  way = 1 ;
833  }
834 
835 
836  FtfHit *selected_hit = 0 ;
837 //
838 // Loop over modules
839 //
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];
844 //
845 //-- Gymnastics if phi is closed
846 //
847  if ( ipp < 1 ) {
848  if ( getPara()->phiClosed )
849  ipp = getPara()->nPhi + ipp ;
850  else
851  continue ;
852  }
853  else if ( ipp > getPara()->nPhi ) {
854  if ( getPara()->phiClosed )
855  ipp = ipp - getPara()->nPhi ;
856  else
857  continue ;
858  }
859 //
860 // Now get eta index
861 //
862  itp = baseHit->etaIndex + loop_eta[k];
863  if ( itp < 1 ) continue ;
864  if ( itp > getPara()->nEta ) continue ;
865 //
866 #ifdef TRDEBUG
867  if ( getPara()->trackDebug && getPara()->debugLevel >= 4 )
868  ftfLog ( "FtfTrack::seekNextHit: search in row %d \n",irp ) ;
869 #endif
870 //
871 // Now loop over hits in each volume
872 //
873  areaIndex = irp * getPara()->nPhiEtaPlusOne + ipp * getPara()->nEtaPlusOne + itp ;
874  for ( FtfHit *candidateHit = (FtfHit *)volume[areaIndex].first ;
875  candidateHit != 0 ;
876  candidateHit = (FtfHit *)candidateHit->nextVolumeHit ){
877 #ifdef TRDEBUG
878  debugInVolume ( baseHit, candidateHit ) ;
879 #endif
880 //----------------------------------------------------------------------------
881 // Check whether the hit was used before
882 //--------------------------------------------------------------------------*/
883  if ( candidateHit->track != 0 ) continue ;
884 //--------------------------------------------------------------------------
885 // If first points, just choose the closest hit
886 //-------------------------------------------------------------------------- */
887  if ( which_function == USE_SEGMENT )
888  result = segmentHitSelection ( baseHit, candidateHit ) ;
889  else
890  result = followHitSelection ( baseHit, candidateHit ) ;
891 //
892 // Check result
893 //
894  if ( result > 0 ) {
895  selected_hit = candidateHit ;
896  if ( result ==2 ) goto found ;
897  }
898 //
899 // End hit loop
900 //
901  }
902 //
903 // End row loop
904 //
905  }
906 //
907 // End volume loop inside cone
908 //
909  }
910 found: ;
911 
912  return selected_hit ;
913 }
914 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
915 // Forms segments
916 // Arguments:
917 // volume : volume pointer
918 // way : whether to go to negative or positive ir
919 // row_to_stop: row index where to stop
920 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
921 int FtfTrack::segment( FtfContainer *volume, int way ){
922 //
923 // Define some variables
924 //
925  double dx, dy, rr ;
926  FtfHit* nextHit ;
927 //
928 // Check which way to go
929 //
930  if ( way < 0 )
931  nextHit = (FtfHit *)lastHit ;
932  else
933  nextHit = (FtfHit *)firstHit ;
934 #ifdef TRDEBUG
935  if ( getPara()->trackDebug && getPara()->debugLevel >= 4 )
936  ftfLog ( "FtfTrack:segment: **** Trying to form segment ****\n" );
937 #endif
938 //
939 // Loop as long a a hit is found and the segment
940 // is shorter than n_hit_segm
941 //
942  while ( nextHit != 0 && nHits < getPara()->nHitsForSegment ) {
943  chi2[0] = getPara()->maxDistanceSegment ; ;
944  nextHit = seekNextHit ( volume, nextHit, way*getPara()->segmentRowSearchRange,
945  USE_SEGMENT ) ;
946 #ifdef TRDEBUG
947  if ( getPara()->trackDebug && getPara()->debugLevel > 0 ) {
948  if ( nextHit != 0 ) {
949  ftfLog ( "FtfTrack::segment: Search succesful, hit %d selected\n",
950  nextHit->id );
951 // nextHit->Show ( getPara()->color_track ) ;
952  }
953  else
954  ftfLog ( "FtfTrack::segment: Search unsuccesful\n" );
955  debugAsk () ;
956  }
957 #endif
958 //
959 // If sz fit update s
960 //
961  if ( nextHit != 0 ){
962 //
963 // Calculate track length if sz plane considered
964 //
965  if ( getPara()->szFitFlag ){
966  dx = ((FtfBaseHit *)nextHit)->x - ((FtfBaseHit *)lastHit)->x ;
967  dy = ((FtfBaseHit *)nextHit)->y - ((FtfBaseHit *)lastHit)->y ;
968  length += (double)sqrt ( dx * dx + dy * dy ) ;
969  nextHit->s = length ;
970  }
971 //
972 // Calculate conformal coordinates
973 //
974  if ( getPara()->primaries == 0 ){
975  rr = square ( xRefHit - nextHit->x ) +
976  square ( yRefHit - nextHit->y ) ;
977 
978 
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) ) ;
983  }
984 //
985 // Add hit to track
986 //
987  add ( nextHit, way ) ;
988  }
989  } // End while ( lastHit ...
990 //
991 // If number of hits is as expected return 1
992 //
993  if ( nHits == getPara()->nHitsForSegment )
994  return 1 ;
995  else
996  return 0 ;
997 }
998 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
999 // Routine to look for segments.
1000 // Arguments:
1001 // baseHit: Hit from which track is being extrapolated
1002 // candidateHit: Hit being examined as a candidate to which extend track
1003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1004 int FtfTrack::segmentHitSelection ( FtfHit *baseHit, FtfHit *candidateHit ){
1005 
1006  double dx, dy, dr, d3, dangle ;
1007  double dphi, deta ;
1008  double angle ;
1009 //
1010 // select hit with the
1011 // the smallest value of d3 (defined below)
1012 //
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 ;
1016 //
1017 // Make sure we want to look at the difference in eta
1018 //
1019  if ( baseHit->dz < 1000. && candidateHit->dz < 1000. ){
1020  deta = (double)fabs((baseHit->eta) - (candidateHit->eta)) ;
1021  if ( deta > getPara()->deta ) return 0 ;
1022  }
1023  else deta = 0.F ;
1024 
1025  dr = (double)fabs((double)(baseHit->row - candidateHit->row));
1026  d3 = (double)(toDeg * dr * ( dphi + deta ) ) ;
1027 //
1028 // If initial segment is longer than 2 store angle info in
1029 // a1Xy and a1_sz
1030 //
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 ;
1037  }
1038 #ifdef TRDEBUG
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] ) ;
1043  if ( d3 < chi2[0] )
1044  ftfLog ( "Best point, keep it !!!\n" );
1045  else{
1046  ftfLog ( "Worse than previous, reject !!\n" );
1047 // candidateHit->Show ( getPara()->color_transparent );
1048  }
1049  debugAsk() ;
1050  }
1051 #endif
1052  if ( d3 < chi2[0] ) {
1053 //
1054 // For second hit onwards check the difference in angle
1055 // between the last two track segments
1056 //
1057  if ( nHits > 1 ) {
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 ;
1065  }
1066 //
1067 // Check whether this is the "closest" hit
1068 //
1069  chi2[0] = d3 ;
1070  if ( d3 < getPara()->goodDistance ) return 2 ;
1071  return 1 ;
1072  }
1073 //
1074 // If hit does not fulfill criterai return 0
1075 //
1076  return 0 ;
1077 }
1078 #ifdef TRDEBUG
1079 //*****************************************************************************
1080 // Ask for a character to keep going
1081 //******************************************************************************/
1082 void FtfTrack::debugAsk (void)
1083 {
1084  char cc;
1085 
1086  ftfLog ( "stop(s), continue (any other key)\n" );
1087  cc = getchar();
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 ;
1096 
1097  ftfLog ( "FtfTrack::debugAsk: Debug Level %d\n", getPara()->debugLevel ) ;
1098 
1099 }
1100 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1101 // Debug Delete Candidate
1102 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1103 void FtfTrack::debugDeleteCandidate(void)
1104 {
1105  if ( getPara()->trackDebug == 0 || getPara()->debugLevel < 1 ) return ;
1106 
1107 // for ( startLoop() ; done() ; nextHit() ) {
1108 // currentHit->Show ( getPara()->color_back ) ;
1109 // }
1110  ftfLog ( "FtfTrack::debugDeleteCandidate: Track %d has %d hits <==\n"
1111  ,id, nHits );
1112  ftfLog ( "FtfTrack::debugDeleteCandidate: Minimum is %d, delete it \n",
1113  getPara()->minHitsPerTrack );
1114 // print ( 31 ) ;
1115  debugAsk () ;
1116 }
1117 /*****************************************************************************
1118  Fill track information tables
1119 ******************************************************************************/
1120 void FtfTrack::debugFill ( )
1121 {
1122  if ( getPara()->trackDebug && getPara()->debugLevel >= 1 ) {
1123  ftfLog ( "\n ===> Track %d added <=== ",id+1 );
1124  Print ( 31 ) ;
1125  }
1126 }
1127 /*****************************************************************************
1128  Reconstructs tracks
1129 ******************************************************************************/
1130 void FtfTrack::debugFollowCandidate ( FtfHit* candidateHit )
1131 {
1132  if ( !getPara()->trackDebug || getPara()->debugLevel >= 4 ) return ;
1133 //
1134 // Show the whole track and fit
1135 //
1136 //for ( startLoop() ; done() ; nextHit() ) {
1137 // currentHit->Show ( getPara()->color_track ) ;
1138 //}
1139 // candidateHit->Show ( getPara()->color_candidate );
1140 //
1141 // Print relevant information
1142 //
1143  ftfLog ( "FtfTrack::debugFollowCandidate ===> Extension in Follow <===\n" ) ;
1144  // print ( 31 ) ;
1145 
1146  ftfLog ( "FtfTrack::debugFollowCandidate: Try hit %d\n", candidateHit->id ) ;
1147  candidateHit->print ( 11 ) ;
1148 //
1149 // If the hit already used say it and forget about it
1150 //
1151  if ( candidateHit->track != 0 )
1152  {
1153  ftfLog ( "FtfTrack::debugFollowCandidate: hit %d used in track %d\n",
1154  candidateHit->id, id );
1155  debugAsk () ;
1156 // candidateHit->Show ( getPara()->color_candidate ) ;
1157  candidateHit->print ( 3 ) ;
1158  }
1159 }
1160 /*******************************************************************************
1161  Reconstructs tracks
1162 *********************************************************************************/
1163 void FtfTrack::debugFollowSuccess ( double dxy, double dsz, double lxyChi2,
1164  double lszChi2, double chi2_min,
1165  FtfHit *candidateHit ) {
1166 //
1167 // Check whether track needs to be debugged
1168 //
1169  if ( !getPara()->trackDebug ) return ;
1170  if ( getPara()->debugLevel < 2 ) return ;
1171 //
1172 // Show first level of info
1173 //
1174  double lchi2 = lxyChi2 + lszChi2 ;
1175 
1176  ftfLog ( " \n ------------------------------------- " ) ;
1177  if ( lchi2 < chi2_min ){
1178  ftfLog ( "FtfTrack::debugFollowSuccess: %f Best Chi2, keep point !!!\n",
1179  lchi2 );
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 !!! " );
1184  }
1185  }
1186  else{
1187  ftfLog ( "FtfTrack::debugFollowSuccess: Hit %d worse than previous, forget it !! ",
1188  candidateHit->id );
1189 // candidateHit->Show ( getPara()->color_track ) ;
1190  }
1191 
1192 
1193  ftfLog ( " \n ------------------------------------- " ) ;
1194 //
1195 // Show second level of info
1196 //
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 );
1206  }
1207  debugAsk() ;
1208 // candidateHit->Show ( getPara()->color_transparent ) ;
1209 }
1210 /*********************************************************************************
1211  Routine to look for segments.
1212  Segments are track starting chains
1213 *******************************************************************************/
1214 void FtfTrack::debugInVolume ( FtfHit *baseHit, FtfHit *candidateHit )
1215 {
1216 
1217  if ( getPara()->trackDebug && getPara()->debugLevel >= 2 ) {
1218 /*----------------------------------------------------------------------------
1219  Show the whole segment
1220 ----------------------------------------------------------------------------*/
1221 // for ( startLoop() ; done() ; nextHit() ) {
1222 // currentHit->Show ( getPara()->color_track ) ;
1223 // }
1224 
1225 // candidateHit->Show ( getPara()->color_candidate ) ;
1226 /*----------------------------------------------------------------------------
1227  Print relevant information
1228 ----------------------------------------------------------------------------*/
1229  if ( nHits > getPara()->nHitsForSegment+1 ) Print ( 31 ) ;
1230 
1231  ftfLog ( "FtfTrack:debugInVolume: Try hit %d\n", candidateHit->id ) ;
1232  candidateHit->print ( 11 ) ;
1233 /*----------------------------------------------------------------------------
1234  If the hit already used say it and forget about it
1235 ----------------------------------------------------------------------------*/
1236  if ( candidateHit->track != 0 ) {
1237  ftfLog ( "FtfTrack:debugInVolume: hit %d used in track %d\n",
1238  candidateHit->id, id+1 );
1239 // candidateHit->Show ( 0 );
1240  }
1241  else {
1242  double dphi = (double)fabs(baseHit->phi - candidateHit->phi) ;
1243  double deta ;
1244  if ( baseHit->dz < 1000 && candidateHit->dz < 1000 )
1245  deta = (double)fabs(baseHit->eta - candidateHit->eta) ;
1246  else
1247  deta = 0.F ;
1248 
1249  if ( dphi > getPara()->dphi )
1250  ftfLog ( "FtfTrack:debugInVolume: Hits too far apart in phi: %f \n",
1251  dphi ) ;
1252  if ( deta > getPara()->deta )
1253  ftfLog ( "FtfTrack:debugInVolume: Hits too far apart in eta: %f \n",
1254  deta ) ;
1255  }
1256  debugAsk () ;
1257  }
1258 }
1259 /*****************************************************************************
1260  Fill track information tables
1261 ******************************************************************************/
1262 void FtfTrack::debugNew ( )
1263 {
1264 
1265  if ( firstHit->id == getPara()->hitDebug ) getPara()->trackDebug = 1 ;
1266  if ( getPara()->trackDebug && getPara()->debugLevel >= 1 )
1267  {
1268  ftfLog ( "================================================ \n" );
1269  ftfLog ( "FtfTrack::debugNew:Starting track %d from point %d\n",
1270  id, firstHit->id );
1271  ftfLog ( "================================================ \n" );
1272 
1273 // firstHit->Show ( getPara()->color_track ) ;
1274  debugAsk () ;
1275  }
1276 }
1277 #endif
Definition: FtfHit.h:16