Skip to content

Commit

Permalink
backwards_ecal: produce file lists
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl committed Dec 5, 2024
1 parent 73128ee commit f569ccb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 7 additions & 4 deletions benchmarks/backwards_ecal/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,25 @@ 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"]

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",
Expand All @@ -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}
"""
10 changes: 7 additions & 3 deletions benchmarks/backwards_ecal/backwards_ecal.org
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/backwards_ecal/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f569ccb

Please sign in to comment.