C   03/09/79 508141518  MEMBER NAME  UMCPAK   (S)           FORTRAN
      SUBROUTINE UMCPAK(IER,*)
C---  IT IS ASSUMED THAT THE EVENT IS ALREADY READ
C---  UNPACK DATA OF ONE MONTE-CARLO EVENT
C
C     H.WRIEDT       12.03.79       11:15
C          MODIFICATION       22.03.80      15:30
C          MODIFICATION       27.11.84   JMN STOPPED ATAG PRINTOUT
C                                            AND TESTED FOR NO ADC
C                                            DATA ( IE JUST HEADER
C                                            WORDS IN ATAG BANK )
C     LAST MODIFICATION       14.8.85    AJF CORRECTION TO ABOVE
C
C
      IMPLICIT INTEGER*2 (H)
C
      EXTERNAL BDLM
C
      COMMON /BCS/ IDATA(30000)
      DIMENSION HDATA(60000), RDATA(30000)
      EQUIVALENCE (IDATA(1),RDATA(1),HDATA(1))
C
      COMMON /CWORK/ HCOINC(16),HLUMON(16),HGGLAT(16),HSCALE(36),
     &               LNG,HPOINT(4),HGGADC(2,192),IWORK1(269),HCORR,
     &               HPBLAT,IWORK2,HSCAL(36),IWORK3(762),HACC,HWORK1,
     &               HLULAT,HWORK2,IWORK4(618),HRUNEX,HEVENT,XV,YV,ZV
      DIMENSION LAT(2),HLAT(4)
C
      INTEGER GGADC(242)
      EQUIVALENCE (GGADC(3),HGGADC(1,1)), (HLAT(1),LAT(1))
C
      COMMON /CRUNCO/ HRUN,HOLDRN
C
      COMMON /CMSGCT/ MSGDUM(21),NGGMSG(16)
C
      COMMON /CGGVRN/ NVRSN(20)
      DATA NVCODE/580032215/
      DATA IEV/0/
C
      NVRSN(5) = NVCODE
      IER = 0
C
C---  FETCH DATA FROM 'HEAD'
C---  FETCH HEAD-POINTER
    4 IHEAD = IDATA(IBLN('HEAD'))
      IF (IHEAD.GT.0) GOTO 5
C---  HEAD IS MISSING
      RETURN 1
C---  FETCH RUN- AND EVENT-NO.
    5 INDEX = 2*IHEAD + 10
      HRUNEX = HDATA(INDEX)
      HEVENT = HDATA(INDEX+1)
      HOLDRN = HRUNEX
      HRUN = HRUNEX
      IEV = IEV + 1
C
C---  TRANSFER DATA FROM 'TPVX'
C---  FETCH TPVX-POINTER
    6 IND = IDATA(IBLN('TPVX'))
      IF (IND.GT.0) GOTO 7
C---  TPVX IS MISSING
      XV = 0.
      YV = 0.
      ZV = 0.
      GOTO 50
C---  FETCH EVENT VERTEX
    7 XV = RDATA(IND+2)
      YV = RDATA(IND+3)
      ZV = RDATA(IND+4)
C
C---  CORRECT INITIALIZATION OF LNG
   50 LNG = 2
C---  TRANSFER DATA FROM 'ATAG'
C---  FETCH ATAG-POINTER
      IND = IDATA(IBLN('ATAG'))
      IF (IND.GT.0) GOTO 51
C---  ATAG IS MISSING
      NGGMSG(3) = NGGMSG(3) + 1
      IER = IER + 2
      RETURN
C---  FETCH ATAG-DATA
C---  LNG:  NUMBER OF ADC-DATA + 2
   51 NDATA = IDATA(IND)
      LNG = NDATA - 1
C
C--- JMN                                 NO ATAG BANK DUMP
C
CCC   IF (IEV.LT.30) CALL BPRS('ATAG',0)
CCC   IF (IEV.LT.30) CALL HPRS('ATAG',0)
C--- JMN                                 TEST FOR NO ADC DATA
C     IF ((LNG.GE.5  ).AND.(LNG.LE.242)) GOTO 53
C AJF VERSION 14/8/85
      IF((NDATA.GT.3).AND.(NDATA.LT.200)) GOTO 53
C END OF AJF VERSION
CCC   IF (LNG.LE.242) GOTO 53
C--- JMN                                 END OF JMN CHANGES
C
      RETURN 1
   53 CALL UCOPY(IDATA(IND+2),GGADC(1),LNG)
C
      RETURN
      END
