4 if [ -z $JPP_DIR ]; then
 
    5     echo "Variable JPP_DIR undefined."
 
    9 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
 
   11 set_variable:  DEBUG       QAQC_DEBUG            2
 
   12 set_variable:  WORKDIR     QAQC_WORKDIR          `pwd`
 
   13 set_variable:  FORMAT      GRAPHICS_FORMAT       gif
 
   14 set_variable+  BATCH       GRAPHICS_BATCH        -B
 
   17     usage "$script [<detector identifier> <run range>] <QA/QC file>"\
 
   18           "\nExample script to produce data quality plots."\
 
   19           "\nWhen a detector identifier and run range are specified, data are downloaded from the database"\
 
   20           "\nand subsequently stored in the given QA/QC file, unless this file already exists."
 
   24     0)  fatal "Wrong number of arguments.";;
 
   25     3)  set_variable  DETECTOR_ID     $argv[1]
 
   26         set_variable  RANGE           $argv[2];&
 
   27     1)  set_variable  QUALITY_TXT     $argv[-1];;
 
   30 set_variable  FILEPREFIX    ${${QUALITY_TXT%%.*}##.*/}
 
   31 set_variable  QUALITY_ROOT  ${QUALITY_TXT%%.*}.root
 
   33 if (( $# == 3 )); then
 
   35     if ( ! reuse_file $QUALITY_TXT ); then
 
   41             -R "${RANGE%%-*} ${RANGE##*-}"                             \
 
   46         echo "Note that the specified detector identifer and runs are discarded."
 
   53     -R "${RANGE%%-*} ${RANGE##*-}"                                                           \
 
   55     -Q "livetime_s;                                                        1200     60000"   \
 
   56     -Q "(UTCMax_s - UTCMin_s) - livetime_s;                               -100     +100"     \
 
   57     -Q "JDAQEvent / livetime_s;                                            0.05     50.0"    \
 
   61     -Q "FIFO;                                                              0.00     0.01"    \
 
   62     -Q "MEAN_Rate_Hz;                                                      4500    15000"    \
 
   63     -Q "RMS_Rate_Hz;                                                       200      5000"    \
 
   64     -Q "Acoustics / livetime_s;                                            0.0      100.0"   \
 
   65     -Q "AHRS      / livetime_s;                                            0.0      100.0"   \
 
   66     -V "(JDAQEvent - JTriggerReprocessor) * 1.0 / (JDAQEvent + 1.0e-10);  -5.0e-3  +5.0e-3"  \
 
   76     -f ${QUALITY_ROOT}:h0                                          \
 
   78     -\^ "number of runs"                                           \
 
   80     -o $WORKDIR/${FILEPREFIX}_quality.${FORMAT}                    $BATCH
 
   83     -f ${QUALITY_ROOT}:h1                                          \
 
   84     -\^ "number of runs"                                           \
 
   86     -o $WORKDIR/${FILEPREFIX}_selection.${FORMAT}                  $BATCH
 
   90     -f ${QUALITY_ROOT}:VETO                                        \
 
   96     -o $WORKDIR/${FILEPREFIX}_veto.${FORMAT}                       $BATCH
 
  101     \^livetime_s\$                           livetime
 
  103     \^JDAQEvent\.\*livetime_s                event-rate
 
  104     \^\(JDAQEvent\.\*JTriggerReprocessor\)   event-count
 
  109     MEAN_Rate_Hz                             PMT-rate-mean
 
  110     RMS_Rate_Hz                              PMT-rate-rms
 
  111     \^out_sync\$                             out_sync
 
  112     \^out_usync\$                            out_usync
 
  116 for KEY VALUE in ${(@kv)BUFFER}; do
 
  120         -f ${QUALITY_ROOT}:${KEY}                                      \
 
  125         -o $WORKDIR/${FILEPREFIX}_${VALUE}.${FORMAT}                   $BATCH