| 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 | user=`whoami`
|
|---|
| 30 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
|---|
| 31 |
|
|---|
| 32 | set -C
|
|---|
| 33 |
|
|---|
| 34 | callistorcnew=$setuppath/callisto/callisto.rc
|
|---|
| 35 | callistorcmarapr05=$setuppath/callisto/callisto_MarApr05.rc
|
|---|
| 36 |
|
|---|
| 37 | table=SequenceProcessStatus
|
|---|
| 38 | column=fCallisto
|
|---|
| 39 | date=NULL
|
|---|
| 40 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 41 | year=`date +%Y`
|
|---|
| 42 | #pno=500 # number of processes, i.e. number of todo-files
|
|---|
| 43 |
|
|---|
| 44 | todofile=$listpath/ToDo-$table-$column
|
|---|
| 45 | getstatuslogpath=$logpath/getstatus/callisto/$year
|
|---|
| 46 | getstatuslog=$getstatuslogpath/getstatus-callisto-$datetime.log
|
|---|
| 47 |
|
|---|
| 48 | scriptlogpath=$logpath/run/callisto/`date +%Y/%m/%d`
|
|---|
| 49 | makedir $scriptlogpath
|
|---|
| 50 | scriptlog=$scriptlogpath/runcallisto-$datetime.log
|
|---|
| 51 |
|
|---|
| 52 | date >> $scriptlog 2>&1
|
|---|
| 53 |
|
|---|
| 54 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
|---|
| 55 |
|
|---|
| 56 | cd $mars
|
|---|
| 57 |
|
|---|
| 58 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
|---|
| 59 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
|---|
| 60 | then
|
|---|
| 61 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
|---|
| 62 | echo " -> choose one file and start calibrating" >> $scriptlog 2>&1
|
|---|
| 63 | else
|
|---|
| 64 | date > $lockpath/lock-getting-callisto-list.txt >> $scriptlog 2>&1
|
|---|
| 65 | checklock0=$?
|
|---|
| 66 | case $checklock0 in
|
|---|
| 67 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
|---|
| 68 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
|---|
| 69 | echo "-> getting list for callisto is running -> exit" >> $scriptlog 2>&1
|
|---|
| 70 | date >> $scriptlog 2>&1
|
|---|
| 71 | exit;;
|
|---|
| 72 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 73 | esac
|
|---|
| 74 |
|
|---|
| 75 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
|---|
| 76 | then
|
|---|
| 77 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
|---|
| 78 | echo " -> choose one file and start calibrating" >> $scriptlog 2>&1
|
|---|
| 79 | else
|
|---|
| 80 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 81 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 82 |
|
|---|
| 83 | case $check0 in
|
|---|
| 84 | 1) echo "check0=$check0 -> everything ok -> run callisto" >> $scriptlog 2>&1;;
|
|---|
| 85 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 86 | esac
|
|---|
| 87 | fi
|
|---|
| 88 | rm -v $lockpath/lock-getting-callisto-list.txt >> $scriptlog 2>&1
|
|---|
| 89 | fi
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | nr=bla
|
|---|
| 93 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
|---|
| 94 | todofiles=`ls -r $listpath/ToDo-$table-$column-*`
|
|---|
| 95 |
|
|---|
| 96 | echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
|
|---|
| 97 |
|
|---|
| 98 | for todofile in ${todofiles[@]}
|
|---|
| 99 | do
|
|---|
| 100 | if ! ls $todofile >> $scriptlog 2>&1
|
|---|
| 101 | then
|
|---|
| 102 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
|---|
| 103 | continue
|
|---|
| 104 | fi
|
|---|
| 105 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
|---|
| 106 | date > $lockfile >> $scriptlog 2>&1
|
|---|
| 107 | checklock=$?
|
|---|
| 108 | case $checklock in
|
|---|
| 109 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
|---|
| 110 | nr=${i}
|
|---|
| 111 | break;;
|
|---|
| 112 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
|---|
| 113 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 114 | esac
|
|---|
| 115 | done
|
|---|
| 116 |
|
|---|
| 117 | case $nr in
|
|---|
| 118 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
|---|
| 119 | date >> $scriptlog 2>&1
|
|---|
| 120 | exit;;
|
|---|
| 121 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
|---|
| 122 | esac
|
|---|
| 123 |
|
|---|
| 124 | sequences=(`cat $todofile`)
|
|---|
| 125 |
|
|---|
| 126 | if [ "$sequences" = "" ]
|
|---|
| 127 | then
|
|---|
| 128 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 129 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 130 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 131 | date >> $scriptlog 2>&1
|
|---|
| 132 | exit
|
|---|
| 133 | fi
|
|---|
| 134 |
|
|---|
| 135 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
|---|
| 136 |
|
|---|
| 137 | for sequence in ${sequences[@]}
|
|---|
| 138 | do
|
|---|
| 139 | no=`printf %08d $sequence | cut -c 0-4`
|
|---|
| 140 | no2=`printf %08d $sequence`
|
|---|
| 141 | outpath="$datapath/callisto/$no/$no2"
|
|---|
| 142 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
|---|
| 143 | makedir $outpath >> $scriptlog 2>&1
|
|---|
| 144 |
|
|---|
| 145 | sequfile="$sequpath/$no/sequence$no2.txt"
|
|---|
| 146 | echo "sequfile: "$sequfile >> $scriptlog 2>&1
|
|---|
| 147 |
|
|---|
| 148 | if [ -e $outpath/callisto.rc ]
|
|---|
| 149 | then
|
|---|
| 150 | echo "found callisto.rc in $outpath -> using this " >> $scriptlog 2>&1
|
|---|
| 151 | callistorcseq=$outpath/callisto.rc
|
|---|
| 152 | else
|
|---|
| 153 | echo "no callisto.rc found in $outpath -> making link " >> $scriptlog 2>&1
|
|---|
| 154 | if [ 49735 -lt $sequence ] && [ $sequence -lt 53516 ]
|
|---|
| 155 | then
|
|---|
| 156 | ln -vs $callistorcmarapr05 $outpath/callisto.rc >> $scriptlog 2>&1
|
|---|
| 157 | else
|
|---|
| 158 | ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
|
|---|
| 159 | fi
|
|---|
| 160 | callistorcseq=$outpath/callisto.rc
|
|---|
| 161 | fi
|
|---|
| 162 |
|
|---|
| 163 | echo "run callisto..." >> $scriptlog 2>&1
|
|---|
| 164 | ./callisto -b -q -v4 -f -raw --log=$outpath/callisto$no2.log --html=$outpath/callisto$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
|
|---|
| 165 | check1=$?
|
|---|
| 166 |
|
|---|
| 167 | case $check1 in
|
|---|
| 168 | 0) echo "check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
|
|---|
| 169 | echo "finding files to be updated" >> $scriptlog 2>&1
|
|---|
| 170 | calfiles=`find $outpath -name *_Y_* `
|
|---|
| 171 | echo "files to be updated: "$calfiles >> $scriptlog 2>&1
|
|---|
| 172 | if [ "$calfiles" = "" ]
|
|---|
| 173 | then
|
|---|
| 174 | echo "no files found -> continue with next sequence" >> $scriptlog 2>&1
|
|---|
| 175 | continue
|
|---|
| 176 | fi
|
|---|
| 177 |
|
|---|
| 178 | merpplogpath=$outpath"/merpplogs"
|
|---|
| 179 | makedir $merpplogpath >> $scriptlog 2>&1
|
|---|
| 180 |
|
|---|
| 181 | for calfile in ${calfiles[@]}
|
|---|
| 182 | do
|
|---|
| 183 | echo "calfile: "$calfile >> $scriptlog 2>&1
|
|---|
| 184 | runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
|
|---|
| 185 | ccfile=`find /magic/subsystemdata/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
|
|---|
| 186 | source=`echo $ccfile | cut -d_ -f4`
|
|---|
| 187 | cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
|
|---|
| 188 | # cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
|
|---|
| 189 | echo "runno: "$runno >> $scriptlog 2>&1
|
|---|
| 190 | echo "ccfile: "$ccfile >> $scriptlog 2>&1
|
|---|
| 191 | if [ "$ccfile" = "" ]
|
|---|
| 192 | then
|
|---|
| 193 | echo "no ccfile found for run "$runno >> $scriptlog 2>&1
|
|---|
| 194 | break
|
|---|
| 195 | fi
|
|---|
| 196 | echo "cacofile: "$cacofile >> $scriptlog 2>&1
|
|---|
| 197 | if [ "$cacofile" = "" ]
|
|---|
| 198 | then
|
|---|
| 199 | echo "no cacofile found for run "$runno >> $scriptlog 2>&1
|
|---|
| 200 | echo "finding cacofile..." >> $scriptlog 2>&1
|
|---|
| 201 | for (( i = 0; i <= 10; i++ ))
|
|---|
| 202 | do
|
|---|
| 203 | newrun=`echo $runno - $i | bc`
|
|---|
| 204 | # echo "$missingcacorun + $i = $newrun"
|
|---|
| 205 | path=`dirname $ccfile`
|
|---|
| 206 | path=`echo $path | sed -e 's/cc/caco/'`
|
|---|
| 207 | echo "path: "$path >> $scriptlog 2>&1
|
|---|
| 208 | cacofile=`find $path -name *$newrun*`
|
|---|
| 209 | if [ "$cacofile" = "" ]
|
|---|
| 210 | then
|
|---|
| 211 | continue
|
|---|
| 212 | else
|
|---|
| 213 | break
|
|---|
| 214 | echo "cacofile: "$cacofile >> $scriptlog 2>&1
|
|---|
| 215 | fi
|
|---|
| 216 | done
|
|---|
| 217 | fi
|
|---|
| 218 | ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null
|
|---|
| 219 | check2=$?
|
|---|
| 220 | case $check2 in
|
|---|
| 221 | 0) echo "check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1;;
|
|---|
| 222 | *) echo "check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
|
|---|
| 223 | continue 2 ;;
|
|---|
| 224 | esac
|
|---|
| 225 | ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null
|
|---|
| 226 | check3=$?
|
|---|
| 227 | case $check3 in
|
|---|
| 228 | 0) echo "check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1;;
|
|---|
| 229 | *) echo "check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
|
|---|
| 230 | continue 2 ;;
|
|---|
| 231 | esac
|
|---|
| 232 | done
|
|---|
| 233 |
|
|---|
| 234 | echo "inserting the status for callisto for sequence $sequence into the db" >> $scriptlog 2>&1
|
|---|
| 235 | setstatuslogpath=$logpath/setstatus/callisto/$no
|
|---|
| 236 | makedir $setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 237 | setstatuslog=$setstatuslogpath/setstatus-callisto-$no2.log
|
|---|
| 238 |
|
|---|
| 239 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 240 | case $check4 in
|
|---|
| 241 | 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1;;
|
|---|
| 242 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
|---|
| 243 | esac
|
|---|
| 244 | ;;
|
|---|
| 245 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 246 | esac
|
|---|
| 247 | done
|
|---|
| 248 |
|
|---|
| 249 | rm -v $todofile >> $scriptlog 2>&1
|
|---|
| 250 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 251 |
|
|---|
| 252 | set +C
|
|---|
| 253 |
|
|---|
| 254 | date >> $scriptlog 2>&1
|
|---|
| 255 |
|
|---|