	SUBROUTINE BLSEL (BLS_LW,BLS_UP,EN,NEBN,ISTR,BLS_FACT,STATUS)
C
C------------------------------------------------------------------------
C
C.IDENTIFICATION:
C	Subroutine BLSEL
C
C.SOURCE FILE:
C       blsel.f	
C
C.LIBRARY:
C       libmecs.a
C
C.AUTHOR:
C       T.Mineo    IFCAI/CNR,  Palermo
C
C.VERSIONS:
C	Vers. 1.0     6-7-95		creation date
C	Vers. 1.1     17-10-96		changed BLS_FACT into a vector
C	Vers. 2.0     17-12-96		introduced the bl sel correction
C                                       function
C
C.PURPOSE:
C       computes the  factor to correct the total efficiency for the
C       Burst Length selection.
C
C.SYNTAX:
C	CALL BLSEL (BLS_LW,BLS_UP,EN,NEBN,ISTR,BLS_FACT,STATUS)
C
C.PARAMETERS:
C       inp. BLS_LW        Integer*4 low threshold for BL selection (ch)
C       inp. BLS_UP        Integer*4 high threshold for BL selection (ch)
C       inp. EN(NEBN)      Real*4    energy (keV)
C       inp. NEBN          Integer*4 number of energy bins
C       inp. ISTR          Integer*4 1=ME1, 2=ME2, 3=ME3
C       out. BLS_FACT(NEBN)Real*4    efficiency correcting factor
C       out. STATUS        Integer*4 STATUS=0 ==>no errors 
C
C.REFERENCED FILES:
C
C------------------------------------------------------------------------
C
C...variables definition
C
	INTEGER*4 ISTR,STATUS,NEBN
	INTEGER*4 BLS_LW,BLS_UP
C
	REAL*4    EN(NEBN),BLS_FACT(NEBN)
        CHARACTER BUFFER*80,NAME*80
        INTEGER   ISYS
        LOGICAL   VOSERROR

C
	SAVE IFLAG_BL
C
        IF(IFLAG_BL. EQ. 0) THEN
          WRITE(BUFFER, 120)ISTR
 120      FORMAT('m',I1,'_blsel.coeff')
          CALL BUILDPATH(BUFFER,'CALIB',NAME)
          CALL Z_OPEN(42,NAME,'SEQ','OLD',0)
          IF (VOSERROR(STATUS,ISYS))RETURN
          READ (42,*)
          READ (42,*)
          READ (42,*)
          READ (42,*)
          READ (42,*) BLMIN, BLMAX, ENER, COST, AESP, TAU
          CLOSE (42)
          IFLAG_BL=1
        END IF
	IF (BLMIN.NE.BLS_LW  .OR. BLMAX.NE.BLS_UP) THEN
	  WRITE(*,*)' BLSEL: BL selection not correct'
	  STATUS =1
	  RETURN
	END IF

	DO 10 I=1,NEBN
	  BLS_FACT(I)=1.0
	  IF(EN(I).GT.ENER) THEN
            BLS_FACT(I)=COST+AESP*EXP(-(EN(I)-ENER)/TAU)
	  END IF
c	write(35,*) en(i),BLS_FACT(I)
 10	CONTINUE
C
        RETURN
        END
