From ef5512da4d88ed7aa0a0c1c4883afd565308a990 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com> Date: Sat, 7 Dec 2024 00:54:07 -0500 Subject: [PATCH] backwards_ecal: add support for campaign processing --- benchmarks/backwards_ecal/Snakefile | 58 ++++++++++++++++++++++++++-- benchmarks/backwards_ecal/config.yml | 4 +- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/benchmarks/backwards_ecal/Snakefile b/benchmarks/backwards_ecal/Snakefile index 5ac3effe..c19db356 100644 --- a/benchmarks/backwards_ecal/Snakefile +++ b/benchmarks/backwards_ecal/Snakefile @@ -77,12 +77,64 @@ rule backwards_ecal_local_sim_list: fp.write("\n".join(input)) +if False: + rule backwards_ecal_campaign_sim_list: + output: + "listing/backwards_ecal/{CAMPAIGN}/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst", + params: + search_path=lambda wildcards: f"EPIC/RECO/{wildcards.CAMPAIGN}/epic_craterlake/SINGLE/{wildcards.PARTICLE}/{wildcards.ENERGY}/{wildcards.PHASE_SPACE}/", + shell: """ + xrdfs root://dtn-eic.jlab.org/ ls /work/eic2/{params.search_path} \ + | awk '{{ print "root://dtn-eic.jlab.org/"$1; }}' \ + | sort \ + > {output} + if [ ! -s {output} ]; then + echo "Got an empty file listing for path \"\"" + exit 1 + fi + """ +else: + checkpoint backwards_ecal_campaign_sim_list_checkpoint: + output: + "listing/backwards_ecal/{CAMPAIGN}/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst.orig", + params: + search_path=lambda wildcards: f"EPIC/RECO/{wildcards.CAMPAIGN}/epic_craterlake/SINGLE/{wildcards.PARTICLE}/{wildcards.ENERGY}/{wildcards.PHASE_SPACE}/", + shell: """ + xrdfs root://dtn-eic.jlab.org/ ls /work/eic2/{params.search_path} \ + | sed -e 's#^/work/eic2/##' \ + | sort \ + > {output} + if [ ! -s {output} ]; then + echo "Got an empty file listing for path \"\"" + exit 1 + fi + """ + + def get_backwards_ecal_campaign_sim_list(wildcards): + with checkpoints.backwards_ecal_campaign_sim_list_checkpoint.get(**wildcards).output[0].open() as fp: + return [line.rstrip() for line in fp.readlines()] + + rule backwards_ecal_campaign_sim_list: + input: + # depend on paths from the file list + get_backwards_ecal_campaign_sim_list, + orig_list="listing/backwards_ecal/{CAMPAIGN}/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst.orig", + output: + "listing/backwards_ecal/{CAMPAIGN}/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst", + shell: """ + cp {input.orig_list} {output} + """ + + +ruleorder: backwards_ecal_local_sim_list > backwards_ecal_campaign_sim_list + + DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"] rule backwards_ecal: input: expand( - "listing/backwards_ecal/local/" + DETECTOR_CONFIG + "/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst", + "listing/backwards_ecal/{{CAMPAIGN}}/" + DETECTOR_CONFIG + "/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst", PARTICLE=["pi-", "e-"], ENERGY=[ "100MeV", @@ -99,14 +151,14 @@ rule backwards_ecal: matplotlibrc=".matplotlibrc", script="benchmarks/backwards_ecal/backwards_ecal.py", output: - directory("results/backwards_ecal") + directory("results/backwards_ecal/{CAMPAIGN}/") shell: """ env \ MATPLOTLIBRC={input.matplotlibrc} \ DETECTOR_CONFIG=""" + DETECTOR_CONFIG + """ \ PLOT_TITLE=""" + DETECTOR_CONFIG + """ \ -INPUT_PATH_FORMAT=listing/backwards_ecal/local/""" + DETECTOR_CONFIG + """/{{particle}}/{{energy}}/130to177deg.lst \ +INPUT_PATH_FORMAT=listing/backwards_ecal/{wildcards.CAMPAIGN}/""" + DETECTOR_CONFIG + """/{{particle}}/{{energy}}/130to177deg.lst \ OUTPUT_DIR={output} \ python {input.script} """ diff --git a/benchmarks/backwards_ecal/config.yml b/benchmarks/backwards_ecal/config.yml index 8f2967f6..75d8f464 100644 --- a/benchmarks/backwards_ecal/config.yml +++ b/benchmarks/backwards_ecal/config.yml @@ -26,7 +26,7 @@ bench:backwards_ecal: script: - export PYTHONUSERBASE=$LOCAL_DATA_PATH/deps - pip install -r benchmarks/backwards_ecal/requirements.txt - - snakemake $SNAKEMAKE_FLAGS --cores 1 backwards_ecal + - snakemake $SNAKEMAKE_FLAGS --cores 1 results/backwards_ecal/local collect_results:backwards_ecal: extends: .det_benchmark @@ -36,5 +36,5 @@ collect_results:backwards_ecal: script: - ls -lrht - mv results{,_save}/ # move results directory out of the way to preserve it - - snakemake $SNAKEMAKE_FLAGS --cores 1 --delete-all-output backwards_ecal + - snakemake $SNAKEMAKE_FLAGS --cores 1 --delete-all-output results/backwards_ecal/local - mv results{_save,}/ -- GitLab