Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:02:38

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 print_env.sh
0046 
0047 ## To run the reconstruction, we need the following global variables:
0048 ## - DETECTOR:         the detector package we want to use for this benchmark
0049 ## - DETECTOR_VERSION: the detector package we want to use for this benchmark
0050 ## - DETECTOR_PATH:            full path to the detector definitions
0051 ##
0052 ## You can ready options/env.sh for more in-depth explanations of the variables
0053 ## and how they can be controlled.
0054 
0055 if [[ ! -n  "${JUGGLER_N_EVENTS}" ]] ; then 
0056   export JUGGLER_N_EVENTS=100
0057 fi
0058 
0059 export JUGGLER_FILE_NAME_TAG="track_hits"
0060 export JUGGLER_GEN_FILE="${LOCAL_DATA_PATH}/${JUGGLER_FILE_NAME_TAG}.hepmc"
0061 
0062 export JUGGLER_SIM_FILE="${LOCAL_DATA_PATH}/sim_${JUGGLER_FILE_NAME_TAG}.edm4hep.root"
0063 
0064 echo "JUGGLER_N_EVENTS = ${JUGGLER_N_EVENTS}"
0065 echo "DETECTOR = ${DETECTOR}"
0066 
0067 
0068 if [ -z "${ANALYSIS_ONLY}" ] ; then
0069 
0070   echo "Generating Events"
0071   ## generate the input events
0072   root -b -q "benchmarks/tracking_detectors/scripts/gen_track_hits.cxx(${JUGGLER_N_EVENTS}, \"${JUGGLER_FILE_NAME_TAG}.hepmc\")"
0073   if [[ "$?" -ne "0" ]] ; then
0074     echo "ERROR running script"
0075     exit 1
0076   fi
0077 
0078   echo "Running geant4 simulation"
0079   ## run geant4 simulations
0080   ddsim --runType batch \
0081     --part.minimalKineticEnergy 1000*GeV  \
0082     --filter.tracker edep0 \
0083     -v WARNING \
0084     --numberOfEvents ${JUGGLER_N_EVENTS} \
0085     --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \
0086     --inputFiles  ${JUGGLER_FILE_NAME_TAG}.hepmc \
0087     --outputFile  ${JUGGLER_SIM_FILE}
0088   if [[ "$?" -ne "0" ]] ; then
0089     echo "ERROR running script"
0090     exit 1
0091   fi
0092 
0093 fi
0094 
0095 
0096 if [ -z "${SIM_ONLY}" ] ; then
0097 
0098   echo "Running analysis scripts"
0099 
0100   mkdir -p results/tracking_detectors
0101   rootls -t ${JUGGLER_SIM_FILE}
0102   root -b -q "benchmarks/tracking_detectors/analysis/sim_track_hits.cxx+(\"${JUGGLER_SIM_FILE}\")"
0103   if [[ "$?" -ne "0" ]] ; then
0104     echo "ERROR running root script"
0105     exit 1
0106   fi
0107 
0108 fi
0109 
0110 root_filesize=$(stat --format=%s "${JUGGLER_SIM_FILE}")
0111 if [[ "${JUGGLER_N_EVENTS}" -lt "500" ]] ; then 
0112   # file must be less than 10 MB to upload
0113   if [[ "${root_filesize}" -lt "10000000" ]] ; then 
0114     cp ${JUGGLER_SIM_FILE} results/.
0115   fi
0116 fi
0117 
0118