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

Feature update names #146

Merged
merged 2 commits into from
Jul 5, 2023
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
30 changes: 15 additions & 15 deletions cli/simulate_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,18 @@ def run_simulation(input_filename,
input_has_vertices = False

try:
genie_hdr = np.array(f['genie_hdr'])
input_has_genie_hdr = True
mc_hdr = np.array(f['mc_hdr'])
input_has_mc_hdr = True
except KeyError:
print("Input file does not have GENIE event summary info")
input_has_genie_hdr = False
print("Input file does not have MC event summary info")
input_has_mc_hdr = False

try:
genie_stack = np.array(f['genie_stack'])
input_has_genie_stack = True
mc_stack = np.array(f['mc_stack'])
input_has_mc_stack = True
except KeyError:
print("Input file does not have GENIE particle stack info")
input_has_genie_stack = False
print("Input file does not have MC particle stack info")
input_has_mc_stack = False

if tracks.size == 0:
print("Empty input dataset, exiting")
Expand Down Expand Up @@ -376,7 +376,7 @@ def run_simulation(input_filename,
for field in dtype[1:]:
new_vertices[field[0]] = vertices[field[0]]
vertices = new_vertices
uniq_ev, counts = np.unique(vertices['eventID'], return_counts=True)
uniq_ev, counts = np.unique(vertices['event_id'], return_counts=True)
vertices['t_event'] = np.repeat(event_times.get(),counts)

if sim.IS_SPILL_SIM:
Expand All @@ -391,9 +391,9 @@ def run_simulation(input_filename,
# all truth info in the edep-sim convention (z = beam coordinate). So
# temporarily undo the swap. It's easier than reorganizing the code!
swap_coordinates(tracks)
output_file.create_dataset("tracks", data=tracks)
output_file.create_dataset(sim.TRACKS_DSET_NAME, data=tracks)
# To distinguish from the "old" files that had z=drift in 'tracks':
output_file['tracks'].attrs['zbeam'] = True
output_file[sim.TRACKS_DSET_NAME].attrs['zbeam'] = True
swap_coordinates(tracks)

if light.LIGHT_SIMULATED:
Expand All @@ -402,10 +402,10 @@ def run_simulation(input_filename,
output_file.create_dataset("trajectories", data=trajectories)
if input_has_vertices:
output_file.create_dataset("vertices", data=vertices)
if input_has_genie_hdr:
output_file.create_dataset("genie_hdr", data=genie_hdr)
if input_has_genie_stack:
output_file.create_dataset("genie_stack", data=genie_stack)
if input_has_mc_hdr:
output_file.create_dataset("mc_hdr", data=mc_hdr)
if input_has_mc_stack:
output_file.create_dataset("mc_stack", data=mc_stack)

if sim.IS_SPILL_SIM:
# ..... even thought larnd-sim does expect t0 to be given with respect to
Expand Down
4 changes: 3 additions & 1 deletion larndsim/consts/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
IS_SPILL_SIM = True
IF_ACTIVE_VOLUME_CHECK = False
SPILL_PERIOD = 1.2e6 # units = microseconds
TRACKS_DSET_NAME = 'tracks'

# We mod event IDs by MAX_EVENTS_PER_FILE to get zero-based IDs for indexing
# purposes; see comments in simulate_pixels.py
Expand All @@ -41,7 +42,7 @@ def set_simulation_properties(simprop_file):
global IF_ACTIVE_VOLUME_CHECK
global SPILL_PERIOD
global MAX_EVENTS_PER_FILE

global TRACKS_DSET_NAME

with open(simprop_file) as df:
simprop = yaml.load(df, Loader=yaml.FullLoader)
Expand All @@ -54,3 +55,4 @@ def set_simulation_properties(simprop_file):
IF_ACTIVE_VOLUME_CHECK = simprop['if_active_volume_check']
SPILL_PERIOD = float(simprop['spill_period'])
MAX_EVENTS_PER_FILE = simprop['max_events_per_file']
TRACKS_DSET_NAME = simprop['tracks_dset_name']
3 changes: 2 additions & 1 deletion larndsim/simulation_properties/2x2_NuMI_sim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ write_batch_size: 1 # batches
is_spill_sim: 1 # boolean
if_active_volume_check: 0 # boolean
spill_period: 1.2e6 # microseconds
event_separator: 'eventID' # 'eventID'
event_separator: 'event_id' # 'event_id'
tracks_dset_name: 'segments' # or 'segments'
max_events_per_file: 1000
5 changes: 1 addition & 4 deletions larndsim/util/batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, track_seg, event_separator ,tpc_batch_size=1, tpc_borders=np.
self.tpc_batch_size = tpc_batch_size
self.tpc_borders = np.sort(tpc_borders, axis=-1)

self._simulated = np.zeros_like(self.track_seg['trackID'], dtype=bool)
self._simulated = np.zeros_like(self.track_seg['traj_id'], dtype=bool)
self._events = np.unique(self.track_seg[self.EVENT_SEPARATOR])
self._curr_event = 0
self._curr_tpc = 0
Expand Down Expand Up @@ -64,6 +64,3 @@ def __next__(self):
self._simulated = self._simulated | mask

return mask