'Collect DACQ events into a dict.
Events are keyed by number starting from 1 (DACQ index of event).
Each event is itself represented by a dict containing the event
parameters.'

def _events_from_acq_pars(self):

    _compat_event_lookup = {1: 1, 2: 2, 3: 4, 4: 8, 5: 16, 6: 32, 7: 3, 8: 5, 9: 6, 10: 7, 11: 9, 12: 10, 13: 11, 14: 12, 15: 13, 16: 14, 17: 15}
    events = dict()
    for evnum in range(1, (self.nevent + 1)):
        evnum_s = str(evnum).zfill(2)
        evdi = dict()
        event_vars = (self._event_vars_compat if self.compat else self._event_vars)
        for var in event_vars:
            acq_key = (('ERFevent' + var) + evnum_s)
            dict_key = var.lower()
            val = self.acq_dict[acq_key]
            if (dict_key in ['newbits', 'oldbits', 'newmask', 'oldmask']):
                val = int(val)
            elif (dict_key in ['delay']):
                val = float(val)
            evdi[dict_key] = val
            evdi['in_use'] = False
        evdi['index'] = evnum
        if self.compat:
            evdi['name'] = str(evnum)
            evdi['oldmask'] = 63
            evdi['newmask'] = 63
            evdi['oldbits'] = 0
            evdi['newbits'] = _compat_event_lookup[evnum]
        events[evnum] = evdi
    return events
