4 # ------------------------------------------------------------------------------------------
 
    6 #                      Script to run K40 time calibration following HV tuning.
 
    8 # ------------------------------------------------------------------------------------------
 
   10 if [ -z $JPP_DIR ]; then
 
   11     echo "Variable JPP_DIR undefined."
 
   15 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
 
   17 set_variable:  DEBUG              CALIBRATION_DEBUG          1
 
   18 set_variable:  WORKDIR            CALIBRATION_WORKDIR        `pwd`
 
   19 set_variable:  DAQ_TIMESLICE      CALIBRATION_TIMESLICE      JDAQTimesliceL1
 
   20 set_variable+  DATABASE_OPTION    CALIBRATION_USEPMTID       -U
 
   21 set_variable+  MODEL              CALIBRATION_MODEL          -D
 
   24     usage "$script <detector file> <input file> <input file> <input file>"\
 
   25           "\nThe 1st and 3rd input file should correspond to a data taking run in which the HV settings are complete (e.g. \"vendor\" or \"tuned\")."\
 
   26           "\nThe 2nd input file should correspond to a run with hybrid HV settings."\
 
   27           "\nIn this, half of the PMTs should have the same HV settings as either the 1st or 3rd input file."
 
   30 if (( $# == 4 )); then
 
   31     set_variable  DETECTOR      $argv[1]
 
   32     set_array     INPUT_FILES   $argv[2,-1]
 
   34     fatal "Wrong number of arguments."
 
   40 # Get background option for given input file.
 
   47     if (( `JPrintTree -f $1 -@ "type = JDAQSummaryslice" -k number_of_entries` > 0 )); then
 
   56 # Standard calibration.
 
   63     JPrintDAQHeader -f $2  |  read  ID  RUN  FRAME_INDEX  UTC
 
   69         -o $WORKDIR/monitor_${RUN}.root              \
 
   74         -f $WORKDIR/monitor_${RUN}.root              \
 
   75         -o $WORKDIR/merge_${RUN}.root                \
 
   76         -@ "LIVETIME_S = 10"                         \
 
   79     JConvertDetectorFormat \
 
   81         -o $WORKDIR/detector_${RUN}.datx
 
   84         -a $WORKDIR/detector_${RUN}.datx             \
 
   85         -f $WORKDIR/merge_${RUN}.root                \
 
   86         -o $WORKDIR/fit_${RUN}.root                  \
 
   98 # \param   2     reference run
 
  103     JPrintDAQHeader -f $3  |  read  ID  RUN  FRAME_INDEX  UTC
 
  109         -o "$WORKDIR/TDC_${2}_${RUN}.txt"
 
  115         -o $WORKDIR/monitor_${RUN}.root              \
 
  120         -f $WORKDIR/monitor_${RUN}.root              \
 
  121         -o $WORKDIR/merge_${RUN}.root                \
 
  122         -@ "LIVETIME_S = 10"                         \
 
  125     JConvertDetectorFormat \
 
  127         -o $WORKDIR/detector_${RUN}.datx
 
  130         -a $WORKDIR/detector_${RUN}.datx             \
 
  131         -f $WORKDIR/merge_${RUN}.root                \
 
  132         -o $WORKDIR/fit_${RUN}.root                  \
 
  136         -! $WORKDIR/TDC_${2}_${RUN}.txt              \
 
  143 eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
 
  147 for INPUT_FILE in $INPUT_FILES[*]; do
 
  149     JPrintDAQHeader -f $INPUT_FILE  |  read  ID  RUN  FRAME_INDEX  UTC
 
  151     if (( $ID != $DETECTOR_ID )); then
 
  152         fatal "Detector identifier from $INPUT_FILE $ID != $DETECTOR_ID"
 
  160 calibrate  $DETECTOR  ${INPUT_FILES[1]}
 
  162 hybrid     $WORKDIR/detector_${RUNS[1]}.datx  ${RUNS[1]}   ${INPUT_FILES[2]}
 
  164 hybrid     $WORKDIR/detector_${RUNS[2]}.datx  ${RUNS[2]}   ${INPUT_FILES[3]}