Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:18:27

0001 #!/bin/bash
0002 source strict-mode.sh
0003 
0004 ## =============================================================================
0005 ## Run the DVMP benchmarks in 5 steps:
0006 ## 1. Parse the command line and setup environment
0007 ## 2. Detector simulation through ddsim
0008 ## 3. Digitization and reconstruction through Juggler
0009 ## 4. Root-based Physics analyses
0010 ## 5. Finalize
0011 ## =============================================================================
0012 
0013 ## make sure we launch this script from the project root directory
0014 PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/../..
0015 pushd ${PROJECT_ROOT}
0016 
0017 echo "Running the DVMP benchmarks"
0018 
0019 
0020 ## =============================================================================
0021 ## Step 1: Setup the environment variables
0022 ##
0023 ## First parse the command line flags.
0024 ## This sets the following environment variables:
0025 ## - CONFIG:   The specific generator configuration
0026 ## - EBEAM:    The electron beam energy
0027 ## - PBEAM:    The ion beam energy
0028 ## - DECAY:    The decay particle for the generator
0029 ## - LEADING:  Leading particle of interest (J/psi)
0030 export REQUIRE_DECAY=1
0031 export REQUIRE_LEADING=1
0032 source parse_cmd.sh $@
0033 
0034 ## We also need the following benchmark-specific variables:
0035 ##
0036 ## - BENCHMARK_TAG: Unique identified for this benchmark process.
0037 ## - BEAM_TAG:      Identifier for the chosen beam configuration
0038 ## - INPUT_PATH:    Path for generator-level input to the benchmarks
0039 ## - TMP_PATH:      Path for temporary data (not exported as artifacts)
0040 ## - RESULTS_PATH:  Path for benchmark output figures and files
0041 ##
0042 ## You can read dvmp/env.sh for more in-depth explanations of the variables.
0043 source benchmarks/Exclusive-Diffraction-Tagging/dvmp/env.sh
0044 
0045 ## Get a unique file names based on the configuration options
0046 GEN_FILE=${INPUT_PATH}/gen-${CONFIG}_${DECAY}_${JUGGLER_N_EVENTS}.hepmc
0047 
0048 SIM_FILE=${TMP_PATH}/sim-${CONFIG}_${DECAY}.edm4hep.root
0049 SIM_LOG=${TMP_PATH}/sim-${CONFIG}_${DECAY}.log
0050 
0051 
0052 REC_FILE=${TMP_PATH}/rec-${CONFIG}_${DECAY}.root
0053 REC_LOG=${TMP_PATH}/sim-${CONFIG}_${DECAY}.log
0054 
0055 PLOT_TAG=${CONFIG}_${DECAY}
0056 
0057 ## =============================================================================
0058 ## Step 2: Run the simulation
0059 echo "Running Geant4 simulation"
0060 ls -lrth 
0061 ls -lrth input
0062 echo ${TMP_PATH}
0063 ls -lrth ${TMP_PATH}
0064 ddsim --runType batch \
0065       --part.minimalKineticEnergy 100*GeV  \
0066       --filter.tracker edep0 \
0067       -v WARNING \
0068       --numberOfEvents ${JUGGLER_N_EVENTS} \
0069       --compactFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml \
0070       --inputFiles ${GEN_FILE} \
0071       --outputFile ${SIM_FILE}
0072 if [ "$?" -ne "0" ] ; then
0073   echo "ERROR running ddsim"
0074   exit 1
0075 fi
0076 
0077 ## =============================================================================
0078 ## Step 3: Run digitization & reconstruction
0079 echo "Running the digitization and reconstruction"
0080 ## FIXME Need to figure out how to pass file name to juggler from the commandline
0081 ## the tracker_reconstruction.py options file uses the following environment
0082 ## variables:
0083 ## - JUGGLER_SIM_FILE:    input detector simulation
0084 ## - JUGGLER_REC_FILE:    output reconstructed data
0085 ## - JUGGLER_N_EVENTS:    number of events to process (part of global environment)
0086 ## - DETECTOR:    detector package (part of global environment)
0087 export JUGGLER_SIM_FILE=${SIM_FILE}
0088 export JUGGLER_REC_FILE=${REC_FILE}
0089 if [ ${RECO} == "eicrecon" ] ; then
0090   eicrecon ${JUGGLER_SIM_FILE} -Ppodio:output_file=${JUGGLER_REC_FILE}
0091   if [[ "$?" -ne "0" ]] ; then
0092     echo "ERROR running eicrecon"
0093     exit 1
0094   fi
0095 fi
0096 
0097 if [[ ${RECO} == "juggler" ]] ; then
0098   gaudirun.py options/reconstruction.py || [ $? -eq 4 ]
0099   if [ "$?" -ne "0" ] ; then
0100     echo "ERROR running juggler"
0101     exit 1
0102   fi
0103 fi
0104 ## =============================================================================
0105 ## Step 4: Analysis
0106 
0107 ## write a temporary configuration file for the analysis script
0108 CONFIG="${TMP_PATH}/${PLOT_TAG}.json"
0109 cat << EOF > ${CONFIG}
0110 {
0111   "rec_file": "${REC_FILE}",
0112   "vm_name": "${LEADING}",
0113   "decay": "${DECAY}",
0114   "detector": "${DETECTOR_CONFIG}",
0115   "output_prefix": "${RESULTS_PATH}/${PLOT_TAG}",
0116   "test_tag": "${LEADING}_${DECAY}_${BEAM_TAG}"
0117 }
0118 EOF
0119 #cat ${CONFIG}
0120 
0121 ## run the analysis script with this configuration
0122 root -b -q "benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_mass.cxx+(\"${CONFIG}\")"
0123 if [ "$?" -ne "0" ] ; then
0124   echo "ERROR running vm_mass script"
0125   exit 1
0126 fi
0127 root -b -q "benchmarks/Exclusive-Diffraction-Tagging/dvmp/analysis/vm_invar.cxx+(\"${CONFIG}\")"
0128 if [ "$?" -ne "0" ] ; then
0129   echo "ERROR running vm_invar script"
0130   exit 1
0131 fi
0132 
0133 ## =============================================================================
0134 ## Step 5: finalize
0135 echo "Finalizing DVMP benchmark"
0136 
0137 ## Copy over reconsturction artifacts as long as we don't have
0138 ## too many events
0139 if [ "${JUGGLER_N_EVENTS}" -lt "500" ] ; then 
0140   cp ${REC_FILE} ${RESULTS_PATH}
0141 fi
0142 
0143 ## Always move over log files to the results path
0144 mv ${REC_LOG} ${RESULTS_PATH}
0145 
0146 
0147 ## cleanup output files
0148 #rm -f ${REC_FILE} ${SIM_FILE} ## --> not needed for CI
0149 
0150 ## =============================================================================
0151 ## All done!
0152 echo "DVMP benchmarks complete"