Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-13 08:26:05

0001 #!/bin/bash
0002 
0003 #set -o errexit
0004 #set -o pipefail
0005 
0006 function print_the_help {
0007   echo "USAGE: ${0}  [--sim-only]  "
0008   echo "OPTIONS: "
0009   echo "  --sim-only    Only run up to the simulation "
0010   echo "  --analysis    Only run the analysis scripts "
0011   exit 
0012 }
0013 
0014 ANALYSIS_ONLY=
0015 SIM_ONLY=
0016 POSITIONAL=()
0017 
0018 while [[ $# -gt 0 ]]
0019 do
0020   key="$1"
0021 
0022   case $key in
0023     -h|--help)
0024       shift # past argument
0025       print_the_help
0026       ;;
0027     --sim-only)
0028       shift # past argument
0029       SIM_ONLY=1
0030       ;;
0031     --analysis)
0032       shift # past argument
0033       ANALYSIS_ONLY=1
0034       ;;
0035     *)    # unknown option
0036       #POSITIONAL+=("$1") # save it in an array for later
0037       echo "unknown option $1"
0038       print_the_help
0039       shift # past argument
0040       ;;
0041   esac
0042 done
0043 set -- "${POSITIONAL[@]}" # restore positional parameters
0044 
0045 ## To run the reconstruction, we need the following global variables:
0046 ## - DETECTOR:         the detector package we want to use for this benchmark
0047 ## - DETECTOR_VERSION: the detector package we want to use for this benchmark
0048 ## - DETECTOR_PATH:            full path to the detector definitions
0049 ##
0050 ## You can ready options/env.sh for more in-depth explanations of the variables
0051 ## and how they can be controlled.
0052 
0053 if [[ ! -n  "${JUGGLER_N_EVENTS}" ]] ; then 
0054   export JUGGLER_N_EVENTS=100
0055 fi
0056 
0057 export JUGGLER_FILE_NAME_TAG="track_hits"
0058 export JUGGLER_GEN_FILE="${LOCAL_DATA_PATH}/${JUGGLER_FILE_NAME_TAG}.hepmc"
0059 
0060 export JUGGLER_SIM_FILE="${LOCAL_DATA_PATH}/sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root"
0061 
0062 echo "JUGGLER_N_EVENTS = ${JUGGLER_N_EVENTS}"
0063 echo "DETECTOR = ${DETECTOR}"
0064 
0065 
0066 if [ -z "${ANALYSIS_ONLY}" ] ; then
0067 
0068   echo "Generating Events"
0069   ## generate the input events
0070   root -b -q "benchmarks/tracking_detectors/scripts/gen_track_hits.cxx(${JUGGLER_N_EVENTS}, \"${JUGGLER_FILE_NAME_TAG}.hepmc\")"
0071   if [[ "$?" -ne "0" ]] ; then
0072     echo "ERROR running script"
0073     exit 1
0074   fi
0075 
0076   echo "Running geant4 simulation"
0077   ## run geant4 simulations
0078   npsim --runType batch \
0079     --part.minimalKineticEnergy 1000*GeV  \
0080     --filter.tracker edep0 \
0081     -v WARNING \
0082     --numberOfEvents ${JUGGLER_N_EVENTS} \
0083     --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \
0084     --inputFiles  ${JUGGLER_FILE_NAME_TAG}.hepmc \
0085     --outputFile  ${JUGGLER_SIM_FILE}
0086   if [[ "$?" -ne "0" ]] ; then
0087     echo "ERROR running script"
0088     exit 1
0089   fi
0090 
0091 fi
0092 
0093 
0094 if [ -z "${SIM_ONLY}" ] ; then
0095 
0096   echo "Running analysis scripts"
0097 
0098   mkdir -p results/tracking_detectors
0099   rootls -t ${JUGGLER_SIM_FILE}
0100   root -b -q "benchmarks/tracking_detectors/analysis/sim_track_hits.cxx+(\"${JUGGLER_SIM_FILE}\")"
0101   if [[ "$?" -ne "0" ]] ; then
0102     echo "ERROR running root script"
0103     exit 1
0104   fi
0105 
0106 fi
0107 
0108 root_filesize=$(stat --format=%s "${JUGGLER_SIM_FILE}")
0109 if [[ "${JUGGLER_N_EVENTS}" -lt "500" ]] ; then 
0110   # file must be less than 10 MB to upload
0111   if [[ "${root_filesize}" -lt "10000000" ]] ; then 
0112     cp ${JUGGLER_SIM_FILE} results/.
0113   fi
0114 fi