Some notes regarding signal reconstruction. M. Lefebvre 19/07/2001 The digital filtering signal reconstruction requires the pedestals to be known. Here we assume that the pedestals are read from a file (in hec_adc they can also be produced by one or two passes over the data by the ped package). Only noting the relevant routines, we have hec_adc.f --> hec_offline.f --> hec_offline_ini.f --> hec_tdc_ini.f ! set some tdc constants --> hec_packages.f ! call packages --> hec_ped.f ! pedestal package --> hec_ped_read.f ! here assume only read peds from file --> hec_dig.f ! reset some variables --> hec_dig_read_weights.f ! read weight parameters from file --> hec_pass1.f (or 2, 3) ! the complete pass --> hec_nextevt_epio.f ! looks for next event record --> hec_evth_epio.f ! unpack event header block (with trig bits) --> hec_adc_epio.f ! unpack hec fadc block --> hec_adc_unpk.f! unpack helper --> hec_tdc_epio.f ! unpack tdc block --> hec_evt.f ! process event --> hec_adc_fill.f ! fill other adc arrays (irrelevant here) --> hec_trig_evt.f ! process trigger bits --> hec_tdc_evt.f ! process tdc data (get phase) --> hec_dig_evt.f ! digital filtering --> hec_dig_calc_weights.f ! computer real weights for event --> hec_dig_fit.f ! get sig max (in adc-ped) and time max (ns) Notes: hec_tdc_ini.f This sets some tdc constants (in principle run dependent): tdc_raw_to_ns ! conversion factor from tdc to ns tdc_wac_c ! wrap around constant for trig_wac_c events tdc_wac_epi ! wrap around constant for trig_wac_epi events tdc_wac_mu ! wrap around constant for trig_wac_mu events tdc_wac_reference ! one of the above tdc_guard_region ! deals with tdc imprecision (usually set to 10 tdc) The tdc_wac_c, epi and mu constants need to be obtained from the data. The tdc_wac_reference corresponds to the wac trigger type used to produce the timing synchronisation of the weight parameters (it should really be in the weights_amp file). hec_dig_read_weights.f This reads the weight parameters file. These weight parameters are not the actual weights; they offer a parametrisation of the weights as a function of time (the 0 to 25 ns phase). The file also contains the header words (see calib/coeff.index): dig_weight_version version number (eg. 981014) dig_nslice number of slices used in filtering (eg. 5) dig_nwpar number of filtering weight parameters (eg. 5) dig_slice_1 the first guess at the first time slice used in filtering dig_t_global for run period >= 9, global time offset (ns) dig_ic_ref for run period >= 9, reference ic for global time offset The last 3 are important to obtain, for each event, a) the phase (0 to 25ns) and b) the first (of 5) time slice to use for the digital filtering. In principal, Pavol (who makes the weight parameters), needs to look at some real data (of which the wac trigger type fixes tdc_wac_reference) in channel dig_ic_ref in order to obtain dig_t_global. If desired, the weight parameters file can also contain timing corrections (t0 offsets) for each channels (see calib/coeff.index for details) hec_adc_epio.f and hec_adc_unpk.f Sepp warns us that the exact format of the hec fadc block will change next year. hec_evth_epio.f The event header block gets unpacked in hec_evth.inc. In particular here, the arrays variables lpat_* contain the bits of the 4 pattern units necessary to compute the trigger words. hec_adc_epio.f and hec_adc_unpk.f The hec fadc block is unpacked in hec_adc.inc in the array i_adc_ic_t(ic, i_t) which contains the adc value of channel ic and for time sample i_t. hec_tdc_epio.f The tdc block is unpacked in hec_tdc_sys.inc, but none of the values stored there are needed later. The only relevant value obtained here is tdc_raw which is filled in inc/hec_tdc.inc. hec_trig_evt.f This routine, which I have checked by Leonid each run period, uses the lpat_* arrays to compute useful trigger words. See inc/hec_trig.inc for details. In particular, trig_wac_c trig_wac_epi trig_wac_mu are needed in order to compute the phase for the event. hec_tdc_evt.f This routine computes the tdc phase for the event. It is tdc_ns is inc/hec_tdc.inc. As input, it needs - the tdc_raw_to_ns and tdc_wac_* constants for this run - the wac trigger words for the event trig_wac_c trig_wac_epi trig_wac_mu - the tdc_raw value for the event (from the tdc module) hec_dig_evt.f This is the main event routine for digital filtering for the event. First, - it computes the weights for the event (hec_dig_calc_weights.f) Then for each channel, - it extracts the appropriate dig_nslice=5 time samples - it computes the signal (ped-adc) and time (ns) of the pulse maximum (hec_dig_fit.f) hec_dig_calc_weights.f To compute the amplitude and time weights for the event, this routine needs to calculate the digital filtering phase for the event (which may differ from the tdc_ns phase because of time sampling shifts (usually +/- 25ns), or because of bad dig_t_global value in weight parameters file). To get this dig_ns_ref phase, it needs - dig_t_global (from the weight parameters file) - tdc_ns (from hec_tdc_evt.f) A by product of this is a possible shift of the first time sample to consider for digital filtering with respect to the dig_slice_1 value in the weights file. This is dig_slice_shift_ref. In principle, dig_ns_ref and dig_slice_shift_ref are only good for the channel used to obtain dig_t_global. At this point, we may want to apply timing corrections (t0 offsets) to each channel (typically of order 1ns). We found out in the past that such corrections did not alter the digital filtering result in a significant way (the slope of the pulse is 0 at the peak!). So we normally use them for all channels: call vfill(dig_ns, i_adc_used, dig_ns_ref) call vfill(dig_slice_shift, i_adc_used, dig_slice_shift_ref) But hec_dig_calc_weights does have all the functionality to apply the t0 offsets. It may be a good idea to keep this in mind in the athena implementation, even if we should not implement it for now. The event weights, which are needed by hec_dig_fit.f, are stored in hec_dig_sys.inc in the arrays dig_weight_amp and dig_weight_tim. hec_dig_fit.f For a given channel, this routine applies the digital filtering weights for the event (dig_weight_amp and dig_weight_tim) to the appropriate dig_nslice=5 time samples to compute the signal (adc-ped) and time (ns) of the pulse maximum. Comments welcome!