| 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 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2006
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | #
|
|---|
| 28 | #
|
|---|
| 29 | ##############################################################################
|
|---|
| 30 | #
|
|---|
| 31 | # This script can be used to run the following steps for one sequence:
|
|---|
| 32 | # - callisto
|
|---|
| 33 | # - merppupdate
|
|---|
| 34 | # - star
|
|---|
| 35 | #
|
|---|
| 36 | # You have to set the path, where your Mars version can be found, the outpath,
|
|---|
| 37 | # where you want to store the output and the sequencenumber of the sequence
|
|---|
| 38 | # you want to process
|
|---|
| 39 | #
|
|---|
| 40 | ##############################################################################
|
|---|
| 41 |
|
|---|
| 42 | #to be set by the user (if you don't use the command-line options)
|
|---|
| 43 | #path of your output directory
|
|---|
| 44 | #outpath=/home/dorner/ToO
|
|---|
| 45 | outpath=
|
|---|
| 46 | #give either sequence number or sequence file (including path)
|
|---|
| 47 | sequence=
|
|---|
| 48 | sequfile=""
|
|---|
| 49 |
|
|---|
| 50 | function usage()
|
|---|
| 51 | {
|
|---|
| 52 | echo "Usage: $0 [options]"
|
|---|
| 53 | echo "options:"
|
|---|
| 54 | echo -n " --sequ sequence# "
|
|---|
| 55 | echo " giving number of sequence which shall be processed "
|
|---|
| 56 | echo -n " --sequ-file sequfile "
|
|---|
| 57 | echo " giving sequencfile (including path) of sequence which shall be processed "
|
|---|
| 58 | echo -n " --out outpath "
|
|---|
| 59 | echo " giving the path where all outputfiles are stored "
|
|---|
| 60 | echo -n " -cal "
|
|---|
| 61 | echo " running only calibration"
|
|---|
| 62 | echo -n " -b "
|
|---|
| 63 | echo " running in non-interactive mode (i.e. you are not asked if the paths are ok)"
|
|---|
| 64 | echo -n " -star "
|
|---|
| 65 | echo " running only star"
|
|---|
| 66 | echo ""
|
|---|
| 67 | echo "Remarks: "
|
|---|
| 68 | echo " - you can set the needed variables also in the script "
|
|---|
| 69 | echo " - you have to set the outpath and either the sequence number or the sequence file"
|
|---|
| 70 | echo " (if both is set, the sequence given by the sequencefile is processed)"
|
|---|
| 71 | echo " - you have to execute the script from your mars directory"
|
|---|
| 72 | echo ""
|
|---|
| 73 | exit
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | function checkreturncode()
|
|---|
| 77 | {
|
|---|
| 78 | case $check in
|
|---|
| 79 | 0) echo "$program finished sucessfully"
|
|---|
| 80 | echo ""
|
|---|
| 81 | ;;
|
|---|
| 82 | [1-9]|[0-9][0-9]|1[0-1][0-9]|12[0-7])
|
|---|
| 83 | echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
|---|
| 84 | if [ "$program" == "callisto" ]
|
|---|
| 85 | then
|
|---|
| 86 | echo -n " - for more details see http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
|
|---|
| 87 | fi
|
|---|
| 88 | echo " you executed the following command: "$command
|
|---|
| 89 | exit
|
|---|
| 90 | ;;
|
|---|
| 91 | *) echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
|---|
| 92 | echo -n " $program returned a signal > 127 ($check)"
|
|---|
| 93 | echo " you executed the following command: "$command
|
|---|
| 94 | exit;;
|
|---|
| 95 | esac
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | interactive="yes"
|
|---|
| 100 |
|
|---|
| 101 | while [ "$1" ]
|
|---|
| 102 | do
|
|---|
| 103 | case $1 in
|
|---|
| 104 | --sequ) shift
|
|---|
| 105 | sequence=$1
|
|---|
| 106 | ;;
|
|---|
| 107 | --out) shift
|
|---|
| 108 | outpath=$1
|
|---|
| 109 | ;;
|
|---|
| 110 | -b) interactive='no'
|
|---|
| 111 | ;;
|
|---|
| 112 | -cal) cal='yes'
|
|---|
| 113 | ;;
|
|---|
| 114 | -star) star='yes'
|
|---|
| 115 | ;;
|
|---|
| 116 | --sequ-file) shift
|
|---|
| 117 | sequfile=$1
|
|---|
| 118 | ;;
|
|---|
| 119 | -h) usage
|
|---|
| 120 | ;;
|
|---|
| 121 | *) echo "unknown option $1 "
|
|---|
| 122 | usage
|
|---|
| 123 | exit
|
|---|
| 124 | ;;
|
|---|
| 125 | esac
|
|---|
| 126 | shift
|
|---|
| 127 | done
|
|---|
| 128 |
|
|---|
| 129 | if [ "$outpath" = "" ]
|
|---|
| 130 | then
|
|---|
| 131 | echo "WARNING outpath has not been set"
|
|---|
| 132 | echo ""
|
|---|
| 133 | usage
|
|---|
| 134 | fi
|
|---|
| 135 |
|
|---|
| 136 | if [ "$sequence" = "" ] && [ "$sequfile" = "" ]
|
|---|
| 137 | then
|
|---|
| 138 | echo "WARNING neither sequ nor sequfile has been set"
|
|---|
| 139 | echo ""
|
|---|
| 140 | usage
|
|---|
| 141 | fi
|
|---|
| 142 |
|
|---|
| 143 | echo ""
|
|---|
| 144 | echo "You have set the variables to: "
|
|---|
| 145 | echo " outpath: "$outpath
|
|---|
| 146 |
|
|---|
| 147 | if [ "$sequfile" = "" ]
|
|---|
| 148 | then
|
|---|
| 149 | if ! n8=`printf %08d $sequence`
|
|---|
| 150 | then
|
|---|
| 151 | echo "your sequence number is not valid"
|
|---|
| 152 | usage
|
|---|
| 153 | exit
|
|---|
| 154 | fi
|
|---|
| 155 | no=`echo $n8 | cut -c 1-4`
|
|---|
| 156 | sequfile="/magic/sequences/"$no"/sequence$n8.txt"
|
|---|
| 157 | echo " sequence: "$sequence
|
|---|
| 158 | echo " sequfile: "$sequfile
|
|---|
| 159 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
|---|
| 160 | # then
|
|---|
| 161 | calpath=$outpath"/callisto/$n8"
|
|---|
| 162 | echo " path where calibration files are stored : "$calpath
|
|---|
| 163 | # fi
|
|---|
| 164 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
|---|
| 165 | then
|
|---|
| 166 | starpath=$outpath"/star/$n8"
|
|---|
| 167 | echo " path where star files are stored : "$starpath
|
|---|
| 168 | fi
|
|---|
| 169 | else
|
|---|
| 170 | echo " sequfile: "$sequfile
|
|---|
| 171 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
|---|
| 172 | # then
|
|---|
| 173 | calpath=$outpath"/callisto"
|
|---|
| 174 | echo " path where calibration files are stored : "$calpath
|
|---|
| 175 | # fi
|
|---|
| 176 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
|---|
| 177 | then
|
|---|
| 178 | starpath=$outpath"/star"
|
|---|
| 179 | echo " path where star files are stored : "$starpath
|
|---|
| 180 | fi
|
|---|
| 181 | fi
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | if [ "$interactive" = "yes" ]
|
|---|
| 185 | then
|
|---|
| 186 | echo ""
|
|---|
| 187 | echo "paths ok? continue?"
|
|---|
| 188 | echo "please insert y, if you want continue"
|
|---|
| 189 | echo " n, if you want quit"
|
|---|
| 190 |
|
|---|
| 191 | answer=`head -n 1`
|
|---|
| 192 | case $answer in
|
|---|
| 193 | y) echo "continue processing sequence"
|
|---|
| 194 | ;;
|
|---|
| 195 | n) exit
|
|---|
| 196 | ;;
|
|---|
| 197 | *) echo "your answer is not clear -> exit"
|
|---|
| 198 | exit
|
|---|
| 199 | ;;
|
|---|
| 200 | esac
|
|---|
| 201 | fi
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 | if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
|---|
| 205 | then
|
|---|
| 206 | mkdir -pv $calpath
|
|---|
| 207 |
|
|---|
| 208 | program=callisto
|
|---|
| 209 | echo "run $program..."
|
|---|
| 210 | logfile=$calpath/$program$sequence.log
|
|---|
| 211 | command="./$program -b -q -f --log=$logfile --out=$calpath $sequfile "
|
|---|
| 212 | echo $command
|
|---|
| 213 | $command
|
|---|
| 214 | check=$?
|
|---|
| 215 | checkreturncode
|
|---|
| 216 |
|
|---|
| 217 | calfiles=`find $calpath -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*_Y_*.root`
|
|---|
| 218 |
|
|---|
| 219 | echo "run merpp update for calibrated files..."
|
|---|
| 220 | echo "calibrated data files: "$calfiles
|
|---|
| 221 |
|
|---|
| 222 | for calfile in ${calfiles[@]}
|
|---|
| 223 | do
|
|---|
| 224 | echo "calfile: "$calfile
|
|---|
| 225 | outpath=`dirname $calfile`
|
|---|
| 226 | echo "outpath: "$outpath
|
|---|
| 227 |
|
|---|
| 228 | merpplogpath=$outpath"/merpplogs"
|
|---|
| 229 | mkdir -pv $merpplogpath
|
|---|
| 230 |
|
|---|
| 231 | runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
|
|---|
| 232 | ccfile=`find /magic/subsystemdata/cc/ -name 20[0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
|
|---|
| 233 | cacofile=`find /magic/subsystemdata/caco/ -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_*.txt`
|
|---|
| 234 | echo "runno: "$runno
|
|---|
| 235 | echo "ccfile: "$ccfile
|
|---|
| 236 | if [ "$ccfile" = "" ]
|
|---|
| 237 | then
|
|---|
| 238 | echo "no ccfile found for run "$runno
|
|---|
| 239 | break
|
|---|
| 240 | fi
|
|---|
| 241 | echo "cacofile: "$cacofile
|
|---|
| 242 | if [ "$cacofile" = "" ]
|
|---|
| 243 | then
|
|---|
| 244 | echo "no cacofile found for run "$runno
|
|---|
| 245 | echo "finding cacofile..."
|
|---|
| 246 | for (( i = 0; i <= 10; i++ ))
|
|---|
| 247 | do
|
|---|
| 248 | newrun=`echo $runno - $i | bc`
|
|---|
| 249 | # echo "$missingcacorun + $i = $newrun"
|
|---|
| 250 | path=`dirname $ccfile`
|
|---|
| 251 | path=`echo $path | sed -e 's/cc/caco/'`
|
|---|
| 252 | echo "path: "$path
|
|---|
| 253 | cacofile=`find $path -name *$newrun*`
|
|---|
| 254 | if [ "$cacofile" = "" ]
|
|---|
| 255 | then
|
|---|
| 256 | continue
|
|---|
| 257 | else
|
|---|
| 258 | break
|
|---|
| 259 | echo "cacofile: "$cacofile
|
|---|
| 260 | fi
|
|---|
| 261 | done
|
|---|
| 262 | fi
|
|---|
| 263 |
|
|---|
| 264 | program=merppccupdate
|
|---|
| 265 | logfile=$merpplogpath/$program$runno.log
|
|---|
| 266 | command="./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
|
|---|
| 267 | echo $command
|
|---|
| 268 | $command
|
|---|
| 269 | check=$?
|
|---|
| 270 | checkreturncode
|
|---|
| 271 |
|
|---|
| 272 | program=merppcacoupdate
|
|---|
| 273 | logfile=$merpplogpath/$program$runno.log
|
|---|
| 274 | command="./merpp -u --log=$logfile --auto-time $cacofile $calfile"
|
|---|
| 275 | echo $command
|
|---|
| 276 | $command
|
|---|
| 277 | check=$?
|
|---|
| 278 | checkreturncode
|
|---|
| 279 |
|
|---|
| 280 | done
|
|---|
| 281 | echo "merppupdate is finished"
|
|---|
| 282 | echo ""
|
|---|
| 283 | fi
|
|---|
| 284 |
|
|---|
| 285 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
|---|
| 286 | then
|
|---|
| 287 | mkdir -pv $starpath
|
|---|
| 288 |
|
|---|
| 289 | program=star
|
|---|
| 290 | echo "run $program..."
|
|---|
| 291 | logfile=$starpath/$program$sequence.log
|
|---|
| 292 | if ! ls $calpath
|
|---|
| 293 | then
|
|---|
| 294 | echo "couldn't find $calpath => taking standard inpath for $program"
|
|---|
| 295 | command="./$program -b -q -f --log=$logfile --out=$starpath $sequfile"
|
|---|
| 296 | echo $command
|
|---|
| 297 | $command
|
|---|
| 298 | else
|
|---|
| 299 | command="./$program -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile"
|
|---|
| 300 | echo $command
|
|---|
| 301 | $command
|
|---|
| 302 | fi
|
|---|
| 303 | check=$?
|
|---|
| 304 | checkreturncode
|
|---|
| 305 | fi
|
|---|
| 306 |
|
|---|