SUBROUTINE FFNUM
*-- Author : S.Burke
      SUBROUTINE FFNUM(JTYPE,JHIT,ITRUE)
**********************************************************************                                        
*                                                                    *                                        
* Count the number of hits for each track                            *                                        
*                                                                    *                                        
* JTYPE is 1 for planars and 2 for radials.                          *                                        
* JHIT is the row number in the FRsX bank.                           *                                        
* ITRUE is an array which counts the number of hits for each STR.    *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      DIMENSION ITRUE(2,1000)                                           
                                                                        
*KEEP,FKNPL.                                                                                                  
      CHARACTER*5 CKDBG                                                 
      PARAMETER (CKDBG='FKDBG')                                         
      PARAMETER (NPL=72)                                                
      LOGICAL LTRUE,LFIRST,LTRPL,LTRPLD                                 
      DOUBLE PRECISION TRUE,RTRUE,CHITRU,SPRO,CPRO,SFIL,CFIL            
     &,                SSMT,CSMT,SSMTR,CSMTR,DPRO,CBPRO,QPRO,QGAIN      
     &,                RPRO,CRPRO,RFIL,CRFIL,RSMT,CRSMT,CHIFIL,CHISMT   
*                                                                                                             
* Per-track values can go in H1WORK; note that LTRUE and LFIRST must                                          
* be set at least per event.                                                                                  
*                                                                                                             
* This is about 36k words long; the remaining common blocks are                                               
* about 3.6k in total. Some of this could be in /H1WORK/, but the                                             
* blocks would have to be reorganised.                                                                        
*                                                                                                             
      COMMON /H1WORK/                                                   
* /FKPROJ/                                                                                                    
     &                SPRO(5,NPL),CPRO(5,5,NPL)                         
* /FKFILT/                                                                                                    
     &,               SFIL(5,NPL),CFIL(5,5,NPL)                         
* /FKSMTH/                                                                                                    
     &,               SSMT(5,NPL),CSMT(5,5,NPL)                         
     &,               SSMTR(5,NPL),CSMTR(5,5,NPL)                       
* /FKINT/                                                                                                     
     &,               DPRO(5,5,NPL),CBPRO(5,5,NPL),QPRO(5,5,NPL)        
     &,               QGAIN(5,5,NPL),IAPROX,LFIRST                      
* /FKRSID/                                                                                                    
     &,               RPRO(2,NPL),CRPRO(2,2,NPL),RFIL(2,NPL)            
     &,               CRFIL(2,2,NPL),RSMT(2,NPL),CRSMT(2,2,NPL)         
     &,               CHIFIL(NPL),CHISMT(NPL)                           
* /FKTRUE/                                                                                                    
     &,               TRUE(5,NPL),RTRUE(5,NPL),CHITRU(NPL),LTRUE        
* /FKDBG/                                                                                                     
     &,               LTRPL(NPL),LTRPLD(NPL)                            
*KEEP,FFWBI.                                                                                                  
* Work bank indices (note that INDKTR is *NOT* a work bank index!)                                            
      PARAMETER (NWBI=10)                                               
      COMMON /FFWBI/ INDRSX(2),INDX(2),INDKX(2),INDPUR                  
     &,              INDKTR,INDKTX,INDTPR                               
*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,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.                                                                                                        
                                                                        
**********************************************************************                                        
                                                                        
* True hits only                                                                                              
      IFLAG = IBTAB(INDRSX(JTYPE),1,JHIT)                               
      IF (IFLAG.GE.512) RETURN                                          
                                                                        
* See if this track has been seen before ...                                                                  
      JSTR   = IBTAB(INDRSX(JTYPE),2,JHIT)                              
      IFOUND = 0                                                        
      INUM   = 0                                                        
 100  CONTINUE                                                          
         INUM = INUM + 1                                                
         IF (INUM.GE.1000) RETURN                                       
         IF (JSTR.EQ.ITRUE(1,INUM)) THEN                                
            IFOUND = INUM                                               
         ELSEIF (ITRUE(1,INUM).GT.0) THEN                               
            GOTO 100                                                    
         ENDIF                                                          
                                                                        
* ... and increment the counter                                                                               
      IF (IFOUND.EQ.0) THEN                                             
         ITRUE(1,INUM) = JSTR                                           
         ITRUE(2,INUM) = 1                                              
      ELSE                                                              
         ITRUE(2,INUM) = ITRUE(2,INUM) + 1                              
      ENDIF                                                             
                                                                        
      RETURN                                                            
      END                                                               
*