source: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto@ 7920

Last change on this file since 7920 was 7920, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 8.4 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 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2006
23#
24#
25# ========================================================================
26#
27# This script is launching the calibration of sequences.
28#
29# In the case of calibration only one sequence is processed. Despite of
30# that the structure of the script is such, that also more sequences could
31# be processed. The restriction to one sequence has been made, as the
32# calibration takes some time. There's one todo file per sequence.
33# First the script searches for a todo file. Then the sequence from this
34# todo file is calibrated and the merpp update is done.
35#
36# the callisto.rc files are stored in the setup directory
37#
38
39program=callisto
40source `dirname $0`/sourcefile
41
42set -C
43
44# define callisto.rc files
45callistorcnew=$setuppath/$program/callisto.rc
46callistorcmarapr05=$setuppath/$program/callisto_MarApr05.rc
47
48column=fCallisto
49#pno=500 # number of processes, i.e. number of todo-files
50
51lockfile=$lockpath/lock-getting-$program-list.txt
52
53scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
54makedir $scriptlogpath
55scriptlog=$scriptlogpath/run$program-$datetime.log
56
57date >> $scriptlog 2>&1
58
59# get todo file
60possibletodofiles=`ls -r $listpath/ToDo-*-$column-*.txt` >> $scriptlog 2>&1
61if [ "$possibletodofiles" = "" ]
62then
63 echo "ERROR: in $program no todofiles found => something went wrong in jobmanager"
64 finish >> $scriptlog 2>&1
65else
66 singleprocess="yes"
67 echo "todofiles: "${possibletodofiles[@]} >> $scriptlog 2>&1
68 for possibletodofile in ${possibletodofiles[@]}
69 do
70 if ! ls $possibletodofile >> $scriptlog 2>&1
71 then
72 echo "file is not on disk -> continue" >> $scriptlog 2>&1
73 continue
74 fi
75 lockfile=`echo $possibletodofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
76 checklock >> $scriptlog 2>&1
77 todofile=$possibletodofile
78 done
79fi
80if [ "$todofile" = "" ]
81then
82 echo "no todofile found -> exit" >> $scriptlog 2>&1
83 finish >> $scriptlog 2>&1
84fi
85
86# get sequence(s) from todo file
87sequences=(`cat $todofile`)
88if [ "$sequences" = "" ]
89then
90 echo "nothing to do -> exit" >> $scriptlog 2>&1
91 finish >> $scriptlog 2>&1
92fi
93echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
94rm -v $todofile >> $scriptlog 2>&1
95
96cd $mars
97
98# run calibration for sequence(s)
99for sequence in ${sequences[@]}
100do
101 echo "run $program for sequence $sequence..." >> $scriptlog 2>&1
102 no=`printf %08d $sequence | cut -c 0-4`
103 no2=`printf %08d $sequence`
104 var1=$no
105 var2=$no2
106 outpath="$datapath/$program/$no/$no2"
107 makedir $outpath >> $scriptlog 2>&1
108
109 sequfile="$sequpath/$no/sequence$no2.txt"
110
111 # find callisto.rc file
112 if [ -e $outpath/callisto.rc ]
113 then
114 echo "found $program.rc in $outpath -> using this " >> $scriptlog 2>&1
115 callistorcseq=$outpath/callisto.rc
116 else
117 echo "no $program.rc found in $outpath -> making link " >> $scriptlog 2>&1
118 if [ 49735 -lt $sequence ] && [ $sequence -lt 53516 ]
119 then
120 ln -vs $callistorcmarapr05 $outpath/callisto.rc >> $scriptlog 2>&1
121 else
122 ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
123 fi
124 callistorcseq=$outpath/callisto.rc
125 fi
126
127 setstatus "start" >> $scriptlog 2>&1
128
129 ./callisto -b -q -v4 -f -raw --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
130 check1=$?
131
132 case $check1 in
133 0) echo " check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
134 # running merpp update if calibration worked
135 # finding files, which have to be updated
136 echo "finding files to be updated..." >> $scriptlog 2>&1
137 calfiles=`find $outpath -name *_Y_* `
138 echo " files to be updated: "$calfiles >> $scriptlog 2>&1
139 if [ "$calfiles" = "" ]
140 then
141 echo " no files found -> continue with next sequence" >> $scriptlog 2>&1
142 continue
143 fi
144
145 merpplogpath=$outpath"/merpplogs"
146 makedir $merpplogpath >> $scriptlog 2>&1
147
148 # updated calibrated data files with the information from the cc and caco files
149 for calfile in ${calfiles[@]}
150 do
151 echo "calfile: "$calfile >> $scriptlog 2>&1
152 # find cc and caco file
153 # if file is missing continue with next sequence
154 runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
155 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`
156 source=`echo $ccfile | cut -d_ -f4`
157 cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
158# cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
159 if [ "$ccfile" = "" ]
160 then
161 echo "no ccfile found for run "$runno >> $scriptlog 2>&1
162 com=$Fnoccfile
163 comadd=$runno
164 check=0
165 break
166 fi
167 if [ "$cacofile" = "" ]
168 then
169 echo "cacofile with no $runno not found" >> $scriptlog 2>&1
170 echo "finding cacofile..." >> $scriptlog 2>&1
171 for (( i = 0; i <= 10; i++ ))
172 do
173 newrun=`echo $runno - $i | bc`
174 # echo "$missingcacorun + $i = $newrun"
175 path=`dirname $ccfile`
176 path=`echo $path | sed -e 's/cc/caco/'`
177 echo "path: "$path >> $scriptlog 2>&1
178 cacofile=`find $path -name *$newrun*`
179 if [ "$cacofile" = "" ]
180 then
181 if [ $i -eq 9 ]
182 then
183 echo "no cacofile found" >> $scriptlog 2>&1
184 com=$Fnocacofile
185 comadd=$runno
186 check=0
187 fi
188 continue
189 else
190 echo "cacofile: "$cacofile >> $scriptlog 2>&1
191 break
192 fi
193 done
194 fi
195 ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null
196 check2=$?
197 case $check2 in
198 0) echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1;;
199 *) echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
200 com=$Fmerppcc
201 comadd=$runno
202 check=$check2
203 break ;;
204 esac
205 ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null
206 check3=$?
207 case $check3 in
208 0) echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1;;
209 *) echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
210 com=$Fmerppcaco
211 comadd=$runno
212 check=$check3
213 break ;;
214 esac
215 done
216 ;;
217 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
218 com=$Fcallisto
219 check=$check1
220 ;;
221 esac
222
223 setstatus "stop" >> $scriptlog 2>&1
224done
225
226finish >> $scriptlog 2>&1
227
Note: See TracBrowser for help on using the repository browser.