subroutine hec_hvstat c c fill arrays ic_hvstat and ic_hv_known c implicit none c c include files c include'hec_par.inc' include'hec_geo.inc' include'hec_hvpar.inc' include'hec_slow_pc.inc' include'hec_stats_epio.inc' include'hec_hvstat.inc' include'hec_datacard.inc' include'hec_runh.inc' c c local variables c integer i, j, ic, i_mod, i_seg, i_pad real hvmin, nhvbad parameter (hvmin = 1790) ! Hasko's limit c c do nothing if slow control bank absent c if ( stat_slow.eq.0 ) return c c set global HV status flag to known if slow control bank read c lhvstat = .true. c c during period 13 some HV lines were disconnected and the c corresponding channels moved to different lines. Modify c hvtodb array accordingly c if(irunpd.eq.13)then if(run_no.ge.9917)then do i=1,3 hvtodb(2,2,i)=hvtodb(0,4,i) hvtodb(0,4,i)=0 hvtodb(2,9,i)=hvtodb(1,6,i) hvtodb(1,6,i)=0 enddo if(run_no.gt.10266)then do i=1,3 hvtodb(2,10,i)=hvtodb(0,12,i) hvtodb(0,12,i)=0 enddo endif endif endif c c loop over HV modules and channels c do i = 0 , nmodhv_cal_max-1 do j = 1 , nchhv_cal_max c c find corresponding module and segment in calorimeter c i_mod = hvtodb(i,j,1) i_seg = hvtodb(i,j,3) c if (i_mod.ne.0.and.i_seg.ne.0) then c c if the HV channel is connected, find out adc # c do i_pad = 1, i_pad_used ic = dbtoic(i_mod,i_seg,i_pad) if( ic. ne. 0)then c c set the channel to good/bad according to HV value c ic_hv_known(ic) = .true. if( hv_cal_hv(i,j).lt.hvmin )then ic_hvstat(ic)=ibset(ic_hvstat(ic),hvtodb(i,j,2)) endif endif enddo c endif c enddo enddo c c calculate simple HV correction factors c do ic = 1, i_adc_used if(ic_hv_known(ic))then if(ic_hvstat(ic).ne.0)then nhvbad=0. do i=1,4 if( btest(ic_hvstat(ic),i) )nhvbad=nhvbad+1. enddo if(nhvbad.lt.4)then ic_hv_cor(ic)=4./(4.- nhvbad) else print*,' *** WARNING: HV OFF according to SC bank' print*,' No correction factor applied' ic_hv_cor(ic)=1. endif else ic_hv_cor(ic)=1. endif endif enddo c c print out list of adc channels affected by HV problems c do i = 1,i_adc_used if(ic_hv_known(i).and.ic_hvstat(i).ne.0)then print*,'HV problem for adc channel ',i , + ' HV correction factor is',ic_hv_cor(i) endif enddo c return end