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-2007
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script checks which files are on disk and updates the database
|
---|
28 | # accordingly. It is not yet running automatically.
|
---|
29 | #
|
---|
30 | # It is checking the:
|
---|
31 | # - ccfiles
|
---|
32 | # - cacofiles
|
---|
33 | # this includes also the search for missing cacofiles:
|
---|
34 | # Sometimes the DAQ aborts a run and starts itself a new one. In this
|
---|
35 | # cases the camera control doesn't start a new file, as the command to
|
---|
36 | # start a new run was not sent by the central control. So the caco
|
---|
37 | # information is stored in the previous caco file, which has a
|
---|
38 | # different runnumber. To be able to merpp the information into the
|
---|
39 | # calibrated data file, the runnumber of the file containing the
|
---|
40 | # information has to be found.
|
---|
41 | # In this script the search and inserting into the database is done
|
---|
42 | # using the macro findcacofiles.C
|
---|
43 | # - rawfiles
|
---|
44 | # The update in the database is done using the macro resetallruns.C
|
---|
45 | #
|
---|
46 |
|
---|
47 | source `dirname $0`/sourcefile
|
---|
48 | printprocesslog "INFO starting $0"
|
---|
49 | program=filesondisk
|
---|
50 |
|
---|
51 | set -C
|
---|
52 |
|
---|
53 | scriptlog=$runlogpath/$program-$datetime.log
|
---|
54 | date >> $scriptlog 2>&1
|
---|
55 |
|
---|
56 | # check if script is already running
|
---|
57 | lockfile=$lockpath/lock-$program.txt
|
---|
58 | checklock >> $scriptlog 2>&1
|
---|
59 |
|
---|
60 | filesondisklogpath=$logpath/$program/`date +%Y/%m`
|
---|
61 | makedir $filesondisklogpath >> $scriptlog 2>&1
|
---|
62 |
|
---|
63 | cd $mars
|
---|
64 |
|
---|
65 | echo "checking disk for ccfiles..." >> $scriptlog 2>&1
|
---|
66 | printprocesslog "INFO checking ccfiles"
|
---|
67 | filename=$filesondisklogpath/ccfilesondisk-$datetime.txt
|
---|
68 | if ls $filename >/dev/null 2>&1
|
---|
69 | then
|
---|
70 | rm -v $filename >> $scriptlog 2>&1
|
---|
71 | fi
|
---|
72 | column=fCCFileAvail
|
---|
73 | find $subsystempath/cc/ -name '*_S.rep' | cut -d_ -f2 > $filename
|
---|
74 |
|
---|
75 | echo "resetting runs..." >> $scriptlog 2>&1
|
---|
76 | check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | intgrep`
|
---|
77 |
|
---|
78 | case $check3 in
|
---|
79 | 1) echo " check3=$check3 -> everything ok -> reset is done" >> $scriptlog 2>&1
|
---|
80 | printprocesslog "INFO ccfiles resetted successfully"
|
---|
81 | ;;
|
---|
82 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
83 | printprocesslog "WARN connection to DB failed"
|
---|
84 | ;;
|
---|
85 | *) echo " check3=$check3 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
|
---|
86 | printprocesslog "ERROR resettallruns.C failed for ccfiles"
|
---|
87 | ;;
|
---|
88 | esac
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | echo "checking disk for cacofiles..." >> $scriptlog 2>&1
|
---|
93 | printprocesslog "INFO checking cacofiles"
|
---|
94 | filename=$filesondisklogpath/cacofilesondisk-$datetime.txt
|
---|
95 | if ls $filename >/dev/null 2>&1
|
---|
96 | then
|
---|
97 | rm -v $filename >> $scriptlog 2>&1
|
---|
98 | fi
|
---|
99 | column=fCaCoFileAvail
|
---|
100 | find $subsystempath/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
|
---|
101 |
|
---|
102 | echo "resetting runs..." >> $scriptlog 2>&1
|
---|
103 | check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | intgrep`
|
---|
104 |
|
---|
105 | case $check0 in
|
---|
106 | 1) echo " check0=$check0 -> everything ok -> reset is done" >> $scriptlog 2>&1
|
---|
107 | printprocesslog "INFO cacofiles resetted successfully"
|
---|
108 | ;;
|
---|
109 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
110 | printprocesslog "WARN connection to DB failed"
|
---|
111 | ;;
|
---|
112 | *) echo " check0=$check0 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
|
---|
113 | printprocesslog "ERROR resettallruns.C failed for cacofiles"
|
---|
114 | ;;
|
---|
115 | esac
|
---|
116 |
|
---|
117 | date=`date +%F`
|
---|
118 | echo "finding missing cacofiles..." >> $scriptlog 2>&1
|
---|
119 | printprocesslog "INFO checking missing cacofiles"
|
---|
120 | check1=`root -q -b $macrospath/findcacofiles.C+ | tee $filesondisklogpath/findcacofiles-$datetime.log | intgrep`
|
---|
121 |
|
---|
122 | case $check1 in
|
---|
123 | 1) echo " check1=$check1 -> everything ok -> missing cacofiles are found" >> $scriptlog 2>&1
|
---|
124 | printprocesslog "INFO missing cacofiles found"
|
---|
125 | ;;
|
---|
126 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
127 | printprocesslog "WARN connection to DB failed"
|
---|
128 | ;;
|
---|
129 | *) echo " check1=$check1 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
|
---|
130 | printprocesslog "ERROR findcacofiles.C failed"
|
---|
131 | ;;
|
---|
132 | esac
|
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 | echo "checking disk for rawfiles..." >> $scriptlog 2>&1
|
---|
137 | printprocesslog "INFO checking rawfiles"
|
---|
138 | filename=$filesondisklogpath/rawfilesondisk-$datetime.txt
|
---|
139 | if ls $filename >/dev/null 2>&1
|
---|
140 | then
|
---|
141 | rm -v $filename >> $scriptlog 2>&1
|
---|
142 | fi
|
---|
143 | column=fRawFileAvail
|
---|
144 | find $datapath/rawfiles -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
|
---|
145 |
|
---|
146 | echo "resetting runs..." >> $scriptlog 2>&1
|
---|
147 | check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | intgrep`
|
---|
148 |
|
---|
149 | case $check4 in
|
---|
150 | 1) echo " check4=$check4 -> everything ok -> reset is done" >> $scriptlog 2>&1
|
---|
151 | printprocesslog "INFO rawfiles resetted successfully"
|
---|
152 | ;;
|
---|
153 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
154 | printprocesslog "WARN connection to DB failed"
|
---|
155 | ;;
|
---|
156 | *) echo " check4=$check4 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
|
---|
157 | printprocesslog "ERROR resettallruns.C failed for rawfiles"
|
---|
158 | ;;
|
---|
159 | esac
|
---|
160 |
|
---|
161 | finish >> $scriptlog 2>&1
|
---|
162 |
|
---|