diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86f311a8bb80da7d1718898ee1dbbaa13ff300de..423a9055738c0e1a9b1d975bf17a68afa61d6a75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -86,6 +86,7 @@ include: - local: 'benchmarks/zdc/config.yml' - local: 'benchmarks/crystal_calorimeter/config.yml' - local: 'benchmarks/pid/config.yml' + - local: 'benchmarks/timing/config.yml' deploy_results: stage: deploy diff --git a/benchmarks/timing/config.yml b/benchmarks/timing/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..23b08327e54377d37245245ed063334b3cff5d75 --- /dev/null +++ b/benchmarks/timing/config.yml @@ -0,0 +1,22 @@ +sim:timing: + extends: .det_benchmark + stage: simulate + timeout: 1 hours + script: + - bash benchmarks/timing/run_timing.sh -n "${NEVENTS}" -p "${PARTICLES}" -e "${ENERGIES}" + artifacts: + paths: + - results/ + parallel: + matrix: + - PARTICLES: ["e-"] + ENERGIES: ["1*GeV"] + NEVENTS: ["1","100"] + +#collect_results:timing: +# extends: .det_benchmark +# stage: collect +# needs: +# - ["sim:timing"] +# script: +# - ls -lrht diff --git a/benchmarks/timing/run_timing.sh b/benchmarks/timing/run_timing.sh new file mode 100755 index 0000000000000000000000000000000000000000..39d0718359f2994c382360b6257436a4b6992068 --- /dev/null +++ b/benchmarks/timing/run_timing.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +function print_the_help { + echo "USAGE: ${0} -nevents <nevents> -p <particle> -e <energy>" + echo " OPTIONS: " + echo " -n,--nevents number of events" + echo " -p,--particle particle type" + echo " -e,--energy particle energy" + exit +} + +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + + case $key in + -h|--help) + shift # past argument + print_the_help + ;; + -n|--nevents) + nevents="$2" + shift # past argument + shift # past value + ;; + -p|--particle) + particle="$2" + shift # past argument + shift # past value + ;; + -e|--energy) + energy="$2" + shift + shift + ;; + *) # unknown option + #POSITIONAL+=("$1") # save it in an array for later + echo "unknown option $1" + print_the_help + shift # past argument + ;; + esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +if [[ ! -n "${nevents}" ]] ; then + nevents="1" +fi + +if [[ ! -n "${particle}" ]] ; then + particle="e-" +fi + +if [[ ! -n "${energy}" ]] ; then + energy="1*GeV" +fi + +if [[ ! -n "${JUGGLER_DETECTOR}" ]] ; then + export JUGGLER_DETECTOR="athena" +fi + +if [[ ! -n "${JUGGLER_DETECTOR_PATH}" ]] ; then + export JUGGLER_DETECTOR_PATH="/opt/detector/share/athena" +fi + +if [[ ! -n "${JUGGLER_INSTALL_PREFIX}" ]] ; then + export JUGGLER_INSTALL_PREFIX="/usr/local" +fi + +compact_path=${JUGGLER_DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml + +echo "JUGGLER_DETECTOR_PATH = ${JUGGLER_DETECTOR_PATH}" +echo "JUGGLER_DETECTOR = ${JUGGLER_DETECTOR}" + +# Run geant4 simulations +output_dir="data/timing/${particle}/${energy/\*/}" +output_file="sim_${nevents}.root" +mkdir -p ${output_dir} +timing_dir="results/timing/${particle}/${energy/\*/}" +timing_file="time_${nevents}events.log" +npsim_file="npsim_${nevents}events.log" +mkdir -p ${timing_dir} +/usr/bin/time -v -o ${timing_dir}/time_${nevents}events.log \ + npsim --runType batch \ + --printLevel WARNING \ + --numberOfEvents ${nevents} \ + --enableGun \ + --gun.energy "${energy}" \ + --gun.particle "${particle}" \ + --gun.thetaMin "45*deg" \ + --gun.thetaMax "135*deg" \ + --gun.distribution "cos(theta)" \ + --part.minimalKineticEnergy "1*TeV" \ + --compactFile ${compact_path} \ + --outputFile ${output_dir}/${output_file} \ + 2>&1 > ${timing_dir}/${npsim_file} +echo "For ${nevents} events:" +cat ${timing_dir}/${timing_file} + +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running npsim" + exit 1 +fi +