diff --git a/scripts/build_evt.py b/scripts/build_evt.py index 0599f77..910cfa5 100644 --- a/scripts/build_evt.py +++ b/scripts/build_evt.py @@ -116,28 +116,24 @@ def replace_evt_with_key(dic, new_key): rand_num = f"{rng.integers(0,99999):05d}" temp_output = f"{args.output}.{rand_num}" +tables = {} for key, config in evt_config.items(): - build_evt( + tables[key] = build_evt( f_tcm=args.tcm_file, f_dsp=args.dsp_file, f_hit=args.hit_file, - f_evt=temp_output, + f_evt=None, evt_config=config, evt_group=f"evt/{key}" if key != "all" else "evt", tcm_group="hardware_tcm_1", dsp_group="dsp", hit_group="hit", - tcm_id_table_pattern="ch{}", - wo_mode="a", + tcm_id_table_pattern="ch{}" ) -tables = {} -for key in evt_config: - tables[key] = sto.read(f"evt/{key}" if key != "all" else "evt", temp_output)[0] - tbl = Table(col_dict=tables) -sto.write(obj=tbl, name="evt", lh5_file=args.output, wo_mode="a") -os.remove(temp_output) +sto.write(obj=tbl, name="evt", lh5_file=temp_output, wo_mode="a") +os.rename(temp_output, args.output) t_elap = time.time() - t_start log.info(f"Done! Time elapsed: {t_elap:.2f} sec.") diff --git a/scripts/build_skm.py b/scripts/build_skm.py index 4bd4293..ab61734 100644 --- a/scripts/build_skm.py +++ b/scripts/build_skm.py @@ -135,14 +135,13 @@ def group_files(fs_evt, fs_hit, fs_dsp, fs_tcm): log.debug(log_string) tables = {} for key, config in skm_config.items(): - build_skm( - f_evt, - f_hit, - f_dsp, - f_tcm, - f"{args.output}.{rand_num+1:05d}", - config, - wo_mode="a", + tables[key] = build_skm( + f_evt = f_evt, + f_hit = f_hit, + f_dsp = f_dsp, + f_tcm = f_tcm, + f_skm= None, + skm_conf = config, skm_group=f"skm/{key}" if key != "all" else "skm", evt_group="evt", tcm_group="hardware_tcm_1", @@ -150,11 +149,8 @@ def group_files(fs_evt, fs_hit, fs_dsp, fs_tcm): hit_group="hit", tcm_id_table_pattern="ch{}", ) - tables[key] = sto.read( - f"skm/{key}" if key != "all" else "skm", f"{args.output}.{rand_num+1:05d}" - )[0] + tbl = Table(col_dict=tables) sto.write(obj=tbl, name="skm", lh5_file=temp_output, wo_mode="a") - os.remove(f"{args.output}.{rand_num+1:05d}") os.rename(temp_output, args.output)