From b76f32aa9c8138143fd94c8f2935b01d720e79b5 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com> Date: Wed, 19 Jun 2024 15:18:54 -0400 Subject: [PATCH] benchmarks/dis: convert to Snakemake --- Snakefile | 1 + benchmarks/dis/README.md | 12 --- benchmarks/dis/Snakefile | 144 +++++++++++++++++++++++++++++ benchmarks/dis/analysis-only.sh | 134 --------------------------- benchmarks/dis/config.yml | 6 +- benchmarks/dis/dis.sh | 157 -------------------------------- benchmarks/dis/env.sh | 58 ------------ benchmarks/dis/gen.sh | 98 -------------------- benchmarks/dis/get.sh | 80 ---------------- 9 files changed, 148 insertions(+), 542 deletions(-) delete mode 100644 benchmarks/dis/README.md create mode 100644 benchmarks/dis/Snakefile delete mode 100755 benchmarks/dis/analysis-only.sh delete mode 100755 benchmarks/dis/dis.sh delete mode 100644 benchmarks/dis/env.sh delete mode 100755 benchmarks/dis/gen.sh delete mode 100644 benchmarks/dis/get.sh diff --git a/Snakefile b/Snakefile index b01ad5e2..ac3778f6 100644 --- a/Snakefile +++ b/Snakefile @@ -31,3 +31,4 @@ ddsim \ """ include: "benchmarks/diffractive_vm/Snakefile" +include: "benchmarks/dis/Snakefile" diff --git a/benchmarks/dis/README.md b/benchmarks/dis/README.md deleted file mode 100644 index 7a8890b6..00000000 --- a/benchmarks/dis/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# DIS Benchmarks - -## Compiling Pythia example - -``` -g++ src/pythia_dis.cc -o pythia_dis \ - -I/home/whit/stow/hepmc3/include \ - -I../include -O2 -std=c++11 -pedantic -W -Wall -Wshadow -fPIC \ - -L../lib -Wl,-rpath,../lib -lpythia8 -ldl \ - -L/home/whit/stow/hepmc3/lib -Wl,-rpath,/home/whit/stow/hepmc3/lib -lHepMC3 -``` - diff --git a/benchmarks/dis/Snakefile b/benchmarks/dis/Snakefile new file mode 100644 index 00000000..f4f8d1fe --- /dev/null +++ b/benchmarks/dis/Snakefile @@ -0,0 +1,144 @@ +import os +import shutil + +from snakemake.remote.S3 import RemoteProvider as S3RemoteProvider + + +S3 = S3RemoteProvider( + endpoint_url="https://eics3.sdcc.bnl.gov:9000", + access_key_id=os.environ["S3_ACCESS_KEY"], + secret_access_key=os.environ["S3_SECRET_KEY"], +) + + +rule dis_compile: + input: + ROOT_BUILD_DIR_PREFIX + "benchmarks/dis/analysis/dis_electrons_cxx.so", + ROOT_BUILD_DIR_PREFIX + "benchmarks/dis/analysis/jets_cxx.so", + + +rule dis_get: + input: + lambda wildcards: S3.remote(f"eictest/EPIC/EVGEN/DIS/NC/{wildcards.EBEAM}x{wildcards.PBEAM}/minQ2={wildcards.MINQ2}/pythia8NCDIS_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc"), + output: + "input/dis/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc", + run: + shutil.move(input[0], output[0]) + + +rule dis_sim: + input: + hepmc="input/dis/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc", + warmup="warmup/{DETECTOR_CONFIG}.edm4hep.root", + output: + "sim/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.edm4hep.root", + params: + N_EVENTS=100 + shell: + """ +ddsim \ + --runType batch \ + --part.minimalKineticEnergy 1000*GeV \ + --filter.tracker edep0 \ + -v WARNING \ + --numberOfEvents {params.N_EVENTS} \ + --compactFile $DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml \ + --inputFiles {input.hepmc} \ + --outputFile {output} +""" + + +rule dis_reco_eicrecon: + input: + "sim/{DETECTOR_CONFIG}/{file}.edm4hep.root", + output: + "reco/{DETECTOR_CONFIG}/{file}.edm4eic.root", + shell: + """ +DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} eicrecon {input} -Ppodio:output_file={output} +""" + + +rule dis_generate_config: + input: + data="reco/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.edm4eic.root", + output: + config="results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/config.json", + shell: """ +cat > {output.config} <<EOF +{{ + "rec_file": "{input.data}", + "detector": "{wildcards.DETECTOR_CONFIG}", + "output_prefix": "$(dirname "{output.config}")/dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}", + "results_path": "$(dirname "{output.config}")", + "ebeam": {wildcards.EBEAM}, + "pbeam": {wildcards.PBEAM}, + "minq2": {wildcards.MINQ2}, + "plot_tag": "dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}", + "test_tag": "dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}" +}} +EOF +""" + + +rule dis_analysis_electrons: + input: + script="benchmarks/dis/analysis/dis_electrons.cxx", + script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/dis/analysis/dis_electrons_cxx.so", + data="reco/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.edm4eic.root", + config="results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/config.json", + output: + expand("results/{{DETECTOR_CONFIG}}/dis/{{EBEAM}}on{{PBEAM}}/minQ2={{MINQ2}}/{FILENAME}", FILENAME=[ + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_logQ2_panels.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_logQ2_overlays.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_Q2_res_panels.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_Q2_res_overlays.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_panels.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_overlays.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_res_panels.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}_x_res_overlays.png", + "dis_{EBEAM}x{PBEAM}_minQ2={MINQ2}dis_electrons.json" + ]), + shell: """ +root -l -b -q '{input.script}+("{input.config}")' +""" + + +rule dis_analysis_jets: + input: + script="benchmarks/dis/analysis/jets.cxx", + script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/dis/analysis/jets_cxx.so", + data="reco/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.edm4eic.root", + config="results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/config.json", + output: + results_path=directory("results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/jets"), + shell: """ +mkdir {output.results_path} +root -l -b -q '{input.script}+("{input.config}")' +""" + + +rule dis_analysis_kinematics_correlations: + input: + data="reco/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.edm4eic.root", + output: + results_path=directory("results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/kinematics_correlations"), + params: + N_EVENTS=100 + shell: """ +mkdir {output.results_path} +python benchmarks/dis/analysis/kinematics_correlations.py --rec_file "{input.data}" --config dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{wildcards.DETECTOR_CONFIG} --results_path {output.results_path} --nevents {params.N_EVENTS} +""" + + +rule dis_analysis_truth_reconstruction: + input: + data="reco/{DETECTOR_CONFIG}/pythia8NCDIS_{EBEAM}x{PBEAM}_minQ2={MINQ2}_beamEffects_xAngle=-0.025_hiDiv_1.edm4eic.root", + output: + results_path=directory("results/{DETECTOR_CONFIG}/dis/{EBEAM}on{PBEAM}/minQ2={MINQ2}/truth_reconstruction"), + params: + N_EVENTS=100 + shell: """ +mkdir {output.results_path} +python benchmarks/dis/analysis/truth_reconstruction.py --rec_file "{input.data}" --config dis_{wildcards.EBEAM}x{wildcards.PBEAM}_minQ2={wildcards.MINQ2}_{wildcards.DETECTOR_CONFIG} --results_path $(dirname {output.results_path}) --nevents {params.N_EVENTS} +""" diff --git a/benchmarks/dis/analysis-only.sh b/benchmarks/dis/analysis-only.sh deleted file mode 100755 index d3685aaf..00000000 --- a/benchmarks/dis/analysis-only.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -source strict-mode.sh - -## ============================================================================= -## Run the DIS benchmarks in 5 steps: -## 1. Parse the command line and setup environment -## 2. Detector simulation through ddsim -## 3. Digitization and reconstruction through Juggler -## 4. Root-based Physics analyses -## 5. Finalize -## ============================================================================= - -## make sure we launch this script from the project root directory -PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/../.. -pushd ${PROJECT_ROOT} - -echo "Running the DIS benchmarks" - -## ============================================================================= -## Step 1: Setup the environment variables -## -## First parse the command line flags. -## This sets the following environment variables: -## - CONFIG: The specific generator configuration -## - EBEAM: The electron beam energy -## - PBEAM: The ion beam energy -source parse_cmd.sh $@ - -## To run the reconstruction, we need the following global variables: -## - DETECTOR: the detector package we want to use for this benchmark -## - DETECTOR_PATH: full path to the detector definitions -## - -## We also need the following benchmark-specific variables: -## -## - BENCHMARK_TAG: Unique identified for this benchmark process. -## - BEAM_TAG: Identifier for the chosen beam configuration -## - INPUT_PATH: Path for generator-level input to the benchmarks -## - TMP_PATH: Path for temporary data (not exported as artifacts) -## - RESULTS_PATH: Path for benchmark output figures and files -## -## You can read dvmp/env.sh for more in-depth explanations of the variables. -source benchmarks/dis/env.sh - -## Get a unique file names based on the configuration options -GEN_FILE=${INPUT_PATH}/gen-${CONFIG}_${JUGGLER_N_EVENTS}.hepmc - -SIM_FILE=${TMP_PATH}/sim-${CONFIG}.edm4hep.root -SIM_LOG=${TMP_PATH}/sim-${CONFIG}.log - - -REC_FILE=${TMP_PATH}/rec-${CONFIG}.root -REC_LOG=${TMP_PATH}/sim-${CONFIG}.log - -PLOT_TAG=${CONFIG} - -## ============================================================================= -## Step 2: Run the simulation -echo "Running Geant4 simulation" -#ddsim --runType batch \ -# --part.minimalKineticEnergy 1000*GeV \ -# --filter.tracker edep0 \ -# -v WARNING \ -# --numberOfEvents ${JUGGLER_N_EVENTS} \ -# --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \ -# --inputFiles ${GEN_FILE} \ -# --outputFile ${SIM_FILE} -#if [ "$?" -ne "0" ] ; then -# echo "ERROR running ddsim" -# exit 1 -#fi - -## ============================================================================= -## Step 3: Run digitization & reconstruction -#echo "Running the digitization and reconstruction" -## FIXME Need to figure out how to pass file name to juggler from the commandline -## the tracker_reconstruction.py options file uses the following environment -## variables: -## - JUGGLER_SIM_FILE: input detector simulation -## - JUGGLER_REC_FILE: output reconstructed data -## - JUGGLER_N_EVENTS: number of events to process (part of global environment) -## - DETECTOR: detector package (part of global environment) -#export JUGGLER_SIM_FILE=${SIM_FILE} -#export JUGGLER_REC_FILE=${REC_FILE} -#gaudirun.py options/tracker_reconstruction.py -## on-error, first retry running juggler again as there is still a random -## crash we need to address FIXME -#if [ "$?" -ne "0" ] ; then -# echo "Juggler crashed, retrying..." -# gaudirun.py options/tracker_reconstruction.py \ -# 2>&1 > ${REC_LOG} -# if [ "$?" -ne "0" ] ; then -# echo "ERROR running juggler, both attempts failed" -# exit 1 -# fi -#fi - -## ============================================================================= -## Step 4: Analysis -## write a temporary configuration file for the analysis script -echo "Running analysis" -CONFIG="${TMP_PATH}/${PLOT_TAG}.json" -cat << EOF > ${CONFIG} -{ - "rec_file": "${REC_FILE}", - "detector": "${DETECTOR}", - "output_prefix": "${RESULTS_PATH}/${PLOT_TAG}", - "test_tag": "${BEAM_TAG}" -} -EOF -#cat ${CONFIG} -root -b -q "benchmarks/dis/analysis/dis_electrons.cxx+(\"${CONFIG}\")" -#root -b -q "benchmarks/dis/analysis/dis_electrons.cxx(\"${CONFIG}\")" -if [[ "$?" -ne "0" ]] ; then - echo "ERROR running rec_dis_electron script" - exit 1 -fi - -## ============================================================================= -## Step 5: finalize -#echo "Finalizing DIS benchmark" - -## Move over reconsturction artifacts as long as we don't have -## too many events -#if [ "${JUGGLER_N_EVENTS}" -lt "500" ] ; then -# cp ${REC_FILE} ${RESULTS_PATH} -#fi - -## Always move over log files to the results path -#cp ${REC_LOG} ${RESULTS_PATH} - -## ============================================================================= -## All done! -echo "DIS benchmarks complete" diff --git a/benchmarks/dis/config.yml b/benchmarks/dis/config.yml index 48ef68c9..8c61b46f 100644 --- a/benchmarks/dis/config.yml +++ b/benchmarks/dis/config.yml @@ -2,7 +2,7 @@ dis:compile: stage: compile extends: .compile_benchmark script: - - compile_analyses.py dis + - snakemake --cores 1 dis_compile dis:generate: stage: generate @@ -21,7 +21,7 @@ dis:generate: MINQ2: [1, 10, 100, 1000] timeout: 1 hours script: - - bash benchmarks/dis/get.sh --config dis_${EBEAM}x${PBEAM}_minQ2=${MINQ2} --ebeam ${EBEAM} --pbeam ${PBEAM} --minq2 ${MINQ2} + - snakemake --cores 1 input/dis/pythia8NCDIS_${EBEAM}x${PBEAM}_minQ2=${MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc dis:simulate: stage: simulate @@ -40,7 +40,7 @@ dis:simulate: MINQ2: [1, 10, 100, 1000] timeout: 2 hours script: - - bash benchmarks/dis/dis.sh --config dis_${EBEAM}x${PBEAM}_minQ2=${MINQ2} --ebeam ${EBEAM} --pbeam ${PBEAM} --minq2 ${MINQ2} + - snakemake --cores 1 results/epic_craterlake/dis/${EBEAM}on${PBEAM}/minQ2=${MINQ2}/dis_${EBEAM}x${PBEAM}_minQ2=${MINQ2}dis_electrons.json results/epic_craterlake/dis/${EBEAM}on${PBEAM}/minQ2=${MINQ2}/kinematics_correlations results/epic_craterlake/dis/${EBEAM}on${PBEAM}/minQ2=${MINQ2}/truth_reconstruction retry: max: 2 when: diff --git a/benchmarks/dis/dis.sh b/benchmarks/dis/dis.sh deleted file mode 100755 index f1a551d9..00000000 --- a/benchmarks/dis/dis.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/bash -source strict-mode.sh - -## ============================================================================= -## Run the DIS benchmarks in 5 steps: -## 1. Parse the command line and setup environment -## 2. Detector simulation through ddsim -## 3. Digitization and reconstruction through Juggler -## 4. Root-based Physics analyses -## 5. Finalize -## ============================================================================= - -## make sure we launch this script from the project root directory -PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/../.. -pushd ${PROJECT_ROOT} - -echo "Running the DIS benchmarks" - -## ============================================================================= -## Step 1: Setup the environment variables -## -## First parse the command line flags. -## This sets the following environment variables: -## - CONFIG: The specific generator configuration -## - EBEAM: The electron beam energy -## - PBEAM: The ion beam energy -export REQUIRE_MINQ2=true -source ${LOCAL_PREFIX}/bin/parse_cmd.sh $@ - -## To run the reconstruction, we need the following global variables: -## - DETECTOR: the detector package we want to use for this benchmark -## - DETECTOR_PATH: full path to the detector definitions -## -## defined in common_bench repo -## You can ready bin/env.sh for more in-depth explanations of the variables -## and how they can be controlled. - -## We also need the following benchmark-specific variables: -## -## - BENCHMARK_TAG: Unique identified for this benchmark process. -## - BEAM_TAG: Identifier for the chosen beam configuration -## - INPUT_PATH: Path for generator-level input to the benchmarks -## - TMP_PATH: Path for temporary data (not exported as artifacts) -## - RESULTS_PATH: Path for benchmark output figures and files -## -## You can read dvmp/env.sh for more in-depth explanations of the variables. -source benchmarks/dis/env.sh - -## Get a unique file names based on the configuration options -GEN_FILE=${INPUT_PATH}/gen-${CONFIG}_${JUGGLER_N_EVENTS}.hepmc - -SIM_FILE=${TMP_PATH}/sim-${CONFIG}.edm4hep.root -SIM_LOG=${TMP_PATH}/sim-${CONFIG}.log - -# JUGGLER_REC_FILE_BASE= ${TMP_PATH}/rec-${CONFIG} -REC_FILE=${TMP_PATH}/rec-${CONFIG}.root -REC_LOG=${TMP_PATH}/sim-${CONFIG}.log - -PLOT_TAG=${CONFIG} - -## ============================================================================= -## Step 2: Run the simulation -echo "Running Geant4 simulation" -if [ ! -f ${SIM_FILE} ] ; then -ddsim --runType batch \ - --part.minimalKineticEnergy 1000*GeV \ - --filter.tracker edep0 \ - -v WARNING \ - --numberOfEvents ${JUGGLER_N_EVENTS} \ - --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \ - --inputFiles ${GEN_FILE} \ - --outputFile ${SIM_FILE} -if [ "$?" -ne "0" ] ; then - echo "ERROR running ddsim" - exit 1 -fi -fi - -## ============================================================================= -## Step 3: Run digitization & reconstruction -echo "Running the digitization and reconstruction" -if [ ${RECO} == "eicrecon" ] ; then - /usr/bin/time -v eicrecon ${SIM_FILE} -Ppodio:output_file=${REC_FILE} - if [ "$?" -ne "0" ] ; then - echo "ERROR running eicrecon" - exit 1 - fi -fi - -if [[ ${RECO} == "juggler" ]] ; then - export JUGGLER_SIM_FILE=${SIM_FILE} - export JUGGLER_REC_FILE=${REC_FILE} - gaudirun.py options/reconstruction.py || [ $? -eq 4 ] - if [ "$?" -ne "0" ] ; then - echo "ERROR running juggler" - exit 1 - fi -fi - - -## ============================================================================= -## Step 4: Analysis -## write a temporary configuration file for the analysis script -echo "Running analysis" -CONFIG="${TMP_PATH}/${PLOT_TAG}.json" -cat << EOF > ${CONFIG} -{ - "rec_file": "${REC_FILE}", - "detector": "${DETECTOR}", - "output_prefix": "${RESULTS_PATH}/${PLOT_TAG}", - "results_path": "${RESULTS_PATH}", - "plot_tag": "${PLOT_TAG}", - "ebeam": ${EBEAM}, - "pbeam": ${PBEAM}, - "minq2": ${MINQ2}, - "test_tag": "${BEAM_TAG}" -} -EOF - -root -b -q "benchmarks/dis/analysis/dis_electrons.cxx+g(\"${CONFIG}\")" -if [[ "$?" -ne "0" ]] ; then - echo "ERROR running dis_electron script" - exit 1 -fi - -python benchmarks/dis/analysis/kinematics_correlations.py --rec_file ${REC_FILE} --config ${PLOT_TAG}_${DETECTOR_CONFIG} --results_path ${RESULTS_PATH} --nevents ${JUGGLER_N_EVENTS} -if [[ "$?" -ne "0" ]] ; then - echo "ERROR running kinematics_correlations script" - exit 1 -fi - -python benchmarks/dis/analysis/truth_reconstruction.py --rec_file ${REC_FILE} --config ${PLOT_TAG}_${DETECTOR_CONFIG} --results_path ${RESULTS_PATH} --nevents ${JUGGLER_N_EVENTS} -if [[ "$?" -ne "0" ]] ; then - echo "ERROR running truth_reconstruction script" - exit 1 -fi - -root -b -q "benchmarks/dis/analysis/jets.cxx+g(\"${CONFIG}\")" -if [[ "$?" -ne "0" ]] ; then - echo "ERROR running dis_electron script" - exit 1 -fi - - -## ============================================================================= -## Step 5: finalize -echo "Finalizing DIS benchmark" - -## Move over reconsturction artifacts as long as we don't have -## too many events -if [ "${JUGGLER_N_EVENTS}" -lt "500" ] ; then - cp ${REC_FILE} ${RESULTS_PATH} -fi - -## ============================================================================= -## All done! -echo "DIS benchmarks complete" diff --git a/benchmarks/dis/env.sh b/benchmarks/dis/env.sh deleted file mode 100644 index 50f6bb04..00000000 --- a/benchmarks/dis/env.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -source strict-mode.sh - -## ============================================================================= -## Local configuration variables for this particular benchmark -## It defines the following additional variables: -## -## - BENCHMARK_TAG: Tag to identify this particular benchmark -## - BEAM_TAG Tag to identify the beam configuration -## - INPUT_PATH: Path for generator-level input to the benchmarks -## - TMP_PATH: Path for temporary data (not exported as artifacts) -## - RESULTS_PATH: Path for benchmark output figures and files -## -## This script assumes that EBEAM and PBEAM are set as part of the -## calling script (usually as command line argument). -## -## ============================================================================= - -## Tag for the local benchmark. Should be the same as the directory name for -## this particular benchmark set (for clarity). -## This tag is used for the output artifacts directory (results/${JUGGLER_TAG}) -## and a tag in some of the output files. -export BENCHMARK_TAG="dis" -echo "Setting up the local environment for the ${BENCHMARK_TAG^^} benchmarks" - -## Extra beam tag to identify the desired beam configuration -export BEAM_TAG="${EBEAM}on${PBEAM}" - -if [[ ! -d "input" ]] ; then - echo " making local link to input " - mkdir_local_data_link input -fi -## Data path for input data (generator-level hepmc file) -INPUT_PATH="input/${BENCHMARK_TAG}/${BEAM_TAG}/minQ2=${MINQ2}" -mkdir_local_data_link input -#export INPUT_PATH=`realpath ${INPUT_PATH}` -mkdir -p "${INPUT_PATH}" -echo "INPUT_PATH: ${INPUT_PATH}" - - -## Data path for temporary data (not exported as artifacts) -TMP_PATH=${LOCAL_DATA_PATH}/tmp/${BEAM_TAG} -mkdir -p ${TMP_PATH} -#export TMP_PATH=`realpath ${TMP_PATH}` -echo "TMP_PATH: ${TMP_PATH}" - -## Data path for benchmark output (plots and reconstructed files -## if not too big). -RESULTS_PATH="results/${BENCHMARK_TAG}/${BEAM_TAG}/minQ2=${MINQ2}" -mkdir -p ${RESULTS_PATH} -mkdir -p "${RESULTS_PATH}/truth_reconstruction" -mkdir -p "${RESULTS_PATH}/jets" -export RESULTS_PATH=`realpath ${RESULTS_PATH}` -echo "RESULTS_PATH: ${RESULTS_PATH}" - -## ============================================================================= -## That's all! -echo "Local environment setup complete." diff --git a/benchmarks/dis/gen.sh b/benchmarks/dis/gen.sh deleted file mode 100755 index 4b27b95d..00000000 --- a/benchmarks/dis/gen.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -source strict-mode.sh - -## ============================================================================= -## Standin for a proper pythia generation process, similar to how we -## generate events for DVMP -## Runs in 5 steps: -## 1. Parse the command line and setup the environment -## 2. Check if we can load the requested file from the cache -## 3. Build generator exe -## 4. Run the actual generator -## 5. Finalize -## ============================================================================= -## ============================================================================= - -## make sure we launch this script from the project root directory -PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/../.. -pushd ${PROJECT_ROOT} - -## ============================================================================= -## Step 1: Setup the environment variables -## First parse the command line flags. -## This sets the following environment variables: -## - CONFIG: The specific generator configuration --> not currenlty used FIXME -## - EBEAM: The electron beam energy --> not currently used FIXME -## - PBEAM: The ion beam energy --> not currently used FIXME -source parse_cmd.sh $@ - -## To run the generator, we need the following global variables: -## -## - LOCAL_PREFIX: Place to cache local packages and data -## - JUGGLER_N_EVENTS: Number of events to process -## - JUGGLER_RNG_SEED: Random seed for event generation. -## -## defined in common_bench repo -## You can ready bin/env.sh for more in-depth explanations of the variables -## and how they can be controlled. - - -## We also need the following benchmark-specific variables: -## -## - BENCHMARK_TAG: Unique identified for this benchmark process. -## - INPUT_PATH: Path for generator-level input to the benchmarks -## - TMP_PATH: Path for temporary data (not exported as artifacts) -## -## You can read dvmp/env.sh for more in-depth explanations of the variables. -source benchmarks/dis/env.sh - -## Get a unique file name prefix based on the configuration options -GEN_TAG=gen-${CONFIG}_${JUGGLER_N_EVENTS} ## Generic file prefix - -## ============================================================================= -## Step 2: Check if we really need to run, or can use the cache. -if [ -f "${INPUT_PATH}/${GEN_TAG}.hepmc" ]; then - echo "Found cached generator output for $GEN_TAG, no need to rerun" - exit 0 -fi - -echo "Generator output for $GEN_TAG not found in cache, need to run generator" - -## ============================================================================= -## Step 3: Build generator exe -## TODO: need to configurability to the generator exe - -echo "Compiling benchmarks/dis/generator/pythia_dis.cxx ..." -g++ benchmarks/dis/generator/pythia_dis.cxx -o ${TMP_PATH}/pythia_dis \ - -I/usr/local/include -I${LOCAL_PREFIX}/include \ - -O2 -std=c++11 -pedantic -W -Wall -Wshadow -fPIC \ - $(pythia8-config --cxxflags --ldflags) \ - $(HepMC3-config --cxxflags --ldflags) -if [[ "$?" -ne "0" ]] ; then - echo "ERROR compiling pythia" - exit 1 -fi -echo "done" - -## ============================================================================= -## Step 4: Run the event generator -echo "Running the generator" -${TMP_PATH}/pythia_dis ${TMP_PATH}/${GEN_TAG}.hepmc -if [[ "$?" -ne "0" ]] ; then - echo "ERROR running pythia" - exit 1 -fi - - -## ============================================================================= -## Step 5: Finally, move relevant output into the artifacts directory and clean up -## ============================================================================= -echo "Moving generator output into ${INPUT_PATH}" -mv ${TMP_PATH}/${GEN_TAG}.hepmc ${INPUT_PATH}/${GEN_TAG}.hepmc -## this step only matters for local execution -echo "Cleaning up" -## does nothing - -## ============================================================================= -## All done! -echo "$BENCHMARK_TAG event generation complete" diff --git a/benchmarks/dis/get.sh b/benchmarks/dis/get.sh deleted file mode 100644 index a8718f9b..00000000 --- a/benchmarks/dis/get.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -source strict-mode.sh - -## ============================================================================= -## Standin for a proper pythia generation process, similar to how we -## generate events for DVMP -## Runs in 5 steps: -## 1. Parse the command line and setup the environment -## 2. Check if we can download the file -## 3. Finalize -## ============================================================================= -## ============================================================================= - -## make sure we launch this script from the project root directory -PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/../.. -pushd ${PROJECT_ROOT} - -## ============================================================================= -## Step 1: Setup the environment variables -## First parse the command line flags. -## This sets the following environment variables: -## - CONFIG: The specific generator configuration --> not currenlty used FIXME -## - EBEAM: The electron beam energy --> not currently used FIXME -## - PBEAM: The ion beam energy --> not currently used FIXME -export REQUIRE_MINQ2=true -source parse_cmd.sh $@ - -## To run the generator, we need the following global variables: -## -## - LOCAL_PREFIX: Place to cache local packages and data -## - JUGGLER_N_EVENTS: Number of events to process -## - JUGGLER_RNG_SEED: Random seed for event generation. -## -## defined in common_bench repo -## You can ready bin/env.sh for more in-depth explanations of the variables -## and how they can be controlled. - - -## We also need the following benchmark-specific variables: -## -## - BENCHMARK_TAG: Unique identified for this benchmark process. -## - INPUT_PATH: Path for generator-level input to the benchmarks -## - TMP_PATH: Path for temporary data (not exported as artifacts) -## -## You can read dvmp/env.sh for more in-depth explanations of the variables. -source benchmarks/dis/env.sh - -## Get a unique file name prefix based on the configuration options -GEN_TAG=gen-${CONFIG}_${JUGGLER_N_EVENTS} ## Generic file prefix - -## ============================================================================= -## Step 2: Check if we can find the file -if [ -f "${INPUT_PATH}/${GEN_TAG}.hepmc" ]; then - echo "Found cached generator output for $GEN_TAG, no need to rerun" - exit 0 -fi - -## ============================================================================= -## Step 3: Copy the file (about 180 lines per event in DIS NC files) -nlines=$((190*${JUGGLER_N_EVENTS})) -DATA_URL=S3/eictest/ATHENA/EVGEN/DIS/NC/${EBEAM}x${PBEAM}/minQ2=${MINQ2}/pythia8NCDIS_${EBEAM}x${PBEAM}_minQ2=${MINQ2}_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc -mc config host add S3 https://eics3.sdcc.bnl.gov:9000 ${S3_ACCESS_KEY} ${S3_SECRET_KEY} -mc head -n ${nlines} ${DATA_URL} | sanitize_hepmc3 > ${TMP_PATH}/${GEN_TAG}.hepmc -if [[ "$?" -ne "0" ]] ; then - echo "ERROR downloading file" - exit 1 -fi - -## ============================================================================= -## Step 4: Finally, move relevant output into the artifacts directory and clean up -## ============================================================================= -echo "Moving generator output to ${INPUT_PATH}/${GEN_TAG}.hepmc" -mv ${TMP_PATH}/${GEN_TAG}.hepmc ${INPUT_PATH}/${GEN_TAG}.hepmc -## this step only matters for local execution -echo "Cleaning up" -## does nothing - -## ============================================================================= -## All done! -echo "$BENCHMARK_TAG event generation complete" -- GitLab