      FUNCTION L15CT_PROV_RUN_SUMMARY ()
C----------------------------------------------------------------------
C-
C-   Purpose and Methods : Write Run Summary for L15CT_PROV
C-
C-   Returned value  :
C-   Inputs  :
C-   Outputs :
C-   Controls:
C-
C-   Created  16-NOV-1994   Steve Gross - MSU L1 Trigger
C-
C----------------------------------------------------------------------
      IMPLICIT NONE
  
      INCLUDE 'D0$PARAMS:LEVEL1_LOOKUP.PARAMS'

C- L15_FRAMEWORK.PARAMS must be included because that's where NUM_DSPS
C- is (for no known reason), and L15_LOCAL_DSP.PARAMS requires NUM_DSPS.
      INCLUDE 'D0$PARAMS:L15_FRAMEWORK.PARAMS'
      INCLUDE 'D0$PARAMS:L15_LOCAL_DSP.PARAMS'

C- temporary
      INCLUDE 'D0$INC:L15_LOCAL_DSP.INC'
C- end temporary

      INCLUDE 'L15CT_PROV_SUMMARY.INC'

      INTEGER SETA, PHI, PHI_LOW, PHI_HIGH

      LOGICAL L15CT_PROV_RUN_SUMMARY
C----------------------------------------------------------------------

      L15CT_PROV_RUN_SUMMARY = .TRUE.

C- Print "header"

      WRITE ( LOG_FILE_LUN, *) ' '
      WRITE ( LOG_FILE_LUN, *) '      ==========='
      WRITE ( LOG_FILE_LUN, *) '      RUN SUMMARY'
      WRITE ( LOG_FILE_LUN, *) '      ==========='
      WRITE ( LOG_FILE_LUN, *) ' '

C---------------------------------------------------
C- Print information about bits seen LOW

      WRITE ( LOG_FILE_LUN, *) ' '
      WRITE ( LOG_FILE_LUN, *) ' Mask (in HEX) of bits never seen LOW'
      WRITE ( LOG_FILE_LUN, *) ' ------------------------------------'
      WRITE ( LOG_FILE_LUN, *) ' '

      DO SETA = -ETA_MAX, ETA_MAX

C- Skip Eta = 0

        IF ( SETA .EQ. 0 ) GOTO 998

        DO PHI_LOW = PHI_MIN, PHI_MAX - 1, PHI_MAX / 2

          PHI_HIGH = PHI_LOW + PHI_MAX / 2 - 1

          WRITE ( LOG_FILE_LUN, 2000)   SETA,
     &        ( 255 - L15CT_TT_RAW_BIT_LOW ( SETA, PHI, L15C_TOT_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

          WRITE ( LOG_FILE_LUN, 2001)   PHI_LOW, PHI_HIGH, 
     &        ( 255 - L15CT_TT_RAW_BIT_LOW ( SETA, PHI, L15C_EM_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

        END DO

        WRITE ( LOG_FILE_LUN, * ) ' '

  998   CONTINUE

      END DO


C---------------------------------------------------
C- Print information about bits seen HIGH

      WRITE ( LOG_FILE_LUN, *) ' '
      WRITE ( LOG_FILE_LUN, *) ' Mask (in HEX) of bits never seen HIGH'
      WRITE ( LOG_FILE_LUN, *) ' -------------------------------------'
      WRITE ( LOG_FILE_LUN, *) ' '

      DO SETA = -ETA_MAX, ETA_MAX

C- Skip Eta = 0

        IF ( SETA .EQ. 0 ) GOTO 997

        DO PHI_LOW = PHI_MIN, PHI_MAX - 1, PHI_MAX / 2

          PHI_HIGH = PHI_LOW + PHI_MAX / 2 - 1

          WRITE ( LOG_FILE_LUN, 2000)   SETA,
     &        ( 255 - L15CT_TT_RAW_BIT_HIGH ( SETA, PHI, L15C_TOT_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

          WRITE ( LOG_FILE_LUN, 2001)   PHI_LOW, PHI_HIGH, 
     &        ( 255 - L15CT_TT_RAW_BIT_HIGH ( SETA, PHI, L15C_EM_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

        END DO

        WRITE ( LOG_FILE_LUN, * ) ' '

  997   CONTINUE

      END DO


C---------------------------------------------------
C- Print information about maximum value

      WRITE ( LOG_FILE_LUN, *) ' '
      WRITE ( LOG_FILE_LUN, *) ' Maximum input value (in ADC counts)'
      WRITE ( LOG_FILE_LUN, *) ' -----------------------------------'
      WRITE ( LOG_FILE_LUN, *) ' '

      DO SETA = -ETA_MAX, ETA_MAX

C- Skip Eta = 0

        IF ( SETA .EQ. 0 ) GOTO 996

        DO PHI_LOW = PHI_MIN, PHI_MAX - 1, PHI_MAX / 2

          PHI_HIGH = PHI_LOW + PHI_MAX / 2 - 1

          WRITE ( LOG_FILE_LUN, 2010)   SETA,
     &        ( L15CT_TT_RAW_MAX ( SETA, PHI, L15C_TOT_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

          WRITE ( LOG_FILE_LUN, 2011)   PHI_LOW, PHI_HIGH, 
     &        ( L15CT_TT_RAW_MAX ( SETA, PHI, L15C_EM_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

        END DO

        WRITE ( LOG_FILE_LUN, * ) ' '

  996   CONTINUE

      END DO


C----------------------------------------------------------------------
C- TEMPORARILY PRINT LAST PULSER PATTERN
C-

      WRITE ( LOG_FILE_LUN, *) ' '
      WRITE ( LOG_FILE_LUN, *) ' Final pulser pattern (in ADC Counts)'
      WRITE ( LOG_FILE_LUN, *) ' ------------------------------------'
      WRITE ( LOG_FILE_LUN, *) ' '

      DO SETA = -ETA_MAX, ETA_MAX

C- Skip Eta = 0

        IF ( SETA .EQ. 0 ) GOTO 995

        DO PHI_LOW = PHI_MIN, PHI_MAX - 1, PHI_MAX / 2

          PHI_HIGH = PHI_LOW + PHI_MAX / 2 - 1

          WRITE ( LOG_FILE_LUN, 2010)   SETA,
     &        ( L15CT_TT_RAW ( SETA, PHI, L15C_TOT_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

          WRITE ( LOG_FILE_LUN, 2011)   PHI_LOW, PHI_HIGH, 
     &        ( L15CT_TT_RAW ( SETA, PHI, L15C_EM_TWR ),
     &          PHI = PHI_LOW, PHI_HIGH )

        END DO

        WRITE ( LOG_FILE_LUN, * ) ' '

  995   CONTINUE

      END DO

C- END TEMPORARY

      CLOSE ( LOG_FILE_LUN )

C----------------------------------------------------------------------

 2000 FORMAT ( ' ETA=' SP, I3, SS, '  TOT', 16 ( '  ', Z2 ) )
 2001 FORMAT ( ' PHI=', I2, ':', I2, ' EM', 16 ( '  ', Z2 ) )

 2010 FORMAT ( ' ETA=' SP, I3, SS, '  TOT', 16 ( ' ', I3 ) )
 2011 FORMAT ( ' PHI=', I2, ':', I2, ' EM', 16 ( ' ', I3 ) )


  999 RETURN
      END
