Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:30:50

0001 #!/bin/bash
0002 source strict-mode.sh
0003 
0004 function print_the_help {
0005   echo "USAGE: ${0} [--rec] [--sim] [--analysis] [--all] "
0006   echo "    The default options are to run all steps (sim,rec,analysis) "
0007   echo "OPTIONS: "
0008   echo "  --data-init     download the input event data"
0009   echo "  --sim,-s        Runs the Geant4 simulation"
0010   echo "  --rec,-r        Run the juggler reconstruction"
0011   echo "  --analysis,-a   Run the analysis scripts"
0012   echo "  --all           (default) Do all steps. Argument is included so usage can convey intent."
0013   exit 
0014 }
0015 
0016 DO_ALL=1
0017 DATA_INIT=
0018 DO_SIM=
0019 DO_REC=
0020 DO_ANALYSIS=
0021 
0022 POSITIONAL=()
0023 while [[ $# -gt 0 ]]
0024 do
0025   key="$1"
0026 
0027   case $key in
0028     -h|--help)
0029       shift # past argument
0030       print_the_help
0031       ;;
0032     --all)
0033       DO_ALL=2
0034       if [[ ! "${DO_REC}${DO_SIM}${DO_ANALYSIS}" -eq "" ]] ; then
0035         echo "Error: cannot use --all with other arguments." 1>&2
0036         print_the_help
0037         exit 1
0038       fi
0039       shift # past value
0040       ;;
0041     -s|--sim)
0042       DO_SIM=1
0043       DO_ALL=
0044       shift # past value
0045       ;;
0046     --data-init)
0047       DATA_INIT=1
0048       DO_ALL=
0049       shift # past value
0050       ;;
0051     -r|--rec)
0052       DO_REC=1
0053       DO_ALL=
0054       shift # past value
0055       ;;
0056     -a|--analysis)
0057       DO_ANALYSIS=1
0058       DO_ALL=
0059       shift # past value
0060       ;;
0061     *)    # unknown option
0062       #POSITIONAL+=("$1") # save it in an array for later
0063       echo "unknown option $1"
0064       print_the_help
0065       shift # past argument
0066       ;;
0067   esac
0068 done
0069 set -- "${POSITIONAL[@]}" # restore positional parameters
0070 
0071 # assuming something like .local/bin/env.sh has already been sourced.
0072 print_env.sh
0073 
0074 FILE_NAME_TAG="dvcs"
0075 XROOTD_BASEURL="root://dtn-eic.jlab.org//work/eic2/EPIC"
0076 INPUT_FILE="EVGEN/EXCLUSIVE/DVCS_ABCONV/10x100/DVCS.1.ab.hiDiv.10x100.hepmc3.tree.root"
0077 
0078 export JUGGLER_MC_FILE="${XROOTD_BASEURL}/${INPUT_FILE}"
0079 export JUGGLER_SIM_FILE="${LOCAL_DATA_PATH}/sim_${FILE_NAME_TAG}.edm4hep.root"
0080 export JUGGLER_REC_FILE="${LOCAL_DATA_PATH}/rec_${FILE_NAME_TAG}.root"
0081 
0082 echo "FILE_NAME_TAG       = ${FILE_NAME_TAG}"
0083 echo "JUGGLER_N_EVENTS    = ${JUGGLER_N_EVENTS}"
0084 echo "DETECTOR    = ${DETECTOR}"
0085 
0086 
0087 ## To run the reconstruction, we need the following global variables:
0088 ## - DETECTOR:       the detector package we want to use for this benchmark
0089 ## - DETECTOR_PATH:          full path to the detector definitions
0090 
0091 ### Step 1. Run the simulation (geant4)
0092 if [[ -n "${DO_SIM}" || -n "${DO_ALL}" ]] ; then
0093   ## run geant4 simulations
0094   ddsim --runType batch \
0095     --part.minimalKineticEnergy 1000*GeV  \
0096     --filter.tracker edep0 \
0097     -v ERROR \
0098     --numberOfEvents ${JUGGLER_N_EVENTS} \
0099     --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \
0100     --inputFiles "${JUGGLER_MC_FILE}" \
0101     --outputFile  ${JUGGLER_SIM_FILE}
0102   if [[ "$?" -ne "0" ]] ; then
0103     echo "ERROR running ddsim"
0104     exit 1
0105   fi
0106 fi
0107 
0108 ### Step 2. Run the reconstruction (eicrecon)
0109 if [[ -n "${DO_REC}" || -n "${DO_ALL}" ]] ; then
0110   if [ ${RECO} == "eicrecon" ] ; then
0111     eicrecon ${JUGGLER_SIM_FILE} -Ppodio:output_file=${JUGGLER_REC_FILE}
0112     if [[ "$?" -ne "0" ]] ; then
0113       echo "ERROR running eicrecon"
0114       exit 1
0115     fi
0116   fi
0117 
0118   if [[ ${RECO} == "juggler" ]] ; then
0119     gaudirun.py options/reconstruction.py || [ $? -eq 4 ]
0120     if [ "$?" -ne "0" ] ; then
0121       echo "ERROR running juggler"
0122       exit 1
0123     fi
0124   fi
0125   root_filesize=$(stat --format=%s "${JUGGLER_REC_FILE}")
0126   if [[ "${JUGGLER_N_EVENTS}" -lt "500" ]] ; then 
0127     # file must be less than 10 MB to upload
0128     if [[ "${root_filesize}" -lt "10000000" ]] ; then 
0129       cp ${JUGGLER_REC_FILE} results/.
0130     fi
0131   fi
0132 fi
0133 
0134 ### Step 3. Run the analysis code
0135 if [[ -n "${DO_ANALYSIS}" || -n "${DO_ALL}" ]] ; then
0136   echo "Running analysis scripts"
0137   rootls -t  ${JUGGLER_REC_FILE}
0138 
0139   # Store all plots here (preferribly png and pdf files)
0140   mkdir -p results/dvcs
0141 
0142   # here you can add as many scripts as you want.
0143   root -b -q "benchmarks/Exclusive-Diffraction-Tagging/dvcs/analysis/dvcs_tests.cxx+(\"${JUGGLER_REC_FILE}\")"
0144   if [[ "$?" -ne "0" ]] ; then
0145     echo "ERROR running root script"
0146     exit 1
0147   fi
0148 fi
0149 
0150 
0151