Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-20 08:45:49

0001 #!/usr/bin/env bash
0002 
0003 set -euo pipefail
0004 
0005 SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
0006 REPO_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
0007 SIMG4OX_BIN=${SIMG4OX_BIN:-simg4ox}
0008 OUTPUT_DIR=${1:-${REPO_DIR}/pfrich_timing}
0009 CONFIG_NAME=${2:-pfrich}
0010 
0011 mkdir -p "${OUTPUT_DIR}"
0012 OUTPUT_DIR=$(cd "${OUTPUT_DIR}" && pwd -P)
0013 
0014 export OPTICKS_HOME="${REPO_DIR}"
0015 export SIMPHONY_CONFIG_DIR="${SIMPHONY_CONFIG_DIR:-${REPO_DIR}/config}"
0016 export OPTICKS_EVENT_MODE=Minimal
0017 export PYTHONPATH="${REPO_DIR}${PYTHONPATH:+:${PYTHONPATH}}"
0018 export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}"
0019 
0020 CONFIG_PATH="${SIMPHONY_CONFIG_DIR}/${CONFIG_NAME}.json"
0021 mapfile -t PROFILE_CONFIG < <(
0022     python3 -c '
0023 import json
0024 import pathlib
0025 import sys
0026 
0027 with open(sys.argv[1], encoding="utf-8") as stream:
0028     config = json.load(stream)
0029 profile = config.get("event_timing", {}).get("profile", {})
0030 base = pathlib.Path(config.get("event", {}).get("output_dir", sys.argv[2]))
0031 if not base.is_absolute():
0032     base = pathlib.Path(sys.argv[2]) / base
0033 output = pathlib.Path(profile.get("output", "event_timing_profile.csv"))
0034 if not output.is_absolute():
0035     output = base / output
0036 path = str(output)
0037 if "%" in path:
0038     path %= int(profile.get("path_index", 0))
0039 print("1" if profile.get("enabled", False) else "0")
0040 print(path)
0041 ' "${CONFIG_PATH}" "${OUTPUT_DIR}"
0042 )
0043 PROFILE_ENABLED=${PROFILE_CONFIG[0]}
0044 PROFILE_CSV=${PROFILE_CONFIG[1]}
0045 rm -f -- "${PROFILE_CSV}"
0046 
0047 cd "${OUTPUT_DIR}"
0048 
0049 RUN_LOG="${OUTPUT_DIR}/simg4ox.stdout.log"
0050 
0051 if ! "${SIMG4OX_BIN}" \
0052     --gdml "${REPO_DIR}/tests/geom/pfrich_min_FINAL.gdml" \
0053     --macro "${REPO_DIR}/tests/run_pfrich_timing.mac" \
0054     --config "${CONFIG_NAME}" \
0055     --particle mu- \
0056     --momentum-gev-c 5 \
0057     --multiplicity 1 \
0058     --seed 42 > "${RUN_LOG}" 2>&1; then
0059     tail -n 100 "${RUN_LOG}" >&2
0060     exit 1
0061 fi
0062 
0063 grep -E "^(Primary source:|RunAction::EndOfRunAction:)" "${RUN_LOG}" || true
0064 
0065 python3 "${REPO_DIR}/tests/check_simg4ox_timing.py" \
0066     "${OUTPUT_DIR}/events.csv" \
0067     --events 3 \
0068     --particle mu- \
0069     --require-photons
0070 
0071 if [[ "${PROFILE_ENABLED}" == "1" ]]; then
0072     if [[ ! -f "${PROFILE_CSV}" ]]; then
0073         echo "Expected configured event timing profile: ${PROFILE_CSV}" >&2
0074         exit 1
0075     fi
0076     python3 "${REPO_DIR}/tests/check_event_timing_profile.py" "${PROFILE_CSV}"
0077 elif [[ -e "${PROFILE_CSV}" ]]; then
0078     echo "Detailed event timing profile was written while disabled: ${PROFILE_CSV}" >&2
0079     exit 1
0080 fi