Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trigger forwarding issue for non modular variation setups #207

Merged
merged 2 commits into from
Feb 28, 2024
Merged
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
7 changes: 6 additions & 1 deletion cli/simulate_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,11 @@ def save_results(event_times, is_first_batch, results, i_trig, i_mod=-1, light_o
segment_ids = all_mod_segment_ids[module_tracks_mask]
RangePop()

# find the module that triggers
io_groups = np.array(list(consts.detector.MODULE_TO_IO_GROUPS.values()))
if light.LIGHT_TRIG_MODE == 0 or light.LIGHT_TRIG_MODE == 1:
trig_module = np.argwhere(io_groups==fee.get_trig_io())[0][0] + 1 # module id (i_mod) counts from 1

RangePush("run_simulation")
TPB = 256
BPG = max(ceil(tracks.shape[0] / TPB),1)
Expand Down Expand Up @@ -786,7 +791,7 @@ def save_results(event_times, is_first_batch, results, i_trig, i_mod=-1, light_o
fee.export_sync_to_hdf5(output_filename, sync_times_export, i_mod)
sync_start = sync_times[-1] + fee.CLOCK_RESET_PERIOD * fee.CLOCK_CYCLE
# beam trigger is only forwarded to one specific pacman (defined in fee)
if (light.LIGHT_TRIG_MODE == 0 or light.LIGHT_TRIG_MODE == 1) and i_mod == 1:
if (light.LIGHT_TRIG_MODE == 0 or light.LIGHT_TRIG_MODE == 1) and (i_mod == trig_module or i_mod == -1):
fee.export_timestamp_trigger_to_hdf5(output_filename, this_event_time, i_mod)

# generate light waveforms for null signal in the module
Expand Down
25 changes: 13 additions & 12 deletions larndsim/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,23 @@
DISCRIMINATOR_NOISE = 650 * e
#: Average time between events in microseconds
EVENT_RATE = 100000 # 10Hz
#: Beam trig io group
BEAM_TRIG_IO = 1
#: Threshold/LRS trig io group
THRES_TRIG_IO = 2

import logging
logging.basicConfig()
logger = logging.getLogger('fee')
logger.setLevel(logging.WARNING)
logger.info("ELECTRONICS SIMULATION")

def get_trig_io():
"""
Returns the io_group if the trigger is only forwarded to one pacman
"""
if light.LIGHT_TRIG_MODE == 0: #: Threshold/LRS trigger
trig_io = 2
elif light.LIGHT_TRIG_MODE == 1: #: Beam trigger
trig_io = 1
return trig_io

def rotate_tile(pixel_id, tile_id):
"""
Returns the pixel ID of the rotated tile.
Expand Down Expand Up @@ -265,10 +271,8 @@ def export_to_hdf5(event_id_list,
packets_frac.append([0] * current_fractions.shape[2])
# redundant here
elif light.LIGHT_TRIG_MODE == 1:
if module_trig == 1: #beam trigger
io_group = BEAM_TRIG_IO
elif module_trig == 0: #threshold trigger
io_group = THRES_TRIG_IO
if module_trig == 1 or module_trig == 0: #1, beam trigger; 2, threshold trigger
io_group = get_trig_io()
packets.append(TriggerPacket(io_group=io_group, trigger_type=b'\x02', timestamp=t_trig))
packets_mc_evt.append([-1])
packets_mc_trk.append([-1] * track_ids.shape[1])
Expand Down Expand Up @@ -450,10 +454,7 @@ def export_timestamp_trigger_to_hdf5(filename, event_start_times, i_mod=-1):

t_trig = int(np.floor(evt_time / CLOCK_CYCLE)) % CLOCK_RESET_PERIOD # tick

if light.LIGHT_TRIG_MODE == 0:
io_group = THRES_TRIG_IO
if light.LIGHT_TRIG_MODE == 1:
io_group = BEAM_TRIG_IO
io_group = get_trig_io()

# timestamp packets
packets.append(TimestampPacket(timestamp=evt_time*units.mus/units.s)) # s
Expand Down