Skip to content

Commit

Permalink
get event_id from the batch directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifan Chen committed Aug 4, 2024
1 parent 053c400 commit 0804788
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions cli/simulate_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,18 +803,14 @@ def save_results(event_times, is_first_batch, results, i_trig, i_mod=-1, light_o
i_trig = 0
sync_start = event_times[0] // (fee.CLOCK_RESET_PERIOD * fee.CLOCK_CYCLE) * (fee.CLOCK_RESET_PERIOD * fee.CLOCK_CYCLE) + (fee.CLOCK_RESET_PERIOD * fee.CLOCK_CYCLE)
det_borders = module_borders if mod2mod_variation else detector.TPC_BORDERS
for batch_mask in tqdm(batching.TPCBatcher(all_mod_tracks, tracks, sim.EVENT_SEPARATOR, tpc_batch_size=sim.EVENT_BATCH_SIZE, tpc_borders=det_borders),
# Batching is carried out by simulating detector response with selected segments from X number of tpcs per event
# X is set by "sim.EVENT_BATCH_SIZE" and can be any number
for ievd, batch_mask in tqdm(batching.TPCBatcher(all_mod_tracks, tracks, sim.EVENT_SEPARATOR, tpc_batch_size=sim.EVENT_BATCH_SIZE, tpc_borders=det_borders),
desc='Simulating batches...', ncols=80, smoothing=0):
i_batch = i_batch+1
# grab only tracks from current batch
# Grab segments from the current batch
# If there are no segments in the batch, we still check if we need to generate null light signals
track_subset = tracks[batch_mask]
# This is safe as long as you never want to simulate different event_ids (spills) in
# the same batch.
if len(track_subset["event_id"]):
ievd = track_subset["event_id"][0]
else:
# If there are no tracks post-masking then just skip.
continue
evt_tracks = track_subset
#first_trk_id = np.argmax(batch_mask) # first track in batch

Expand Down
2 changes: 1 addition & 1 deletion larndsim/util/batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def __next__(self):
mask = mask & tpc_mask
self._simulated = self._simulated | mask

return mask
return self._events[self._curr_event], mask

0 comments on commit 0804788

Please sign in to comment.