      logical function trigger_ele(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
c---  
      trigger_ele=.false.
      if (highlumi) then
         cut=34
      else
         cut=29
      endif

      do i=1,nle_cwn
         if (lisol_cwn(i).eq.0.and.abs(kl_cwn(i)).eq.1) then 
            ptrav=sqrt(pl_cwn(1,i)**2+pl_cwn(2,i)**2)
            if (ptrav.gt.cut) trigger_ele=.true.
         endif
      enddo

      return
      end

c--------------------------------------------
      logical function trigger_diele(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp
      integer niso
c---
      trigger_diele=.false.
      if (highlumi) then
         cut=19
      else
         cut=17
      endif

      temp=0
      niso=0
      do i=1,nle_cwn
         if (abs(kl_cwn(i)).eq.1) then 
            ptrav=sqrt(pl_cwn(1,i)**2+pl_cwn(2,i)**2)
            if (ptrav.gt.cut) then
               temp=temp+1
               if (lisol_cwn(i).eq.0) niso=niso+1
            endif
         endif
      enddo
      if (temp.ge.2.and.niso.gt.0) trigger_diele=.true.

      return
      end

c--------------------------------------------
      logical function trigger_mu(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
      real abseta, etafun
c---
      trigger_mu=.false.
      if (highlumi) then
         cut=20
      else
         cut=14
      endif

      do i=1,nle_cwn
         if (lisol_cwn(i).eq.0.and.abs(kl_cwn(i)).eq.2) then 
            ptrav=sqrt(pl_cwn(1,i)**2+pl_cwn(2,i)**2)
            abseta=abs(etafun(pl_cwn(1,i),pl_cwn(2,i),pl_cwn(3,i)))
            if (ptrav.gt.cut.and.abseta.le.2.1) trigger_mu=.true.
         endif
      enddo

      return
      end

c--------------------------------------------
      logical function trigger_dimu(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp
      integer niso
      real abseta,etafun
c---
      trigger_dimu=.false.
      if (highlumi) then
         cut=5
      else
         cut=3
      endif

      temp=0
      niso=0
      do i=1,nle_cwn
         if (abs(kl_cwn(i)).eq.2) then 
            ptrav=sqrt(pl_cwn(1,i)**2+pl_cwn(2,i)**2)
            abseta=abs(etafun(pl_cwn(1,i),pl_cwn(2,i),pl_cwn(3,i)))
            if (ptrav.gt.cut.and.abseta.le.2.1) then
	       temp=temp+1
               if (lisol_cwn(i).eq.0) niso=niso+1
            endif
         endif
      enddo
      if (temp.ge.2.and.niso.gt.0) trigger_dimu=.true.

      return
      end

c--------------------------------------------
      logical function trigger_1jet(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
c---
      trigger_1jet=.false.
      if (highlumi) then
         cut=250
      else
         cut=177
      endif

      do i=1,njg_cwn
         ptrav=sqrt(pjg_cwn(1,i)**2+pjg_cwn(2,i)**2)
         if (ptrav.gt.cut) trigger_1jet=.true.
      enddo

      return
      end

c--------------------------------------------
      logical function trigger_3jet(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp
c---
      trigger_3jet=.false.
      if (highlumi) then
         cut=110
      else
         cut=86
      endif

      temp=0
      do i=1,njg_cwn
         ptrav=sqrt(pjg_cwn(1,i)**2+pjg_cwn(2,i)**2)
         if (ptrav.gt.cut) temp=temp+1
      enddo
      if (temp.ge.3) trigger_3jet=.true.

      return
      end

c--------------------------------------------
      logical function trigger_4jet(highlumi)
      implicit none
      logical highlumi
      real cut
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp
c---
      trigger_4jet=.false.
      if (highlumi) then
         cut=95
      else
         cut=70
      endif

      temp=0
      do i=1,njg_cwn
         ptrav=sqrt(pjg_cwn(1,i)**2+pjg_cwn(2,i)**2)
         if (ptrav.gt.cut) temp=temp+1
      enddo
      if (temp.ge.4) trigger_4jet=.true.

      return
      end

c--------------------------------------------
      logical function trigger_jet_etmiss(highlumi)
      implicit none
      logical highlumi
      real cut1
      real cut2
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp
c---
      trigger_jet_etmiss=.false.
      if (highlumi) then
         cut1=113
         cut2=70
      else
         cut1=88
         cut2=46
      endif

      temp=0
      do i=1,njg_cwn
         ptrav=sqrt(pjg_cwn(1,i)**2+pjg_cwn(2,i)**2)
         if (ptrav.gt.cut1) temp=temp+1
      enddo
      ptmiss=sqrt(ptm(1)*ptm(1)+ptm(2)*ptm(2))
      if (temp.ge.1.and.ptmiss.gt.cut2) trigger_jet_etmiss=.true.

      return
      end

c--------------------------------------------
      logical function trigger_ele_jet(highlumi)
      implicit none
      logical highlumi
      real cut1
      real cut2
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp1
      integer temp2
c---
      trigger_ele_jet=.false.
      if (highlumi) then
         cut1=25
         cut2=52
      else
         cut1=21
         cut2=45
      endif

      temp1=0
      do i=1,nle_cwn
         if (lisol_cwn(i).eq.0.and.abs(kl_cwn(i)).eq.1) then 
            ptrav=sqrt(pl_cwn(1,i)**2+pl_cwn(2,i)**2)
            if (ptrav.gt.cut1) temp1=temp1+1
         endif
      enddo
      temp2=0
      do i=1,njg_cwn
         ptrav=sqrt(pjg_cwn(1,i)**2+pjg_cwn(2,i)**2)
         if (ptrav.gt.cut2) temp2=temp2+1
      enddo
      if (temp1.ge.1.and.temp2.ge.2) trigger_ele_jet=.true.

      return
      end

c--------------------------------------------
      logical function trigger_mu_jet(highlumi)
      implicit none
      logical highlumi
      real cut1
      real cut2
      real ptrav
      integer i
      include "readcwn.inc"
      integer temp1,temp2
c---
      trigger_mu_jet=.false.
      if (highlumi) then
         cut1=15
         cut2=40
      else
         cut1=9999
         cut2=9999
      endif

      temp1=0
      do i=1,nle_cwn
         if (lisol_cwn(i).eq.0.and.abs(kl_cwn(i)).eq.2) then 
            ptrav=sqrt(pl_cwn(1,i)**2+pl_cwn(2,i)**2)
            if (ptrav.gt.cut1) temp1=temp1+1
         endif
      enddo
      temp2=0
      do i=1,njg_cwn
         ptrav=sqrt(pjg_cwn(1,i)**2+pjg_cwn(2,i)**2)
         if (ptrav.gt.cut2) temp2=temp2+1
      enddo
      if (temp1.ge.1.and.temp2.ge.2) trigger_mu_jet=.true.

      return
      end

c--------------------------------------------
      logical function trigger_combo(highlumi)
      implicit none
      logical highlumi
      logical trigger_ele
      logical trigger_diele
      logical trigger_mu
      logical trigger_dimu
      logical trigger_1jet
      logical trigger_3jet
      logical trigger_4jet
      logical trigger_jet_etmiss
      logical trigger_ele_jet
      logical trigger_mu_jet
c---
      trigger_combo=.false.
      if (trigger_ele(highlumi).or.trigger_diele(highlumi).or.
     &     trigger_mu(highlumi).or.trigger_dimu(highlumi).or.
     &     trigger_1jet(highlumi).or.trigger_3jet(highlumi).or.
     &     trigger_4jet(highlumi).or.trigger_jet_etmiss(highlumi).or.
     &     trigger_ele_jet(highlumi).or.trigger_mu_jet(highlumi))
     &     trigger_combo=.true.

      return
      end
