FUNCTION FFRJCT
*-- Author : Stephen Burke
      LOGICAL FUNCTION FFRJCT(QBYP)
*-----------------------------------------Updates 07/09/93-------                                             
**: FFRJCT 40000 SB. Min. no. of hits for radial-only tracks.                                                 
*-----------------------------------------Updates----------------                                             
**********************************************************************                                        
*                                                                    *                                        
* Makes an initial decision on whether to reject the track, or       *                                        
* points on it                                                       *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      DOUBLE PRECISION QBYP                                             
      DIMENSION MODP(9),MODR(3)                                         
      SAVE MODP,MODR                                                    
                                                                        
*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,FFSTEE.                                                                                                 
      PARAMETER (NFT=72)                                                
      LOGICAL LRISV,LWMAP,LGRAPH,LTRUTH                                 
      REAL DSX,DSY,DSQOP,DSTTH,DSPHI,PMCUT,PCUT,CHPCUT                  
     &,    QOPMAX,THEMAX,RFTMIN,RFTMAX,CEMAX                            
      COMMON /FFSTEE/ DSX,DSY,DSQOP,DSTTH,DSPHI                         
     &,               PMCUT,IDIAG,JPLRSV,LRISV,LWMAP(NFT),JPLMAX        
     &,               IRP(NPL),JPLFT(NPL),JFTPL(NFT)                    
     &,               LUNGKS,IWKGKS,IDGKS,LUNHB,LUNGKM,IWKGKM,IDGKM     
     &,               LGRAPH,LTRUTH,IHFF,IHFK,ISRJCT,PCUT,CHPCUT        
     &,               QOPMAX,THEMAX,RFTMIN,RFTMAX,CEMAX                 
*KEEP,FFSCAL.                                                                                                 
* Counters                                                                                                    
      PARAMETER (NSCAL=145)                                             
      COMMON /FFSCAL/ NPFAIL,NRFAIL,NXFAIL,NFFAIL,NMFAIL,NBFAIL,NTFAIL  
     &,               NWFAIL,NNSPLT,NNMISS,NNMISP                       
     &,               NQFAIL,NAFAIL,NOFAIL,NIFAIL                       
     &,               NTRIN,NTROUT,NPRSEG(0:7,0:7),N23SEG(0:7,0:7)      
*KEEP,FKFLAG.                                                                                                 
      LOGICAL LPRO,LFIL,LSMT,LMES,LRAD,LRPRO,LRFIL,LRSMT,LPOINT,LBLOCK  
      COMMON /FKFLAG/ LPRO(NPL),LFIL(NPL),LSMT(NPL),LMES(NPL)           
     &,               LRAD(NPL),LRPRO,LRFIL,LRSMT,LPOINT,LBLOCK         
*KEND.                                                                                                        
                                                                        
      DATA MODP/1,5,9,25,29,33,49,53,57/                                
      DATA MODR/13,37,61/                                               
                                                                        
**********************************************************************                                        
                                                                        
      FFRJCT = .TRUE.                                                   
                                                                        
      IF (PCUT.GT.0 .AND. ABS(SNGL(QBYP)).GT.1./PCUT) THEN              
         NMFAIL = NMFAIL + 1                                            
         RETURN                                                         
      ENDIF                                                             
                                                                        
      NRHIT  = MOD(ISRJCT/10,100)                                       
      NRMOD  = MOD(ISRJCT,10)                                           
                                                                        
* Must have more than NRMOD modules with NRHIT hits each                                                      
      NMODR = 0                                                         
      NTOTR = 0                                                         
      DO 200 JMOD=1,3                                                   
         NHIT = 0                                                       
         MFT = MODR(JMOD)                                               
         DO 100 JFT=MFT,MFT+11                                          
            JPL = JFTPL(JFT)                                            
            IF (JPL.GT.0 .AND. LMES(JPL)) NHIT = NHIT + 1               
 100     CONTINUE                                                       
         NTOTR = NTOTR + NHIT                                           
         IF (NHIT.GE.NRHIT) NMODR = NMODR + 1                           
 200  CONTINUE                                                          
                                                                        
* Kill radials if less than 9 hits total (reduces space in FTKR/DTNV)                                         
      IF (NTOTR.LT.9) NMODR = 0                                         
                                                                        
      IF (NMODR.LT.NRMOD) THEN                                          
         NRFAIL = NRFAIL + 1                                            
         RETURN                                                         
      ENDIF                                                             
                                                                        
      NPKILL = MOD(ISRJCT/1000000,10)                                   
      NPHIT  = MOD(ISRJCT/100000,10)                                    
      NPMOD  = MOD(ISRJCT/10000,10)                                     
      NPSMOD = MOD(ISRJCT/1000,10)                                      
                                                                        
* Must have NPHIT hits in NPMOD modules in NPSMOD supermodules                                                
      NSMOD = 0                                                         
      DO 700 JSMOD=0,2                                                  
         NMODP = 0                                                      
         DO 500 JMOD=1,3                                                
            MFT = MODP(3*JSMOD+JMOD)                                    
            NHIT = 0                                                    
            DO 300 JFT=MFT,MFT+3                                        
               JPL = JFTPL(JFT)                                         
               IF (JPL.GT.0 .AND. LMES(JPL)) NHIT = NHIT + 1            
 300        CONTINUE                                                    
            IF (NHIT.GE.NPHIT) THEN                                     
               NMODP = NMODP + 1                                        
            ELSEIF (NPKILL.GT.0) THEN                                   
               DO 400 JFT=MFT,MFT+3                                     
                  JPL = JFTPL(JFT)                                      
                  IF (JPL.GT.0) LMES(JPL) = .FALSE.                     
 400           CONTINUE                                                 
            ENDIF                                                       
 500     CONTINUE                                                       
         IF (NMODP.GE.NPMOD) THEN                                       
            NSMOD = NSMOD + 1                                           
         ELSEIF (NPKILL.GT.0) THEN                                      
            MFT = MODP(3*JSMOD+1)                                       
            DO 600 JFT=MFT,MFT+11                                       
               JPL = JFTPL(JFT)                                         
               IF (JPL.GT.0) LMES(JPL) = .FALSE.                        
 600        CONTINUE                                                    
         ENDIF                                                          
 700  CONTINUE                                                          
                                                                        
      IF (NSMOD.GE.NPSMOD) THEN                                         
         FFRJCT = .FALSE.                                               
      ELSE                                                              
         NPFAIL = NPFAIL + 1                                            
      ENDIF                                                             
                                                                        
* Must have at least one module above the threshold number of hits                                            
      IF (NMODR+NSMOD.LT.1) THEN                                        
         FFRJCT = .TRUE.                                                
         NRFAIL = NRFAIL + 1                                            
         RETURN                                                         
      ENDIF                                                             
                                                                        
      RETURN                                                            
      END                                                               
*