C   10/09/82 701161320  MEMBER NAME  STAT82   (JADESR)      FORTRAN
      SUBROUTINE STAT82
C   MODIFIED 16/01/87    TO INTRODUCE MBYTE COUNT
#include "ciouni.for"
      COMMON /CIGG/ IPRN,IGG(80)
C------------
C  PAGE TITLE
C------------
C
C KILL FULL STATISTICS FOR INDIVIDUAL RUNS AND JUST PRINT ONE LINE
      IF(IGG(1).NE.0)GOTO10000
CCCCC IF(IGG(1).NE.0)PRINT1000,IGG(1)
C1000 FORMAT(1H1/
C    + 1X,116('=')/
C    + 1X,45('='),' STATISTICS FOR RUN',I6,1X,45('=')/
C    + 1X,116('='))
C
C END OF JOB SUMMARY
      IF(IGG(1).EQ.0)PRINT1001
 1001 FORMAT(1H1/
     + 1X,113('=')/
     + 1X,40('='),' OVERALL STATISTICS FOR THIS JOB ',40('=')/
     + 1X,113('='))
C-------------------
C PRINT RAW COUNTERS
C-------------------
      PRINT1010,(IGG(I),I=1,80)
 1010 FORMAT(/' INTEGER CONTENTS',1X,10I8/
     +        ' ----------------',1X,10I8/6(18X,10I8/))
C-------------------
C USER LEVELS CALLED
C-------------------
      PRINT1015,(IGG(I),I=5,10)
 1015 FORMAT(' USER LEVELS 3 TO 8',7X,6I8/
     +       ' ------------------'/)
C-----------------
C EVENT STATISTICS
C-----------------
      PRINT1016
 1016 FORMAT(' EVENT STATISTICS'/
     +       ' ----------------')
C--------------------
C PULSERSCALER EVENTS
C--------------------
      N4RED=IGG(4)-IGG(11)
      FRACTN=0.0
      IF(IGG(4).GT.0)FRACTN=100./FLOAT(IGG(4))
      FIGG11=IGG(11)*FRACTN
      PRINT1020,IGG(4),IGG(11),FIGG11,IGG(9),N4RED
 1020 FORMAT(/
     + 10X,I10,1X,'(100.00%) ',
     +'EVENTS READ'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'PULSER/SCALER EVENTS (REJECTED)'/
     + 10X,I10,11X,
     +'LGCALB ERROR RETURNS'/
     + 10X,I10,11X,
     +'EVENTS CONTINUE FOR PROCESSING BY REDUC1 PACKAGE'/)
C-----------------------------------
C TRIGGER ACCEPT / REJECT & POSTPONE
C-----------------------------------
      NLB48=N4RED-IGG(14)-IGG(15)-IGG(21)
      NLB8=IGG(24) + IGG(25)+IGG(27)+IGG(28)+IGG(29)+IGG(30)
      NLB4=NLB48-NLB8
      FLB4 =NLB4 *FRACTN
      FLB8 =NLB8 *FRACTN
      FIGG14=IGG(14)*FRACTN
      FIGG15=IGG(15)*FRACTN
      FIGG21=IGG(21)*FRACTN
      PRINT1040,IGG(15),FIGG15,IGG(14),FIGG14,
     +          IGG(21),FIGG21,NLB4,FLB4,NLB8,FLB8
 1040 FORMAT(
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED WITH UNCONDITIONAL T1 REJECT (LABEL 0)'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS ACCEPTED WITH UNCONDITIONAL T1 ACCEPT (LABEL 1)'//
C
     + 31X,
     +'CREATE ZVTX BANK'/
C
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS ACCEPTED WITH UNCONDITIONAL T1 ACCEPT (LABEL 2)'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS CONTINUE DIRECTLY TO PATREC TESTS (LABEL 4 ONLY)'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS CONTINUE THROUGH Z-VERTEX TESTS   (LABEL 8 ONLY)'/)
C-----------
C ZVTX TESTS
C-----------
C ONLY LBACC = 8 SUBJECTED TO ZVTX CUTS
      FIGG24=IGG(24)*FRACTN
      FIGG22=IGG(22)*FRACTN
      FIGG23=IGG(23)*FRACTN
      NLB8=NLB8-IGG(22)-IGG(23)-IGG(24)
      FLB8=NLB8*FRACTN
      PRINT1060,IGG(24),FIGG24,
     +          IGG(25),IGG(27),IGG(28),IGG(29),IGG(30),
     +          IGG(22),FIGG22,IGG(23),FIGG23,NLB8,FLB8
 1060 FORMAT(
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED (LABEL 8) AFTER FAILING TO CREATE A ZVTX BANK'/
     + 10X,I10,11X,
     +'EVENTS RETURNED A ZVTX FLAG OF -2'/
     + 10X,I10,11X,
     +'EVENTS RETURNED A ZVTX FLAG OF  0'/
     + 10X,I10,11X,
     +'EVENTS RETURNED A ZVTX FLAG OF  1'/
     + 10X,I10,11X,
     +'EVENTS RETURNED A ZVTX FLAG OF  2'/
     + 10X,I10,11X,
     +'EVENTS RETURNED A ZVTX FLAG OF  3'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED WITH NO GOOD ZVTX FOUND'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED WITH ZVTX OUTSIDE 300 MMS'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'(LABEL 8) EVENTS CONTINUE TO PATREC TESTS'/)
C-----------
C PATR TESTS
C-----------
C ONLY LBACC = 4 , 8 LEFT
      N2TEST=NLB4+NLB8
      F2TEST=N2TEST *FRACTN
      FIGG31=IGG(31)*FRACTN
      FIGG32=IGG(32)*FRACTN
      FIGG33=IGG(33)*FRACTN
      FIGG34=IGG(34)*FRACTN
      FIGG35=IGG(35)*FRACTN
      FIGG36=IGG(36)*FRACTN
      FIGG40=IGG(40)*FRACTN
      PRINT1080,N2TEST,F2TEST,
     +          IGG(31),FIGG31,IGG(32),FIGG32,
     +          IGG(33),FIGG33,IGG(34),FIGG34,IGG(35),FIGG35,
     +          IGG(36),FIGG36,IGG(40),FIGG40
 1080 FORMAT(31X,'CREATE PATR BANK'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS ARRIVE FOR PATREC TESTS (LABEL 4 & 8)'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS ACCEPTED BECAUSE NO PATREC BANK COULD BE CREATED'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED BECAUSE NO ID TRACKS WERE FOUND'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED BECAUSE NO TRACKS WITH > 12 HITS WERE FOUND'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED BECAUSE NO LONG TRACKS HAD PT > 100MEV'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED BECAUSE NO LONG HI-PT TRACKS HAD ZINT < 300MMS'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS REJECTED BECAUSE NO GOOD TRACKS ALSO HAD RMIN < 50MMS'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS ACCEPTED WITH .GE. 1 GOOD TRACK FROM VERTEX'/)
C---------------
C EVENTS WRITTEN
C---------------
      FIGG10=IGG(10)*FRACTN
      NWR0=IGG(10)-IGG(51)-IGG(58)-IGG(66)
      FWR0=NWR0*FRACTN
      FIGG51=IGG(51)*FRACTN
      FIGG58=IGG(58)*FRACTN
      FIGG66=IGG(66)*FRACTN
      PRINT1100,IGG(10),FIGG10,
     +          NWR0,FWR0,IGG(51),FIGG51,IGG(58),FIGG58,IGG(66),FIGG66
 1100 FORMAT(
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS ACCEPTED IN TOTAL'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS WERE ACCEPTED WITH WRITE FLAG  0'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS WERE ACCEPTED WITH WRITE FLAG  1'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS WERE ACCEPTED WITH WRITE FLAG  8'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'EVENTS WERE ACCEPTED WITH WRITE FLAG 16'/)
C-------------
C MIPROC FLAGS
C-------------
      FIGG49=0.
      IF(IGG(10).GT.0) FIGG49=100.*IGG(49)/FLOAT(IGG(10))
      FIGG50=0.
      IF(IGG(10).GT.0) FIGG50=100.*IGG(50)/FLOAT(IGG(10))
      PRINT1120,IGG(49),FIGG49,IGG(50),FIGG50
 1120 FORMAT(
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'OF ACCEPTED EVENTS HAD THE MIPROC BIT 30 SET'/
     + 10X,I10,1X,'(',F6.2,'%) ',
     +'OF ACCEPTED EVENTS HAD THE MIPROC BIT 29 SET'/)
C-------------------------
C OVERALL REDUCTION FACTOR
C-------------------------
      PRINT9090,IGG(4),IGG(10),FIGG10
 9090 FORMAT(///
     +      5X,24('='), 11X,26('='), 11X,36('=')/
     +      1X,I10,' EVENTS WERE READ',6X,
     +      1X,I10,' EVENTS WERE WRITTEN',6X,
     +      1X, 5X,' ACCEPTED EVENT FRACTION = ',F7.2,'%'/
     +      5X,24('='), 11X,26('='), 11X,36('='))
      RETURN
C------------------------------------------
C SPECIAL BY-PASS FOR RUN-BY-RUN STATISTICS
C------------------------------------------
10000 CONTINUE
      FIGG10=0.
      IF(IGG(4).GT.0)FIGG10=100.*IGG(10)/FLOAT(IGG(4))
      XMB = XMBYTE( JUNIT )
      PRINT10001,IGG(1),IGG(4),IGG(11),IGG(10),FIGG10, XMB
10001 FORMAT(/
     + ' -----> RUN',I6,I10,' EVENTS READ',I4,' SCALER EVENTS',I6,
     + ' (',F6.2,'%) EVENTS WRITTEN (',F7.2,' MBYTE)')
      RETURN
      END
      FUNCTION XMBYTE( IWUNIT )
C----------------------------------------------------------
C  VERSION OF 14/01/87       LAST MOD 16/01/87   E ELSEN
C  COMPUTE MBYTES OUTPUT SINCE LAST CALL ON UNIT IWUNIT
C  ONLY ONE UNIT CAN BE HANDLED
C----------------------------------------------------------
      COMMON / BCS / IW(1)
      DATA IRLCOU / 0 /, LOGUNI / 0 /
      IF( IRLCOU .EQ. 0 ) LOGUNI = IWUNIT
      IF( IWUNIT.NE.LOGUNI ) GO TO 8101
        XMBYTE = 0.
        CALL BLOC( NPBUF, '+BUF', IWUNIT, &8101, IER )
          XMBYTE = 4.E-6*(IW(NPBUF+7) - IRLCOU )
          IRLCOU = IW(NPBUF+7)
 8101 CONTINUE
      RETURN
      END
C
      BLOCK DATA
#include "cutsr1.for"
      DATA NRUNST/0/,NEVTST/0/,NOTTOT/0/,NOTRUN/10*0/,NVRSN/1982/
C
C
C     REDUC1 THRESHOLDS FOR T1-ACCEPT TRIGGERS (1982-DATA)
C     ELGLM(1-4) : ETOT, BARREL THRESHOLDS
C     ELGLM(5-8) : END CAP THRESHOLDS
C
      DATA ELGLM  /6000.,2500.,2000.,1500.,
     ,             4000.,1000., 500., 300./
      END
