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 | # Author(s): Daniel Hoehne-Moench 01/2009 <mailto:hoehne@astro.uni-wuerzburg.de>
|
---|
22 | #
|
---|
23 | # Copyright: MAGIC Software Development, 2000-2009
|
---|
24 | #
|
---|
25 | #
|
---|
26 | # ========================================================================
|
---|
27 | #
|
---|
28 | # This script is launching the calibration of mc sequences.
|
---|
29 | #
|
---|
30 | # As callisto takes some time, only one sequence is processed at once.
|
---|
31 | # First the script gets a sequence number from the mc database, for which
|
---|
32 | # the calibration has to be done (function gettodo). After setting the
|
---|
33 | # status in the database (set fStartTime to know, that the sequence is
|
---|
34 | # already being processed), the sequence is calibrated. Afterwards
|
---|
35 | # the status in the mc database is updated according to the return value
|
---|
36 | # of the program.
|
---|
37 | # The important INFOs, WARNings and ERRORs are written not only to the
|
---|
38 | # scriptlog but also to the processlog.
|
---|
39 | #
|
---|
40 | # Atm the processing has to be done in a separate Mars directory because
|
---|
41 | # different sql.rc and steps.rc files are needed.
|
---|
42 | #
|
---|
43 | # The callisto.rc files are stored in the setup directory
|
---|
44 | #
|
---|
45 |
|
---|
46 | source `dirname $0`/sourcefile
|
---|
47 | printprocesslog "INFO starting $0"
|
---|
48 | program=callisto
|
---|
49 | column=fCallisto
|
---|
50 |
|
---|
51 | set -C
|
---|
52 |
|
---|
53 | scriptlog=$runlogpath/runmc$program-$datetime.log
|
---|
54 | date >> $scriptlog 2>&1
|
---|
55 |
|
---|
56 | # get sequence #
|
---|
57 | gettodo "1" >> $scriptlog 2>&1
|
---|
58 | sequence=${primaries[0]}
|
---|
59 |
|
---|
60 | # lock sequ for cal
|
---|
61 | lockfile=$lockpath/lock-$table-$column-$sequence.txt
|
---|
62 | checklock >> $scriptlog 2>&1
|
---|
63 |
|
---|
64 | cd $mars
|
---|
65 |
|
---|
66 | # run calibration for sequence
|
---|
67 | echo "run $program for mc sequence $sequence..." >> $scriptlog 2>&1
|
---|
68 | printprocesslog "INFO starting $program for mc sequence $sequence"
|
---|
69 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
70 | no2=`printf %08d $sequence`
|
---|
71 | outpath="$mcpath/$program/$no/$no2"
|
---|
72 | makedir $outpath >> $scriptlog 2>&1
|
---|
73 | sequfile="$mcsequpath/$no/sequence$no2.txt"
|
---|
74 |
|
---|
75 | # define callisto.rc files
|
---|
76 | callistorcnew=$setuppath/$program/callisto.rc
|
---|
77 | callistorcmux=$setuppath/$program/callisto_mux.rc
|
---|
78 |
|
---|
79 | epoch=`grep Epoch $sequfile | cut -d: -f2 | grep Mux`
|
---|
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 [ "$epoch" = "" ]
|
---|
88 | then
|
---|
89 | ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
|
---|
90 | else
|
---|
91 | ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
|
---|
92 | fi
|
---|
93 | callistorcseq=$outpath/callisto.rc
|
---|
94 | fi
|
---|
95 |
|
---|
96 | primvar=$no2
|
---|
97 | setstatus "start" >> $scriptlog 2>&1
|
---|
98 |
|
---|
99 | echo "./callisto -mc -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
|
---|
100 | ./callisto -mc -b -q -v4 -f --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
|
---|
101 | check1=$?
|
---|
102 |
|
---|
103 | case $check1 in
|
---|
104 | 0) echo " check1=$check1 -> everything ok" >> $scriptlog 2>&1
|
---|
105 | printprocesslog "INFO $program finished successfully for mc sequence $sequence"
|
---|
106 | ;;
|
---|
107 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
108 | printprocesslog "ERROR $program failed for mc sequence $sequence (return code $check1)"
|
---|
109 | com=$Fmccallisto
|
---|
110 | check=$check1
|
---|
111 | ;;
|
---|
112 | esac
|
---|
113 |
|
---|
114 | setstatus "stop" >> $scriptlog 2>&1
|
---|
115 |
|
---|
116 | finish >> $scriptlog 2>&1
|
---|
117 |
|
---|