From f569ccb1e5372a12c501395fe4a5c71bacec105a Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Thu, 5 Dec 2024 14:24:12 -0500 Subject: [PATCH] backwards_ecal: produce file lists --- benchmarks/backwards_ecal/Snakefile | 11 +++++++---- benchmarks/backwards_ecal/backwards_ecal.org | 10 +++++++--- benchmarks/backwards_ecal/config.yml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/benchmarks/backwards_ecal/Snakefile b/benchmarks/backwards_ecal/Snakefile index 9b0b1559..8b94d911 100644 --- a/benchmarks/backwards_ecal/Snakefile +++ b/benchmarks/backwards_ecal/Snakefile @@ -64,14 +64,17 @@ exec env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ """ -rule backwards_ecal_recon_many: +rule backwards_ecal_local_sim_list: input: expand( "sim_output/backwards_ecal/{{DETECTOR_CONFIG}}/{{PARTICLE}}/{{ENERGY}}/{{PHASE_SPACE}}/{{PARTICLE}}_{{ENERGY}}_{{PHASE_SPACE}}.{INDEX:04d}.eicrecon.tree.edm4eic.root", INDEX=range(20), ), output: - touch("sim_output/backwards_ecal/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/flag"), + "listing/backwards_ecal/local/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst", + run: + with open(output[0], "wt") as fp: + fp.write("\n".join(input)) DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"] @@ -79,7 +82,7 @@ DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"] rule backwards_ecal: input: expand( - "sim_output/backwards_ecal/" + DETECTOR_CONFIG + "/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/flag", + "listing/backwards_ecal/local/" + DETECTOR_CONFIG + "/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst", PARTICLE=["pi-", "e-"], ENERGY=[ "100MeV", @@ -103,7 +106,7 @@ env \ MATPLOTLIBRC={input.matplotlibrc} \ DETECTOR_CONFIG=""" + DETECTOR_CONFIG + """ \ PLOT_TITLE=""" + DETECTOR_CONFIG + """ \ -INPUT_PATH_FORMAT=sim_output/backwards_ecal/""" + DETECTOR_CONFIG + """/{{particle}}/{{energy}}/130to177deg/{{particle}}_{{energy}}_130to177deg.{{ix:04d}}.eicrecon.tree.edm4eic.root \ +INPUT_PATH_FORMAT=listing/backwards_ecal/local/""" + DETECTOR_CONFIG + """/{{particle}}/{{energy}}/130to177deg.lst \ OUTPUT_DIR={output} \ python {input.script} """ diff --git a/benchmarks/backwards_ecal/backwards_ecal.org b/benchmarks/backwards_ecal/backwards_ecal.org index 27f1094c..1028e318 100644 --- a/benchmarks/backwards_ecal/backwards_ecal.org +++ b/benchmarks/backwards_ecal/backwards_ecal.org @@ -57,7 +57,6 @@ setup_presentation_style() DETECTOR_CONFIG=os.environ.get("DETECTOR_CONFIG") PLOT_TITLE=os.environ.get("PLOT_TITLE") INPUT_PATH_FORMAT=os.environ.get("INPUT_PATH_FORMAT", "EPIC/RECO/24.04.0/epic_craterlake/SINGLE/{particle}/{energy}/130to177deg/{particle}_{energy}_130to177deg.{ix:04d}.eicrecon.tree.edm4eic.root") -INPUT_PATH_INDEX_RANGE=list(range(20)) output_dir=Path(os.environ.get("OUTPUT_DIR", "./")) output_dir.mkdir(parents=True, exist_ok=True) @@ -102,13 +101,18 @@ filter_name = [ pi_eval = {} e_eval = {} +def readlist(path): + with open(path, "rt") as fp: + paths = [line.rstrip() for line in fp.readlines()] + return paths + for energy in energies: pi_eval[energy] = filter_pointing(uproot.concatenate( - {INPUT_PATH_FORMAT.format(particle="pi-", energy=energy, ix=ix): "events" for ix in INPUT_PATH_INDEX_RANGE}, + {path: "events" for path in readlist(INPUT_PATH_FORMAT.format(particle="pi-", energy=energy))}, filter_name=filter_name, )) e_eval[energy] = filter_pointing(uproot.concatenate( - {INPUT_PATH_FORMAT.format(particle="e-", energy=energy, ix=ix): "events" for ix in INPUT_PATH_INDEX_RANGE}, + {path: "events" for path in readlist(INPUT_PATH_FORMAT.format(particle="e-", energy=energy))}, filter_name=filter_name, )) #+end_src diff --git a/benchmarks/backwards_ecal/config.yml b/benchmarks/backwards_ecal/config.yml index 7048f8e7..202ed06d 100644 --- a/benchmarks/backwards_ecal/config.yml +++ b/benchmarks/backwards_ecal/config.yml @@ -16,7 +16,7 @@ sim:backwards_ecal: ] script: - | - snakemake $SNAKEMAKE_FLAGS --cores 5 sim_output/backwards_ecal/${DETECTOR_CONFIG}/${PARTICLE}/${MOMENTUM}/130to177deg/flag + snakemake $SNAKEMAKE_FLAGS --cores 5 lists/backwards_ecal/local/${DETECTOR_CONFIG}/${PARTICLE}/${MOMENTUM}/130to177deg.lst bench:backwards_ecal: extends: .det_benchmark