      SUBROUTINE GUKINE
C +SEQ, GCFLAG.
      COMMON/GCFLAG/IDEBUG,IDEMIN,IDEMAX,ITEST,IDRUN,IDEVT,IEORUN
     +        ,IEOTRI,IEVENT,ISWIT(10),IFINIT(20),NEVENT,NRNDM(2)
c      COMMON /GCFLAX/ BATCH, NOLOG
c      LOGICAL BATCH, NOLOG
C+SEQ, GCKINE.
c      COMMON /GCKINE/ IKINE,PKINE(10),ITRA,ISTAK,IVERT,IPART,ITRTYP,
c     +   NAPART(5),AMASS,CHARGE,TLIFE,VERT(3),PVERT(4),IPAOLD
c----------------------------------------------------------------------
      include 'ntpl.inc'
      include 'edep1.inc'
c----------------------------------------------------------------------
      real vertex(3), plab3(4), pabs

      integer iout/0/
c
      call getbeam(kpart, vertex, plab3)
      if(kpart.lt.0) go to 9999
c
  
c  Load vertex position onto GEANT stack

      call gsvert(vertex,0,0,dummy,0,nvert)       ! nvert returned

      if(nvert.eq.0) then
         print *,'GUKINE: error in vertex # from GSVERT'
         print *,'VERTEX=',vertex
      endif
c
c  Load track onto GEANT stack                          
      call gskine(plab3,kpart,nvert,dummy,0,nt)   ! nt returned
c
      if(nt.eq.0) then 
         print *,'GUKINE:  error in track number'
         print *,'kpart, PLAB3=',kpart, Plab3
         call gprint('KINE',0)
      endif

      call jbgtrk(2)

      etotal0 = etotal0 + plab3(4)

cc      call uzero(edepbuf, 1, 200)

c---        save beam particle in ntuple
      nh = 0
      if(iout.eq.1) then
         nh = 1
         irl(nh) = 0
cc       ql(nh) = 0.
cc       if(kpart.eq.2) ql(nh) = +1.
cc       if(kpart.eq.3) ql(nh) = -1.
         el(nh) = plab3(4)
         xl(nh) = vertex(1)
         yl(nh) = vertex(2)
         zl(nh) = vertex(3)
         pabs=sqrt(plab3(1)**2+plab3(2)**2+plab3(3)**2)
         ul(nh) = plab3(1)/pabs
         vl(nh) = plab3(2)/pabs
         wl(nh) = plab3(3)/pabs
cc      ph(nh) = 0.
cc      fh(nh) = 0.
cc      evnt(nh) = 0.
      end if
c---
c      CALL GSVERT(PKINE,0,0,0,0,NVERT)
c      CALL GSKINE(PKINE(4),IKINE,NVERT,0,0,NT)

      IF (IDEBUG.NE.0) THEN
         CALL GPRINT('VERT',0)
         CALL GPRINT('KINE',0)
      ENDIF
      return

9999  continue

      ieorun = 1

      END




