	subroutine jpsi_run_status(irun,istatus)
	implicit none
C*********************************************************************
c
C  USAGE:   This program returns 'istatus' to show the J/psi run status
C	    by inputting the run number.
c 
C  INPUT:   irun,   run number.
c
C  OUTPUT:  istatus, the status of the run:
C           istatus = 1 : good runs.                 
c           istatus = 2 : good runs, with some problems, but
C	                  recommend be used,         
C           istatus = 3 : bad runs, should not be used,
c
c                                         Shen Xiaoyan and Zhao Zhengguo 
c
c                                         May 14, 2000
c
c********************************************************************
c
c  The second run Jpsi data was taken from Nov. 8, 2000 to April 3,
c  2001. The usable run of the second Jpsi data set is from 17209 to 
c  19149.
c
c                                         Shen Xiaoyan and Wang zheng
c
c                                         May 13, 2001
C*********************************************************************
c  Run 13531 - 13690:  taken from Nov. 29, 1999 - Dec. 10, 1999,
c                      totally around 1M hadron events.
c                      MDC threshold: 625, 1025 ...
c                      BSC E_tot_l and E_tot_h not determinded yet
c              (recommend not be used)     
c
c  From run 13691: all the MDC thresholds are set to be 625, 
c                  BSC E_tot_l = 20, E_tot_h = 65
c
c  From run 14029: MDC L6 4 cells' HV turned off
c
c  From run 14963: BSC E_tot_l = 23, E_tot_h = 70
c
c  From run 14890: ESC E_tot changed from 40 to 45,
c                  solved the inteference problem of SC reset signal
c                  to MDC. 
c
c  From run 15197: BSC E_tot_h = 75, add N_vc >= 1
c
c  From run 15443 - 15489: data taken at 3.0 GeV for background study
c
c  From run 15752: MDC L4 4 cells field wire HV changed from 1750 to 1200V.
c
c  From run 16262: MDC L6 4 cells field wire HV changed from 1750 to 1400V.
c
c  From run 16748 - 16777: MDC L4 4 cells dead.
c
c  From run 16836, BES started to do J/psi peak scan, Psi(2S) peak scan and
c                  Psi(2S) data taking.
c
c  The following list starts from Run 13691.
c
c*********************************************************************
c
	integer irun,istatus
c
        istatus = 1
c
        if (irun.lt.13691)                   istatus = 3 ! for tuning
        if (irun.ge.13742.and.irun.le.13748) istatus = 3 ! J/psi peak scan
        if (irun.eq.13847)                   istatus = 3 !
        if (irun.eq.13863)                   istatus = 2 ! Mu hot
        if (irun.ge.13931.and.irun.le.13939) istatus = 3 ! trig. eff. study
        if (irun.eq.13950)                   istatus = 3 ! BSC: many hot channels
        if (irun.eq.13998)                   istatus = 2 ! BSC: some hot channels
        if (irun.eq.14175)                   istatus = 2 ! BSC: some hot channels
        if (irun.eq.14227)                   istatus = 2 ! Mu: many hot channels
        if (irun.eq.14279.or.irun.eq.14280)  istatus = 3 ! MDC: many dead channels
        if (irun.ge.14323.and.irun.le.14324) istatus = 3 ! J/psi peak scan
        if (irun.eq.14445)                   istatus = 3 ! MDC power supply fuse broken
        if (irun.eq.14453)                   istatus = 3 ! empty
        if (irun.eq.14513)                   istatus = 3 ! MDC power supply fuse broken
        if (irun.eq.14514)                   istatus = 3 ! MDC power supply fuse broken
        if (irun.eq.14523)                   istatus = 3 ! MDC power supply fuse broken
        if (irun.eq.14524)                   istatus = 3 ! MDC power supply fuse broken
        if (irun.eq.14532)                   istatus = 3 ! empty
        if (irun.eq.14565)                   istatus = 2 ! BSC L1, L6 some dead channels
        if (irun.eq.14572)                   istatus = 3 ! MDC power supply fuse broken
        if (irun.eq.14631)                   istatus = 3 ! BADC read/write error
        if (irun.eq.14632)                   istatus = 3 ! BADC read/write error
        if (irun.eq.14638)                   istatus = 3 ! TOF dead
        if (irun.eq.14672)                   istatus = 3 ! empty
        if (irun.eq.14723)                   istatus = 3 ! BSC many hot channels, totally 7 mins.
        if (irun.eq.14724)                   istatus = 3 ! BSC hot, MDC power supply fuse broken
        if (irun.eq.14725)                   istatus = 3 ! BSC hot
        if (irun.eq.14726)                   istatus = 3 ! BSC hot, MDC power supply fuse broken
        if (irun.eq.14781.or.irun.eq.14782)  istatus = 2 ! BSC hot, totally 15 mins.
        if (irun.eq.14835)                   istatus = 3 ! TOF one crate dead
        if (irun.ge.14864.and.irun.le.14867) istatus = 2 ! BSC hot
        if (irun.ge.14871.and.irun.le.14874) istatus = 2 ! MDC dE/dX hot
        if (irun.eq.15159)                   istatus = 3 ! VME problem
        if (irun.eq.15418.or.irun.eq.15419)  istatus = 3 ! cosmic ray 
        if (irun.ge.15422.and.irun.le.15431) istatus = 3 ! trig. curve study
        if (irun.ge.15443.and.irun.le.15489) istatus = 3 ! 3.0 GeV data
        if (irun.eq.15622)                   istatus = 2 ! Mu hot
        if (irun.eq.15623)                   istatus = 3 ! empty
        if (irun.ge.15705.and.irun.le.15715) istatus = 3 ! J/psi peak scan
        if (irun.eq.15718)                   istatus = 3 ! empty
        if (irun.ge.16056.and.irun.le.16059) istatus = 3 ! J/psi peak scan
        if (irun.ge.16062.and.irun.le.16063) istatus = 3 ! J/psi peak scan
        if (irun.eq.16086)                   istatus = 3 ! MDC HV trip
        if (irun.eq.16368)                   istatus = 3 ! BSC some dead channels
        if (irun.eq.16517)                   istatus = 3 ! HV problem
        if (irun.eq.16593)                   istatus = 3 ! MDC dE/dX dead channles
        if (irun.ge.16594.and.irun.le.16596) istatus = 2 ! BSC hot
        if (irun.eq.16718.or.irun.eq.16719)  istatus = 2 ! TOF 65# dead
        if (irun.eq.16731)                   istatus = 3 !
        if (irun.ge.16836.and.irun.le.17018) istatus = 3 ! scan and Psi(2S) data 
c
c
c
c
c************************************for second run Jpsi data.
c
c Run 17019-----17208 Taken from Nov.8, 2000 to Nov.17, 2000. Used for
c                    threshold study, trigger effeciency study and 
c                    Jpsi peak scan. And also something is wrong
c                    with the Vertex part. Cann't be used.
c
c From 17073--17078  Threshold study.
c 
c From 17079--17085  Trigger effeciency study.
c
c From 17086         Etot-h=60, Etot-l=18, Radial threshold=12.
c
c From 17163         Etot-h=70, Etot-l=20.
c
c Form run 17209 to 17422, the vertex information doesn't match with 
c MDC information. But these runs are still usable after some 
c treatments.


       if (irun.ge.17019.and.irun.le.17208) istatus = 3 ! not usable            
       if (irun.eq.17238)                   istatus = 2 ! Beam lost
c      From 17244 Etot-h=80, Etot-l=20, radial threshold=25
       if (irun.eq.17244)                   istatus = 2 ! Beam lost
       if (irun.eq.17247)                   istatus = 2 ! Beam lost.
       if (irun.eq.17248)                   istatus = 2 ! MDC hot ch.
       if (irun.eq.17249)                   istatus = 2 ! MDC hot ch.
       if (irun.eq.17281)                   istatus = 3 ! Cosmic ray
c
c      Run 17281: Not set trigger table,from this run Etot-h=75
c      From run 17282, turn off ESC.                                  
       if (irun.ge.17286.and.irun.le.17290) istatus = 2 ! VC HV.err.
c      From 17291 Etot-h=70.
       if (irun.eq.17300)                   istatus = 3 ! no neutral trigger
       if (irun.eq.17305)                   istatus = 3 ! MDC hot 
       if (irun.eq.17307)                   istatus = 2 ! BSC hot ch.
       if (irun.eq.17344)                   istatus = 2 ! MU hot ch.
       if (irun.eq.17389)                   istatus = 3 ! MDC dead ch.
       if (irun.eq.17401)                   istatus = 3 ! VC dead ch.
       if (irun.ge.17402.and.irun.le.17403) istatus = 3 ! trigger err.
       if (irun.ge.17407.and.irun.le.17408) istatus = 3 ! MDC HV. err.
c      From 17409 MDC L1 one wire was broken, the HV of some cells were
c      turned off.
c
c      From 17423 VC is ok.
c      From 17438 Etot-h=65,Etot-l=17
       if (irun.eq.17440)                   istatus = 2 ! MU hot ch.
       if (irun.ge.17443.and.irun.le.17444) istatus = 3 ! MDC:L7 no HV.
       if (irun.eq.17461)                   istatus = 3 ! BTOF dead ch.
       if (irun.eq.17464)                   istatus = 3 ! BSC,MDC hot ch.
c      From 17470 BSC L6 a wire break.
       if (irun.eq.17472)                   istatus = 3 ! BSC HV error.
       if (irun.eq.17474)                   istatus = 2 ! MDC hot ch.
       if (irun.eq.17476)                   istatus = 3 ! BSC hot ch.
       if (irun.eq.17485)                   istatus = 2 ! MDC,BSC,MU hot ch.
       if (irun.eq.17503)                   istatus = 2 ! Beam is not good.
       if (irun.ge.17569.and.irun.le.17573) istatus = 3 ! Jpsi scan
       if (irun.eq.17582)                   istatus = 2 ! BSC dead ch.
       if (irun.eq.17591)                   istatus = 3 !
       if (irun.eq.17590)                   istatus = 2 ! BSC dead ch.
       if (irun.eq.17593)                   istatus = 2 ! MU hot ch.
c      From 17605, turn off ESC BADC.
       if (irun.ge.17643.and.irun.le.17645) istatus = 2 ! BSC hot ch.
       if (irun.ge.17648.and.irun.le.17654) istatus = 2 ! MU dead ch.
       if (irun.eq.17706)                   istatus = 3 ! MU no HV.
       if (irun.eq.17710)                   istatus = 2 ! MU hot ch.
       if (irun.ge.17726.and.irun.le.17736) istatus = 3 ! for trigger study.
       if (irun.eq.17750)                   istatus = 3 ! VC problem.
       if (irun.eq.17874)                   istatus = 2 ! MDC dead ch.
c      From 17867 to 17876, ESC on.
       if (irun.ge.17882.and.irun.le.17888) istatus = 3 ! Jpsi scan.
       if (irun.ge.17945.and.irun.le.17946) istatus = 2 ! MU hot ch.TOF HVerr
       if (irun.ge.17955.and.irun.le.17965) istatus = 2 ! NDC L10 hot ch.
       if (irun.eq.17968)                   istatus = 2 ! TOF hot ch.
       if (irun.ge.18087.and.irun.le.18122) istatus = 3 ! 3.0 GeV
       if (irun.ge.18246.and.irun.le.18250) istatus = 2 ! ETOF HV err.
       if (irun.eq.18281)                   istatus = 2 ! BSC hot ch.
       if (irun.eq.18340)                   istatus = 3 !
       if (irun.eq.18412)                   istatus = 3 ! VME eror.
       if (irun.eq.18420)                   istatus = 3 ! empty run
       if (irun.eq.18497)                   istatus = 3 ! empty run
       if (irun.eq.18560)                   istatus = 3 ! MDC HV err.
       if (irun.eq.18597)                   istatus = 3 ! MU no singal.
       if (irun.eq.18728)                   istatus = 3 ! empty run
       if (irun.eq.18782)                   istatus = 2 ! VC problem.
       if (irun.eq.18802)                   istatus = 2 ! MDC hot ch.
       if (irun.eq.18829)                   istatus = 3 ! empty run
       if (irun.eq.18986)                   istatus = 3 ! MU no HV.
       if (irun.ge.18993.and.irun.le.18994) istatus = 2 ! MDC hot ch.
       if (irun.eq.19050)                   istatus = 3 ! HV is off.
       if (irun.eq.19082)                   istatus = 3 ! MU no signal.
c      From 19150 to 19186 data taking for background study (3.0 GeV).
c      From 19187 to 19533 data taking for Jpsi , psi(2S),Jpsi" peak scan
c      and Jpsi(2s),Jpsi" data.
       if (irun.ge.19150)                   istatus = 3



       return
       end

