subroutine hec_hvstat c c fill HV status 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 initialize HV related variables c already done in hec_slow_pass anyway c lhvstat = .false. call vzero(ic_hvstat,i_adc_dim) call vfill(ic_hv_cor,i_adc_dim, 1.) ! preset HV correction factors to 1 call vzero(ic_hv_known,i_adc_dim) c c do nothing if PC slow control block absent c if (stat_slow_pc .eq. 0) return c c set global HV status flag to known if slow control bank read c lhvstat = .true. c c Skip if online mode, c unless calibrated energy histograms are asked for. c also skip first runs of june 2000 testbeam, when the SC bank where c screwed up c if (irunpd .le. 8) then return elseif (irunpd.eq.12 .and. run_no.lt.9420) then print*,' *** WARNING: PC HV information is wrong' print*,' *** cannot calculate HV correction factor' print*,' ' return elseif (run_mode.eq.2 .and. histo_switch(5).eq.0) then return endif 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 endif enddo enddo c c calculate simple HV correction factors c note that they are preset to 1 in hec_slow_pass c do ic = 1, i_adc_used if (ic_hv_known(ic) .and. ic_connected(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) endif endif endif enddo c c print out list of adc channels affected by HV problems c j = 0 do ic = 1, i_adc_used if (ic_connected(ic)) then if ( (ic_hv_known(ic) .and. ic_hvstat(ic).ne.0) .or. + .not.ic_hv_known(ic) ) then j = j + 1 if (j .eq. 1) then print *, ' ***** WARNING: HV problems' print *, ' ic HV corection comment' endif if (ic_hv_known(ic) .and. ic_hvstat(ic).ne.0) then if (ic_hv_cor(ic) .ne. 1.) then write(*, '(5x,i5,5x,f10.4,5x,a,4i2)') ic, ic_hv_cor(ic), + 'subgaps: ', (1-ibits(ic_hvstat(ic),i,1),i=1,4) else write(*, '(5x,i5,5x,f10.4,5x,a)') ic, ic_hv_cor(ic), + 'status known, but all subgaps supposed off!' endif else write(*, '(5x,i5,5x,f10.4,5x,a)') ic, ic_hv_cor(ic), + 'status unknown!' endif endif endif enddo c return end