From e48cb96bef7c771621acc7396792d71a49be9485 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 1 Dec 2024 16:28:54 -0500 Subject: [PATCH 1/5] insert_muon: use spaces --- benchmarks/insert_muon/Snakefile | 72 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/benchmarks/insert_muon/Snakefile b/benchmarks/insert_muon/Snakefile index a9a32168..ca647c59 100644 --- a/benchmarks/insert_muon/Snakefile +++ b/benchmarks/insert_muon/Snakefile @@ -1,27 +1,27 @@ rule insert_muon_generate: - input: - script="benchmarks/insert_muon/analysis/gen_particles.cxx", - params: - NEVENTS_GEN=5000, - th_max=7.0, - th_min=1.7 - output: - GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc" - shell: - """ + input: + script="benchmarks/insert_muon/analysis/gen_particles.cxx", + params: + NEVENTS_GEN=5000, + th_max=7.0, + th_min=1.7 + output: + GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc" + shell: + """ root -l -b -q '{input.script}({params.NEVENTS_GEN},"{output.GEN_FILE}", "mu-", {params.th_min}, {params.th_max}, 0., 360., {wildcards.P})' """ rule insert_muon_simulate: - input: - GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc", - warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", - params: - PHYSICS_LIST="FTFP_BERT" - output: - SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root" - shell: - """ + input: + GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc", + warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + params: + PHYSICS_LIST="FTFP_BERT" + output: + SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root" + shell: + """ NEVENTS_SIM=1000 # Running simulation npsim \ @@ -34,28 +34,28 @@ npsim \ """ rule insert_muon_recon: - input: - SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root" - output: - REC_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_rec_mu-_{P}GeV_{INDEX}.edm4hep.root" - shell: - """ + input: + SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root" + output: + REC_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_rec_mu-_{P}GeV_{INDEX}.edm4hep.root" + shell: + """ NEVENTS_REC=1000 eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters -Pjana:nevents=$NEVENTS_REC """ rule insert_muon_analysis: - input: - expand("sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root", - P=[50], - DETECTOR_CONFIG=["{DETECTOR_CONFIG}"], - INDEX=range(5), - ), - script="benchmarks/insert_muon/analysis/muon_plots.py", - output: - results_dir=directory("results/{DETECTOR_CONFIG}/insert_muon"), - shell: - """ + input: + expand("sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root", + P=[50], + DETECTOR_CONFIG=["{DETECTOR_CONFIG}"], + INDEX=range(5), + ), + script="benchmarks/insert_muon/analysis/muon_plots.py", + output: + results_dir=directory("results/{DETECTOR_CONFIG}/insert_muon"), + shell: + """ mkdir -p {output.results_dir} python {input.script} {output.results_dir} """ From e36d19df69e88457a388385b76a8e0b4382b9cda Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 1 Dec 2024 16:29:58 -0500 Subject: [PATCH 2/5] insert_neutron: use spaces --- benchmarks/insert_neutron/Snakefile | 72 ++++++++++++++--------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/benchmarks/insert_neutron/Snakefile b/benchmarks/insert_neutron/Snakefile index 136c56e2..48bf47ed 100644 --- a/benchmarks/insert_neutron/Snakefile +++ b/benchmarks/insert_neutron/Snakefile @@ -1,28 +1,28 @@ rule insert_neutron_generate: - input: - script="benchmarks/insert_neutron/analysis/gen_particles.cxx", - params: - NEVENTS_GEN=1000, - th_max=5.7, - th_min=2.0 - output: - GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc" - shell: - """ + input: + script="benchmarks/insert_neutron/analysis/gen_particles.cxx", + params: + NEVENTS_GEN=1000, + th_max=5.7, + th_min=2.0 + output: + GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc" + shell: + """ mkdir -p sim_output/insert_neutron root -l -b -q '{input.script}({params.NEVENTS_GEN},"{output.GEN_FILE}", "neutron", {params.th_min}, {params.th_max}, 0., 360., {wildcards.P})' """ rule insert_neutron_simulate: - input: - GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc", - warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", - params: - PHYSICS_LIST="FTFP_BERT" - output: - SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root" - shell: - """ + input: + GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc", + warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + params: + PHYSICS_LIST="FTFP_BERT" + output: + SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root" + shell: + """ NEVENTS_SIM=200 # Running simulation npsim \ @@ -35,28 +35,28 @@ npsim \ """ rule insert_neutron_recon: - input: - SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root" - output: - REC_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_rec_neutron_{P}GeV_{INDEX}.edm4eic.root" - shell: - """ + input: + SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root" + output: + REC_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_rec_neutron_{P}GeV_{INDEX}.edm4eic.root" + shell: + """ NEVENTS_REC=200 eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters -Pjana:nevents=$NEVENTS_REC """ rule insert_neutron_analysis: - input: - expand("sim_output/insert_neutron/{DETECTOR_CONFIG}_rec_neutron_{P}GeV_{INDEX}.edm4eic.root", - P=[20, 30, 40, 50, 60, 70, 80], - DETECTOR_CONFIG=["{DETECTOR_CONFIG}"], - INDEX=range(5), - ), - script="benchmarks/insert_neutron/analysis/neutron_plots.py", - output: - results_dir=directory("results/{DETECTOR_CONFIG}/insert_neutron"), - shell: - """ + input: + expand("sim_output/insert_neutron/{DETECTOR_CONFIG}_rec_neutron_{P}GeV_{INDEX}.edm4eic.root", + P=[20, 30, 40, 50, 60, 70, 80], + DETECTOR_CONFIG=["{DETECTOR_CONFIG}"], + INDEX=range(5), + ), + script="benchmarks/insert_neutron/analysis/neutron_plots.py", + output: + results_dir=directory("results/{DETECTOR_CONFIG}/insert_neutron"), + shell: + """ mkdir -p {output.results_dir} python {input.script} {output.results_dir} """ From ec52693f787273e19bc875ffc2a85fbdfb49397a Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 1 Dec 2024 16:50:52 -0500 Subject: [PATCH 3/5] femc_*,insert_*: enable caching --- benchmarks/femc_electron/Snakefile | 33 +++++++++++++++++++---------- benchmarks/femc_photon/Snakefile | 29 +++++++++++++++++-------- benchmarks/femc_pi0/Snakefile | 25 ++++++++++++++++------ benchmarks/insert_muon/Snakefile | 31 ++++++++++++++++++--------- benchmarks/insert_neutron/Snakefile | 31 ++++++++++++++++++--------- benchmarks/insert_tau/Snakefile | 26 ++++++++++++++++------- 6 files changed, 120 insertions(+), 55 deletions(-) diff --git a/benchmarks/femc_electron/Snakefile b/benchmarks/femc_electron/Snakefile index 13e8b737..90a0c40f 100644 --- a/benchmarks/femc_electron/Snakefile +++ b/benchmarks/femc_electron/Snakefile @@ -8,12 +8,12 @@ def get_n_events(wildcards): rule femc_electron_generate: input: script="benchmarks/femc_electron/analysis/gen_particles.cxx", + output: + GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc", params: N_EVENTS=get_n_events, th_max=28, - th_min=2.0 - output: - GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc" + th_min=2.0, shell: """ mkdir -p sim_output/femc_electron @@ -22,17 +22,24 @@ root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "e-", {para rule femc_electron_simulate: input: - GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc" + GEN_FILE="sim_output/femc_electron/e-_{P}GeV.hepmc", + warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + geometry_lib=find_epic_libraries(), + output: + SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root", params: N_EVENTS=get_n_events, - PHYSICS_LIST="FTFP_BERT" - output: - SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root" + PHYSICS_LIST="FTFP_BERT", + DETECTOR_PATH=os.environ["DETECTOR_PATH"], + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + DD4HEP_HASH=get_spack_package_hash("dd4hep"), + NPSIM_HASH=get_spack_package_hash("npsim"), + cache: True shell: """ # Running simulation npsim \ - --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \ --numberOfEvents {params.N_EVENTS} \ --physicsList {params.PHYSICS_LIST} \ --inputFiles {input.GEN_FILE} \ @@ -41,14 +48,18 @@ npsim \ rule femc_electron_recon: input: - SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root" + SIM_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_sim_e-_{P}GeV.edm4hep.root", output: - REC_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root" + REC_FILE="sim_output/femc_electron/{DETECTOR_CONFIG}_rec_e-_{P}GeV.edm4eic.root", params: N_EVENTS=get_n_events, + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + EICRECON_HASH=get_spack_package_hash("eicrecon"), + cache: True shell: """ -eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS} +env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ + eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS} """ rule femc_electron_analysis: diff --git a/benchmarks/femc_photon/Snakefile b/benchmarks/femc_photon/Snakefile index d92a3cd1..d85b8132 100644 --- a/benchmarks/femc_photon/Snakefile +++ b/benchmarks/femc_photon/Snakefile @@ -8,12 +8,12 @@ def get_n_events(wildcards): rule femc_photon_generate: input: script="benchmarks/femc_photon/analysis/gen_particles.cxx", + output: + GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc", params: N_EVENTS=get_n_events, th_max=28, - th_min=2.0 - output: - GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc" + th_min=2.0, shell: """ mkdir -p sim_output/femc_photon @@ -22,17 +22,24 @@ root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "gamma", {p rule femc_photon_simulate: input: - GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc" + GEN_FILE="sim_output/femc_photon/photon_{P}GeV.hepmc", + warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + geometry_lib=find_epic_libraries(), + output: + SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.root", params: N_EVENTS=get_n_events, - PHYSICS_LIST="FTFP_BERT" - output: - SIM_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_sim_photon_{P}GeV.edm4hep.root" + PHYSICS_LIST="FTFP_BERT", + DETECTOR_PATH=os.environ["DETECTOR_PATH"], + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + DD4HEP_HASH=get_spack_package_hash("dd4hep"), + NPSIM_HASH=get_spack_package_hash("npsim"), + cache: True shell: """ # Running simulation npsim \ - --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \ --numberOfEvents {params.N_EVENTS} \ --physicsList {params.PHYSICS_LIST} \ --inputFiles {input.GEN_FILE} \ @@ -46,9 +53,13 @@ rule femc_photon_recon: REC_FILE="sim_output/femc_photon/{DETECTOR_CONFIG}_rec_photon_{P}GeV.edm4eic.root" params: N_EVENTS=get_n_events, + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + EICRECON_HASH=get_spack_package_hash("eicrecon"), + cache: True shell: """ -eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS} +env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ + eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS} """ rule femc_photon_analysis: diff --git a/benchmarks/femc_pi0/Snakefile b/benchmarks/femc_pi0/Snakefile index 9b8713ab..05902510 100644 --- a/benchmarks/femc_pi0/Snakefile +++ b/benchmarks/femc_pi0/Snakefile @@ -8,12 +8,12 @@ def get_n_events(wildcards): rule femc_pi0_generate: input: script="benchmarks/femc_pi0/analysis/gen_particles.cxx", + output: + GEN_FILE="sim_output/femc_pi0/pi0_{P}GeV.hepmc", params: N_EVENTS=get_n_events, th_max=28, - th_min=2.0 - output: - GEN_FILE="sim_output/femc_pi0/pi0_{P}GeV.hepmc" + th_min=2.0, shell: """ mkdir -p sim_output/femc_pi0 @@ -22,17 +22,24 @@ root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "pi0", {par rule femc_pi0_simulate: input: - GEN_FILE="sim_output/femc_pi0/pi0_{P}GeV.hepmc" + GEN_FILE="sim_output/femc_pi0/pi0_{P}GeV.hepmc", + warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + geometry_lib=find_epic_libraries(), params: N_EVENTS=get_n_events, - PHYSICS_LIST="FTFP_BERT" + PHYSICS_LIST="FTFP_BERT", + DETECTOR_PATH=os.environ["DETECTOR_PATH"], + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + DD4HEP_HASH=get_spack_package_hash("dd4hep"), + NPSIM_HASH=get_spack_package_hash("npsim"), + cache: True output: SIM_FILE="sim_output/femc_pi0/{DETECTOR_CONFIG}_sim_pi0_{P}GeV.edm4hep.root" shell: """ # Running simulation npsim \ - --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \ --numberOfEvents {params.N_EVENTS} \ --physicsList {params.PHYSICS_LIST} \ --inputFiles {input.GEN_FILE} \ @@ -46,9 +53,13 @@ rule femc_pi0_recon: REC_FILE="sim_output/femc_pi0/{DETECTOR_CONFIG}_rec_pi0_{P}GeV.edm4eic.root" params: N_EVENTS=get_n_events, + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + EICRECON_HASH=get_spack_package_hash("eicrecon"), + cache: True shell: """ -eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS} +env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ + eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPInsertRecHits,EcalEndcapPClusters -Pjana:nevents={params.N_EVENTS} """ rule femc_pi0_analysis: diff --git a/benchmarks/insert_muon/Snakefile b/benchmarks/insert_muon/Snakefile index ca647c59..fe9ce0ae 100644 --- a/benchmarks/insert_muon/Snakefile +++ b/benchmarks/insert_muon/Snakefile @@ -1,12 +1,12 @@ rule insert_muon_generate: input: script="benchmarks/insert_muon/analysis/gen_particles.cxx", + output: + GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc", params: NEVENTS_GEN=5000, th_max=7.0, - th_min=1.7 - output: - GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc" + th_min=1.7, shell: """ root -l -b -q '{input.script}({params.NEVENTS_GEN},"{output.GEN_FILE}", "mu-", {params.th_min}, {params.th_max}, 0., 360., {wildcards.P})' @@ -16,16 +16,22 @@ rule insert_muon_simulate: input: GEN_FILE="sim_output/insert_muon/mu-_{P}GeV.hepmc", warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", - params: - PHYSICS_LIST="FTFP_BERT" + geometry_lib=find_epic_libraries(), output: - SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root" + SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root", + params: + PHYSICS_LIST="FTFP_BERT", + DETECTOR_PATH=os.environ["DETECTOR_PATH"], + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + DD4HEP_HASH=get_spack_package_hash("dd4hep"), + NPSIM_HASH=get_spack_package_hash("npsim"), + cache: True shell: """ NEVENTS_SIM=1000 # Running simulation npsim \ - --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \ --skipNEvents $(( $NEVENTS_SIM * {wildcards.INDEX} )) \ --numberOfEvents $NEVENTS_SIM \ --physicsList {params.PHYSICS_LIST} \ @@ -35,13 +41,18 @@ npsim \ rule insert_muon_recon: input: - SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root" + SIM_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_sim_mu-_{P}GeV_{INDEX}.edm4hep.root", output: - REC_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_rec_mu-_{P}GeV_{INDEX}.edm4hep.root" + REC_FILE="sim_output/insert_muon/{DETECTOR_CONFIG}_rec_mu-_{P}GeV_{INDEX}.edm4hep.root", + params: + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + EICRECON_HASH=get_spack_package_hash("eicrecon"), + cache: True shell: """ NEVENTS_REC=1000 -eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters -Pjana:nevents=$NEVENTS_REC +env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ + eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters -Pjana:nevents=$NEVENTS_REC """ rule insert_muon_analysis: diff --git a/benchmarks/insert_neutron/Snakefile b/benchmarks/insert_neutron/Snakefile index 48bf47ed..98cc5a28 100644 --- a/benchmarks/insert_neutron/Snakefile +++ b/benchmarks/insert_neutron/Snakefile @@ -1,12 +1,12 @@ rule insert_neutron_generate: input: script="benchmarks/insert_neutron/analysis/gen_particles.cxx", + output: + GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc", params: NEVENTS_GEN=1000, th_max=5.7, - th_min=2.0 - output: - GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc" + th_min=2.0, shell: """ mkdir -p sim_output/insert_neutron @@ -17,16 +17,22 @@ rule insert_neutron_simulate: input: GEN_FILE="sim_output/insert_neutron/neutron_{P}GeV.hepmc", warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", - params: - PHYSICS_LIST="FTFP_BERT" + geometry_lib=find_epic_libraries(), output: - SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root" + SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root", + params: + PHYSICS_LIST="FTFP_BERT", + DETECTOR_PATH=os.environ["DETECTOR_PATH"], + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + DD4HEP_HASH=get_spack_package_hash("dd4hep"), + NPSIM_HASH=get_spack_package_hash("npsim"), + cache: True shell: """ NEVENTS_SIM=200 # Running simulation npsim \ - --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \ --skipNEvents $(( $NEVENTS_SIM * {wildcards.INDEX} )) \ --numberOfEvents $NEVENTS_SIM \ --physicsList {params.PHYSICS_LIST} \ @@ -36,13 +42,18 @@ npsim \ rule insert_neutron_recon: input: - SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root" + SIM_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_sim_neutron_{P}GeV_{INDEX}.edm4hep.root", output: - REC_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_rec_neutron_{P}GeV_{INDEX}.edm4eic.root" + REC_FILE="sim_output/insert_neutron/{DETECTOR_CONFIG}_rec_neutron_{P}GeV_{INDEX}.edm4eic.root", + params: + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + EICRECON_HASH=get_spack_package_hash("eicrecon"), + cache: True shell: """ NEVENTS_REC=200 -eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters -Pjana:nevents=$NEVENTS_REC +env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ + eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters -Pjana:nevents=$NEVENTS_REC """ rule insert_neutron_analysis: diff --git a/benchmarks/insert_tau/Snakefile b/benchmarks/insert_tau/Snakefile index 57e4390e..ffc9c491 100644 --- a/benchmarks/insert_tau/Snakefile +++ b/benchmarks/insert_tau/Snakefile @@ -7,12 +7,12 @@ def get_n_events(wildcards): rule insert_tau_generate: input: script="benchmarks/insert_tau/analysis/gen_particles.cxx", + output: + GEN_FILE="sim_output/insert_tau/tau-_{P}GeV.hepmc", params: N_EVENTS=get_n_events, th_max=7.0, th_min=1.7, - output: - GEN_FILE="sim_output/insert_tau/tau-_{P}GeV.hepmc", shell: """ root -l -b -q '{input.script}({params.N_EVENTS},"{output.GEN_FILE}", "tau-", {params.th_min}, {params.th_max}, 0., 360., {wildcards.P})' @@ -22,16 +22,22 @@ rule insert_tau_simulate: input: GEN_FILE="sim_output/insert_tau/tau-_{P}GeV.hepmc", warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + geometry_lib=find_epic_libraries(), + output: + SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.root", params: N_EVENTS=get_n_events, PHYSICS_LIST="FTFP_BERT", - output: - SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.root" + DETECTOR_PATH=os.environ["DETECTOR_PATH"], + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + DD4HEP_HASH=get_spack_package_hash("dd4hep"), + NPSIM_HASH=get_spack_package_hash("npsim"), + cache: True shell: """ # Running simulation npsim \ - --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --compactFile {params.DETECTOR_PATH}/{params.DETECTOR_CONFIG}.xml \ --numberOfEvents {params.N_EVENTS} \ --skipNEvents $(( {params.N_EVENTS} * {wildcards.INDEX} )) \ --physicsList {params.PHYSICS_LIST} \ @@ -42,13 +48,17 @@ npsim \ rule insert_tau_recon: input: SIM_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_sim_tau-_{P}GeV_{INDEX}.edm4hep.root", - params: - N_EVENTS=get_n_events, output: REC_FILE="sim_output/insert_tau/{DETECTOR_CONFIG}_rec_tau-_{P}GeV_{INDEX}.edm4eic.root", + params: + N_EVENTS=get_n_events, + DETECTOR_CONFIG=lambda wildcards: wildcards.DETECTOR_CONFIG, + EICRECON_HASH=get_spack_package_hash("eicrecon"), + cache: True shell: """ -eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_files=$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPClusters,LFHCALClusters -Pjana:nevents={params.N_EVENTS} +env DETECTOR_CONFIG={params.DETECTOR_CONFIG} \ + eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Ppodio:output_collections=MCParticles,HcalEndcapPInsertRecHits,HcalEndcapPInsertClusters,HcalEndcapPInsertSubcellHits,EcalEndcapPInsertRecHits,EcalEndcapPInsertClusters,EcalEndcapPClusters,LFHCALClusters -Pjana:nevents={params.N_EVENTS} """ rule insert_tau_analysis: From 61af10254ca5061ea23a3da2a2c8f6d9e6ddf229 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 1 Dec 2024 16:54:03 -0500 Subject: [PATCH 4/5] calo_pid/config.yml: use --- benchmarks/calo_pid/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/calo_pid/config.yml b/benchmarks/calo_pid/config.yml index 8a65daa6..ca24a765 100644 --- a/benchmarks/calo_pid/config.yml +++ b/benchmarks/calo_pid/config.yml @@ -18,7 +18,7 @@ sim:calo_pid: ] script: - | - snakemake --cache --cores 5 \ + snakemake $SNAKEMAKE_FLAGS --cores 5 \ $(seq --format="sim_output/calo_pid/epic_inner_detector/${PARTICLE}/100MeVto20GeV/130to177deg/${PARTICLE}_100MeVto20GeV_130to177deg.%04.f.eicrecon.tree.edm4eic.root" ${INDEX_RANGE}) bench:calo_pid: @@ -30,7 +30,7 @@ bench:calo_pid: script: - export PYTHONUSERBASE=$LOCAL_DATA_PATH/deps - pip install -r benchmarks/calo_pid/requirements.txt - - snakemake --cache --cores 1 results/epic_inner_detector/calo_pid + - snakemake $SNAKEMAKE_FLAGS --cores 1 results/epic_inner_detector/calo_pid collect_results:calo_pid: allow_failure: true # until inference merged into EICrecon @@ -41,5 +41,5 @@ collect_results:calo_pid: script: - ls -lrht - mv results{,_save}/ # move results directory out of the way to preserve it - - snakemake --cores 1 --delete-all-output results/epic_inner_detector/calo_pid + - snakemake $SNAKEMAKE_FLAGS --cores 1 --delete-all-output results/epic_inner_detector/calo_pid - mv results{_save,}/ From 6b89fac30400af69fcbb991a6e166d9c72173d6f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 1 Dec 2024 16:54:22 -0500 Subject: [PATCH 5/5] ecal_gaps/config.yml: remove a redundant --cache --- benchmarks/ecal_gaps/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/ecal_gaps/config.yml b/benchmarks/ecal_gaps/config.yml index fdf31892..07144845 100644 --- a/benchmarks/ecal_gaps/config.yml +++ b/benchmarks/ecal_gaps/config.yml @@ -4,7 +4,7 @@ sim:ecal_gaps: script: - mkdir -p $LOCAL_DATA_PATH/input - ln -s $LOCAL_DATA_PATH/input input - - snakemake $SNAKEMAKE_FLAGS --cache --cores 10 results/epic_inner_detector/ecal_gaps --omit-from ecal_gaps + - snakemake $SNAKEMAKE_FLAGS --cores 10 results/epic_inner_detector/ecal_gaps --omit-from ecal_gaps bench:ecal_gaps: extends: .det_benchmark