| 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-2004
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | #
|
|---|
| 28 |
|
|---|
| 29 | source /home/operator/Mars/datacenter/scripts/sourcefile
|
|---|
| 30 |
|
|---|
| 31 | set -C
|
|---|
| 32 |
|
|---|
| 33 | table=SequenceProcessStatus
|
|---|
| 34 | column=fFillCallisto
|
|---|
| 35 | date=NULL
|
|---|
| 36 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 37 | year=`date +%Y`
|
|---|
| 38 |
|
|---|
| 39 | todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
|
|---|
| 40 | getstatuslogpath=$logpath/getstatus/fillcallisto/$year
|
|---|
| 41 | getstatuslog=$getstatuslogpath/getstatus-fillcallisto-$datetime.log
|
|---|
| 42 |
|
|---|
| 43 | scriptlogpath=$logpath/run/fillcallisto/`date +%Y/%m/%d`
|
|---|
| 44 | if [ ! -d $scriptlogpath ]
|
|---|
| 45 | then
|
|---|
| 46 | mkdir -pv $scriptlogpath
|
|---|
| 47 | if [ ! -d $scriptlogpath ]
|
|---|
| 48 | then
|
|---|
| 49 | echo "could not make scriptlogpath "$scriptlogpath
|
|---|
| 50 | exit
|
|---|
| 51 | fi
|
|---|
| 52 | fi
|
|---|
| 53 |
|
|---|
| 54 | scriptlog=$scriptlogpath/runfillcallisto-$datetime.log
|
|---|
| 55 |
|
|---|
| 56 | date >> $scriptlog 2>&1
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | if [ ! -d $getstatuslogpath ]
|
|---|
| 60 | then
|
|---|
| 61 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
|---|
| 62 | if [ ! -d $getstatuslogpath ]
|
|---|
| 63 | then
|
|---|
| 64 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
|---|
| 65 | date >> $scriptlog 2>&1
|
|---|
| 66 | exit
|
|---|
| 67 | fi
|
|---|
| 68 | fi
|
|---|
| 69 |
|
|---|
| 70 | cd $mars
|
|---|
| 71 |
|
|---|
| 72 | date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 73 | checklock0=$?
|
|---|
| 74 | case $checklock0 in
|
|---|
| 75 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
|---|
| 76 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
|---|
| 77 | echo "-> fillcallisto is running -> exit" >> $scriptlog 2>&1
|
|---|
| 78 | date >> $scriptlog 2>&1
|
|---|
| 79 | exit;;
|
|---|
| 80 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 81 | esac
|
|---|
| 82 |
|
|---|
| 83 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 84 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 85 |
|
|---|
| 86 | case $check0 in
|
|---|
| 87 | 1) echo "check0=$check0 -> everthing ok -> run fillcallisto" >> $scriptlog 2>&1;;
|
|---|
| 88 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 89 | esac
|
|---|
| 90 |
|
|---|
| 91 | sequences=(`cat $todofile`)
|
|---|
| 92 |
|
|---|
| 93 | if [ "$sequences" = "" ]
|
|---|
| 94 | then
|
|---|
| 95 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 96 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 97 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 98 | date >> $scriptlog 2>&1
|
|---|
| 99 | exit
|
|---|
| 100 | fi
|
|---|
| 101 |
|
|---|
| 102 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
|---|
| 103 |
|
|---|
| 104 | for sequence in ${sequences[@]}
|
|---|
| 105 | do
|
|---|
| 106 | no=`printf %08d $sequence | cut -c 0-4`
|
|---|
| 107 | no2=`printf %08d $sequence`
|
|---|
| 108 | path="/magic/data/callisto/$no/$no2"
|
|---|
| 109 | signalfile=$path/signal$no2.root
|
|---|
| 110 | calibfile=$path/calib$no2.root
|
|---|
| 111 | fillcallistologpath=$logpath/fillcallisto/$no
|
|---|
| 112 | echo "fillcallistologpath: "$fillcallistologpath >> $scriptlog 2>&1
|
|---|
| 113 | if [ ! -d $fillcallistologpath ]
|
|---|
| 114 | then
|
|---|
| 115 | mkdir -pv $fillcallistologpath >> $scriptlog 2>&1
|
|---|
| 116 | if [ ! -d $fillcallistologpath ]
|
|---|
| 117 | then
|
|---|
| 118 | echo "could not make fillcallistologpath $fillcallistologpath -> continue " >> $scriptlog 2>&1
|
|---|
| 119 | continue
|
|---|
| 120 | fi
|
|---|
| 121 | fi
|
|---|
| 122 | fillcaliblog=$fillcallistologpath/fillcalib-$sequence.log
|
|---|
| 123 | fillsignallog=$fillcallistologpath/fillsignal-$sequence.log
|
|---|
| 124 |
|
|---|
| 125 | echo "run fillcallisto for sequence $sequence" >> $scriptlog 2>&1
|
|---|
| 126 | echo "run fillcalib..." >> $scriptlog 2>&1
|
|---|
| 127 | check1=`root -q -b $macrospath/fillcalib.C+\("\"$calibfile\""\,kFALSE\) | tee $fillcaliblog | grep int | sed -e 's/(int)//'`
|
|---|
| 128 |
|
|---|
| 129 | case $check1 in
|
|---|
| 130 | 1) echo "check1=$check1 -> everthing ok -> run fillsignal " >> $scriptlog 2>&1;;
|
|---|
| 131 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 132 | continue;;
|
|---|
| 133 | esac
|
|---|
| 134 |
|
|---|
| 135 | check2=`root -q -b $macrospath/fillsignal.C+\("\"$signalfile\""\,kFALSE\) | tee $fillsignallog | grep int | sed -e 's/(int)//'`
|
|---|
| 136 | case $check2 in
|
|---|
| 137 | 1) echo "check2=$check2 -> everthing ok " >> $scriptlog 2>&1
|
|---|
| 138 | echo "-> inserting the status for fillcallisto for sequence $sequence into the db" >> $scriptlog 2>&1
|
|---|
| 139 | setstatuslogpath=$logpath/setstatus/fillcallisto/$no
|
|---|
| 140 | if [ ! -d $setstatuslogpath ]
|
|---|
| 141 | then
|
|---|
| 142 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 143 | if [ ! -d $setstatuslogpath ]
|
|---|
| 144 | then
|
|---|
| 145 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 146 | continue
|
|---|
| 147 | fi
|
|---|
| 148 | fi
|
|---|
| 149 | setstatuslog=$setstatuslogpath/setstatus-fillcallisto
|
|---|
| 150 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog-$sequence.log | grep int | sed -e 's/(int)//'`
|
|---|
| 151 | case $check4 in
|
|---|
| 152 | 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
|---|
| 153 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
|---|
| 154 | esac
|
|---|
| 155 | ;;
|
|---|
| 156 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 157 | esac
|
|---|
| 158 | done
|
|---|
| 159 |
|
|---|
| 160 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 161 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
|---|
| 162 |
|
|---|
| 163 | set +C
|
|---|
| 164 |
|
|---|
| 165 | date >> $scriptlog 2>&1
|
|---|
| 166 |
|
|---|