FTJN3 COMMENTS
*-- Author : I.O. Skillicorn
      SUBROUTINE FTJN3(CF,IU,LLL,LL,RPC,RPS,PH,CH,        ZI)
**: FTJN3 40000 IS.  New linking code.                                                                        
**----------------------------------------------------------------------                                      
**: FTJN3 40000 .SM. Fix selection of best link.                                                              
**----------------------------------------------------------------------                                      
C     JOIN THREE MODULES                                                                                      
C     AUTHOR    I.O.SKILLICORN                                                                                
C     21/5/91  REDUCE SIZE                                                                                    
*KEEP,FRDIMS.                                                                                                 
*KEEP,FH1WORK.                                                                                                
*    Planar geometry                                                                                          
*                                                                                                             
*    Radial geometry                                                                                          
*                                                                                                             
*    Radial data...                                                                                           
*                                                                                                             
*    Planar Data                                                                                              
*                                                                                                             
*    Pointers into DIGI bank for IOS labelled hits                                                            
*                                                                                                             
*    Track segment data                                                                                       
*                                                                                                             
*    Fit data                                                                                                 
*                                                                                                             
*                                                                                                             
*KEEP,FPTVTX.                                                                                                 
**the common/VERTEX/ becomes /VERTVV/ (in analogy to /VERTFF/) on the                                         
** 17/6/91, since it is in conflict with the VERTEX module (g.bernardi)                                       
** (note that all these common names should start by F in this deck...)                                       
*KEEP,FJNPAR.                                                                                                 
*KEND.                                                                                                        
*                                                                                                             
*                                                                                                             
*     LOCAL ARRAYS...                                                                                         
C     DIMENSION IP(36),SD(36),IPP(36,MAXTR3),SDD(36,MAXTR3)                                                   
C     'Centre' points of radial modules                                                                       
      CALL STEXT(2016,4,' PHI CONT - M12 R12 PSCUT ALL')                                               
      CALL BHS(2016,0,40,-.10,.10)                                                                     
      CALL STEXT(2017,4,' PHI CONT - M23 R23 PSCUT 3M AFTER M12 SEL ')                                 
      CALL BHS(2017,0,40,-.10,.10)                                                                     
*                                                                                                             
*                                                                                                             
C     TO JOIN THREE MODULES                                                                                   
*************************NEW CUTS******94 DATA**************                                                  
*     RCUT=20.                                                                                                
*     PCUT=0.04                                                                                               
*     PSCUT=0.002                                                                                             
*     CHT=100                                                                                                 
************************************************************                                                  
C                                                                                                             
C                                                                                                             
C                                                                                                             
C     =0 USE MANY TIMES  =1  USE ONCE                                                                         
C     *******************************                                                                         
C     CYCLE LINE SEGMENTS M0                                                                                  
C     CYCLE LINE SEGMENTS M1                                                                                  
C     CHECK LINE SEGMENTS POINT TO Z-AXIS                                                                     
C     FILL POINTS/DRIFT SIGN                                                                                  
C     REFIT PHI-Z WITH R-VALUES OF SEGMENTS                                                                   
C     RECALCULATE PHI-Z SLOPE AND INTERCEPT                                                                   
C     R : ASSUMES LINEAR TO VERTEX                                                                            
C     PHI CONTINUOUS                                                                                          
C     FIT LINESEG IN M0                                                                                       
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS1,PZ1,D1,D2,D3,COV)
C     FIT LINESEG IN M1                                                                                       
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS2,PZ2,D1,D2,D3,COV)
C     CHECK RECALCULATED PHI CONTINUOUS AT MID-PLANE                                                          
*     CHECK PHI CONTINUOUS                                                                                    
*     CHECK PHI' SIMILAR FOR EACH SEGMENT                                                                     
C     HERE HAVE 0-1 LINK . CYCLE LINKS IN M2                                                                  
C     CHECK 1-2 POINTS TO Z AXIS IN R                                                                         
C     FILL POINTS/DRIFT SIGN                                                                                  
C     REFIT PHI-Z WITH R-VALUES OF SEGMENTS                                                                   
C     RECALCULATE PHI-Z SLOPE AND INTERCEPT                                                                   
C     R : ASSUMES LINEAR TO VERTEX                                                                            
C     PHI CONTINUOUS                                                                                          
C     REFIT M1 M2 WITH COMMON R                                                                               
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS1,PZ1,D1,D2,D3,COV)
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS2,PZ2,D1,D2,D3,COV)
C     CHECK RECALCULATED PHI CONTINUOUS M2 M3                                                                 
C     CHECK M1, M2 CONTINUOUS AT MID PLANE                                                                    
C     CHECK PHI' SIMILAR                                                                                      
C     THREE MODULES LINK WITHIN TOLERANCE                                                                     
C     CHECK STRAIGHT LINE IN PHI-Z                                                                            
C     R-Z FROM THREE MODULES                                                                                  
C     R : ASSUMES LINEAR TO VERTEX                                                                            
C     PHI CONTINUOUS                                                                                          
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS2,PZ2,D1,D2,D3,COV)
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS3,PZ3,D1,D2,D3,COV)
      CALL FTLFTW(XXX,YYY,WWT,IC,0,2,PS1,PZ1,D1,D2,D3,COV)
C     COMPARE PHI VALUES AT  MODULE CENTRE                                                                    
C     NO CUT ON THIS PARAMETER                                                                                
C     GOOD LINK:  GET CHI , BEST TRACK PARAMETERS                                                             
      CALL FTCHKH(PCOS,PHZ,PSIN,RI,I,J,K,CHI)
C     LOOSE CUT ON CHI.                                                                                       
C     USE CHI TO SELECT BEST CANDIDATE IF AMBIGUITIES                                                         
C                                                                                                             
C******************************************12/10/88********************                                       
C     NEW COMPARE SECTION                                                                                     
C     NEW COMPARE SECTION                                                                                     
C     NEW COMPARE SECTION                                                                                     
C     NEW COMPARE SECTION                                                                                     
C     SELECT BEST                                                                                             
C     WRITE(*,*)' K ,CHI  ',K,CH(K),LL(K,1),LL(K,2),LL(K,3)                                                   
C     WRITE(*,*)' KB,CHIB ',KB,CHB                                                                            
C     COMPARE BEST WITH REMAINDER                                                                             
C     REMOVE LINK                                                                                             
C     WRITE(*,*)' REMOVE ',K                                                                                  
C     COMPARE FINISHED , MARK BEST SEGMENT USED                                                               
C     RESET CHI WHEN COMPARE FINISHED                                                                         
C                                                                                                             
C                                                                                                             
C                                                                                                             
C     SET USED FLAGS                                                                                          
*------------------------------------------                                                                   
C     PRINT1000,LL(I,1),LL(I,2),LL(I,3)                                                                       
*------------------------------------------                                                                   
*