      REAL FUNCTION dyrpt_x2(XDUMMY)
      REAL
     +am      ,x1      ,x2      ,xf      ,pt      ,target  ,
     +trigger ,yield   ,sgrt_DW ,sgrt_DFe,sgrt_DBe 
*
      LOGICAL         CHAIN
      CHARACTER*128   CFILE
*
      COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
      COMMON /PAWCHC/ CFILE
*
      COMMON/PAWIDN/IDNEVT,OBS(13),
     +am      ,x1      ,x2      ,xf      ,pt      ,target  ,
     +trigger ,yield   ,sgrt_DW ,sgrt_DFe,sgrt_DBe 
*
      if(idnevt.eq.1) then
	write(6,100)
100     format('calling dyrpt_x2.f')
        if(target.eq.3) then
          do i=1,10
            call hbook1(10+i-1,'Be vrs pT',10,0.,5.,0.)
            call hbook1(70+i-1,'Be vrs pT',10,0.,5.,0.)
            call hbook1(110+i-1,'Be vrs pT',10,0.,5.,0.)
          enddo
          call hbook2(40,'Be mass vrs pT',10,0.,5.,200,4.,14.,0.)
          call hbook1(41,'Be vrs pT',10,0.,5.,0.)
          call hbook1(42,'Be vrs pT',10,0.,5.,0.)
          call hbook1(43,'Be vrs pT',10,0.,5.,0.)
        else if(target.eq.2) then
          do i=1,10
            call hbook1(20+i-1,'Fe vrs pT',10,0.,5.,0.)
            call hbook1(80+i-1,'Fe vrs pT',10,0.,5.,0.)
            call hbook1(120+i-1,'Fe vrs pT',10,0.,5.,0.)
          enddo
          call hbook2(50,'Fe mass vrs pT',10,0.,5.,200,4.,14.,0.)
          call hbook1(51,'Fe vrs pT',8,0.,5.,0.)
          call hbook1(52,'Fe vrs pT',8,0.,5.,0.)
          call hbook1(53,'Fe vrs pT',8,0.,5.,0.)
        else if(target.eq.1) then
          do i=1,10
            call hbook1(30+i-1,'W vrs pT',10,0.,5.,0.)
            call hbook1(90+i-1,'W vrs pT',10,0.,5.,0.)
            call hbook1(130+i-1,'W vrs pT',10,0.,5.,0.)
          enddo
          call hbook2(60,'W mass vrs pT',10,0.,5.,200,4.,14.,0.)
          call hbook1(61,'W vrs pT',8,0.,5.,0.)
          call hbook1(62,'W vrs pT',8,0.,5.,0.)
          call hbook1(63,'W vrs pT',8,0.,5.,0.)
        endif
      endif
      if(am.gt.4.0.and.am.lt.8.4) then
      if(xdummy.eq.3.and.(target.eq.3.or.target.eq.4)) then
	i = int(x2/.02)
c        i = int(am)-3
        weight = yield
c        weight = yield*sgrt_dbe
        weight2 = weight**2
        call hfill(10+i-1,pt,0.,weight)
        call hfill(70+i-1,pt,0.,weight2)
        if(weight.eq.1) call hfill(100+i-1,pt,10.,weight)
        call hfill(40,pt,x2,weight)
        call hfill(41,pt,0.,weight)
        call hfill(42,pt,0.,weight2)
        if(weight.eq.1) call hfill(43,pt,0.,weight)
      else if(xdummy.eq.2.and.(target.eq.2.or.target.eq.4)) then
	i = int(x2/.02)
c        i = int(am)-3
        weight = yield
c        weight = yield*sgrt_dfe
        weight2 = weight**2
        call hfill(20+i-1,pt,0.,weight)
        call hfill(80+i-1,pt,0.,weight2)
        if(weight.eq.1) call hfill(120+i-1,pt,0.,weight)
        call hfill(50,pt,x2,weight)
        call hfill(51,pt,0.,weight)
        call hfill(52,pt,0.,weight2)
        if(weight.eq.1) call hfill(53,pt,0.,weight)
      else if(xdummy.eq.1.and.(target.eq.1.or.target.eq.4)) then
	i = int(x2/.02)
c        i = int(am)-3
        weight = yield
c        weight = yield*sgrt_dw
        weight2 = weight**2
        call hfill(30+i-1,pt,0.,weight)
        call hfill(90+i-1,pt,0.,weight2)
        if(weight.eq.1) call hfill(130+i-1,pt,0.,weight)
        call hfill(60,pt,x2,weight)
        call hfill(61,pt,0.,weight)
        call hfill(62,pt,0.,weight2)
        if(weight.eq.1) call hfill(63,pt,0.,weight)
      endif
      endif
      dyrpt_x2=1.
      END
