Skip to content
Snippets Groups Projects
hc_shms_replay 2.53 KiB
Newer Older
  • Learn to ignore specific revisions
  • Whitney Armstrong's avatar
    Whitney Armstrong committed
    #!/bin/bash
    #set -u 
    
    function print_the_help {
      echo "USAGE: $0 -r <run_number> -n <num> "
      echo "  OPTIONS: "
      echo "            -r,--run           Required run number"
      echo "            -n,--n-events        Required number of eventsrun number"
    
      echo "            -j,--jlab          Run on the JLab farm"
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
      #echo "            -o,--online-only   Log online only"
      #echo "            -a,--all           Log all plots (online, detectors, physics)"
      #echo "            -n,--no-log        Do not submit any log entries"
      #echo "            -y,--yes           Automatically submit log entries (does not prompt for y/n)"
      exit 
    }
    
    function yes_or_no {
      while true; do
        read -p "$* [y/n]: " yn
        case $yn in
          [Yy]*) return 0 ;;
          [Nn]*) echo "No entered" ; return 1 ;;
        esac
      done
    }
    
    run_number=
    n_events=-1
    container=
    
    if [[ $# -eq 0 ]] ; then
      print_the_help
      exit 
    fi
    
    POSITIONAL=()
    while [[ $# -gt 0 ]]
    do
      key="$1"
    
      case $key in
        -h|--help)
          shift # past argument
          print_the_help
          ;;
        -r|--run)
          run_number="$2"
          shift # past argument
          shift # past value
          ;;
        -n|--n-events)
          n_events="$2"
          shift # past argument
          shift # past value
          ;;
    
        -j|--jlab)
          jlab_farm=1
          #shift # past argument
          shift # past value
          ;;
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
        #-c|--container)
        #  container=1
        #  #shift # past argument
        #  shift # past value
        #  ;;
        #-a|--all)
        #  LOG_ALL_PLOTS=1
        #  shift # past argument
        #  #shift # past value
        #  ;;
        #-o|--online-only)
        #  ONLINE_ONLY=1
        #  shift # past argument
        #  #shift # past value
        #  ;;
        *)    # unknown option
          #POSITIONAL+=("$1") # save it in an array for later
          echo "unknown option"
          print_the_help
          shift # past argument
          ;;
      esac
    done
    set -- "${POSITIONAL[@]}" # restore positional parameters
    
    if [[ -z ${n_events} ]] ; then
      echo  " need argument -n <num> "
    fi
    if [[ -z ${run_number} ]] ; then
      echo  " need argument -r <run> "
    fi
    
    #if [[ $# -eq 0 ]] ; then
    #  print_the_help
    #  exit 
    #fi
    
    
    if [[ -n ${jlab_farm} ]] ; then
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
    source /group/c-csv/local/setup.sh
    
    # For some reason the module files need to put in a specific order.
    # This is probably because we are using the old TCL version.
    
    #module unload csv/dev
    #module load csv/dev
    #module load tmux/latest
    #module load python/latest
    #module load python/2.7.15
    #module load python3/latest
    #module load vim/latest
    #module load git/latest
    #module load ruby/2.5.3
    fi
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
    
    
    hcana -b -q "scripts/replay_production_shms.cxx(${run_number},${n_events})"