subroutine hec_adc_epio c c read raw ADC block from epio c implicit none c include'hec_par.inc' !shared parameters include'hec_adc.inc' !adc values include'hec_datacard.inc' !user datacard values include'hec_epio.inc' !epio common include'hec_geo.inc' !geometry correspondence tables include'hec_runh.inc' !run header c c local variables c integer ic !adc channel number integer i_t !time sampling number integer ladc !index of first adc word in adc bank integer n_adc_epio !actual number of adc channels read integer ip real a c INTEGER I,J c c index of first adc in adc block c number of adc channels read by epio c n_adc_epio = i_adc_used if (irunpd .le. 3) then ladc = 3 n_adc_epio = ibankbuf(1) -1 else ladc = 5 endif c c check for bad event (number of adc to be read is too big). The only c time this is allowed to happen is in runs from may96. c During that period the adc banks were very screwed up with extra words c and we need to allow the code to keep going in those affected c runs, or may96 data would be impossible to analyse. c Unfortunately, this is an ugly fix. c if (n_adc_epio .gt. i_adc_dim) then if (irunpd .eq. 1) then n_adc_epio = i_adc_used else print *, ' *** number of adc in event is too big for '// + 'this run period in hec_adc_epio', + n_adc_epio stop endif endif c c fill i_adc_ic_t in hec_adc.inc from data array c if (irunpd .le. 4) then do ic = 1, n_adc_epio do i_t = 1, i_tim_used ip = (ic - 1)*i_tim_used + i_t i_adc_ic_t(ic, i_t) = ibankbuf(ladc - 1 + ip) enddo enddo elseif (irunpd .eq. 5) then ip = 0 do ic = 2, n_adc_epio, 2 do i_t = 1, i_tim_used ip = ip + 2 i_adc_ic_t(ic - 1, i_t) = ibankbuf(ladc - 1 + ip) i_adc_ic_t(ic, i_t) = ibankbuf(ladc - 1 + ip - 1) enddo enddo else ip = 0 do ic = 2, n_adc_epio, 2 do i_t = 1, i_tim_used ip = ip + 2 i_adc_pk(ic - 1, i_t) = ibankbuf(ladc - 1 + ip - 1) i_adc_pk(ic, i_t) = ibankbuf(ladc - 1 + ip) enddo enddo call hec_adc_unpk endif c c cabling fixes c c fix bad adcs for July 1996 (zero them) c if (irunpd .eq. 2) then i_adc_ic(54) = 0 i_adc_ic(59) = 0 c c remap to account for recabling in September 1996 c elseif (irunpd .eq. 3) then i_adc_ic(93) = i_adc_ic(173) i_adc_ic(107) = i_adc_ic(172) i_adc_ic(135) = i_adc_ic(169) i_adc_ic(121) = 0 i_adc_ic(149) = 0 c c 2 adc modules were swapped for early runs in April 1998 c elseif (irunpd .eq. 7) then if (run_no .le. 6912) then do ic = 1, 32 do i_t = 1, i_tim_used a = i_adc_ic_t(ic, i_t) i_adc_ic_t(ic, i_t) = i_adc_ic_t(ic + 32, i_t) i_adc_ic_t(ic + 32, i_t) = a enddo enddo endif endif c c print *, ' *** adc values read',i_adc_used c WRITE(*,*)((i_adc_ic_t(i,j),j=1,7),i=1,i_adc_used) c end