source: trunk/MagicSoft/Mars/datacenter/scripts/fillstar@ 7030

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