diff --git a/benchmarks/barrel_hcal/config.yml b/benchmarks/barrel_hcal/config.yml index 1674c8e8d9e97a0045f183695ca8efe4e667cad2..fa40a22fa6ff854bed70730fca2ccdc60fb90b99 100644 --- a/benchmarks/barrel_hcal/config.yml +++ b/benchmarks/barrel_hcal/config.yml @@ -1,106 +1,53 @@ -sim:hcal_barrel_pions: +sim:hcal_barrel: extends: .det_benchmark stage: simulate + parallel: + matrix: + - PARTICLE: ["piplus", "piminus", "kplus", "kminus", "kshort", "klong", "muon", "antimuon", "proton"] script: - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh piplus - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh piminus + - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh ${PARTICLE} -sim:hcal_barrel_kaons: +sim:hcal_barrel:scan: extends: .det_benchmark stage: simulate + parallel: + matrix: + - PARTICLE: ["muon", "antimuon", "proton"] + E: ["0.25", "0.5", "1", "2", "3", "4", "7", "15", "20"] script: - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh kplus - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh kminus - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh kshort - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh klong + - bash benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh ${PARTICLE} ${E} -sim:hcal_barrel_muons: - extends: .det_benchmark - stage: simulate - script: - - bash benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh muon - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh muon - -sim:hcal_barrel_antimuons: - extends: .det_benchmark - stage: simulate - script: - - bash benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh antimuon - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh antimuon - -sim:hcal_barrel_protons: - extends: .det_benchmark - stage: simulate - script: - - bash benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh proton - - bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh proton - -bench:hcal_barrel_protons: - extends: .det_benchmark - stage: benchmarks - needs: - - ["sim:hcal_barrel_protons"] - script: - - ls -lhtR sim_output/ - - rootls -t sim_output/sim_hcal_barrel_proton.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("proton")' - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx+("proton")' - -bench:hcal_barrel_muons: - extends: .det_benchmark - stage: benchmarks - needs: - - ["sim:hcal_barrel_muons"] - script: - - ls -lhtR sim_output/ - - rootls -t sim_output/sim_hcal_barrel_muon.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("muon")' - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx+("muon")' - -bench:hcal_barrel_antimuons: - extends: .det_benchmark - stage: benchmarks - needs: - - ["sim:hcal_barrel_antimuons"] - script: - - ls -lhtR sim_output/ - - rootls -t sim_output/sim_hcal_barrel_antimuon.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("antimuon")' - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx+("antimuon")' - -bench:hcal_barrel_kaons: +bench:hcal_barrel: extends: .det_benchmark stage: benchmarks needs: - - ["sim:hcal_barrel_kaons"] + - ["sim:hcal_barrel"] + parallel: + matrix: + - PARTICLE: ["piplus", "piminus", "kplus", "kminus", "kshort", "klong", "muon", "antimuon", "proton"] script: - ls -lhtR sim_output/ - - rootls -t sim_output/sim_hcal_barrel_kplus.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("kplus")' - - rootls -t sim_output/sim_hcal_barrel_kminus.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("kminus")' - - rootls -t sim_output/sim_hcal_barrel_kshort.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("kshort")' - - rootls -t sim_output/sim_hcal_barrel_klong.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("klong")' + - rootls -t sim_output/sim_hcal_barrel_${PARTICLE}.edm4hep.root + - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("'${PARTICLE}'")' -bench:hcal_barrel_pions: +bench:hcal_barrel:scan: extends: .det_benchmark stage: benchmarks needs: - - ["sim:hcal_barrel_pions"] + - ["sim:hcal_barrel:scan"] + parallel: + matrix: + - PARTICLE: ["muon", "antimuon", "proton"] script: - ls -lhtR sim_output/ - - rootls -t sim_output/sim_hcal_barrel_piplus.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("piplus")' - - rootls -t sim_output/sim_hcal_barrel_piminus.edm4hep.root - - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_particles_analysis.cxx+("piminus")' + - sort -n sim_output/hcal_barrel_energy_scan_points_${PARTICLE}_*.txt > sim_output/hcal_barrel_energy_scan_points_${PARTICLE}.txt + - root -b -q 'benchmarks/barrel_hcal/scripts/hcal_barrel_energy_scan_analysis.cxx+("'${PARTICLE}'")' collect_results:barrel_hcal: extends: .det_benchmark stage: collect needs: - - ["bench:hcal_barrel_muons", "bench:hcal_barrel_protons", "bench:hcal_barrel_kaons", "bench:hcal_barrel_pions"] + - ["bench:hcal_barrel", "bench:hcal_barrel:scan"] script: - ls -lrht - echo " FIX ME" diff --git a/benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh b/benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh index 92388286b75e6bfb8bca59252dbad716c9f2c316..74282724280364300276177f4edc6b05355d554a 100755 --- a/benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh +++ b/benchmarks/barrel_hcal/run_hcal_barrel_energy_scan.sh @@ -1,21 +1,28 @@ #!/bin/bash export PARTICLE=$1 -E_file="sim_output/hcal_barrel_energy_scan_points_${PARTICLE}.txt" +shift +E_file="sim_output/hcal_barrel_energy_scan_points_${PARTICLE}_${CI_JOB_ID}.txt" -#for E in 1 2 6 10 -for E in 0.25 0.5 1 2 3 4 7 15 20 +if [ $# -gt 0 ] ; then + E_VALUES=("$@") +else + E_VALUES=(0.25 0.5 1 2 3 4 7 15 20) +fi + +for E in ${E_VALUES[@]} do export E_START="$E" export E_END="$E" + export JUGGLER_FILE_NAME_TAG=hcal_barrel_${PARTICLE}_${E} bash benchmarks/barrel_hcal/run_hcal_barrel_particles.sh "${PARTICLE}" && echo "$E" >> "$E_file" || exit 1 path_rootfiles="sim_output/energy_scan/${E}/" path_plots="results/energy_scan/${E}/" mkdir -p "$path_rootfiles" mkdir -p "$path_plots" ls -lthaR sim_output/ - mv "sim_output/sim_hcal_barrel_${PARTICLE}.edm4hep.root" "$path_rootfiles" + mv "sim_output/sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root" "$path_rootfiles/sim_hcal_barrel_${PARTICLE}.edm4hep.root" done ls -lthaR sim_output diff --git a/benchmarks/barrel_hcal/run_hcal_barrel_particles.sh b/benchmarks/barrel_hcal/run_hcal_barrel_particles.sh index ddae1318c5a8d898327549226755550f68f36f84..d9f459f85ef937f46a779749832563cd7a770f7e 100755 --- a/benchmarks/barrel_hcal/run_hcal_barrel_particles.sh +++ b/benchmarks/barrel_hcal/run_hcal_barrel_particles.sh @@ -21,10 +21,13 @@ if [[ ! -n "${PARTICLE}" ]] ; then export PARTICLE="electron" fi -export JUGGLER_FILE_NAME_TAG="hcal_barrel_${PARTICLE}" -export JUGGLER_GEN_FILE="${JUGGLER_FILE_NAME_TAG}.hepmc" +if [[ ! -n "${JUGGLER_FILE_NAME_TAG}" ]] ; then + export JUGGLER_FILE_NAME_TAG="hcal_barrel_${PARTICLE}" +fi + +export JUGGLER_GEN_FILE="data/${JUGGLER_FILE_NAME_TAG}.hepmc" -export JUGGLER_SIM_FILE="sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root" +export JUGGLER_SIM_FILE="sim_output/sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root" export JUGGLER_REC_FILE="rec_${JUGGLER_FILE_NAME_TAG}.root" echo "JUGGLER_N_EVENTS = ${JUGGLER_N_EVENTS}" @@ -51,8 +54,8 @@ ddsim --runType batch \ --filter.tracker edep0 \ --numberOfEvents ${JUGGLER_N_EVENTS} \ --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \ - --inputFiles data/${JUGGLER_FILE_NAME_TAG}.hepmc \ - --outputFile sim_output/${JUGGLER_SIM_FILE} + --inputFiles ${JUGGLER_GEN_FILE} \ + --outputFile ${JUGGLER_SIM_FILE} if [[ "$?" -ne "0" ]] ; then echo "ERROR running npdet" @@ -61,7 +64,3 @@ fi # Directory for plots mkdir -p results - -# Move ROOT output file -#mv ${JUGGLER_REC_FILE} sim_output/ - diff --git a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx index 297a74f554ed4b48a52acb9415ecc4c950e272dd..a35829db126657014b53a9656d077d80246e0359 100644 --- a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx +++ b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_gen.cxx @@ -18,6 +18,7 @@ #include <fstream> #include <math.h> #include <random> +#include <cstdlib> #include <fmt/core.h> #include "hcal_barrel_common_functions.h" @@ -25,7 +26,12 @@ using namespace HepMC3; void hcal_barrel_particles_gen(int n_events = 1e6, double e_start = 0.0, double e_end = 20.0, std::string particle_name = "muon") { - std::string out_fname = fmt::format("./data/hcal_barrel_{}.hepmc", particle_name); + std::string out_fname; + auto env_fname = getenv("JUGGLER_GEN_FILE"); + if (env_fname != nullptr) + out_fname = env_fname; + else + out_fname = fmt::format("./data/hcal_barrel_{}.hepmc", particle_name); WriterAscii hepmc_output(out_fname); int events_parsed = 0; GenEvent evt(Units::GEV, Units::MM); diff --git a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx index c21db831cd198a640ea74d08a1f2e5d30a8ea7d5..f40f7c29c77c55165ecfca8350ee08924974370b 100644 --- a/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx +++ b/benchmarks/barrel_hcal/scripts/hcal_barrel_particles_reader.cxx @@ -19,6 +19,7 @@ #include <iostream> #include <fstream> +#include <cstdlib> #include <fmt/core.h> #include "hcal_barrel_common_functions.h" @@ -50,7 +51,12 @@ void hcal_barrel_particles_reader(std::string particle_name = "electron") gStyle->SetPadLeftMargin(0.14); gStyle->SetPadRightMargin(0.17); - std::string in_fname = fmt::format("./data/hcal_barrel_{}.hepmc",particle_name); + std::string in_fname; + auto env_fname = getenv("JUGGLER_GEN_FILE"); + if (env_fname != nullptr) + in_fname = env_fname; + else + in_fname = fmt::format("./data/hcal_barrel_{}.hepmc", particle_name); ReaderAscii hepmc_input(in_fname); int events_parsed = 0; GenEvent evt(Units::GEV, Units::MM);