      subroutine ilimittypestats(ntotpoints,iphotolimit,ilimittype,
     &numrubis,numrubp,numtpu)
      implicit none
      integer ntotpoints,iphotolimit(ntotpoints),ilimittype,
     &numrubis,numrubp,numtpu,i

      numrubis=0
      numrubp=0
      numtpu=0
      do i=1,ntotpoints
        if(iphotolimit(i).eq.1)numrubis=numrubis+1
        if(iphotolimit(i).eq.2)numrubp=numrubp+1
        if(iphotolimit(i).eq.3)numtpu=numtpu+1
      enddo
      if(numrubis.eq.0.and.numrubp.eq.0.and.numtpu.eq.0)then
        ilimittype=0
        return
      endif
      if(numrubis.eq.0)then
        if(numrubp.eq.0)then
          ilimittype=7
        else
          if(numtpu.eq.0)then
            ilimittype=6
          else
            ilimittype=4
          endif
        endif
      else
        if(numrubp.eq.0)then
          if(numtpu.eq.0)then
            ilimittype=5
          else
            ilimittype=3
          endif
        else
          if(numtpu.eq.0)then
            ilimittype=2
          else
            ilimittype=1
          endif
        endif
      endif
      return
      end
