subroutine hec_tdc_epio c c unpack and save TDC data into common block for each event c author: 17/11/97 Dieter Striegel c modification: 08/04/98 M. L. c 14/08/99 M.L. Improved tdc data decoding c new hec_tdc_sys.inc common for details c implicit none c include'hec_epio.inc' ! epio include'hec_tdc.inc' ! tdc include'hec_tdc_sys.inc' ! tdc detailed info c integer i, data_channel, data_word, data_status integer tdc_header c c get the tdc header word and decode it c tdc_header = ibankbuf(3) tdc_status = ibits(tdc_header, 15, 1) tdc_n_data = ibits(tdc_header, 12, 3) tdc_i_event = ibits(tdc_header, 0, 12) c c get the data words and their status word c do i = 0, 7 tdc_data(i) = 0 tdc_data_status(i) = 1 enddo if (tdc_status .eq. 1) then do i = 0, tdc_n_data data_channel = ibits(ibankbuf(i + 4), 12, 3) data_word = ibits(ibankbuf(i + 4), 0, 12) data_status = ibits(ibankbuf(i + 4), 15, 1) if (data_channel.ge.0 .and. data_channel.le.7) then tdc_data(data_channel) = data_word tdc_data_status(data_channel) = data_status else print *, ' *** problem in tdc data, tdc channel # ', + data_channel endif enddo endif c c get the tdc_raw value used in the analysis from channel 0. c if (tdc_data_status(0) .eq. 0) then tdc_raw = tdc_data(0) else tdc_raw = 0 endif c c for reference, old way of getting tdc raw c it was verified that this old way gives the same result as the new way c but the new way is safest c c tdc_raw = ibits(ibankbuf(4), 0, 12) c c end