FPDG33 COMMENTS
*-- Author :  R. Henderson
      SUBROUTINE FPDG33(IP)
**: FPDG33 40000 RH. New steering parameter.                                                                  
*------------------------------------------------------------------                                           
**: FPDG33 30907 RH. Bug fix in cluster finding.                                                              
C------------------------------------------------------------------                                           
C                                                                                                             
C---  This routine finds clusters from 3 digitizings                                                          
C---  wires 2 3 4 only                                                                                        
C---  This routine should always be called from within FPDG4                                                  
C---  after FPDG31                                                                                            
C                                                                                                             
C---                                                                                                          
*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                                                                                                             
C---                                                                                                          
*KEND.                                                                                                        
C---                                                                                                          
*KEEP,FPLGEO.                                                                                                 
C---                                                                                                          
C---                                                                                                          
*KEND.                                                                                                        
C---                                                                                                          
*KEEP,FPCLUS.                                                                                                 
C---                                                                                                          
*KEND.                                                                                                        
C---                                                                                                          
*KEEP,FPH1WRK.                                                                                                
C--    *KEEP,FPCSEG.                                                                                          
C---                                                                                                          
C---                                                                                                          
C--    *KEEP,FPDIGI.                                                                                          
C---                                                                                                          
C--    *KEEP,FPDGI.                                                                                           
C---                                                                                                          
C--    *KEEP,FPSTID.                                                                                          
C---                                                                                                          
C--    *interface to real data                                                                                
C---.                                                                                                         
*KEND.                                                                                                        
C---                                                                                                          
C---                                                                                                          
C-------------------------------------------------------------------                                          
C                     DIGITS ANALYSIS                                                                         
C                                                                                                             
C   The following arrays are used in the remainder of this routine                                            
C                                                                                                             
C       drsto(drift,wire_in_orientation):                                                                     
C       This has both drift and reflection per orientation                                                    
C                                                                                                             
C       ndrsto(wire_in_orientation):                                                                          
C       Number of drifts + reflections on wire (Naughty)                                                      
C                                                                                                             
C       drmask(drift,wire_in_orientation):                                                                    
C       1.0 If digit or reflection used                                                                       
C       0.0 If digit or reflection unused                                                                     
C                                                                                                             
C       idigst(wire_in_orientation,found_segment_candidate):                                                  
C       index of digitising associated with a particular                                                      
C       candidate segment for a particular wire                                                               
C                                                                                                             
C       nsgtab(candidate_segment):                                                                            
C       Number of candidate segments with which current segment                                               
C       shares digitizings                                                                                    
C                                                                                                             
C       segtab(candidate_segment,associated_ambiguous_segments):                                              
C       segment index ambiguous with current segment                                                          
C                                                                                                             
C-------------------------------------------------------------------                                          
C                                                                                                             
C---  tolerance for finding digitizings                                                                       
C                                                                                                             
C                                                                                                             
C---  define maximum slope to be found for segment                                                            
C                                                                                                             
C                                                                                                             
C---  Section to find 2d line segments                                                                        
C                                                                                                             
C---  loop over first and last wire in orientation                                                            
C---  but allow one of the intermediate points to be missing                                                  
C                                                                                                             
C                                                                                                             
C---  entry point for more relaxed segment search                                                             
C---  ifirst = 1 on first pass through                                                                        
C                                                                                                             
C                                                                                                             
C---  determine if dealing with a split cell                                                                  
C                                                                                                             
C                                                                                                             
C---  On first pass filter out large slopes                                                                   
C                                                                                                             
C---                                                                                                          
C                                                                                                             
C---  use tolerance to find digitizings to form segments                                                      
C                                                                                                             
C                                                                                                             
C---  plane 2                                                                                                 
C                                                                                                             
C                                                                                                             
C---  store the digitizing per segment found                                                                  
C                                                                                                             
        CALL ERRLOG(209,'W:FPDG33: NSEG > MSEGLM')                                                     
C                                                                                                             
C---  Now sort out which initial segments to keep                                                             
C                                                                                                             
C                                                                                                             
C---  Create segtab showing interconnectivity                                                                 
C                                                                                                             
      CALL VZERO(NSGTAB,MSEGLM)                                                                        
C                                                                                                             
C---  loop over remaining segments                                                                            
C                                                                                                             
C                                                                                                             
C---  comparison loop over each wire in turn                                                                  
C                                                                                                             
C                                                                                                             
C---  has the same wire the same digit                                                                        
C                                                                                                             
C                                                                                                             
C--- remove nodes greater than or equal to 3                                                                  
C                                                                                                             
       CALL VFLOAT(NSGTAB,ASGTAB,NSEG)                                                                 
C                                                                                                             
C--- greater than 2.0 so remove by setting nsgtab = -1.0                                                      
C                                                                                                             
C                                                                                                             
C--- Now remove any reference to this node in the remaining nodes                                             
C                                                                                                             
C                                                                                                             
C---  Now try to find loops and angles and eliminate                                                          
C                                                                                                             
C                                                                                                             
C---  Find first candidate with 2 links                                                                       
C                                                                                                             
C                                                                                                             
C---  Now trace its path                                                                                      
C                                                                                                             
C                                                                                                             
C---  Entry point for step along chain                                                                        
C                                                                                                             
C                                                                                                             
C---  Test if path at end                                                                                     
C                                                                                                             
C                                                                                                             
C---  Skip link if pointing back                                                                              
C                                                                                                             
C                                                                                                             
C---  Store next element of chain                                                                             
C                                                                                                             
C                                                                                                             
C---  Test if loop complete                                                                                   
C                                                                                                             
C                                                                                                             
C---  Points to next element in chain                                                                         
C                                                                                                             
C                                                                                                             
C---  End of branch one                                                                                       
C                                                                                                             
C                                                                                                             
C---  This cannot be a loop so kill off node                                                                  
C                                                                                                             
C                                                                                                             
C--- Now remove any reference to this node in the remaining nodes                                             
C                                                                                                             
C                                                                                                             
C---  Now continue on node loop                                                                               
C                                                                                                             
C                                                                                                             
C---  Loop complete                                                                                           
C                                                                                                             
C                                                                                                             
C---  Perform fits and eliminate all but one node in loop                                                     
C                                                                                                             
       CALL FPCFIT(IP,Y,W,SLOPE,ZERO,COVSLZ,CHISQ,PBCHI)
C                                                                                                             
C---  Keep only highest probability iff prob gt 10**-5                                                        
C                                                                                                             
C                                                                                                             
C---  now loop over segments and remove all but the saved                                                     
C                                                                                                             
C                                                                                                             
C--- Now remove any reference to this node in the remaining nodes                                             
C                                                                                                             
C                                                                                                             
C                                                                                                             
C--- now remove any pairs by fitting                                                                          
C                                                                                                             
C                                                                                                             
C---  Found a pair so find partner                                                                            
C                                                                                                             
C                                                                                                             
C---  fit the first possiblity                                                                                
C                                                                                                             
       CALL FPCFIT(IP,Y,W,SLOPE,ZERO,COVSLZ,CHISQ1,PBCHI1)
C                                                                                                             
C---  Fit the second possiblity                                                                               
C                                                                                                             
       CALL FPCFIT(IP,Y,W,SLOPE,ZERO,COVSLZ,CHISQ2,PBCHI2)
C                                                                                                             
C---  Now remove the smaller probability segment                                                              
C                                                                                                             
C                                                                                                             
C--- Now remove any reference to this node in the remaining nodes                                             
C                                                                                                             
C                                                                                                             
C---  Now draw remaining segments                                                                             
C                                                                                                             
C                                                                                                             
C---  fit remaining segments                                                                                  
C                                                                                                             
       CALL FPCFIT(IP,Y,W,SLOPE,ZERO,COVSLZ,CHISQ,PBCHI)
C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                         
C                                                                                                             
C---  find the absolute coordinate normal current wire orientation                                            
C                                                                                                             
C                                                                                                             
C---  find which orientation plane (1-9) is current                                                           
C                                                                                                             
C                                                                                                             
C---  find fitted 'y' position at begining and end of 4 wire set                                              
C---  fdrsta and fdrend respectively                                                                          
C                                                                                                             
C                                                                                                             
C---  Transform from orientation drift coordinates to global coordinates                                      
C---  assuming that drift x coordinate is zero                                                                
C                                                                                                             
C                                                                                                             
C---  Fill track cluster banks and banks counter                                                              
C                                                                                                             
C                                                                                                             
C---  Increment cluster counter per plane                                                                     
C                                                                                                             
        CALL ERRLOG(210,'W:FPDG33: NTC(IPLANE) > MAXCLU')                                              
C                                                                                                             
C---  store toc                                                                                               
C                                                                                                             
C                                                                                                             
C---  store the digitisings associated with plane/track for final                                             
C     fit                                                                                                     
C                                                                                                             
C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                               
C                                                                                                             
C---  Now plot unused digitisizings                                                                           
C                                                                                                             
C                                                                                                             
C---  Set drmask to 1.0 for used digits                                                                       
C                                                                                                             
C                                                                                                             
C---  If first pass now loop back with 2*tolerance and 3*maxang                                               
C                                                                                                             
*