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-2006
|
---|
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 controll 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 macros findcacofiles.C and insertcacofile.C
|
---|
43 | # - rawfiles
|
---|
44 | # The update in the database is done using the macro resetallruns.C
|
---|
45 | #
|
---|
46 |
|
---|
47 | user=`whoami`
|
---|
48 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
49 |
|
---|
50 | cd $mars
|
---|
51 | date=`date +%F`
|
---|
52 |
|
---|
53 | subsystemdir=/magic/subsystemdata
|
---|
54 | filesondisklogpath=$logpath/filesondisk/`date +%Y`
|
---|
55 | makedir $filesondisklogpath
|
---|
56 |
|
---|
57 |
|
---|
58 | echo "checking disk for ccfiles..."
|
---|
59 | filename=$filesondisklogpath/ccfilesondisk-$date.txt
|
---|
60 | column=fCCFileAvail
|
---|
61 | find $subsystemdir/cc/ -name '*_S.rep' | cut -d_ -f2 > $filename
|
---|
62 |
|
---|
63 | echo "resetting runs..."
|
---|
64 | check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
|
---|
65 |
|
---|
66 | case $check3 in
|
---|
67 | 1) echo "check3=$check3 -> everything ok -> reset is done";;
|
---|
68 | *) echo "check3=$check3 -> ERROR -> something went wrong while resetting";;
|
---|
69 | esac
|
---|
70 |
|
---|
71 |
|
---|
72 | echo "checking disk for cacofiles..."
|
---|
73 | filename=$filesondisklogpath/cacofilesondisk-$date.txt
|
---|
74 | column=fCaCoFileAvail
|
---|
75 | find $subsystemdir/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
|
---|
76 |
|
---|
77 | echo "resetting runs..."
|
---|
78 | check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
|
---|
79 |
|
---|
80 | case $check0 in
|
---|
81 | 1) echo "check0=$check0 -> everything ok -> reset is done";;
|
---|
82 | *) echo "check0=$check0 -> ERROR -> something went wrong while resetting";;
|
---|
83 | esac
|
---|
84 |
|
---|
85 | echo "checking missing cacofiles..."
|
---|
86 | check1=`root -q -b $macrospath/findcacofiles.C+\("\"$date\""\,"\"$filesondisklogpath\""\) | tee $filesondisklogpath/findcacofiles-$date.log | grep int | sed -e 's/(int)//'`
|
---|
87 |
|
---|
88 | case $check1 in
|
---|
89 | 1) echo "check1=$check1 -> everything ok -> missing cacofiles are found";;
|
---|
90 | *) echo "check1=$check1 -> ERROR -> something went wrong while resetting";;
|
---|
91 | esac
|
---|
92 |
|
---|
93 | missingcacoruns=(`cat $filesondisklogpath/findcacofiles-$date.txt`)
|
---|
94 | for missingcacorun in ${missingcacoruns[@]}
|
---|
95 | do
|
---|
96 | runno=$missingcacorun
|
---|
97 | echo "no cacofile found for run "$runno
|
---|
98 | echo "finding cacofile"
|
---|
99 | ccfile=`find $subsystemdir/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
|
---|
100 | echo "ccfile: "$ccfile
|
---|
101 | if [ "$ccfile" = "" ]
|
---|
102 | then
|
---|
103 | echo "no ccfile found for run "$runno
|
---|
104 | continue
|
---|
105 | fi
|
---|
106 | for (( i = 0; i <= 10; i++ ))
|
---|
107 | do
|
---|
108 | newrun=`echo $runno - $i | bc`
|
---|
109 | path=`dirname $ccfile`
|
---|
110 | path=`echo $path | sed -e 's/cc/caco/'`
|
---|
111 | cacofile=`find $path -name *$newrun*`
|
---|
112 | if [ "$cacofile" = "" ]
|
---|
113 | then
|
---|
114 | continue
|
---|
115 | else
|
---|
116 | echo "inserting cacofile $file for run $missingcacorun..."
|
---|
117 | check2=`root -q -b $macrospath/insertcacofile.C+\("\"$runno\""\,"\"$newrun\""\) | tee $filesondisklogpath/insertcacofile-$missingcacorun.log | grep int | sed -e 's/(int)//'`
|
---|
118 |
|
---|
119 | case $check2 in
|
---|
120 | 1) echo "check2=$check2 -> everything ok -> insert is done";;
|
---|
121 | *) echo "check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun;;
|
---|
122 | esac
|
---|
123 | break
|
---|
124 | fi
|
---|
125 | done
|
---|
126 | echo "cacofile: "$cacofile
|
---|
127 |
|
---|
128 | done
|
---|
129 |
|
---|
130 |
|
---|
131 | echo "checking disk for rawfiles..."
|
---|
132 | filename=$filesondisklogpath/rawfilesondisk-$date.txt
|
---|
133 | column=fRawFileAvail
|
---|
134 | find $datapath -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
|
---|
135 |
|
---|
136 | echo "resetting runs..."
|
---|
137 | check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
|
---|
138 |
|
---|
139 | case $check4 in
|
---|
140 | 1) echo "check4=$check4 -> everything ok -> reset is done";;
|
---|
141 | *) echo "check4=$check4 -> ERROR -> something went wrong while resetting";;
|
---|
142 | esac
|
---|
143 |
|
---|
144 |
|
---|