Skip to content
Snippets Groups Projects
monitor_singles 2.58 KiB
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/bash
    
    function print_the_help {
      echo "USAGE:    monitor_singles [-r run_number] [-n nevents]"
      echo "OPTIONS:                    "
      echo "            -I,--no-update  Don't update run info or charge goals. Also set when count goal = 0."
      echo "            -r,--run        run number [default: most current run]"
      echo "            -m,--mode       DAQ mode, ['coin' (default), 'shms', 'hms']"
      echo "            -n,--nevents    Number of events to replay. [default: -1 (full replay)]"
      echo "            -h,--help       print help"
      echo "                                                                         "
      echo "  This script will do the following:            "
      echo "   1. Replay the data using the latest run and 100k events if not specified. "
      echo "   2. Run the good event counters"
      echo "   4. Fill a json database with useful run information."
      echo "        db2/run_list.json         (read only)"
      echo "        db2/run_hms_count_list.json"
      echo "        db2/run_shms_count_list.json"
      echo "         "
      echo "EXAMPLES:"
      echo "          "
      echo "process a full run in coin mode (default) "
      echo "    $ do_good_coin -n -1 -r 1234    "
      echo "           "
      echo "CONTACT:  Sylvester Joosten (sjjooste@jlab.org) 217-848-0565"
      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
    }
    
    
    if [[ $# -eq 0 ]] ; then
      print_the_help
      exit 
    fi
    
    daq_mode='coin'
    num_events=-1
    run_number=$(latest_run -t shms)
    update_run_info=0
    
    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|--nevents)
          num_events="$2"
          shift # past argument
          shift # past value
          ;;
        -m|--mode)
          daq_mode="$2"
          shift # past argument
          shift # past value
          ;;
        -I|--no-update)
          update_run_info=0
          shift # past argument
          ;;
        *)    # unknown option
          #POSITIONAL+=("$1") # save it in an array for later
          echo "unknown option $1"
          print_the_help
          shift # past argument
          ;;
      esac
    done
    set -- "${POSITIONAL[@]}" # restore positional parameters
    
    pushd $CURRENT_REPLAY_DIR
    
    if [ "$daq_mode" != "shms" ]; then
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
    root -b -q "scripts/good_hms_counter.cxx+(${run_number}, ${num_events}, \"${daq_mode}\")"
    
    fi
    if [ "$daq_mode" != "hms" ]; then
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
    root -b -q "scripts/good_shms_counter.cxx+(${run_number}, ${num_events}, \"${daq_mode}\")"