| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # ========================================================================
|
|---|
| 4 | #
|
|---|
| 5 | # *
|
|---|
| 6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 7 | # * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 9 | # * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 10 | # *
|
|---|
| 11 | # * Permission to use, copy, modify and distribute this software and its
|
|---|
| 12 | # * documentation for any purpose is hereby granted without fee,
|
|---|
| 13 | # * provided that the above copyright notice appear in all copies and
|
|---|
| 14 | # * that both that copyright notice and this permission notice appear
|
|---|
| 15 | # * in supporting documentation. It is provided "as is" without express
|
|---|
| 16 | # * or implied warranty.
|
|---|
| 17 | # *
|
|---|
| 18 | #
|
|---|
| 19 | #
|
|---|
| 20 | # Author(s): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | # This script runs the timing correction for all run, that need the timing
|
|---|
| 28 | # correction
|
|---|
| 29 | #
|
|---|
| 30 | # After checking if the script is already running the todolist is written.
|
|---|
| 31 | # Then for each run the timing correction is done
|
|---|
| 32 | # If this was successful, the status is inserted into the database using
|
|---|
| 33 | # the function setstatus.
|
|---|
| 34 | #
|
|---|
| 35 | # This script was needed for the data between 06/2004 and 02/2005 (including
|
|---|
| 36 | # this months).
|
|---|
| 37 | #
|
|---|
| 38 |
|
|---|
| 39 | source `dirname $0`/sourcefile
|
|---|
| 40 | printprocesslog "INFO starting $0"
|
|---|
| 41 | echo "This script has not been adapted to the new file structure (MAGIC II). "
|
|---|
| 42 | echo "Please adapt it before using it."
|
|---|
| 43 | exit
|
|---|
| 44 |
|
|---|
| 45 | program=correct_raw_time
|
|---|
| 46 | column=fTimingCorrection
|
|---|
| 47 |
|
|---|
| 48 | scriptlog=$runlogpath/$program-$datetime.log
|
|---|
| 49 | date >> $scriptlog 2>&1
|
|---|
| 50 |
|
|---|
| 51 | if [ -e $todofile ]
|
|---|
| 52 | then
|
|---|
| 53 | echo "$program is already running -> exit" >> $scriptlog 2>&1
|
|---|
| 54 | exit
|
|---|
| 55 | fi
|
|---|
| 56 |
|
|---|
| 57 | # get todo list
|
|---|
| 58 | getdolist >> $scriptlog 2>&1
|
|---|
| 59 |
|
|---|
| 60 | # retrieving runs from todo file
|
|---|
| 61 | runs=(`cat $listpath/ToDo-$table-$column.txt`)
|
|---|
| 62 | if [ "$runs" = "" ]
|
|---|
| 63 | then
|
|---|
| 64 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 65 | finish >> $scriptlog 2>&1
|
|---|
| 66 | fi
|
|---|
| 67 | echo "runs: "${runs[@]} >> $scriptlog 2>&1
|
|---|
| 68 |
|
|---|
| 69 | cd $mars
|
|---|
| 70 |
|
|---|
| 71 | for run in ${runs[@]}
|
|---|
| 72 | do
|
|---|
| 73 | printprocesslog "INFO run correct_raw_time for run $run"
|
|---|
| 74 | no=`printf %08d $run | cut -c 1-5`
|
|---|
| 75 | echo "getting path for run $run ... " >> $scriptlog 2>&1
|
|---|
| 76 | infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[DCPS]_*`
|
|---|
| 77 | echo "infile:"$infile >> $scriptlog 2>&1
|
|---|
| 78 | outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
|
|---|
| 79 | echo "outfile:"$outfile >> $scriptlog 2>&1
|
|---|
| 80 | outpath=`dirname $outfile`
|
|---|
| 81 | echo "outpath:"$outpath >> $scriptlog 2>&1
|
|---|
| 82 | makedir $outpath >> $scriptlog 2>&1
|
|---|
| 83 |
|
|---|
| 84 | timecorrpath=$outpath"/timecorrlogs"
|
|---|
| 85 | echo "timecorrpath: "$timecorrpath >> $scriptlog 2>&1
|
|---|
| 86 | makedir $timecorrpath >> $scriptlog 2>&1
|
|---|
| 87 |
|
|---|
| 88 | check1=0
|
|---|
| 89 | echo "run $program..." >> $scriptlog 2>&1
|
|---|
| 90 | primvar=$run
|
|---|
| 91 | setstatus "start" >> $scriptlog 2>&1
|
|---|
| 92 |
|
|---|
| 93 | /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/$program-$run.log
|
|---|
| 94 | check1=$?
|
|---|
| 95 |
|
|---|
| 96 | case $check1 in
|
|---|
| 97 | 1) echo " check1=$check1 -> everything ok -> setting status..." >> $scriptlog 2>&1 ;;
|
|---|
| 98 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 99 | printprocesslog "ERROR $program failed"
|
|---|
| 100 | com=$Ftimecorr
|
|---|
| 101 | check=$check1
|
|---|
| 102 | ;;
|
|---|
| 103 | esac
|
|---|
| 104 |
|
|---|
| 105 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 106 | done
|
|---|
| 107 |
|
|---|
| 108 | finish >> $scriptlog 2>&1
|
|---|
| 109 |
|
|---|