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

Last change on this file since 6940 was 6940, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.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#
22# Copyright: MAGIC Software Development, 2000-2004
23#
24#
25# ========================================================================
26#
27#
28
29export ROOTSYS=/opt/root_v3.10.02
30export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
31export PATH=$PATH:$ROOTSYS/bin
32
33set -C
34
35mars=/home/operator/Mars
36macrospath=$mars/datacenter/macros
37scriptspath=$mars/datacenter/scripts
38
39table=SequenceProcessStatus
40column=fFillCallisto
41date=NULL
42datetime=`date +%F-%H-%M-%S`
43year=`date +%Y`
44
45todofile=/magic/datacenter/lists/ToDo-$table-$column.txt
46lockpath=/magic/datacenter/locks
47logpath=/magic/datacenter/autologs
48getstatuslogpath=$logpath/getstatus/fillcallisto/$year
49getstatuslog=$getstatuslogpath/getstatus-fillcallisto-$datetime.log
50
51scriptlogpath=$logpath/run/fillcallisto/`date +%Y/%m/%d`
52if [ ! -d $scriptlogpath ]
53then
54 mkdir -pv $scriptlogpath
55 if [ ! -d $scriptlogpath ]
56 then
57 echo "could not make scriptlogpath "$scriptlogpath
58 exit
59 fi
60fi
61
62scriptlog=$scriptlogpath/runfillcallisto-$datetime.log
63
64date >> $scriptlog 2>&1
65
66
67if [ ! -d $getstatuslogpath ]
68then
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
76fi
77
78cd $mars
79
80date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
81checklock0=$?
82case $checklock0 in
83 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
84 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
85 echo "-> fillcallisto is running -> exit" >> $scriptlog 2>&1
86 date >> $scriptlog 2>&1
87 exit;;
88 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
89esac
90
91echo "getting list..." >> $scriptlog 2>&1
92check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
93
94case $check0 in
95 1) echo "check0=$check0 -> everthing ok -> run fillcallisto" >> $scriptlog 2>&1;;
96 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
97esac
98
99sequences=(`cat $todofile`)
100
101if [ "$sequences" = "" ]
102then
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
108fi
109
110echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
111
112for sequence in ${sequences[@]}
113do
114 no=`printf %08d $sequence | cut -c 4`
115 path="/magic/data/callisto/"`printf %04d $no`"/"`printf %08d $sequence`
116 signalfile=$path/signal`printf %08d $sequence`.root
117 calibfile=$path/calib`printf %08d $sequence`.root
118 fillcallistologpath=$logpath/fillcallisto/`printf %04d $no`
119 echo "fillcallistologpath: "$fillcallistologpath >> $scriptlog 2>&1
120 if [ ! -d $fillcallistologpath ]
121 then
122 mkdir -pv $fillcallistologpath >> $scriptlog 2>&1
123 if [ ! -d $fillcallistologpath ]
124 then
125 echo "could not make fillcallistologpath $fillcallistologpath -> continue " >> $scriptlog 2>&1
126 continue
127 fi
128 fi
129 fillcaliblog=$fillcallistologpath/fillcalib-$sequence.log
130 fillsignallog=$fillcallistologpath/fillsignal-$sequence.log
131
132 echo "run fillcallisto for sequence $sequence" >> $scriptlog 2>&1
133 echo "run fillcalib..." >> $scriptlog 2>&1
134 check1=`root -q -b $macrospath/fillcalib.C+\("\"$calibfile\""\,kFALSE\) | tee $fillcaliblog | grep int | sed -e 's/(int)//'`
135
136 case $check1 in
137 1) echo "check1=$check1 -> everthing ok -> run fillsignal " >> $scriptlog 2>&1;;
138 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
139 continue;;
140 esac
141
142 check2=`root -q -b $macrospath/fillsignal.C+\("\"$signalfile\""\,kFALSE\) | tee $fillsignallog | grep int | sed -e 's/(int)//'`
143 case $check2 in
144 1) echo "check2=$check2 -> everthing ok " >> $scriptlog 2>&1
145 echo "-> inserting the status for fillcallisto for sequence $sequence into the db" >> $scriptlog 2>&1
146 setstatuslogpath=$logpath/setstatus/fillcallisto/`printf %04d $no`
147 if [ ! -d $setstatuslogpath ]
148 then
149 mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
150 if [ ! -d $setstatuslogpath ]
151 then
152 echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
153 continue
154 fi
155 fi
156 setstatuslog=$setstatuslogpath/setstatus-fillcallisto
157 check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog-$sequence.log | grep int | sed -e 's/(int)//'`
158 case $check4 in
159 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
160 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
161 esac
162 ;;
163 *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
164 esac
165done
166
167rm -v $todofile >> $scriptlog 2>&1
168rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
169
170set +C
171
172date >> $scriptlog 2>&1
173
Note: See TracBrowser for help on using the repository browser.