| 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 launches the datacheck for all runs, which are not yet
|
|---|
| 28 | # checked
|
|---|
| 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 following steps are done:
|
|---|
| 33 | # - filldotraw.C
|
|---|
| 34 | # - sinope (once for data and once for calibration events)
|
|---|
| 35 | # - fillsinope
|
|---|
| 36 | # - reset ExclusionsDone, so that the result from the datacheck can be
|
|---|
| 37 | # taken into account when doexclusions is running the next time
|
|---|
| 38 | # If this was successful, the status is inserted into the database using
|
|---|
| 39 | # the macro setstatus.C
|
|---|
| 40 | #
|
|---|
| 41 |
|
|---|
| 42 | program=datacheck
|
|---|
| 43 | source `dirname $0`/sourcefile
|
|---|
| 44 |
|
|---|
| 45 | set -C
|
|---|
| 46 |
|
|---|
| 47 | cd $mars
|
|---|
| 48 |
|
|---|
| 49 | table=RunProcessStatus
|
|---|
| 50 | column=fDataCheckDone
|
|---|
| 51 |
|
|---|
| 52 | todofile=$listpath/ToDo-$table-$column
|
|---|
| 53 | lockfile=$lockpath/lock-getting-$program-list.txt
|
|---|
| 54 |
|
|---|
| 55 | scriptlogpath=$logpath/run/$program/`date +%Y/%m`
|
|---|
| 56 | makedir $scriptlogpath
|
|---|
| 57 | scriptlog=$scriptlogpath/$program-$datetime.log
|
|---|
| 58 |
|
|---|
| 59 | date >> $scriptlog 2>&1
|
|---|
| 60 |
|
|---|
| 61 | # check if there are already todo files
|
|---|
| 62 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
|---|
| 63 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
|---|
| 64 | then
|
|---|
| 65 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
|---|
| 66 | echo " -> choose one file and start $program " >> $scriptlog 2>&1
|
|---|
| 67 | else
|
|---|
| 68 | # check if getting of list is already running
|
|---|
| 69 | checklock "getting list of" >> $scriptlog 2>&1
|
|---|
| 70 | # get todo list
|
|---|
| 71 | getdolist >> $scriptlog 2>&1
|
|---|
| 72 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 73 | fi
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 | # finding a todo file
|
|---|
| 77 | nr=bla
|
|---|
| 78 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
|---|
| 79 | todofiles=`ls -r $listpath/ToDo-$table-$column-*`
|
|---|
| 80 |
|
|---|
| 81 | echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
|
|---|
| 82 | for todofile in ${todofiles[@]}
|
|---|
| 83 | do
|
|---|
| 84 | if ! ls $todofile >> $scriptlog 2>&1
|
|---|
| 85 | then
|
|---|
| 86 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
|---|
| 87 | continue
|
|---|
| 88 | fi
|
|---|
| 89 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
|---|
| 90 | date > $lockfile >> $scriptlog 2>&1
|
|---|
| 91 | checklock=$?
|
|---|
| 92 | case $checklock in
|
|---|
| 93 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
|---|
| 94 | nr=${i}
|
|---|
| 95 | break;;
|
|---|
| 96 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
|---|
| 97 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 98 | esac
|
|---|
| 99 | done
|
|---|
| 100 |
|
|---|
| 101 | case $nr in
|
|---|
| 102 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
|---|
| 103 | date >> $scriptlog 2>&1
|
|---|
| 104 | exit;;
|
|---|
| 105 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
|---|
| 106 | esac
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | # get run(s) from todo file
|
|---|
| 110 | runs=(`cat $todofile`)
|
|---|
| 111 | if [ "$runs" = "" ]
|
|---|
| 112 | then
|
|---|
| 113 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 114 | finish >> $scriptlog 2>&1
|
|---|
| 115 | fi
|
|---|
| 116 |
|
|---|
| 117 | # processing run(s)
|
|---|
| 118 | echo "runs: "${runs[@]} >> $scriptlog 2>&1
|
|---|
| 119 | for run in ${runs[@]}
|
|---|
| 120 | do
|
|---|
| 121 | echo "do $program for run "$run >> $scriptlog 2>&1
|
|---|
| 122 | no=`printf %08d $run | cut -c 0-2`
|
|---|
| 123 | no2=`printf %08d $run`
|
|---|
| 124 | var1=$date
|
|---|
| 125 | var2=$no2
|
|---|
| 126 | rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[D,P,C,S]_*_E.raw.gz`
|
|---|
| 127 | echo "rawfile: "$rawfile >> $scriptlog 2>&1
|
|---|
| 128 | date=`echo $rawfile | cut -c 22-31`
|
|---|
| 129 | echo "date: "$date >> $scriptlog 2>&1
|
|---|
| 130 | # for sinope the date is needed in the format YYYY-MM-DD
|
|---|
| 131 | date2=`echo $date | sed -e 's/\//-/g'`
|
|---|
| 132 | echo "date2: "$date2 >> $scriptlog 2>&1
|
|---|
| 133 |
|
|---|
| 134 | # running filldotraw
|
|---|
| 135 | filldotrawpath=$logpath/filldotraw/$date
|
|---|
| 136 | makedir $filldotrawpath >> $scriptlog 2>&1
|
|---|
| 137 | filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
|
|---|
| 138 |
|
|---|
| 139 | echo "doing filldotraw..." >> $scriptlog 2>&1
|
|---|
| 140 | setstatus "start" >> $scriptlog 2>&1
|
|---|
| 141 |
|
|---|
| 142 | check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
|
|---|
| 143 |
|
|---|
| 144 | case $check1 in
|
|---|
| 145 | 1) echo "check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
|---|
| 146 | ;;
|
|---|
| 147 | 0) echo "check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
|---|
| 148 | check="no"
|
|---|
| 149 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 150 | continue ;;
|
|---|
| 151 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 152 | com=$Ffillraw
|
|---|
| 153 | check=$check1
|
|---|
| 154 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 155 | continue ;;
|
|---|
| 156 | esac
|
|---|
| 157 |
|
|---|
| 158 | # running sinope
|
|---|
| 159 | sinopepath=$datapath/sinope/$date
|
|---|
| 160 | makedir $sinopepath >> $scriptlog 2>&1
|
|---|
| 161 |
|
|---|
| 162 | sins=( "-dat" "-cal")
|
|---|
| 163 | echo ${sins[@]} >> $scriptlog 2>&1
|
|---|
| 164 | for sin in ${sins[@]}
|
|---|
| 165 | do
|
|---|
| 166 | sinopefile=sinope$sin$no2
|
|---|
| 167 | echo $sinopefile >> $scriptlog 2>&1
|
|---|
| 168 |
|
|---|
| 169 | echo "running sinope $sin..." >> $scriptlog 2>&1
|
|---|
| 170 | ./sinope -b -q -v4 -f $sin --outf=$sinopefile --out=$sinopepath --log=$sinopepath/$sinopefile.log --html=$sinopepath/$sinopefile.html --run=$run --date=$date2 2>> $scriptlog > /dev/null
|
|---|
| 171 | check2=$?
|
|---|
| 172 |
|
|---|
| 173 | case $check2 in
|
|---|
| 174 | 0) echo "check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
|---|
| 175 | ;;
|
|---|
| 176 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 177 | com=$Fsinope
|
|---|
| 178 | # comadd=
|
|---|
| 179 | check=$check2
|
|---|
| 180 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 181 | continue 2;;
|
|---|
| 182 | esac
|
|---|
| 183 | check2=1
|
|---|
| 184 | done
|
|---|
| 185 |
|
|---|
| 186 | # running fillsinope
|
|---|
| 187 | fillsinopepath=$logpath/fillsinope/$date
|
|---|
| 188 | makedir $fillsinopepath >> $scriptlog 2>&1
|
|---|
| 189 | fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
|
|---|
| 190 |
|
|---|
| 191 | echo "doing fillsinope..." >> $scriptlog 2>&1
|
|---|
| 192 | check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | grep int | sed -e 's/.*(int)//'`
|
|---|
| 193 |
|
|---|
| 194 | case $check3 in
|
|---|
| 195 | 1) echo "check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
|
|---|
| 196 | ;;
|
|---|
| 197 | 0) echo "check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
|---|
| 198 | check="no"
|
|---|
| 199 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 200 | continue ;;
|
|---|
| 201 | *) echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 202 | com=$Ffillsinope
|
|---|
| 203 | check=$check3
|
|---|
| 204 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 205 | continue ;;
|
|---|
| 206 | esac
|
|---|
| 207 |
|
|---|
| 208 | # resetting the status for exclusions
|
|---|
| 209 | echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
|
|---|
| 210 | resetlogpath=$logpath/resetexclusions/$date
|
|---|
| 211 | echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
|
|---|
| 212 | makedir $resetlogpath >> $scriptlog 2>&1
|
|---|
| 213 | resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
|
|---|
| 214 |
|
|---|
| 215 | check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | grep int | sed -e 's/(int)//'`
|
|---|
| 216 | case $check5 in
|
|---|
| 217 | 1) echo "check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
|
|---|
| 218 | ;;
|
|---|
| 219 | 0) echo "check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
|---|
| 220 | check="no"
|
|---|
| 221 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 222 | continue ;;
|
|---|
| 223 | *) echo "check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
|
|---|
| 224 | com=$Fresetexcl
|
|---|
| 225 | comadd=`echo $date2 | sed -e 's/-//g'`
|
|---|
| 226 | check=$check5
|
|---|
| 227 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 228 | continue ;;
|
|---|
| 229 | esac
|
|---|
| 230 |
|
|---|
| 231 | # set status
|
|---|
| 232 | echo "inserting the status for the $program for run $run into the db" >> $scriptlog 2>&1
|
|---|
| 233 | statustime="Now()"
|
|---|
| 234 | failed="NULL"
|
|---|
| 235 | starttime="NULL"
|
|---|
| 236 | failedtime="NULL"
|
|---|
| 237 | var1=$date
|
|---|
| 238 | var2=$no2
|
|---|
| 239 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 240 | done
|
|---|
| 241 |
|
|---|
| 242 | finish >> $scriptlog 2>&1
|
|---|
| 243 |
|
|---|