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-2008
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script is launching the calibration of sequences.
|
---|
28 | #
|
---|
29 | # As callisto takes some time, only one sequence is processed at once.
|
---|
30 | # First the script gets a sequence number from the database, for which
|
---|
31 | # the calibration has to be done (function gettodo). After setting the
|
---|
32 | # status in the database (set fStartTime to know, that the sequence is
|
---|
33 | # already being processed), the sequence is calibrated and the merpp
|
---|
34 | # update is done. Afterwards the status in the database is updated
|
---|
35 | # according to the return value of the program. In case one of the merpp
|
---|
36 | # update failes, also the corresponding runnumber is inserted into the
|
---|
37 | # database.
|
---|
38 | # The important INFOs, WARNings and ERRORs are written not only to the
|
---|
39 | # scriptlog but also to the processlog.
|
---|
40 | #
|
---|
41 | # The callisto.rc files are stored in the setup directory
|
---|
42 | #
|
---|
43 |
|
---|
44 | source `dirname $0`/sourcefile
|
---|
45 | printprocesslog "INFO starting $0"
|
---|
46 | program=callisto
|
---|
47 | column=fCallisto
|
---|
48 |
|
---|
49 | set -C
|
---|
50 |
|
---|
51 | scriptlog=$runlogpath/run$program-$datetime.log
|
---|
52 | date >> $scriptlog 2>&1
|
---|
53 |
|
---|
54 | # get sequence #
|
---|
55 | gettodo "1" >> $scriptlog 2>&1
|
---|
56 | sequence=${primaries[0]}
|
---|
57 | telnum=${primaries[1]}
|
---|
58 |
|
---|
59 | # lock sequ for cal
|
---|
60 | lockfile=$lockpath/lock-$table-$column-$sequence.txt
|
---|
61 | checklock >> $scriptlog 2>&1
|
---|
62 |
|
---|
63 | cd $mars
|
---|
64 |
|
---|
65 | # run calibration for sequence
|
---|
66 | echo "run $program for sequence $sequence..." >> $scriptlog 2>&1
|
---|
67 | printprocesslog "INFO starting $program for sequence $sequence"
|
---|
68 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
69 | no2=`printf %08d $sequence`
|
---|
70 | sequfile="$sequpath/$no/sequence$no2.txt"
|
---|
71 |
|
---|
72 | outpath="$datapath/$program/$no/$no2"
|
---|
73 | makedir $outpath >> $scriptlog 2>&1
|
---|
74 |
|
---|
75 | # define callisto.rc files
|
---|
76 | callistorcnew=$setuppath/$program/callisto.rc
|
---|
77 | #callistorcmux=$setuppath/$program/callisto_mux.rc
|
---|
78 | callistorcmux=$setuppath/$program/callisto_mux_new.rc
|
---|
79 |
|
---|
80 | # find callisto.rc file
|
---|
81 | if [ -e $outpath/callisto.rc ]
|
---|
82 | then
|
---|
83 | echo "found $program.rc in $outpath -> using this " >> $scriptlog 2>&1
|
---|
84 | callistorcseq=$outpath/callisto.rc
|
---|
85 | else
|
---|
86 | echo "no $program.rc found in $outpath -> making link " >> $scriptlog 2>&1
|
---|
87 | if [ $sequence -gt 200000 ]
|
---|
88 | then
|
---|
89 | ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
|
---|
90 | else
|
---|
91 | ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
|
---|
92 | fi
|
---|
93 | callistorcseq=$outpath/callisto.rc
|
---|
94 | fi
|
---|
95 |
|
---|
96 | # lock sequ for zipping
|
---|
97 | lockfile=$lockpath/calzip$sequence.txt
|
---|
98 | # if lockfile is already existing, 1 is returned
|
---|
99 | if ! checklock return 1 >> $scriptlog 2>&1
|
---|
100 | then
|
---|
101 | # reset lockfile name
|
---|
102 | lockfile=$lockpath/lock-$table-$column-$sequence.txt
|
---|
103 | finish >> $scriptlog 2>&1
|
---|
104 | fi
|
---|
105 |
|
---|
106 | setstatus "start" >> $scriptlog 2>&1
|
---|
107 |
|
---|
108 | # stage the needed files; to be removed as soon as the correct stub file size has been determined
|
---|
109 | echo "staging files:" >> $scriptlog 2>&1
|
---|
110 |
|
---|
111 | echo 'root -q -b $macrospath/stage.C\("\"$sequfile\""\) | tee -a $scriptlog | intgrep' >> $scriptlog 2>&1
|
---|
112 | check0=`root -q -b $macrospath/stage.C\("\"$sequfile\""\) | tee -a $scriptlog | intgrep`
|
---|
113 |
|
---|
114 | case $check0 in
|
---|
115 | 0) echo " check0=$check0 -> everything ok -> files staging..." >> $scriptlog 2>&1
|
---|
116 | printprocesslog "INFO staging files started for $sequence"
|
---|
117 | ;;
|
---|
118 | *) echo " check0=$check0 -> an error occured..." >> $scriptlog 2>&1
|
---|
119 | printprocesslog "ERROR getting sequence $sequence"
|
---|
120 | check="no"
|
---|
121 | ;;
|
---|
122 | esac
|
---|
123 |
|
---|
124 |
|
---|
125 | echo "./callisto -b -q -v4 -f --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null" >> $scriptlog 2>&1
|
---|
126 | ./callisto -b -q -v4 -f --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
|
---|
127 | check1=$?
|
---|
128 |
|
---|
129 | # remove lockfile for zip and reset lockfile name
|
---|
130 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
131 | lockfile=$lockpath/lock-$table-$column-$sequence.txt
|
---|
132 |
|
---|
133 | case $check1 in
|
---|
134 | 0) echo " check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
|
---|
135 | printprocesslog "INFO $program finished successfully for sequence $sequence"
|
---|
136 |
|
---|
137 | printprocesslog "INFO starting merpp/ccupdate for sequence $sequence"
|
---|
138 |
|
---|
139 | # updated calibrated data files with the information from the cc and caco files
|
---|
140 | echo "./merpp -v3 --log=$outpath/merpp$no2.log --html=$outpath/merpp$no2.html --auto-time-stop $sequfile $outpath 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
|
---|
141 | ./merpp -v3 --log=$outpath/merpp$no2.log --html=$outpath/merpp$no2.html --auto-time-stop $sequfile $outpath 2>> $scriptlog > /dev/null
|
---|
142 | check2=$?
|
---|
143 |
|
---|
144 | case $check2 in
|
---|
145 | 0) echo " check2=$check2 -> everything ok, merpp/ccupdate worked -> continue" >> $scriptlog 2>&1
|
---|
146 | printprocesslog "INFO merpp/ccupdate of sequence $sequence sucessfull"
|
---|
147 | ;;
|
---|
148 | *) echo " check2=$check2 -> ERROR -> merpp/ccupdate $sequence failed" >> $scriptlog 2>&1
|
---|
149 | printprocesslog "ERROR merpp/ccupdate of sequence $sequence failed"
|
---|
150 | com=$Fmerppcc
|
---|
151 | check=$check2
|
---|
152 | # comadd=$runno
|
---|
153 | ;;
|
---|
154 | esac
|
---|
155 | ;;
|
---|
156 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
157 | printprocesslog "ERROR $program failed for sequence $sequence (return code $check1)"
|
---|
158 | com=$Fcallisto
|
---|
159 | check=$check1
|
---|
160 | ;;
|
---|
161 | esac
|
---|
162 |
|
---|
163 | setstatus "stop" >> $scriptlog 2>&1
|
---|
164 |
|
---|
165 | finish >> $scriptlog 2>&1
|
---|
166 |
|
---|