Skip to content

Commit

Permalink
Add Snakefile.8
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl committed Mar 27, 2024
1 parent 6d574fd commit f134e5d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 42 deletions.
40 changes: 2 additions & 38 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,6 @@ elif config["remote"] == "XRootD":
else:
raise ValueError(f"Unexpected config[\"remote\"] = {config['remote']}")

include: "benchmarks/backgrounds/Snakefile"
include: "benchmarks/barrel_ecal/Snakefile"
include: "benchmarks/ecal_gaps/Snakefile"
storage = provider.remote # provide Snakemake 8.x interface


rule warmup_run:
output:
"warmup/{DETECTOR_CONFIG}.edm4hep.root",
message: "Ensuring that calibrations/fieldmaps are available for {wildcards.DETECTOR_CONFIG}"
shell: """
ddsim \
--runType batch \
--numberOfEvents 1 \
--compactFile "$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml" \
--outputFile "{output}" \
--enableGun
"""


rule matplotlibrc:
output:
".matplotlibrc",
run:
with open(output[0], "wt") as fp:
fp.write("backend: Agg\n")
# interactive mode prevents plt.show() from blocking
fp.write("interactive : True\n")


rule org2py:
input:
notebook=workflow.basedir + "/{NOTEBOOK}.org",
converter=workflow.source_path("benchmarks/common/org2py.awk"),
output:
"{NOTEBOOK}.py"
shell:
"""
awk -f {input.converter} {input.notebook} > {output}
"""
include: "Snakefile.common"
15 changes: 15 additions & 0 deletions Snakefile.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
configfile: "config.yaml"
storage:
provider="s3",
endpoint_url="https://eics3.sdcc.bnl.gov:9000",
access_key=os.environ["S3_ACCESS_KEY"],
secret_key=os.environ["S3_SECRET_KEY"],

if config["remote"] == "S3":
remote_path = lambda path: f"s3://eictest/{path}"
elif config["remote"] == "XRootD":
remote_path = lambda path: f"root://dtn-eic.jlab.org//work/eic2/{path}"
else:
raise ValueError(f"Unexpected config[\"remote\"] = {config['remote']}")

include: "Snakefile.common"
39 changes: 39 additions & 0 deletions Snakefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
include: "benchmarks/backgrounds/Snakefile"
include: "benchmarks/barrel_ecal/Snakefile"
include: "benchmarks/ecal_gaps/Snakefile"


rule warmup_run:
output:
"warmup/{DETECTOR_CONFIG}.edm4hep.root",
message: "Ensuring that calibrations/fieldmaps are available for {wildcards.DETECTOR_CONFIG}"
shell: """
ddsim \
--runType batch \
--numberOfEvents 1 \
--compactFile "$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml" \
--outputFile "{output}" \
--enableGun
"""


rule matplotlibrc:
output:
".matplotlibrc",
run:
with open(output[0], "wt") as fp:
fp.write("backend: Agg\n")
# interactive mode prevents plt.show() from blocking
fp.write("interactive : True\n")


rule org2py:
input:
notebook=workflow.basedir + "/{NOTEBOOK}.org",
converter=workflow.source_path("benchmarks/common/org2py.awk"),
output:
"{NOTEBOOK}.py"
shell:
"""
awk -f {input.converter} {input.notebook} > {output}
"""
6 changes: 3 additions & 3 deletions benchmarks/backgrounds/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import shutil

rule backgrounds_get_beam_gas_electron:
input:
provider.remote(remote_path("EPIC/EVGEN/BACKGROUNDS/BEAMGAS/electron/beam_gas_ep_10GeV_foam_emin10keV_10Mevt_vtx.hepmc")),
storage(remote_path("EPIC/EVGEN/BACKGROUNDS/BEAMGAS/electron/beam_gas_ep_10GeV_foam_emin10keV_10Mevt_vtx.hepmc")),
output:
"input/backgrounds/beam_gas_electron.hepmc",
run:
Expand All @@ -13,7 +13,7 @@ rule backgrounds_get_beam_gas_electron:

rule backgrounds_get_beam_gas_proton:
input:
provider.remote(remote_path("EPIC/EVGEN/BACKGROUNDS/BEAMGAS/proton/ProtonBeamGasEvents/100GeV/100GeV_1.hepmc")),
storage(remote_path("EPIC/EVGEN/BACKGROUNDS/BEAMGAS/proton/ProtonBeamGasEvents/100GeV/100GeV_1.hepmc")),
output:
"input/backgrounds/beam_gas_proton.hepmc",
run:
Expand All @@ -22,7 +22,7 @@ rule backgrounds_get_beam_gas_proton:

rule backgrounds_get_DIS:
input:
provider.remote(remote_path("EPIC/EVGEN/DIS/NC/{BEAM}/minQ2={MINQ2}/pythia8NCDIS_{BEAM}_minQ2={MINQ2}_{SUFFIX}.hepmc")),
storage(remote_path("EPIC/EVGEN/DIS/NC/{BEAM}/minQ2={MINQ2}/pythia8NCDIS_{BEAM}_minQ2={MINQ2}_{SUFFIX}.hepmc")),
wildcard_constraints:
BEAM="\d+x\d+",
MINQ2="\d+",
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/ecal_gaps/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import os

rule ecal_gaps_sim:
input:
steering_file=provider.remote(remote_path("EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer")),
steering_file=storage(remote_path("EPIC/EVGEN/SINGLE/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.steer")),
warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root",
output:
"sim_output/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX}.edm4hep.root",
Expand Down

0 comments on commit f134e5d

Please sign in to comment.