SUBROUTINE FQEND
*-- Author :    John V. Morris   28/06/93
      SUBROUTINE FQEND
**********************************************************************                                        
*                                                                    *                                        
* Copy the end-of-run statistics from histogram number 26, filled on *                                        
* the farm, into the corresponding off-line arrays and variables.    *                                        
*                                                                    *                                        
* JVM 22/6/93                                                        *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
*KEEP,FHLUN.                                                                                                  
      COMMON/FHLUN/ LUNH, LUNS, LMES, IL4L5                             
*KEEP,FHITLS.                                                                                                 
      COMMON/FHITLS/ LHITSP(0:8), LHITSR(0:8)                           
*KEEP,FCOUNT.                                                                                                 
      COMMON/FCOUNT/ NDATE0,NTIME0,ISTATP(20),ISTATR(20),IFRHV,IFPHV,   
     &               NEVENT,NFIEL0,NPRES0,NECUR0,NPCUR0,IRTE0,IRTP0,    
     &               IEVIN,NFPEVT,NHITSP,NFREVT,NHITSR,NMIN92,          
     &               TOTL,H1L,RTIME,REFF,ILRET                          
*     TOTL   total run luminosity (mb^-1)                                                                     
*     H1L    H1 gated run luminosity (mb^-1)                                                                  
*     RTIME  total run time (sec)                                                                             
*     REFF   run efficiency = (1 - dead_time/run_time)                                                        
*     ILRET  return flag: 0 - ok,  1 - no inf. found in H1DB                                                  
*KEEP,FTOTST.                                                                                                 
      PARAMETER(LENST=66)                                               
      COMMON/FTOTST/ ISTSUM(LENST)                                      
*KEEP,FTQRUN.                                                                                                 
      LOGICAL PLANAR,RADIAL                                             
      COMMON /FTQRUN/  NRUN,NRUN0,NRUN1,MAXEV,PLANAR,RADIAL             
*KEND.                                                                                                        
      INTEGER  IBT(220)                                                 
                                                                        
                                                                        
* ISTSUM should have been filled in FLK2HB                                                                    
* fill the elements of ISTATP and ISTATR ....                                                                 
                                                                        
      DO 101 J=1,20                                                     
      LOCP = 7+J                                                        
      LOCR = 27+J                                                       
      ISTATP(J) = ISTSUM(LOCP)                                          
      ISTATR(J) = ISTSUM(LOCR)                                          
  101 CONTINUE                                                          
                                                                        
      DO 201 J=0,8                                                      
      LOCP = 48+J                                                       
      LOCR = 57+J                                                       
      LHITSP(J) = ISTSUM(LOCP)                                          
      LHITSR(J) = ISTSUM(LOCR)                                          
  201 CONTINUE                                                          
                                                                        
      IF(NRUN0.LT.59419 .OR. NRUN0.GT.59922) IEVIN  = ISTSUM(LENST)     
                                                                        
* fill the remaining run statistics in /FCOUNT/                                                               
* in principle the first 7 elements of ISTSUM hold this data, but                                             
* it can equally well be extracted from the database?                                                         
      CALL GETEAR(NRUN0,IDATE,ITIME,IBFLD,IPRESS,IFR,IFP,IRET)                                         
      IF(IRET.EQ.0) THEN                                                
        NDATE0 = IDATE                                                  
        NTIME0 = ITIME                                                  
        CALL DMIN92(NDATE0,NTIME0,NMIN92)                                                              
        NFIEL0 = IBFLD                                                  
        NPRES0 = IPRESS                                                 
        IFRHV = IFR                                                     
        IFPHV = IFP                                                     
      ELSE                                                              
        NPROC  = INT(FLOAT(ISTSUM(1))/FLOAT(NRUN0)+0.5)                 
        NDATE0 = ISTSUM(2)/NPROC                                        
        NTIME0 = ISTSUM(3)/NPROC                                        
        CALL DMIN92(NDATE0,NTIME0,NMIN92)                                                              
        NFIEL0 = ISTSUM(4)/NPROC                                        
        NPRES0 = ISTSUM(5)/NPROC                                        
        IFRHV = 2                                                       
        IFPHV = 2                                                       
      ENDIF                                                             
      CALL EPBEAM(NRUN0,PTC,PPC,ETC,EPC,IBT,IRET)                                                      
      IF(IRET.EQ.0) THEN                                                
        NECUR0 = INT(ETC)                                               
        IRTE0 = 0                                                       
        NPCUR0 = INT(PTC)                                               
        IRTP0 = 0                                                       
      ELSE                                                              
        IRTE0 = 1                                                       
        IRTP0 = 1                                                       
      ENDIF                                                             
      NRUN1  = NRUN0                                                    
      NRUN   = NRUN0                                                    
                                                                        
      CALL GETH1L (NRUN0,TOTL,H1L,RTIME,REFF,ILRET)                                                    
                                                                        
      RETURN                                                            
      END