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

Last change on this file since 9082 was 9054, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.1 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-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
44source `dirname $0`/sourcefile
45printprocesslog "INFO starting $0"
46program=callisto
47column=fCallisto
48
49set -C
50
51scriptlog=$runlogpath/run$program-$datetime.log
52date >> $scriptlog 2>&1
53
54# get sequence #
55gettodo "1" >> $scriptlog 2>&1
56sequence=${primaries[0]}
57telnum=${primaries[1]}
58
59# lock sequ for cal
60lockfile=$lockpath/lock-$table-$column-$sequence.txt
61checklock >> $scriptlog 2>&1
62
63cd $mars
64
65# run calibration for sequence
66echo "run $program for sequence $sequence..." >> $scriptlog 2>&1
67printprocesslog "INFO starting $program for sequence $sequence"
68no=`printf %08d $sequence | cut -c 0-4`
69no2=`printf %08d $sequence`
70sequfile="$sequpath/$no/sequence$no2.txt"
71
72outpath="$datapath/$program/$no/$no2"
73makedir $outpath >> $scriptlog 2>&1
74
75# define callisto.rc files
76callistorcnew=$setuppath/$program/callisto.rc
77#callistorcmux=$setuppath/$program/callisto_mux.rc
78callistorcmux=$setuppath/$program/callisto_mux_new.rc
79
80# find callisto.rc file
81if [ -e $outpath/callisto.rc ]
82then
83 echo "found $program.rc in $outpath -> using this " >> $scriptlog 2>&1
84 callistorcseq=$outpath/callisto.rc
85else
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
94fi
95
96# lock sequ for zipping
97lockfile=$lockpath/calzip$sequence.txt
98# if lockfile is already existing, 1 is returned
99if ! checklock return 1 >> $scriptlog 2>&1
100then
101 # reset lockfile name
102 lockfile=$lockpath/lock-$table-$column-$sequence.txt
103 finish >> $scriptlog 2>&1
104fi
105
106setstatus "start" >> $scriptlog 2>&1
107
108# stage the needed files; to be removed as soon as the correct stub file size has been determined
109echo "staging files:" >> $scriptlog 2>&1
110
111echo 'root -q -b $macrospath/stage.C\("\"$sequfile\""\) | tee -a $scriptlog | intgrep' >> $scriptlog 2>&1
112check0=`root -q -b $macrospath/stage.C\("\"$sequfile\""\) | tee -a $scriptlog | intgrep`
113
114case $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 ;;
122esac
123
124
125echo "./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
127check1=$?
128
129# remove lockfile for zip and reset lockfile name
130rm -v $lockfile >> $scriptlog 2>&1
131lockfile=$lockpath/lock-$table-$column-$sequence.txt
132
133case $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 ;;
161esac
162
163setstatus "stop" >> $scriptlog 2>&1
164
165finish >> $scriptlog 2>&1
166
Note: See TracBrowser for help on using the repository browser.