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-2007
|
---|
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 "
|
---|
70 | echo " file (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 " - in your outpath a calibration directory (callisto/sequencenumber), a "
|
---|
73 | echo " directory for the image fiels (star/sequencenumber) and a directory for "
|
---|
74 | echo " the merpplogs in the calibration directory are created. "
|
---|
75 | echo ""
|
---|
76 | exit
|
---|
77 | }
|
---|
78 |
|
---|
79 | function checkreturncode()
|
---|
80 | {
|
---|
81 | case $check in
|
---|
82 | 0) echo "$program finished sucessfully"
|
---|
83 | echo ""
|
---|
84 | ;;
|
---|
85 | [1-9]|[0-9][0-9]|1[0-1][0-9]|12[0-7])
|
---|
86 | echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
---|
87 | if [ "$program" == "callisto" ]
|
---|
88 | then
|
---|
89 | echo -n " - for more details see http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
|
---|
90 | fi
|
---|
91 | echo " you executed the following command: "$command
|
---|
92 | exit
|
---|
93 | ;;
|
---|
94 | *) echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
---|
95 | echo -n " $program returned a signal > 127 ($check)"
|
---|
96 | echo " you executed the following command: "$command
|
---|
97 | exit;;
|
---|
98 | esac
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | interactive="yes"
|
---|
103 |
|
---|
104 | while [ "$1" ]
|
---|
105 | do
|
---|
106 | case $1 in
|
---|
107 | --sequ) shift
|
---|
108 | sequence=$1
|
---|
109 | ;;
|
---|
110 | --out) shift
|
---|
111 | outpath=$1
|
---|
112 | ;;
|
---|
113 | -b) interactive='no'
|
---|
114 | ;;
|
---|
115 | -cal) cal='yes'
|
---|
116 | ;;
|
---|
117 | -star) star='yes'
|
---|
118 | ;;
|
---|
119 | --sequ-file) shift
|
---|
120 | sequfile=$1
|
---|
121 | ;;
|
---|
122 | -h) usage
|
---|
123 | ;;
|
---|
124 | *) echo "unknown option $1 "
|
---|
125 | usage
|
---|
126 | exit
|
---|
127 | ;;
|
---|
128 | esac
|
---|
129 | shift
|
---|
130 | done
|
---|
131 |
|
---|
132 | if [ "$outpath" = "" ]
|
---|
133 | then
|
---|
134 | echo "WARNING outpath has not been set"
|
---|
135 | echo ""
|
---|
136 | usage
|
---|
137 | fi
|
---|
138 |
|
---|
139 | if [ "$sequence" = "" ] && [ "$sequfile" = "" ]
|
---|
140 | then
|
---|
141 | echo "WARNING neither sequ nor sequfile has been set"
|
---|
142 | echo ""
|
---|
143 | usage
|
---|
144 | fi
|
---|
145 |
|
---|
146 | echo ""
|
---|
147 | echo "You have set the variables to: "
|
---|
148 | echo " outpath: "$outpath
|
---|
149 |
|
---|
150 | if [ "$sequfile" = "" ]
|
---|
151 | then
|
---|
152 | if ! n8=`printf %08d $sequence`
|
---|
153 | then
|
---|
154 | echo "your sequence number is not valid"
|
---|
155 | usage
|
---|
156 | exit
|
---|
157 | fi
|
---|
158 | no=`echo $n8 | cut -c 1-4`
|
---|
159 | sequfile="/magic/sequences/"$no"/sequence$n8.txt"
|
---|
160 | echo " sequence: "$sequence
|
---|
161 | echo " sequfile: "$sequfile
|
---|
162 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
---|
163 | # then
|
---|
164 | calpath=$outpath"/callisto/$n8"
|
---|
165 | echo " path where calibration files are stored : "$calpath
|
---|
166 | # fi
|
---|
167 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
---|
168 | then
|
---|
169 | starpath=$outpath"/star/$n8"
|
---|
170 | echo " path where star files are stored : "$starpath
|
---|
171 | fi
|
---|
172 | else
|
---|
173 | echo " sequfile: "$sequfile
|
---|
174 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
---|
175 | # then
|
---|
176 | calpath=$outpath"/callisto"
|
---|
177 | echo " path where calibration files are stored : "$calpath
|
---|
178 | # fi
|
---|
179 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
---|
180 | then
|
---|
181 | starpath=$outpath"/star"
|
---|
182 | echo " path where star files are stored : "$starpath
|
---|
183 | fi
|
---|
184 | fi
|
---|
185 |
|
---|
186 |
|
---|
187 | if [ "$interactive" = "yes" ]
|
---|
188 | then
|
---|
189 | echo ""
|
---|
190 | echo "paths ok? continue?"
|
---|
191 | echo "please insert y, if you want continue"
|
---|
192 | echo " n, if you want quit"
|
---|
193 |
|
---|
194 | answer=`head -n 1`
|
---|
195 | case $answer in
|
---|
196 | y) echo "continue processing sequence"
|
---|
197 | ;;
|
---|
198 | n) exit
|
---|
199 | ;;
|
---|
200 | *) echo "your answer is not clear -> exit"
|
---|
201 | exit
|
---|
202 | ;;
|
---|
203 | esac
|
---|
204 | fi
|
---|
205 |
|
---|
206 |
|
---|
207 | if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
---|
208 | then
|
---|
209 | mkdir -pv $calpath
|
---|
210 |
|
---|
211 | program=callisto
|
---|
212 | echo "run $program..."
|
---|
213 | logfile=$calpath/$program$sequence.log
|
---|
214 | command="./$program -b -q -f --log=$logfile --out=$calpath $sequfile "
|
---|
215 | echo $command
|
---|
216 | $command
|
---|
217 | check=$?
|
---|
218 | checkreturncode
|
---|
219 |
|
---|
220 | calfiles=`find $calpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*_Y_*.root`
|
---|
221 |
|
---|
222 | echo "run merpp update for calibrated files..."
|
---|
223 | echo "calibrated data files: "$calfiles
|
---|
224 |
|
---|
225 | for calfile in ${calfiles[@]}
|
---|
226 | do
|
---|
227 | echo "calfile: "$calfile
|
---|
228 | outpath=`dirname $calfile`
|
---|
229 | echo "outpath: "$outpath
|
---|
230 |
|
---|
231 | merpplogpath=$outpath"/merpplogs"
|
---|
232 | mkdir -pv $merpplogpath
|
---|
233 |
|
---|
234 | date=`date --date \`basename $calfile | cut -d_ -f1\` +%Y/%m/%d`
|
---|
235 | ccpath=$subsystempath/cc/$date
|
---|
236 | cacopath=$subsystempath/caco/$date
|
---|
237 | runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
|
---|
238 | ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
|
---|
239 | source=`echo $ccfile | cut -d_ -f4`
|
---|
240 | cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
|
---|
241 | echo "runno: "$runno
|
---|
242 | echo "ccfile: "$ccfile
|
---|
243 | if [ "$ccfile" = "" ]
|
---|
244 | then
|
---|
245 | echo "no ccfile found for run "$runno
|
---|
246 | break
|
---|
247 | fi
|
---|
248 | echo "cacofile: "$cacofile
|
---|
249 | if [ "$cacofile" = "" ]
|
---|
250 | then
|
---|
251 | echo "no cacofile found for run "$runno
|
---|
252 | echo "finding cacofile..."
|
---|
253 | for (( i = 0; i <= 10; i++ ))
|
---|
254 | do
|
---|
255 | newrun=`echo $runno - $i | bc`
|
---|
256 | cacofile=`find $cacopath -name *$newrun*`
|
---|
257 | if [ "$cacofile" = "" ]
|
---|
258 | then
|
---|
259 | continue
|
---|
260 | else
|
---|
261 | break
|
---|
262 | echo "cacofile: "$cacofile
|
---|
263 | fi
|
---|
264 | done
|
---|
265 | fi
|
---|
266 |
|
---|
267 | program=merppccupdate
|
---|
268 | logfile=$merpplogpath/$program$runno.log
|
---|
269 | command="./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
|
---|
270 | echo $command
|
---|
271 | $command
|
---|
272 | check=$?
|
---|
273 | checkreturncode
|
---|
274 |
|
---|
275 | program=merppcacoupdate
|
---|
276 | logfile=$merpplogpath/$program$runno.log
|
---|
277 | command="./merpp -u --log=$logfile --auto-time $cacofile $calfile"
|
---|
278 | echo $command
|
---|
279 | $command
|
---|
280 | check=$?
|
---|
281 | checkreturncode
|
---|
282 |
|
---|
283 | done
|
---|
284 | echo "merppupdate is finished"
|
---|
285 | echo ""
|
---|
286 | fi
|
---|
287 |
|
---|
288 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
---|
289 | then
|
---|
290 | mkdir -pv $starpath
|
---|
291 |
|
---|
292 | program=star
|
---|
293 | echo "run $program..."
|
---|
294 | logfile=$starpath/$program$sequence.log
|
---|
295 | if ! ls $calpath
|
---|
296 | then
|
---|
297 | echo "couldn't find $calpath => taking standard inpath for $program"
|
---|
298 | command="./$program -b -q -f --log=$logfile --out=$starpath $sequfile"
|
---|
299 | echo $command
|
---|
300 | $command
|
---|
301 | else
|
---|
302 | command="./$program -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile"
|
---|
303 | echo $command
|
---|
304 | $command
|
---|
305 | fi
|
---|
306 | check=$?
|
---|
307 | checkreturncode
|
---|
308 | fi
|
---|
309 |
|
---|