!----------------------------------------------------------------------
! estimation of background
! M. Staric, jan-2000
!
!----------------------------------------------------------------------

      SUBROUTINE BGR_ESTIMATE(NITER)

      INTEGER NITER

#include "riter/RIC_TRA.fi"

      REAL STF_ANTI(MAXTRA)

! reset
      DO ITRA=1,NTRA
         STF_ANTI(ITRA)=0.
      ENDDO
! count (photon with sig<0 is in antiwindow) 
      CALL GET_RING_TAB_ROWS(NT)
      DO K=1,NT
         CALL GET_RING_TAB(K,ITRA,IFOT,SIG,TH_CER,FI_CER,WT)
         IF(SIG.LT.0) STF_ANTI(ITRA)=STF_ANTI(ITRA)+WT
      ENDDO
! estimate (do fit)
      IF(NITER.GT.0) THEN
         DO ITRA=1,NTRA
            STFB(ITRA)=FAB3(ITRA)*STF_ANTI(ITRA)
         ENDDO
      ELSE
         DO ITRA=1,NTRA
            STFB(ITRA)=FAB1(ITRA)*STF_ANTI(ITRA)
         ENDDO
      ENDIF
      RETURN
      END


