| 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-2006
|
|---|
| 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
|
|---|
| 31 | # written by using the macro getdolist.C
|
|---|
| 32 | # Then for each run the timing correction is done
|
|---|
| 33 | # If this was successful, the status is inserted into the database using
|
|---|
| 34 | # the macro setstatus.C
|
|---|
| 35 | #
|
|---|
| 36 | # This script was needed for the data between 06/2004 and 02/2005 (including
|
|---|
| 37 | # this months).
|
|---|
| 38 | #
|
|---|
| 39 |
|
|---|
| 40 | program=correct_raw_time
|
|---|
| 41 | source `dirname $0`/sourcefile
|
|---|
| 42 |
|
|---|
| 43 | table=RunProcessStatus
|
|---|
| 44 | column=fTimingCorrection
|
|---|
| 45 |
|
|---|
| 46 | todofile=$listpath/ToDo-$table-$column.txt
|
|---|
| 47 | lockfile=$lockpath/lock-$program.txt
|
|---|
| 48 |
|
|---|
| 49 | if [ -e $todofile ]
|
|---|
| 50 | then
|
|---|
| 51 | echo "$program is already running -> exit"
|
|---|
| 52 | exit
|
|---|
| 53 | fi
|
|---|
| 54 |
|
|---|
| 55 | cd $mars
|
|---|
| 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"
|
|---|
| 65 | finish >> $scriptlog 2>&1
|
|---|
| 66 | fi
|
|---|
| 67 |
|
|---|
| 68 | echo "runs: "${runs[@]}
|
|---|
| 69 | for run in ${runs[@]}
|
|---|
| 70 | do
|
|---|
| 71 | no=`printf %08d $run | cut -c 1-5`
|
|---|
| 72 | var1=$no
|
|---|
| 73 | var2=$run
|
|---|
| 74 | echo "getting path for run $run ... "
|
|---|
| 75 | infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*`
|
|---|
| 76 | echo "infile:"$infile
|
|---|
| 77 | outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
|
|---|
| 78 | echo "outfile:"$outfile
|
|---|
| 79 | outpath=`dirname $outfile`
|
|---|
| 80 | echo "outpath:"$outpath
|
|---|
| 81 | makedir $outpath
|
|---|
| 82 |
|
|---|
| 83 | timecorrpath=$outpath"/timecorrlogs"
|
|---|
| 84 | echo "timecorrpath: "$timecorrpath
|
|---|
| 85 | makedir $timecorrpath
|
|---|
| 86 |
|
|---|
| 87 | check1=0
|
|---|
| 88 | echo "run $program..." >> $scriptlog 2>&1
|
|---|
| 89 | setstatus "start" >> $scriptlog 2>&1
|
|---|
| 90 |
|
|---|
| 91 | /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/$program-$run.log
|
|---|
| 92 | check1=$?
|
|---|
| 93 |
|
|---|
| 94 | case $check1 in
|
|---|
| 95 | 1) echo "check1=$check1 -> everything ok -> setting status..." >> $scriptlog 2>&1 ;;
|
|---|
| 96 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 97 | com=$Ftimecorr
|
|---|
| 98 | check=$check1
|
|---|
| 99 | ;;
|
|---|
| 100 | esac
|
|---|
| 101 | echo "inserting the status for $program for run $run into the db" >> $scriptlog 2>&1
|
|---|
| 102 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 103 | done
|
|---|
| 104 |
|
|---|
| 105 | finish >> $scriptlog 2>&1
|
|---|
| 106 |
|
|---|