subroutine hec_cal_read c c read calibration coefficient file c implicit none c include'hec_par.inc' !shared parameters include'hec_cal.inc' include'hec_cal_coef.inc' !calibration coefficients include'hec_datacard.inc' !user datacard include'hec_geo.inc' !geometry correspondence tables c integer i, j integer ic real cal(4) integer iflg, nc integer nbad, ic_bad(1:i_adc_dim) integer npbad, ic_pbad(1:i_adc_dim) integer nnocal, ic_nocal(1:i_adc_dim) c c open input calibration file c open (unit=io_cal(2), file='calib.dat', status='old', err=3) c c read version number from top of calibration file c read (io_cal(2), *, err=2, end=4) cal_version print *, ' ' print *, ' *** reading calibration coefficients for version ', + cal_version c ic = 1 do while (ic .ge. 1 .and. ic .le. i_adc_dim) read (io_cal(2), *, err=2, end=4) ic, (cal(i), i=1, 4), iflg if (ic .ge. 1 .and. ic .le. i_adc_used) then do i = 1, 4 hec_cal_coef(ic, i) = cal(i) enddo hec_cal_coef(ic, 5) = iflg endif enddo c 2 continue print *, ' *** error reading calibration file' close (unit = io_cal(2)) stop c 3 continue print *, ' *** error opening calibration file' close (unit=io_cal(2)) stop c 4 continue close (unit=io_cal(2)) c c look for cells that have good calibration coefficients c bad if iflg = 0 c keep track locally, for printing only, of c bad connected cells (iflg = 0) c possibly bad connected cells (iflg = 2) c cells for which calibration is obtained from neighbour cells (iflg < 0) c nc = 0 nbad = 0 npbad = 0 nnocal = 0 call vzero(ic_bad, i_adc_dim) call vzero(ic_pbad, i_adc_dim) call vzero(ic_nocal, i_adc_dim) do ic = 1, i_adc_dim ic_has_calib(ic) = .true. if (nint(hec_cal_coef(ic, 5)) .eq. 0) then ic_has_calib(ic) = .false. if (ic_connected(ic)) then nbad = nbad + 1 ic_bad(nbad) = ic endif elseif (nint(hec_cal_coef(ic, 5)) .eq. 2) then if (ic_connected(ic)) then npbad = npbad + 1 ic_pbad(npbad) = ic endif elseif (nint(hec_cal_coef(ic, 5)) .lt. 0) then if (ic_connected(ic)) then nnocal=nnocal+1 ic_nocal(nnocal) = ic endif endif if (ic_has_calib(ic)) nc = nc +1 enddo print *, ' good calibration read for ', nc, ' channels' if (nbad .gt. 0) then print *, ' ***** WARNING *****' print *, ' bad or no calibration read for ', nbad, + ' connected channels:' do i = 1, nbad/10 + 1 write(*, '(5x,10i5)') + (ic_bad(j), j=1+10*(i-1), min(10+10*(i-1), nbad)) enddo endif if (npbad .gt. 0) then print *, ' ***** WARNING *****' print *, ' possibly bad calibration read for ', npbad, + ' connected channels:' do i = 1, npbad/10 + 1 write(*, '(5x,10i5)') + (ic_pbad(j), j=1+10*(i-1), min(10+10*(i-1), npbad)) enddo endif if (nnocal .gt. 0) then print *, ' ***** WARNING *****' print *, ' OFF weights and calibration coefficients from' print *, ' neighbouring cells for ',nnocal,' channels:' do i = 1, nnocal/10 +1 write(*, '(5x,10i5)') + (ic_nocal(j), j=1+10*(i-1), min(10+10*(i-1), nnocal)) enddo endif c end