n      REAL  FUNCTION FBIN(x)
C
C binned correction function for 98 data and MC
C
C  x = cos(theta)

      parameter(nbin=28) !
      real chtb(29)      ! bin boundaries
      real ratio(nbin),eratio(nbin)


      data chtb / -1.00,-0.95,-0.90,-0.85,-0.80,
     &            -0.75,-0.70,-0.65,-0.60,
     &            -0.50,-0.40,-0.30,-0.20,-0.10, 0.00, 
     &             0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 
     &             0.65, 0.70, 0.75, 0.80,
     &             0.85, 0.90, 0.95, 1.00  /

      OPEN(5,FILE='ratio.data',STATUS='unknown')
      READ(5,1000) ratio

      fbin = 1.  

C find bin
      do i=1,nbin
        if(chtb(i).le.x.and.chtb(i+1).ge.x) ibin = i
      enddo    
     
      if(ibin.gt.nbin.or.ibin.lt.1) return 
      
      fbin = ratio(ibin)
      CLOSE(5)
 1000 format(4(f8.5,','))

      END
