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 |
|
---|
29 | export ROOTSYS=/opt/root_v3.10.02
|
---|
30 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
|
---|
31 | export PATH=$PATH:$ROOTSYS/bin
|
---|
32 |
|
---|
33 | set -C
|
---|
34 |
|
---|
35 | mars=/home/operator/Mars
|
---|
36 | macrospath=$mars/datacenter/macros
|
---|
37 | scriptspath=$mars/datacenter/scripts
|
---|
38 |
|
---|
39 | table=SequenceProcessStatus
|
---|
40 | column=fFillStar
|
---|
41 | date=NULL
|
---|
42 | datetime=`date +%F-%H-%M-%S`
|
---|
43 | year=`date +%Y`
|
---|
44 |
|
---|
45 | todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
|
---|
46 | lockpath=/magic/datacenter/locks
|
---|
47 | logpath=/magic/datacenter/autologs
|
---|
48 | getstatuslogpath=$logpath/getstatus/fillstar/$year
|
---|
49 | getstatuslog=$getstatuslogpath/getstatus-fillstar-$datetime.log
|
---|
50 |
|
---|
51 | scriptlogpath=$logpath/run/fillstar/`date +%Y/%m/%d`
|
---|
52 | if [ ! -d $scriptlogpath ]
|
---|
53 | then
|
---|
54 | mkdir -pv $scriptlogpath
|
---|
55 | if [ ! -d $scriptlogpath ]
|
---|
56 | then
|
---|
57 | echo "could not make scriptlogpath "$scriptlogpath
|
---|
58 | exit
|
---|
59 | fi
|
---|
60 | fi
|
---|
61 |
|
---|
62 | scriptlog=$scriptlogpath/runfillstar-$datetime.log
|
---|
63 |
|
---|
64 | date >> $scriptlog 2>&1
|
---|
65 |
|
---|
66 |
|
---|
67 | if [ ! -d $getstatuslogpath ]
|
---|
68 | then
|
---|
69 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
---|
70 | if [ ! -d $getstatuslogpath ]
|
---|
71 | then
|
---|
72 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
---|
73 | date >> $scriptlog 2>&1
|
---|
74 | exit
|
---|
75 | fi
|
---|
76 | fi
|
---|
77 |
|
---|
78 | cd $mars
|
---|
79 |
|
---|
80 | date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
81 | checklock0=$?
|
---|
82 | case $checklock0 in
|
---|
83 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
84 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
85 | echo "-> fillstar is running -> exit" >> $scriptlog 2>&1
|
---|
86 | date >> $scriptlog 2>&1
|
---|
87 | exit;;
|
---|
88 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
89 | esac
|
---|
90 |
|
---|
91 | echo "getting list..." >> $scriptlog 2>&1
|
---|
92 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
93 |
|
---|
94 | case $check0 in
|
---|
95 | 1) echo "check0=$check0 -> everthing ok -> run fillstar" >> $scriptlog 2>&1;;
|
---|
96 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
97 | esac
|
---|
98 |
|
---|
99 | sequences=(`cat $todofile`)
|
---|
100 |
|
---|
101 | if [ "$sequences" = "" ]
|
---|
102 | then
|
---|
103 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
104 | rm -v $todofile >> $scriptlog 2>&1
|
---|
105 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
106 | date >> $scriptlog 2>&1
|
---|
107 | exit
|
---|
108 | fi
|
---|
109 |
|
---|
110 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
---|
111 |
|
---|
112 | for sequence in ${sequences[@]}
|
---|
113 | do
|
---|
114 | no=`printf %08d $sequence | cut -c 4`
|
---|
115 | path="/magic/data/star/"`printf %04d $no`"/"`printf %08d $sequence`
|
---|
116 | starfile=$path/star`printf %08d $sequence`.root
|
---|
117 | fillstarlogpath=$logpath/fillstar/`printf %04d $no`
|
---|
118 | echo "fillstarlogpath: "$fillstarlogpath >> $scriptlog 2>&1
|
---|
119 | if [ ! -d $fillstarlogpath ]
|
---|
120 | then
|
---|
121 | mkdir -pv $fillstarlogpath >> $scriptlog 2>&1
|
---|
122 | if [ ! -d $fillstarlogpath ]
|
---|
123 | then
|
---|
124 | echo "could not make fillstarlogpath $fillstarlogpath -> continue " >> $scriptlog 2>&1
|
---|
125 | continue
|
---|
126 | fi
|
---|
127 | fi
|
---|
128 | fillstarlog=$fillstarlogpath/fillstar-$sequence.log
|
---|
129 |
|
---|
130 | echo "run fillstar for sequence $sequence" >> $scriptlog 2>&1
|
---|
131 | check2=`root -q -b $macrospath/fillstar.C+\("\"$starfile\""\,kFALSE\) | tee $fillstarlog | grep int | sed -e 's/(int)//'`
|
---|
132 | case $check2 in
|
---|
133 | 1) echo "check2=$check2 -> everthing ok " >> $scriptlog 2>&1
|
---|
134 | echo "-> inserting the status for fillstar for sequence $sequence into the db" >> $scriptlog 2>&1
|
---|
135 | setstatuslogpath=$logpath/setstatus/fillstar/`printf %04d $no`
|
---|
136 | if [ ! -d $setstatuslogpath ]
|
---|
137 | then
|
---|
138 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
---|
139 | if [ ! -d $setstatuslogpath ]
|
---|
140 | then
|
---|
141 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
---|
142 | continue
|
---|
143 | fi
|
---|
144 | fi
|
---|
145 | setstatuslog=$setstatuslogpath/setstatus-fillstar
|
---|
146 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog-$sequence.log | grep int | sed -e 's/(int)//'`
|
---|
147 | case $check4 in
|
---|
148 | 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
---|
149 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
---|
150 | esac
|
---|
151 | ;;
|
---|
152 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
153 | esac
|
---|
154 | done
|
---|
155 |
|
---|
156 | rm -v $todofile >> $scriptlog 2>&1
|
---|
157 | rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
|
---|
158 |
|
---|
159 | set +C
|
---|
160 |
|
---|
161 | date >> $scriptlog 2>&1
|
---|
162 |
|
---|