| 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 | # Get todo file
|
|---|
| 31 | # Then for each run the following steps are done:
|
|---|
| 32 | # - filldotraw.C
|
|---|
| 33 | # - sinope (once for data and once for calibration events)
|
|---|
| 34 | # - fillsinope
|
|---|
| 35 | # - reset ExclusionsDone, so that the result from the datacheck can be
|
|---|
| 36 | # taken into account when doexclusions is running the next time
|
|---|
| 37 | # If this was successful, the status is inserted into the database using
|
|---|
| 38 | # the macro setstatus.C
|
|---|
| 39 | #
|
|---|
| 40 |
|
|---|
| 41 | source `dirname $0`/sourcefile
|
|---|
| 42 | printprocesslog "INFO starting $0"
|
|---|
| 43 | program=datacheck
|
|---|
| 44 | column=fDataCheckDone
|
|---|
| 45 |
|
|---|
| 46 | set -C
|
|---|
| 47 |
|
|---|
| 48 | scriptlog=$runlogpath/$program-$datetime.log
|
|---|
| 49 | date >> $scriptlog 2>&1
|
|---|
| 50 |
|
|---|
| 51 | # get run #
|
|---|
| 52 | gettodo >> $scriptlog 2>&1
|
|---|
| 53 | run=$process
|
|---|
| 54 |
|
|---|
| 55 | # lock sequ
|
|---|
| 56 | lockfile=$lockpath/lock-$table-$column-$run.txt
|
|---|
| 57 | checklock >> $scriptlog 2>&1
|
|---|
| 58 |
|
|---|
| 59 | cd $mars
|
|---|
| 60 |
|
|---|
| 61 | echo "do $program for run "$run >> $scriptlog 2>&1
|
|---|
| 62 | printprocesslog "INFO do $program for run $run"
|
|---|
| 63 | no=`printf %08d $run | cut -c 0-2`
|
|---|
| 64 | no2=`printf %08d $run`
|
|---|
| 65 | var1=$date
|
|---|
| 66 | var2=$no2
|
|---|
| 67 | rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[D,P,C,S]_*_E.raw.gz`
|
|---|
| 68 | echo "rawfile: "$rawfile >> $scriptlog 2>&1
|
|---|
| 69 | date=`echo $rawfile | cut -c 22-31`
|
|---|
| 70 | # for sinope the date is needed in the format YYYY-MM-DD
|
|---|
| 71 | date2=`echo $date | sed -e 's/\//-/g'`
|
|---|
| 72 |
|
|---|
| 73 | setstatus "start" >> $scriptlog 2>&1
|
|---|
| 74 |
|
|---|
| 75 | # running filldotraw
|
|---|
| 76 | echo "doing filldotraw..." >> $scriptlog 2>&1
|
|---|
| 77 | filldotrawpath=$logpath/filldotraw/$date
|
|---|
| 78 | makedir $filldotrawpath >> $scriptlog 2>&1
|
|---|
| 79 | filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
|
|---|
| 80 |
|
|---|
| 81 | check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | intgrep`
|
|---|
| 82 |
|
|---|
| 83 | case $check1 in
|
|---|
| 84 | 1) echo " check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
|---|
| 85 | printprocesslog "INFO finished filldotraw.C sucessfully for $rawfile"
|
|---|
| 86 | ;;
|
|---|
| 87 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
|---|
| 88 | printprocesslog "WARN connection to DB failed"
|
|---|
| 89 | check="no"
|
|---|
| 90 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 91 | continue ;;
|
|---|
| 92 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 93 | printprocesslog "ERROR filldotraw.C failed for $rawfile"
|
|---|
| 94 | com=$Ffillraw
|
|---|
| 95 | check=$check1
|
|---|
| 96 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 97 | continue ;;
|
|---|
| 98 | esac
|
|---|
| 99 |
|
|---|
| 100 | # running sinope
|
|---|
| 101 | printprocesslog "INFO running sinope for $run"
|
|---|
| 102 | sinopepath=$datapath/sinope/$date
|
|---|
| 103 | makedir $sinopepath >> $scriptlog 2>&1
|
|---|
| 104 |
|
|---|
| 105 | sins=( "-dat" "-cal")
|
|---|
| 106 | for sin in ${sins[@]}
|
|---|
| 107 | do
|
|---|
| 108 | sinopefile=sinope$sin$no2
|
|---|
| 109 |
|
|---|
| 110 | echo "running sinope $sin..." >> $scriptlog 2>&1
|
|---|
| 111 | ./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
|
|---|
| 112 | check2=$?
|
|---|
| 113 |
|
|---|
| 114 | case $check2 in
|
|---|
| 115 | 0) echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
|---|
| 116 | ;;
|
|---|
| 117 | *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 118 | printprocesslog "ERROR sinope $sin failed for $rawfile"
|
|---|
| 119 | com=$Fsinope
|
|---|
| 120 | # comadd=
|
|---|
| 121 | check=$check2
|
|---|
| 122 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 123 | continue 2;;
|
|---|
| 124 | esac
|
|---|
| 125 | check2=1
|
|---|
| 126 | done
|
|---|
| 127 |
|
|---|
| 128 | # running fillsinope
|
|---|
| 129 | fillsinopepath=$logpath/fillsinope/$date
|
|---|
| 130 | makedir $fillsinopepath >> $scriptlog 2>&1
|
|---|
| 131 | fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
|
|---|
| 132 |
|
|---|
| 133 | echo "doing fillsinope..." >> $scriptlog 2>&1
|
|---|
| 134 | check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | intgrep`
|
|---|
| 135 |
|
|---|
| 136 | case $check3 in
|
|---|
| 137 | 1) echo " check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
|
|---|
| 138 | printprocesslog "INFO finished fillsinope.C sucessfully for run $run"
|
|---|
| 139 | ;;
|
|---|
| 140 | 0) echo " check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
|---|
| 141 | printprocesslog "WARN connection to DB failed"
|
|---|
| 142 | check="no"
|
|---|
| 143 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 144 | continue ;;
|
|---|
| 145 | *) echo " check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 146 | printprocesslog "ERROR fillsinope.C failed for run $run"
|
|---|
| 147 | com=$Ffillsinope
|
|---|
| 148 | check=$check3
|
|---|
| 149 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 150 | continue ;;
|
|---|
| 151 | esac
|
|---|
| 152 |
|
|---|
| 153 | # resetting the status for exclusions
|
|---|
| 154 | echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
|
|---|
| 155 | printprocesslog "INFO resetting fExclusions done for $date2"
|
|---|
| 156 | resetlogpath=$logpath/resetexclusions/$date
|
|---|
| 157 | makedir $resetlogpath >> $scriptlog 2>&1
|
|---|
| 158 | resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
|
|---|
| 159 |
|
|---|
| 160 | check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | intgrep`
|
|---|
| 161 | case $check5 in
|
|---|
| 162 | 1) echo " check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
|
|---|
| 163 | printprocesslog "INFO resetted fExclusions done for $date2 successfully"
|
|---|
| 164 | ;;
|
|---|
| 165 | 0) echo " check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
|---|
| 166 | printprocesslog "WARN connection to DB failed"
|
|---|
| 167 | check="no"
|
|---|
| 168 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 169 | continue ;;
|
|---|
| 170 | *) echo " check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
|
|---|
| 171 | printprocesslog "ERROR resetcolumn.C failed for date $date2"
|
|---|
| 172 | com=$Fresetexcl
|
|---|
| 173 | comadd=`echo $date2 | sed -e 's/-//g'`
|
|---|
| 174 | check=$check5
|
|---|
| 175 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 176 | continue ;;
|
|---|
| 177 | esac
|
|---|
| 178 |
|
|---|
| 179 | # set status
|
|---|
| 180 | statustime="Now()"
|
|---|
| 181 | failed="NULL"
|
|---|
| 182 | starttime="NULL"
|
|---|
| 183 | failedtime="NULL"
|
|---|
| 184 | var1=$date
|
|---|
| 185 | var2=$no2
|
|---|
| 186 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 187 |
|
|---|
| 188 | finish >> $scriptlog 2>&1
|
|---|
| 189 |
|
|---|