source: trunk/MagicSoft/Mars/scripts/processsequence@ 8025

Last change on this file since 8025 was 8006, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 9.0 KB
Line 
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
45outpath=
46#give either sequence number or sequence file (including path)
47sequence=
48sequfile=""
49
50function 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 " -merppu "
65# echo " running only merppupdate"
66 echo -n " -star "
67 echo " running only star"
68 echo ""
69 echo "Remarks: "
70 echo " - you can set the variables (or part of it) also in the script "
71 echo " - you have to set the outpath and either the sequence number or the sequence file"
72 echo " (if both is set, the sequence given by the sequencefile is processed)"
73 echo ""
74 exit
75}
76
77interactive="yes"
78
79while [ "$1" ]
80do
81 case $1 in
82 --sequ) shift
83 sequence=$1
84 ;;
85 --mars) shift
86 mars=$1
87 ;;
88 --out) shift
89 outpath=$1
90 ;;
91 -b) interactive='no'
92 ;;
93 -cal) cal='yes'
94 ;;
95# -merppu) merppu='yes'
96# ;;
97 -star) star='yes'
98 ;;
99 --sequ-file) shift
100 sequfile=$1
101 ;;
102 -h) usage
103 ;;
104 *) echo "unknown option $1 "
105 usage
106 exit
107 ;;
108 esac
109 shift
110done
111
112##getting settings for root
113#if [ "$mars" = "" ]
114#then
115# echo "WARNING Mars-Version has not been set"
116# echo ""
117# usage
118#fi
119#source $mars/datacenter/scripts/setup
120
121if [ "$outpath" = "" ]
122then
123 echo "WARNING outpath has not been set"
124 echo ""
125 usage
126fi
127
128if [ "$sequence" = "" ] && [ "$sequfile" = "" ]
129then
130 echo "WARNING neither sequ nor sequfile has been set"
131 echo ""
132 usage
133fi
134
135echo ""
136echo "You have set the variables to: "
137#echo "mars: "$mars
138echo " outpath: "$outpath
139
140if [ "$sequfile" = "" ]
141then
142 if ! n8=`printf %08d $sequence`
143 then
144 echo "your sequence number is not valid"
145 usage
146 exit
147 fi
148 no=`echo $n8 | cut -c 1-4`
149 sequfile="/magic/sequences/"$no"/sequence$n8.txt"
150 echo " sequence: "$sequence
151 echo " sequfile: "$sequfile
152 if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
153 then
154 calpath=$outpath"/callisto/$n8"
155 echo " path where calibration files are stored : "$calpath
156 fi
157 if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
158 then
159 starpath=$outpath"/star/$n8"
160 echo " path where star files are stored : "$starpath
161 fi
162else
163 echo " sequfile: "$sequfile
164 if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
165 then
166 calpath=$outpath"/callisto"
167 echo " path where calibration files are stored : "$calpath
168 fi
169 if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
170 then
171 starpath=$outpath"/star"
172 echo " path where star files are stored : "$starpath
173 fi
174fi
175
176
177if [ "$interactive" = "yes" ]
178then
179 echo ""
180 echo "paths ok? continue?"
181 echo "please insert y, if you want continue"
182 echo " n, if you want quit"
183
184 answer=`head -n 1`
185# echo "answer: "$answer
186 case $answer in
187 y) echo "continue processing sequence"
188 ;;
189 n) exit
190 ;;
191 *) echo "your answer is not clear -> exit"
192 exit
193 ;;
194 esac
195fi
196
197exit
198
199
200#cd $mars
201
202if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
203then
204 mkdir -pv $calpath
205
206 echo "run callisto..."
207 echo "./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile "
208 ./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile
209 check=$?
210 case $check in
211 0) echo "callisto finished sucessfully"
212 echo "";;
213 *) echo -n "ERROR: callisto returned $check - please check "
214 echo -n "http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
215 echo " for more details"
216 exit;;
217 esac
218
219
220 calfiles=`find $calpath -name [2][0][0-2][0-9][0,1][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 makedir $merpplogpath
233
234 runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
235 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`
236 cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
237 echo "runno: "$runno
238 echo "ccfile: "$ccfile
239 if [ "$ccfile" = "" ]
240 then
241 echo "no ccfile found for run "$runno
242 break
243 fi
244 echo "cacofile: "$cacofile
245 if [ "$cacofile" = "" ]
246 then
247 echo "no cacofile found for run "$runno
248 echo "finding cacofile..."
249 for (( i = 0; i <= 10; i++ ))
250 do
251 newrun=`echo $runno - $i | bc`
252 # echo "$missingcacorun + $i = $newrun"
253 path=`dirname $ccfile`
254 path=`echo $path | sed -e 's/cc/caco/'`
255 echo "path: "$path
256 cacofile=`find $path -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 logfile=$merpplogpath/merppccupdate$runno.log
268 echo "./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
269 ./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile
270 check=$?
271 case $check in
272 0) ;;
273 *) echo "ERROR: merppccupdate returned $check "
274 echo "please check the logfile $logfile "
275 exit;;
276 esac
277
278 logfile=$merpplogpath/merppcacoupdate$runno.log
279 echo "./merpp -u --log=$logfile --auto-time $cacofile $calfile "
280 ./merpp -u --log=$logfile --auto-time $cacofile $calfile
281 check=$?
282 case $check in
283 0) ;;
284 *) echo "ERROR: merppcacoupdate returned $check "
285 echo "please check the logfile $logfile "
286 exit;;
287 esac
288 done
289 echo "merppupdate is finished"
290 echo ""
291fi
292
293if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
294then
295 mkdir -pv $starpath
296
297 echo "run star..."
298 logfile=$starpath/star$sequence.log
299 if ! ls $calpath
300 then
301 echo "couldn't find $calpath => taking standard inpath for star"
302 echo "./star -b -q -f --log=$logfile --out=$starpath $sequfile "
303 ./star -b -q -f --log=$logfile --out=$starpath $sequfile
304 else
305 echo "./star -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile "
306 ./star -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile
307 fi
308 check=$?
309 case $check in
310 0) echo "star finished sucessfully"
311 echo "";;
312 *) echo "ERROR: star returned $check - please check "
313 echo "please check the logfile $logfile "
314 exit;;
315 esac
316
317 echo "star is finished "
318fi
319
320
Note: See TracBrowser for help on using the repository browser.