SUBROUTINE FTREC
*-- Author : S.J. Maxfield
      SUBROUTINE FTREC
**----------------------------------------------------------------------                                      
*D: FPMAC  80700 SB. Sequence FPPRAM changed:                                                                 
*S: FPPRAM 80700 SB. MSEGLM reduced to 150 (from 250) to reduce cpu time                                      
*D: FPSOUT 80700 SB. Make FPSG bank without IADROW, downscale histograms                                      
*D: FRSOUT 80700 SB. Downscale histograms                                                                     
*D: FPLOCO 80700 SB. Downscale histograms                                                                     
*D: FRLOCO 80700 SB. Downscale histograms                                                                     
*D: FVZFIT 80700 SB. Hit database only at the beginning of a run                                              
*D: FTRNDB 80700 SB. Reset LOOK area to FTREC 1 at end                                                        
*D: FPDG4  80700 SB. Break out of loop when array limit is reached                                            
*D: FPCXTD 80700 SB. Histograms only if FTTUNE is selected                                                    
*D: FTJN3  80700 SB. Histograms only if FTTUNE is selected                                                    
*D: FTLSEG 80700 SB. Histograms only if FTTUNE is selected                                                    
*D: FPLPKS 80700 SB. Histograms only if IDOHIS is 2                                                           
*D: FPTHIS 80700 SB. Book some histograms only if FTTUNE is selected                                          
*D: FPTHIS 80700 SB. Reduce number of channels for some 2-D histograms                                        
*D: FFFIT  80700 SB. Reject single radial tracks early                                                        
*D: FFKLMN 80700 SB. Call FFTRF for faster calculation of fine correctio                                      
*D: FFTRF  80700 SB. New routine: fast version of FKTRAN                                                      
*D: FFCORR 80700 SB. Pass B field to avoid call to GUFLD                                                      
*D: FKHUNT 80700 SB. Pass B field value to FFCORR                                                             
*D: FFOUT  80700 SB. Downscale some per-hit histograms                                                        
*D: FFHTHS 80700 SB. Downscale some per-hit histograms                                                        
*D: FFHTHS 80700 SB. Restore residuals vs. Q histograms                                                       
*D: FFRJCT 80700 SB. Ask for at least 9 hits on radial-only tracks                                            
*D: FTRMON 80700 SB. Get histograms from the correct area                                                     
**----------------------------------------------------------------------                                      
*D: Various80600 GP. HTML comments added                                                                      
*D: FTREC  80600 GP. Add call to FTRNDB on BEGRUN                                                             
*D: FTRNDB 80600 GP. New monitoring routine (puts v and t0 in an ntuple)                                      
*D: FDBGET 80600 GP. New monitoring routine (get v and t0 from db)                                            
*D: FDBGTL 80600 GP. New monitoring routine (get Lorenz angle)                                                
*D: FFBKLK 80600 SB. Residuals vs. Q plots added to standard set                                              
*D: FFHTHS 80600 SB. Residuals vs. Q plots added to standard set                                              
*D: FFKLMN 80600 SB. Change use of FKTRAN to increase speed                                                   
*D: FFEVT0 80600 SB. Hit database only on new run (saves time)                                                
*D: FTDSGI 80600 SB. Vertex/T0 selection only for real data                                                   
**----------------------------------------------------------------------                                      
*D: FPPJ12 80503 SB. Comment out redundant line                                                               
*D: FPPJ23 80503 SB. Comment out redundant line                                                               
**----------------------------------------------------------------------                                      
*D: FPMAC  80500 SB. Change to FPPRAM:                                                                        
*S: FPPRAM 80500 SB. MAXSEG decreased to 200 to reduce cpu time                                               
*D: FPKPKR 80500 IS. New segment linking code                                                                 
*D: FPLKPR 80500 IS. New segment linking code                                                                 
*D: FRPKPL 80500 IS. New segment linking code                                                                 
*D: FPLPKP 80500 IS. New segment linking code                                                                 
*D: FPLPKS 80500 IS. New segment linking code                                                                 
*D: FREFIT 80500 IS. New segment linking code                                                                 
*D: FPTHIS 80500 SB. Book timing histograms unconditionally                                                   
*D: FTMSGI 80500 SB. Downscale FT monitoring by a factor of ten                                               
**----------------------------------------------------------------------                                      
*D: FEORMAC80400 GP. New sequence FHLUN:                                                                      
*S: FHLUN  80400 GP. Common block with unit numbers                                                           
*D: FQBOOK 80400 GP. Change histogram booking                                                                 
*D: FQMONP 80400 GP. Small change                                                                             
*D: FQMONR 80400 GP. Small change                                                                             
*D: FTDEOR 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FLK2HB 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: GETEAR 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FTQINT 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FBOOKQ 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FPEAKF 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FSUMP  80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FSUMR  80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FTRMON 80400 GP. Allow for running offline with PRIVOFFL flag                                             
*D: FOFFLM 80400 GP. New deck for running offline with PRIVOFFL flag                                          
*D: FLASTR 80400 GP. New deck for running offline with PRIVOFFL flag                                          
*D: FLASTP 80400 GP. New deck for running offline with PRIVOFFL flag                                          
*D: FMOUTP 80400 GP. New deck for running offline with PRIVOFFL flag                                          
*D: FMOUTR 80400 GP. New deck for running offline with PRIVOFFL flag                                          
*D: FMEANT 80400 GP. New deck for running offline with PRIVOFFL flag                                          
*D: FMSLCT 80400 KM. Farm change                                                                              
*D: FPLOCO 80400 SB. Make fine correction to T0 for data                                                      
*D: FTREC  80400 SB. Don't re-initialise on BEGRUNs after the first                                           
*D: FPTHIS 80400 SB. Book timing histograms by default                                                        
*D: FPPJN3 80400 IS. FPPHIT called to check link in phi                                                       
*D: FPPJ12 80400 IS. FPPHIT called to check link in phi                                                       
*D: FPPJ23 80400 IS. FPPHIT called to check link in phi                                                       
*D: FPPJ13 80400 IS. FPPHIT called to check link in phi                                                       
*D: FPPHIT 80400 IS. New deck to check linking in phi                                                         
**----------------------------------------------------------------------                                      
*D: FMOMAC 80300 SB. Allow for more monitoring histograms                                                     
*S: FMOHIS 80300 SB. Allow for more monitoring histograms                                                     
*D: FPTINT 80300 KM. Farm changes                                                                             
*D: FPLOCO 80300 SB. Fine T0 correction (inner/outer wires); farm change                                      
*D: FRLOCO 80300 SB. Farm changes                                                                             
*D: FTREC  80300 SB. Farm changes                                                                             
*D: FTQUIC 80300 SB. Farm changes                                                                             
*D: FFKLCH 80300 SB. Farm changes                                                                             
*D: FQBOOK 80300 GP. Changes to monitoring histograms                                                         
*D: FQMONP 80300 GP. Changes to monitoring histograms                                                         
*D: FQMONR 80300 GP. Changes to monitoring histograms                                                         
*D: FILLQR 80300 GP. Changes to monitoring histograms                                                         
*D: FBOOKQ 80300 GP. Changes to monitoring histograms                                                         
**----------------------------------------------------------------------                                      
*D: FFHTHS 71100 SB. Change to C2 histograms                                                                  
**----------------------------------------------------------------------                                      
*D: FPLOCO 70908 SB. Fix swapped channels for '94 data                                                        
*D: FPFIX  70908 SB. Fix swapped channels for '94 data                                                        
**----------------------------------------------------------------------                                      
*D: FMSLCT 70903 SB. Change cut on event T0 to use DB value                                                   
**----------------------------------------------------------------------                                      
*D: FTDEOR 70901 GP. Bug fix for nonexistent FTDSGI area                                                      
**----------------------------------------------------------------------                                      
*D: FTDEOR 70400 GP. More histograms monitored.                                                               
*D: FLK2HB 70400 GP. More histograms monitored.                                                               
*D: FTRMON 70400 GP. More histograms monitored.                                                               
*D: FPFSTS 70400 SB. Initialisation of NEVENT removed (!)                                                     
**----------------------------------------------------------------------                                      
*D: FTDSGI 70303 SB. Call FMSLCT to reject events with bad timing.                                            
*D: FTMSGI 70303 SB. New routine to call FTDSGI without calling FTREC.                                        
*D: FMSLCT 70303 SB. Select events with good timing and vertex.                                               
*D: FFRCEL 70303 SB. Fix bug in drift calculation.                                                            
*D: FFHTHS 70303 SB. Put R cut on radial drift distribution.                                                  
**----------------------------------------------------------------------                                      
*D: FPLOCO 70211 SB. New monitoring histograms for event T0.                                                  
*D: FPTHIS 70211 SB. New monitoring histograms for event T0.                                                  
*D: FFBKLK 70211 SB. New checksum histograms; units added to axes.                                            
*D: FFHTHS 70211 SB. New checksum histograms.                                                                 
**----------------------------------------------------------------------                                      
*D: FKHIST 70211 SB. Bug fix for point rejection printout.                                                    
*D: FTREC. 70211 SB.  Initialise IGTTRK array; do peakparm for new histo                                      
*D: FRPKPL 70211 SM. Zero IGTTRK.                                                                             
**----------------------------------------------------------------------                                      
*D: FPKPKR 70211 IS. New linking code; remove cosmic version.                                                 
*D: FPLKPR 70211 IS. New linking code; remove cosmic version.                                                 
*D: FTFIT. 70211 IS.  New linking code.                                                                       
*D: FPCXTD 70211 IS. New linking code.                                                                        
*D: FPLPKS 70211 IS. New linking code.                                                                        
*D: FPATUT 70211 SM. Allow for invalid radial segments.                                                       
*D: FSINGR 70211 SM. Allow for invalid radial segments.                                                       
*D: FRSOUT 70211 SB. Exclude invalid segments from FRSG.                                                      
**----------------------------------------------------------------------                                      
*S: FPMAC  70211 SB.  New variables DWG, DRIWP and DRIWM in /H1WORK/.                                         
*D: FPUDAT 70211 SB. Use asymmetric drifts in planar patrec.                                                  
*D: FPDG4  70211 SB.  Use asymmetric drifts in planar patrec.                                                 
*D: FPFSSG 70211 SB. Use asymmetric drifts in planar patrec.                                                  
**----------------------------------------------------------------------                                      
*B: FTT0   70200 SB. New bank with event T0.                                                                  
*D: FPLOCO 70200 SB. Add FTT0 bank and monitoring histograms.                                                 
*D: FPTHIS 70200 SB. New monitoring histograms for event T0.                                                  
*D: FFBKLK 70200 SB. Used hit histograms altered.                                                             
*D: FFOUT  70200 SB. Used hit histograms altered.                                                             
*D: FFHTHS 70200 SB. Only make C1, C2 if all 4 hits are in the same cell                                      
**----------------------------------------------------------------------                                      
*D: FTJN3  70100 SB.  Linking bug fix.                                                                        
*D: FFOUT  70100 SB.  Radial segment quality written to FTKR word 20.                                         
*D: FFCORR 70100 SB. New correction for B-field variation.                                                    
*D: FFCORR 70100 SB. Small updates to drift vel. and Lorenz angle.                                            
*D: FFCORR 70100 SB. DEVT0 is now passed as an argument (and histogramme                                      
*D: FFKLMN 70100 SB. Changed argument list to FFCORR (DEVT0 added).                                           
*D: FKHUNT 70100 SB. Changed argument list to FFCORR (DEVT0 added).                                           
*D: FFEVT0 70100 SB. DEVT0 is now the change in T0, not drift distance.                                       
*D: FTREC  70100 SB.  Print peakparm values with LOOK histograms.                                             
*D: FFHBK  70100 SB.  New diagnostic histograms (small corrections).                                          
*D: FPT0   70100 SB.   Always compile, add trigger element names.                                             
*D: FFEND  70100 SB.  FPT0 diagnostic histograms written out.                                                 
*D: FPT02  70100 SB.  Obsolete.                                                                               
**----------------------------------------------------------------------                                      
*B: FTGX 70006 SB.   New bank to connect FTGR to FTKR.                                                        
*D: FVZFIT 70006 SB. Create the new FTGX bank.                                                                
*D: FVFIT 70006 SB.  Define the format of the new FTGX bank.                                                  
*D: FVZWM 70006 SB.  Fill the new FTGX bank.                                                                  
*D: FVXTRP 70006 SB. Small fix for use of nominal vertex.                                                     
*D: FVZFIT 70006 SB. Bug fixes for debug printout.                                                            
*D: FVZWM 70006 SB.  Bug fixes for debug printout.                                                            
**----------------------------------------------------------------------                                      
*D: FPIINT 70004 SB. Initialise STP, CTP.                                                                     
*D: FPINIT 70004 SB. Initialise STP, CTP.                                                                     
*D: FTDGEO 70004 SB. Initialise STP, CTP.                                                                     
*S: FPMAC 70004 SB.  DRMASK now LOGICAL, new variables STP, CTP.                                              
*D: FPDG31 70004 SB. Various speedups.                                                                        
*D: FPDG32 70004 SB. Various speedups.                                                                        
*D: FPDG33 70004 SB. Various speedups.                                                                        
*D: FPDG4 70004 SB.  Various speedups.                                                                        
*D: FPFSSG 70004 SB. Various speedups.                                                                        
*D: FPFTSG 70004 SB. Various speedups.                                                                        
*D: FPSSGF 70004 SB. Various speedups.                                                                        
*D: FPDCA 70004 SB.  Various speedups.                                                                        
*D: FPNDCA 70004 SB. New, faster version of FPDCA.                                                            
*D: FPPBIN 70004 RH. Generate lookup table for FPPROB.                                                        
*D: FPPROB 70004 RH. PROB replacement using lookup table.                                                     
**----------------------------------------------------------------------                                      
*D: FTDPAT 70004 IS. Pick up connected planar segments.                                                       
*D: FPCXTD 70004 IS. New routine to pick up connected planars.                                                
*D: FPSPC 70004 IS.  New routine to pick up connected planars.                                                
**----------------------------------------------------------------------                                      
*D: FTCORG 70004 SM. Remove fix for effective stagger.                                                        
*D: FPPJN3 70004 IS. New monitoring histograms.                                                               
*D: FPTHIS 70004 IS. New monitoring histograms.                                                               
*D: FKPRNT 70004 SB. Bug fix for large track numbers.                                                         
*D: FFOUT 70004 SB.  Make histograms for 2 and 3 radial tracks.                                               
**----------------------------------------------------------------------                                      
*S: FTMMAC 70004 SB. Obsolete.                                                                                
*D: FCSWIM 70004 SB. Obsolete.                                                                                
*D: FPDDIS 70004 SB. Obsolete.                                                                                
*D: FPTFPT 70004 SB. Obsolete.                                                                                
*D: FPTOUT 70004 SB. Obsolete.                                                                                
*D: FRDDIS 70004 SB. Obsolete.                                                                                
*D: FZDCA 70004 SB.  Obsolete.                                                                                
*D: FTNTRK 70004 SB. Obsolete.                                                                                
*D: FTDHTC 70004 SB. Obsolete.                                                                                
*D: FCFOXY 70004 SB. Obsolete.                                                                                
*D: FLINE 70004 SB.  Obsolete.                                                                                
*D: FLNKRS 70004 SB. Obsolete.                                                                                
*D: FSEGRS 70004 SB. Obsolete.                                                                                
*D: FTMAB 70004 SB.  Obsolete.                                                                                
*D: FTMABP 70004 SB. Obsolete.                                                                                
*D: FTMABS 70004 SB. Obsolete.                                                                                
*D: FTMABT 70004 SB. Obsolete.                                                                                
*D: FTMAT2 70004 SB. Obsolete.                                                                                
*D: FTMATB 70004 SB. Obsolete.                                                                                
*D: FTMINV 70004 SB. Obsolete.                                                                                
*D: FTSQ 70004 SB.   Obsolete.                                                                                
*D: FTTRAC 70004 SB. Obsolete.                                                                                
*D: FTUTOH 70004 SB. Obsolete.                                                                                
*D: FTVTOH 70004 SB. Obsolete.                                                                                
*D: FPLPK1 70004 SB. Obsolete.                                                                                
*D: FRFAIL 70004 SB. Obsolete.                                                                                
**----------------------------------------------------------------------                                      
*D: FTREC  60014 SB.   CTKV dependence removed to aid reprocessing                                            
*D: FTREC  60004 SB.   Abort reconstruction for very large events                                             
**----------------------------------------------------------------------                                      
*D: FPPJN3 60000 IS.  Array bounds increased to 100 in /FTPLNK/                                               
*D: FPPJ12 60000 IS.  Array bounds increased to 100 in /FTPLNK/                                               
*D: FPPJ23 60000 IS.  Array bounds increased to 100 in /FTPLNK/                                               
*D: FPPJ13 60000 IS.  Array bounds increased to 100 in /FTPLNK/                                               
*D: FFCHEK 60000 SB.  Small bug fix in efficiency calculation                                                 
*D: FFKLMN 60000 SB.  Veto bad tracks before diagnostics                                                      
*D: FFOUT  60000 SB.   Don't flag empty segments as tertiary!                                                 
**----------------------------------------------------------------------                                      
*S: FPMAC  60000 SB.  MAXCLU increased to 100                                                                 
*S: FPMAC  60000 SB.  New common FPSTSG                                                                       
*D: FPSOUT 60000 SB.  MASKSG in FPSG extended.                                                                
*D: FFOUT  60000 SB.   Flag 2ry/3ry segments in NHIT word                                                     
*D: FPTINT 60000 SB.  Parameter printout by default                                                           
**----------------------------------------------------------------------                                      
*D: FFHBK  60000 SB.   New diagnostic histograms                                                              
*D: FFCHEK 60000 SB.  New diagnostic histograms                                                               
*D: FFBKLK 60000 SB.  New monitoring histograms                                                               
*D: FFOUT  60000 SB.   Restore some monitoring histograms                                                     
*D: FKHUNT 60000 SB.  Add timing corrections, correct track angle correc                                      
*D: FFFILL 60000 SB.  New routine to fill KF common blocks                                                    
*D: FFEVT0 60000 SB.  New routine to perform the event T0 correction                                          
*D: FFCORR 60000 SB.  New routine to perform timing/track angle correcti                                      
*D: FFSTART 60000 SB. New routine to set up KF starting vector                                                
*D: FFKLMN 60000 SB.  Move some code into subroutines                                                         
**----------------------------------------------------------------------                                      
*D: FVZWM  60000 SB.   New z-vertex algorithm                                                                 
*D: FVTRUE 60000 SB.  Use FVXPRM to defined primary tracks                                                    
*D: FVZFIT 60000 SB.  New z-vertex algorithm                                                                  
*D: FVZFIT 60000 SB.  Multiple vertices in FTGR                                                               
*D: FVBKLK 60000 SB.  New monitoring histograms                                                               
*D: FVXTRP 60000 SB.  Pass the nominal z-vertex as an argument                                                
**----------------------------------------------------------------------                                      
*D: FFFIT  60000 SB.   Trap bank problems                                                                     
*D: FTDHTC 60000 SB.  Avoid overflows                                                                         
*D: FRLOCO 60000 SB.  Protect against zero charge                                                             
*D: FILHTS 60000 SM.  Protect against corrupt pointers                                                        
*D: FTVDET 60000 SB.  Protect against division by zero                                                        
*D: FPPJ13 60000 SB.  Eliminate compiler warning                                                              
*D: FPFSEG 60000 SB.  Comment out use of IUCLU (unused)                                                       
*D: FPFYUV 60000 SB.  Suppress printout                                                                       
**----------------------------------------------------------------------                                      
*D: FPTINT 60000 SM.  Modifications to FPPP bank for new linking.                                             
*D: FPLPKP 60000 IS.  Different cuts for 2ry/3ry planar segments                                              
*D: FPPJN3 60000 IS.  Different cuts for 2ry/3ry planar segments                                              
*D: FPPJ12 60000 IS.  Different cuts for 2ry/3ry planar segments                                              
*D: FPPJ23 60000 IS.  Different cuts for 2ry/3ry planar segments                                              
*D: FPPJ13 60000 IS.  Different cuts for 2ry/3ry planar segments                                              
**----------------------------------------------------------------------                                      
*D: FPLINT 60000 RH.  Add calls for 2ry/3ry segments                                                          
*D: FPFSSG 60000 RH.  Find 2ry planar segments                                                                
*D: FPFTSG 60000 RH.  Find 3ry planar segments                                                                
*D: FPDCA  60000 RH.   New utility routine (find dca between vectors)                                         
*D: FPFSTS 60000 RH.  Fit 2ry/3ry planar segments                                                             
*D: FPSSGF 60000 RH.  Check connectivity of 2ry/3ry planar segments                                           
**----------------------------------------------------------------------                                      
*S: FRMAC  60000 SM.  Sequence FJNPAR changed.                                                                
*D: FPTINT 60000 SM.  Modifications to FPRP bank for new linking.                                             
*D: FTJN3  60000 .SM.  New radial radial linking.                                                             
*D: FTJN12 60000 SM.  New radial radial linking.                                                              
*D: FTJN23 60000 SM.  New radial radial linking.                                                              
*D: FTJN13 60000 SM.  New radial radial linking.                                                              
*D: FTCHKH 60000 SM.  New radial radial linking.                                                              
**----------------------------------------------------------------------                                      
*D: FPTVER 60000 SM.  Fix vertex.                                                                             
*D: FPATUT 60000 SM.  Add FAUX bank to R list.                                                                
*D: FTLSEG 60000 SM.  De-SELECT some unbooked histograms.                                                     
*D: FTDPAT 60000 SM.  Correct SAREA call.                                                                     
*D: FPTHIS 60000 SM.  Book some unbooked histograms.                                                          
*D: FPTREZ 60000 SM.  Remove a bug with x-y vertex shift.                                                     
**----------------------------------------------------------------------                                      
*D: FRDT2D 60000 SM.  New radial t-to-d function for asymmetry.                                               
*D: FTCORG 60000 SM.  Extension of FRG1 bank to include asymmetry.                                            
*D: FTCORG 60000 SM.  Get effective stagger from new FCR3 bank.                                               
*D: FTCORG 60000 SM.  Extension of FPG1 bank to include asymmetry.                                            
*D: FTCORG 60000 SM.  Get effective stagger from FCP1 bank.                                                   
*D: FPLOCO 60000 SM.  Allow for near/far asymmetry. Extend FPLC bank,                                         
*D: FPLOCO 60000 SM.  get stagger from FGAP.                                                                  
*D: FPLOCO 60000 SB.  Correct for trigger in wrong bunch crossings.                                           
*D: FRLOCO 60000 SM.  Introduce asymmetry and wire-plane velocity                                             
*D: FRLOCO 60000 SM.  factors. New parameters ex FCR3 bank.                                                   
*D: FTREC  60000 SM. Tidy LOOK output.                                                                        
**----------------------------------------------------------------------                                      
*D: FFEND  50108 SB.  New routine for end-of-run printout                                                     
*D: FFOUT  50108 SB.  New parameters in call.                                                                 
*D: FFBKLK 50108 SB.  Changes to monitoring histograms.                                                       
**----------------------------------------------------------------------                                      
*D: FFFIT  50106 SB.  New parameters in FFOUT call.                                                           
*D: FFKLMN 50106 SB   Bug fix for low momentum.                                                               
*D: FKLXYZ 50106 SB   Protect against divide by 0.                                                            
**----------------------------------------------------------------------                                      
*D: FVZFIT 50004 GR   replace  CJGR by CJKV bank                                                              
**----------------------------------------------------------------------                                      
*D: FFKLMN 50003 SB   bug fix                                                                                 
**----------------------------------------------------------------------                                      
*D: FPTINT 40313 GR   replace UGTBNK call for rundependent MC banks                                           
**----------------------------------------------------------------------                                      
*D: FTDPAT 40312 RP.  printout removed for L4                                                                 
*D: FMOMAC 40312 SB.  (common) save statement included for L4                                                 
**----------------------------------------------------------------------                                      
*D: FVXTRP 40310 GR.  replace OSVX by SIPA for default MC vertex                                              
**----------------------------------------------------------------------                                      
*D: FVFIT  40309 SB.  bug corrected in initialisation                                                         
**----------------------------------------------------------------------                                      
*D: FTCORG 40303 GR.  replace UGTBNK calls for rundependent MC banks                                          
**----------------------------------------------------------------------                                      
*D: FVXTRP 40302 GR.  bug fixed (missing BOS common)                                                          
**----------------------------------------------------------------------                                      
*D: FVXTRP 40301 SB.  get default vertex from DB                                                              
*D: FSETMC 40301 SB.  update version handling                                                                 
**----------------------------------------------------------------------                                      
*D: FTREC  40100 SM.  CALL new module FTDMON which was running at L4.                                         
**----------------------------------------------------------------------                                      
*D: FTREC  40011 SM.  Make FPKANL call SELECTable. Default- no call.                                          
*D: FTREC  40011 SM.  Move FPOKER call into FTDPAT.                                                           
*D: FFBKLK 40011 SB.  Changes to monitoring histograms.                                                       
*D: FFFIT  40011 SB.   New parameters in FFOUT call.                                                          
*D: FFKLMN 40011 SB.  Farm changes.                                                                           
*D: FFKLMN 40011 SB.  New params in FFOUT call.                                                               
*D: FFKLMN 40011 SB.  Debug histos only for .GE.2 planar segs.                                                
*D: FFOUT  40011 SB.   New parameters in call.                                                                
*D: FFOUT  40011 SB.   New monitoring histograms.                                                             
*D: FFOUT  40011 SB.   Fix FTPR bug.                                                                          
*D: FPLOCO 40011 SB.  Correct for trigger in wrong bunch crossings.                                           
*D: FRLOCO 40011 SB.  Correct for trigger in wrong bunch crossings.                                           
*D: FPATUT 40011 SM.  Put supermodule mask in FTUR bank.                                                      
*D: FTDPAT 40011 SM.  Add call to FPOKER. Add call to FPRFIT                                                  
*D: FPRFIT 40011 SM.  New routine to improve track parameters.                                                
*D: FPKPKR 40011 SM.  Improved segment linking.                                                               
*D: FTLSEG 40011 SM.  Improved segment finding.                                                               
*D: FTLISA 40011 SM.  Improved segment finding.                                                               
*D: FCFOXY 40011 SM.  Bug fix                                                                                 
*D: FPPJN3 40011 SM.  Bug fix and add Chisq cut.                                                              
*D: FPPJ12 40011 SM.  Add Chisq cut.                                                                          
*D: FPPJ23 40011 SM.  Add Chisq cut.                                                                          
*D: FPPJ13 40011 SM.  Add Chisq cut.                                                                          
*D: FPTREZ 40011 SM.  Add Chisq cut.                                                                          
*D: FPOKER 40011 SM.  Add Lorentz angle histograms.                                                           
*D: FPKANL 40011 SM.  Add Lorentz angle histograms.                                                           
*D: FPTHIS 40011 SM.  Bug fix.                                                                                
**----------------------------------------------------------------------                                      
*D: FTREC  40011 SB.  Reinstate call to FPKANL.                                                               
*D: FPK1LO 40011 SB. Compile only when FDOCAL is selected.                                                    
*D: FPOKER 40011 SM. Bugs in histogram booking corrected.                                                     
*D: FPKANL 40011 SM. Now more friendly to machines other than DESY IBM.                                       
**----------------------------------------------------------------------                                      
*D: FPLPKP 40002 RG.  SGI..                                                                                   
*D: FTLSEG 40002 RG.  SGI..                                                                                   
**----------------------------------------------------------------------                                      
*D: FVTEXT 40001 SB. Turn off momentum cuts for zero field.                                                   
*D: FVZFIT 40001 SB. Ignore CT z-vertex if z=0.0.                                                             
*D: FPKANL 40001 SB. Compile only on DESY IBM.                                                                
*D: FPK1LO 40001 SB. Compile only on DESY IBM.                                                                
*D: FPPJ12 40001 IS. Small bug fixed.                                                                         
*D: FKTRAN 40001 SB. Cope better (?) with zero field.                                                         
*D: FKETOI 40001 SB. Cope better (?) with zero field.                                                         
*D: FKITOE 40001 SB. Cope better (?) with zero field.                                                         
*D: FFTEXT 40001 SB. Turn off momentum cuts for zero field.                                                   
*D: FTCAL 40001 SB.  Remove illegal character.                                                                
*D: FTCALP 40001 SB. Remove illegal character.                                                                
**----------------------------------------------------------------------                                      
*D: FTREC 40000 SM.  New call to FPOKE/FPKANL.                                                                
*D: FTREC 40000 SB.  No more garbage collection.                                                              
*D: FPTPDT 40000 SM. New definition of dead wire flag.                                                        
*D: FPTRDT 40000 SM. New definition of dead wire flag.                                                        
*D: FPWHIT 40000 SM. New definition of dead wire flag.                                                        
*D: FRCART 40000 SM. New definition of dead wire flag.                                                        
*D: FRLOCO 40000 SM. Make new temporary bank FAUX.                                                            
*D: FVFIT 40000 SB.  No more garbage collection.                                                              
*D: FVZFIT 40000 SB. Don't make a z-vertex if error is too big.                                               
*D: FVXTRP 40000 SB. Fix bug in xy vertex histos.                                                             
*D: FVBKLK 40000 SB. Change scale on xy vertex histos.                                                        
*D: FCFOXY 40000 SM. New definition of dead wire flag.                                                        
*D: FTQUIC 40000 SB. New deck to give a guess at no. of tracks.                                               
*D: FPOKER 40000 SM. New routine for calibration checking.                                                    
*D: FPKANL 40000 SM. New routine for calibration checking.                                                    
*D: FPK1LO 40000 SM. New routine for calibration checking.                                                    
*D: FPLPKP 40000 SM. New debug histos.                                                                        
*D: FPPJN3 40000 IS. New linking code.                                                                        
*D: FPPJ12 40000 IS. New linking code.                                                                        
*D: FPPJ23 40000 IS. New linking code.                                                                        
*D: FPPJ13 40000 IS. New linking code.                                                                        
*D: FPSP 40000 SM.   Undo +SEQ expansion.                                                                     
*D: FPCHI 40000 IS.  New routine to calculate chi-squared.                                                    
*D: FTFHQQ 40000 IS. New linking code.                                                                        
*D: FTJN12 40000 IS. New linking code.                                                                        
*D: FTJN13 40000 IS. New linking code.                                                                        
*D: FTJN23 40000 IS. New linking code.                                                                        
*D: FTJN3 40000 IS.  New linking code.                                                                        
*D: FTLSEG 40000 SM. New monitoring histos.                                                                   
*D: FTLISA 40000 SM. Initialise RR (else DDMIN*RR test might fail?).                                          
*D: FTLISA 40000 SM. Add SEQ BOSMDL so farm change might work.                                                
*D: FTCHKH 40000 IS. New linking routine.                                                                     
*D: FPDG31 40000 RH. New steering parameter.                                                                  
*D: FPDG32 40000 RH. New steering parameter.                                                                  
*D: FPDG33 40000 RH. New steering parameter.                                                                  
*D: FPUDAT 40000 SM. New definition of dead wire flag.                                                        
*D: FPDG4 40000 RH.  New steering parameters; use true resolution.                                            
*D: FPT0 40000 SB.   New routine to plot DT vs. trigger element.                                              
*D: FPTHIS 40000 SM. New monitoring/debug histos.                                                             
*D: FKITOE 40000 SB. Only print field warning in production run.                                              
*D: FFKAL 40000 SB.  No more garbage collection.                                                              
*D: FFPHNT 40000 SB. New definition of dead wire flag.                                                        
*D: FFRHNT 40000 SB. New definition of dead wire flag.                                                        
*D: FFRJCT 40000 SB. Min. no. of hits for radial-only tracks.                                                 
*D: FFCHEK 40000 SB. New definition of dead wire flag.                                                        
*D: FFTRCH 40000 SB. New definition of dead wire flag.                                                        
*D: FTMMON 40000 SB. No more garbage collection.                                                              
*D: FCALIB 40000 SB. No more garbage collection.                                                              
**----------------------------------------------------------------------                                      
*D: FTREC  30907 RP. Farm changes.                                                                            
*D: FPLOCO 30907 RP. Farm changes.                                                                            
*D: FPTPDT 30907 RP. Farm changes.                                                                            
*D: FPTRDT 30907 RP. Farm changes.                                                                            
*D: FRLOCO 30907 RP. Farm changes.                                                                            
*D: FTCORG 30907 RP.  Farm changes.                                                                           
*D: FPSOUT 30907 RP. Farm changes.                                                                            
*D: FRSOUT 30907 RP. Farm changes.                                                                            
*D: FRSGST 30907 SM. Allow for 12-wire readout.                                                               
*D: FVFIT  30907 RP. Farm changes.                                                                            
*D: FVFIT  30907 SB. Initialise LUN at BEGJOB.                                                                
*D: FVZFIT 30907 SB. Change monitoring histograms.                                                            
*D: FVZFIT 30907 RP. Farm changes.                                                                            
*D: FVZWM  30907 RP. Farm changes.                                                                            
*D: FVXTRP 30907 SB. Change monitoring histograms.                                                            
*D: FVXTRP 30907 RP. Farm changes.                                                                            
*D: FVBKLK 30907 SB. Change monitoring histograms.                                                            
*D: FVBKLK 30907 SB. Vertex monitoring histograms added.                                                      
*D: FPKPKR 30907 RP. Farm changes.                                                                            
*D: FPLKPR 30907 RP. Farm changes.                                                                            
*D: FPLPKP 30907 RP. Farm changes.                                                                            
*D: FPPJN3 30907 RP. Farm changes.                                                                            
*D: FPPJ12 30907 RP. Farm changes.                                                                            
*D: FPPJ23 30907 RP. Farm changes.                                                                            
*D: FPPJ13 30907 RP. Farm changes.                                                                            
*D: FTDPAT 30907 RP. Farm changes.                                                                            
*D: FRPKPL 30907 RP. Farm changes.                                                                            
*D: FTMERG 30907 RP. Farm changes.                                                                            
*D: FTPRTR 30907 RP. Farm changes.                                                                            
*D: FPATUT 30907 RP. Farm changes.                                                                            
*D: FPSP   30907 RP. Farm changes.                                                                            
*D: FSINGR 30907 RP. Farm changes.                                                                            
*D: FTLSEG 30907 RP. Farm changes.                                                                            
*D: FTLISA 30907 RP. Farm changes.                                                                            
*D: FPDG31 30907 RH. Bug fix in cluster finding.                                                              
*D: FPDG32 30907 RH. Bug fix in cluster finding.                                                              
*D: FPDG33 30907 RH. Bug fix in cluster finding.                                                              
*D: FPUDAT 30907 RP. Farm changes.                                                                            
*D: FPDG4  30907 RH. Bug fix in cluster finding.                                                              
*D: FPFPLC 30907 RP. Farm changes.                                                                            
*D: FPFRLC 30907 RP. Farm changes.                                                                            
*D: FPTHIS 30907 RP. Farm changes.                                                                            
*D: FKCHXY 30907 SB. Function now (correctly) double precision.                                               
*D: FKEM   30907 SB. Change 'error 17' message.                                                               
*D: FKNORM 30907 SB. Error 17 now tan(theta)>5.                                                               
*D: FFBKLK 30907 SB. Changes to monitoring histograms.                                                        
*D: FFBKLK 30907 RP. Farm changes.                                                                            
*D: FFBKLK 30907 SB. Correct bad update.                                                                      
*D: FFFIT  30907 SB. Changes to monitoring histograms.                                                        
*D: FFFIT  30907 RP. Farm changes.                                                                            
*D: FFKAL  30907 RP. Farm changes.                                                                            
*D: FFKLMN 30907 RP. Farm changes.                                                                            
*D: FFOUT  30907 SB. Changes to monitoring histograms.                                                        
*D: FFOUT  30907 RP. Farm changes.                                                                            
*D: FFPHNT 30907 RP. Farm changes.                                                                            
*D: FFPLAN 30907 RP. Farm changes.                                                                            
*D: FFRAD  30907 RP. Farm changes.                                                                            
*D: FFRHNT 30907 RP. Farm changes.                                                                            
*D: FFHUNT 30907 RP. Farm changes.                                                                            
*D: FFKILL 30907 SB. Changes to monitoring histograms.                                                        
*D: FFKILL 30907 RP. Farm changes.                                                                            
*D: FTMPCH 30907 RP. Farm changes.                                                                            
*D: FTMPTO 30907 RP. Farm changes.                                                                            
**----------------------------------------------------------------------                                      
*D: FTREC  30901 SM. Its all new.                                                                             
*S: FRMAC  30901 SM. sequence FSGPAR changed.                                                                 
*T: FPRP   30901 SM. New calibration banks for radial chambers.                                               
*T: FPPP   30901 SM. New calibration banks for planar chambers.                                               
*T: FCR1   30901 SM. New calibration banks for radial chambers.                                               
*T: FCR2   30901 SM. New calibration banks for radial chambers.                                               
*T: FCP1   30901 SM. New calibration banks for planar chambers.                                               
*T: FCP2   30901 SM. New calibration banks for planar chambers.                                               
*T: FRCP   30901 SM. New version of steering bank.                                                            
*D: FSETMC 30901 SM. New routine for setting correct MC bank versions                                         
*D: FRSTMC 30901 SM. New routine for setting correct MC bank versions                                         
*D: FPSGRF 30901 SM. Bug fix. Trap array bound error.                                                         
*D: FPLOCO 30901 SM. New t-to-d. Extensively rewritten.                                                       
*D: FRLOCO 30901 SM. New t-to-d. Extensively rewritten.                                                       
*D: FPTINT 30901 SM. Changes to steering control.                                                             
*D: FPSGST 30901 SM. Changes for MC handling.                                                                 
*D: FVFIT  30901 SB. Print summary on ENDJOB.                                                                 
*D: FEFFIC 30901 SM. Change to include p->R                                                                   
*D: FPTEND 30901 SM. Bug fix.                                                                                 
*D: FPLT2D 30901 SM. New routine.                                                                             
*D: FCFOXY 30901 SM. New routine.                                                                             
*D: FPPJN3 30901 SM. Flag event saturation                                                                    
*D: FPPJ12 30901 SM. Flag event saturation                                                                    
*D: FPPJ23 30901 SM. Flag event saturation                                                                    
*D: FPPJ13 30901 SM. Flag event saturation                                                                    
*D: FTDPAT 30901 SM. ERRLOG event saturation.                                                                 
*D: FTPRTR 30901 SM. Flag event saturation                                                                    
*D: FPSP   30901 SM. Flag event saturation                                                                    
*D: FTLSEG 30901 SM. Steering changes                                                                         
*D: FPLPKS 30901 SM. Remove duplicate histogram.                                                              
*D: FPLKPR 30901 SM. SELectable code for field off cosmics added.                                             
*D: FPKPKR 30901 SM. SELectable code for field off cosmics added.                                             
*D: FTLISA 30901 SM. Steering changes                                                                         
*D: FPTHIS 30901 SM. Remove unused histograms                                                                 
*D: FILHIS 30901 SM. Remove unused histograms.                                                                
*D: FFBKLK 30901 SB. Change range of MC histos.                                                               
*D: FFBKLK 30901 SB. New monitoring histograms.                                                               
*D: FFKAL  30901 SB. Print summary on ENDJOB.                                                                 
*D: FFKAL  30901 SB. Output LOOK histograms.                                                                  
*D: FFKLMN 30901 SB. Radius ignored if there are planar hits.                                                 
*D: FFRAD  30901 SB. Radius ignored if there are planar hits.                                                 
*D: FKHUNT 30901 SB. Extra argument to FFRAD.                                                                 
*D: FFCHEK 30901 SB. Allow for hits with no digi.                                                             
*D: FFCHEK 30901 SB. Fix bug in efficiency histograms                                                         
*D: FFHBK  30901 SB. Reinstate missing track histograms.                                                      
*D: FFTRCH 30901 SB. Check for dead wires and hits with no digi.                                              
*D: FFTRCH 30901 SB. Reinstate missing track histograms.                                                      
**----------------------------------------------------------------------                                      
*D: FVFIT  30704 GB. run summary printed only with SUMM steering param.                                       
*D: FFKAL  30704 GB. run summary printed only with SUMM steering param.                                       
**----------------------------------------------------------------------                                      
*T: FVRS   30606 SB. New steering bank for forward Z-vertex fit.                                              
*T: FVRP   30606 SB. Split NHIT cut into planars and radials.                                                 
*T: FVRP   30606 SB. New steering bank for forward z-vertex fit.                                              
*S: FFMAC  30606 SB. FFSTEE sequence modified:                                                                
*S: FFSTEE 30606 SB. Extra cuts added.                                                                        
*S: FFMAC  30606 SB. FFSCAL sequence modified:                                                                
*S: FFSCAL 30606 SB. New counters added.                                                                      
*S: FVMAC  30606 SB. FVPAR sequence modified:                                                                 
*S: FVMAC  30606 SB. FVSCAL sequence modified:                                                                
*D: FVFIT  30606 SB. A bit of extra printout.                                                                 
*D: FVZFIT 30606 SB. Compare FT with CT z-vertex.                                                             
*D: FVZWM  30606 SB. New debug histogram numbers.                                                             
*D: FVXTRP 30606 SB. Separate cut on # of radial and planar hits.                                             
*D: FVXTRP 30606 SB. New debug histograms and numbers.                                                        
*D: FVTEXT 30606 SB. Separate cuts on # of planar/radial hits.                                                
*D: FVTEXT 30606 SB. FVRP steering bank format changed.                                                       
*D: FVHBK  30606 SB. New debug histograms/numbers.                                                            
*D: FFBKLK 30606 SB. New monitoring histograms.                                                               
*D: FFKAL  30606 SB. Print new counters.                                                                      
*D: FFKAL  30606 SB. Call new diagnostic routine FFTRAN.                                                      
*D: FFKLMN 30606 SB. Small change in debug steering.                                                          
*D: FFOUT  30606 SB. Call new track rejection routine FFKILL.                                                 
*D: FFOUT  30606 SB. New monitoring histograms.                                                               
*D: FFTEXT 30606 SB. New steering cuts; FFRS bank format changed.                                             
*D: FFKILL 30606 SB. New deck to remove bad tracks.                                                           
*D: FFHBK  30606 SB. Debug steering changed slightly.                                                         
*D: FFTRAN 30606 SB. New deck for diagnostics.                                                                
*D: FTREC  30606 SM. Add diagnostics.                                                                         
*D: FRLOCO 30606 SM. FRLC bank extended. Histos added.                                                        
*D: FPLOCO 30606 SM. FPLC bank extended. Histos added.                                                        
*D: FPSOUT 30606 SM. Histogram bug fixed.                                                                     
*D: FRSGST 30606 SM. Diagnostic changes.                                                                      
*D: FPSGST 30606 SM. Diagnostic changes.                                                                      
*D: FPREZI 30606 SM. Histograms added.                                                                        
*D: FEFFIC 30606 SM. Write statements removed.                                                                
*D: FTJN3  30606 SM. Algorithm changed. Histos added.                                                         
*D: FTJN12 30606 SM. Algorithm changed. Histos added                                                          
*D: FTJN23 30606 SM. Algorithm changed. Histos added.                                                         
*D: FTJN13 30606 SM. Algorithm changed. Histos added.                                                         
*D: FTTRAC 30606 SM. Extra diagnostics.                                                                       
*D: FPTREZ 30606 SM. Extra diagnostics.                                                                       
*D: FPUDAT 30606 SM. Extra diagnostics. Measurement errors improved.                                          
*D: FPDG4  30606 SM. Extra diagnostics. Measurement errors improved.                                          
*D: FPTHIS 30606 SM. Usual.                                                                                   
*D: FCALIB 30606 SM. Subroutine name conflict removed!                                                        
*D: FCLHIS 30606 SM. Small cosmetic changes.                                                                  
*D: FSEGMN 30606 SM. New Deck.                                                                                
*D: FCLSEG 30606 SM. Obsoleted from patch FT_CALIB                                                            
**----------------------------------------------------------------------                                      
*D: FTREC  30602 SM. Add diagnostics.                                                                         
*D: FRLOCO 30602 SM. Add diagnostics.                                                                         
*D: FPSGST 30602 SM. Remove HBOOK.                                                                            
*D: FTKRAN 30602 SM. New monitor routine.                                                                     
*D: FEFFIC 30602 SM. New monitor routine.                                                                     
*D: FOXY   30602 SM. New monitor routine.                                                                     
*D: FTFHQQ 30602 SM. Change error calculation.                                                                
*D: FTJN3  30602 SM. Remove HBOOK. Modify link.                                                               
*D: FPLPKS 30602 SM. Fix histograms.                                                                          
*D: FPFYUV 30602 SM. Bug fix.                                                                                 
*D: FPUDAT 30602 SM. New error estimation.                                                                    
*D: FPDG4  30602 SM. New error estimation.                                                                    
*D: FPPPTZ 30602 SM. New routine for cov propagation.                                                         
*D: FPTHIS 30602 SM. Usual.                                                                                   
**----------------------------------------------------------------------                                      
*D: FTREC  30600 SM. Fix nasty bug in planar segment calls.                                                   
**----------------------------------------------------------------------                                      
*D: FFKLMN 30600 SB. Trap SGI overwrites.                                                                     
**----------------------------------------------------------------------                                      
*S: FRMAC  30600 SM. SEQ FRDIMS changed!!                                                                     
*D: FPLOCO 30600 SM. error bad hit flag restored.                                                             
*D: FPTINT 30600 SM. cosmetic fix.                                                                            
*D: FTFHPL 30600 SM. Phi=0 patch.                                                                             
*D: FTFHQQ 30600 SM. change radius error calculation.                                                         
*D: FTJN3  30600 SM. expand diagnostic plots.                                                                 
*D: FTTRAC 30600 SM. Fix bug. Remove poorly parametrised tracks.                                              
*D: FPLPKS 30600 SM. Yet another Phi=0 problem fixed.                                                         
**----------------------------------------------------------------------                                      
*D: FPLOCO 30404 SM. FRLC bank mod. Improved drift errors, diagnostics.                                       
*D: FRLOCO 30404 SM. Improved drift errors. Extend diagnostics.                                               
*D: FPTINT 30404 SM. Select flag simplification.                                                              
*D: FPTRDT 30404 SM. Improved drift errors. Exclude bad hits.                                                 
*D: FPTPDT 30404 SM. Improved drift errors.Exclude bad hits.                                                  
*D: FPTOUT 30404 SM. Intermediate banks to R-list. Remove swim to end                                         
*D: FPTOUT 30404 SM.  -wall. Clean SELECT's.                                                                  
*D: FTREC  30404 SM. Put intermediate banks to R-list. Clean SELECT's.                                        
*D: FPSOUT 30404 SM. Put intermediate banks to R-list. Clean SELECT's.                                        
*D: FPSGST 30404 SM. Clean SELECT's.                                                                          
*D: FRSOUT 30404 SM. Put intermediate banks to R-list. Clean SELECT's.                                        
*D: FRSOUT 30404 SM. Segment z-limits defined hits not cell edges.                                            
*D: FRSGST 30404 SM. Clean SELECT's.                                                                          
*D: FRPCHK 30404 SM. Rewrite for ep data.                                                                     
*D: FPTFPT 30404 SM. Clean SELECT's.                                                                          
*D: FTNTRK 30404 SM. New deck. Get num 'good' FTD tracks.                                                     
*D: FPREZI 30404 SM. New deck. planar segment residual plots.                                                 
*D: FVXTRP 30404 SB. Redundant calls to FKNORM removed.                                                       
*D: FVZFIT 30404 SB. New monitoring histograms.                                                               
                                                                        
*D: FTFHQQ 30404 SM. Improved drift errors.Fix Phi continuity.                                                
*D: FTJN3  30404 SM. Add new histos for tuning.                                                               
*D: FTTRAC 30404 SM. Add new histos for tuning.                                                               
*D: FTTRAC 30404 SM. Evaluate track parameters at 1st measured point.                                         
*D: FPTREZ 30404 SM. Add new histos for tuning.                                                               
*D: FPLPKS 30404 SM. Internal parameter adjustments. Clean SELECT's.                                          
                                                                        
*D: FPFYUV 30404 SM. Internal parameter adjustments.                                                          
*D: FPUDAT 30404 SM. Exclude bad hits.                                                                        
*D: FPDG4  30404 SM. Internal parameter adjustments.                                                          
                                                                        
*D: FPTHIS 30404 SM. Changes to special histograms.                                                           
                                                                        
*D: FKANAL 30404 SB. Minor bug fixed.                                                                         
*D: FKDPL  30404 SB. Small bug fixed.                                                                         
*D: FKRDRW 30404 SB. Leave out projected residuals.                                                           
*D: FKTDRW 30404 SB. Leave out projected tracks.                                                              
*D: FKCLIK 30404 SB. Cosmetic.                                                                                
                                                                        
*D: FFFIT  30404 SB. Cosmetic changes.                                                                        
*D: FFFIT  30404 SB. 1-column FTKR banks no longer made.                                                      
*D: FFFIT  30404 SB. Creation of empty files moved to FFOUT.                                                  
*D: FFFIT  30404 SB. Small fix to error counting.                                                             
*D: FFFIT  30404 SB. Make empty FTKX bank if necessary.                                                       
*D: FFKAL  30404 SB.  Cosmetic changes.                                                                       
*D: FFKLMN 30404 SB. Cosmetic changes; new histograms.                                                        
*D: FFKLMN 30404 SB. Severity added to ERRLOG messages.                                                       
*D: FFOUT  30404 SB. New monitoring histograms.                                                               
*D: FFOUT  30404 SB. Empty banks made here instead of in FFFIT.                                               
*D: FFOUT  30404 SB. Protect against large chi-squared.                                                       
*D: FFOUT  30404 SB. Vertex fit stuff removed.                                                                
*D: FFOUT  30404 SB. Protect against divide by 0.                                                             
*D: FFOUT  30404 SB. FTKX now added to E-list in FTREC for debug.                                             
*D: FFPHNT 30404 SB. Add check on bad hit flag.                                                               
*D: FFRAD  30404 SB.  Fix bad radius bug.                                                                     
*D: FFRHNT 30404 SB. Check for bad hits (again).                                                              
*D: FFTEXT 30404 SB. Cosmetics.                                                                               
*D: FFBKLK 30404 SB. Remove vertex histos, add xy, change scales.                                             
*D: FFRCEL 30404 SB. Cosmetics.                                                                               
*D: FFPLAN 30404 SB. Fix IDSIGN.                                                                              
*D: FFHBK  30404 SB. New histograms.                                                                          
*T: FRCS   30404 SM. Steering adjustments.                                                                    
*T: FRCP   30404 SM. Steering adjustments.                                                                    
**----------------------------------------------------------------------                                      
*D: FRPCHK 30308 SM. New deck for rad-pla alignment plots                                                     
*D: FRSOUT 30308 SM. Add call to FRPCHK (not for standard job).                                               
*D: FRLOCO 30308 SM. Add event T0 correction from CEVT0.                                                      
*D: FPLOCO 30308 SM. Add event T0 correction from CEVT0.                                                      
*D: FTREC 30308 .SM. Turn on planar segment with event size check.                                            
*D: FPTINT 30308 SM. Add max planar event size for FPSEG.                                                     
*D: FPTREZ 30308 SM. Add additional monitoring plots.                                                         
*D: FTTRAC 30308 SM. extend residual plots to < 3mod tracks.                                                  
*D: FPSOUT 30308 SM. Add control for MC only.                                                                 
*D: FPTHIS 30308 SM. Adjust histogram binning.                                                                
*S: FRMAC  30404 SM. Add max planar event size for FPSEG to SEQ FPTFLG.                                       
*T: FPCP   30404 SM. Extend for max planar event size.                                                        
**----------------------------------------------------------------------                                      
*D: FTREC  30307 SM. Switch off planar segnment finding (time).                                               
**----------------------------------------------------------------------                                      
*D: FTLINK 30306 SW. bug. Undefined variable (NIG) removed.                                                   
*D: FRCART 30306 SM. temp.fix to a  bug which causes problems in h1look                                       
**----------------------------------------------------------------------                                      
*D: FPLOCO 30304 SM. Add illegal channel handling.                                                            
*D: FRLOCO 30304 SM. Add illegal channel handling.                                                            
*D: FPTINT 30304 SM. Add FTlink steering.                                                                     
*D: FTJN12 30304 SM. Add FTlink steering.                                                                     
*D: FTJN13 30304 SM. Add FTlink steering.                                                                     
*D: FTJN23 30304 SM. Add FTlink steering.                                                                     
*D: FTJN3  30304 SM. Add FTlink steering.                                                                     
*D: FPTHIS 30304 SM. Fix histogram steering bug.                                                              
*D: FRSGST 30304 SM. Fix histogram steering bug.                                                              
*S: FRMAC  30304 SM. Add sequence FJNPAR for link steering.                                                   
*T: FRCP   30304 SM. Extend for link steering.                                                                
**----------------------------------------------------------------------                                      
*D: FTREC  30303 .SM. Add call to z-vertex finding routine.                                                   
*S: FVSTEE 30303 SB. New sequence + common block for steering.                                                
*S: FVPAR  30303 SB. New sequence + common block with parameters.                                             
*S: FVSCAL 30303 SB. New sequence + common block with counters.                                               
*S: FVWBI  30303 SB. New sequence + common block with indices.                                                
*T: FVRS   30303 SB. New steering bank for forward Z-vertex fit.                                              
*T: FVRP   30303 SB. New steering bank for forward z-vertex fit.                                              
*D: FVMAC  30303 SB. New deck, with sequences for FT vertex fit:                                              
*D: FVFIT  30303 SB. New deck to steer forward z-vertex fit.                                                  
*D: FVZFIT 30303 SB. Bank FVZR added to the E-list:                                                           
*D: FVZFIT 30303 SB. New deck to perform forward z-vertex fit.                                                
*D: FVCHEK 30303 SB. New deck to check FVFIT output.                                                          
*D: FVZWM  30303 SB. New deck to take a weighted mean of z values.                                            
*D: FVXTRP 30303 SB. New deck to extrapolate tracks to vertex.                                                
*D: FVTEXT 30303 SB. New steering banks FVRS and FVRP from db:                                                
*D: FVTEXT 30303 SB. New deck to read z-vertex fit steering banks.                                            
*D: FVBKLK 30303 SB. New deck to book z-vertex monitoring histograms.                                         
*D: FVHBK  30303 SB. New deck to book z-vertex diagnostic histograms.                                         
*D: FVTRUE 30303 SB. New deck to mark tracks as primary/secondary.                                            
**----------------------------------------------------------------------                                      
*D: FTJN13 30301 SM. Fix selection of best link.                                                              
*D: FTJN12 30301 SM. Fix selection of best link.                                                              
*D: FPMAC  30301 GB: macro FPRINT and FPGEOM renamed to FPPRNT,FPLGEO.                                        
*S: FPLGEO 30301 GB: sequence replacing FPGEOM (avoid clash)                                                  
*S: FPPRNT 30301 GB: sequence replacing FPRINT (avoid clash)                                                  
*D: FPTINT 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FTDGEO 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPCFIT 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPCPLN 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPDG31 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPDG32 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPDG33 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPFSEG 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPFYUV 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPIINT 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPINIT 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPLINT 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPPDEF 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FPDG4 30301 .GB: macro FPRINT renamed to FPPRNT to avoid clash                                            
*D: FPIPRT 30301 GB: macro FPRINT renamed to FPPRNT to avoid clash                                            
*D: FCTRAC 30301 GB: macro FPGEOM renamed to FPLGEO to avoid clash                                            
*D: FTREC 30301 .SM. Correct handling of FTKX bank. (see FFFIT FFOUT)                                         
*D: FPLOCO 30301 SM. Bug fix. Drop banks at begin for display.                                                
*D: FPTFPT 30301 SM. Output radial segments if FPSGOUT selected.                                              
*D: FPTINT 30301 SM. Pick up pattern recognition parameters from bank.                                        
*D: FPTOUT 30301 SM. radial segment handling if FPSGOUT selected.                                             
*D: FRLOCO 30301 SM. Explicitly drop FRLC FRHC banks.                                                         
*D: FPSGST 30301 SM. More diagnostic histograms.                                                              
*D: FRSOUT 30301 SM. New routine for monitoring.                                                              
*D: FRSGST 30301 SM. New routine for monitoring.                                                              
*D: FZDCA 30301 .SM. New routine for monitoring.                                                              
*D: FTJN12 30301 SM. Fix selection of best link.                                                              
*D: FTJN13 30301 SM. Fix selection of best link.                                                              
*D: FTJN23 30301 SM. Fix selection of best link.                                                              
*D: FTJN3 30301 .SM. Fix selection of best link.                                                              
*D: FTLSEG 30301 SM. Mod to allow parameters from bank.                                                       
*D: FTTRAC 30301 SM. Add selectable code for monitoring.                                                      
*D: FPCFIT 30301 SM. Bug fix. Protect against small Chisq for PROB.                                           
*D: FPFYUV 30301 SM. Bug fix. Protect against small Chisq for PROB.                                           
*D: FPRCHI 30301 SM. Bug fix. Protect against small Chisq for PROB.                                           
*D: FPSGRF 30301 SM. Bug fix. Protect against small Chisq for PROB.                                           
*D: FPTHIS 30301 SM. Yet mor changes to histograms.                                                           
*D: FTZFIT 30301 SM. New routine for monitoring.                                                              
*D: FLLFIT 30301 SM. New routine for monitoring.                                                              
*D: FFUNCS 30301 SM. New routine for monitoring.                                                              
*D: FLFIT 30301 .SM. New routine for monitoring.                                                              
*D: FAUSSJ 30301 SM. New routine for monitoring.                                                              
*D: FKEM   30301 SB. New error messages for FKLPAS and FKLPAF.                                                
*D: FKLPAF 30301 SB. Error message description updated.                                                       
*D: FFFIT  30301 SB. Make empty FTKX bank if necessary.                                                       
*D: FFOUT  30301 SB. FTKX now added to E-list in FTREC for debug.                                             
*T: FRCP   30301 SM. Another extension.Version number added.                                                  
*T: FPCP   30301 SM. Version number added.                                                                    
*T: FRCS   30301 SM. Version number added.                                                                    
*S: FSGPAR 30301 SM. New sequence.                                                                            
**----------------------------------------------------------------------                                      
*D: FPLOCO 30207 GB. comment lines moved inside the routine                                                   
*D: FPTFPT 30207 GB. comment lines moved inside the routine                                                   
*D: FPTRDT 30207 GB. comment lines moved inside the routine                                                   
*D: FRLOCO 30207 GB. comment lines moved inside the routine                                                   
*D: FPSGST 30207 GB. comment lines moved inside the routine                                                   
*D: FPLPKS 30207 GB. comment lines moved inside the routine                                                   
*D: FPFSEG 30207 GB. comment lines moved inside the routine                                                   
*D: FPFYUV 30207 GB. comment lines moved inside the routine                                                   
*D: FPDG4  30207 GB. comment lines moved inside the routine                                                   
*D: FPTHIS 30207 GB. comment lines moved inside the routine                                                   
*D: F_____ 30207 GB. comment lines moved inside the routine FOR MOST ROU                                      
**----------------------------------------------------------------------                                      
*D: FRLOCO 30205 SM. Modifications for Filter farm.                                                           
*D: FPLOCO 30205 SM. Modifications fror Filter Farm. Add histogram.                                           
*D: FPTFPT 30205 SM. Make deck anti-selected for FILTER.                                                      
*D: FPSGST 30205 SM. Add extra diagnostics for segments.                                                      
*D: FPLPKS 30205 SM. Crush small bug.                                                                         
*D: FPLPK1 30205 SM. Add histogram.                                                                           
*D: FPTREZ 30205 SM. Add histogram.                                                                           
*D: FPDG4  30205 SM. Tune slope cuts. Add diagnostic histograms.                                              
*D: FPFSEG 30205 SM. Add diagnostic histograms                                                                
*D: FPFYUV 30205 SM. Add diagnostic histogram                                                                 
*D: FPTHIS 30205 SM. Numerous changes to histograms                                                           
*D: FTREC  30205 SM. Improve(?) histogram handling.                                                           
**----------------------------------------------------------------------                                      
*D: FPTRDT 30202 GB. Cosmetics                                                                                
*D: FFRHNT 30202 GB. Cosmetics                                                                                
*D: FTREC  30202 GB. call to setrec to set MONTE flag.                                                        
**----------------------------------------------------------------------                                      
*D: FTREC  30201 SM. Cosmic special code removed. SEL FCOSSPC to get it.                                      
*D: FTLFT  30201 SM. changed to  double precision internally.                                                 
*D: FPTOUT 30201 SM. planar segment bank (internal) changed.                                                  
*D: FPSOUT 30201 SM. planar segment bank (internal) changed.                                                  
*D: FPSGST 30201 SM. planar segment bank (internal) changed.                                                  
*D: FPTHIS 30201 SM. Histograms rearranged slightly.                                                          
*D: FTREC  30110 SM. Planar segment output with FPSGOUT selected.                                             
*D: FTLFTW 30110 SM. changed to  double precision internally.                                                 
*D: FTCORG 30110 SM. Modifications for filter.                                                                
*D: FCSWIM 30110 SM. Modifications for filter.                                                                
*D: FRLOCO 30110 SM. Time-distance relation corrected.                                                        
*D: FRLOCO 30110 SM. Modifications for filter. MVBITS replaced.                                               
*D: FPLOCO 30110 SM. Modifications for filter. MVBITS replaced.                                               
*D: FRMAC  30110 SM. Sequences FPTFLG FPTPAR FWINDS added.                                                    
*S: FWINDS 30110 SM. New sequence.                                                                            
*S: FPTFLG 30110 SM. New sequence.                                                                            
*S: FPTPAR 30110 SM. New sequence.                                                                            
*D: FPTINT 30110 SM. Read more parameters from FRCP bank.                                                     
*D: FPTINT 30110 SM. Modifications for filter.                                                                
*D: FPTRDT 30110 SM. Modifications for filter.                                                                
*D: FPTPDT 30110 SM. Modifications for filter.                                                                
*D: FPTOUT 30110 SM. Planar segment output with FPSGOUT selected                                              
*D: FPSOUT 30110 SM. Planar segment output with FPSGOUT selected                                              
*D: FPSGST 30110 SM. Planar segment output with FPSGOUT selected                                              
*D: FTFHPL 30110 SM. New version. New argument list.                                                          
*D: FTTRAC 30110 SM. New version. Uses planar segments and/or hits.                                           
*D: FPTREZ 30110 SM. New deck.                                                                                
*D: FPLPK1 30110 SM. New deck for planar hit pick-up.                                                         
*D: FPLPKS 30110 SM. New deck for planar hit pick-up.                                                         
*D: FTLSEG 30110 SM. Improved version for data and MC.                                                        
*D: FPTHIS 30110 SM. More diagnostic histograms added.                                                        
*T: FRCP   30110 SM. Bank contents extended.                                                                  
**----------------------------------------------------------------------                                      
*D: FTDGEO 30108 RG. INDR replaced with INFGAR (INDR is a fct of bos)                                         
*D: FKCOVR 30108 SB. Overflow error trapped.                                                                  
*D: FKEM   30108 SB. New error code (IOVCV). Message format changed.                                          
*D: FKEND  30108 SB. Cosmetic change to printout.                                                             
*D: FKLOOK 30108 SB. Initialise IFAIL1 to please UNDEF.                                                       
*D: FKLPAF 30108 SB. Initialise IFAIL to please UNDEF.                                                        
*D: FKLRSD 30108 SB. Trap overflows.                                                                          
*D: FKLSSM 30108 SB. Remove unused FKECODE sequence.                                                          
*D: FKPRHS 30108 SB. Change FKISUM to subroutine to please UNDEF.                                             
*D: FKSTAT 30108 SB. Change FKISUM to subroutine to please UNDEF.                                             
*D: FKISUM 30108 SB. Change from function to subroutine to please UNDEF.                                      
*D: FKPROB 30108 SB. Change to avoid UNDEF warning.                                                           
*D: FKANAL 30108 SB. Digi with wrong drift sign counts as a bad hit.                                          
*D: FKANAL 30108 SB. Phi histograms added.                                                                    
*D: FKCLIK 30108 SB. Change to avoid UNDEF warnings.                                                          
*D: FKDHIT 30108 SB. Remove unused GKSENUM sequence.Change to avoid UND.                                      
*D: FKDPL  30108 SB. Plane with wrong drift sign drawn in yellow. "" "                                        
*D: FKHBK  30108 SB. Phi histograms added.                                                                    
*D: FKHPR  30108 SB. Remove unused FKMEAS sequence.                                                           
*D: FKHPR  30108 SB. Print histograms only if they exist.                                                     
*D: FKIHGZ 30108 SB. Reference H array to please UNDEF.                                                       
*D: FKRDRW 30108 SB. Remove unused GKSENUM sequence.Change to avoidUND                                        
*D: FKTDRW 30108 SB. Remove unused GKSENUM sequence.                                                          
*D: FFBKLK 30108 SB. Add some new histograms, with new numbering.                                             
*D: FFBKLK 30108 SB. Change range of histograms for data.                                                     
*D: FFFIT  30108 SB. ERRLOG changed. BKFMT calls moved to FFKAL.                                              
*D: FFFIT  30108 SB. Add #tracks histogram call for empty events                                              
*D: FFKAL  30108 SB. Small cosmetic change (IFIRST -> LINIT).                                                 
*D: FFKAL  30108 SB. ERRLOG error numbers changed.                                                            
*D: FFKAL  30108 SB. Change printout format slightly.                                                         
*D: FFKAL  30108 SB. BKFMT calls moved here.                                                                  
*D: FFKAL  30108 SB. New counters added.                                                                      
*D: FFKAL  30108 SB. Call H1STOP if initialisation fails.ERRLOG. PAW                                          
*D: FFKLMN 30108 SB. Make efficiency histograms conditional on PMCUT                                          
*D: FFKLMN 30108 SB. BKFMT calls moved to FFKAL.ERRLOG.                                                       
*D: FFKLMN 30108 SB. Check the drift sign in debug mode.Count failed                                          
*D: FFKLMN 30108 SB. tracks.Starting errors must be .LE. errors in FTUR                                       
*D: FFOUT  30108 SB. Bug fix (NDF now correct if LRISV is .TRUE.)                                             
*D: FFOUT  30108 SB. ERRLOG.Remove unused FKMEAS seq. Count failures.                                         
*D: FFOUT  30108 SB. Better handling of errors with missing banks.                                            
*D: FFOUT  30108 SB. ERRLOG.Add some new histograms, with new numbering.                                      
*D: FFPCEL 30108 SB. ERRLOG. FKMEAS.                                                                          
*D: FFPLAN 30108 SB. ERRLOG. FKMEAS.                                                                          
*D: FFRCEL 30108 SB. ERRLOG. FKMEAS.                                                                          
*D: FFRAD  30108 SB. ERRLOG. FKMEAS.                                                                          
*D: FFTEXT 30108 SB. Steering banks/parameters modified. Now protected                                        
*D: FFTEXT 30108 SB. against getting wrong version of steering banks.                                         
*D: FFTEXT 30108 SB. ERRLOG.Printout format improved.small bug corr.                                          
*D: FKHUNT 30108 SB. Remove unused HCHI variable.Initialise IFAIL1 to                                         
*D: FKHUNT 30108 SB. please UNDEF. Check for wrong drift sign in debug .                                      
*D: FFCHEK 30108 SB. Fix bug in efficiency histograms.Check drift sign.                                       
*D: FFCHEK 30108 SB. Add a check for dead wires                                                               
*D: FFCHTR 30108 SB. Check to see if the drift sign is correct.ERRLog                                         
*D: FFKLCH 30108 SB. Remove unused FKCNTL sequence.UNDEF.ERRLOG                                               
*D: FFXTRP 30108 SB. Initialise IPF and IRF to please UNDEF.                                                  
*D: FPFPHC 30108 SE: non-standard fortran                                                                     
*D: FPHITZ 30108 SE: non-standard fortran                                                                     
*D: FFMAC  30108 SB. FFSTEE sequence modified:                                                                
*S: FFSTEE 30108 SB. Obsolete parameters removed.                                                             
*S: FFSCAL 30108 SB. New counters added.                                                                      
*D: FKMAC1 30108 SB. FKNPL, FKLERR sequences modified:                                                        
*S: FKNPL  30108 SB. Array LTRPLD added to flag wrong drift sign.                                             
*S: FKLERR 30108 SB. New error code (IOVCV) added.                                                            
*D: FKMAC2 30108 SB. FKDBG, FKLERR sequences modified:                                                        
*S: FKDBG  30108 SB. Array LTRPLD added to flag wrong drift sign.                                             
*S: FKLERR 30108 SB. New error code (IOVCV) added.                                                            
*D: KTMAC  30108 SB. Sequences modified:                                                                      
*S: KTSTEE 30108 SB. Debug steering flags added.                                                              
*S: KTPAR  30108 SB. Extra steering parameters added.                                                         
*S: KTSCAL 30108 SB. New sequence + common block with counters.                                               
**----------------------------------------------------------------------                                      
*D: FRLOCO 30104 SM. Add distortion correction to radius.                                                     
*D: FRLOCO 30104 SM. Flag potentential timing pulses by setting                                               
*D: FRLOCO 30104 SM. Bit 2 in ISGNW. See routine for details.                                                 
*D: FPTRDT 30104 SM. reject bad hits flagged by FRLOCO.                                                       
*D: FFBKLK 30104 SM. Change range of Histos for data.                                                         
*D: FFRHNT 30104 SM. Check for bad hits.                                                                      
*D: FFRAD  30104 SM. Check for bad hits.                                                                      
*T: FGAP   30104 SM. Data version of bank added.                                                              
*T: FGAR   30104 SM. Data version of bank added                                                               
**----------------------------------------------------------------------                                      
***************************************************************                                               
*     Module to Pattern recognise Forward tracker                                                             
*                                                                                                             
***************************************************************                                               
*KEEP,BCS.                                                                                                    
      INTEGER      NHROW,NHCOL,NHLEN                                    
      PARAMETER   (NHROW = 2, NHCOL = 1, NHLEN=2)                       
      INTEGER      NBOSIW                                               
      PARAMETER   (NBOSIW=1000000)                                      
      INTEGER      IW(NBOSIW)                                           
      REAL         RW(NBOSIW)                                           
      COMMON /BCS/ IW                                                   
      EQUIVALENCE (RW(1),IW(1))                                         
      SAVE   /BCS/                                                      
*KEEP,BOSMDL.                                                                                                 
C     ------BOSMDL                                                                                            
      LOGICAL       BEGJOB,ENDRUN,BEGRUN,REVENT,ENDJOB,OTHDAT           
      COMMON/BOSMDL/BEGJOB,ENDRUN,BEGRUN,REVENT,ENDJOB,OTHDAT,          
     +              LCCRUN,NCCRUN,NEVENT,                               
     +              IHA,IBS,IDB,IDATEL,LUP,ISN,JSN                      
      SAVE  /BOSMDL/                                                    
C     ------                                                                                                  
*KEEP,FDIFLG.                                                                                                 
      COMMON/LDIAG/IDIAG,IDIAG2,MAXPRT,IDOHIS,PMCUT                     
*KEEP,H1EVDT.                                                                                                 
      COMMON /H1EVDT/ KEVENT,IDATA,MONTE,LCONF                          
      INTEGER KEVENT,IDATA,LCONF                                        
      LOGICAL MONTE                                                     
*                                                                                                             
*  IDATA  type of information (HEAD bank word 6) :                                                            
*                                                                                                             
*                       0 - real data H1                                                                      
*                       1 - MC data H1SIM                                                                     
*                       2 - real data CERN tests                                                              
*                       3 - MC data ARCET                                                                     
*                                                                                                             
*  MONTE = .TRUE.   if IDATA=1                                                                                
*  KEVENT = event processed counter for H1REC                                                                 
*                                                                                                             
*KEEP,FPTFLG.                                                                                                 
      COMMON/FPTFLG/IPLAR, NIT, IREZ, LUNFP, NPLMAX                     
*KEEP,FPPRAM.                                                                                                 
C                                                                                                             
C---  MAXSEG is maximum number of segments per supermodule                                                    
C---  MAXCON is maximum number of amibiguous segments associatable with                                       
C---         one segment                                                                                      
C---  LIMSTO is maximum number of 2 cluster planes intersections to be                                        
C---         stored per supermodule                                                                           
C---  MSEGLM is maximum number of clusters that can be found before                                           
C---         connectivity considered                                                                          
C---  MAXCLU is maximum number of clusters that can be found after                                            
C---         forming non-connected set    MUST BE 50 IF RUN WITH OLD RCW                                      
C---         (cluster = 3/4 digits found in a straight line in one                                            
C---          4-wire orientation)                                                                             
C                                                                                                             
      PARAMETER (MAXSEG = 200)                                          
      PARAMETER (MAXCON = 100)                                          
      PARAMETER (LIMSTO = 5000)                                         
      PARAMETER (MSEGLM = 150)                                          
      PARAMETER (MAXCLU = 50)                                           
C---                                                                                                          
*KEEP,FPLSEG.                                                                                                 
C---                                                                                                          
      COMMON /FPLSEG / PW(12,MAXSEG,3)   , PWC(12,MAXSEG,3)     ,       
     1                 PRCHI(MAXSEG,3)   , NFSEG(3)             ,       
     2                 XYDXY(4,MAXSEG,3) , EXYDXY(4,4,MAXSEG,3) ,       
     3                 ZSEG(2,MAXSEG,3)  ,                              
     4                 ASEGIN(MAXSEG,3)  , ISEGIN(5,MAXSEG,3)   ,       
     5                 MASKSG(MAXSEG,3)  , IDGISG(12,MAXSEG,3)          
C---                                                                                                          
*KEEP,FRDIMS.                                                                                                 
      PARAMETER (MAXHTS=200)                                            
      PARAMETER (NUMWPL=36)                                             
      PARAMETER (MAXTRK=200)                                            
      PARAMETER (MXTTRK=900)                                            
      PARAMETER (MAXTR3=200)                                            
      PARAMETER (MAXHPW=2)                                              
      PARAMETER (MAXDIG=2000)                                           
      PARAMETER (NUMRWR=1727)                                           
      PARAMETER (NUMPWR=1151)                                           
*KEEP,FRH3FT.                                                                                                 
*     Common for RETRAC results (SJM)                                                                         
      COMMON/FRH3FT/ IRN(36,MAXTRK),SDN(36,MAXTRK),                     
     +              IRP(36,MAXTRK),SDP(36,MAXTRK),                      
     +              IG2,IGTTRK(MAXTRK),                                 
     +              CHISQ(MAXTRK),NUMDF(MAXTRK),                        
     +              FITX(MAXTRK),FITY(MAXTRK),FITZ(MAXTRK),             
     +              FITTH(MAXTRK),FITPH(MAXTRK),                        
     +              FITCU(MAXTRK),FTCOV(15,MAXTRK)                      
*KEND.                                                                                                        
                                                                        
*     bank number forvarious banks.                                                                           
      PARAMETER(NBN=0)                                                  
      PARAMETER(NCFPLC=7)                                               
      PARAMETER(NCFRLC=10)                                              
      PARAMETER(NCFAUX=1)                                               
      PARAMETER(NCFPHC=2)                                               
      PARAMETER(NRFPHC=1152)                                            
      PARAMETER(NCFRHC=2)                                               
      PARAMETER(NRFRHC=864)                                             
                                                                        
      CHARACTER*17 SANAME                                               
      CHARACTER*8 VERSQQ                                                
      LOGICAL LFIRST                                                    
      DATA JEVENT / 0 /                                                 
      DATA LFIRST/.TRUE./                                               
*KEEP,VERSQQ.                                                                                                 
      VERSQQ = ' 8.07/02'                                               
      IVERSQ =  80702                                                   
*KEND.                                                                                                        
*                                                                                                             
*     module steering by MODULS                                                                               
*      CALL MODULS('FTREC',IVERSQ,'FRREFRPECJKVCTKV')                                                         
* CTKV dependence removed to aid reprocessing                                                                 
      CALL MODULS('FTREC',IVERSQ,'FRREFRPECJKV')                                                       
*     get right bank versions for MC events...                                                                
      CALL FSETMC
*                                                                                                             
      IF (LFIRST) THEN                                                  
* Initialise IGTTRK flag array                                                                                
         CALL VZERO(IGTTRK,MAXTRK)                                                                     
         LFIRST = .FALSE.                                               
      ENDIF                                                             
      IF(BEGJOB) THEN                                                   
        CALL H1ENVI(JSTAT,JPROC,NPROC)                                                                 
      ENDIF                                                             
      IF(ENDRUN) THEN                                                   
      END IF                                                            
                                                                        
*-----PATTERN RECOGNITION SECTION-------------------------------------                                        
*                                                                                                             
*     Set area for Pattern Recognition histograms.                                                            
      CALL SAREA('FTREC',1)                                                                            
                                                                        
      IF (BEGRUN.AND.JEVENT.LT.1) THEN                                  
        WRITE(6,'('' '')')                                              
        WRITE(6,'(10X,''F T R E C  Initialising...'')')                 
        WRITE(6,'(10X,''        ...Production Version'')')              
        WRITE(6,'('' '')')                                              
* rebook b16 input bank formats for the farm                                                                  
         CALL BKFMT('FRRE','B16')
         CALL BKFMT('FRPE','B16')
C         CALL SETREC                                                                                         
         CALL FPTINT
         CALL FPTHIS
      ENDIF                                                             
*                                                                                                             
* Monitor V/T0 used                                                                                           
      IF (BEGRUN) CALL FTRNDB(NCCRUN)
*                                                                                                             
      IF(REVENT) THEN                                                   
C+SELF,IF=FTTIME.                                                                                             
         CALL TIMEX(T1)                                                                                
C+SELF.                                                                                                       
         JEVENT = JEVENT + 1                                            
                                                                        
*        Unpack radial and planar digis into temporary banks                                                  
*        FRLC FPLC etc.                                                                                       
         CALL FRLOCO
         CALL FPLOCO
         INFPLC = NLINK('FPLC',0)
         IF (INFPLC.GT.0) THEN                                          
            NPHIT = IW(INFPLC+2)                                        
            IF (NPHIT.GT.NPLMAX) THEN                                   
* Abandon very large events                                                                                   
               CALL ERRLOG(1,'S:FTREC:  Too many planar hits')                                         
               INFRLC = NLINK('FRLC',0)
               IF (INFRLC.GT.0) THEN                                    
                  NRHIT = IW(INFRLC+2)                                  
               ELSE                                                     
                  NRHIT = 0                                             
               ENDIF                                                    
               CALL H1WARN(10001,'Too big',FLOAT(NPHIT),FLOAT(NRHIT),0.)                               
               CALL BDROP(IW,'FPLC')
               CALL BDROP(IW,'FRLC')
               CALL BDROP(IW,'FAUX')
               INFPLC = NBANK('FPLC',NBN,2)
               IF (INFPLC.GT.0) THEN                                    
                  IW(INFPLC+1) = NCFPLC                                 
                  IW(INFPLC+2) = 0                                      
               ENDIF                                                    
               INFRLC = NBANK('FRLC',NBN,2)
               IF (INFRLC.GT.0) THEN                                    
                  IW(INFRLC+1) = NCFRLC                                 
                  IW(INFRLC+2) = 0                                      
               ENDIF                                                    
               INFAUX = NBANK('FAUX',NBN,2)
               IF (INFAUX.GT.0) THEN                                    
                  IW(INFAUX+1) = NCFAUX                                 
                  IW(INFAUX+2) = 0                                      
               ENDIF                                                    
               INFPHC = NLINK('FPHC',0)
               IF (INFPHC.GT.0) CALL VZERO(IW(INFPHC+1),NCFPHC*NRFPHC)                                 
               INFRHC = NLINK('FRHC',0)
               IF (INFRHC.GT.0) CALL VZERO(IW(INFRHC+1),NCFRHC*NRFRHC)                                 
            ENDIF                                                       
         ENDIF                                                          
C+SELF,IF=FTTIME.                                                                                             
         CALL TIMEX(T2)                                                                                
C+SELF.                                                                                                       
*------------------------------------------------------                                                       
*        Find planar segments and make FPSG etc. banls.                                                       
*                                                                                                             
         CALL FPLSG
*                                                                                                             
C+SELF,IF=FTTIME.                                                                                             
         CALL TIMEX(T3)                                                                                
C+SELF.                                                                                                       
*------------------------------------------------------                                                       
*        Find Radial segments and make FRSG etc. banks.                                                       
*                                                                                                             
         CALL FRSEG
*                                                                                                             
*------------------------------------------------------                                                       
*        Link the segments and make output banks.                                                             
*                                                                                                             
         CALL FTDPAT
*                                                                                                             
*------------------------------------------------------                                                       
*        Diagnostics...                                                                                       
*                                                                                                             
         IF((IDIAG.GE.1 .OR. IDIAG2.GE.1)                               
     +              .AND. JEVENT .LE. MAXPRT) CALL FPTDIA
         IF(IDOHIS.GT.0)CALL FILHIS                                     
*        Clean up                                                                                             
C         CALL BGARB(IW)                                                                                      
C         CALL WGARB(IW)                                                                                      
      ENDIF                                                             
                                                                        
*     Make monitoring histograms                                                                              
C      IF(JSTAT.GT.0)THEN                                                                                     
C        CALL SAREA('FTDSGI', 0)                                                                              
C        CALL FTDSGI                                                                                          
C        CALL SAREA('FTREC',0)                                                                                
C      ENDIF                                                                                                  
                                                                        
      IF(ENDJOB) THEN                                                   
*        Print summary...                                                                                     
         CALL FPTEND(JEVENT)
                                                                        
         CALL SAREA('FTREC', 0)                                                                        
         CALL LPEAKS(4,6)                                                                              
         CALL LPEAKS(22,22)                                                                            
         CALL LPEAKS(28,29)                                                                            
         CALL LPEAKS(75,76)                                                                            
         CALL LPEAKS(79,84)                                                                            
         CALL LPEAKS(87,90)                                                                            
         CALL PRNTF(0,0)                                                                               
                                                                        
         IF(IDOHIS.GT.0) THEN                                           
           CALL SAREA('FTREC', 1)                                                                      
           CALL PRNTF(0,0)                                                                             
           CALL SAREA('FTREC', 2)                                                                      
           CALL PRNTF(0,0)                                                                             
         ENDIF                                                          
                                                                        
*        Output LOOK Histograms...                                                                            
                                                                        
                                                                        
      END IF                                                            
*                                                                                                             
*-----KALMAN FILTER AND FINAL OUTPUT---------------------------------                                         
*                                                                                                             
*     Set area for overall histograms...                                                                      
      CALL SAREA('FTREC',0)                                                                            
*     Now do the KALMAN filter fitting                                                                        
      CALL FFKAL
*     Find z-vertex from forward tracks.                                                                      
      CALL FVFIT
*                                                                                                             
C+SELF,IF=FTTIME.                                                                                             
      IF(REVENT) THEN                                                   
         CALL SAREA('FTREC',1)                                                                         
         CALL TIMEX(T4)                                                                                
         IND1 = NLINK('FRLC',0)
         IND2 = NLINK('FPLC',0)
         FUMR = FLOAT(IW(IND1+2))                                       
         FUMP = FLOAT(IW(IND2+2))                                       
         FUMRP=FUMR+FUMP                                                
         TTOT = T4-T1                                                   
         TPLA = T3-T2                                                   
         CALL SHS(224,0,TTOT)                                                                          
         CALL SHS(225,0,TPLA)                                                                          
         CALL SHD(226,0,FUMRP,TTOT)                                                                    
         CALL SHD(227,0,FUMP,TPLA)                                                                     
         CALL SHD(228,0,FUMP,TPLA)                                                                     
         CALL SHD(229,0,TTOT,TPLA)                                                                     
         CALL SHS(230,0,FUMP)                                                                          
         CALL SHS(231,0,FUMR)                                                                          
         CALL SHS(232,0,FUMRP)                                                                         
      ENDIF                                                             
C+SELF.                                                                                                       
*      Now clean up. Switch some banks from R to E list if requested.                                         
                                                                        
      CALL BLIST(IW,'R+','FTKX')                                                                       
*                                                                                                             
*     MODULe Finish                                                                                           
*                                                                                                             
      CALL FRSTMC
      CALL MODULF                                                                                      
*                                                                                                             
      RETURN                                                            
      END                                                               
*