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

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