SUBROUTINE FPFPLC
*-- Author :    Girish D. Patel   16/04/91
      SUBROUTINE FPFPLC
**: FPFPLC 30907 RP. Farm changes.                                                                            
*-----------------------------------------------------------*                                                 
*     Print output banks from Forward Pattern recognition   *                                                 
*     in readable form.  FPLC local coordinate bank.        *                                                 
*-----------------------------------------------------------*                                                 
*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     ------                                                                                                  
*KEND.                                                                                                        
      COMMON /FPF8WW/ INDFPX                                            
*KEEP,STFUNCT.                                                                                                
*     index of element before row number IROW                                                                 
      INDR(IND,IROW)=IND+2+IW(IND+1)*(IROW-1)                           
*     index of L'th element  of row number IROW                                                               
      INDCR(IND,L,IROW)=INDR(IND,IROW) + L                              
*     L'th integer element of the IROW'th row of bank with index IND                                          
      IBTAB(IND,L,IROW)=IW(INDCR(IND,L,IROW))                           
*     L'th real element of the IROW'th row of bank with index IND                                             
      RBTAB(IND,L,IROW)=RW(INDCR(IND,L,IROW))                           
*KEEP,FTFUNCT.                                                                                                
*     Statement functions for RADIAL Chamber data access.                                                     
*     Using Channel Number J                                                                                  
                                                                        
*     Module, Wedge-pair and Z-plane numbers...                                                               
      IRMOD(J) = J/288                                                  
      IRWDP(J) = (J-IRMOD(J)*288)/12                                    
      IRZPL(J) =  J-IRMOD(J)*288-IRWDP(J)*12                            
*     Statement function for obtaining WEDGE numbers(0-47) of                                                 
*     wires at plus and minus ends of Cell numbers                                                            
      IRWPL(J) = (IRWDP(J)/2)*4 + (MOD(IRWDP(J),2))                     
      IRWMI(J) = MOD(IRWPL(J) + 34,48)                                  
*     Statement function for obtaining IOS wire number (1-36)                                                 
      IRIOSW(J) = IRMOD(J)*12 + IRZPL(J) + 1                            
                                                                        
*     Statement functions for PLANAR Chamber data access.                                                     
*     Using Channel Number J                                                                                  
                                                                        
*     Module, orientation, W-cell and Z-plane numbers...                                                      
      IPMOD(J)  = J/384                                                 
      IPORI(J)  = (J-IPMOD(J)*384)/128                                  
      IPWCL(J)  = (J-IPMOD(J)*384-IPORI(J)*128)/4                       
      IPZPL(J)  = (J-IPMOD(J)*384-IPORI(J)*128-IPWCL(J)*4)              
                                                                        
*     IPSMD in range 0:8 Planar module number.                                                                
      IPSMD(J)  = IPMOD(J)*3 + IPORI(J)                                 
*                                                                                                             
*     IOS wire number (runs from 0 to 36)                                                                     
      IPIOSW(J) = IPSMD(J)*4 + IPZPL(J) + 1                             
                                                                        
* SB plane numbers (1-72) from cell number                                                                    
      IPSBW(J) = 24*IPMOD(J) + 4*IPORI(J) + IPZPL(J) + 1                
      IRSBW(J) = 24*IRMOD(J)              + IRZPL(J) + 13               
                                                                        
* Module, orientation, wire and (typical) cell number from plane                                              
* number in the range 1-72 (planars, radials and combined)                                                    
      IPMSB(J)  = (J - 1)/24                                            
      IPOSB(J)  = (J - 24*IPMSB(J) - 1)/4                               
      IPZSB(J)  = J - 24*IPMSB(J) - 4*IPOSB(J) - 1                      
      IPCLSB(J) = 384*IPMSB(J) + 128*IPOSB(J) + IPZSB(J)                
                                                                        
      IRMSB(J)  = (J - 1)/24                                            
      IRZSB(J)  = J - 24*IRMSB(J) - 13                                  
      IRCLSB(J) = 288*IRMSB(J) + IRZSB(J)                               
                                                                        
      IRADSB(J) = (J - 24*((J-1)/24) - 1)/12                            
      ICELSB(J) = IRADSB(J)*IRCLSB(J) + (1 - IRADSB(J))*IPCLSB(J)       
*KEND.                                                                                                        
                                                                        
      NBN = 0                                                           
      IND = NLINK('FPLC',NBN)
      IF(IND.EQ.0) THEN                                                 
        WRITE(6,*) ' FPFPLC>> FPLC Bank not found in event ',NEVENT     
        RETURN                                                          
      ENDIF                                                             
      NROW = IW(IND+2)                                                  
                                                                        
      WRITE(6,'(''  '')')                                               
      WRITE(6,'(/,8X,'' -------  FPLC BANK:  Event'',I10,               
     +          2X,I4,'' Hits ---------'')')                            
     +      NEVENT,NROW                                                 
      IF(NROW .GT.0) THEN                                               
                                                                        
      NBN = 0                                                           
      INDE = NLINK('FPUX',NBN)
                                                                        
      INDFPX = 0                                                        
      IF(INDE .NE. 0) THEN                                              
         CALL BKTOW(IW,'FPUX',NBN,IW,INDFPX,*900)
      ELSE                                                              
         WRITE(6,'('' FPFPLC Error ... Hits but no FPUX bank!'')')      
      ENDIF                                                             
                                                                        
      WRITE(6, '(                                                       
     +      '' Row Cel Pln   Drf  Edrf   Phiw   Wwir'',                 
     +              ''     w+     w-      z Sg'')')                     
                                                                        
      DO 1 J= 1,NROW                                                    
*       Calculate w coordinates of the hit (both solutions)                                                   
        CALL FPWHIT(J,WWP,WWM,PHW,WWIR,ZZ,IBAD)
*       Sign of hit from FPUX bank                                                                            
        IF(INDFPX .NE. 0) THEN                                          
          IUSED = IBTAB(INDFPX,1,J)                                     
          IF(IUSED .NE. 0) THEN                                         
            ISIGN = IBTAB(INDFPX,2,J)                                   
          ELSE                                                          
            ISIGN = -1                                                  
          ENDIF                                                         
        ELSE                                                            
          ISIGN = -1                                                    
        ENDIF                                                           
                                                                        
        WRITE(6,'(I4,I5,I4,2(F6.3),5(1X,F6.2),I3)')                     
     +          J, IBTAB(IND,1,J),                                      
     +             IPIOSW(IBTAB(IND,1,J)),                              
     +            (RBTAB(IND,K,J), K=2,3),                              
     +          PHW, WWIR, WWP, WWM, ZZ, ISIGN                          
                                                                        
 1    CONTINUE                                                          
                                                                        
      ENDIF                                                             
 900  CONTINUE                                                          
      CALL WDROP(IW,INDFPX)                                                                            
      RETURN                                                            
      END                                                               
*