Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/proto_nd_flow/reco/charge/raw_event_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,9 @@ def build_events(self, packets, unix_ts, mc_assn=None):
if self.trig_io_grp != [-1]:
iog_masks = [packets['io_group'] == iog for iog in self.trig_io_grp]
trig_mask &= np.logical_or.reduce(iog_masks)

trigger_idcs = np.where(trig_mask)[0]

events = []
event_unix_ts = []
event_mc_assn = [] if mc_assn is not None else None
Expand Down
10 changes: 10 additions & 0 deletions src/proto_nd_flow/reco/charge/raw_event_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,16 @@ def next(self):
if self.is_mc:
mc_assn = mc_assn[mask]

pkts_indices = np.arange(len(packet_buffer))
trig_mask = packet_buffer['packet_type'] == 7
trig_ts = packet_buffer['timestamp'][trig_mask]

# handle when there are duplicate triggers -- specifically designed to handle the 2x2 run2 problem where repeat pulses have precisely 3 ticks between them
ts_diff = np.diff(trig_ts)
if np.any(ts_diff == 3):
trigger_idcs = np.concatenate(([0], np.where(ts_diff != 3)[0]+1))
packet_buffer = packet_buffer[(packet_buffer['packet_type'] != 7) | np.isin(pkts_indices, pkts_indices[trig_mask][trigger_idcs])]

# find unix timestamp groups
ts_mask = packet_buffer['packet_type'] == 4
ts_grps = np.split(packet_buffer, np.argwhere(ts_mask).ravel())
Expand Down
Loading