source: trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto@ 7323

Last change on this file since 7323 was 7265, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.7 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-2004
23#
24#
25# ========================================================================
26#
27#
28
29user=`whoami`
30source /home/$user/Mars/datacenter/scripts/sourcefile
31
32set -C
33
34table=SequenceProcessStatus
35column=fFillCallisto
36date=NULL
37datetime=`date +%F-%H-%M-%S`
38year=`date +%Y`
39
40todofile=$listpath/ToDo-$table-$column.txt
41getstatuslogpath=$logpath/getstatus/fillcallisto/$year
42getstatuslog=$getstatuslogpath/getstatus-fillcallisto-$datetime.log
43
44scriptlogpath=$logpath/run/fillcallisto/`date +%Y/%m/%d`
45makedir $scriptlogpath
46
47scriptlog=$scriptlogpath/runfillcallisto-$datetime.log
48
49date >> $scriptlog 2>&1
50
51makedir $getstatuslogpath >> $scriptlog 2>&1
52
53cd $mars
54
55date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
56checklock0=$?
57case $checklock0 in
58 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
59 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
60 echo "-> fillcallisto is running -> exit" >> $scriptlog 2>&1
61 date >> $scriptlog 2>&1
62 exit;;
63 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
64esac
65
66echo "getting list..." >> $scriptlog 2>&1
67check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
68
69case $check0 in
70 1) echo "check0=$check0 -> everything ok -> run fillcallisto" >> $scriptlog 2>&1;;
71 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
72esac
73
74sequences=(`cat $todofile`)
75
76if [ "$sequences" = "" ]
77then
78 echo "nothing to do -> exit" >> $scriptlog 2>&1
79 rm -v $todofile >> $scriptlog 2>&1
80 rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
81 date >> $scriptlog 2>&1
82 exit
83fi
84
85echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
86
87for sequence in ${sequences[@]}
88do
89 no=`printf %08d $sequence | cut -c 0-4`
90 no2=`printf %08d $sequence`
91 path="$datapath/callisto/$no/$no2"
92 signalfile=$path/signal$no2.root
93 calibfile=$path/calib$no2.root
94 fillcallistologpath=$logpath/fillcallisto/$no
95 echo "fillcallistologpath: "$fillcallistologpath >> $scriptlog 2>&1
96 makedir $fillcallistologpath >> $scriptlog 2>&1
97 fillcaliblog=$fillcallistologpath/fillcalib-$sequence.log
98 fillsignallog=$fillcallistologpath/fillsignal-$sequence.log
99
100 echo "run fillcallisto for sequence $sequence" >> $scriptlog 2>&1
101 echo "run fillcalib..." >> $scriptlog 2>&1
102 check1=`root -q -b $macrospath/fillcalib.C+\("\"$calibfile\""\,kFALSE\) | tee $fillcaliblog | grep int | sed -e 's/(int)//'`
103
104 case $check1 in
105 1) echo "check1=$check1 -> everything ok -> run fillsignal " >> $scriptlog 2>&1;;
106 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
107 continue;;
108 esac
109
110 check2=`root -q -b $macrospath/fillsignal.C+\("\"$signalfile\""\,kFALSE\) | tee $fillsignallog | grep int | sed -e 's/(int)//'`
111 case $check2 in
112 1) echo "check2=$check2 -> everything ok " >> $scriptlog 2>&1
113 echo "-> inserting the status for fillcallisto for sequence $sequence into the db" >> $scriptlog 2>&1
114 setstatuslogpath=$logpath/setstatus/fillcallisto/$no
115 makedir $setstatuslogpath >> $scriptlog 2>&1
116 setstatuslog=$setstatuslogpath/setstatus-fillcallisto
117
118 check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog-$sequence.log | grep int | sed -e 's/(int)//'`
119 case $check4 in
120 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1;;
121 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
122 esac
123 ;;
124 *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
125 esac
126done
127
128rm -v $todofile >> $scriptlog 2>&1
129rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
130
131set +C
132
133date >> $scriptlog 2>&1
134
Note: See TracBrowser for help on using the repository browser.