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

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