FTLISA COMMENTS
*-- Author :    I. O. Skillicorn
      SUBROUTINE FTLISA(IRN,IPN,IWC,IC,MAXC,NSS,IM,IDIAG)
**: FTLISA 40000 SM. Initialise RR (else DDMIN*RR test might fail?).                                          
**: FTLISA 40000 SM. Add SEQ BOSMDL so farm change might work.                                                
**----------------------------------------------------------------------                                      
**: FTLISA 30907 RP. Farm changes.                                                                            
**----------------------------------------------------------------------                                      
C                                                                                                             
C     PROCEDURE:-                                                                                             
C  1  FORM CLUSTERS BASED ON WIRE HITS                                                                        
C  2  SELECT LARGEST CLUSTER . END IF TOO FEW  HITS                                                           
C     OR ALL CLUSTERS HAVE BEEN EXAMINED.                                                                     
C  3  SEARCH FOR  TRIPLES IN CLUSTER  (UNUSED POINTS ONLY)                                                    
C     IF NO TRIPLES GOTO2                                                                                     
C  4  JOIN TRIPLES TO FORM LINE SEGMENTS                                                                      
C  5  SELECT LONGEST LINE SEGMENT                                                                             
C  6  EXTEND THIS LINE SEGMENT BY STRAIGHT LINE PROJECTION                                                    
C     IN DRIFT (AND R )  WITHIN CLUSTER. MARK USED POINTS.                                                    
C  7  EXTEND FURTHER BY PROJECTION IN PHI INTO NEIGHBOURING                                                   
C     CLUSTERS . MARK USED POINTS .                                                                           
C  8  REEXAMINE LARGEST CLUSTER . IF INSUFFICIENT POINTS                                                      
C     ELIMINATE CLUSTER AND  GOTO 2 . OTHERWISE GOTO 3.                                                       
C                                                                                                             
C                                                                                                             
C     AUTHOR:      I.O.SKILLICORN                                                                             
*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,FSGPAR.                                                                                                 
*KEEP,BCS.                                                                                                    
*KEEP,BOSMDL.                                                                                                 
C     ------BOSMDL                                                                                            
C     ------                                                                                                  
*KEND.                                                                                                        
*    LOCAL ARRAYS                                                                                             
*                                                                                                             
C     MODS 13/5/91 FOLLOW TO SAVE SPACE   VVVVVVVVVVVVVVVVVVVVVVVVV                                           
C     ADD                                                                                                     
C                                                                                                             
CEND ADDITION  ********************************************                                                   
C                                                                                                             
C     NO DIAGNOSTIC HISTOGRAMS  IDIAG=0                                                                       
C                                                                                                             
*                                                                                                             
*     >  Chard                                                                                                
*     Hard-wired cuts if wanted, else take from COMMON/FSGPAR/ filled                                         
*     by FPTINT from the FRCP bank.                                                                           
*                                                                                                             
C     CUTS                                                                                                    
C     MAXIMUM  DISTANCE ( IN DRIFT) FOR DIGITISING                                                            
C     TO BE ASSOCIATED WITH TRIPLE(S)                                                                         
C     IE ROAD WIDTH IS 2.*DMINX  (CMS.)                                                                       
C     SHOULD BE LESS THAN TWO-TRACK RESOLUTION  0.2 CMS                                                       
C     AND LESS THAN 4*STAGGER                                                                                 
Chard DMINX=0.1                                                                                               
C                                                                                                             
Chard PROJ=0.0                                                                                                
C     DMINX=DFCUT                                                                                             
C     MAXIMUM  DISTANCE ( IN PHI  ) FOR DIGITISING                                                            
C     TO BE ASSOCIATED WITH CLUSTER = PROJ*DMINX/R                                                            
C                                                                                                             
C     MINIMUM SIZE OF CLUSTER FOR STARTING TRIPLE       FINDING                                               
Chard MINHTS=3                                                                                                
C                                                                                                             
C     MINIMUM NUMBER OF POINTS/TRACK SEGMENT                                                                  
Chard MINPTS=4                                                                                                
C                                                                                                             
C     MAX SIZE OF CLUSTER FOR ANALYSIS                                                                        
C                                                                                                             
C     ABS((D1+D3)/2 -D2 ).LT.TSCUT FOR TRIPLE(OPEN FROM 0.08)                                                 
Chard TSCUT=0.10                                                                                              
C     IN JOINING TRIPLES ALL POINTS MUST LIE WITHIN +- TSCUT                                                  
C     OF FIRST AND LAST POINTS OF TRIPLES TO BE JOINED                                                        
C                                                                                                             
C                                                                                                             
C     MAX TRIPLE SLOPE- CORRESPONDS TO 0.25 GEV(OPEN FROM 0.25)                                               
Chard TSLPC=0.5                                                                                               
C     SLOPE CUT FOR JOINING TRIPLES                                                                           
Chard SLCUT=0.15                                                                                              
C                                                                                                             
C     MIN LENGTH OF SEGMENT BEFORE EXTENSION BY PROJECTION                                                    
Chard LSCUT=3                                                                                                 
C                                                                                                             
C     CUT IN R FOR TRIPLE AND PROJECTION(OPEN FROM 20.)                                                       
Chard RCUT=50.                                                                                                
C                                                                                                             
C     RCUT=RRCUT                                                                                              
C     DIAGNOSTIC HISTOGRAMS                                                                                   
      CALL STEXT(9000,4,' TRIPLE DISTANCE DEFINE -TSCUT ')                                             
      CALL BHS(9000,0,50,-0.5,0.5 )                                                                    
      CALL STEXT(9001,4,' TRIPLE SLOPE -TSLPC         ')                                               
      CALL BHS(9001,0,50,-1.0,1.0 )                                                                    
      CALL STEXT(9002,4,' TRIPLE DISTANCE JOIN 1-TSCUT         ')                                      
      CALL BHS(9002,0,50,-0.5,0.5 )                                                                    
      CALL STEXT(9003,4,' TRIPLE DISTANCE JOIN 2-TSCUT         ')                                      
      CALL BHS(9003,0,50,-0.5,0.5 )                                                                    
      CALL STEXT(9004,4,' PROJECT- DMINX        ')                                                     
      CALL BHS(9004,0,50,-0.51,0.49 )                                                                  
      CALL STEXT(9005,4,' PROJECT IN PHI - DMINX*PROJ   ')                                             
      CALL BHS(9005,0,50,-1.0,1.0 )                                                                    
      CALL STEXT(9006,4,' TRIPLE SLOPE CUT - SLCUT     ')                                              
      CALL BHS(9006,0,50,-0.5,0.5 )                                                                    
      CALL STEXT(9007,4,' PROJECT- DMINX DURING SELECTION       ')                                     
      CALL BHS(9007,0,50,0.00,1.00 )                                                                   
      CALL STEXT(9008,4,' PROJECT- DMINX FINAL      ')                                                 
      CALL BHS(9008,0,50,0.00,0.20 )                                                                   
      CALL STEXT(9009,4,' RESIDUALS TO FINAL SEGMENT')                                                 
      CALL BHS(9009,0,50,-0.10,0.10 )                                                                  
      CALL STEXT(9010,4,' RESIDUALS TO FINAL SEGMENT')                                                 
      CALL BHS(9010,0,50, 0.0,0.20 )                                                                   
      CALL STEXT(9011,4,' RMS OF FIT ')                                                                
      CALL BHS(9011,0,50, 0.0,0.10 )                                                                   
C                                                                                                             
C     OPEN EXTRAPOLATION FOR CLEAN WEDGES                                                                     
C                                                                                                             
C                                                                                                             
C                                                                                                             
Chard NWIRES= 12                                                                                              
C                                                                                                             
C     SEARCH FOR TRIPLES IN CLUSTER                                                                           
C     WRITE(*,*)' LJ1 LP1',LJ1,LP1                                                                            
C     WRITE(*,*)' LJ2 LP2',LJ2,LP2                                                                            
C     WRITE(*,*)' LJ3 LP3',LJ3,LP3                                                                            
C     NOW HAVE POSSIBLE TRIPLE - LOOP OVER SIGNS                                                              
C     MAX TRIPLE SLOPE                                                                                        
C     MAX SLOPE OF TRIPLE                                                                                     
C     DDA=  (D1+D3)*0.5-D2                                                                                    
C     CALL HFILL(70004,DDAS,0.,1.)                                                                            
C     POINTERS TO CLUSTER                                                                                     
C     WRITE(*,*)' TRI ',NTRI,II,JJ,KK                                                                         
C     NUMBER POINTERS                                                                                         
C     DRIFT SIGN                                                                                              
C     Z OF CENTRE OF LAST TRIPLE                                                                              
C     SLOPE OF TRIPLE                                                                                         
C     MEAN DRIFT                                                                                              
C     MEAN R                                                                                                  
C     WRITE(*,*)' FTLISA  NTRI ',NTRI                                                                         
*                                                                                                             
*                                                                                                             
*                                                                                                             
*                                                                                                             
*                                                                                                             
*                                                                                                             
C     COMBINE TRIPLES TO FORM TRACK                                                                           
C     CHECK FOR TWO POINTS IN COMMON WITH SAME DRIFT SIGNS                                                    
C     EXTEND TRIPLE BY ONE POINT                                                                              
C     TWO POINTS AGREE,ADD FINAL POINT AFTER CHECKING                                                         
C     THAT ALL POINTS ARE WITHIN TOLERANCE OF LINE                                                            
C     CONNECTED TO FIRST AND LAST POINTS OF POTENTIAL                                                         
C     JOINED SEGMENTS                                                                                         
C     FIRST POINT FIRST TRIPLE                                                                                
C     LAST POINT SECOND TRIPLE                                                                                
C     POINTS                                                                                                  
C     PLANES                                                                                                  
C     DRIFT SIGNS                                                                                             
C     CHECK POINTS AGREE - FIRST TRIPLE                                                                       
C     MEASURED                                                                                                
C     PREDICTED                                                                                               
C     WRITE(*,*)' T-J 1 ',N1,ABS(DP-D11),DMINX                                                                
C     CHECK POINTS AGREE - SECOND TRIPLE                                                                      
C     WRITE(*,*)' T-J 2 ',N1,ABS(DP-D11),DMINX                                                                
C     WRITE(*,*)' ADD I,J ',I,J                                                                               
C     PRINT1100, I,(LTRI(III, I),III=1,NL( I))                                                                
C     PRINT1100, J,(LTRI(III, J),III=1,NL( J))                                                                
CDEB  PRINT1100, I,(LTRI(III, I),III=1,NL( I))                                                                
C     REPLACE Z,SLOPE,MEAN DRIFT                                                                              
C     MARK J AS USED                                                                                          
C     ALLOW FOR ONE MISSING DIGITIZING, JOIN ACROSS GAP                                                       
C     CALL HFILL(70003,(SLTRI(I)-SLTRI(J)),0.,1.)                                                             
C     THEN                                                                                                    
C     CHECK THAT ALL POINTS ARE WITHIN TOLERANCE OF LINE                                                      
C     CONNECTED TO FIRST AND LAST POINTS OF POTENTIAL                                                         
C     JOINED SEGMENTS                                                                                         
C     FIRST POINT FIRST TRIPLE                                                                                
C     LAST POINT SECOND TRIPLE                                                                                
C     POINTS                                                                                                  
C     PLANES                                                                                                  
C     DRIFT SIGNS                                                                                             
C     CHECK POINTS AGREE - FIRST TRIPLE                                                                       
C     MEASURED                                                                                                
C     PREDICTED                                                                                               
C     WRITE(*,*)' T-J 1 ',N1,ABS(DP-D11),DMINX                                                                
C     CHECK POINTS AGREE - SECOND TRIPLE                                                                      
C     WRITE(*,*)' T-J 2 ',N1,ABS(DP-D11),DMINX                                                                
C     JOIN                                                                                                    
C     FLAG TRIPLE AS JOINED                                                                                   
*                                                                                                             
*     NOW HAVE JOINED TRIPLES - FIT                                                                           
*                                                                                                             
C     WRITE(*,*)' NTRI TOT BEFORE DO 100 LOOP ',NTRI                                                          
C     PICK UP POINTS IN EXTENDED TRIPLE AND FIT STR LINE                                                      
C     WRITE(*,*)' FTLISA JOINED TRIPLES -NL ',KC,NL(KC)                                                       
*                                                                                                             
*                                                                                                             
*                                                                                                             
C                                                                                                             
C                                                                                                             
C     WRITE(*,*)' KCC ',KCC                                                                                   
C     WRITE(*,*)' KCC AT LIMIT - FTLISA '                                                                     
C     NOW LOOK FOR OTHER POINTS IN CLUSTER TO FILL                                                            
C     GAPS IN SEGMENT                                                                                         
C     IF POINT ON PLANE EXISTS IN TRIPLE GOTO60                                                               
C     CHECK POINT IN R                                                                                        
C     PREDICT DRIFT AT THIS Z                                                                                 
C     IF(ABS(DDAS).GT.0.00001)CALL HFILL(70005,DDAS,0.,1.)                                                    
C     GOOD POINT                                                                                              
C      CLOSER TO LINE THAN PREVIOUS GOOD POINT - STORE                                                        
C                                                                                                             
C                                                                                                             
C                                                                                                             
C     WRITE(*,*)' I1,KCC,JPP,SDD ',I1,KCC,JPP,SDD(JPP,KCC)                                                    
C      PRINT 1003,KCC,NNPTS(KCC),CHI(KCC),(JDD(I2,KCC),I2=1,12)                                               
C     PRINT 1103,KCC,NNPTS(KCC),CHI(KCC),(SDD(I2,KCC),I2=1,12)                                                
C     WRITE(*,*)' AFTER DO 100 LOOP KCC',KCC                                                                  
C     SELECT BEST LINE - LONGEST OR BEST CHI                                                                  
C     WEIGHT=#POINTS                                                                                          
C     ONE OR MORE POINTS EXCESS - SELECT ON POINTS                                                            
C     SAME NUMBER POINTS     - SELECT ON CHI                                                                  
C     BAD CLUSTER - LT    MINPTS POINTS                                                                       
C     WRITE(*,*)' BAD CLUSTER LT MINPTS'                                                                      
C     AT THIS POINT WE HAVE A GOOD SEGMENT                                                                    
C     FILL OUTPUT BANK FOR FOUND SEGMENT                                                                      
C     WRITE(*,*)' NTRAKS(IM) ',NT                                                                             
CDEB  WRITE(*,*)' I,JP,IIG ',I,JP,IIG,SDD(I,IIG)                                                              
C      WRITE(*,*)' JPPMAX=0 OR JPPMIN=1000 '                                                                  
C      WRITE(*,*)' OUTPUT BANK  BEFORE PROJECTION'                                                            
C      PRINT 1014,IM,NT,(IRPT(I1,NT,IM),I1=1,12)                                                              
CDEB  PRINT 1015,IM,NT,(SDRFT(I1,NT,IM),I1=1,12)                                                              
C     LOOK FOR CLUSTER ON NEARBY WIRES                                                                        
C     CALCULATE PARAMETERS FOR PROJECTION IN PHI                                                              
C     UNLESS FULL LINE SEGMENT                                                                                
C                                                                                                             
C     CHECK ADJACENT WIRE - LOWER NUMBER- SAVE IC                                                             
C     IF IC=1 EXAMINE 48 AS LOWER NUMBER                                                                      
C     IF(IC.EQ.1)IC=49                                                                                        
C     NOTE IABS BECAUSE THERE COULD BE USEFUL POINTS THAT DO NOT FORM TR                                      
C     CHECK PHI CONTINUITY                                                                                    
C     PREDICT PHI                                                                                             
CDEB  WRITE(*,*)' LOW CLUSTER PHI ',PHIP,YN(1),YN(2)                                                          
C     DD2=ABS(YN(IS)-PHIP+PI2)                                                                                
C     DD2=ABS(YN(IS)-PHIP-PI2)                                                                                
C     DD=AMIN1(DD1,DD2,DD3)                                                                                   
C     CALL HFILL(70006,DDAS,0.,1.)                                                                            
C     GOOD POINT - CONT. IN PHI                                                                               
CDEB  WRITE(*,*)' OUTPUT BANK AFTER ADDING LOWER CLUSTER'                                                     
CDEB  PRINT 1004,NT,(IRPT(I1,NT,IM),I1=1,12)                                                                  
C1004 FORMAT(' IRPT ',I5,1X,12I3)                                                                             
CDEB  PRINT 1005,NT,(SDRFT(I1,NT,IM),I1=1,12)                                                                 
C1005 FORMAT(' SDRFT',I5,1X,12F3.0)                                                                           
C     RESET IC IN CASE CHANGED                                                                                
C     CHECK ADJACENT WIRE - HIGHER NUMBER                                                                     
C     IF IC=48 EXAMINE IC=1 AS HIGHER NUMBER                                                                  
C     IF(IC.EQ.48)IC=0                                                                                        
C     CHECK PHI CONTINUITY                                                                                    
C     PREDICT PHI                                                                                             
CDEB  WRITE(*,*)' HIGH CLUSTER PHI ',PHIP,YN(1),YN(2)                                                         
C     DD2=ABS(YN(IS)-PHIP+PI2)                                                                                
C     DD2=ABS(YN(IS)-PHIP-PI2)                                                                                
C     DD=AMIN1(DD1,DD2,DD3)                                                                                   
C     CALL HFILL(70006,DDAS,0.,1.)                                                                            
C     GOOD POINT - CONT. IN PHI                                                                               
CDEB  WRITE(*,*)' OUTPUT BANK AFTER ADDING HIGHER CLUSTER'                                                    
CDEB  PRINT 1004,NT,(IRPT(I1,NT,IM),I1=1,12)                                                                  
C1004 FORMAT(' IRPT ',I5,1X,12I3)                                                                             
CDEB  PRINT 1005,NT,(SDRFT(I1,NT,IM),I1=1,12)                                                                 
C1005 FORMAT(' SDRFT',I5,1X,12F3.0)                                                                           
C     RESET IC IN CASE CHANGED                                                                                
C     WRITE(*,*)' NTIN,NTRAKS(IM) ',NTIN,NTRAKS(IM)                                                           
C     WRITE(*,*)' FTLISA OUT ',NTRAKS(IM)                                                                     
C     PRINT 1014,IM,NT,(IRPT(I1,NT,IM),I1=1,12)                                                               
C     PRINT 1015,IM,NT,(SDRFT(I1,NT,IM),I1=1,12)                                                              
C     REEXAMINE CLUSTER                                                                                       
C      IF(IWC(IC).GT.0)THEN                                                                                   
C      WRITE(*,*)' GT 500 REEXAMINE CLUSTER IWC',IWC(IC),IC                                                   
C      DO 3000 I=1,10                                                                                         
C      PRINT 4000,I,(IUSED(I,II),II=1,36)                                                                     
C 4000 FORMAT(' IUSED ',I5,3X,12I1,1X,12I1,1X,12I1)                                                           
C 3000 CONTINUE                                                                                               
C      ENDIF                                                                                                  
C     RESET DMINX                                                                                             
C                                                                                                             
C     CORRECT R FOR LORENTZ ANGLE FOR                                                                         
C     FOUND TRACK SEGMENTS                                                                                    
C     PLANE #                                                                                                 
C     POINT #                                                                                                 
C     DRIFT SIGN                                                                                              
     1 +FLOREN(RM(NP,IP),DRI(NP,IP),SGN)
C                                                                                                             
C     PRINT 1014,IM, I,(IRPT(I1, I,IM),I1=1,12)                                                               
C     PRINT 1015,IM, I,(SDRFT(I1, I,IM),I1=1,12)                                                              
*