source: trunk/Mars/datacenter/scripts/runcallisto@ 15487

Last change on this file since 15487 was 9099, checked in by snruegam, 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
77callistorcmux=$setuppath/$program/callisto_mux.rc
78
79# find callisto.rc file
80if [ -e $outpath/callisto.rc ]
81then
82 echo "found $program.rc in $outpath -> using this " >> $scriptlog 2>&1
83 callistorcseq=$outpath/callisto.rc
84else
85 echo "no $program.rc found in $outpath -> making link " >> $scriptlog 2>&1
86 if [ $sequence -gt 200000 ]
87 then
88 ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
89 else
90 ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
91 fi
92 callistorcseq=$outpath/callisto.rc
93fi
94
95# lock sequ for zipping
96lockfile=$lockpath/calzip${sequence}-${telnum}.txt
97# if lockfile is already existing, 1 is returned
98if ! checklock return 1 >> $scriptlog 2>&1
99then
100 # reset lockfile name
101 lockfile=$lockpath/lock-$table-$column-$sequence.txt
102 finish >> $scriptlog 2>&1
103fi
104
105setstatus "start" >> $scriptlog 2>&1
106
107# stage the needed files; to be removed as soon as the correct stub file size has been determined
108echo "staging files:" >> $scriptlog 2>&1
109
110echo 'root -q -b $macrospath/stage.C\("\"$sequfile\""\) | tee -a $scriptlog | intgrep' >> $scriptlog 2>&1
111check0=`root -q -b $macrospath/stage.C\("\"$sequfile\""\) | tee -a $scriptlog | intgrep`
112
113case $check0 in
114 0) echo " check0=$check0 -> everything ok -> files staging..." >> $scriptlog 2>&1
115 printprocesslog "INFO staging files started for $sequence"
116 ;;
117 *) echo " check0=$check0 -> an error occured..." >> $scriptlog 2>&1
118 printprocesslog "ERROR getting sequence $sequence"
119 check="no"
120 ;;
121esac
122
123
124echo "./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
125./callisto -b -q -v4 -f --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
126check1=$?
127
128# remove lockfile for zip and reset lockfile name
129rm -v $lockfile >> $scriptlog 2>&1
130lockfile=$lockpath/lock-$table-$column-$sequence.txt
131
132case $check1 in
133 0) echo " check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
134 printprocesslog "INFO $program finished successfully for sequence $sequence"
135
136 printprocesslog "INFO starting merpp/ccupdate for sequence $sequence"
137
138 # updated calibrated data files with the information from the cc and caco files
139 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
140 ./merpp -v3 --log=$outpath/merpp$no2.log --html=$outpath/merpp$no2.html --auto-time-stop $sequfile $outpath 2>> $scriptlog > /dev/null
141 check2=$?
142
143 case $check2 in
144 0) echo " check2=$check2 -> everything ok, merpp/ccupdate worked -> continue" >> $scriptlog 2>&1
145 printprocesslog "INFO merpp/ccupdate of sequence $sequence sucessfull"
146 ;;
147 *) echo " check2=$check2 -> ERROR -> merpp/ccupdate $sequence failed" >> $scriptlog 2>&1
148 printprocesslog "ERROR merpp/ccupdate of sequence $sequence failed"
149 com=$Fmerppcc
150 check=$check2
151# comadd=$runno
152 ;;
153 esac
154 ;;
155 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
156 printprocesslog "ERROR $program failed for sequence $sequence (return code $check1)"
157 com=$Fcallisto
158 check=$check1
159 ;;
160esac
161
162setstatus "stop" >> $scriptlog 2>&1
163
164finish >> $scriptlog 2>&1
165
Note: See TracBrowser for help on using the repository browser.