diff --git a/benchmarks/sampling_ecal/run_emcal_barrel_photons.sh b/benchmarks/sampling_ecal/run_emcal_barrel_photons.sh new file mode 100644 index 0000000000000000000000000000000000000000..aaa472899f793386b0338cc1dcea1d6d2af81e0a --- /dev/null +++ b/benchmarks/sampling_ecal/run_emcal_barrel_photons.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +if [[ ! -n "${JUGGLER_DETECTOR}" ]] ; then + export JUGGLER_DETECTOR="topside" +fi +export CB_EMCAL_COMPACT_PATH=${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml + + +if [[ ! -n "${CB_EMCAL_NUMEV}" ]] ; then + export CB_EMCAL_NUMEV=1000 +fi + +if [[ ! -n "${CB_EMCAL_ENERGY}" ]] ; then + export CB_EMCAL_ENERGY=5.0 +fi + + +if [[ ! -n "${CB_EMCAL_SAMP_FRAC}" ]] ; then + export CB_EMCAL_SAMP_FRAC=0.014 +fi + +export CB_EMCAL_NAME_TAG="emcal_barrel_uniform_photons" +export CB_EMCAL_GEN_FILE="${CB_EMCAL_NAME_TAG}.hepmc" + +export CB_EMCAL_SIM_FILE="sim_${CB_EMCAL_NAME_TAG}.root" +export CB_EMCAL_REC_FILE="rec_${CB_EMCAL_NAME_TAG}.root" + +echo "CB_EMCAL_NUMEV = ${CB_EMCAL_NUMEV}" +echo "CB_EMCAL_COMPACT_PATH = ${CB_EMCAL_COMPACT_PATH}" + +# Generate the input events +python benchmarks/sampling_ecal/scripts/gen_particles.py ${CB_EMCAL_GEN_FILE} \ + --angmin 90 --angmax 90 --parray ${CB_EMCAL_ENERGY} --particles="22" +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running script: generating input events" + exit 1 +fi + +ls -lh ${CB_EMCAL_GEN_FILE} + +# Run geant4 simulations +npsim --runType batch \ + -v WARNING \ + --part.minimalKineticEnergy 0.5*GeV \ + --numberOfEvents ${CB_EMCAL_NUMEV} \ + --compactFile ${CB_EMCAL_COMPACT_PATH} \ + --inputFiles ${CB_EMCAL_GEN_FILE} \ + --outputFile ${CB_EMCAL_SIM_FILE} + +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running npdet" + exit 1 +fi + +rootls -t "${CB_EMCAL_SIM_FILE}" + +# Directory for plots +mkdir -p results + +# CB_EMCAL_OPTION_DIR=${JUGGLER_INSTALL_PREFIX}/Examples/options +# CB_EMCAL_SCRIPT_DIR=${JUGGLER_INSTALL_PREFIX}/Examples/scripts/sampling_calorimeter +CB_EMCAL_OPTION_DIR=benchmarks/sampling_ecal/options +CB_EMCAL_SCRIPT_DIR=benchmarks/sampling_ecal/scripts + +# Run Juggler +# xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv gaudirun.py ${CB_EMCAL_OPTION_DIR}/sampling_cluster3d.py +gaudirun.py ${CB_EMCAL_OPTION_DIR}/sampling_cluster3d.py +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running juggler" + exit 1 +fi + +# check required python modules +python -m pip install -r benchmarks/sampling_ecal/requirements.txt + +# Run analysis script +python ${CB_EMCAL_SCRIPT_DIR}/draw_cluster_layers.py \ + ${CB_EMCAL_REC_FILE} -e 0 --topo-size=1.0 --compact=${CB_EMCAL_COMPACT_PATH} -o results/photons +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running analysis script: draw_cluster_layers" + exit 1 +fi + +python ${CB_EMCAL_SCRIPT_DIR}/draw_cluster.py \ + ${CB_EMCAL_REC_FILE} -e 0 --topo-size=2.0 --compact=${CB_EMCAL_COMPACT_PATH} -o results/photons +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running analysis script: draw_cluster" + exit 1 +fi + +python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \ + ${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/photons \ + --save=results/profile.csv --color=royalblue +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running analysis script: energy_profile" + exit 1 +fi + + +root_filesize=$(stat --format=%s "${CB_EMCAL_REC_FILE}") +if [[ "${CB_EMCAL_NUMEV}" -lt "500" ]] ; then + # file must be less than 10 MB to upload + if [[ "${root_filesize}" -lt "10000000" ]] ; then + cp ${CB_EMCAL_REC_FILE} results/. + fi +fi + diff --git a/benchmarks/sampling_ecal/run_emcal_barrel_pion.sh b/benchmarks/sampling_ecal/run_emcal_barrel_pion.sh new file mode 100644 index 0000000000000000000000000000000000000000..c610c12e51a7798260f1026f96052c21961b1e59 --- /dev/null +++ b/benchmarks/sampling_ecal/run_emcal_barrel_pion.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +if [[ ! -n "${JUGGLER_DETECTOR}" ]] ; then + export JUGGLER_DETECTOR="topside" +fi +export CB_EMCAL_COMPACT_PATH=${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml + + +if [[ ! -n "${CB_EMCAL_NUMEV}" ]] ; then + export CB_EMCAL_NUMEV=1000 +fi + +if [[ ! -n "${CB_EMCAL_ENERGY}" ]] ; then + export CB_EMCAL_ENERGY=5.0 +fi + + +if [[ ! -n "${CB_EMCAL_SAMP_FRAC}" ]] ; then + export CB_EMCAL_SAMP_FRAC=0.014 +fi + +export CB_EMCAL_NAME_TAG="emcal_barrel_uniform_pions" +export CB_EMCAL_GEN_FILE="${CB_EMCAL_NAME_TAG}.hepmc" + +export CB_EMCAL_SIM_FILE="sim_${CB_EMCAL_NAME_TAG}.root" +export CB_EMCAL_REC_FILE="rec_${CB_EMCAL_NAME_TAG}.root" + +echo "CB_EMCAL_NUMEV = ${CB_EMCAL_NUMEV}" +echo "CB_EMCAL_COMPACT_PATH = ${CB_EMCAL_COMPACT_PATH}" + +# Generate the input events +python benchmarks/sampling_ecal/scripts/gen_particles.py ${CB_EMCAL_GEN_FILE} \ + --angmin 90 --angmax 90 --parray ${CB_EMCAL_ENERGY} --particles="-211" +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running script: generating input events" + exit 1 +fi + +ls -lh ${CB_EMCAL_GEN_FILE} + +# Run geant4 simulations +npsim --runType batch \ + -v WARNING \ + --part.minimalKineticEnergy 0.5*GeV \ + --numberOfEvents ${CB_EMCAL_NUMEV} \ + --compactFile ${CB_EMCAL_COMPACT_PATH} \ + --inputFiles ${CB_EMCAL_GEN_FILE} \ + --outputFile ${CB_EMCAL_SIM_FILE} + +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running npdet" + exit 1 +fi + +rootls -t "${CB_EMCAL_SIM_FILE}" + +# Directory for plots +mkdir -p results + +# CB_EMCAL_OPTION_DIR=${JUGGLER_INSTALL_PREFIX}/Examples/options +# CB_EMCAL_SCRIPT_DIR=${JUGGLER_INSTALL_PREFIX}/Examples/scripts/sampling_calorimeter +CB_EMCAL_OPTION_DIR=benchmarks/sampling_ecal/options +CB_EMCAL_SCRIPT_DIR=benchmarks/sampling_ecal/scripts + +# Run Juggler +# xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv gaudirun.py ${CB_EMCAL_OPTION_DIR}/sampling_cluster3d.py +gaudirun.py ${CB_EMCAL_OPTION_DIR}/sampling_cluster3d.py +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running juggler" + exit 1 +fi + +# check required python modules +python -m pip install -r benchmarks/sampling_ecal/requirements.txt + +# Run analysis script +python ${CB_EMCAL_SCRIPT_DIR}/draw_cluster_layers.py \ + ${CB_EMCAL_REC_FILE} -e 0 --topo-size=1.0 --compact=${CB_EMCAL_COMPACT_PATH} -o results/pions +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running analysis script: draw_cluster_layers" + exit 1 +fi + +python ${CB_EMCAL_SCRIPT_DIR}/draw_cluster.py \ + ${CB_EMCAL_REC_FILE} -e 0 --topo-size=2.0 --compact=${CB_EMCAL_COMPACT_PATH} -o results/pions +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running analysis script: draw_cluster" + exit 1 +fi + +python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \ + ${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/pions \ + --save=results/profile.csv --color=royalblue +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running analysis script: energy_profile" + exit 1 +fi + + +root_filesize=$(stat --format=%s "${CB_EMCAL_REC_FILE}") +if [[ "${CB_EMCAL_NUMEV}" -lt "500" ]] ; then + # file must be less than 10 MB to upload + if [[ "${root_filesize}" -lt "10000000" ]] ; then + cp ${CB_EMCAL_REC_FILE} results/. + fi +fi +