From e245ba641bd21a488e80ce6cb6b699408b170564 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Tue, 13 Aug 2024 19:43:53 -0400
Subject: [PATCH] lambda/Snakefile: adjust output paths, don't upload edm4hep
 files to artifacts

---
 benchmarks/lambda/Snakefile                | 14 +++++++-------
 benchmarks/lambda/analysis/lambda_plots.py |  2 +-
 benchmarks/lambda/config.yml               | 14 ++++++++++----
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/benchmarks/lambda/Snakefile b/benchmarks/lambda/Snakefile
index e565e8ea..c909f433 100644
--- a/benchmarks/lambda/Snakefile
+++ b/benchmarks/lambda/Snakefile
@@ -4,7 +4,7 @@ rule lambda_generate:
 	params:
 		NEVENTS_GEN=100000,
 	output:
-		GEN_FILE="results/lambda/lambda_decay_{P}GeV.hepmc"
+		GEN_FILE="sim_output/lambda/lambda_decay_{P}GeV.hepmc"
 	shell:
 		"""
 mkdir -p results/lambda
@@ -13,11 +13,11 @@ root -l -b -q '{input.script}({params.NEVENTS_GEN},0,"{output.GEN_FILE}",{wildca
 
 rule lambda_simulate:
 	input:
-		GEN_FILE="results/lambda/lambda_decay_{P}GeV.hepmc"
+		GEN_FILE="sim_output/lambda/lambda_decay_{P}GeV.hepmc"
 	params:
 		PHYSICS_LIST="FTFP_BERT"
 	output:
-		SIM_FILE="results/lambda/{DETECTOR_CONFIG}_sim_lambda_dec_{P}GeV.edm4hep.root"
+		SIM_FILE="sim_output/lambda/{DETECTOR_CONFIG}_sim_lambda_dec_{P}GeV.edm4hep.root"
 	shell:
 		"""
 if [[ {wildcards.P} -gt 225 ]]; then
@@ -36,9 +36,9 @@ npsim \
 
 rule lambda_recon:
         input:
-                SIM_FILE="results/lambda/{DETECTOR_CONFIG}_sim_lambda_dec_{P}GeV.edm4hep.root"
+                SIM_FILE="sim_output/lambda/{DETECTOR_CONFIG}_sim_lambda_dec_{P}GeV.edm4hep.root"
         output:
-                REC_FILE="results/lambda/{DETECTOR_CONFIG}_rec_lambda_dec_{P}GeV.edm4hep.root"
+                REC_FILE="sim_output/lambda/{DETECTOR_CONFIG}_rec_lambda_dec_{P}GeV.edm4hep.root"
         shell:
                 """
 if [[ {wildcards.P} -gt 225 ]]; then
@@ -51,12 +51,12 @@ eicrecon {input.SIM_FILE} -Ppodio:output_file={output.REC_FILE} -Pdd4hep:xml_fil
 
 rule lambda_analysis:
 	input:
-                expand("results/lambda/{DETECTOR_CONFIG}_rec_lambda_dec_{P}GeV.edm4hep.root",
+                expand("sim_output/lambda/{DETECTOR_CONFIG}_rec_lambda_dec_{P}GeV.edm4hep.root",
 		    P=[100, 125, 150,175, 200, 225, 250, 275],
 		    DETECTOR_CONFIG=["{DETECTOR_CONFIG}"]),
                 script="benchmarks/lambda/analysis/lambda_plots.py",
 	output:
-		results_dir=directory("results/lambda/results_{DETECTOR_CONFIG}_lambda_dec"),
+		results_dir=directory("results/{DETECTOR_CONFIG}/lambda"),
 	shell:
 		"""
 mkdir -p {output.results_dir}
diff --git a/benchmarks/lambda/analysis/lambda_plots.py b/benchmarks/lambda/analysis/lambda_plots.py
index 10260be6..0a6079a2 100644
--- a/benchmarks/lambda/analysis/lambda_plots.py
+++ b/benchmarks/lambda/analysis/lambda_plots.py
@@ -18,7 +18,7 @@ import uproot as ur
 arrays_sim={}
 momenta=100, 125, 150, 175,200,225,250,275
 for p in momenta:
-    filename=f'results/lambda/epic_zdc_sipm_on_tile_only_rec_lambda_dec_{p}GeV.edm4hep.root'
+    filename=f'sim_output/lambda/epic_zdc_sipm_on_tile_only_rec_lambda_dec_{p}GeV.edm4hep.root'
     print("opening file", filename)
     events = ur.open(filename+':events')
     arrays_sim[p] = events.arrays()[:-1] #remove last event, which for some reason is blank
diff --git a/benchmarks/lambda/config.yml b/benchmarks/lambda/config.yml
index 1813e8d1..877d7016 100644
--- a/benchmarks/lambda/config.yml
+++ b/benchmarks/lambda/config.yml
@@ -1,4 +1,3 @@
-
 lambda:simulate:
   stage: simulate
   extends: .phy_benchmark
@@ -15,14 +14,21 @@ lambda:simulate:
       - P: 275
   timeout: 6 hours
   script:
-    - snakemake --cores 1 results/lambda/epic_zdc_sipm_on_tile_only_rec_lambda_dec_${P}GeV.edm4hep.root 
+    - snakemake --cores 1 sim_output/lambda/epic_zdc_sipm_on_tile_only_rec_lambda_dec_${P}GeV.edm4hep.root 
   retry:
     max: 2
     when:
       - runner_system_failure
 
+lambda:analyze:
+  stage: analyze
+  extends: .phy_benchmark
+  needs: ["lambda:simulate"]
+  script:
+    - snakemake --cores 1 results/epic_zdc_sipm_on_tile_only/lambda 
+
 lambda:results:
   stage: collect
-  needs: ["lambda:simulate"]
+  needs: ["lambda:analyze"]
   script:
-    - python benchmarks/lambda/analysis/lambda_plots.py results/lambda/results_epic_zdc_sipm_on_tile_only_lambda_dec
+    - ls -al
-- 
GitLab