From ad054ed3b40c52b51d6ed069deca7b9eed72fb71 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Tue, 27 Feb 2024 14:56:43 -0500 Subject: [PATCH] centralize org2py.awk --- .gitignore | 4 ++++ Snakefile | 12 ++++++++++ benchmarks/backgrounds/Snakefile | 13 +---------- benchmarks/{backgrounds => common}/org2py.awk | 0 benchmarks/ecal_gaps/Snakefile | 13 +---------- benchmarks/ecal_gaps/org2py.awk | 22 ------------------- 6 files changed, 18 insertions(+), 46 deletions(-) rename benchmarks/{backgrounds => common}/org2py.awk (100%) delete mode 100644 benchmarks/ecal_gaps/org2py.awk diff --git a/.gitignore b/.gitignore index fc58c11b..bf34adef 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,7 @@ __pycache__/ calorimeters/test/ *.d *.pcm + +# org2py output +benchmarks/backgrounds/ecal_backwards.py +benchmarks/ecal_gaps/ecal_gaps.py diff --git a/Snakefile b/Snakefile index dcec820c..d72b6952 100644 --- a/Snakefile +++ b/Snakefile @@ -29,3 +29,15 @@ rule matplotlibrc: 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} +""" diff --git a/benchmarks/backgrounds/Snakefile b/benchmarks/backgrounds/Snakefile index 1060d6ba..f8991097 100644 --- a/benchmarks/backgrounds/Snakefile +++ b/benchmarks/backgrounds/Snakefile @@ -55,23 +55,12 @@ ddsim \ """ -rule backgrounds_org2py: - input: - notebook=workflow.source_path("ecal_backwards.org"), - converter=workflow.source_path("./org2py.awk"), - output: - "ecal_backwards.py" - shell: - """ -awk -f {input.converter} {input.notebook} > {output} -""" - DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"] rule backgrounds_ecal_backwards: input: matplotlibrc=".matplotlibrc", - script="ecal_backwards.py", + script="benchmarks/backgrounds/ecal_backwards.py", electron_beam_gas_gen="input/backgrounds/beam_gas_electron.hepmc", electron_beam_gas_sim="sim_output/" + DETECTOR_CONFIG + "/backgrounds/beam_gas_electron.edm4hep.root", physics_signal_sim="sim_output/" + DETECTOR_CONFIG + "/backgrounds/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_1.edm4hep.root", diff --git a/benchmarks/backgrounds/org2py.awk b/benchmarks/common/org2py.awk similarity index 100% rename from benchmarks/backgrounds/org2py.awk rename to benchmarks/common/org2py.awk diff --git a/benchmarks/ecal_gaps/Snakefile b/benchmarks/ecal_gaps/Snakefile index 0c9c43f3..2cf76ec8 100644 --- a/benchmarks/ecal_gaps/Snakefile +++ b/benchmarks/ecal_gaps/Snakefile @@ -45,23 +45,12 @@ eicrecon {input} -Ppodio:output_file={output} \ """ -rule ecal_gaps_org2py: - input: - notebook=workflow.source_path("ecal_gaps.org"), - converter=workflow.source_path("./org2py.awk"), - output: - "ecal_gaps.py" - shell: - """ -awk -f {input.converter} {input.notebook} > {output} -""" - DETECTOR_CONFIG=os.environ["DETECTOR_CONFIG"] rule ecal_gaps: input: matplotlibrc=".matplotlibrc", - script="ecal_gaps.py", + script="benchmarks/ecal_gaps/ecal_gaps.py", # TODO pass as a file list? _=expand( "sim_output/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root", diff --git a/benchmarks/ecal_gaps/org2py.awk b/benchmarks/ecal_gaps/org2py.awk deleted file mode 100644 index 0d23cf25..00000000 --- a/benchmarks/ecal_gaps/org2py.awk +++ /dev/null @@ -1,22 +0,0 @@ -BEGIN { - in_src = 0 - IGNORECASE=1 -} - -/^#\+begin_src\s+[^\s]*python/ { - in_src = 1 - match($0, /^ */) - spaces = RLENGTH - next -} - -/^#\+end_src/ { - in_src = 0 - next -} - -in_src { - re = "^ {" spaces "}" - gsub(re,"") - print -}