Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-20 08:28:44

0001 #!/bin/bash
0002 
0003 ## =============================================================================
0004 ## Shared step-control functions for Exclusive-Diffraction-Tagging benchmarks.
0005 ##
0006 ## Source this file (do not run it directly). It defines:
0007 ##
0008 ##   print_step_options_help  - prints the step-option help text; call this from
0009 ##                              the sourcing script's print_the_help function
0010 ##   parse_step_options "$@"  - parses step-control flags and sets:
0011 ##                                DO_ALL, DATA_INIT, DO_SIM, DO_REC, DO_ANALYSIS
0012 ##                              Calls print_the_help (must be defined by caller)
0013 ##                              on -h/--help or unknown options.
0014 ##
0015 ## Usage in a benchmark script:
0016 ##
0017 ##   source benchmarks/Exclusive-Diffraction-Tagging/options.sh
0018 ##
0019 ##   function print_the_help {
0020 ##     echo "USAGE: ${0} [--sim] [--rec] [--analysis] [--all]"
0021 ##     print_step_options_help
0022 ##     exit
0023 ##   }
0024 ##
0025 ##   parse_step_options "$@"
0026 ##
0027 ## =============================================================================
0028 
0029 function print_step_options_help {
0030   echo "    The default behavior is to run all steps (sim, rec, analysis)."
0031   echo "STEP OPTIONS:"
0032   echo "  --data-init     Download the input event data"
0033   echo "  --sim, -s       Run the Geant4 simulation"
0034   echo "  --rec, -r       Run the reconstruction"
0035   echo "  --analysis, -a  Run the analysis scripts"
0036   echo "  --all           (default) Run all steps"
0037   echo "  -h, --help      Print this message"
0038 }
0039 
0040 function parse_step_options {
0041   DO_ALL=1
0042   DATA_INIT=
0043   DO_SIM=
0044   DO_REC=
0045   DO_ANALYSIS=
0046 
0047   while [[ $# -gt 0 ]]; do
0048     key="$1"
0049     case $key in
0050       -h|--help)
0051         print_the_help
0052         ;;
0053       --all)
0054         DO_ALL=1
0055         if [[ -n "${DO_REC}${DO_SIM}${DO_ANALYSIS}" ]]; then
0056           echo "Error: cannot use --all with other step arguments." 1>&2
0057           print_the_help
0058           exit 1
0059         fi
0060         shift
0061         ;;
0062       -s|--sim)
0063         DO_SIM=1
0064         DO_ALL=
0065         shift
0066         ;;
0067       --data-init)
0068         DATA_INIT=1
0069         DO_ALL=
0070         shift
0071         ;;
0072       -r|--rec)
0073         DO_REC=1
0074         DO_ALL=
0075         shift
0076         ;;
0077       -a|--analysis)
0078         DO_ANALYSIS=1
0079         DO_ALL=
0080         shift
0081         ;;
0082       *)
0083         echo "unknown option '$1'" 1>&2
0084         print_the_help
0085         exit 1
0086         ;;
0087     esac
0088   done
0089 }