SUBROUTINE FPFTUR
*-- Author : S.J. Maxfield
      SUBROUTINE FPFTUR
*-----------------------------------------------------------*                                                 
*     Print output banks from Forward Pattern recognition   *                                                 
*     in readable form.                                     *                                                 
*-----------------------------------------------------------*                                                 
*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     ------                                                                                                  
*KEEP,H1EVDT.                                                                                                 
      COMMON /H1EVDT/ KEVENT,IDATA,MONTE,LCONF                          
      INTEGER KEVENT,IDATA,LCONF                                        
      LOGICAL MONTE                                                     
*                                                                                                             
*  IDATA  type of information (HEAD bank word 6) :                                                            
*                                                                                                             
*                       0 - real data H1                                                                      
*                       1 - MC data H1SIM                                                                     
*                       2 - real data CERN tests                                                              
*                       3 - MC data ARCET                                                                     
*                                                                                                             
*  MONTE = .TRUE.   if IDATA=1                                                                                
*  KEVENT = event processed counter for H1REC                                                                 
*                                                                                                             
*KEND.                                                                                                        
*     Diagnostic flag from FRCS BANK                                                                          
*KEEP,FDIFLG.                                                                                                 
      COMMON/LDIAG/IDIAG,IDIAG2,MAXPRT,IDOHIS,PMCUT                     
*KEND.                                                                                                        
      DIMENSION COV(5,5)                                                
*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))                           
*KEND.                                                                                                        
*     FTUR bank...                                                                                            
      NBN = 0                                                           
      IND = NLINK('FTUR',NBN)
      IF(IND.EQ.0) THEN                                                 
        WRITE(6,*) ' FPFTUR>> FTUR Bank not found in event ',NEVENT     
        RETURN                                                          
      ENDIF                                                             
      NROW = IW(IND+2)                                                  
      WRITE(6,'(''  '')')                                               
      WRITE(6,'(/,8X,'' -------  FTUR BANK:  Event'',I10,               
     +          2X,I4,'' tracks -------'')')                            
     +      NEVENT,NROW                                                 
      WRITE(6,'(10X,'' Level zero track fits'')')                       
      WRITE(6, '(                                                       
     +      ''Trk      Cu     Phi   Theta'',                            
     +          ''       x       y       z'',                           
     +          '' Ndf  Chsq FPUR'')')                                  
      DO 1 J= 1,NROW                                                    
        WRITE(6,'(I3,6(1X,F7.3),I4,F6.3,I5)')                           
     +                J,(RBTAB(IND,K,J), K=1,6),IBTAB(IND,17,J),        
     +                   RBTAB(IND,18,J),IBTAB(IND,21,J)                
 1    CONTINUE                                                          
      IF(IDIAG.GE.2) THEN                                               
      DO 2 J=1,NROW                                                     
*     Track 4-momentum...                                                                                     
        CURV =  RBTAB(IND,1,J)                                          
        PHI  =  RBTAB(IND,2,J)                                          
        THET =  RBTAB(IND,3,J)                                          
        IF(ABS(CURV) .GT. 0.0) THEN                                     
           PTMEAS = ABS(0.0002998*12.0/CURV)                            
           PMEAS  = PTMEAS/SIN(THET)                                    
           PXMEAS = PTMEAS * COS(PHI)                                   
           PYMEAS = PTMEAS * SIN(PHI)                                   
           PZMEAS = PMEAS / TAN(THET)                                   
           WRITE(6,'(/,''   Momentum of Track '',I4,                    
     +                 '' for 12 kG field'')') J                        
           WRITE(6, '(''        Px        Py        Pz         P'',     
     +               /, 4E10.3)') PXMEAS, PYMEAS, PZMEAS, PMEAS         
        ELSE                                                            
           WRITE(6,'(/,''      Momentum of Track '',I4)') J             
           WRITE(6, '('' ... is infinite'')')                           
        ENDIF                                                           
                                                                        
*     Decompress covariance matrix                                                                            
        CALL COVCP(5,COV,RW(INDCR(IND,8,J)),1)                                                         
        WRITE(6,'(/,''      Covariance Matrix for Track '',I4)') J      
        WRITE(6, '(''        Cu       Phi     Theta'',                  
     +             ''         x         y'',/,                          
     +    (5E10.3) )' )                                                 
     +                 COV                                              
 2    CONTINUE                                                          
      ENDIF                                                             
      RETURN                                                            
      END                                                               
*