source: trunk/MagicSoft/Mars/datacenter/scripts/runmccallisto@ 9157

Last change on this file since 9157 was 8967, checked in by hoehne, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 9.8 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# Author(s): Daniel Hoehne 06/2008 <mailto:hoehne@astro.uni-wuerzburg.de>
22#
23# Copyright: MAGIC Software Development, 2000-2008
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
46source `dirname $0`/sourcefile
47printprocesslog "INFO starting $0"
48program=callisto
49column=fCallisto
50
51set -C
52
53scriptlog=$runlogpath/runmc$program-$datetime.log
54date >> $scriptlog 2>&1
55
56# get sequence #
57gettodo >> $scriptlog 2>&1
58sequence=$process
59
60# lock sequ for cal
61lockfile=$lockpath/lock-$table-$column-$sequence.txt
62checklock >> $scriptlog 2>&1
63
64cd $mars
65
66# run calibration for sequence
67echo "run $program for mc sequence $sequence..." >> $scriptlog 2>&1
68printprocesslog "INFO starting $program for mc sequence $sequence"
69no=`printf %08d $sequence | cut -c 0-4`
70no2=`printf %08d $sequence`
71outpath="$mcpath/$program/$no/$no2"
72makedir $outpath >> $scriptlog 2>&1
73sequfile="$mcsequpath/$no/sequence$no2.txt"
74
75## stage the needed files; to be removed as soon as the correct stub file size has been determined
76#echo "staging files:" >> $scriptlog 2>&1
77#day=`grep Night $sequfile | cut -c 18-27 | sed -e "s/-/\//g"`
78#runs=`grep Runs $sequfile | cut -d: -f2`
79#i=0
80#
81#for run in ${runs[@]}
82#do
83# files[i]=19*_${run}_[PCD]_*_E.root
84# echo ${mcpath}/rawfiles/${day}/${files[i]} >> $scriptlog 2>&1
85# let i++
86#done
87#
88#ssh -nx phoenix "cd ${mcpath}/rawfiles/${day}; /opt/SUNWsamfs/bin/stage ${files[@]}"
89
90
91# define callisto.rc files
92callistorcnew=$setuppath/$program/callisto.rc
93callistorcmux=$setuppath/$program/callisto_mux_new.rc
94
95epoch=`grep Epoch $sequfile | cut -d: -f2 | grep Mux`
96# find callisto.rc file
97if [ -e $outpath/callisto.rc ]
98then
99 echo "found $program.rc in $outpath -> using this " >> $scriptlog 2>&1
100 callistorcseq=$outpath/callisto.rc
101else
102 echo "no $program.rc found in $outpath -> making link " >> $scriptlog 2>&1
103 if [ "$epoch" = "" ]
104 then
105 ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
106 else
107 ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
108 fi
109 callistorcseq=$outpath/callisto.rc
110fi
111
112# lock sequ for zipping
113#lockfile=$lockpath/calzip$sequence.txt
114# if lockfile is already existing, 1 is returned
115#if ! checklock return 1 >> $scriptlog 2>&1
116#then
117 # reset lockfile name
118# lockfile=$lockpath/lock-$table-$column-$sequence.txt
119# finish >> $scriptlog 2>&1
120#fi
121
122primvar=$no2
123setstatus "start" >> $scriptlog 2>&1
124
125echo "./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
126./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
127check1=$?
128
129# remove lockfile for zip and reset lockfile name
130#rm -v $lockfile >> $scriptlog 2>&1
131#lockfile=$lockpath/lock-$table-$column-$sequence.txt
132
133case $check1 in
134 0) echo " check1=$check1 -> everything ok" >> $scriptlog 2>&1
135 printprocesslog "INFO $program finished successfully for mc sequence $sequence"
136 ;;
137 # running merpp update if calibration worked
138 # finding files, which have to be updated
139# echo "finding files to be updated..." >> $scriptlog 2>&1
140# calfiles=`find $outpath -name *_Y_* `
141# if [ "$calfiles" = "" ]
142# then
143# echo " no files found -> continue with next sequence" >> $scriptlog 2>&1
144# printprocesslog "ERROR no calfiles found"
145# fi
146# echo " files to be updated: "$calfiles >> $scriptlog 2>&1
147#
148# merpplogpath=$outpath"/merpplogs"
149# makedir $merpplogpath >> $scriptlog 2>&1
150#
151# printprocesslog "INFO doing merppupdate for sequence $sequence"
152# # updated calibrated data files with the information from the cc and caco files
153# for calfile in ${calfiles[@]}
154# do
155# echo "calfile: "$calfile >> $scriptlog 2>&1
156# # find cc and caco file
157# # if file is missing continue with next sequence
158# date=`date --date \`basename $calfile | cut -d_ -f1\` +%Y/%m/%d`
159# ccpath=$subsystempath/cc/$date
160# cacopath=$subsystempath/caco/$date
161# runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
162# ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
163# source=`echo $ccfile | cut -d_ -f4`
164# cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
165# if [ "$ccfile" = "" ]
166# then
167# echo "no ccfile found for run "$runno >> $scriptlog 2>&1
168# printprocesslog "ERROR ccfile $ccfile not found for $calfile"
169# com=$Fnoccfile
170# comadd=$runno
171# check=0
172# break
173# fi
174# if [ "$cacofile" = "" ]
175# then
176# echo "cacofile with no $runno not found" >> $scriptlog 2>&1
177# echo "finding cacofile..." >> $scriptlog 2>&1
178# for (( i = 0; i <= 10; i++ ))
179# do
180# newrun=`echo $runno - $i | bc`
181# cacofile=`find $cacopath -name *$newrun*`
182# if [ "$cacofile" = "" ]
183# then
184# if [ $i -eq 9 ]
185# then
186# echo "no cacofile found for runno $newrun in $cacopath" >> $scriptlog 2>&1
187# printprocesslog "ERROR cacofile $cacofile not found for $calfile"
188# com=$Fnocacofile
189# comadd=$runno
190# check=0
191# break 2
192# fi
193# continue
194# else
195# echo "cacofile: "$cacofile >> $scriptlog 2>&1
196# break
197# fi
198# done
199# fi
200# 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
201# ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null
202# check2=$?
203# case $check2 in
204# 0) echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
205# printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
206# ;;
207# *) echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
208# printprocesslog "ERROR merppccupdate with file $ccfile failed for $calfile"
209# com=$Fmerppcc
210# comadd=$runno
211# check=$check2
212# break ;;
213# esac
214# echo "./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
215# ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null
216# check3=$?
217# case $check3 in
218# 0) echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
219# printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
220# ;;
221# *) echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
222# printprocesslog "ERROR merppcacoupdate with file $cacofile failed for $calfile"
223# com=$Fmerppcaco
224# comadd=$runno
225# check=$check3
226# break ;;
227# esac
228# done
229# printprocesslog "INFO finished merppupdate successfully for sequence $sequence"
230# ;;
231 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
232 printprocesslog "ERROR $program failed for mc sequence $sequence (return code $check1)"
233 com=$Fmccallisto
234 check=$check1
235 ;;
236esac
237
238setstatus "stop" >> $scriptlog 2>&1
239
240finish >> $scriptlog 2>&1
241
Note: See TracBrowser for help on using the repository browser.