Skip to content

Commit

Permalink
add mod2mod_variation capability to the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifan Chen committed Apr 21, 2024
1 parent a007b27 commit 1a476e9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/LarpixParser/event_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_t0_event(vertices, run_config, event_parser='event_id', time_parser='t_e
return t0_ev


def packet_to_eventid(assn, tracks, event_parser='event_id'):
def packet_to_eventid(assn, tracks, event_parser='event_id', track_parser='segment_ids'):
'''
Assoiciate packet to event_id.
Expand All @@ -84,7 +84,7 @@ def packet_to_eventid(assn, tracks, event_parser='event_id'):
array of event_id.
`len(event_ids)` equals to `len(packets)`
'''
track_ids = assn['track_ids'].max(axis=-1)
track_ids = assn[track_parser].max(axis=-1)

event_ids = np.full_like(track_ids, -1, dtype=int)
mask = track_ids != -1
Expand Down
13 changes: 11 additions & 2 deletions src/LarpixParser/get_raw_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ def get_pixel_plane_position(packets_arr, geom_dict, run_config):

tpc_centers = run_config['tpc_offsets']
nr_iogroup_module = run_config['nr_iogroup_module']
try:
geom_dict_idx = run_config['geom_dict_idx']
modvar = True
except:
modvar = False
pass

x, y, z, direction = [], [], [], []
for packet in packets_arr:
io_group = packet['io_group']
io_group = packet['io_group'] # counting from 1

module_id = (io_group - 1) // nr_iogroup_module # counting from 0
io_group = io_group - module_id * nr_iogroup_module

xyz = geom_dict[io_group, packet['io_channel'], packet['chip_id'], packet['channel_id']]
if modvar:
xyz = geom_dict[geom_dict_idx[module_id]][io_group, packet['io_channel'], packet['chip_id'], packet['channel_id']]
else:
xyz = geom_dict[io_group, packet['io_channel'], packet['chip_id'], packet['channel_id']]

# Note tpc_centers is ordered by z, y, x, as in larnd-sim config files
x_offset = tpc_centers[module_id][2]*10
Expand Down
16 changes: 9 additions & 7 deletions src/LarpixParser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_run_config(run_config_path, use_builtin = False):
return run_config

def configuration_keywords():
return ['module0','2x2', '2x2_only', '2x2_MR4', '2x2_MR45', 'ndlar']
return ['module0','2x2', '2x2_mod2mod_variation', '2x2_MR3', '2x2_MR4', 'ndlar']

def detector_configuration(detector):

Expand All @@ -76,7 +76,7 @@ def detector_configuration(detector):
run_config = get_run_config(run_config_path)
geom_dict = load_geom_dict(geom_path)

elif detector == "2x2":
elif detector == "2x2_MR3":
run_config_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/2x2.yaml')
geom_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/dict_repo/multi_tile_layout-2.3.16.pkl')
run_config = get_run_config(run_config_path)
Expand All @@ -88,17 +88,19 @@ def detector_configuration(detector):
run_config = get_run_config(run_config_path)
geom_dict = load_geom_dict(geom_path)

elif detector == "2x2_MR45":
elif detector == "2x2":
run_config_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/2x2_geo_v4.yaml')
geom_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/dict_repo/multi_tile_layout-2.4.16.pkl')
run_config = get_run_config(run_config_path)
geom_dict = load_geom_dict(geom_path)

elif detector == "2x2_only":
run_config_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/2x2.yaml')
geom_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/dict_repo/multi_tile_layout-2.4.16.pkl')
elif detector == "2x2_mod2mod_variation":
run_config_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/2x2_geo_v4.yaml')
geom_path_v2a = pkg_resources.resource_filename('LarpixParser', 'config_repo/dict_repo/multi_tile_layout-2.4.16.pkl')
geom_path_v2b = pkg_resources.resource_filename('LarpixParser', 'config_repo/dict_repo/multi_tile_layout-2.5.16.pkl')
run_config = get_run_config(run_config_path)
geom_dict = load_geom_dict(geom_path)
geom_dict = [load_geom_dict(geom_path_v2a), load_geom_dict(geom_path_v2b)]
run_config['geom_dict_idx'] = [0,0,1,0]

elif detector == "ndlar":
run_config_path = pkg_resources.resource_filename('LarpixParser', 'config_repo/ndlar-module.yaml')
Expand Down

0 comments on commit 1a476e9

Please sign in to comment.