FPCHI COMMENTS
*-- Author :    I. O. Skillicorn      31/08/93
      SUBROUTINE FPCHI(IM1,IM2,I,J,CHID)
**: FPCHI 40000 IS.  New routine to calculate chi-squared.                                                    
**----------------------------------------------------------------------                                      
C234567                                                                                                       
C     CALCULATES CHI RELATIVE TO HELIX FOR TWO-MODULE TRACKS                                                  
*ARRAY DIMENSIONS...                                                                                          
*KEEP,FRDIMS.                                                                                                 
*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---                                                                                                          
*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,FPFVTX.                                                                                                 
*                                                                                                             
*KEND.                                                                                                        
C     VERTEX FROM FIRST PLANAR MODULE                                                                         
C     HELIX DEFINED RELATIVE TO THIS VERTEX                                                                   
C     FIT HELIX TO FITTED LINE SEGMENTS                                                                       
C     STRAIGHT LINE PHI-Z                                                                                     
C      WRITE(*,*)' M1,M2,I,J ',IM1,IM2,I,J                                                                    
C      WRITE(*,*)' XFFF,YFFF,ZFFF ',XFFF,YFFF,ZFFF                                                            
C      WRITE(*,*)' IM,II,RH,XH,YH ',IM,II,RH,XH,YH                                                            
C     FIT PHI-Z IN HELIX FRAME                                                                                
      CALL FTLFTW(XX,YY,WP,IC,0,2,PS,PI,D1,D2,D3,D4)
C     FIT R-Z IN HELIX FRAME                                                                                  
C     STRAIGHT LINE IN R - SIN(.....)                                                                         
      CALL FTLFTW(XX,ZZ,WP,IC,0,2,RS,RI,D1,D2,D3,D4)
C     EXAMINE PLANAR RESIDUALS WITH RESPECT TO HELIX                                                          
*