From 1a476e9fdbaec78006ccdd9dbabdd85df80b688e Mon Sep 17 00:00:00 2001 From: Yifan Chen Date: Sun, 21 Apr 2024 08:44:11 -0700 Subject: [PATCH] add mod2mod_variation capability to the parser --- src/LarpixParser/event_parser.py | 4 ++-- src/LarpixParser/get_raw_coord.py | 13 +++++++++++-- src/LarpixParser/util.py | 16 +++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/LarpixParser/event_parser.py b/src/LarpixParser/event_parser.py index c9e0e5f..e7bad3c 100644 --- a/src/LarpixParser/event_parser.py +++ b/src/LarpixParser/event_parser.py @@ -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. @@ -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 diff --git a/src/LarpixParser/get_raw_coord.py b/src/LarpixParser/get_raw_coord.py index 0b191d6..7c0756e 100644 --- a/src/LarpixParser/get_raw_coord.py +++ b/src/LarpixParser/get_raw_coord.py @@ -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 diff --git a/src/LarpixParser/util.py b/src/LarpixParser/util.py index 838037a..e9a1d40 100644 --- a/src/LarpixParser/util.py +++ b/src/LarpixParser/util.py @@ -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): @@ -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) @@ -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')