      REAL FUNCTION seln()
*********************************************************
*                                                       *
* This file was generated by HUWFUN.                    *
*                                                       *
*********************************************************
*
*     Ntuple Id:      2000 
*     Ntuple Title:   gammakk
*     Creation:       05/12/:1 11.21.02
*
*********************************************************
*
      LOGICAL         CHAIN
      CHARACTER*128   CFILE
      INTEGER         IDNEVT,NCHEVT,ICHEVT
      REAL            OBS(13)
*
      COMMON /PAWIDN/ IDNEVT,OBS
      COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
      COMMON /PAWCHC/ CFILE
*
*--   Ntuple Variable Declarations
*
      REAL irun,irec,tottks,nmdc,nneu,rx1,ry1,rz1,rx2,ry2,rz2,cosk1
     + ,cosk2,pxyk1,pxyk2,pp1,pp2,tof1,tof2,tq1,tq2,pid1,pid2,deltat
     + ,esc1,esc2,rmkk,rmks1,rmks2,rmkg1,rmkg2,umiss,api0,q2,chi2g
     + ,chi2pi,fmkk,fmgk1,fmgk2,cthetv,cthetx,cthetm,phim,escn,cosg,thdf
     + ,thpf1,thpf2,phpf1,phpf2,ppx1,ppy1,ppz1,ee1,amass1,ppx2,ppy2,ppz2
     + ,ee2,amass2,ppx3,ppy3,ppz3,ee3,amass3,rmht1,rmht2,chi2pi1,chi2pi2
     + ,chi2pi3,chi2pi4,chi2pi5,chi2pi6,rmpi01m,rmpi02m,rmpi03m,rmpi04m
     + ,rmpi05m,rmpi06m,idflag1,idflag2,xx1time1,xx1time2,xx1time3
     + ,xx1timee1,xx1timee2,xx1timee3,xx1timeoff1,xx1timeoff2
     + ,xx1timeoff3,xx1timesig1,xx1timesig2,xx1timesig3,xx2time1
     + ,xx2time2,xx2time3,xx2timee1,xx2timee2,xx2timee3,xx2timeoff1
     + ,xx2timeoff2,xx2timeoff3,xx2timesig1,xx2timesig2,xx2timesig3
     + ,iddflag1,iddflag2,xx1xsp1,xx1xsp2,xx1xsp3,xx1dedxoff1
     + ,xx1dedxoff2,xx1dedxoff3,xx1dedxsig1,xx1dedxsig2,xx1dedxsig3
     + ,xx2xsp1,xx2xsp2,xx2xsp3,xx2dedxoff1,xx2dedxoff2,xx2dedxoff3
     + ,xx2dedxsig1,xx2dedxsig2,xx2dedxsig3,IDGDTOF1,IDGDDEDX1,IDGDCOM1
     + ,IDGDTOF2,IDGDDEDX2,IDGDCOM2,thkk,rx0,ry0,rz0,chi2pi7,chi2pi8
     + ,chi2pi9,rmpi07m,rmpi08m,rmpi09m,rmkk07m,rmkk08m,rmkk09m,rmks107m
     + ,rmks108m
      REAL rmks109m,rmks207m,rmks208m,rmks209m
      INTEGER iscf1,iscf2,nscl,nfscl,nngg,ngg
*
      COMMON /PAWCR4/ irun,irec,tottks,nmdc,nneu,rx1,ry1,rz1,rx2,ry2,rz2
     + ,cosk1,cosk2,pxyk1,pxyk2,pp1,pp2,tof1,tof2,tq1,tq2,pid1,pid2
     + ,deltat,iscf1,iscf2,esc1,esc2,rmkk,rmks1,rmks2,rmkg1,rmkg2,umiss
     + ,api0,q2,chi2g,chi2pi,fmkk,fmgk1,fmgk2,cthetv,cthetx,cthetm,phim
     + ,escn,nscl,nfscl,cosg,thdf,thpf1,thpf2,phpf1,phpf2,nngg,ngg,ppx1
     + ,ppy1,ppz1,ee1,amass1,ppx2,ppy2,ppz2,ee2,amass2,ppx3,ppy3,ppz3
     + ,ee3,amass3,rmht1,rmht2,chi2pi1,chi2pi2,chi2pi3,chi2pi4,chi2pi5
     + ,chi2pi6,rmpi01m,rmpi02m,rmpi03m,rmpi04m,rmpi05m,rmpi06m,idflag1
     + ,idflag2,xx1time1,xx1time2,xx1time3,xx1timee1,xx1timee2,xx1timee3
     + ,xx1timeoff1,xx1timeoff2,xx1timeoff3,xx1timesig1,xx1timesig2
     + ,xx1timesig3,xx2time1,xx2time2,xx2time3,xx2timee1,xx2timee2
     + ,xx2timee3,xx2timeoff1,xx2timeoff2,xx2timeoff3,xx2timesig1
     + ,xx2timesig2,xx2timesig3,iddflag1,iddflag2,xx1xsp1,xx1xsp2
     + ,xx1xsp3,xx1dedxoff1,xx1dedxoff2,xx1dedxoff3,xx1dedxsig1
     + ,xx1dedxsig2,xx1dedxsig3,xx2xsp1,xx2xsp2,xx2xsp3,xx2dedxoff1
     + ,xx2dedxoff2,xx2dedxoff3,xx2dedxsig1,xx2dedxsig2,xx2dedxsig3
     + ,IDGDTOF1,IDGDDEDX1,IDGDCOM1,IDGDTOF2,IDGDDEDX2,IDGDCOM2,thkk,rx0
     + ,ry0,rz0,chi2pi7,chi2pi8,chi2pi9,rmpi07m,rmpi08m,rmpi09m,rmkk07m
     + ,rmkk08m,rmkk09m,rmks107m,rmks108m,rmks109m,rmks207m,rmks208m
     + ,rmks209m
*

*
*--   Enter user code here
*
      seln = 0.
*
       if( abs(cosk1).gt.0.80 ) return
       if( abs(cosk2).gt.0.80 ) return
*
       if( nngg.le.0.0 ) return
       if( nngg.ge.2.0 ) then
         if(chi2pi1.lt.50.and.abs(rmpi01m-0.135).lt.0.050) return
         if(chi2pi2.lt.50.and.abs(rmpi02m-0.135).lt.0.050) return
       endif
*
       if(chi2pi1.lt.chi2g ) return
       if(chi2pi2.lt.chi2g ) return
       if( chi2pi.le.chi2g.or.chi2g.ge.50.0
     *   ) return
       if( chi2pi.le.10..or.chi2g.ge.10.00
     *   ) return
*
       if( umiss.ge.0.20.or.umiss.le.-0.10 ) return
       if (thdf.ge.18.0 ) return
       if( q2.ge.0.0020 ) return
*
       if(fmkk.lt.1.40.and.idflag1.ne.1.0.or.idflag2.ne.1.0) return
*
       if(idflag1.eq.1.0.or.idflag2.eq.1.0) then
         seln=1.
       else
         seln=0.
       endif
*
      END
