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 |
|
---|
39 | source `dirname $0`/sourcefile
|
---|
40 | printprocesslog "INFO starting $0"
|
---|
41 | program=callisto
|
---|
42 | column=fCallisto
|
---|
43 |
|
---|
44 | set -C
|
---|
45 |
|
---|
46 | scriptlog=$runlogpath/run$program-$datetime.log
|
---|
47 | date >> $scriptlog 2>&1
|
---|
48 |
|
---|
49 | # get sequence #
|
---|
50 | gettodo >> $scriptlog 2>&1
|
---|
51 | sequence=$process
|
---|
52 |
|
---|
53 | # lock sequ
|
---|
54 | lockfile=$lockpath/lock-$table-$column-$sequence.txt
|
---|
55 | checklock >> $scriptlog 2>&1
|
---|
56 |
|
---|
57 | cd $mars
|
---|
58 |
|
---|
59 | # run calibration for sequence
|
---|
60 | echo "run $program for sequence $sequence..." >> $scriptlog 2>&1
|
---|
61 | printprocesslog "INFO starting $program for sequence $sequence"
|
---|
62 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
63 | no2=`printf %08d $sequence`
|
---|
64 | var1=$no
|
---|
65 | var2=$no2
|
---|
66 | outpath="$datapath/$program/$no/$no2"
|
---|
67 | makedir $outpath >> $scriptlog 2>&1
|
---|
68 | sequfile="$sequpath/$no/sequence$no2.txt"
|
---|
69 |
|
---|
70 | # define callisto.rc files
|
---|
71 | callistorcnew=$setuppath/$program/callisto.rc
|
---|
72 | callistorcmarapr05=$setuppath/$program/callisto_MarApr05.rc
|
---|
73 | # find callisto.rc file
|
---|
74 | if [ -e $outpath/callisto.rc ]
|
---|
75 | then
|
---|
76 | echo "found $program.rc in $outpath -> using this " >> $scriptlog 2>&1
|
---|
77 | callistorcseq=$outpath/callisto.rc
|
---|
78 | else
|
---|
79 | echo "no $program.rc found in $outpath -> making link " >> $scriptlog 2>&1
|
---|
80 | if [ 49735 -lt $sequence ] && [ $sequence -lt 53516 ]
|
---|
81 | then
|
---|
82 | ln -vs $callistorcmarapr05 $outpath/callisto.rc >> $scriptlog 2>&1
|
---|
83 | else
|
---|
84 | ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
|
---|
85 | fi
|
---|
86 | callistorcseq=$outpath/callisto.rc
|
---|
87 | fi
|
---|
88 |
|
---|
89 | setstatus "start" >> $scriptlog 2>&1
|
---|
90 |
|
---|
91 | ./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
|
---|
92 | check1=$?
|
---|
93 |
|
---|
94 | case $check1 in
|
---|
95 | 0) echo " check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
|
---|
96 | printprocesslog "INFO $program finished successfully for sequence $sequence"
|
---|
97 | # running merpp update if calibration worked
|
---|
98 | # finding files, which have to be updated
|
---|
99 | echo "finding files to be updated..." >> $scriptlog 2>&1
|
---|
100 | calfiles=`find $outpath -name *_Y_* `
|
---|
101 | echo " files to be updated: "$calfiles >> $scriptlog 2>&1
|
---|
102 | if [ "$calfiles" = "" ]
|
---|
103 | then
|
---|
104 | echo " no files found -> continue with next sequence" >> $scriptlog 2>&1
|
---|
105 | continue
|
---|
106 | fi
|
---|
107 |
|
---|
108 | merpplogpath=$outpath"/merpplogs"
|
---|
109 | makedir $merpplogpath >> $scriptlog 2>&1
|
---|
110 |
|
---|
111 | printprocesslog "INFO doing merppupdate for sequence $sequence"
|
---|
112 | # updated calibrated data files with the information from the cc and caco files
|
---|
113 | for calfile in ${calfiles[@]}
|
---|
114 | do
|
---|
115 | echo "calfile: "$calfile >> $scriptlog 2>&1
|
---|
116 | # find cc and caco file
|
---|
117 | # if file is missing continue with next sequence
|
---|
118 | runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
|
---|
119 | 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`
|
---|
120 | source=`echo $ccfile | cut -d_ -f4`
|
---|
121 | cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
|
---|
122 | # cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
|
---|
123 | if [ "$ccfile" = "" ]
|
---|
124 | then
|
---|
125 | echo "no ccfile found for run "$runno >> $scriptlog 2>&1
|
---|
126 | printprocesslog "ERROR no ccfile found for $calfile"
|
---|
127 | com=$Fnoccfile
|
---|
128 | comadd=$runno
|
---|
129 | check=0
|
---|
130 | break
|
---|
131 | fi
|
---|
132 | if [ "$cacofile" = "" ]
|
---|
133 | then
|
---|
134 | echo "cacofile with no $runno not found" >> $scriptlog 2>&1
|
---|
135 | echo "finding cacofile..." >> $scriptlog 2>&1
|
---|
136 | for (( i = 0; i <= 10; i++ ))
|
---|
137 | do
|
---|
138 | newrun=`echo $runno - $i | bc`
|
---|
139 | # echo "$missingcacorun + $i = $newrun"
|
---|
140 | path=`dirname $ccfile`
|
---|
141 | path=`echo $path | sed -e 's/cc/caco/'`
|
---|
142 | echo "path: "$path >> $scriptlog 2>&1
|
---|
143 | cacofile=`find $path -name *$newrun*`
|
---|
144 | if [ "$cacofile" = "" ]
|
---|
145 | then
|
---|
146 | if [ $i -eq 9 ]
|
---|
147 | then
|
---|
148 | echo "no cacofile found" >> $scriptlog 2>&1
|
---|
149 | com=$Fnocacofile
|
---|
150 | comadd=$runno
|
---|
151 | check=0
|
---|
152 | fi
|
---|
153 | continue
|
---|
154 | else
|
---|
155 | echo "cacofile: "$cacofile >> $scriptlog 2>&1
|
---|
156 | break
|
---|
157 | fi
|
---|
158 | done
|
---|
159 | fi
|
---|
160 | ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null
|
---|
161 | check2=$?
|
---|
162 | case $check2 in
|
---|
163 | 0) echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
|
---|
164 | printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
|
---|
165 | ;;
|
---|
166 | *) echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
|
---|
167 | printprocesslog "ERROR merppccupdate failed for $calfile"
|
---|
168 | com=$Fmerppcc
|
---|
169 | comadd=$runno
|
---|
170 | check=$check2
|
---|
171 | break ;;
|
---|
172 | esac
|
---|
173 | ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null
|
---|
174 | check3=$?
|
---|
175 | case $check3 in
|
---|
176 | 0) echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
|
---|
177 | printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
|
---|
178 | ;;
|
---|
179 | *) echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
|
---|
180 | printprocesslog "ERROR merppcacoupdate failed for $calfile"
|
---|
181 | com=$Fmerppcaco
|
---|
182 | comadd=$runno
|
---|
183 | check=$check3
|
---|
184 | break ;;
|
---|
185 | esac
|
---|
186 | done
|
---|
187 | printprocesslog "INFO finished merppupdate successfully for sequence $sequence"
|
---|
188 | ;;
|
---|
189 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
190 | printprocesslog "ERROR $program failed for sequence $sequence (return code $check1)"
|
---|
191 | com=$Fcallisto
|
---|
192 | check=$check1
|
---|
193 | ;;
|
---|
194 | esac
|
---|
195 |
|
---|
196 | setstatus "stop" >> $scriptlog 2>&1
|
---|
197 |
|
---|
198 | finish >> $scriptlog 2>&1
|
---|
199 |
|
---|