View Javadoc

1   package org.lcsim.recon.tracking.ftf;
2   public class FtfFinder
3   {
4       private   FtfTrack currentTrack;
5       
6       
7       public   FtfFinder( )
8       {
9       }
10      
11      //     Calculates deposited Energy
12      public   void    dEdx                    ( )
13      {
14          for ( int i = 0 ; i<nTracks ; i++ )
15          {
16              track[i].dEdx( ) ;
17          }
18      }
19      
20      // Recontruct primary tracks
21      public   int     getTracks               ( )
22      {
23          //
24          //     Set conformal coordinates if we are working with primaries
25          //
26          int nHitsSegment   = (short)para.nHitsForSegment;
27          if ( para.primaries!=0 )
28          {
29              setConformalCoordinates( ) ;
30              para.minHitsForFit = 1 ;
31              para.nHitsForSegment = Math.max(2,nHitsSegment);
32          }
33          else
34          {
35              para.minHitsForFit = 2 ;
36              para.nHitsForSegment = Math.max(3,nHitsSegment);
37          }
38          //
39          //               Loop over rows
40          //
41          for ( int ir = para.nRowsPlusOne - 1 ; ir>=para.minHitsPerTrack ; ir--)
42          {
43              //
44              //           Loop over hits in this particular row
45              //
46              //cng      if ( rowC[ir].first &&  (((FtfHit)rowC[ir].first).row) < para.rowEnd ) break ;
47              //    if ( (((FtfHit *)rowC[ir].first).row) < para.rowEnd ) break ;
48              for ( FtfHit firstHit = (FtfHit)rowC[ir].first ;
49              firstHit != null ;
50              firstHit = (FtfHit )(firstHit.nextRowHit) )
51              {
52                  //
53                  //     Check hit was not used before
54                  //
55                  if ( firstHit.track != null  ) continue ;
56                  //
57                  //     One more track
58                  //
59                  nTracks++ ;
60                  //
61                  //
62                  if ( nTracks > maxTracks )
63                  {
64                      System.out.println("\n FtfFinder::getTracks: Max nr tracks reached !") ;
65                      nTracks = maxTracks  ;
66                      return 1 ;
67                  }
68                  //
69                  //     Initialize variables before going into track hit loop
70                  //
71                  FtfTrack thisTrack = track[nTracks-1];
72                  thisTrack.para     = para ;
73                  thisTrack.id       = nTracks ;
74                  thisTrack.firstHit = thisTrack.lastHit = firstHit ;
75                  thisTrack.innerMostRow = thisTrack.outerMostRow = firstHit.row ;
76                  thisTrack.xRefHit  = firstHit.x ;
77                  thisTrack.yRefHit  = firstHit.y ;
78                  thisTrack.xLastHit = firstHit.x ;
79                  thisTrack.yLastHit = firstHit.y ;
80                  // TRDEBUG
81                  //cng         thisTrack.debugNew ( ) ;
82                  //
83                  //
84                  //              Set fit parameters to zero
85                  //
86                  thisTrack.reset( ) ;
87                  //
88                  //      Go into hit looking loop
89                  //
90                  if ( thisTrack.buildTrack( firstHit, volumeC ) !=0 )
91                  {
92                      //
93                      //    Merge Tracks if requested
94                      //
95                      if ( para.primaries !=0 &&
96                              para.mergePrimaries == 1 &&
97                              para.fillTracks &&
98                              thisTrack.mergePrimary( trackC )==0  )
99                      {
100                         nTracks-- ;
101                         thisTrack.deleteCandidate( ) ;
102                     }
103                 }
104                 else
105                 {
106                     //
107                     //      If track was not built delete candidate
108                     //
109                     thisTrack.deleteCandidate( ) ;
110                     nTracks-- ;
111                 }
112                 //
113                 //       End loop over hits inside row
114                 //
115             }
116             //       End loop over rows
117             //
118             //    Check time
119             //
120             if ( CpuTime() - initialCpuTime > para.maxTime )
121             {
122                 System.out.println( "FtfFinder::getTracks: tracker time out after \n"+ (CpuTime() - initialCpuTime) ) ;
123                 break ;
124             }
125         }
126         //
127         para.nHitsForSegment = nHitsSegment ;
128         //
129         return 0 ;
130     }
131     public   void    mergePrimaryTracks      ( )
132     {
133     }
134     
135     private static void log(String s)
136     {
137         System.out.println(s);
138     }
139     //      Steers the tracking
140     public   double  process( )
141     {
142         //-----------------------------------------------------------------
143         //        Make sure there is something to work with
144         //------------------------------------------------------------------
145         if ( nHits <= 0 )
146         {
147             if ( para.infoLevel > 2 )
148                 log( "fft: Hit structure is empty \n " ) ;
149             return 1 ;
150         }
151         //
152         initialCpuTime  = CpuTime( );
153         initialRealTime = RealTime( );
154         //
155         //        General initialization
156         //
157         if ( para.init == 0 )
158         {
159             if ( reset( )!=0 ) return 1 ;
160         }
161         //
162         //      Event reset and set pointers
163         //
164         if ( (para.eventReset!=0)  && (setPointers( )!=0) ) return 1 ;
165         //
166         //      Build primary tracks now
167         //
168         short i ;
169         para.primaries = 1 ;
170         for ( i = 0 ; i < para.nPrimaryPasses ; i++ )
171             if ( getTracks( )!=0 ) break ;
172         //
173         //      Look for secondaries
174         //
175         para.primaries = 0 ;
176         for ( i = 0 ; i < para.nSecondaryPasses ; i++ )
177             if ( getTracks( )!=0 ) break ;
178         
179         //   if ( para.dEdx ) dEdx ( ) ;
180         
181         cpuTime  = CpuTime  ( ) - initialCpuTime  ;
182         realTime = RealTime( ) - initialRealTime ;
183         //DEBUG
184         if ( para.infoLevel > 0 )
185             log(  "FtfFinder::process: cpu "+cpuTime+" real "+realTime+" \n" ) ;
186         //
187         return cpuTime ;
188     }
189     
190     
191     public   int     reset                   ( )
192     {
193         return 0;
194     }
195     public   int     setConformalCoordinates( )
196     {
197         return 0;
198     }
199     public   int     setPointers             ( )
200     {
201         return 0;
202     }
203     public   double  CpuTime                 ( )
204     {
205         return 0.;
206     }
207     public   double  RealTime                ( )
208     {
209         return 0.;
210     }
211     //
212     //
213     public   int           nHits      ;
214     public   int           nHitsOutOfRange ;
215     public   int           maxHits    ;
216     public   FtfHit        hit       ;
217     public   int           nTracks    ;
218     public   FtfTrack[]      track     ;
219     public   FtfPara       para       ;
220     public   int           maxTracks  ;
221     public  int           nMcTracks  ;
222     public   FtfMcTrack    mcTrack    ;
223     public   FtfContainer  volumeC ;
224     public   FtfContainer[]  rowC    ;
225     public   FtfContainer  trackC  ;
226     public  double        initialCpuTime ;
227     public  double        initialRealTime ;
228     public  double        cpuTime ;
229     public   double        realTime ;
230     
231     
232 }