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

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