Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backwards_ecal: changes for the PDR #110

Merged
merged 11 commits into from
Dec 19, 2024
71 changes: 65 additions & 6 deletions benchmarks/backwards_ecal/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,77 @@ 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))


if config.get("stream_from_xrootd", True) not in [False, "", "0", "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(
"sim_output/backwards_ecal/" + DETECTOR_CONFIG + "/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/flag",
"listing/backwards_ecal/{{CAMPAIGN}}/" + DETECTOR_CONFIG + "/{PARTICLE}/{ENERGY}/{PHASE_SPACE}.lst",
PARTICLE=["pi-", "e-"],
ENERGY=[
"100MeV",
Expand All @@ -96,14 +151,18 @@ rule backwards_ecal:
matplotlibrc=".matplotlibrc",
script="benchmarks/backwards_ecal/backwards_ecal.py",
output:
directory("results/backwards_ecal")
directory("results/backwards_ecal/{CAMPAIGN}/")
shell:
"""
if [[ "{wildcards.CAMPAIGN}" == "local" ]]; then
export PLOT_TITLE="Benchmark simulation"
else
export PLOT_TITLE="\\textbf{{ePIC}} Simulation {wildcards.CAMPAIGN}"
fi
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/{wildcards.CAMPAIGN}/""" + DETECTOR_CONFIG + """/{{particle}}/{{energy}}/130to177deg.lst \
OUTPUT_DIR={output} \
python {input.script}
"""
Loading
Loading