subroutine hec_fadc_unpk c c read event header from epio block c implicit none c c geometry correspondence tables common c must be preceded by the include file hec_par.inc c include'hec_par.inc' include'hec_geo.inc' c c adc values common c include'hec_fadc.inc' c c local variables c integer i_t integer ipat1, ipat2, imod, iw, iwstart, iwend c c unpack bits and fill common. c do imod = 1, n_fadc_mod if (imod .eq. 1) then iwstart = 2 iwend = 2*i_fadc_tim elseif (imod .eq. 2) then iwstart = 2*i_fadc_tim + 2 iwend = 4*i_fadc_tim endif do iw = iwstart, iwend, 2 ipat1 = i_fadc_pk(iw-1) ipat2 = i_fadc_pk(iw) c c make binary into actual channel numbers and adc values c first 8 bits are channel, then 12 bits for even numbered c channel followed by 12 bits for odd numbered channel. c ibits is from cernlib Kernlib M441. It translates a certain c bit range in a word into an integer (counts right to left). c c if (imod .eq. 1) i_t = iw/2 if (imod .eq. 2) i_t = iw/2 - iwstart/2 + 1 i_fadc_ic_t(4*imod-3,i_t) = ibits(i_fadc_pk(iw),0,8) i_fadc_ic_t(4*imod-2,i_t) = ibits(i_fadc_pk(iw),8,8) c i_fadc_ic_t(4*imod-1,i_t) = ibits(i_fadc_pk(iw-1),0,8) i_fadc_ic_t(4*imod,i_t) = ibits(i_fadc_pk(iw-1),8,8) c c print debug c ccc print *, 'ipat1:2 -->',ipat1,ipat2 ccc print *, 'fadc,ic,t',i_fadc_ic_t(4*imod-3,i_t),4*imod-3,i_t ccc print *, 'fadc,ic,t',i_fadc_ic_t(4*imod-2,i_t),4*imod-2,i_t ccc print *, 'fadc,ic,t',i_fadc_ic_t(4*imod-1,i_t),4*imod-1,i_t ccc print *, 'fadc,ic,t',i_fadc_ic_t(4*imod,i_t),4*imod,i_t c enddo enddo c c c print *,' *** fadc data unpacked' c end